

// JavaScript Document
var xmlHttp
function showWeather(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getWeather.php";
url=url+"?id="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("weather").innerHTML="";
document.getElementById("weather").innerHTML=xmlHttp.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 hideWeatherForm()
{
	document.getElementById("w").innerHTML="<a href='#' onclick='showWeatherForm(); return false;'><img src='my weather.png' /></a>";
}

function showWeatherForm(id)
{
	
	xmlHttpWeather=GetXmlHttpObjectLoadWeather();
if (xmlHttpWeather==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="showUserWeather.php";

xmlHttpWeather.onreadystatechange=stateChangedWeather;
xmlHttpWeather.open("GET",url,true);
xmlHttpWeather.send(null);
}

function stateChangedWeather() 
{ 
if (xmlHttpWeather.readyState==4)
{ 
var reply  = xmlHttpWeather.responseText;

document.getElementById("w").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadWeather()
{
var xmlHttpWeather=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpWeather=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpWeather=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpWeather=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpWeather;
}


function sendWeather()
{
	//var name = document.frmweather.name.value;
	//var address = document.frmweather.address.value;
	//var phone = document.frmweather.phoneno.value;
	//var city = document.frmweather.city.value;
	//var img = document.frmweather.image.value;
	//if(emai.length==0)
	//{
		
		//return;
	//}
	//xmlHttpSend=GetXmlHttpObjectLoadSend();
	//if (xmlHttpSend==null)
	  //{
	  //alert ("Your browser does not support AJAX!");
	 // return;
	 //} 
	//var url="sendWeather.php";
	//url=url+"?name="+name;
	//url=url+"&address="+address;
	//url=url+"&phone="+phone;
	//url=url+"&city="+city;
	//url=url+"&img="+img;
	//xmlHttpSend.onreadystatechange=stateChangedSend;
	//xmlHttpSend.open("POST",url,true);
	//xmlHttpSend.setRequestHeader("Content-type", "multipart/form-data");
	//xmlHttpSend.setRequestHeader("Connection", "close");
	//xmlHttpSend.setRequestHeader("Content-length", 0);
	//xmlHttpSend.send(null);
	document.getElementById("feedback").innerHTML="Weather Uploaded";
}



function stateChangedSend() 
{ 

if (xmlHttpSend.readyState==4)
{ 
var reply  = xmlHttpSend.responseText;



document.getElementById("w").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadSend()
{
var xmlHttpSend=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpSend=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpSend=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpSend=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpSend;
}
function updateCount()
{
	var comment = document.frm.message.value;
	var length= comment.length;
	
	if(length==0)
	{
		document.frm.message.value="";
		document.getElementById("character").innerHTML="160 characters remaining";
		return;
	}
	
	if(rem==0)
	{
		return;
	}
	var rem= 160 - length;
	document.getElementById("character").innerHTML=rem + " characters remaining";

}
