var xmlHttp = null;
var xmlHttpMaster = null;
function showHintMap(index)
{
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	if (index == 0)
	    var url="iconMapHandler.ashx";
	else
	    var url="tempMapHandler.ashx";
//	url=url+"?q="+str;
//	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
function showHint(str)
{
    var cityDDl= null;
    var cityValue = null;
    var cityIndex = null;
   // cityValue = Get_Cookie("weatherCity");
   cityValue = readCookie("weatherCity","city_value");
   cityIndex = readCookie("weatherCity","city_index");
   if(cityValue != null)
   {
        str = cityValue;
        cityDDl = document.getElementById("ctl00_MainContent_city");
        if(cityDDl != null && cityIndex != null)
        {
              cityDDl.options[parseInt(cityIndex.toString())].selected = true;
        }
   }
        else
	    if (str.length==0)
	    { 
		    document.getElementById("weatherTxt").innerHTML="";
		    return;
	    }
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="http://www.mivzakon.co.il/weather/weather_HandlerNew.ashx";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function showHintMaster(str)
{
    var cityValue = null;
    
   // cityValue = Get_Cookie("weatherCity");
   cityValue = readCookie("weatherCity","city_value");
 //  cityIndex = readCookie("weatherCity","city_index");
   if(cityValue != null)
   {
        str = cityValue;
   }
   else
	    if (str.length==0)
	    { 
		    document.getElementById("masterWeatherDiv").innerHTML="";
		    return;
	    }
	xmlHttpMaster=GetXmlHttpObjectMaster()
	if (xmlHttpMaster==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var urlMaster="http://www.mivzakon.co.il/weather/masterWeatherHandler.ashx";
	urlMaster=urlMaster+"?q="+str;
	urlMaster=urlMaster+"&sid="+Math.random();
	xmlHttpMaster.onreadystatechange=stateChangedMaster;
	xmlHttpMaster.open("GET",urlMaster,true);
	xmlHttpMaster.send(null);
} 

function readCookie(name , valueName ) {
    var temp1 = null;
    var temp2 = null;
	var nameEQ = name + "=";
	var valueEQ = valueName +"=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) 
		{   temp1 = c.substring(nameEQ.length,c.length);
		    temp1 = temp1.split('&');
		    for (i=0; i<temp1.length;i++)
		    {
		        temp2= temp1[i];
		        while (temp2.charAt(0)==' ')temp2 = temp2.substring(1,temp2.length);
		        if (temp2.indexOf(valueEQ) == 0 )
		           return temp2.substring(valueEQ.length,temp2.length); 
		    }
		    
		   // return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function showWeatherCell()
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="http://www.mivzakon.co.il/weather/aspWeatherHandler.ashx";
	xmlHttp.onreadystatechange=stateChangedCell;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4&&document.getElementById("weatherTxt"))
	{ 
		document.getElementById("weatherTxt").innerHTML=xmlHttp.responseText;
	}
}
function stateChangedCell() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("weatherCell").innerHTML=xmlHttp.responseText;
	}
}

function stateChangedMaster() 
{ 
	if (xmlHttpMaster.readyState==4)
	{ 
		document.getElementById("masterWeatherDiv").innerHTML=xmlHttpMaster.responseText;
	}
}

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 GetXmlHttpObjectMaster()
{
	var xmlHttpMaster=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttpMaster=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttpMaster=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttpMaster=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttpMaster;
}
