	/* *******************************************/
	/*	File: dropdown.js
		Description: JS Document To Show html contents of Dropdown using Ajax For Sending and 
					 Recieving Request(s) for Ajax on Musaras.ca Admin Section
		Date: December 1, 2007
		Copyright (c) 2007 - 2008, Avenir Technologies (Pvt.) Ltd.
		All rights reserved. 
		Author: Ikram Hassan
		Email : ik_malik2001@yahoo.com */
	/* ****************************************** */

	/*********************************************/
	// Function to get list of zip codes...
	/*********************************************/
	function sndReq(vote,id_num,ip_num,units) {
	prod_id = id_num;
	document.getElementById('rating_click').value = "Applied";
	var theUL = document.getElementById('unit_ul'+id_num); // the UL
	
	// switch UL with a loading div
	theUL.innerHTML = '<div class="loading"></div>';
	//alert("rpc: "+ 'rpc.php?j='+vote+'&q='+id_num+'&t='+ip_num+'&c='+units);
    xmlhttp.open('get', 'rpc_new.php?j='+vote+'&q='+id_num+'&t='+ip_num+'&c='+units);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);	
}

function handleResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
		//alert("prod:"+ prod_id + "response: "+ response);
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
			//show_rest_ratings(prod_id, '5');
			show_rest_ratings_temp(prod_id, '5');
            //changeText(update[0], update[1]);
        }
		}
    }
}
Event.observe(window, 'load', init_rest_rat_temp);

function init_rest_rat_temp() {
  // Attach handler to form's submit event
  Event.observe('gcontainer', 'load', show_rest_ratings_temp);
}
function show_rest_ratings_temp(e, h) {
// Update user interface
  document.getElementById('gcontainer').style.display='';
  document.getElementById('gcontainer').innerHTML ='<table width="100%" ><tr><td align="center" ><img src="images/working.gif"> &nbsp; &nbsp; &nbsp; <img src="images/working.gif"></td></tr></table>';
   var url="view_rating_temp.php?prod_id="+e+"&unit="+h;
       // xmlHttp.onreadystatechange=showRating;
	    xmlHttp.open("GET",url,true);
		   xmlHttp.send(null);
  // Prepare query string and send AJAX request
   //var pars = 'prod_id=' + e+'&unit='+ h;
   //alert("pars: "+ pars);
  //var myAjax = new Ajax.Updater('gcontainer', 'view_rating_temp.php', {method: 'get', parameters: pars});
  // Stop form from submitting when JavaScript is enabled
  //Event.stop(e);
}
	function show_rest_ratings(e, h) {
	document.getElementById('gcontainer').style.display='';
	// Generating Ajax Object
		xmlHttp=GetXmlHttpObject()
		
		// if match criteria
		if (xmlHttp==null)
		{
			// Showing user message
			alert ("Your browser does not support AJAX!");
			return;
		}
		// Making Request Format  For zip codes
		    var url="view_rating.php?prod_id="+e+"&unit="+h;
		
		// the following line was commented out by edwin due to popup reappearing on live site 
		// alert("url: "+ url)
		   xmlHttp.onreadystatechange=showRating;
		   xmlHttp.open("GET",url,true);
		   xmlHttp.send(null);

	}
		function showRating() 
	{
		// if returned response is in ready state to give output
		if (xmlHttp.readyState==4)
		{
			// Showing Output on template from returned responsed Text
			document.getElementById('gcontainer').innerHTML = xmlHttp.responseText;
		
		}
		else
		{
			// Showing Pre-loader as Output on template before showing returned responsed Text
			document.getElementById('gcontainer').innerHTML='<table width="100%" ><tr><td align="center" ><img src="images/working.gif"> &nbsp; &nbsp; &nbsp; <img src="images/working.gif"></td></tr></table>';
		}
	}

	
	function select_zip(str, state_id, zip_code)
	{
		// if match criteria
		if (str.length==0)
		{
			// Updating HTML Interface by Assigning values
			document.getElementById('zip_txt').innerHTML="";
			return;
		}
		// Generating Ajax Object
		xmlHttp=GetXmlHttpObject()
		
		// if match criteria
		if (xmlHttp==null)
		{
			// Showing user message
			alert ("Your browser does not support AJAX!");
			return;
		}
		// Making Request Format  For zip codes
		var url="view_zip_list.php?id="+str+"&state_id="+state_id+"&zip_code="+zip_code;
		
		// the following line was commented out by edwin due to popup reappearing on live site 
		// alert("url: "+ url)
		xmlHttp.onreadystatechange=stateChanged_zip;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	/* Recieving Response  For  zip codes */
	function stateChanged_zip() 
	{
		// if returned response is in ready state to give output
		if (xmlHttp.readyState==4)
		{
			// Showing Output on template from returned responsed Text
			document.getElementById('zip_txt').innerHTML = xmlHttp.responseText;
		
		}
		else
		{
			// Showing Pre-loader as Output on template before showing returned responsed Text
			document.getElementById('zip_txt').innerHTML='<img src="_admin/images/loader.gif"> &nbsp; &nbsp; &nbsp; <img src="_admin/images/loader.gif">&nbsp; &nbsp; &nbsp; <img src="_admin/images/loader.gif">';
		}
	}
	/*********************************************/
	// Function to get list of zip codes...
	/*********************************************/
	function select_nbr(str, state_id, nbr_id)
	{
		// if match criteria
		if (str.length==0)
		{
			// Updating HTML Interface by Assigning values
			//document.getElementById('nbr_txt').innerHTML="";
			//return;
		}
		// Generating Ajax Object
		xmlHttp=GetXmlHttpObject()
		
		// if match criteria
		if (xmlHttp==null)
		{
			// Showing user message
			alert ("Your browser does not support AJAX!");
			return;
		}
		// Making Request Format  For zip codes
		var url="view_nbr_list.php?id="+str+"&state_id="+state_id+"&nbr_id="+nbr_id;
		
		// the following line was commented out by edwin due to popup reappearing on live site 
		// alert("url: "+ url)
		xmlHttp.onreadystatechange = stateChanged_nbr;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	/* Recieving Response  For  zip codes */
	function stateChanged_nbr() 
	{
		// if returned response is in ready state to give output
		if (xmlHttp.readyState==4)
		{
			// Showing Output on template from returned responsed Text
			document.getElementById('nbr_txt').innerHTML = xmlHttp.responseText;
		
		}
		else
		{
			// Showing Pre-loader as Output on template before showing returned responsed Text
			document.getElementById('nbr_txt').innerHTML='<img src="images/loader.gif"> &nbsp; &nbsp; &nbsp; <img src="images/loader.gif">&nbsp; &nbsp; &nbsp; <img src="images/loader.gif">';
		}
	}
	/*********************************************/
	// Function to get list of States...
	/*********************************************/
	function select_state(str, state_id, city_id, zip_code)
	{
		/*if (str.length==0)
		{
			document.getElementById('state_txt').innerHTML="";
			return;
		}*/
		
		// Generating Ajax Object
		xmlHttp=GetXmlHttpObject()
		
		// if match criteria
		if (xmlHttp==null)
		{
			// Showing user message
			alert ("Your browser does not support AJAX!");
			return;
		} 
		// Making Request Format  For zip codes
		var url="view_state_list.php?id="+str+"&state_id="+state_id+"&city_id="+city_id+"&zip_code="+zip_code;
		
		// the following line was commented out by edwin due to popup reappearing on live site 
		// alert("url: "+ url)
		xmlHttp.onreadystatechange=stateChanged_state;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	/* Recieving Response  For states list */
	function stateChanged_state() 
	{ 
		// if returned response is in ready state to give output
		if (xmlHttp.readyState==4)
		{ 
			// Showing Output on template from returned responsed Text
			document.getElementById('state_txt').innerHTML = xmlHttp.responseText;
		
		}
		else
		{
			// Showing Pre-loader as Output on template before showing returned responsed Text
			document.getElementById('state_txt').innerHTML='<img src="_admin/images/loader.gif"> &nbsp; &nbsp; &nbsp; <img src="_admin/images/loader.gif">&nbsp; &nbsp; &nbsp; <img src="_admin/images/loader.gif">';
		}
	}
	/*********************************************/
	// Function to get list of cities...
	/*********************************************/
	function select_city(str, city_id, zip_code)
	{
		// if match criteria
		if (str.length==0)
		{
			// Updating HTML Interface by Assigning values
			document.getElementById('city_txt').innerHTML="";
			return;
		}
		// Generating Ajax Object
		xmlHttp_city=GetXmlHttpObject()
		
		// if match criteria
		if (xmlHttp_city==null)
		{
			// Showing user message
			alert ("Your browser does not support AJAX!");
			return;
		}
		// Making Request Format  For cities
		var url="view_cities_list.php?state_id="+str+"&city_id="+city_id+"&zip_code="+zip_code;
		
		// the following line was commented out by edwin due to popup reappearing on live site 
		//alert("url: "+ url)
		xmlHttp_city.onreadystatechange=stateChanged1;
		xmlHttp_city.open("GET",url,true);
		xmlHttp_city.send(null);
	}
	/* Recieving Response  For cities list */
	function stateChanged1() 
	{ 
		// if returned response is in ready state to give output
		if (xmlHttp_city.readyState==4)
		{ 
			// Showing Output on template from returned responsed Text
			document.getElementById('city_txt').innerHTML = xmlHttp_city.responseText;
		
		}
		else
		{
			// Showing Pre-loader as Output on template before showing returned responsed Text
			document.getElementById('city_txt').innerHTML='<img src="_admin/images/loader.gif"> &nbsp; &nbsp; &nbsp; <img src="_admin/images/loader.gif">&nbsp; &nbsp; &nbsp; <img src="_admin/images/loader.gif">';
		}
	}
	/*********************************************/
	// Function to get list of cities...
	/*********************************************/
	function select_city2(str, city_id)
	{
		// if match criteria
		if (str.length==0)
		{
			// Updating HTML Interface by Assigning values
			document.getElementById('city_txt').innerHTML="";
			return;
		}
		// Generating Ajax Object
		xmlHttp_city2=GetXmlHttpObject()
		
		// if match criteria
		if (xmlHttp_city2==null)
		{
			// Showing user message
			alert ("Your browser does not support AJAX!");
			return;
		}
		// Making Request Format  For cities
		var url="view_cities2_list.php?state_id="+str+"&city_id="+city_id;
		
		// the following line was commented out by edwin due to popup reappearing on live site 
		//alert("url: "+ url)
		xmlHttp_city2.onreadystatechange=stateChanged2;
		xmlHttp_city2.open("GET",url,true);
		xmlHttp_city2.send(null);
	}
	/* Recieving Response  For cities list */
	function stateChanged2() 
	{ 
		// if returned response is in ready state to give output
		if (xmlHttp_city2.readyState==4)
		{ 
			// Showing Output on template from returned responsed Text
			document.getElementById('city_txt').innerHTML = xmlHttp_city2.responseText;
		
		}
		else
		{
			// Showing Pre-loader as Output on template before showing returned responsed Text
			document.getElementById('city_txt').innerHTML='<img src="images/loader.gif"> &nbsp; &nbsp; &nbsp; <img src="images/loader.gif">&nbsp; &nbsp; &nbsp; <img src="images/loader.gif">';
		}
	}	
	/*********************************************/
	// Function Body XML HTTP Object for Ajax
	/*********************************************/
	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;
	}