//Script written by Andrew Pote - 7th Sept 2001
//Script Updated - 22nd October 2001

var price1, price, lenc, store, pap, addtot=6;


function clock() {
        		var y=0, x=20;
		
		price= document.clock.charecters.value;		

		//Calc String Lenth
		for (var i=0; i < (x +15); i++)
		{

			if (price.charAt(i) == ' ') 
			{
				y++;
			}
				
			//if last charecter == null then get length
			if (price.charAt(i) == '') 
			{
				price1= i;

				if (i == x) store= price;
				if (i > x) document.clock.charecters.value= store;
				i= x + 18;
			}
			
		}

		price1= price1 - y;
		document.clock.numofchars.value= price1 + y; 

		//Add up extra charceters
		coste= (price1 - 12) * 0.50;
		extra= price1 - 12;
		  if (coste < 0) coste= 0;
		  if (extra < 0) extra= 0;
		document.clock.xcost.value= coste;
		document.clock.extrac.value= extra;

		//Cost of Box
		boxcost= 6.50 + coste;
		document.clock.boxcost.value= boxcost;

		//Cost for all boxes		
		total= addtot * boxcost;
		document.clock.totalcost.value= total;

		//Postage and Packaging
		if (addtot < 50) pap= 32;
		if (addtot < 48) pap= 32;
		if (addtot < 36) pap= 16;
		if (addtot < 18) pap= 10;
		if (addtot < 7) pap= 10;

		document.clock.pandp.value= pap;
		document.clock.totpandp.value= (total + pap);

        Timer= setTimeout("clock()",80);
}

function validate() {
        
	inputOK= 1
	if (document.clock.realname.value == "") 
	{
		inputOK= 0;
		alert("You must enter your Name!");
	}
	
	else if (document.clock.email.value == "")
	{
		inputOK= 0;
		alert("You must enter your email!");
	}

	else if (document.clock.phone.value == "") 
	{
		inputOK= 0;
		alert("You must enter your phone number!");
	}

	else if (document.clock.time.value == "") 
	{
		inputOK= 0;
		alert("You must enter box name!");
	}


  if (inputOK == 1) return true
    else return false;
}


function setf()
{
	document.clock.charecters.value= "<type here>";
	document.clock.charecters.focus();
	document.clock.charecters.select();
}