var xmlHttp 
	
	function GetXmlHttpObject(handler)
	{ 
		var objXmlHttp=null
		
		if (navigator.userAgent.indexOf("Opera")>=0)
		{
			alert("This example doesn't work in Opera") 
			return 
		}
		if (navigator.userAgent.indexOf("MSIE")>=0)
		{ 
			var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
			{
				strName="Microsoft.XMLHTTP"
			} 
			try
			{ 
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler 
				return objXmlHttp
			} 
			catch(e)
			{ 
				alert("Error. Scripting for ActiveX might be disabled") 
				return 
			} 
		} 
		if (navigator.userAgent.indexOf("Mozilla")>=0)
		{
		    objXmlHttp=new XMLHttpRequest()
			objXmlHttp.onload=handler
			objXmlHttp.onerror=handler 
			return objXmlHttp
		}
	}/*-- Function GetXmlHttpObject() Ends Here --*/
	
	function show_favourite(id){
		var restaurant_id = id;
		var page_path = document.getElementById('page_path').value;
		var url =page_path+restaurant_id; 
		xmlHttp=GetXmlHttpObject(select_item)
    	xmlHttp.open("GET", url , true)
    	xmlHttp.send(null) 
	}
	
	function select_item(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
	    	var str =xmlHttp.responseText;
	    	document.getElementById("display_item").innerHTML=xmlHttp.responseText
		}  
	}
	
	
    
    function voteNow(p,v,tyval)
     {   
     	if(document.getElementById('user_id').value=='')
     	{
     		 alert("Please login to continue...");
     		 var base_path = document.getElementById("base_path").value;
     		 window.location.href = base_path+"user/login";
     		 return false;
     	}
     
      	if(tyval=='1') {
	      	if(document.getElementById('rated_already_exists').value == "N") {	
	      		document.getElementById('food_status').value = "Y";
	      		document.getElementById('food_rate').value = p;
	      		document.getElementById('new_div_1'+v).innerHTML = "<font color='red' style='font-size:10px;'>Rate Added.</font>";
	      	} else {
	      		document.getElementById('new_div_1'+v).innerHTML = "<font color='red' style='font-size:9px;'>Rate Already Added for today.</font>";
	      	}
      	}
      	
      	if(tyval=='2') {
	      	if(document.getElementById('rated_already_exists').value == "N") {	
	      		document.getElementById('service_status').value = "Y";
	      		document.getElementById('service_rate').value = p;
	      		document.getElementById('new_div_2'+v).innerHTML = "<font color='red' style='font-size:10px;'>Rate Added.</font>";
	      	} else {
	      		document.getElementById('new_div_2'+v).innerHTML = "<font color='red' style='font-size:9px;'>Rate Already Added for today.</font>";
	      	}
      	}
      	
      	if(tyval=='3') {
	      	if(document.getElementById('rated_already_exists').value == "N") {	
	      		document.getElementById('ambiance_status').value = "Y";
	      		document.getElementById('ambiance_rate').value = p;
	      		document.getElementById('new_div_3'+v).innerHTML = "<font color='red' style='font-size:10px;'>Rate Added.</font>";
	      	} else {
	      		document.getElementById('new_div_3'+v).innerHTML = "<font color='red' style='font-size:9px;'>Rate Already Added for today.</font>";
	      	}
      	}
      	
      	
      	document.getElementById('rated_status').value = "Y";
     }
    
    //poll process starts here
	  function process_vote(p,v,tyval)
		{
		  var url = document.getElementById('rating_path').value+p+"/"+v+"/"+tyval;
		   xmlHttp=GetXmlHttpObject(pollChangeds);
		   xmlHttp.open("GET", url , true);
		   xmlHttp.send(null);
		}  
		
	  function pollChangeds() 
		{ 
		   if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 {
				 var rel_id =xmlHttp.responseText;
				 related_ids_array = rel_id.split("######"); 
				 var point= related_ids_array[1];
				 related_ids=point.split('<');
				 var rel_array = related_ids[0];
				 var rel = rel_array.split('_'); 
				 //var new_div ="new_div_"+related_ids[0];
				 //var defaults ="defaults_"+related_ids[0];
				 var new_div ="new_div_"+rel[0]+rel[1];
				 var defaults ="defaults_"+rel[0]+rel[1];
				 document.getElementById(defaults).style.display='none'; 
				 document.getElementById(new_div).style.display='block';
				 document.getElementById(new_div).innerHTML=related_ids_array[0]; 
			 } 
		   else
		     {
		        document.getElementById("new_div").innerHTML = "progress...";
		     }
		    
		} 
		
		function report_abuse(){
				var url = document.getElementById("path_abuse").value;	
				window.open(url,"mywindow","width=600,height=250,location=0"); 
		}
		
		function rate_popup(){
				var url = document.getElementById("rate_star_path").value;
				window.open(url,"mywindow","width=450,height=320,location=0,top=250,left=200");
		}
		
		function update_window(){
				window.opener.location.reload();
				window.close();
		}