var rs= "http://61.4.185.48:81/g/";
var visitor=new Cookie(document,"cityid",43800,"/","m.weather.com.cn","/");
visitor.load(); 
var std="";
var url = window.location.href; 
var start=url.indexOf("id"); 
var end=url.indexOf("T"); 
if(start!=-1){
var first=start+parseInt(3);
call = url.substring(first,end);
 res(call);
}
else{//传参开始
if(!visitor.idinfo||!visitor.date)
{
var js = document.createElement("script"); 
js.setAttribute("type", "text/javascript");
js.setAttribute("src",rs);
document.body.insertBefore(js, null);
function id_callback(){ 
std = id;
visitor.idinfo=std;
visitor.date="5";
visitor.store();
 res(std);
} 
}
else
{
std=visitor.idinfo;
res(std);
}
if(typeof(id)=="undefined"){
var id="101010100";
res(id);

}
else
{
std=visitor.idinfo;
res(std);
}
}///传参时程序结束
function res(id){
if(id==""){
str="101010100";
var datetime='/data/'+str+'.html';
}
else
{
var datetime='/data/'+id+'.html';

}

var xmlhttp=null; 
function createXMLHTTPRequext(){ 
if (window.XMLHttpRequest){
	xmlhttp = new XMLHttpRequest(); //Mozilla

	}
else if (window.ActiveXObject) {
xmlhttp =new ActiveXObject("Msxml2.XMLHTTP") ;
if (! xmlhttp ){
 xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); 
 }
}
}
var jsonobj;

function HandleStateChange() 
{
    if (xmlhttp.readyState == 4){
       var jsontext =xmlhttp.responseText;
       var func = new Function("return " + jsontext);
       jsonobj = func();
    } 
}

function PostOrder(xmldoc) 
{ 
    createXMLHTTPRequext();
    
    xmlhttp.open("GET", xmldoc,false); 
    xmlhttp.onreadystatechange= HandleStateChange;  
    xmlhttp.send(null); 


}


    var xmlhttp; 
    PostOrder(datetime);
    HandleStateChange();
    var cityname=jsonobj.weatherinfo.city;
    var id=jsonobj.weatherinfo.cityid;    
    var cityinfo1=jsonobj.weatherinfo.weather1;
    var cityinfo2=jsonobj.weatherinfo.weather2;
    var wd1=jsonobj.weatherinfo.wind1;
    var wd2=jsonobj.weatherinfo.wind2;
    var temp1=jsonobj.weatherinfo.temp1;
    var temp2=jsonobj.weatherinfo.temp2;
    var img1=jsonobj.weatherinfo.img1;
    var img2=jsonobj.weatherinfo.img2;
    var img3=jsonobj.weatherinfo.img3;
    var img4=jsonobj.weatherinfo.img4;
    var index=jsonobj.weatherinfo.index;
    var index_d=jsonobj.weatherinfo.index_d;
    var index_xc=jsonobj.weatherinfo.index_xc;
    var index_uv=jsonobj.weatherinfo.index_uv;
    var date=jsonobj.weatherinfo.date;
    var date_y=jsonobj.weatherinfo.date_y;
    var imgtitle1=jsonobj.weatherinfo.img_title1;
    var imgtitle2=jsonobj.weatherinfo.img_title2;
    var fl1=jsonobj.weatherinfo.fl1;
    var fl2=jsonobj.weatherinfo.fl2;
    var imgsingle=jsonobj.weatherinfo.img_single;
    var imgtitlesingle=jsonobj.weatherinfo.img_title_single;
    
for(var i=1;i<=document.getElementsByTagName("A").length;i++)
{
var num1="url"+i;
var bs=document.getElementById(num1).href="http://www.weather.com.cn/html/weather/"+id+".shtml";
}
if(document.getElementById("small1") != null)
{
	document.getElementById("small1").src="http://m.weather.com.cn/img/c"+img1+".gif";
	document.getElementById("small1").title=imgtitle1;
	document.getElementById("small1").alt=imgtitle1;
}
if(document.getElementById("small2")!=null)
{
	if( img2 != '99')
	{
		document.getElementById("small2").src="http://m.weather.com.cn/img/c"+img2+".gif";
		document.getElementById("small2").title=imgtitle2;
		document.getElementById("small2").alt=imgtitle2;
	}
	else
	{
		document.getElementById("small2").style.height='0px';
		document.getElementById("small2").title='';
		document.getElementById("small2").alt='';
	}
}
if(document.getElementById("small") != null) // 单天气现象的图标（小）
{
	document.getElementById("small").src="http://m.weather.com.cn/img/c"+imgsingle+".gif";
	document.getElementById("small").title=imgtitlesingle;
	document.getElementById("small").alt=imgtitlesingle;
}
if((document.getElementById("big1")!=null) && (document.getElementById("big1") != '99'))
{
	document.getElementById("big1").src="http://m.weather.com.cn/img/b"+img1+".gif";
	document.getElementById("big1").title=imgtitle1;
	document.getElementById("big1").alt=imgtitle1;
}
if(document.getElementById("big2")!=null)
{
	if( img2 != '99')
	{
		document.getElementById("big2").src="http://m.weather.com.cn/img/b"+img2+".gif";
		document.getElementById("big2").title=imgtitle2;
		document.getElementById("big2").alt=imgtitle2;
	}
	else
	{
		document.getElementById("big2").style.height='0px';
		document.getElementById("big2").title='';
		document.getElementById("big2").alt='';
	}
}
if(document.getElementById("big") != null) // 单天气现象的图标（大）
{
	document.getElementById("big").src="http://m.weather.com.cn/img/b"+imgsingle+".gif";
	document.getElementById("big").title=imgtitlesingle;
	document.getElementById("big").alt=imgtitlesingle;
}
if(document.getElementById("city")!=null)
{
	document.getElementById("city").innerHTML=cityname;
}
if(document.getElementById("weather1")!=null)
{
	if( cityinfo1.length > 8 )
	{
		document.getElementById("weather1").innerHTML =cityinfo1.substr(0,7)+'...';
		document.getElementById("weather1").title = cityinfo1;
	}
	else
	{
		document.getElementById("weather1").innerHTML =cityinfo1;
	}
}

//document.getElementById("weather2").innerHTML =cityinfo2;
if(document.getElementById("temp1")!=null)
{
	document.getElementById("temp1").innerHTML =temp1;
}
//document.getElementById("temp2").innerHTML =temp2;
if(document.getElementById("wd1")!=null)
{
	if( fl1 == '小于3级' )
	{
		fl1 = '微风';
	}
	document.getElementById("wd1").innerHTML =fl1;
}
//document.getElementById("wd2").innerHTML =wd2; 
if(document.getElementById("img1")!=null)
{
	document.getElementById("img1").innerHTML =img1;
}
if(document.getElementById("img2")!=null)
{
	document.getElementById("img2").innerHTML =img2;
}
//document.getElementById("img3").innerHTML =img3;
//document.getElementById("img4").innerHTML =img4;
if(document.getElementById("index")!=null)
{
	document.getElementById("index").innerHTML =index;
}
if(document.getElementById("index_d")!=null)
{
	document.getElementById("index_d").innerHTML =index_d;
}
if(document.getElementById("index_xc")!=null)
{
	document.getElementById("index_xc").innerHTML =index_xc;
}
if(document.getElementById("index_uv")!=null)
{
	document.getElementById("index_uv").innerHTML =index_uv;
}
if(document.getElementById("date")!=null)
{
	document.getElementById("date").innerHTML =date;
}
if(document.getElementById("date_y")!=null)
{
	document.getElementById("date_y").innerHTML =date_y;
}
}
