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];}
}
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 validateSetupAccount() {
	if(document.setup_account.contact.value == "") {alert("Please enter your Name!");document.setup_account.contact.focus();return false;}
	if(document.setup_account.phone.value == "") {alert("Please enter your Phone!");document.setup_account.phone.focus();return false;}
	if(document.setup_account.address.value == "") {alert("Please enter your Address!");document.setup_account.address.focus();return false;}
	if(document.setup_account.city.value == "") {alert("Please enter your City!");document.setup_account.city.focus();return false;}
	if(document.setup_account.state.selectedIndex == 0) {alert("Please enter your State!");document.setup_account.state.focus();return false;}
	if(document.setup_account.zip.value == "") {alert("Please enter your Zip!");document.setup_account.zip.focus();return false;}
	if(document.setup_account.email_address.value == "") {alert("Please enter your Email Address!");document.setup_account.email_address.focus();return false;}

	// Check email address
	var checkEmail = "@.";
	var checkStr = document.setup_account.email_address.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
	if (ch == checkEmail.charAt(j) && ch == "@")
	EmailAt = true;
	if (ch == checkEmail.charAt(j) && ch == ".")
	EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
	if (EmailAt && EmailPeriod)
	{
		EmailValid = true
		break;
	}
	}
	if (!EmailValid)
	{
	alert("The \"Email Address\" must contain an \"@\" and a \".\".");
	document.setup_account.email_address.focus();
	return (false);}	
	
	if(document.setup_account.confirm_email_address.value == "") {alert("Please Confirm your Email Address!");document.setup_account.confirm_email_address.focus();return false;}
	
	// Check email address confirm
	var checkEmail = "@.";
	var checkStr = document.setup_account.confirm_email_address.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
	if (ch == checkEmail.charAt(j) && ch == "@")
	EmailAt = true;
	if (ch == checkEmail.charAt(j) && ch == ".")
	EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
	if (EmailAt && EmailPeriod)
	{
		EmailValid = true
		break;
	}
	}
	if (!EmailValid)
	{
	alert("The \"Confirmed Email Address\" must contain an \"@\" and a \".\".");
	document.setup_account.confirm_email_address.focus();
	return (false);}	
	
	// check to make sure the email addresses match
	if(!(document.setup_account.email_address.value == document.setup_account.confirm_email_address.value)) {alert("Email Addresses Do Not Match!");document.setup_account.email_address.value="";document.setup_account.confirm_email_address.value="";document.setup_account.email_address.focus();return false;}
	
	if(document.setup_account.password.value == "") {alert("Please enter your Password!");document.setup_account.password.focus();return false;}
	if(document.setup_account.confirm_password.value == "") {alert("Please Confirm your Password!");document.setup_account.confirm_password.focus();return false;}
	
	if(!(document.setup_account.password.value == document.setup_account.confirm_password.value)) {alert("Passwords Do Not Match!");document.setup_account.password.value="";document.setup_account.confirm_password.value="";document.setup_account.password.focus();return false;}
	
	//if(document.setup_account.credit_card_type.selectedIndex == 0) {alert("Please enter your Credit Card Type!");document.setup_account.credit_card_type.focus();return false;}
	//if(document.setup_account.name_on_card.value == "") {alert("Please enter your Name on Credit Card!");document.setup_account.name_on_card.focus();return false;}
	//if(document.setup_account.card_expiration_month.selectedIndex == 0) {alert("Please enter your Credit Card Expiration Month!");document.setup_account.card_expiration_month.focus();return false;}
	//if(document.setup_account.card_expiration_year.selectedIndex == 0) {alert("Please enter your Credit Card Expiration Year!");document.setup_account.card_expiration_year.focus();return false;}
	
	//if(document.setup_account.credit_card_number.value == "") {alert("Please enter your Credit Card Number!");document.setup_account.credit_card_number.focus();return false;}
	
  return (true);
}

function validateAccountLogin() {
	//check email address
	var checkEmail = "@.";
	var checkStr = document.place_order.email_address.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
	if (ch == checkEmail.charAt(j) && ch == "@")
	EmailAt = true;
	if (ch == checkEmail.charAt(j) && ch == ".")
	EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
	if (EmailAt && EmailPeriod)
	{
		EmailValid = true
		break;
	}
	}
	if (!EmailValid)
	{
	alert("The \"Email Address\" must contain an \"@\" and a \".\".");
	document.place_order.email_address.focus();
	return (false);}
	//check password
  if(document.place_order.password.value == "") {alert("Please enter your Password!");document.place_order.password.focus();return false;}
  return (true);
}

function validateOrderDelivery() {
	if(document.order_delivery.pickup_contact.value == "") {alert("Please enter the Pick Up Contact Name!");document.order_delivery.pickup_contact.focus();return false;}
	if(document.order_delivery.pickup_phone.value == "") {alert("Please enter the Pick Up Contact Phone!");document.order_delivery.pickup_phone.focus();return false;}
	if(document.order_delivery.pickup_address.value == "") {alert("Please enter the Pick Up Address!");document.order_delivery.pickup_address.focus();return false;}
	if(document.order_delivery.pickup_city.value == "") {alert("Please enter the Pick Up City!");document.order_delivery.pickup_city.focus();return false;}
	if(document.order_delivery.pickup_zip.value == "") {alert("Please enter the Pick Up Zip!");document.order_delivery.pickup_zip.focus();return false;}
	if(document.order_delivery.dropoff_contact.value == "") {alert("Please enter the Drop Off Contact!");document.order_delivery.dropoff_contact.focus();return false;}
	if(document.order_delivery.dropoff_phone.value == "") {alert("Please enter the Drop Off Phone!");document.order_delivery.dropoff_phone.focus();return false;}
	if(document.order_delivery.dropoff_address.value == "") {alert("Please enter the Drop Off Address!");document.order_delivery.dropoff_address.focus();return false;}
	if(document.order_delivery.dropoff_city.value == "") {alert("Please enter the Drop Off City!");document.order_delivery.dropoff_city.focus();return false;}
	if(document.order_delivery.dropoff_state.selectedIndex == 0) {alert("Please enter the Drop Off State!");document.order_delivery.dropoff_state.focus();return false;}
	if(document.order_delivery.dropoff_zip.value == "") {alert("Please enter the Drop Off Zip!");document.order_delivery.dropoff_zip.focus();return false;}
	if(document.order_delivery.packages.value == "") {alert("Please enter the Number of Packages!");document.order_delivery.packages.focus();return false;}
	if(document.order_delivery.ready_time.value == "") {alert("Please enter the Ready by Time !");document.order_delivery.ready_time.focus();return false;}
	if(document.order_delivery.deliver_time.value == "") {alert("Please enter the Deliver by Time!");document.order_delivery.deliver_time.focus();return false;}
	return (true);
}