var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
 var i;
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        
        if (((c < "0") || (c > "9"))) {
        	return false;
        }
    }
    return true;
}

function stripCharsInBag(s, bag){
 var i;
    var returnString = "";
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) {
        	returnString += c;
        }
    }
    return returnString;
}

function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
 for (var i = 1; i <= n; i++) {
  this[i] = 31;
  if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
  if (i==2) {this[i] = 29;}
   }
   return this;
}

function isDate(dtStr){
 var daysInMonth = new DaysArray(12)
 var pos1=dtStr.indexOf(dtCh)
 var pos2=dtStr.indexOf(dtCh,pos1+1)
 var strDay=dtStr.substring(0,pos1)
 var strMonth=dtStr.substring(pos1+1,pos2)
 var strYear=dtStr.substring(pos2+1)
 strYr=strYear
 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
 for (var i = 1; i <= 3; i++) {
  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
 }
 month=parseInt(strMonth)
 day=parseInt(strDay)
 year=parseInt(strYr)
 if (pos1==-1 || pos2==-1){
  alert("Please select the date you would like to receive your order.")
  return false
 }
 if (strMonth.length<1 || month<1 || month>12){
  alert("Please enter a valid month")
  return false
 }
 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
  alert("Please enter a valid day")
  return false
 }
 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
  alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
  return false
 }
 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
  alert("Please enter a valid date")
  return false
 }
return true
}




/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all;

function restrictinput(maxlength,e,placeholder)
{
	if (window.event&&event.srcElement.value.length>=maxlength) {
		return false;
	}
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength)
	{
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
		if (pressedkey.test(String.fromCharCode(e.which))) {
			e.stopPropagation();
		}
	}
}

function countlimit(maxlength,e,placeholder){
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
		if (window.event||e.target&&e.target==eval(placeholder)){
			if (lengthleft<0)
			theform.value=theform.value.substring(0,maxlength)
			placeholderobj.innerHTML=lengthleft
		}
}


function displaylimit(thename, theid, thelimit){
	var theform=theid!=""? document.getElementById(theid) : thename
	var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining in total'
	if (document.all||ns6)
		document.write(limit_text)
	if (document.all){
		eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
		eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
		document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
	}
}


function checkbox2ShowHide(obj,groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("itemname8").value = "";
	}
}



function checkboxShowHide(obj, groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
		document.getElementById("flavours_item27ShowHide").style.display = "none";
		document.getElementById("itemname4a").checked = false;
		document.getElementById("cupcake20").value = "0";
		
		calculateCupcake(30,11,2007);

	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("cupcake1").value = "0";
		document.getElementById("cupcake2").value = "0";
		document.getElementById("cupcake3").value = "0";
		document.getElementById("cupcake4").value = "0";
		document.getElementById("cupcake5").value = "0";
		document.getElementById("cupcake6").value = "0";
		document.getElementById("cupcake7").value = "0";
		document.getElementById("cupcake8").value = "0";
		document.getElementById("cupcake9").value = "0";

		
		calculateCupcake(30,11,2007);
	}
}

function checkbox3ShowHide(obj,groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
		document.getElementById("flavours_item25ShowHide").style.display = "none";
		document.getElementById("itemname4b").checked = false;
		document.getElementById("cupcake1").value = "0";
		document.getElementById("cupcake2").value = "0";
		document.getElementById("cupcake3").value = "0";
		document.getElementById("cupcake4").value = "0";
		document.getElementById("cupcake5").value = "0";
		document.getElementById("cupcake6").value = "0";
		document.getElementById("cupcake7").value = "0";
		document.getElementById("cupcake8").value = "0";
		document.getElementById("cupcake9").value = "0";
		
		calculateCupcake(30,11,2007);

	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("cupcake20").value = "0";
		
		calculateCupcake(30,11,2007);
	}
}


function checkbox4ShowHide(obj, groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
		document.getElementById("flavours_item27ShowHide").style.display = "none";
		document.getElementById("itemname4a").checked = false;
		document.getElementById("cupcake20").value = "0";
		
		calculateCupcake(30,11,2007);

	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("cupcake1").value = "0";
		document.getElementById("cupcake2").value = "0";
		document.getElementById("cupcake3").value = "0";
		document.getElementById("cupcake4").value = "0";
		document.getElementById("cupcake5").value = "0";
		document.getElementById("cupcake6").value = "0";
		document.getElementById("cupcake7").value = "0";
		document.getElementById("cupcake8").value = "0";
		document.getElementById("cupcake9").value = "0";
		document.getElementById("cupcake10").value = "0";
		document.getElementById("cupcake11").value = "0";
		document.getElementById("cupcake12").value = "0";
		document.getElementById("cupcake13").value = "0";
		document.getElementById("cupcake14").value = "0";
		document.getElementById("cupcake15").value = "0";
		document.getElementById("cupcake16").value = "0";
		
		calculateCupcake(30,11,2007);
	}
}


function checkbox5ShowHide(obj,groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
		document.getElementById("flavours_item25ShowHide").style.display = "none";
		document.getElementById("itemname4b").checked = false;
		document.getElementById("cupcake1").value = "0";
		document.getElementById("cupcake2").value = "0";
		document.getElementById("cupcake3").value = "0";
		document.getElementById("cupcake4").value = "0";
		document.getElementById("cupcake5").value = "0";
		document.getElementById("cupcake6").value = "0";
		document.getElementById("cupcake7").value = "0";
		document.getElementById("cupcake8").value = "0";
		document.getElementById("cupcake9").value = "0";
		document.getElementById("cupcake10").value = "0";
		document.getElementById("cupcake11").value = "0";
		document.getElementById("cupcake12").value = "0";
		document.getElementById("cupcake13").value = "0";
		document.getElementById("cupcake14").value = "0";
		document.getElementById("cupcake15").value = "0";
		document.getElementById("cupcake16").value = "0";
		
		calculateCupcake(30,11,2007);

	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("cupcake20").value = "0";
		
		calculateCupcake(30,11,2007);
	}
}




function checkbox6ShowHide(obj, groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
		document.getElementById("flavours_item31ShowHide").style.display = "none";
		document.getElementById("itemname4a").checked = false;
		document.getElementById("cupcake20").value = "0";
		
		calculateCupcake(30,11,2007);

	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("cupcake1").value = "0";
		document.getElementById("cupcake2").value = "0";
		document.getElementById("cupcake3").value = "0";
		
		calculateCupcake(30,11,2007);
	}
}



function checkbox7ShowHide(obj,groupName) {
	// if checking, show group
	if (document.getElementById(obj.id).checked) {
		document.getElementById(groupName + "ShowHide").style.display = "inline";
		document.getElementById("flavours_item30ShowHide").style.display = "none";
		document.getElementById("itemname4b").checked = false;
		document.getElementById("cupcake1").value = "0";
		document.getElementById("cupcake2").value = "0";
		document.getElementById("cupcake3").value = "0";

		calculateCupcake(30,11,2007);

	}

	// if unchecking, hide group
	else {
		document.getElementById(groupName + "ShowHide").style.display = "none";
		document.getElementById("cupcake20").value = "0";
		
		calculateCupcake(30,11,2007);
	}
}


var className;

if(window.ActiveXObject) {
	className = "className";
}
else {
	className = "class";
}


// page 1: when changing between PICKUP and DELIVERY options, show/hide form fields accordingly 
function deliveryMethod_func(source) { 

        if (source.getElementById("deliveryMethod").value == "DELIVERY") { // delivery 
                source.getElementById("pickup_div").style.display = "none"; 
                source.getElementById("delivery_div").style.display = "inline"; 
                source.getElementById("timed_delivery_div").style.display = "none";                             
                source.getElementById("X2itemname3").value = ""; 
                source.getElementById("X2itemname5").value = ""; 
                               
        } else if (source.getElementById("deliveryMethod").value == "TIMED DELIVERY") { // timed delivery 
                source.getElementById("pickup_div").style.display = "none";     
                source.getElementById("delivery_div").style.display = "none"; 
                source.getElementById("timed_delivery_div").style.display = "inline"; 
                source.getElementById("X2itemname3").value = ""; 
                source.getElementById("X2itemname5").value = "";                 
                                
        } else if (source.getElementById("deliveryMethod").value == "PICKUP") { // timed delivery 
                source.getElementById("pickup_div").style.display = "inline";   
                source.getElementById("timed_delivery_div").style.display = "none";             
                source.getElementById("delivery_div").style.display = "none"; 
                source.getElementById("X2itemname4").value = ""; 
                
        }
        else {
		source.getElementById("pickup_div").style.display = "none";   
		source.getElementById("timed_delivery_div").style.display = "none";             
		source.getElementById("delivery_div").style.display = "none"; 
		source.getElementById("X2itemname4").value = ""; 
                source.getElementById("X2itemname3").value = ""; 
                source.getElementById("time").value = ""; 
                                
        }
} 



function writeMonthOptions() 
{ 

        var today = new Date(); 
	var splitTime = (13*60)+59;
		
	var DSThours = today.getUTCHours();

	var nowTime = ((DSThours+1)*60) + today.getUTCMinutes();

	if (nowTime > splitTime) {
	
		today.setDate(today.getUTCDate()+1);		
	}
	
        var actualday = today.getUTCDay(); 
        var actualmonth = today.getUTCMonth(); 
        var date = today.getUTCDate(); 
        var year = today.getUTCFullYear(); 

	if (actualday < 0) actualday = 6;
	if (actualday > 6) actualday = 0;
	

    for (dateCounter = 0; dateCounter < 150; dateCounter++) 
    { 

                date++; 
                actualday++; 

                if (actualday === 7){ 
                        actualday = 0; 
                } 

                if (actualmonth === 0 && date === 32) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 1 && date === 29) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 2 && date === 32) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 3 && date === 31) { 
                actualmonth++; 
                date = 1; 
                } 
                
                if (actualmonth === 4 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }               
                
                if (actualmonth === 5 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }               

                if (actualmonth === 6 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 7 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 8 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 9 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }         
                
                if (actualmonth === 10 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }     
                
                if (actualmonth === 11 && date === 32) { 
                actualmonth = 0; 
                date = 1; 
                year++;
                }      
                
                
                var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
                var months = new Array("January","February","March","April","May"," June","July","August","September","October","November","December");

                var day = days[actualday]; 
                var month = months[actualmonth]; 


                if ((actualmonth == 11) || (actualmonth == 2) || (actualmonth == 3) || (actualmonth == 4) || (actualmonth == 5) || (actualmonth == 6) || (actualmonth == 7) || (actualmonth == 8) || (actualmonth == 9) || (actualmonth == 10)) {

                }             
                else if (actualday != 0) { 

                        var printmonth = actualmonth + 1; 

                        if (date == 1 || date == 2 || date == 3 || date == 4 || date == 5 || date == 6 || date == 7 || date == 8 || date == 9) {

                                date = "0" + date; 
                } 

		        document.write('<OPTION value=' + date + '/' + printmonth + '/' + year + '>' + day + ', ' + date + ' ' + month + ' ' + year);

                } 
    } 

}


function writeCakeMonthOptions() 
{ 

        var today = new Date(); 
	var splitTime = (13*60)+59;
	
	var DSThours = today.getUTCHours();
	
	var nowTime = ((DSThours+1)*60) + today.getUTCMinutes();

	today.setDate(today.getUTCDate()+1);

	if (nowTime > splitTime) {

		today.setDate(today.getDate()+1);
	}
			
        var actualday = today.getUTCDay(); 
        var actualmonth = today.getUTCMonth(); 
        var date = today.getUTCDate(); 
        var year = today.getUTCFullYear(); 

	if (actualday < 0) actualday = 6;
	if (actualday > 6) actualday = 0;
	

    for (dateCounter = 0; dateCounter < 150; dateCounter++) 
    { 

                date++; 
                actualday++; 

                if (actualday === 7){ 
                        actualday = 0; 
                } 

                if (actualmonth === 0 && date === 32) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 1 && date === 29) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 2 && date === 32) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 3 && date === 31) { 
                actualmonth++; 
                date = 1; 
                } 
                
                if (actualmonth === 4 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }               
                
                if (actualmonth === 5 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }               

                if (actualmonth === 6 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 7 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 8 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 9 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }         
                
                if (actualmonth === 10 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }     
                
                if (actualmonth === 11 && date === 32) { 
                actualmonth = 0; 
                date = 1; 
                year++;
                }      
                
                
                var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
                var months = new Array("January","February","March","April","May"," June","July","August","September","October","November","December");

                var day = days[actualday]; 
                var month = months[actualmonth]; 


                if ( (actualmonth == 11) || (actualmonth == 2) || (actualmonth == 3) || (actualmonth == 4) || (actualmonth == 5) || (actualmonth == 6) || (actualmonth == 7) || (actualmonth == 8) || (actualmonth == 9) || (actualmonth == 10)) {

                }             
                else if (actualday != 0) { 

                        var printmonth = actualmonth + 1; 

                        if (date == 1 || date == 2 || date == 3 || date == 4 || date == 5 || date == 6 || date == 7 || date == 8 || date == 9) {

                                date = "0" + date; 
                } 

		        document.write('<OPTION value=' + date + '/' + printmonth + '/' + year + '>' + day + ', ' + date + ' ' + month + ' ' + year);

                } 
    } 

}



function writeValentinesMonthOptions() 
{ 

        var today = new Date(); 

	var splitTime = (13*60)+59;
	var nowTime = (today.getUTCHours()*60) + today.getUTCMinutes();

	if (nowTime > splitTime) {

		today.setUTCDate(today.getUTCDate()+1);
	}
	
        var actualday = today.getUTCDay(); 
        var actualmonth = today.getUTCMonth(); 
        var date = today.getUTCDate(); 
        var year = today.getUTCFullYear(); 

	if (actualday < 0) actualday = 6;
	if (actualday > 6) actualday = 0;
	

    for (dateCounter = 0; dateCounter < 150; dateCounter++) 
    { 

                date++; 
                actualday++; 

                if (actualday === 7){ 
                        actualday = 0; 
                } 

                if (actualmonth === 0 && date === 32) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 1 && date === 29) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 2 && date === 32) { 
                actualmonth++; 
                date = 1; 
                } 

                if (actualmonth === 3 && date === 31) { 
                actualmonth++; 
                date = 1; 
                } 
                
                if (actualmonth === 4 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }               
                
                if (actualmonth === 5 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }               

                if (actualmonth === 6 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 7 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 8 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }  
                
                if (actualmonth === 9 && date === 32) { 
                actualmonth++; 
                date = 1; 
                }         
                
                if (actualmonth === 10 && date === 31) { 
                actualmonth++; 
                date = 1; 
                }     
                
                if (actualmonth === 11 && date === 32) { 
                actualmonth = 1; 
                date = 1; 
                year++;
                }                     
                
                
                var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
                var months = new Array("January","February","March","April","May"," June","July","August","September","October","November","December");

                var day = days[actualday]; 
                var month = months[actualmonth]; 


                if ((actualmonth == 11 && date == 02) || (actualmonth == 01 && date == 13) || (actualmonth == 01 && date == 12) || (actualmonth == 11) || (actualmonth == 3) || (actualmonth == 4) || (actualmonth == 5) || (actualmonth == 6) || (actualmonth == 7) || (actualmonth == 8) || (actualmonth == 9) || (actualmonth == 10)) {

                }             
                else if (actualday != 0) { 

                        var printmonth = actualmonth + 1; 

                        if (date == 1 || date == 2 || date == 3 || date == 4 || date == 5 || date == 6 || date == 7 || date == 8 || date == 9) {

                                date = "0" + date; 
                } 

		        document.write('<OPTION value=' + date + '/' + printmonth + '/' + year + '>' + day + ', ' + date + ' ' + month + ' ' + year);

                } 
    } 

}


function getSameDay() 
{
        var today = new Date(); 
        var actualday = today.getDay(); 
        var actualmonth = today.getMonth(); 
        var date = today.getDate(); 
        var year = today.getFullYear(); 	


	var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
	var months = new Array("January","February","March","April","May"," June","July","August","September","October","November","December");

	var day = days[actualday]; 
	var month = months[actualmonth]; 

	if ((actualmonth == 11 && date == 02) || (actualmonth == 4 && date == 5) || (actualmonth == 4 && date == 26)  || (actualmonth == 7 && date == 25)  || (actualmonth == 2 && date == 24) || (actualmonth == 1 && date == 13) || (actualmonth == 1 && date == 14)  || (actualmonth == 2 && date == 1) || (actualmonth == 11 && date == 26) || (actualmonth == 11 && date == 27) || (actualmonth == 11 && date == 28) || (actualmonth == 11 && date == 29) || (actualmonth == 11 && date == 31) || (actualmonth == 0 && date == 1) || (actualmonth == 0 && date == 2) || (actualmonth == 0 && date == 3) || (actualmonth == 0 && date == 4) || (actualmonth == 0 && date == 5) || (actualmonth == 0 && date == 6)) {

	}             
	else if (actualday != 0) { 

		var printmonth = actualmonth + 1; 

		if (date == 1 || date == 2 || date == 3 || date == 4 || date == 5 || date == 6 || date == 7 || date == 8 || date == 9) {

			date = "0" + date; 
		} 
	}
	
	
	var yesterday = new Date(); 
	yesterday.setDate(today.getDate()-1);

	var yesterdayday = yesterday.getDay(); 
	var yesterdaymonth = yesterday.getMonth(); 
	var yesterdaydate = yesterday.getDate(); 
	var yesterdayyear = yesterday.getFullYear(); 

	var yestday = days[yesterdayday]; 
	var yestmonth = months[yesterdaymonth]; 


	if ((actualmonth == 6 && date == 12)){
	}             
	else if (actualday != 0) { 

		var printtommonth = yesterdaymonth + 1; 

		if (yesterdaydate == 1 || yesterdaydate == 2 || yesterdaydate == 3 || yesterdaydate == 4 || yesterdaydate == 5 || yesterdaydate == 6 || yesterdaydate == 7 || yesterdaydate == 8 || yesterdaydate == 9) {

			yesterdaydate = "0" + yesterdaydate; 
		} 
	}


	document.write('<OPTION value=' + yesterdaydate + '/' + printtommonth + '/' + yesterdayyear + '>' + yestday + ', ' + yesterdaydate + ' ' + yestmonth + ' ' + yesterdayyear);	

	document.write('<OPTION value=' + date + '/' + printmonth + '/' + year + '>' + day + ', ' + date + ' ' + month + ' ' + year);


	var tomorrow = new Date(); 
	tomorrow.setDate(today.getDate()+1);
	
        var tomorrowday = tomorrow.getDay(); 
        var tomorrowmonth = tomorrow.getMonth(); 
        var tomorrowdate = tomorrow.getDate(); 
        var tomorrowyear = tomorrow.getFullYear(); 
        
	var tomday = days[tomorrowday]; 
	var tommonth = months[tomorrowmonth]; 


        if ((actualmonth == 6 && date == 12)){
	}             
	else if (actualday != 0) { 

		var printtommonth = tomorrowmonth + 1; 

		if (tomorrowdate == 1 || tomorrowdate == 2 || tomorrowdate == 3 || tomorrowdate == 4 || tomorrowdate == 5 || tomorrowdate == 6 || tomorrowdate == 7 || tomorrowdate == 8 || tomorrowdate == 9) {

			tomorrowdate = "0" + tomorrowdate; 
		} 
	}
	
	document.write('<OPTION value=' + tomorrowdate + '/' + printtommonth + '/' + tomorrowyear + '>' + tomday + ', ' + tomorrowdate + ' ' + tommonth + ' ' + tomorrowyear);	
} 



function getToday() 
{ 

        var today = new Date(); 
        var actualday = today.getDay(); 
        var actualmonth = today.getMonth(); 
        var date = today.getDate(); 
        var year = today.getFullYear(); 
	

	var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
	var months = new Array("January","February","March","April","May"," June","July","August","September","October","November","December");

	var day = days[actualday]; 
	var month = months[actualmonth]; 

	if ((actualmonth == 9 && date == 16) || (actualmonth == 9 && date == 17) || (actualmonth == 8 && date == 9) || (actualmonth == 3 && date == 10) || (actualmonth == 3 && date == 13) || (actualmonth == 4 && date == 5) || (actualmonth == 4 && date == 26)  || (actualmonth == 7 && date == 25)  || (actualmonth == 2 && date == 24) || (actualmonth == 1 && date == 13) || (actualmonth == 1 && date == 14)  || (actualmonth == 2 && date == 1) || (actualmonth == 11 && date == 26) || (actualmonth == 11 && date == 27) || (actualmonth == 11 && date == 31) || (actualmonth == 0 && date == 1) || (actualmonth == 0 && date == 2) || (actualmonth == 0 && date == 3) || (actualmonth == 0 && date == 4) || (actualmonth == 0 && date == 5) || (actualmonth == 0 && date == 6)) {

	}             
	else if (actualday != 0) { 

		var printmonth = actualmonth + 1; 

		if (date == 1 || date == 2 || date == 3 || date == 4 || date == 5 || date == 6 || date == 7 || date == 8 || date == 9) {

			date = "0" + date; 
		} 
	} 

	document.write('<OPTION value=' + date + '/' + printmonth + '/' + year + '>' + day + ', ' + date + ' ' + month + ' ' + year);

}

function getGrams(product) {

	count = 0;
	var total = document.getElementById("tubTotal");
	var qty = document.getElementById("quantity").value;
	var cakeName = "no cakes";


	if (product == "cupcakes{0.75}") {
		
		grams = document.getElementById("tubQuantity").value = 75;
		count = grams * qty;
		cakeName = "regular cupcake (s)";
	}

	if (product == "tiny cupcakes{0.45}") {
		
		grams = document.getElementById("tubQuantity").value = 40;
		count = grams * qty;
		cakeName = "tiny cupcake (s)";		
	}

	if (product == "7' round cupcake cake{15.00}") {
		
		grams = document.getElementById("tubQuantity").value = 960;
		count = grams * qty;
		cakeName = "7' round cupcake cake (s)";
	}

	if (product == "9' round cupcake cake{25.00}") {
		
		grams = document.getElementById("tubQuantity").value = 1845;
		count = grams * qty;
		cakeName = "9' round cupcake cake (s)";		
	}

	if (product == "11' heart cupcake cake{35.00}") {
		
		grams = document.getElementById("tubQuantity").value = 2500;
		count = grams * qty;
		cakeName = "11' heart cupcake cake (s)";		
	}
	
	if (product == "12' square cupcake cake{45.00}") {
		
		grams = document.getElementById("tubQuantity").value = 2500;
		count = grams * qty;
		cakeName = "12' square cupcake cake (s)";		
	}
	
	if (product == "giant cupcake{35.00}") {
		
		grams = document.getElementById("tubQuantity").value = 1365;
		count = grams * qty;
		cakeName = "giant cupcake (s)";		
	}
		
	
	total.firstChild.nodeValue = count;
	document.getElementById("tubQuantity").value = count;
	
	typeCake.firstChild.nodeValue = cakeName;
	document.getElementById("cakeType").value = cakeName;

	qtyCake.firstChild.nodeValue = qty;
	document.getElementById("cakeQty").value = qty;		
	
	tubQty = count / 100;		
	tubQty = tubQty.toFixed(1);	
	tubNo.firstChild.nodeValue = tubQty;
	document.getElementById("noOfTubs").value = tubQty;	
	
	largeTubQty =  count / 600;
	largeTubQty = largeTubQty.toFixed(1);	
	largeTubNo.firstChild.nodeValue = largeTubQty;
	document.getElementById("noOfLargeTubs").value = largeTubQty;	
}

function pickTinyBottles(form) {

	var a = form.tinybottle1.value;
	var b = form.tinybottle2.value;
	var c = form.tinybottle3.value;
	var d = form.tinybottle4.value;
	var e = form.tinybottle5.value;
	var f = form.tinybottle6.value;
	var g = form.tinybottle7.value;
	var h = form.tinybottle8.value;
	var i = form.tinybottle9.value;
	var j = form.tinybottle10.value;
	var k = form.tinybottle11.value;
	var l = form.tinybottle12.value;

	var tinybottles = "";
	count = 0;

	funBottlePrice = 0.95;
	naturalBottlePrice = 0.75;

	price = 0;


	if (form.tinybottle1.value != "0") {
		tinybottles = tinybottles + "silver balls (" + a + "), ";
		count += (a*1);
		price += funBottlePrice*a;				
	}

	if (form.tinybottle2.value != "0") {
		tinybottles = tinybottles + "butterfly sprinkles (" + b + "), ";
		count += (b*1);
		price += funBottlePrice*b;				
	}

	if (form.tinybottle3.value != "0") {
		tinybottles = tinybottles + "blue & white stars (" + c + "), ";
		count += (c*1);	
		price += funBottlePrice*c;				
	}

	if (form.tinybottle4.value != "0") {
		tinybottles = tinybottles + "walnuts (" + d + "), ";
		count += (d*1);	
		price += funBottlePrice*d;				
	}

	if (form.tinybottle5.value != "0") {
		tinybottles = tinybottles + "dark chocolate bits (" + e + "), ";
		count += (e*1);
		price += funBottlePrice*e;				
	}

	if (form.tinybottle6.value != "0") {
		tinybottles = tinybottles + "white vermicelli (" + f + "), ";
		count += (f*1);	
		price += funBottlePrice*f;				
	}

	if (form.tinybottle7.value != "0") {
		tinybottles = tinybottles + "peanuts (pecan) (" + g + "), ";
		count += (g*1);	
		price += funBottlePrice*g;				
	}

	if (form.tinybottle8.value != "0") {
		tinybottles = tinybottles + "milk chocolate vermicelli (" + h + "), ";
		count += (h*1);
		price += funBottlePrice*h;				
	}

	if (form.tinybottle9.value != "0") {
		tinybottles = tinybottles + "red velvet crumbs (" + i + "), ";
		count += (i*1);
		price += funBottlePrice*i;				
	}

	if (form.tinybottle10.value != "0") {
		tinybottles = tinybottles + "mini smarties (" + j + "), ";
		count += (j*1);
		price += funBottlePrice*j;				
	}			

	if (form.tinybottle11.value != "0") {
		tinybottles = tinybottles + "coconut (" + k + "), ";
		count += (k*1);
		price += funBottlePrice*k;				
	}

	if (form.tinybottle12.value != "0") {
		tinybottles = tinybottles + "milk chocolate bits (" + l + "), ";
		count += (l*1);
		price += funBottlePrice*l;				
	}			

	var tinyBottlesLength = tinybottles.length;
	alltinyBottles = tinybottles.slice(0,tinyBottlesLength-2);

	document.getElementById("X5itemname2").value = alltinyBottles;			
	document.getElementById("X5quantity").value = count;
	document.getElementById("X5price").value = funBottlePrice;
}


function pickRegularBottles(form) {

	var a = form.regularbottle1.value;
	var b = form.regularbottle2.value;
	var c = form.regularbottle3.value;
	var d = form.regularbottle4.value;
	var e = form.regularbottle5.value;
	var f = form.regularbottle6.value;
	var g = form.regularbottle7.value;
	var h = form.regularbottle8.value;
	var i = form.regularbottle9.value;
	var j = form.regularbottle10.value;
	var k = form.regularbottle11.value;
	var l = form.regularbottle12.value;

	var regularbottles = "";
	count = 0;

	funBottlePrice = 1.95;
	naturalBottlePrice = 1.35;

	price = 0;


	if (form.regularbottle1.value != "0") {
		regularbottles = regularbottles + "silver balls (" + a + "), ";
		count += (a*1);
		price += funBottlePrice*a;				
	}

	if (form.regularbottle2.value != "0") {
		regularbottles = regularbottles + "butterfly sprinkles (" + b + "), ";
		count += (b*1);
		price += funBottlePrice*b;				
	}

	if (form.regularbottle3.value != "0") {
		regularbottles = regularbottles + "blue & white stars (" + c + "), ";
		count += (c*1);	
		price += funBottlePrice*c;				
	}

	if (form.regularbottle4.value != "0") {
		regularbottles = regularbottles + "walnuts (" + d + "), ";
		count += (d*1);	
		price += funBottlePrice*d;				
	}

	if (form.regularbottle5.value != "0") {
		regularbottles = regularbottles + "dark chocolate bits (" + e + "), ";
		count += (e*1);
		price += funBottlePrice*e;				
	}

	if (form.regularbottle6.value != "0") {
		regularbottles = regularbottles + "white vermicelli (" + f + "), ";
		count += (f*1);	
		price += funBottlePrice*f;				
	}

	if (form.regularbottle7.value != "0") {
		regularbottles = regularbottles + "peanuts (pecan) (" + g + "), ";
		count += (g*1);	
		price += funBottlePrice*g;				
	}

	if (form.regularbottle8.value != "0") {
		regularbottles = regularbottles + "milk chocolate vermicelli (" + h + "), ";
		count += (h*1);
		price += funBottlePrice*h;				
	}

	if (form.regularbottle9.value != "0") {
		regularbottles = regularbottles + "red velvet crumbs (" + i + "), ";
		count += (i*1);
		price += funBottlePrice*i;				
	}

	if (form.regularbottle10.value != "0") {
		regularbottles = regularbottles + "mini smarties (" + j + "), ";
		count += (j*1);
		price += funBottlePrice*j;				
	}			

	if (form.regularbottle11.value != "0") {
		regularbottles = regularbottles + "coconut (" + k + "), ";
		count += (k*1);
		price += funBottlePrice*k;				
	}

	if (form.regularbottle12.value != "0") {
		regularbottles = regularbottles + "milk chocolate bits (" + l + "), ";
		count += (l*1);
		price += funBottlePrice*l;				
	}			

	var regularBottlesLength = regularbottles.length;
	allregularBottles = regularbottles.slice(0,regularBottlesLength-2);

	document.getElementById("X4itemname2").value = allregularBottles;			
	document.getElementById("X4quantity").value = count;
	document.getElementById("X4price").value = funBottlePrice;
}



function pickGiantBottles(form) {

	var a = form.giantbottle1.value;
	var b = form.giantbottle2.value;
	var c = form.giantbottle3.value;
	var d = form.giantbottle4.value;
	var e = form.giantbottle5.value;
	var f = form.giantbottle6.value;
	var g = form.giantbottle7.value;
	var h = form.giantbottle8.value;
	var i = form.giantbottle9.value;
	var j = form.giantbottle10.value;
	var k = form.giantbottle11.value;
	var l = form.giantbottle12.value;

	var giantbottles = "";
	count = 0;

	funBottlePrice = 8.50;
	naturalBottlePrice = 5.50;

	price = 0;


	if (form.giantbottle1.value != "0") {
		giantbottles = giantbottles + "silver balls (" + a + "), ";
		count += (a*1);
		price += funBottlePrice*a;				
	}

	if (form.giantbottle2.value != "0") {
		giantbottles = giantbottles + "butterfly sprinkles (" + b + "), ";
		count += (b*1);
		price += funBottlePrice*b;				
	}

	if (form.giantbottle3.value != "0") {
		giantbottles = giantbottles + "blue & white stars (" + c + "), ";
		count += (c*1);	
		price += funBottlePrice*c;				
	}

	if (form.giantbottle4.value != "0") {
		giantbottles = giantbottles + "walnuts (" + d + "), ";
		count += (d*1);	
		price += funBottlePrice*d;				
	}

	if (form.giantbottle5.value != "0") {
		giantbottles = giantbottles + "dark chocolate bits (" + e + "), ";
		count += (e*1);
		price += funBottlePrice*e;				
	}

	if (form.giantbottle6.value != "0") {
		giantbottles = giantbottles + "white vermicelli (" + f + "), ";
		count += (f*1);	
		price += funBottlePrice*f;				
	}

	if (form.giantbottle7.value != "0") {
		giantbottles = giantbottles + "peanuts (pecan) (" + g + "), ";
		count += (g*1);	
		price += funBottlePrice*g;				
	}

	if (form.giantbottle8.value != "0") {
		giantbottles = giantbottles + "milk chocolate vermicelli (" + h + "), ";
		count += (h*1);
		price += funBottlePrice*h;				
	}

	if (form.giantbottle9.value != "0") {
		giantbottles = giantbottles + "red velvet crumbs (" + i + "), ";
		count += (i*1);
		price += funBottlePrice*i;				
	}

	if (form.giantbottle10.value != "0") {
		giantbottles = giantbottles + "mini smarties (" + j + "), ";
		count += (j*1);
		price += funBottlePrice*j;				
	}			

	if (form.giantbottle11.value != "0") {
		giantbottles = giantbottles + "coconut (" + k + "), ";
		count += (k*1);
		price += funBottlePrice*k;				
	}

	if (form.giantbottle12.value != "0") {
		giantbottles = giantbottles + "milk chocolate bits (" + l + "), ";
		count += (l*1);
		price += funBottlePrice*l;				
	}			

	var giantBottlesLength = giantbottles.length;
	allGiantBottles = giantbottles.slice(0,giantBottlesLength-2);

	document.getElementById("X3itemname2").value = allGiantBottles;			
	document.getElementById("X3quantity").value = count;
	document.getElementById("X3price").value = funBottlePrice;
}


function valid(form) { 

		var code = "blank";
		
		if (document.getElementById("admincode")) {
		
			code = document.getElementById("admincode").value;
		}
		
		
		if (form.type.value == "makeyourown") {
		
			var item = document.getElementById("product").value;

			if (item == "cupcakes{0.75}") {
								
				document.getElementById("itemname").value = "Unfinished Cupcakes";
				document.getElementById("itemname2").value = "cupcake size{0.75}";
			}
			
			if (item == "tiny cupcakes{0.45}") {
								
				document.getElementById("itemname").value = "Unfinished Cupcakes";
				document.getElementById("itemname2").value = "tiny cupcake size{0.45}";
			}
			
			if (item == "7' round cupcake cake{15.00}") {
												
				document.getElementById("itemname").value = "Unfinished Cupcake Cake";
				document.getElementById("itemname2").value = "7' round{15.00}";
			}
			
			if (item == "9' round cupcake cake{25.00}") {
								
				document.getElementById("itemname").value = "Unfinished Cupcake Cake";
				document.getElementById("itemname2").value = "9' round{25.00}";
			}
			
			if (item == "11' heart cupcake cake{35.00}") {
								
				document.getElementById("itemname").value = "Unfinished Cupcake Cake";
				document.getElementById("itemname2").value = "11' heart{35.00}";
			}
			
		  	if (item == "12' square cupcake cake{45.00}") {
								
				document.getElementById("itemname").value = "Unfinished Cupcake Cake";
				document.getElementById("itemname2").value = "12' square{45.00}";
			}
			
			if (item == "giant cupcake{35.00}") {
								
				document.getElementById("itemname").value = "Showgirl Giant Cupcake";
				document.getElementById("itemname2").value = "showgirl{35.00}";
			}			
			
			x1qty = document.getElementById("X1quantity").value;
			
			if (x1qty !== 0) {

				pickMakeYourOwnIcingFlavours();
			
			}
		}	
		
			
		if (form.type.value == "cupcakes") {


			if (form.style.value == "specials") {

				var size = document.getElementById("itemname3").value;
				var total = document.getElementById("quantity").value;
				var qty = parseInt(total);

				if (size == "tiny cupcake size{1.25}") {
				
					if (qty % 12 !== 0) {
						alert ("Please ensure you order tiny cupcakes in multiples of 12.");
						return false;
						
					} else if (qty < 24) {
						alert ("Please ensure you order a minimum of 24 tiny cupcakes.");
						return false;
					}
				}

				else {	
					if (qty == 0) {			
						alert ("Please enter the quantity of cupcakes you'd like to purchase.");
						return false;
					
					} else if (qty % 6 !== 0) {
						alert ("Please ensure you order your cupcakes in multiples of 6  (i.e. 6, 12, 18, 30, 36, 42, etc)");
						return false;
						
					} else if (qty < 12) {
						alert ("Please ensure you order a minimum of 12 regular cupcakes.");
						return false;
					}
				}
			}
			
			else if (form.style.value == "mosaic") {

				var totalCakes = document.getElementById("quantity").value;
				var qtyCakes = parseInt(totalCakes);
				
				var size = document.getElementById("X1itemname3").value;

				var total = document.getElementById("X1quantity").value;
				var qty = parseInt(total);


				if (qtyCakes == 0) {			
					alert ("Please enter the quantity of PICTURE GALLERY cakes you'd like.");
					return false;
				}

				if (qty % 6 !== 0) {
					alert ("Please ensure you order your extra cupcakes in multiples of 6  (i.e. 6, 12, 18, 30, 36, 42, etc)");
					return false;
				}

			}

			else if (form.style.value != "KMQ") {

				var size = document.getElementById("itemname3").value;

				var total = document.getElementById("quantity").value;
				var qty = parseInt(total);


				if (code != "lolasrulez") {

					if (size == "tiny cupcake size{0.90}") {
						if (qty % 12 !== 0) {
							alert ("Please ensure you order tiny cupcakes in multiples of 12.");
							return false;
						}
					}

					if (size == "tiny cupcake size{1.10}") {
						if (qty % 12 !== 0) {
							alert ("Please ensure you order tiny cupcakes in multiples of 12.");
							return false;
						}
					}


					else if (size == "tiny cupcake size{1.50}") {
						if (qty % 12 !== 0) {
							alert ("Please ensure you order tiny cupcakes in multiples of 12.");
							return false;
						}
					}

					else if (size == "tiny cupcake size{1.30}") {
						if (qty % 12 !== 0) {
							alert ("Please ensure you order tiny cupcakes in multiples of 12.");
							return false;
						}
					}		

					else if (size == "tiny cupcake size{1.40}") {
						if (qty % 12 !== 0) {
							alert ("Please ensure you order tiny cupcakes in multiples of 12.");
							return false;
						}
					}	

					else if (size == "tiny cupcake size{1.25}") {
						if (qty % 12 !== 0) {
							alert ("Please ensure you order tiny cupcakes in multiples of 12.");
							return false;
						}
					}

					else {	
						if (qty == 0) {			
							alert ("Please enter the quantity of cupcakes you'd like to purchase.");
							return false;
						}

						else if (qty % 6 !== 0) {
							alert ("Please ensure you order your cupcakes in multiples of 6  (i.e. 6, 12, 18, 30, 36, 42, etc)");
							return false;
						}

					}
				}
			}
		}


		if (form.personalised.value == "yes") {

			document.getElementById("itemname8").value = "";
			document.getElementById("itemname9").value = "";
			
			var personalisation = document.getElementById("X1quantity").value;
			var writing = document.getElementById("itemname8").value;			

			if (document.getElementById("my_div").innerHTML != "") {

				for (i = 1; i <= personalisation; i++){
					var personalisedCupcake = document.getElementById("mytext" + i).value;				

					if (i<personalisation) {
						writing += personalisedCupcake + "/";
					} else if (i==personalisation) {
						writing += personalisedCupcake;
					}
				}
			}

			document.getElementById("itemname8").value = writing;
						
			var total = document.getElementById("quantity").value;
			var qty = parseInt(total);
			var personalqty = parseInt(personalisation);
						
			if((personalisation != "0") && (document.getElementById("itemname8").value == "")) {
				alert ("You have requested personalisation on your cupcakes but have not specified the text - please amend.");
				return false;
			}
			

			if(personalisation !== "0") {
				document.getElementById("itemname9").value = personalisation + " personalised cupcakes";
			}


			if (personalqty > qty) {
				alert ("You have ordered " + personalqty + " personalised cupcakes but only " + qty + " cupcake flavours - please amend.");
				return false;
			}


			if (writing !== "") {
				if (personalqty == 0) {
					alert ("You have requested personalisation on your cupcakes but have not specified how many you would like - please amend.");
					return false;
				}
			}
		}



		if (form.style.value == "signature") {		

			pickSignatureFlavours(form);

		} else if (form.style.value == "retail"){

			pickRetailFlavours(form);

		} else if (form.style.value == "bespoke"){

			pickBespokeFlavours(form);

		} else if (form.style.value == "specials"){	

			pickSpecialFlavours(form);		

		} else if (form.style.value == "shamrock"){	

			pickShamrockFlavours(form);		

		} else if (form.style.value == "giant"){	

			pickGiantCupcakeCakeFlavours(form);		

		} else if (form.style.value == "gu"){	

			pickGuFlavours(form);

		} else if (form.style.value == "fixedflavours"){	

			pickFixedFlavours(form);

		} else if (form.style.value == "oscars"){	

			pickOscarsFlavours(form);

		}  else if (form.style.value == "royalwedding"){	

			pickRoyalWeddingFlavours(form);

		} else if (form.style.value == "cherryblossom"){	

			pickCherryBlossomFlavours(form);

		} else if (form.style.value == "hellmanns"){	

			pickHellmannsFlavours(form);

		}  else if (form.style.value == "dad"){	

			pickDADFlavours(form);

		} else if (form.style.value == "4thJuly"){	

			pick4thJuly(form);
			
		} else if (form.style.value == "football"){	

			pickFootball(form);
			
		} else if (form.style.value == "manuka"){	

			pickMannuka(form);

		} else if (form.style.value == "fruit"){	

			pickFruit(form);
		
		} else if (form.style.value == "blackbottom"){	

			pickBlackBottom(form);
			
		} else if (form.style.value == "bff"){	

			pickBFF(form);

		} else if (form.style.value == "dessert"){	

			pickDessert(form);
				
		} else if (form.style.value == "bonfire"){	
			
			pickBonfire(form);
									
		} else if (form.style.value == "KMQ"){	
			
			pickKMQ(form);
									
		}  else if (form.style.value == "tennis"){	

			pickTennisFlavours(form);
			
		}  else if (form.style.value == "mosaic"){	

			pickMosaicFlavours(form);
			pickMosaicExtrasFlavours(form);

		}  else if (form.style.value == "makeyourown"){	

			pickMakeYourOwnFlavours(form);		
		}


		if (form.type.value == "layercakes") {


			if (document.getElementById("itemname2").value == "vanilla") {

				if (document.getElementById("itemname4_vanilla").value == "") {
					alert("Please choose the icing colour you would like on your vanilla cake.");
					return false;

				} else {
					document.getElementById("itemname4").value = document.getElementById("itemname4_vanilla").value;
				}

			} else {
				document.getElementById("itemname4").value = "";
			}
		}	


		if (form.type.value == "cupcakecakes") {

			var cakeSize = document.getElementById("itemname2a").value;

			if (cakeSize == "") {
				alert ("Please choose a cake size!");
				return false;
			}  


			var styleP = document.getElementsByName("personalisationStyle");
			
			for (var i=0; i < styleP.length; i++) {

				if (styleP[i].checked) {
					var personalisationStyle = styleP[i].value;
				}
			}
			
			
			if (personalisationStyle == "edibleImage") {

				document.getElementById("itemname8").value = "add edible image{4.00}";

			} else if (personalisationStyle == "writing") {

				document.getElementById("itemname8").value = document.getElementById("itemname8_writing").value;
			}	

			var personalisation = document.getElementById("itemname8").value;
			var personalisationLength = personalisation.length;
			var qty = parseInt(personalisationLength);
			
			if (cakeSize == "number cake{90.00}") {
				var numberCake = document.getElementById("itemname2b").value;
				document.getElementById("itemname2").value = numberCake;
			} else {
				document.getElementById("itemname2").value = cakeSize;
			}			


			if (code != "lolasrulez") {

				if (cakeSize == "7' round{35.00}") {
					if (qty > 14) {
						alert ("We can't fit more than 14 characters onto a 7' cake - please amend.");
						return false;
					}
				}  

				else if (cakeSize == "9' round{55.00}") {
					if (qty > 25) {
						alert ("We can't fit more than 25 characters onto a 9' cake - please amend.");
						return false;
					}
				}

				else {
					if (qty > 40) {
						alert ("We can't fit more than 45 characters onto a cake - please amend.");
						return false;
					}
				}
			}
		}	


	var option = document.getElementById("deliveryOption").value;

	if (option == "added") {
		document.getElementById("X2itemname").value = "";
		document.getElementById("X2itemname2").value = "";
		document.getElementById("X2itemname3").value = "";
		document.getElementById("X2itemname4").value = "";
		document.getElementById("X2itemname5").value = "";
	}

	if(option == "notadded") {
		
		
	var postcodesEligibleForLDLArray = document.getElementById("LDLPostcodes").value;
	var postcodesEligibleForLDL = postcodesEligibleForLDLArray.split('#'); 						

	var postcodesEligibleForTimedArray = document.getElementById("TimedPostcodes").value;
	var postcodesEligibleForTimed = postcodesEligibleForTimedArray.split('#'); 						

	var postcodesEligibleForLocalArray = document.getElementById("LocalPostcodes").value;
	var postcodesEligibleForLocal = postcodesEligibleForLocalArray.split('#'); 						


	var dateIsValid = false; 

	var dt=document.bespoke.X2itemname2; 		

	if (isDate(dt.value) === false){ 
		return dateIsValid; 
	}

	dateIsValid = true; 

	if (dateIsValid === true) { 
				
		var newDate = dt.value;

		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var matchArray = newDate.match(datePat);

		day = matchArray[1];
		month = matchArray[3];
		year = matchArray[5];	

		var correctmonth = month-1;
		
		var dateToCheck = new Date(); 
		dateToCheck.setYear(year);
		dateToCheck.setMonth(correctmonth);
		dateToCheck.setDate(day);			
					
					
		if(document.getElementById("deliveryMethod").value == "PICKUP") { 

			var collectionTime = form.X2itemname3.value; 
			document.getElementById("X2itemname5").value = "you're collecting from LOLA's Mayfair (Lansdowne Row)";
			
			document.getElementById("FirstName").value = " ";
			document.getElementById("LastName").value = " ";
			document.getElementById("Address1").value = " ";
			document.getElementById("Address2").value = " ";
			document.getElementById("Town").value = " ";
			document.getElementById("Postcode").value = "";
			document.getElementById("Country").value = " ";
			document.getElementById("CompanyName").value = " ";
			
			document.getElementById("DFirstName").value = " ";
			document.getElementById("DLastName").value = " ";
			document.getElementById("DAddress1").value = "16 Lansdowne Row";
			document.getElementById("DAddress2").value = "Berkeley Square";
			document.getElementById("DTown").value = "London";
			document.getElementById("DPostcode").value = "W1J 8QF";
			document.getElementById("DCountry").value = "United Kingdom";
			document.getElementById("DCompanyName").value = "LOLAs Mayfair";



			if (code != "lolasrulez") {

				if (collectionTime === "") { 
					alert("Please select the time you would like us to have your order ready."); 
					return false; 
				} 				

				else { 
					size = collectionTime.length; 

					if (size > 4) { 
						collectionTime = collectionTime.substr(12,17);size = collectionTime.length; 
					} 

					if (confirm("Thanks, its no problem to have your order ready at " + collectionTime + ".\nCollection is from LOLA's Mayfair, 16 Lansdowne Row, Berkeley Square, W1J 8QF")) { 
						document.getElementById("X2itemname").value = "Collection"; 
						return true; 
					} 
					else { 
						return false; 
					}                       

					document.getElementById("X2itemname").value = "Collection";
				}
			} 
			
			else { 
				size = collectionTime.length; 

				if (size > 4) { 
					collectionTime = collectionTime.substr(12,17);size = collectionTime.length; 
				} 

				if (confirm("Thanks, its no problem to have your order ready at " + collectionTime + ".")) { 
					document.getElementById("X2itemname").value = "Collection"; 
					return true; 
				} 
				else { 
					return false; 
				}                       

				document.getElementById("X2itemname").value = "Collection";
			}	
		}



		else if(document.getElementById("deliveryMethod").value == "DELIVERY") { 

			var X2price = ""; 

			var eligibleForLDL= false; 
			var eligibleForTimed = false; 
			var eligibleForLocal = false; 


			var field = form.postcodeInput.value; 
			size = field.length; 
			userPostcode = field.toUpperCase(); 


			while (userPostcode.slice(0,1) == " ") 
			{userPostcode = userPostcode.substr(1,size-1);size = userPostcode.length; 
			} 

			while(userPostcode.slice(size-1,size)== " ") 
			{userPostcode = userPostcode.substr(0,size-1);size = userPostcode.length; 
			} 

			if (size > 3){ 
			userPostcode = userPostcode.substr(0,4);size = userPostcode.length; 
			} 

			if (size < 2 || size > 5){ 
			alert(userPostcode + " is not a valid postcode - wrong length"); 
			return false; 
			} 

			if (!(isNaN(userPostcode.charAt(0)))){ 
			alert(userPostcode + " is not a valid postcode - cannot start with a number"); 
			return false; 
			} 



			for (i = 0; i<postcodesEligibleForLDL.length; i++) { 
				if (userPostcode == postcodesEligibleForLDL[i]) { 
					eligibleForLDL = true; 
				} 
			}


			for (i = 0; i<postcodesEligibleForLocal.length; i++) { 
				if (userPostcode == postcodesEligibleForLocal[i]) { 
					eligibleForLocal = true; 
				} 
			}                 



			for (i = 0; i<postcodesEligibleForTimed.length; i++) { 
				if (userPostcode == postcodesEligibleForTimed[i]) { 
					eligibleForTimed = true; 
				} 
			} 



			if (!userPostcode) { 
				alert("You must enter a delivery postcode if you would like LOLA's to deliver." + userPostcode);

				return false; 
			} 

			else if (eligibleForLDL) { 

				var postcodeArrayLDL = document.getElementById("postcodeArrayLDL").value;								
				var postcodeJSArrayLDL = postcodeArrayLDL.split('#'); 				
				
				var prices=[];
				
				for(i = 0; i < postcodeJSArrayLDL.length-1; i++) {
					var postcodePrice = postcodeJSArrayLDL[i].replace(/ /g,'').split(":");
					prices[ postcodePrice[0] ]  =postcodePrice[1];
				}								
					
				X2price = prices[userPostcode];													
				
				var mobileNumber = form.mobile.value; 

				if (mobileNumber == "") {
					mobileNumber = "mobile number not provided";
				}
		
				document.getElementById("X2itemname4").value = "LOLAS DOES LONDON, " + userPostcode + ", " + mobileNumber + "{" + X2price + "}";
				document.getElementById("X2itemname").value = "Delivery"; 

				var answer = confirm(userPostcode + " is eligible for this delivery service and will cost £" + X2price + ".");

				if (answer) 
				return true; 
				else 
				return false; 
			} 
			else if (eligibleForLocal) { 
			
				var mobileNumber = form.mobile.value; 

				if (mobileNumber == "") {
					mobileNumber = "mobile number not provided";
				}
					
				document.getElementById("X2itemname4").value = "LOLAS DOES LONDON, " + userPostcode + ", " + mobileNumber + "{0}"; 
				document.getElementById("X2itemname").value = "Delivery";                         


				var answer = confirm(userPostcode + " is eligible for free hand delivery!  Please proceed to place your order.");

				if (answer) 
				return true; 
				else 
				return false; 
			} 
			else if (eligibleForTimed) { 

				var postcodeArray = document.getElementById("postcodeArray").value;								
				var postcodeJSArray = postcodeArray.split('#'); 				
				
				var prices=[];
				
				for(i = 0; i < postcodeJSArray.length-1; i++) {
					var postcodePrice = postcodeJSArray[i].replace(/ /g,'').split(":");
					prices[ postcodePrice[0] ]  =postcodePrice[1];
				}								
					
				X2price = prices[userPostcode];													
				
				var mobileNumber = form.mobile.value; 

				if (mobileNumber == "") {
					mobileNumber = "mobile number not provided";
				}
		
				document.getElementById("X2itemname4").value = "delivery, " + userPostcode + ", " + mobileNumber + "{" + X2price + "}";
				document.getElementById("X2itemname").value = "Delivery"; 

				var answer = confirm(userPostcode + " is not eligible for our standard delivery service, but we can arrange a same day courier for £" + X2price + ".");


				if (answer) 
				return true; 
				else 
				return false;                   
			} 

			else { 
				alert(userPostcode + " is outside of our delivery area and the charge will be more than £30.\n\nIf you're still interested, please call us to arrange a same day courier or you can collect from the bakery.");

				return false; 
			} 
		} 

		else if(document.getElementById("deliveryMethod").value == "TIMED DELIVERY") { 


			var eligibleForTimed = false; 

			var field = form.postcode2.value; 
			size = field.length; 
			userPostcode = field.toUpperCase(); 


			while (userPostcode.slice(0,1) == " ") 
			{userPostcode = userPostcode.substr(1,size-1);size = userPostcode.length; 
			} 

			while(userPostcode.slice(size-1,size)== " ") 
			{userPostcode = userPostcode.substr(0,size-1);size = userPostcode.length; 
			} 

			if (size > 3){ 
			userPostcode = userPostcode.substr(0,4);size = userPostcode.length; 
			} 

			if (size < 2 || size > 5){ 
			alert(userPostcode + " is not a valid postcode - wrong length"); 
			return false; 
			} 

			if (!(isNaN(userPostcode.charAt(0)))){ 
			alert(userPostcode + " is not a valid postcode - cannot start with a number"); 
			return false; 
			} 



			for (i = 0; i<postcodesEligibleForTimed.length; i++) { 
				if (userPostcode == postcodesEligibleForTimed[i]) { 
					eligibleForTimed = true; 
				} 
			}
			

			if (!userPostcode) { 
				alert("You must enter a delivery postcode if you would like LOLA's to deliver." + userPostcode);

				return false; 
			} 

			else if (eligibleForTimed) { 


				var postcodeArray = document.getElementById("postcodeArray").value;								
				var postcodeJSArray = postcodeArray.split('#'); 				
				
				var prices=[];
				
				for(i = 0; i < postcodeJSArray.length-1; i++) {
					var postcodePrice = postcodeJSArray[i].replace(/ /g,'').split(":");
					prices[ postcodePrice[0] ]  =postcodePrice[1];
				}								
					
				X2price = prices[userPostcode];	
				
				
				var time = form.time.value; 
				var mobileNumber = form.mobile2.value; 

				if (mobileNumber == "") {
					mobileNumber = "mobile number not provided";
				}
					
				document.getElementById("X2itemname4").value = "deadline delivery, " + time + ", " + userPostcode + ", " + mobileNumber + "{" + X2price + "}";
				document.getElementById("X2itemname").value = "Delivery"; 
				

				if (time == "") { 
					var answer = confirm("We can deliver to " + userPostcode + " for a fee of £" + X2price + " (inc VAT).");


					if (answer) 
					return true; 
					else 
					return false; 

				} 
				else { 
					var answer = confirm("We can deliver to " + userPostcode + " at " + time  + " for a fee of £" + X2price + " (inc VAT).");

					if (answer) 
					return true; 
					else 
					return false; 
				}                       
			} 

			else { 
				alert(userPostcode + " is outside of our delivery area and the charge will be more than £30.  \n\nIf you're still interested, please call us to arrange a same day courier or you can collect from the bakery.");
				return false; 
			} 
		}
		else {
			alert ("Please select a delivery or collection option");
			return false;
			}
		}
	}
}


function pickGuFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "Gü cupcakes (" + a + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}



function pickFixedFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/3 + "), ";
		flavours = flavours + "chocolate (" + a/3 + "), ";
		flavours = flavours + "oreo (" + a/6 + "), ";
		flavours = flavours + "rocky road (" + a/6 + "), ";	
	}
					
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickOscarsFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "red velvet (" + a/2 + "), ";	
	}
					
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickMosaicFlavours(form) {

	var a = form.cupcake1.value;
	a=a*12;
	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "chocolate (" + a/2 + "), ";	
	}
					
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickMosaicExtrasFlavours(form) {

	var a = form.X1quantity.value;
	var flavours = "";

	
	if (form.X1quantity.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "chocolate (" + a/2 + "), ";	
	}
					
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("X1itemname5").value = allFlavours;
}

function pickRoyalWeddingFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "blue velvet (" + a/2 + "), ";	
	}
					
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickCherryBlossomFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "cherry blossom (" + a + "), ";
	}
					
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickHellmannsFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "hellmanns (" + a + "), ";
	}
					
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickDADFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/3 + "), ";
		flavours = flavours + "chocolate (" + a/3 + "), ";
		flavours = flavours + "oreo (" + a/3 + "), ";			
	}
					
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickTennisFlavours(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "strawberry (" + a/2 + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickMannuka(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "manuka honey (" + a/2 + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickBlackBottom(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "heart blackbottom (" + a + "), ";
	}
	
	if (form.cupcake2.value != "0") {
		flavours = flavours + "milk blackbottom (" + b + "), ";
	}	

	if (form.cupcake3.value != "0") {
		flavours = flavours + "milk and white blackbottom (" + c + "), ";
	}

	if (form.cupcake4.value != "0") {
		flavours = flavours + "white blackbottom (" + d + "), ";
	}	
	
	if (form.cupcake5.value != "0") {
		flavours = flavours + "blackforest blackbottom (" + e + "), ";
	}
	
	if (form.cupcake6.value != "0") {
		flavours = flavours + "cappuccino blackbottom (" + f + "), ";
	}
	
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}



function pickFruit(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "raspberry (" + a + "), ";
	}
	
	if (form.cupcake2.value != "0") {
		flavours = flavours + "blueberry (" + b + "), ";
	}	

	if (form.cupcake3.value != "0") {
		flavours = flavours + "passionfruit (" + c + "), ";
	}

	if (form.cupcake4.value != "0") {
		flavours = flavours + "banana (" + d + "), ";
	}	
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}



function pickBFF(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "sticky toffee (" + a/2 + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickBonfire(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pickKMQ(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}


function pick4thJuly(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "red velvet (" + a/2 + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickFootball(form) {

	var a = form.cupcake1.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a/2 + "), ";
		flavours = flavours + "chocolate (" + a/2 + "), ";
	}
				
		
	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;

	var flavours = "";

	
	if(document.getElementById("itemname4a").checked) {

		if (form.cupcake1.value !== 0) {
			flavours = "assorted flavours  ";
		}

		document.getElementById("itemname5").value = flavours;
	}
	
	if(document.getElementById("itemname4b").checked) {
	
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "oreo (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "peanut butter (" + h + "), ";
		}

		if (form.cupcake9.value != "0") {
			flavours = flavours + "strawberry (" + i + "), ";
		}
				
		}			
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
}


function pickDessert(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;
	var j = form.cupcake10.value;
	var k = form.cupcake11.value;
	var l = form.cupcake12.value;

	var flavours = "";

	if (form.cupcake1.value != "0") {
		flavours = flavours + "vanilla (" + a + "), ";
	}

	if (form.cupcake2.value != "0") {
		flavours = flavours + "chocolate (" + b + "), ";
	}

	if (form.cupcake3.value != "0") {
		flavours = flavours + "carrot (" + c + "), ";
	}

	if (form.cupcake4.value != "0") {
		flavours = flavours + "banana (" + d + "), ";
	}

	if (form.cupcake5.value != "0") {
		flavours = flavours + "lemon (" + e + "), ";
	}

	if (form.cupcake6.value != "0") {
		flavours = flavours + "red velvet (" + f + "), ";
	}

	if (form.cupcake7.value != "0") {
		flavours = flavours + "van milk choc (" + g + "), ";
	}

	if (form.cupcake8.value != "0") {
		flavours = flavours + "choc milk (" + h + "), ";
	}		

	if (form.cupcake9.value != "0") {
		flavours = flavours + "peanut butter (" + i + "), ";
	}			

	if (form.cupcake10.value != "0") {
		flavours = flavours + "strawberry (" + j + "), ";
	}

	if (form.cupcake11.value != "0") {
		flavours = flavours + "rocky road (" + k + "), ";
	}

	if (form.cupcake12.value != "0") {
		flavours = flavours + "oreo (" + l + "), ";
	}			


	var flavoursLength = flavours.length;
	allFlavours = flavours.slice(0,flavoursLength-2);

	document.getElementById("itemname5").value = allFlavours;
}

function pickRetailFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;
	var j = form.cupcake10.value;
	var k = form.cupcake11.value;
	var l = form.cupcake12.value;
	var m = form.cupcake13.value;
	var n = form.cupcake14.value;
	var o = form.cupcake15.value;
	var p = form.cupcake16.value;

	var flavours = "";

	
	if(document.getElementById("itemname4a").checked) {

		if (form.cupcake1.value !== 0) {
			flavours = "assorted flavours";
		}

		document.getElementById("itemname5").value = flavours;
	}
	
	if(document.getElementById("itemname4b").checked) {
	
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "banana chocolate (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "van milk choc (" + h + "), ";
		}		
		
		if (form.cupcake9.value != "0") {
			flavours = flavours + "choc milk (" + i + "), ";
		}			
		
		if (form.cupcake10.value != "0") {
			flavours = flavours + "choc coconut (" + j + "), ";
		}
		
		if (form.cupcake11.value != "0") {
			flavours = flavours + "coconut (" + k + "), ";
		}
		
		if (form.cupcake12.value != "0") {
			flavours = flavours + "peanut butter (" + l + "), ";
		}			
		
		if (form.cupcake13.value != "0") {
			flavours = flavours + "strawberry (" + m + "), ";
		}

		if (form.cupcake14.value != "0") {
			flavours = flavours + "rocky road (" + n + "), ";
		}
		
		if (form.cupcake15.value != "0") {
			flavours = flavours + "oreo (" + o + "), ";
		}
		
		if (form.cupcake16.value != "0") {
			flavours = flavours + "gluten free rv (" + p + "), ";
		}
				
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
	}
}



function pickSignatureFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;
	var j = form.cupcake10.value;
	var k = form.cupcake11.value;
	var l = form.cupcake12.value;
	var m = form.cupcake13.value;
	var n = form.cupcake14.value;
	var o = form.cupcake15.value;
	var p = form.cupcake16.value;

	var flavours = "";

	
	if(document.getElementById("itemname4a").checked) {

		if (form.cupcake1.value !== 0) {
			flavours = "assorted flavours";
		}

		document.getElementById("itemname5").value = flavours;
	}
	
	if(document.getElementById("itemname4b").checked) {
	
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "banana chocolate (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "van milk choc (" + h + "), ";
		}		
		
		if (form.cupcake9.value != "0") {
			flavours = flavours + "choc milk (" + i + "), ";
		}			
		
		if (form.cupcake10.value != "0") {
			flavours = flavours + "choc coconut (" + j + "), ";
		}
		
		if (form.cupcake11.value != "0") {
			flavours = flavours + "coconut (" + k + "), ";
		}
		
		if (form.cupcake12.value != "0") {
			flavours = flavours + "peanut butter (" + l + "), ";
		}			
		
		if (form.cupcake13.value != "0") {
			flavours = flavours + "strawberry (" + m + "), ";
		}

		if (form.cupcake14.value != "0") {
			flavours = flavours + "rocky road (" + n + "), ";
		}
		
		if (form.cupcake15.value != "0") {
			flavours = flavours + "oreo (" + o + "), ";
		}
				
		if (form.cupcake16.value != "0") {
			flavours = flavours + "flavour of the month (" + p + "), ";
		}
				
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
	}
}


function pickBespokeFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;

	var flavours = "";

	
	if(document.getElementById("itemname4a").checked) {

		if (form.cupcake1.value !== 0) {
			flavours = "assorted flavours  ";
		}

		document.getElementById("itemname5").value = flavours;
	}
	
	if(document.getElementById("itemname4b").checked) {
	
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "oreo (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "peanut butter (" + h + "), ";
		}

		if (form.cupcake9.value != "0") {
			flavours = flavours + "strawberry (" + i + "), ";
		}
				
		}			
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
}



function pickSpecialFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;
	
	var j = form.cupcake20.value;
	
	var flavours = "";
	
	
	if(document.getElementById("itemname4a").checked) {

		if (form.cupcake1.value !== 0) {
			flavours = flavours + "vanilla (" + j/2 + "), chocolate (" + j/2 + ")";
		}

		document.getElementById("itemname5").value = flavours;
	}
	
	if(document.getElementById("itemname4b").checked) {
	
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "oreo (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "peanut butter (" + h + "), ";
		}

		if (form.cupcake9.value != "0") {
			flavours = flavours + "strawberry (" + i + "), ";
		}
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
	}
}



function pickShamrockFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;
	var j = form.cupcake10.value;
	
	var flavours = "";
	
	
	if(document.getElementById("itemname4a").checked) {

		if (form.cupcake1.value !== 0) {
			flavours = "assorted flavours";
		}

		document.getElementById("itemname5").value = flavours;
	}
	
	if(document.getElementById("itemname4b").checked) {
	
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "oreo (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "peanut butter (" + h + "), ";
		}

		if (form.cupcake9.value != "0") {
			flavours = flavours + "strawberry (" + i + "), ";
		}
		
		if (form.cupcake10.value != "0") {
			flavours = flavours + "guinness and baileys (" + j + "), ";
		}
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
	}
}






function pickGiantCupcakeCakeFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	
	var flavours = "";
	
		
		if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "red velvet (" + c + "), ";
		}
						
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
}


function pickMakeYourOwnFlavours(form) {

	var a = form.cupcake1.value;
	var b = form.cupcake2.value;
	var c = form.cupcake3.value;
	var d = form.cupcake4.value;
	var e = form.cupcake5.value;
	var f = form.cupcake6.value;
	var g = form.cupcake7.value;
	var h = form.cupcake8.value;
	var i = form.cupcake9.value;

	var flavours = "";

	
	if (form.cupcake1.value != "0") {
			flavours = flavours + "vanilla (" + a + "), ";
		}

		if (form.cupcake2.value != "0") {
			flavours = flavours + "chocolate (" + b + "), ";
		}

		if (form.cupcake3.value != "0") {
			flavours = flavours + "carrot (" + c + "), ";
		}

		if (form.cupcake4.value != "0") {
			flavours = flavours + "banana (" + d + "), ";
		}
		
		if (form.cupcake5.value != "0") {
			flavours = flavours + "oreo (" + e + "), ";
		}

		if (form.cupcake6.value != "0") {
			flavours = flavours + "lemon (" + f + "), ";
		}
		
		if (form.cupcake7.value != "0") {
			flavours = flavours + "red velvet (" + g + "), ";
		}

		if (form.cupcake8.value != "0") {
			flavours = flavours + "peanut butter (" + h + "), ";
		}

		if (form.cupcake9.value != "0") {
			flavours = flavours + "strawberry (" + i + "), ";
		}
				
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("itemname5").value = allFlavours;
}



function pickMakeYourOwnIcingFlavours(form) {


	var a = document.getElementById("icing1").value;	
	var b = document.getElementById("icing2").value;
	var c = document.getElementById("icing3").value;
	var d = document.getElementById("icing4").value;
	var e = document.getElementById("icing5").value;
	var f = document.getElementById("icing6").value;
	var g = document.getElementById("icing7").value;
	var h = document.getElementById("icing8").value;
	var i = document.getElementById("icing9").value;
	var j = document.getElementById("icing10").value;
	var k = document.getElementById("icing11").value;
	var l = document.getElementById("icing12").value;
	var m = document.getElementById("icing13").value;

	var flavours = "";

	
		if (document.getElementById("icing1").value != "0") {
			flavours = flavours + "chocolate (" + a + "), ";
		}

		if (document.getElementById("icing2").value!= "0") {
			flavours = flavours + "strawberry (" + b + "), ";
		}

		if (document.getElementById("icing3").value != "0") {
			flavours = flavours + "oreo (" + c + "), ";
		}

		if (document.getElementById("icing4").value != "0") {
			flavours = flavours + "lemon (" + d + "), ";
		}
		
		if (document.getElementById("icing5").value != "0") {
			flavours = flavours + "cream cheese (" + e + "), ";
		}

		if (document.getElementById("icing6").value != "0") {
			flavours = flavours + "peanut butter (" + f + "), ";
		}
		
		if (document.getElementById("icing7").value != "0") {
			flavours = flavours + "vanilla - white (" + g + "), ";
		}
		
		if (document.getElementById("icing8").value != "0") {
			flavours = flavours + "vanilla - pink (" + h + "), ";
		}
		
		if (document.getElementById("icing9").value != "0") {
			flavours = flavours + "vanilla - green (" + i + "), ";
		}
		
		if (document.getElementById("icing10").value != "0") {
			flavours = flavours + "vanilla - blue (" + j + "), ";
		}
		
		if (document.getElementById("icing11").value != "0") {
			flavours = flavours + "vanilla - yellow (" + k + "), ";
		}
		
		if (document.getElementById("icing12").value != "0") {
			flavours = flavours + "vanilla - orange (" + l + "), ";
		}
		
		if (document.getElementById("icing13").value != "0") {
			flavours = flavours + "vanilla - lilac (" + m + "), ";
		}		
		
		var flavoursLength = flavours.length;
		allFlavours = flavours.slice(0,flavoursLength-2);

		document.getElementById("X1itemname5").value = allFlavours;
}

function calculateIcing(day_value,month,year) {
	count = 0;

	/* now passed in as arguments
	//only generate if day is determined
	var day_value = document.getElementById("day").value;
	var month = document.getElementById("month").value;
	var year = document.getElementById("year").value;
	*/

	if(day_value != "" && month != "" && year != "") {
		var total = document.getElementById("icingTotal");
		
		// cycle through all possible cupcakes to see if tallied
		// TODO: find a more permanent solution than this.
		for(var i = 0; i < 1000; i++) {	
			if(document.getElementById("icing" + i)) {
				if((document.getElementById("icing" + i).value != 0) && (document.getElementById("icing" + i).value != "")) {
					// validate the input (strip non-digits).
					var validChars = "0123456789";
					var thisString = document.getElementById("icing" + i).value;
					var newString = "";
					for (var n = 0; n <= thisString.length; n++) {
						if (validChars.indexOf(thisString.charAt(n)) != -1)
							newString += thisString.charAt(n);
					}
					if (newString == "")
						newString = '0';

					/*OLD VALIDATION
					if (parseInt(document.getElementById("icing" + i).value) > 0) {
						count += parseInt(document.getElementById("cupcake" + i).value);
						document.getElementById("icing" + i).value = parseInt(document.getElementById("icing" + i).value);
					}
					else
						document.getElementById("icing" + i).value = 0;*/
					
					// update display
						document.getElementById("icing" + i).value = newString;
					
					// add it to the cumulative sum (multiply by 1 to convert string to int
						count += (newString*1);
					
				}
			}
		}
		if(document.getElementById("assorted")) {			
			count += document.getElementById("assorted").value * 12;
		}
		if(document.getElementById("assortedCupcakes")) {
			count += (document.getElementById("assortedCupcakes").value*1);
		}
		for(var i = 0; i < 100; i++) {	
			if(document.getElementById("holidaybox" + i)) {
				if((document.getElementById("holidaybox" + i).value != 0) && (document.getElementById("holidaybox" + i).value != "")) {
					count += document.getElementById("holidaybox" + i).value * 12;
				}
			}			
		}
		
		total.firstChild.nodeValue = count;
		document.getElementById("X1quantity").value = count;		
	}
}


function calculateCupcake(day_value,month,year) {
	count = 0;

	/* now passed in as arguments
	//only generate if day is determined
	var day_value = document.getElementById("day").value;
	var month = document.getElementById("month").value;
	var year = document.getElementById("year").value;
	*/

	if(day_value != "" && month != "" && year != "") {
		var total = document.getElementById("cupcakeTotal");
		
		// cycle through all possible cupcakes to see if tallied
		// TODO: find a more permanent solution than this.
		for(var i = 0; i < 1000; i++) {	
			if(document.getElementById("cupcake" + i)) {
				if((document.getElementById("cupcake" + i).value != 0) && (document.getElementById("cupcake" + i).value != "")) {
					// validate the input (strip non-digits).
					var validChars = "0123456789";
					var thisString = document.getElementById("cupcake" + i).value;
					var newString = "";
					for (var n = 0; n <= thisString.length; n++) {
						if (validChars.indexOf(thisString.charAt(n)) != -1)
							newString += thisString.charAt(n);
					}
					if (newString == "")
						newString = '0';

					/*OLD VALIDATION
					if (parseInt(document.getElementById("cupcake" + i).value) > 0) {
						count += parseInt(document.getElementById("cupcake" + i).value);
						document.getElementById("cupcake" + i).value = parseInt(document.getElementById("cupcake" + i).value);
					}
					else
						document.getElementById("cupcake" + i).value = 0;*/
					
					// update display
						document.getElementById("cupcake" + i).value = newString;
					
					// add it to the cumulative sum (multiply by 1 to convert string to int
						count += (newString*1);
					
				}
			}
		}
		if(document.getElementById("assorted")) {			
			count += document.getElementById("assorted").value * 12;
		}
		if(document.getElementById("assortedCupcakes")) {
			count += (document.getElementById("assortedCupcakes").value*1);
		}
		for(var i = 0; i < 100; i++) {	
			if(document.getElementById("holidaybox" + i)) {
				if((document.getElementById("holidaybox" + i).value != 0) && (document.getElementById("holidaybox" + i).value != "")) {
					count += document.getElementById("holidaybox" + i).value * 12;
				}
			}			
		}
		
		total.firstChild.nodeValue = count;
		document.getElementById("quantity").value = count;
				
		
		var code = "blank";

		if (document.getElementById("makeYourOwn")) {
			code = document.getElementById("makeYourOwn").value;
		}
		
		if (code == "true") {
		
			// TUB VALUE
			tubCount = 0;
			var tubtotal = document.getElementById("tubTotal");
			var product = document.getElementById("product").value;			
			var cakeName = "no cakes";

			if (product == "cupcakes{0.75}") {

				grams = document.getElementById("tubQuantity").value = 75;
				tubCount = grams * count;
				cakeName = "regular cupcake (s)";
			}

			if (product == "tiny cupcakes{0.45}") {

				grams = 40;
				tubCount = grams * count;
				cakeName = "tiny cupcake (s)";
			}

			if (product == "7' round cupcake cake{15.00}") {

				grams = 960;
				tubCount = grams * count;
				cakeName = "7' cupcake cake (s)";
			}

			if (product == "9' round cupcake cake{25.00}") {

				grams = 1845;
				tubCount = grams * count;
				cakeName = "9' cupcake cake (s)";
			}

			if (product == "11' heart cupcake cake{35.00}") {

				alert(document.getElementById("tubQuantity").value);									

				grams = 2500;
				tubCount = grams * count;
				cakeName = "11' cupcake cake (s)";
			}

			if (product == "12' square cupcake cake{45.00}") {

				grams = 2500;						
				tubCount = grams * count;
				cakeName = "12' square cupcake cake (s)";
			}

			if (product == "giant cupcake{35.00}") {

				grams = 1365;
				tubCount = grams * count;
				cakeName = "giant cupcake (s)";		
			}		

			tubtotal.firstChild.nodeValue = tubCount;
			document.getElementById("tubQuantity").value = tubCount;


			typeCake.firstChild.nodeValue = cakeName;
			document.getElementById("cakeType").value = cakeName;

			qtyCake.firstChild.nodeValue = count;
			document.getElementById("cakeQty").value = count;


			tubQty = tubCount / 100;
			tubQty = tubQty.toFixed(1);			
			tubNo.firstChild.nodeValue = tubQty;
			document.getElementById("noOfTubs").value = tubQty;

			largeTubQty =  tubCount / 600;
			largeTubQty = largeTubQty.toFixed(1);					
			largeTubNo.firstChild.nodeValue = largeTubQty;
			document.getElementById("noOfLargeTubs").value = largeTubQty;
		}
			
	}
}


function checkValidInt(obj,cutLeadingZero) {
	// validate the input (strip non-digits).
	var validChars = "0123456789";
	var thisString = document.getElementById(obj.id).value;
	var newString = "";
	for (var n = 0; n <= thisString.length; n++) {
		if (validChars.indexOf(thisString.charAt(n)) != -1)
			newString += thisString.charAt(n);
	}
	while (newString.charAt(0) == '0' && cutLeadingZero == 1)
		newString = newString.substring(1); // take off leading '0'

	// update display
		document.getElementById(obj.id).value = newString;
}

function checkquantity(obj){
	if(document.getElementById(obj.id).value == "") {
	  document.getElementById(obj.id).value = '0';
	}
}


// page 2: cupcake total calculation
function clearquantity(obj){
	if(document.getElementById(obj.id).value == '0') {
	  document.getElementById(obj.id).value = "";
	}
}



function newImage(arg) { 
        if (document.images) { 
                rslt = new Image(); 
                rslt.src = arg; 
                return rslt; 
        } 
} 

function changeImagesArray(array) { 
        if (document.images && (preloadFlag == true)) { 
                for (var i=0; i<array.length; i+=2) { 
                        document[array[i]].src = array[i+1]; 
                } 
        } 
} 

function changeImages() { 
        changeImagesArray(changeImages.arguments); 
} 

function toggleImages() { 
        for (var i=0; i<toggleImages.arguments.length; i+=2) { 
                if (selectedLocation == toggleImages.arguments[i])      changeImagesArray(toggleImages.arguments[i+1]); 
        } 
} 

var selectedLocation = ''; 
var preloadFlag = false; 
function preloadImages() { 
        if (document.images) { 
                locations_bh_over = newImage("images/locations/locations_bh-over.gif"); 
                locations_pantry_over = newImage("images/locations/locations_pantry-over.gif"); 
                locations_nb_over = newImage("images/locations/locations_nb-over.gif"); 
                locations_da_over = newImage("images/locations/locations_da-over.gif"); 
                locations_ph_over = newImage("images/locations/locations_ph-over.gif"); 
                preloadFlag = true; 
        } 
        
deliveryMethod_func(document);        
} 



function MM_swapImgRestore() { //v3.0 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; 
} 

function MM_preloadImages() { //v3.0 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); 
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) 
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} 
} 

function MM_findObj(n, d) { //v4.01 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
  if(!x && d.getElementById) x=d.getElementById(n); return x; 
} 

function MM_swapImage() { //v3.0 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) 
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} 
} 

/*********************************************** 
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com) 
* This notice must stay intact for legal use. Last updated Mar 23rd, 2004. 
* Visit http://www.dynamicdrive.com/ for full source code 
***********************************************/ 

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off) 
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no) 

if (document.getElementById){ 
document.write('<style type="text/css">') 
document.write('.switchcontent{display:none;}') 
document.write('</style>') 
} 

function getElementbyClass(classname){ 
ccollect=new Array() 
var inc=0 
var alltags=document.all? document.all : document.getElementsByTagName("*") 
for (i=0; i<alltags.length; i++){ 
if (alltags[i].className==classname) 
ccollect[inc++]=alltags[i] 
} 
} 

function contractcontent(omit){ 
var inc=0 
while (ccollect[inc]){ 
if (ccollect[inc].id!=omit) 
ccollect[inc].style.display="none" 
inc++ 
} 
} 

function expandcontent(cid){ 
if (typeof ccollect!="undefined"){ 
if (collapseprevious=="yes") 
contractcontent(cid) 
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none" 

if(cid == "pickup_div") {
document.getElementById("deliveryMethod").value = "PICKUP";
}
else if(cid == "delivery_div") {
document.getElementById("deliveryMethod").value = "DELIVERY";
}
else if(cid == "timed_delivery_div") {
document.getElementById("deliveryMethod").value = "TIMED DELIVERY";
}
else {
document.getElementById("deliveryMethod").value = "";
}

deliveryMethod_func(document);

} 
} 

function revivecontent(){ 
contractcontent("omitnothing") 
selectedItem=getselectedItem() 
selectedComponents=selectedItem.split("|") 
for (i=0; i<selectedComponents.length-1; i++) 
document.getElementById(selectedComponents[i]).style.display="block" 
} 

function get_cookie(Name) { 
var search = Name + "=" 
var returnvalue = ""; 
if (document.cookie.length > 0) { 
offset = document.cookie.indexOf(search) 
if (offset != -1) { 
offset += search.length 
end = document.cookie.indexOf(";", offset); 
if (end == -1) end = document.cookie.length; 
returnvalue=unescape(document.cookie.substring(offset, end)) 
} 
} 
return returnvalue; 
} 

function getselectedItem(){ 
if (get_cookie(window.location.pathname) != ""){ 
selectedItem=get_cookie(window.location.pathname) 
return selectedItem 
} 
else 
return "" 
} 

function saveswitchstate(){ 
var inc=0, selectedItem="" 
while (ccollect[inc]){ 
if (ccollect[inc].style.display=="block") 
selectedItem+=ccollect[inc].id+"|" 
inc++ 
} 

document.cookie=window.location.pathname+"="+selectedItem 
} 

function do_onload(){ 
uniqueidn=window.location.pathname+"firsttimeload" 
getElementbyClass("switchcontent") 
if (enablepersist=="on" && typeof ccollect!="undefined"){ 
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load 
if (!firsttimeload) 
revivecontent() 
} 
} 



if (window.addEventListener) 
window.addEventListener("load", do_onload, false) 
else if (window.attachEvent) 
window.attachEvent("onload", do_onload) 
else if (document.getElementById) 
window.onload=do_onload 

if (enablepersist=="on" && document.getElementById) 
window.onunload=saveswitchstate 


if (document.images) {
var button1_over = new Image();
button1_over.src = "images/delivery/delivery_collection_over.jpg";
}

function click_collection_button() {
  if (document.images) {
    document["locations_bh"].src = button1_over.src
  }
}


/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="online_store_signature.html">Retail Cupcakes</a>'
menu1[1]='<a href="online_store_bespoke_occasions.html">Sprinkles & Occasions</a>'
menu1[2]='<a href="online_store_custom_corporate.html">Edible Image Cupcakes</a>'
menu1[3]='<a href="online_store_desserts.html">Pink Label Cupcakes</a>'
menu1[4]='<a href="online_store_custom_weddings.html">Wedding Cupcakes</a>'
menu1[5]='<a href="online_store_specials.html">Calendar</a>'


//Contents for menu 2
var menu2=new Array()
menu2[0]='<a href="online_store_birthdaycakes.html">Cupcake Cake</a>'
menu2[1]='<a href="online_store_cakes_giantcupcake.html">Giant Cupcake</a>'
menu2[2]='<a href="online_store_cakes_layer.html">Layer Cakes</a>'
menu2[3]='<a href="online_store_cakes_cheesecake.html">11" Cheese Cake</a>'
menu2[4]='<a href="online_store_cakes_mosaic.html">Picture Gallery</a>'
menu2[5]='<a href="online_store_cakes_cheesecake_TINY.html">TINY Cakes</a>'


var menuwidth='50px' //default menu width
var menubgcolor='#efe1c1'  //menu bgcolor

var disappeardelay=100  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

