﻿Scrolling = function(preid,interval,height,cnt)
{
	this.preid = preid;
	this.speed = 1;				//速度 px
	this.height = height;		//一次滚动 px
	this.cnt = cnt;				//1set 滚动条数
	this.interval = interval;	//运动间歇
	this.iswait = false;
	this.htmltxt = eval(preid+"Text");
	this.div = document.getElementById(this.preid);
	this.div.innerHTML = '<div id="'+this.preid+'_scroll" style="position:absolute;top:0;">'+this.htmltxt+this.htmltxt+'<\/div>';
	this.div_scroll = document.getElementById(this.preid+"_scroll");
	this.tmp = 0; this.ncnt=1;
	this.div.onmouseover=function(){ this.isover=true; }
	this.div.onmouseout=function(){	this.isover=false; }
	var self=this;
	window.setTimeout(function(){self.play()}, interval);
}
Scrolling.prototype.play = function() {
    var self=this;
    if(!self.div.isover) {
        var top = parseInt(self.div_scroll.style.top);
        this.div_scroll.style.top=top-self.speed+"px";
        if(self.tmp++ > self.height-1)
        {
            if(self.ncnt++ == self.cnt) { this.div_scroll.style.top=0; self.ncnt=1;} //원위치
            self.tmp=0;
            window.setTimeout(function(){self.play()}, this.interval);
            return;
        }
    } 
    window.setTimeout(function(){self.play()},1);
};



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'); 
 }
}
}

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 city=weather.weatherinfo.city;
	var date_y=weather.weatherinfo.date_y;
	var date=weather.weatherinfo.date;

var scrollWeatherText="<ul><li style=\"width:35PX;\"><img src=\"/images/weather/d"+weather.weatherinfo.img1+".gif\"><\/li><li>今日 杭州 "+weather.weatherinfo.weather1+"<br>"+weather.weatherinfo.temp1+" "+weather.weatherinfo.wind1+"<\/li><\/ul><ul><li style=\"width:35PX;\"><img src=\"/images/weather/d"+weather.weatherinfo.img3+".gif\"><\/li><li>明日 杭州 "+weather.weatherinfo.weather2+"<br>"+weather.weatherinfo.temp2+" "+weather.weatherinfo.wind2+"<\/li><\/ul>";
var wstr='<div id="WTS_media" title="浙江省杭州市 \n今日'+ weather.weatherinfo.weather1 +'('+weather.weatherinfo.temp1 +')\n'+ weather.weatherinfo.index_d +'">';
wstr+='<div class="L">'+date_y+'<br>'+date+'<\/div>';
wstr+='<div class="R" id="scrollWeather"><\/div>';
wstr+='<\/div>';
document.getElementById('WTS').innerHTML = wstr;
new Scrolling("scrollWeather",4100,27,2);
