	//Populates the delivery address with the correct details
	function PopulateDeliveryFields( objValue ) {
	//inbound Avon Cottage Durrington Hill~Worthing~bn13 2py
	
	document.getElementById("deliveryAddress").style.display = "block";
	
	var objsplit = objValue.split("~")
	document.deliveryAddressBook.address1.value = objsplit[0];
	document.deliveryAddressBook.town.value = objsplit[1];
	var splittingPostcode = objsplit[2].split(" ")
	document.deliveryAddressBook.postcodeA.value = splittingPostcode[0];
	document.deliveryAddressBook.postcodeB.value = splittingPostcode[1];
	
	}

	//Open Close the layer
		function hidecheckout( action ) {
			document.getElementById("showCheckout").style.display = (action=="block") ? 'none' : 'block';
		}
	

	//Called from the banner process
	function stop() {
		alert("Please complete each step\n\nThe step you are trying to click on is not available until\nyou have completed the step before!")
	}

	//Called From Step 3 Cake stuff
	function checkFiletype( oForm ) {
	//if( eval(document.birthdaymessages.Thumb1_new) != "undefined") {
		fExt=document.birthdaymessages.Thumb1_new.value.substring(document.birthdaymessages.Thumb1_new.value.length-4,document.birthdaymessages.Thumb1_new.value.length);
			fExt=fExt.toLowerCase()
			if (fExt!='.jpg'&&fExt!='jpeg'&&fExt!='.gif'&&fExt!='') {
				fExtPrev=fExt;
		  	alert('The image that you upload must be a GIF or a JPEG\n\nThe file you are trying to upload is '+ fExt +'');
			  return false;
		}
		document.getElementById("showLoading").style.display = 'block';
	}
//	}

	//Called From Step 3 Cake stuff
	function countcharacters( oForm ) {
		len = document.birthdaymessages.messageType.value.length;
		content = document.birthdaymessages.messageType.value;
		newContent = content.substring(0, 50);
		if(len>50) {
			document.birthdaymessages.messageType.value = ""
			document.birthdaymessages.messageType.value = newContent;
		}
	document.getElementById("characters1").innerHTML = "Number of characters left " + (parseFloat(50) - parseFloat(document.birthdaymessages.messageType.value.length));
	
		len = document.birthdaymessages.birthdaymessage.value.length;
		content = document.birthdaymessages.birthdaymessage.value;
		newContent = content.substring(0, 50);
		if(len>50) {
			document.birthdaymessages.birthdaymessage.value = ""
			document.birthdaymessages.birthdaymessage.value = newContent;
		}
	document.getElementById("characters2").innerHTML = "Number of characters left " + (parseFloat(50) - parseFloat(document.birthdaymessages.birthdaymessage.value.length));
	}

	//Called From Step 3 Cake stuff
	function howmanyCharacters( oForm ) {
		var correct = true;
		if(oForm.birthdaymessage.value.length > 50) {
			correct = false;
			alert("Your message is too long, please check the number characters");
			}
		return correct;
		}


	//Called From Step 3 Cake stuff
	function showSize( oImg ) {
		if (yeahMan || (oImg.id.substr(0,5)=='Image' && oImg.id.length==6) || (oImg.id.substr(0,5)=='Thumb' && oImg.id.length==6)) {
			oImg.style.width = 'auto';		// allow image to be it's natural size so we can grab it's real dimensions
			document.getElementById(oImg.id + "_size").innerHTML = Math.floor((oImg.fileSize*1+1023)/1024) + "Kb (" + oImg.width + 'x' + oImg.height + ')';
			oImg.style.width = '75px';		// resize
		}
	}
	function countMyChar(i) {
		var	ii = i.length;
		if(ii>240) {alert("You have too many characters"); document.content.sellingMessagexx.value = i.substring(1,i.length-1)}
	}

	//Called from Customer screen Step 1
	function valForm( oForm ) {
	var correct = true;

	//Check the email address is correct
	//the length has to be .com .co.uk so at least s@aas.com 9
	if(oForm.email.value.length < 10) {
	correct = false;
	alert("Your email appears invalid");
		}

	//the email must contain at least the @ and at least one .
	if(oForm.email.value.indexOf('@') == -1 || oForm.email.value.indexOf('.') == -1) {
	correct = false;
	alert("Your email does not contain \'@\' or \'.\'");
		}
	if(oForm.email.value != oForm.email2.value) {
	correct = false;
	alert("YOUR email addresses do not match")
	}
	//if(oForm.username.value.length < 6) {
	//correct = false;
	//alert("YOU MUST ENTER A USERNAME! \n\nwhich needs to be 6 or more characters");
	//	}
	if(oForm.password.value.length < 6) {
	correct = false;
	alert("YOU MUST ENTER A PASSWORD! \n\nwhich needs to be 6 or more characters");
		}
	if(oForm.password.value != oForm.password2.value) {
	correct = false;
	alert("Your passwords do not match");
		}
	if(correct == true) {
		return validateForm( oForm );
		}
	return correct;
	}
	function openTerms() {
	window.open('checkout/popTerms.asp?pageID=125', 'newWindow', 'width=600,height=600');
	}
	