// Scripts used on the order Foam
//////////////////////////////////////////////////////////////////////////////////////
function copyCHAddress(){

	// SH Address
	window.document.lgoCartForm.sh_address1.value = window.document.lgoCartForm.ch_address1.value;
	window.document.lgoCartForm.sh_address2.value = window.document.lgoCartForm.ch_address2.value;
	window.document.lgoCartForm.sh_address3.value = window.document.lgoCartForm.ch_address3.value;
	window.document.lgoCartForm.sh_postcode.value = window.document.lgoCartForm.ch_postcode.value;
	window.document.lgoCartForm.sh_country.value  = window.document.lgoCartForm.ch_country.value;
	
}
//////////////////////////////////////////////////////////////////////////////////////
function validateOrderForm() {
	
	// set flag to true as default
	var flag = true
	
	// Reset all old errors
		var element = document.getElementById('name');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('sname');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('email');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('phoneday');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('phoneeve');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('mobilephone');
		element.style.backgroundColor = '#FFFFFF';

		// CH Address
		var element = document.getElementById('ch_address1');
		element.style.backgroundColor = '#FFFFFF';
		
		var element = document.getElementById('ch_address2');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('ch_address3');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('ch_postcode');
		element.style.backgroundColor = '#FFFFFF';
		
		var element = document.getElementById('ch_country');
		element.style.backgroundColor = '#FFFFFF';
		
		// SH Address
		var element = document.getElementById('sh_address1');
		element.style.backgroundColor = '#FFFFFF';
		
		var element = document.getElementById('sh_address2');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('sh_address3');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('sh_postcode');
		element.style.backgroundColor = '#FFFFFF';
		
		var element = document.getElementById('sh_country');
		element.style.backgroundColor = '#FFFFFF';
		
		// Card Payment
		var element = document.getElementById('nameoncard');
		element.style.backgroundColor = '#FFFFFF';
		
		var element = document.getElementById('cardno');
		element.style.backgroundColor = '#FFFFFF';
				
		var element = document.getElementById('endmonth');
		element.style.backgroundColor = '#FFFFFF';
		
		var element = document.getElementById('endyear');
		element.style.backgroundColor = '#FFFFFF';

		var element = document.getElementById('securitycode');
		element.style.backgroundColor = '#FFFFFF';
		
		
	// Check if feild are filled in
	if (!window.document.lgoCartForm.name.value) {
		var element = document.getElementById('name');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.sname.value) {
		var element = document.getElementById('sname');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.email.value) {
		var element = document.getElementById('email');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.phoneday.value) {
		var element = document.getElementById('phoneday');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.phoneeve.value) {
		var element = document.getElementById('phoneeve');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.mobilephone.value) {
		var element = document.getElementById('mobilephone');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	
	// CH Address
	if (!window.document.lgoCartForm.ch_address1.value) {
		var element = document.getElementById('ch_address1');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.ch_address2.value) {
		var element = document.getElementById('ch_address2');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.ch_address3.value) {
		var element = document.getElementById('ch_address3');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.ch_postcode.value) {
		var element = document.getElementById('ch_postcode');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.ch_country.value) {
		var element = document.getElementById('ch_country');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	
	// SH Address
	if (!window.document.lgoCartForm.sh_address1.value) {
		var element = document.getElementById('sh_address1');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.sh_address2.value) {
		var element = document.getElementById('sh_address2');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.sh_address3.value) {
		var element = document.getElementById('sh_address3');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.sh_postcode.value) {
		var element = document.getElementById('sh_postcode');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.sh_country.value) {
		var element = document.getElementById('sh_country');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	
	// Card Payment
	if (!window.document.lgoCartForm.nameoncard.value) {
		var element = document.getElementById('nameoncard');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.cardno.value) {
		var element = document.getElementById('cardno');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.endmonth.value) {
		var element = document.getElementById('endmonth');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.endyear.value) {
		var element = document.getElementById('endyear');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}
	if (!window.document.lgoCartForm.securitycode.value) {
		var element = document.getElementById('securitycode');
		element.style.backgroundColor = '#FF3333';
		flag = false;
	}

	if(!flag) alert('Please check the red form feilds and end date of card.');
	
	// return flag
	return flag;
}
//////////////////////////////////////////////////////////////////////////////////////
