var xmlHttp

function getDoc(url, doFunc, id){
	xmlHttp=GetXmlHttpObject();
    xmlHttp.onreadystatechange= function() { 
        if (xmlHttp.readyState==4)
            if (xmlHttp.status==200)
                doFunc(xmlHttp, id);
    }

    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function cuisineChanged(req, id) {
	
    document.getElementById(id).innerHTML = req.responseText;
}

function toggleMe(x){
	//url, function, Element id
	getDoc('getcuisine.asp?rid='+x, cuisineChanged, 'cus');	
	return false;
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function getvalidate(){

	var rid=document.frm.rid
	var cid=document.frm.cid
	var keyword=document.frm.keyword
	keyword.value = EliminateSpaces(keyword.value);
	
	if (rid.value=="0" &&cid.value=="0" && keyword.value==""){
		alert("Please select Restaurant or Cusine or enter Keyword.")
		rid.focus()
		return false
	}
	
	if(rid.value!="0" && cid.value=="0" && keyword.value=="") {
		window.location.href="chkpath.asp?flagi=0&rid="+rid.value+"&cid="+cid.value+"&keyword="+keyword.value
	}
	if(rid.value=="0" && cid.value!="0" && keyword.value!=""){
		window.location.href="chkpath.asp?flagi=1&cid="+cid.value+"&keyword="+keyword.value
	}
	if(rid.value!="0" && cid.value!="0" && keyword.value==""){
		window.location.href="chkpath.asp?flagi=2&rid="+rid.value+"&cid="+cid.value+"&keyword="+keyword.value
	}
	if(rid.value!="0" && cid.value=="0" && keyword.value!="") {
		window.location.href="chkpath.asp?flagi=3&rid="+rid.value+"&cid="+cid.value+"&keyword="+keyword.value
	}
	if(rid.value=="0" && cid.value!="0" && keyword.value==""){
		window.location.href="chkpath.asp?flagi=4&rid="+rid.value+"&cid="+cid.value+"&keyword="+keyword.value
	}
	if(rid.value!="0" && cid.value!="0" && keyword.value!=""){
		window.location.href="chkpath.asp?flagi=5&rid="+rid.value+"&cid="+cid.value+"&keyword="+keyword.value
	}
	if(rid.value=="0" && cid.value=="0" && keyword.value!=""){
		window.location.href="chkpath.asp?flagi=6&keyword="+keyword.value
	}
	return false
}

// eliminating the spaces in the control string
function EliminateSpaces(str){    
//leading spaces    
      var flag = 0;    
	  while (flag == 0){
	    substr = str.substring(0,1);	       
	    if (substr == " " ){
	      str = str.substring(1);	   
	    }
	    else{
	      flag = 1;
	    }    
	  }
	  // trailing Spaces
	  flag = 0;    
	  while (flag == 0){	  
	    substr = str.substring(str.length-1);	       
	    if (substr == " " ){

	       str = str.substring(0,str.length-1);	   
	    }
	    else{
	      flag = 1;
	    }    
	  }	

      var newstr = new String("");
	  for (var i=0; i<=str.length; i++){	  	   
	    substr = new String(str.substring(i-1,i+1));	      
	    if ((substr != "  " ) && (i != 0)) {
	     newstr = newstr.concat(substr.substring(0,1));
	    }
	  }
	  return newstr;
} 

