

function EscapeSpecialChar(str)
 {
   if(str!=null   &&   str.length>0)  
  {  
  if(str.indexOf("\f")!=-1)  
  str=str.replace("\f","&#92;f");  
  if(str.indexOf("\n")!=-1)  
  str=str.replace("\n","&#92;n");  
  if(str.indexOf("\r")!=-1)  
  str=str.replace("\r","&#92;r");  
  if(str.indexOf("\t")!=-1)  
  str=str.replace("\t","&#92;t");  
  if(str.indexOf("\'")!=-1)  
  str=str.replace("\'","&#92;'"); 
  }  
 
  return   str;    
 }
function ShowWeatherDetail(city){
	
	if (typeof document.body.style.maxHeight != "undefined") {
	  // IE 7, mozilla, safari, opera 9
		path = "weather/_weatherdetail.php?city=";
		imgPath = "images/loading_alt.gif";
	} else {
	  // IE6, older browsers
		path = "../weather/_weatherdetail.php?city=";
		imgPath = "../images/loading_alt.gif";
	}
	
	document.getElementById("weatherDetail").innerHTML ="<div style=\"text-align: center;\"><img src=\""+imgPath+"\" /><br/><br/><b>Loading Weather Data. . .</b></div> ";
	xmlHttp = createXmlHttp();
	if (xmlHttp) {
		
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			//try to connect to the server
			try{
				// Initiate reading the async.txt file from the server
				xmlHttp.open("GET", path+city, true);
				//Send the proper header information along with the request
				xmlHttp.onreadystatechange = handleRequestStateChangeWeather;
				xmlHttp.send(null);
	
			}catch(z){
				//Display the error in case of failure
				alert("Can't Connect to the server:\n"+ z.toString());
			}
	 
		} else {
			// if the connection is busy, try again after 1/4 second  
			setTimeout('findWeather('+city+')', 250);
		}
		
		city = EscapeSpecialChar(city);
            if(city.indexOf(',')!=-1)        
            {
	           city = city.substr(0,city.indexOf(','));	
	          
			 document.getElementById('hide').value = city;
            }	
		
	} else {
		alert('There was an error creating the XML Object.');
	}
}

function handleRequestStateChangeWeather(){
	//alert("Handling");
	// Obtain a reference to the <div> element on the page
	weatherDiv = document.getElementById('weatherDetail');

			//Continue only if the server response if "OK"
			if(xmlHttp.readyState == 4){
				
				if(xmlHttp.status == 200){
				try{
				
					//Read the message from the server
					response = xmlHttp.responseText;
				
					// Display the result
					weatherDiv.innerHTML = response;

				}catch(z){
					alert("Error reading the response: "+ z.toString());
				}
				
			}else{
				// Display error message
				alert("There was an error getting the data:\n" + xmlHttp.statusText)
			}
			}
			
}


function RefreshSatImg(){
 document.getElementById('satImg').innerHTML = '';

 document.getElementById('satImg').innerHTML = "<img src=\"http://www.intellicast.com/Partners/statusfirm/images/SatelliteIR/namer+.jpg\" /><br/>";
 //document.getElementById('satevent').innerHTML = "<img src=\"images/bullet_arrow.gif\" align=\"absmiddle\"/> &nbsp;<a href=\"javascript:CloseSatImg();\">close satellite image</a>";
		       				                   
}

function CloseSatImg(){
 document.getElementById('satImg').innerHTML = '';

 document.getElementById('satevent').innerHTML = "<img src=\"images/bullet_arrow.gif\" align=\"absmiddle\"/> &nbsp;<a href=\"javascript:RefreshSatImg();\">view satellite image</a>";

}





