/* all script functions of this site defined in this file */



function chk_mailing_list(obj)

{	

	var msg="";



	if(obj.email.value.length==0)

		msg+="Enter Email\n";

	else if(!chk_email(obj.email))

	{

		msg+="Enter valid email\n";

	}				



	if(msg.length > 0)

	{	

		alert(msg);



		return false;

	}



	return true;

}



function validate_vendor_admin(dc, is_admin)

{

	

	var msg="";	

	

	if(dc.first_name.value.length==0)

		msg+="Enter First Name\n";

	

	if(dc.last_name.value.length==0)

		msg+="Enter Last Name\n";

	

	if(dc.phone.value.length==0)

		msg+="Enter Phone\n";

	

	if(dc.email.value.length==0)

		msg+="Enter Email\n";

		/* need not be a email!!

	else if(!chk_email(dc.email))

		msg+="Enter valid email\n";

	*/

	

	

	if(is_admin!=1)

	{





	if(dc.password.value.length==0)

		msg+="Enter Password\n";

	

	if(dc.confirm_password.value.length==0)

		msg+="Confirm Password\n";

	

	if(dc.confirm_password.value!=dc.password.value)

		msg+="Passwords do not match\n";



	if(dc.security_qn.value.length==0)

		msg+="Enter Security Question\n";

	

	if(dc.security_qn.value.length==0)

		msg+="Enter Security Answer\n";





	if(!dc.agree.checked)

		msg+="Accept the terms and conditions\n";

	}

	

	if(msg.length > 0)

	{

		alert(msg);

		return false;

	}

	

	return true;

	



}





function validate_vendor(dc)

{

	



	var msg="";	

	

	if(dc.pizzeria_name.value.length==0)

		msg+="Enter Pizzeria Name\n";





	if(dc.contact_name.value.length==0)

		msg+="Enter Contact Name\n";



	if(dc.address1.value.length==0)

		msg+="Enter Address\n";

	

	

	if(dc.city.value.length==0)

		msg+="Enter City\n";

	

	if(dc.state.value.length==0)

		msg+="Enter State\n";

	

	if(dc.code.value.length!=5)

		msg+="Enter valid Zip Code\n";

	

	if(dc.phone.value.length==0)

		msg+="Enter Phone\n";

/*		

	if(dc.fax.value.length==0)

		msg+="Enter Fax\n";



	if(dc.email.value.length==0)

		msg+="Enter Email\n";

	else if(!chk_email(dc.email))

		msg+="Enter valid email\n";

	*/					

	

	if(msg.length > 0)

	{

		alert(msg);

		return false;

	}

	

	return true;

	



}





function validate_user(dc, is_admin)

{

	

	

	var msg="";	

	

	if(dc.first_name.value.length==0)

		msg+="Enter First Name\n";

	

	if(dc.last_name.value.length==0)

		msg+="Enter Last Name\n";	

	

	if(dc.zip.value.length!=5)

		msg+="Enter valid Zip Code\n";

	

	if(dc.email.value.length==0)

		msg+="Enter Email\n";

	else if(!chk_email(dc.email))

		msg+="Enter valid email\n";

	else if(dc.email.value!=dc.cemail.value)

		msg+="Emails do not match\n";	

	





	if(is_admin!=1)

	{



	if(dc.password.value.length==0)

		msg+="Enter Password\n";

	

	if(dc.confirm_password.value.length==0)

		msg+="Enter Confirm Password\n";

	

	if(dc.confirm_password.value!=dc.password.value)

		msg+="Passwords do not match\n";



		if(!dc.agree.checked)

			msg+="Accept the terms and conditions\n";

	}



	if(msg.length > 0)

	{

	alert(msg);

	return false;

	}

	

	return true;

	



}







function chk_email(fldname)

{



	var str=fldname.value;	

	

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i



	if (filter.test(str))

		testresults=true

	else{

//		alert("Please input a valid email address!")



		testresults=false

	}



	return (testresults)

}



function confirm_on_del(val)

{



	if(val.length==0)

		val = "Are you sure?";



		if(confirm(val))



			return true;



		else



			return false;







}







function alert_delete(val1,val2,val3)



{







if(confirm_on_del(''))



{







str=val2+"&id="+val1+"&type="+val3;







//alert(str);







window.location.href=str;







}







}



function validate_cart(formname, howmany)

{



		if(howmany==3){

		

			if(!formname.gift_cert[0].checked && !formname.gift_cert[1].checked && !formname.gift_cert[2].checked )

			{

				alert("Select a Gift Certificate\n");

				return false;

			}

		

		}



		if(howmany==2){

		

			if(!formname.gift_cert[0].checked && !formname.gift_cert[1].checked)

			{

				alert("Select a Gift Certificate\n");

				return false;

			}

		

		}

		

		if(howmany==1){

		

			if(!formname.gift_cert.checked)

			{

				alert("Select a Gift Certificate\n");

				return false;

			}

		

		}



		return true;



}



function validate_order_comments(obj)

{

	if(obj.admin_comments.value.length==0)

	{

		alert("Enter comments");

		return false;

	}

	

	return true;

}



function chk_gc_validation(obj)

{

	if(obj.gc_numbers.value.length<10)

	{

		alert("Enter GC Numbers to validate");

		return false;

	}

	

	return true;

}





function change_pass(obj)

{

	var msg="";



	if(obj.old_pass.value.length==0)

		msg+="Enter Current Password\n";	



	if(obj.password.value.length==0)

		msg+="Enter New Password\n";

	

	if(obj.password.value!=obj.con_password.value)

		msg+= "Passwords do not match\n"; 

	

	

	if(msg.length > 0)

	{	

		alert(msg);	

		return false;	

	}	

	

	return true;

	

}



function chk_security(obj)

{

	var msg="";



	if(obj.security_qn.value.length==0)

		msg+="Enter Question\n";	



	if(obj.security_ans.value.length==0)

		msg+="Enter Answer\n";		

	

	if(msg.length > 0)

	{	

		alert(msg);	

		return false;	

	}	

	

	return true;

	

}



function empty_field(obj)

{

	obj.value='';

}



function validate_customize_gc_old(obj)

{

	var msg="";

	

	if(obj.recipient_name.value.length==0)	msg+="Enter Recipient Name\n";

	

	if(obj.recipient_email.value.length==0)

		msg+="Enter Recipient Email\n";

	else if(!chk_email(obj.recipient_email))

		msg+="Enter valid email\n";

		

	if(msg.length > 0)

	{	

		alert(msg);	

		return false;	

	}	

	

	return true;

	



}



function validate_customize_gc(obj, qty)

{

	var msg="";

	

	var fld;

	

	for(i=0;i<obj.elements.length;i++)

	{

		

		fld_name=obj.elements[i].name;

		

		fld_sub_name=fld_name.substring(0,11)

		

		if(fld_sub_name=="recipient_n" || fld_sub_name=="sender_name")

		{

			if(obj.elements[i].value=="Enter Recipient's Name" || obj.elements[i].value.length==0 || obj.elements[i].value=="Enter Your Name")

			{

					alert("Enter required fields");

					return false;

			}

		}





		if(fld_sub_name=="recipient_e" || fld_sub_name=="sender_emai")

		{

			if(obj.elements[i].value=="Enter Recipient's Email Address" || obj.elements[i].value.length==0 || obj.elements[i].value=="Enter Your Email Address" || !chk_email(obj.elements[i]))

			{

					alert("Enter valid email");

					return false;

			}

		}



	}

	

	return true;

	



}



function validate_reviews(obj)

{



	var msg="";

	



	if(!obj.food[0].checked && !obj.food[1].checked && !obj.food[2].checked  && !obj.food[3].checked && !obj.food[4].checked)

	{

		msg+="Rate Food\n";

	}



	if(!obj.service[0].checked && !obj.service[1].checked && !obj.service[2].checked  && !obj.service[3].checked && !obj.service[4].checked)

	{

		msg+="Rate Service\n";

	}



	if(!obj.cleanliness[0].checked && !obj.cleanliness[1].checked && !obj.cleanliness[2].checked  && !obj.cleanliness[3].checked && !obj.cleanliness[4].checked)

	{

		msg+="Rate Cleanliness\n";

	}



	if(!obj.price[0].checked && !obj.price[1].checked && !obj.price[2].checked  && !obj.price[3].checked && !obj.price[4].checked)

	{

		msg+="Rate Price\n";

	}



	if(msg.length > 0)

	{

		alert(msg);

		return false;

	}

	

	return true;

	

}



var xmlhttp, xmlhttp1;



xmlhttp=GetXmlHttpObject();



xmlhttp1=GetXmlHttpObject();



function show_limitations(gc_id, vendor_id, limitations_id, show_additional)

{

	limitations_id="limitations_text_"+vendor_id;

	

	if (xmlhttp==null)

	{

	alert ("Browser does not support HTTP Request");

	return;

	}

   

   var url="get_limitations_text.php";

   url=url+"?gc_id="+gc_id+"&vendor_id="+vendor_id+"&show_additional="+show_additional+"&sid="+Math.random();;

   xmlhttp.onreadystatechange=function () { 

                                    display_limitation(limitations_id, xmlhttp);

                                    }

   

   ;

   xmlhttp.open("GET",url,true);

   xmlhttp.send(null);	

}



function display_limitation(limitations_id, xmlhttp)

{

	

	if(xmlhttp.readyState==4)

	{		

		var result=xmlhttp.responseText;			

	  

		document.getElementById(""+limitations_id+"").innerHTML=result;

	}	

}		





function GetXmlHttpObject()

{

   

	if(window.XMLHttpRequest)

	{

	  // code for IE7+, Firefox, Chrome, Opera, Safari

	  return new XMLHttpRequest();

	}

	if (window.ActiveXObject)

	{

	  // code for IE6, IE5

	  return new ActiveXObject("Microsoft.XMLHTTP");

	}

	

	return null;

}





function show_menu(menu_id)

{	



//	alert(menu_id);

	

//	document.getElementById("menu_img").innerHTML="<img src='thickbox/loading.gif'>";



	if (xmlhttp1==null)

	{

	alert ("Browser does not support HTTP Request");

	return;

	}

   

   var url="get_menu.php";

   url=url+"?menu_id="+menu_id+"&sid="+Math.random();

   

   xmlhttp1.onreadystatechange=display_menu;

   

   xmlhttp1.open("GET",url,true);

   

   xmlhttp1.send(null);	

}



function display_menu()

{

	

	if(xmlhttp1.readyState==4)

	{		

		var result=xmlhttp1.responseText;			

	  

		document.getElementById("menu_img").innerHTML=result;

	}	

}		





function validate_signup_step1(obj)

{

	var msg='';

		

	if(obj.pizzeria_name.value.length==0)	msg+="Enter Pizzeria Name\n";



	if(obj.address1.value.length==0)	msg+="Enter Pizzeria Address\n";



	if(obj.city.value.length==0)	msg+="Enter City\n";



	if(obj.state.value.length==0)	msg+="Select State\n";



	if(obj.code.value.length==0)	msg+="Enter Zip Code\n";



	if(msg.length > 0){alert(msg);return false;}



	return true;

}







function iteration(array, bool)

{ 	 

  for (var i = 0; i < array.length; i++){ 

	 document.getElementById(array[i]).disabled=bool;

  }      

} 

	

function mask_form_elements(obj, arrayname)

{			

	if(obj.checked)

	{

		iteration(arrayname, true);		

	}

	else

	{

		iteration(arrayname, false);		

	}

}



function unmask_form_elements(obj, arrayname)

{			

	if(obj.checked)

	{

		iteration(arrayname, false);		

	}

	else

	{	

		iteration(arrayname, true);		

	}

}




function validate_discount()
{

	var msg="";

	dc=document.discount_frm;

	if(dc.code.value.length==0)
		msg+="Enter Code\n";
	
	if(dc.discount.value.length==0)
		msg+="Enter Discount Value\n";
		
	if(dc.discounttype.value==0)
		msg+="Select Discount Type\n";
		
	if(msg.length > 0)
	{	
		alert(msg);
		return false;
	}

	return true;		

}

