//银行汇率控件JS

var HtmlParser=function(){
 this.urljsp="template/390/Wearther/html_date.jsp";
 this.urlhtml="put.html";
 this.tdnumber=4;
 this.td="0,1,2,3";//0--6
 this.tr="0,1,2,3,4,5,6,7,8,9";//0--9
 this.time=80;
}
HtmlParser.prototype={
  getJson:function(url){
  var obj=this;
  obj.ShowAnd(true);
   $.getJSON(url,function(date){
   	 var json=eval(date);
   	 obj.setHtml(json);
   });
  },
 ShowAnd:function(sing){
  if(sing)	
    $("#YingHeng").css("display","none");
  else
     $("#YingHeng").css("display","inline");
  },
  setHtml:function(json){
 //   alert(json[0]);
  	var ob=this;
     $("#YingHeng TD").each(function(i){
     	          var hang=(i%ob.tdnumber).toString();
     	          if(ob.td.indexOf(hang)!=-1)
                      $(this).attr("id","date"+i);
                  else
                      $(this).remove();
                      });
     
      $("#YingHeng TR").each(function(i){    
                  var hangl=(i).toString();         
     	          if(ob.tr.indexOf(hangl)!=-1)
                      $(this).attr("id","daterow"+i);
                  else
                      $(this).remove();
                      });
                      
     for(key in json){
       if(key!=json.length-1){
        if(json[key]!="none")
         $("#date"+key).html(json[key]);
        else
         $("#date"+key).html("&nbsp;");
       }
       else
          $("#Time").html(json[key]);
    }
    ob.RomeDome();
    
  },
  RomeDome:function(){
    var obj=this;
    var divwidth=254;
	var divheight=70;
	var countMin=-25;
	var current=0;
	var divobj=$("#Kingjing");
	var TABLEobj=divobj.find("TABLE");
	divobj.css({"position":"relative","overflow":"hidden","height":divheight,"width":divwidth});
//	TABLEobj.css({"position":"relative"});
	TABLEobj.css({"position":"relative"});
	$("#YingHangDate").css({"position":"relative"});
	setInterval(MoveDom,this.time);
	function MoveDom(){
	obj.ShowAnd(false);
   if(current>countMin)	{	
      TABLEobj.css("top",current+"px");
      current--;
   }
    else  if(current==countMin){
    	TABLEobj.css("top",countMin+"px");
    	current--;
          
      }else if(current<countMin){      	
        var firt=TABLEobj.find("TR").get(0);
       	TABLEobj.append(firt);
       	TABLEobj.css("top",0+"px");
       current=0;
      }
	}
  }
  
}
$(function() {
          var html=new HtmlParser();
          html.getJson(html.urljsp);
          //html.getHtml();
                   
		})
		


//天气预报控件JS

var Weather=function(){
 this.url="template/390/Wearther/Weather.jsp";
}
Weather.prototype={
getJson:function(){
	var obj=this;
 $.getJSON(obj.url,function(date){
   var json=eval(date);
   obj.setHtml(json);
 });
},
setHtml:function(jsonn){
  var html_ciry=$("<div></div>").html(jsonn["weatherinfo"]["city"]).attr("id","html_ciry");
  var html_temperature=$("<div></div>").html(jsonn["weatherinfo"]["temp1"]).attr("id","html_temperature");
  var html_weather=$("<div></div>").html(jsonn["weatherinfo"]["weather1"]).attr("id","html_weather");
  var html_wind=$("<div></div>").html(jsonn["weatherinfo"]["wind1"]).attr("id","html_wind");
  var html_img=$("<div></div>").attr("id","html_img");
  
  var html_img1=$("<img />").attr("src","http://m.weather.com.cn/img/c"+jsonn["weatherinfo"]["img1"]+".gif");
  html_img.append(html_img1);

   
 if(jsonn["weatherinfo"]["img2"].toString()!="99"){  
   var html_img2=$("<img />").attr("src","http://m.weather.com.cn/img/c"+jsonn["weatherinfo"]["img2"]+".gif");
  html_img.append(html_img2);
 }

  $("#NewWearther").append(html_ciry);
  $("#NewWearther").append(html_img);
  $("#NewWearther").append(html_weather);  
  $("#NewWearther").append(html_temperature); 
  $("#NewWearther").append(html_wind); 
}

}

$(function() {
          var wer=new Weather();
          wer.getJson();
		})