/* the following set up rules for behaviour.js */
	var site_rules = {
		'#SameAsBilling' : function(element) {
			element.onclick = function() {
				if (element.checked) {
					// copy all text field values and disable elements
					copyDetail('FirstName', true); copyDetail('LastName', true);
					copyDetail('Street', true); copyDetail('TownCity', true);
					copyDetail('County', true); copyDetail('PostCode', true);
					// copy select field and disable element
					$('#DeliveryCountryID').attr('selectedIndex', $('#BillingCountryID').attr('selectedIndex'));
					$('#DeliveryCountryID').attr('disabled', 'disabled');
				} else {
					// blank out all text field values and enable elements
					copyDetail('FirstName', false); copyDetail('LastName', false);
					copyDetail('Street', false); copyDetail('TownCity', false);
					copyDetail('County', false); copyDetail('PostCode', false);					
					// reset select field and enable element
					$('#DeliveryCountryID').attr('selectedIndex', 0);
					$('#DeliveryCountryID').attr('disabled', '');
				}
			}
		},
		'#style_selector' : function(element) {
			element.onchange = function() {
				$('#frm_selector').submit();
			}
		},
		'#BrochureSectionID' : function(element) {
			element.onchange = function() {
				$('#frm_selector').submit();
			}
		},
		'#CountyID' : function(element) {
			element.onchange = function() {
				$('#frm_selector').submit();
			}
		}
	}

	Behaviour.register(site_rules);
	
	function copyDetail(strName, blnDisable) {
		if (blnDisable) {
			$('#Delivery' + strName).attr('value', $('#Billing' + strName).attr('value'));
			$('#Delivery' + strName).attr('disabled', 'disabled');
		} else {
			$('#Delivery' + strName).attr('value', '');
			$('#Delivery' + strName).attr('disabled', '');
		}
	}
	
	