///////////////////////////////////////////////////////////////////////
//     This script was designed by Erik Arvidsson for WebFX          //
//                                                                   //
//     For more info and examples see: http://webfx.eae.net          //
//     or send mail to erik@eae.net                                  //
//                                                                   //
//     Feel free to use this code as lomg as this disclaimer is      //
//     intact.                                                       //
///////////////////////////////////////////////////////////////////////
function select_div(val)

{
	var div_type=document.search_prop_index_0.ordertype.value;
	obj1=document.getElementById("div_delivery");
	obj2=document.getElementById("div_takeout");
	obj3=document.getElementById("div_both");
	obj4=document.getElementById("div_delivery_btn");
	obj5=document.getElementById("div_takeout_btn");
	obj6=document.getElementById("div_both_btn");
	
	
	if(div_type == 'takeout')
	{
		obj1.style.display="none";	  
		obj2.style.display='';	  
		obj3.style.display="none";
		obj4.style.display="none";	  
		obj5.style.display='';	  
		obj6.style.display="none";
		
	}
	else if(div_type == 'both')
	{
		obj1.style.display="none";	  
		obj2.style.display="none";	  
		obj3.style.display="";
		obj4.style.display="none";	  
		obj5.style.display="none";	  
		obj6.style.display="";	  
	}
	else
	{
		obj1.style.display="";	  
		obj2.style.display="none";	  
		obj3.style.display="none";
		obj4.style.display="";	  
		obj5.style.display="none";	  
		obj6.style.display="none";	  	  
	}

}

function select_div1(val)

{
	var div_type=document.search_prop_index_0.ordertype.value;
	obj1=document.getElementById("div_delivery");
	obj2=document.getElementById("div_takeout");
	//obj3=document.getElementById("div_both");
	obj4=document.getElementById("div_delivery_btn");
	obj5=document.getElementById("div_takeout_btn");
	//obj6=document.getElementById("div_both_btn");
	
	
	if(div_type == 'takeout')
	{
		obj1.style.display="none";	  
		obj2.style.display='';	  
		//obj3.style.display="none";
		obj4.style.display="none";	  
		obj5.style.display='';	  
		//obj6.style.display="none";
		
	}
	/*else if(div_type == 'both')
	{
		obj1.style.display="none";	  
		obj2.style.display="none";	  
		obj3.style.display="";
		obj4.style.display="none";	  
		obj5.style.display="none";	  
		obj6.style.display="";	  
	}*/
	else
	{
		obj1.style.display="";	  
		obj2.style.display="none";	  
		//obj3.style.display="none";
		obj4.style.display="";	  
		obj5.style.display="none";	  
		//obj6.style.display="none";	  	  
	}

}





/* Code for search Page FOR MOVING DIV STARTS HERE*/
function sort_result(url, type)
{
	window.location.href=url+"&sortby="+type;
}


function load_address_div(var_lc)
{	
	document.getElementById("Layer2").style.display="";	
	document.search_tmp.tmp_location.value=var_lc;
}

function unload_address_div()
{
	document.getElementById("Layer2").style.display="none";	  
}

function confirmstatus()
{
var agree=confirm("Continue with pickup or search for delivery vendors.");

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

var checkZIndex = true;

var dragobject = null;
var tx;
var ty;

var ie5 = document.all != null && document.getElementsByTagName != null;

function getReal(el) {
	temp = el;

	while ((temp != null) && (temp.tagName != "BODY")) {
		if ((temp.className == "moveme") || (temp.className == "handle")){
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}


function moveme_onmousedown() {
	el = getReal(window.event.srcElement)
	
	if (el.className == "moveme" || el.className == "handle") {
		if (el.className == "handle") {
			tmp = el.getAttribute("handlefor");
			if (tmp == null) {
				dragobject = null;
				return;
			}
			else
				dragobject = eval(tmp);
		}
		else 
			dragobject = el;
		
		if (checkZIndex) makeOnTop(dragobject);
		
		ty = window.event.clientY - getTopPos(dragobject);
		tx = window.event.clientX - getLeftPos(dragobject);
		
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
	else {
		dragobject = null;
	}
}

function moveme_onmouseup() {
	if(dragobject) {
		dragobject = null;
	}
}

function moveme_onmousemove() {
	if (dragobject) {
		if (window.event.clientX >= 0 && window.event.clientY >= 0) {
			dragobject.style.left = window.event.clientX - tx;
			dragobject.style.top = window.event.clientY - ty;
		}
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
}

function getLeftPos(el) {
	if (ie5) {
		if (el.currentStyle.left == "auto")
			return 0;
		else
			return parseInt(el.currentStyle.left);
	}
	else {
		return el.style.pixelLeft;
	}
}

function getTopPos(el) {
	if (ie5) {
		if (el.currentStyle.top == "auto")
			return 0;
		else
			return parseInt(el.currentStyle.top);
	}
	else {
		return el.style.pixelTop;
	}
}

function makeOnTop(el) {
	var daiz;
	var max = 0;
	var da = document.all;
	
	for (var i=0; i<da.length; i++) {
		daiz = da[i].style.zIndex;
		if (daiz != "" && daiz > max)
			max = daiz;
	}
	
	el.style.zIndex = max + 1;
}

if (document.all) { //This only works in IE4 or better
	document.onmousedown = moveme_onmousedown;
	document.onmouseup = moveme_onmouseup;
	document.onmousemove = moveme_onmousemove;
}

document.write("<style>");
document.write(".moveme		{cursor: move;}");
document.write(".handle		{cursor: move;}");
document.write("</style>");

/* Code for search Page FOR MOVING DIV ENDS HERE*/



/* Code for search Page FOR Message Box after 10 seconds STARTS HERE*/

function Togglesearch(item, item1) {
   obj=document.getElementById(item);
   obj1=document.getElementById(item1);

   visible=(obj.style.display!="none")
   visible1=(obj1.style.display!="none")
   
   key=document.getElementById("x" + item);
   key1=document.getElementById("x" + item1);
   
   if (visible) {
     obj.style.display="none";
     obj1.style.display="block";
   //  key.innerHTML="<img src='folder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
   } else {
      obj.style.display="block";
      obj1.style.display="none";
      
     // key.innerHTML="<img src='textfolder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
   }
}




function loadmsgbox()
{
	document.getElementById("Layer2").style.display="";	  
}


function unloadmsgbox()
{	
	var len=document.getElementById("Layer2");
	len.style.display="none";	  
}    

function redirectuser()
{
		window.location.href="locationenquiry.php";	
}   


<!--
var secs
var timerID = null
var timerRunning = false
var delay = 400

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 10
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
    	
        StopTheClock();
     
		var response=loadmsgbox();
       	
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
/* Code for search Page FOR Message Box after 10 seconds ENDS HERE*/
function active_changeorderdiv()
{
	document.getElementById("changeorder").style.display="";	  
}

/* SEARCH FUNCTION IF ORDER TYPE DELIVERY STARTS HERE (INDEX PAGE SEARCH) */
function redirect_search()
{
if(trim(document.search_tmp.streetaddress.value) == "")
	{
			alert('Enter a valid delivery address.');
	 	 	document.search_tmp.streetaddress.focus();
	 	 	return false;
	}
/*
else if(document.search_tmp.longitude.value == "" || document.search_tmp.latitude.value == "")
	{
		openwindow_address_div();
		document.search_tmp.streetaddress.focus();
		return(false);
	}
	*/
	else
	{
	unload_address_div();
	}

}

function doSearch_index_delivery(){
	 with(document.search_prop_index_1)
	 {
		if(trim(streetaddress.value) == "")
		{
			alert('Enter a valid delivery address.');
	 	 	streetaddress.focus();
	 	 	return false;
		}
		
		//alert(state.value);
	 	if(state.value == "")
		{
			alert('Select a state.');
	 	 	state.focus();
	 	 	return false;
		}	
		else if(trim(city.value) == "")
		{
			alert('Select a city.');
	 		city.focus();
	 		return false;
		}
		/*
		else if(longitude.value == "" || latitude.value == "")
		{
			openwindow_index();
			//alert('You must enter valid address.');
			streetaddress.focus();
			return(false);
		}
		*/
		else if(hour.value == 0)
		{
			alert('Select your event time hour.');
			hour.focus();
			return(false);
		}
		else if(minute.value == "")
		{
			alert('Select your event time minute.');
			minute.focus();
			return(false);
		}
		else if(half.value == 0)
		{
			alert('Choose AM or PM.');
			half.focus();
			return(false);
		}
		else if(deliverydate1.value == null || deliverydate1.value == "")
		{	
			alert('Click on calendar to choose your event date.');
			deliverydate1.focus();
			return(false);			
		}
		else if(deliverydate1.value !="")
		{
			var dt=document.search_prop_index_1.deliverydate1;
			if (isDate(dt.value) == false)
			{
				dt.focus();
				return false;
			}
		}
		//var searchurl="city="+city.value+"&state="+state.value+"&streetaddress="+streetaddress.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&action="+"advance";
		//openwindow_index(searchurl);
			document.search_prop_index_1.submit();
		//window.location.href = "search.php?city="+city.value+"&state="+state.value+"&streetaddress="+streetaddress.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&action="+"advance";	
	 }
}


function doSearch_index_delivery_static(){
//alert('delivery');
	 with(document.search_prop_index)
	 {
		if(trim(streetaddress.value) == "")
		{
			alert('Enter a valid delivery address.');
	 	 	streetaddress.focus();
	 	 	return false;
		}	
	 	if(state.value == "")
		{
			alert('Select a state.');
	 	 	state.focus();
	 	 	return false;
		}	
		else if(trim(city.value) == "")
		{
			alert('Select a city.');
	 		city.focus();
	 		return false;
		}
		/*
		else if(longitude.value == "" || latitude.value == "")
		{
			openwindow_index_static();
			//alert('You must enter valid address.');
			streetaddress.focus();
			return(false);
		}
		*/
		else if(hour.value == 0)
		{
			alert('Select your event time hour.');
			hour.focus();
			return(false);
		}
		else if(minute.value == "")
		{
			alert('YSelect your event time minute.');
			minute.focus();
			return(false);
		}
		else if(half.value == 0)
		{
			alert('Select AM or PM.');
			half.focus();
			return(false);
		}
		else if(deliverydate.value == null || deliverydate.value == "")
		{	
			alert('Click on calendar to choose your event date.');
			deliverydate.focus();
			return(false);			
		}
		else if(deliverydate.value !="")
		{
			var dt=document.search_prop_index.deliverydate;
			if (isDate(dt.value) == false)
			{
				dt.focus();
				return false;
			}
		}
		window.location.href = "search.php?city="+city.value+"&state="+state.value+"&streetaddress="+streetaddress.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&action="+"advance";	
	 }
}


/* SEARCH FUNCTION IF ORDER TYPE DELIVERY ENDS (INDEX PAGE)*/



/* SEARCH FUNCTION IF ORDER TYPE TAKEOUT OR BOTH STARTS HERE(INDEX PAGE)*/
function doSearch_index_takeout(){
	 with(document.search_prop_index_2)
	 {
	 	if( (state.value =="" || city.vale == "") && (within.value ==""))
	 	{
	 	 	alert('Select the state & city to search.');
	 	 	state.focus();
	 	 	return false;
	 	}
	 	else if(state.value != "")
		{
			within.value="";
			if(trim(city.value) == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.value == 0)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.value == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate2.value == null || deliverydate2.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate2.focus();
				return(false);			
			}
			else if(deliverydate2.value !="")
			{
				var dt=deliverydate2;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		else if(within.value != "")
		{
			if(isNaN(within.value) || trim(within.value) =="")
			{
				alert('Enter a valid zipcode.');
	 			within.focus();
				return(false);
			}
			/*
			if(trim(milesof.value) == null || trim(milesof.value) == "" || isNaN(milesof.value))
			{
				alert('You must valid enter distance.');
	 			milesof.focus();
				return(false);
			}
			*/
			if(hour.value == "" || hour.value == null)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate2.value == null || deliverydate2.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate2.focus();
				return(false);			
			}
			else if(deliverydate2.value !="")
			{
				var dt=document.search_prop_index_2.deliverydate2;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		window.location.href = "search.php?city="+city.value+"&state="+state.value+"&zipcode="+within.value+"&deliverydate="+deliverydate2.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&action="+"advance";	
	 }
}


function doSearch_index_takeout_static(){
	 with(document.search_prop_index)
	 {
	 	if( (state.value =="" || city.vale == "") && (within.value ==""))
	 	{
	 	 	alert('Select the state & city to search.');
	 	 	state.focus();
	 	 	return false;
	 	}
	 	else if(state.value != "")
		{
			within.value="";
			if(trim(city.value) == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.SelectedIndex == 0)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		else if(within.value != "")
		{
			if(isNaN(within.value) || trim(within.value) =="")
			{
				alert('Enter a valid zipcode.');
	 			within.focus();
				return(false);
			}
			/*
			if(trim(milesof.value) == null || trim(milesof.value) == "" || isNaN(milesof.value))
			{
				alert('You must valid enter distance.');
	 			milesof.focus();
				return(false);
			}
			*/
			if(hour.value == "" || hour.value == null)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop_index.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		window.location.href = "search.php?city="+city.value+"&state="+state.value+"&zipcode="+within.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&action="+"advance";	
	 }
}




function doSearch_index_both(){
	 with(document.search_prop_index_3)
	 {
	 	if( (state.value =="" || city.vale == "") && (within.value ==""))
	 	{
	 	 	alert('Select the state & city to search.');
	 	 	state.focus();
	 	 	return false;
	 	}
	 	else if(state.value != "")
		{
			//within.value="";
			if(trim(city.value) == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.value == 0)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.value == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate3.value == null || deliverydate3.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate3.focus();
				return(false);			
			}
			else if(deliverydate3.value !="")
			{
				var dt=deliverydate3;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		else if(within.value != "")
		{
			if(isNaN(within.value) || trim(within.value) =="")
			{
				alert('Enter a valid zipcode.');
	 			within.focus();
				return(false);
			}
			/*
			if(trim(milesof.value) == null || trim(milesof.value) == "" || isNaN(milesof.value))
			{
				alert('You must valid enter distance.');
	 			milesof.focus();
				return(false);
			}
			*/
			if(hour.value == "" || hour.value == null)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate3.value == null || deliverydate3.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate3.focus();
				return(false);			
			}
			else if(deliverydate3.value !="")
			{
				var dt=document.search_prop_index_3.deliverydate3;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		window.location.href = "search.php?city="+city.value+"&state="+state.value+"&zip="+within.value+"&deliverydate="+deliverydate3.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&action="+"advance";	
	 }
}

/* SEARCH FUNCTION IF ORDER TYPE TAKEOUT OR BOTH ENDS HERE (INDEX PAGE)*/


/* SEARCH FUNCTION IF ORDER TYPE TAKEOUT OR BOTH STARTS HERE*/
function doSearchadvance(){
//alert('all');
	 with(document.search_prop)
	 {
	 	if( (state.value =="" || city.vale == "") && (within.value ==""))
	 	{
	 	 	alert('Select the state & city to search.');
	 	 	state.focus();
	 	 	return false;
	 	}
	 	else if(state.value != "")
		{
			document.search_prop.within.value="";
			//document.search_prop.milesof.value="";	
			if(trim(city.value) == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.value == "")
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		else if(within.value != "")
		{
			if(isNaN(within.value) || trim(within.value) =="")
			{
				alert('Enter a valid zipcode.');
	 			within.focus();
				return(false);
			
			}
			/*
			if(trim(milesof.value) == null || trim(milesof.value) == "" || isNaN(milesof.value))
			{
				alert('You must enter valid distance.');
	 			milesof.focus();
				return(false);
			}
			*/
			else if(hour.value == "" || hour.value == null)
			{
				alert('Select your pickup time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your pickup time minute.');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your pickup date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		if(cuisine_type.value == null || cuisine_type.value == ""){
	 		cuisine_type.value = "";
		}
		if(ordertype.value == null || ordertype.value == ""){
	 		ordertype.value = "";
		}
		if(special.checked == false){
	 		special.value = "";
		}
		if(rating.checked ==false)
		{
			rating.value = "";	
		}
		window.location.href = "search.php?city="+city.value+"&state="+state.value+"&zipcode="+within.value+"&cuisine_type="+cuisine_type.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&special="+special.value+"&rating="+rating.value+"&action="+"advance";	
	 }
}
/* SEARCH FUNCTION IF ORDER TYPE TAKEOUT OR BOTH ENDS HERE*/


/* SEARCH FUNCTION IF ORDER TYPE DELIVERY STARTS HERE*/
function doSearchadvance_delivery(){
	//alert('delivery')
	 with(document.search_prop)
	 {
			if(trim(streetaddress.value) == null || trim(streetaddress.value) == "")
			{
	 			alert('Enter a valid delivery address');
	 			streetaddress.focus();
	 			return(false);			
			}
			else if(state.value == "")
			{
				alert('Select the State.');
	 	 		state.focus();
	 	 		return false;
			}
			else if(trim(city.value) == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.value == 0)
			{
				alert('Select your event time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your event time minute.');
				minute.focus();
				return(false);
			}
			else if(half.value == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your event date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		if(special.checked == false){
	 		special.value = "";
		}
		if(rating.checked ==false)
		{
			rating.value = "";	
		}
			if(cuisine_type.value == null || cuisine_type.value == ""){
	 		cuisine_type.value = "";
		}
	
		window.location.href = "search.php?city="+city.value+"&state="+state.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&cuisine_type="+cuisine_type.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordertype="+ordertype.value+"&special="+special.value+"&rating="+rating.value+"&streetaddress="+streetaddress.value+"&action="+"advance";	
	 }
}
/* SEARCH FUNCTION IF ORDER TYPE DELIVERY ENDS HERE*/


/* SEARCH FUNCTION FOR CHANGE ORDER TYPE TO DELIVERY AT TIME OF CHECKOUT*/
function changeto_delivery(){
	//alert('delivery')
	 with(document.search_prop)
	 {
			if(trim(streetaddress.value) == null || trim(streetaddress.value) == "")
			{
	 			alert('Enter a valid delivery address');
	 			streetaddress.focus();
	 			return(false);			
			}
			else if(state.value == "")
			{
				alert('Select the state.');
	 	 		state.focus();
	 	 		return false;
			}
			else if(city.value == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.value == 0)
			{
				alert('Select your event time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your event time minute.');
				minute.focus();
				return(false);
			}
			else if(half.value == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your event date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		window.location.href = "change_ordertype_verify.php?city="+city.value+"&state="+state.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordermethod="+ordermethod.value+"&streetaddress="+streetaddress.value+"&action="+"advance_change";	
	 }
}
function changeto_delivery_ram(){
	//alert('delivery')
	 with(document.search_tmp)
	 {
			if(trim(streetaddress.value) == null || trim(streetaddress.value) == "")
			{
	 			alert('Enter a valid delivery address');
	 			streetaddress.focus();
	 			return(false);			
			}
			document.search_tmp.submit();
			return false;		
		window.location.href = "change_ordertype_verify.php?city="+city.value+"&state="+state.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordermethod="+ordermethod.value+"&streetaddress="+streetaddress.value+"&action="+"advance_change";	
	 }
}

function selectto_delivery(){
	//alert('delivery')
	 with(document.search_prop)
	 {
		
			if(trim(streetaddress.value) == null || trim(streetaddress.value) == "")
			{
	 			alert('Enter a valid delivery address');
	 			streetaddress.focus();
	 			return(false);			
			}
			else if(state.value == "")
			{
				alert('Select the state.');
	 	 		state.focus();
	 	 		return false;
			}
			else if(trim(city.value) == "")
			{
				alert('Select the city.');
	 	 		city.focus();
	 	 		return false;
			}
			else if(hour.value == 0)
			{
				alert('Select your event time hour.');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('Select your event time minute.');
				minute.focus();
				return(false);
			}
			else if(half.value == 0)
			{
				alert('Select AM or PM.');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('Click on calendar to choose your event date.');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
	/*
		} 
		else if(within.value != "")
		{
			if(milesof.value == null || milesof.value == "")
			{
				alert('You must enter distance.');
	 			milesof.focus();
				return(false);
			}
			else if(streetaddress.value == null || streetaddress.value == "")
			{
	 			alert('You must enter valid street address');
	 			streetaddress.focus();
	 			return(false);			
			}
			else if(hour.value == "" || hour.value == null)
			{
				alert('You must select hour');
				hour.focus();
				return(false);
			}
			else if(minute.value == "")
			{
				alert('You must select delivery minute');
				minute.focus();
				return(false);
			}
			else if(half.SelectedIndex == 0)
			{
				alert('You must select AM/PM value');
				half.focus();
				return(false);
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('You must enter delivery date');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value == null || deliverydate.value == "")
			{	
				alert('You must enter delivery date');
				deliverydate.focus();
				return(false);			
			}
			else if(deliverydate.value !="")
			{
				var dt=document.search_prop.deliverydate;
				if (isDate(dt.value) == false)
				{
					dt.focus();
					return false;
				}
			}
		}
		window.location.href = "change_ordertype_verify.php?city="+city.value+"&state="+state.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&zipcode="+within.value+"&distance="+milesof.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordermethod="+ordermethod.value+"&streetaddress="+streetaddress.value+"&action="+"advance_select";	

		*/
		window.location.href = "change_ordertype_verify.php?city="+city.value+"&state="+state.value+"&longitude="+longitude.value+"&latitude="+latitude.value+"&deliverydate="+deliverydate.value+"&hour="+hour.value+"&minute="+minute.value+"&half="+half.value+"&ordermethod="+ordermethod.value+"&streetaddress="+streetaddress.value+"&action="+"advance_select";	
		//window.close();
	 }
}



/* SEARCH FUNCTION IF ORDER TYPE DELIVERY ENDS HERE(CHANGE ORDER)*/


/************************* FUNCTION FOR DATE VALIDATION ************************/
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to 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){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    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 = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=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("The date should be in the format mm-dd-yyyy")
		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
}
/*********************************** DATE FUNCTION ENDS HERE *******************************/

/************************* FUNCTION FOR CALCULATION LONGI & LATI ************************/
function openwindow(){
	if(document.search_prop.state.value !="" && document.search_prop.city.value !="")
	{
	var url='includes/yahooapistatic.php?address='+document.search_prop.streetaddress.value+'&city='+document.search_prop.city.value+'&state='+document.search_prop.state.value+'&etc='+'1&output='+'php';
	window.open(url, '_blank', "height=50,width=50");
	}
}

function openwindow_index(searchurl){
	if(document.search_prop_index_1.state.value !="" && document.search_prop_index_1.city.value !="")
	{
	var url='includes/yahooapihome.php?'+searchurl+'&etc='+'1&'+'&output='+'php';
	window.open(url, '_blank', "height=50,width=50");
	}
}

function openwindow_index_static(){
	if(document.search_prop_index.state.value !="" && document.search_prop_index.city.value !="")
	{
	var url='includes/yahooapistatic_left.php?address='+document.search_prop_index.streetaddress.value+'&city='+document.search_prop_index.city.value+'&state='+document.search_prop_index.state.value+'&etc='+'1&'+'&output='+'php';
	window.open(url, '_blank', "height=50,width=50");
	}
}


function openwindow_address_div(){
	if(document.search_tmp.state.value !="" && document.search_tmp.city.value !="")
	{
	var url='includes/yahooapi_addressdiv.php?address='+document.search_tmp.streetaddress.value+'&city='+document.search_tmp.city.value+'&state='+document.search_tmp.state.value+'&etc='+'1&output='+'php';
	window.open(url, '_blank', "height=50,width=50");
	}
}

/*********************************** DATE FUNCTION ENDS HERE *******************************/



/************FUNCTION FOR ACCESSING GOOGLE MAPS*******************/
function load(lati,longi,addr) 
{
   	window.open('googlemapnew.php?longitude='+longi+'&latitude='+lati+'&address='+addr);
	//window.open('http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAbGXH65YTFtsIyC503faZ-hS8LK252iDG6zvpm2zd7cPbauo0NhSMQtLC_hy_FGy4SA0WQ05Acs-JVQ&longitude='+longi+'&latitude='+lati);
/*    	
document.getElementById("Layer1").style.display="";	  
var map = new GMap2(document.getElementById("Layer1"));
//var center = new GLatLng(37.4419, -122.1419);
var center = new GLatLng(lati, longi);

map.setCenter(center, 15);

var marker = new GMarker(center, {draggable: true});

GEvent.addListener(marker, "dragstart", function() {
  map.closeInfoWindow();
  });
map.addOverlay(marker);
GEvent.addListener(map, "click", function(marker, point) {
  if (marker) {
    map.removeOverlay(marker);
  } else {
    map.addOverlay(new GMarker(point));
  }
}
);
*/
}
/*****************************/

/*************************************************/
function checkaddress(date, time, address, city, state, ordertype, zipcode)
{
	/*alert('pankaj');
	alert(date)
		alert(time);
	alert(address);
	alert(city);
	alert(state);
	*/
	//alert(ordertype);
	//alert(zipcode);
	//*/
	if(ordertype == null || ordertype =='')
	{
		alert('Please select to receive food by Pickup or Delivery.');
		return false;
	}
	else if(ordertype=='DELIVERY')
	{
		if((date=="" || time=="" || address =="") && zipcode =="" && (city!="" && state!=""))
		{
			alert('11 Please select (state & city) or (zip & distance), hour, minute & date & search again.');
			return(false);
		}
		if((date=="" || time=="" || address =="") && zipcode !="" && (city=="" && state==""))
		{
			alert('21 Please select (state & city) or (zip & distance), hour, minute & date');
			return(false);
		}
	}
	else
	{
		if((date=="" || time=="") && zipcode =="" && (city!="" && state!=""))
		{
			alert('12 Please select (state & city) or (zip & distance), hour, minute & date & search again.');
			return(false);
		}
		if((date=="" || time=="") && zipcode !="" && (city=="" && state==""))
		{
			alert('22 Please select (state & city) or (zip & distance), hour, minute & date');
			return(false);
		}
	
	}
}

function check_secondstep(ordertype)
{
	if(ordertype == 'delivery')
	{
		alert('xPlease select (state & city) or (zip & distance), street address, delivery time, date & search again.');
		return(false);
	}
	else
	{
		alert('yPlease select (state & city) or (zip & distance), time, date & search again.');
		return(false);
	}
}

/*************************************************/




/*************************************************/

function openwindow_changeorder(){
	
	ordertype = document.frmcheckout.ordtype.value;
	if(ordertype =='DELIVERY')
	{
		//load_address_div();
		var url='checkout_delivery.php?page=2';
		window.open(url, '_parent', "height=500,width=510");
		return false;
	}
	else if(ordertype =='TAKEOUT')
	{
	    //var url='checkout.php';
		//window.location.href="change_ordertype_verify.php?changeto=takeout&a=1";
		//return false;
		var url='checkout_1.php?page=1';
		window.open(url, '_parent', "height=500,width=510");
		return false;
	}
	else if(ordertype ==null || ordertype == '')
	{
		var url='select_ordertype.php';
		window.open(url, '_blank', "height=140,width=510");
		return false;
	}
	else
	{
		false
	}
}
function openwindow_changeorder_ram()
{
	var ordertype = document.frmcheckout.ordtype.value;
	alert(ordertype);
	/*if(stat_var == 'unavl')
	{
		alert('This restaurant is unavailable right now. Please try gain latter.');
		return false;
	}*/
	if(ordertype =='TAKEOUT')
	{
		
		load_address_div();
		//var url='change_ordertype.php';
		//window.open(url, '_blank', "height=140,width=506");
		//return false;
	}
	else if(ordertype =='DELIVERY')
	{
	//		var url='checkout.php';
		window.location.href="change_ordertype_verify.php?changeto=takeout";
		//return false;
	}
	else if(ordertype ==null || ordertype == '')
	{
		var url='select_ordertype.php';
		window.open(url, '_blank', "height=140,width=510");
		return false;
	}
	else
	{
		return false
	}
}



function openwindow_changeorder_new(ordertype, stat_var){
	if(stat_var == 'unavl')
	{
		alert('This restaurant is unavailable for your event. Please try again later.');
		return false;
	}
	else if(ordertype =='TAKEOUT')
	{
		return true;
	}
	else if(ordertype =='DELIVERY')
	{
	//		var url='checkout.php';
		window.location.href="change_ordertype_verify.php?changeto=takeout";
		//return false;
	}
	else if(ordertype ==null || ordertype == '')
	{
		alert("To order, please go back to results page and click on type: takeout or delivery.");
		//var url='select_ordertype.php';
		//window.open(url, '_blank', "height=140,width=510");
		return false;
	}
}



/*************************************************/
