function $(d){return document.getElementById(d);}
String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}
var isIE = (document.all) ? true : false;
function _g(box){var xy={"x":box.offsetLeft,"y":box.offsetTop};while(box=box.offsetParent){xy.x+=box.offsetLeft;xy.y+=box.offsetTop;}return xy;}
var Class = {create: function() {return function() { this.initialize.apply(this, arguments); }}};
var Bind = function (obj,fun,arr){return function() {return fun.apply(obj,arr);}}
function addEventHandler(oTarget, sEventType, fnHandler) {
	if (oTarget.addEventListener) {oTarget.addEventListener(sEventType, fnHandler, false);} 
	else if (oTarget.attachEvent) {oTarget.attachEvent("on" + sEventType, fnHandler);} 
	else {oTarget["on" + sEventType] = fnHandler;}
};
function removeEventHandler(oTarget, sEventType, fnHandler) {
    if (oTarget.removeEventListener) {oTarget.removeEventListener(sEventType, fnHandler, false);} 
	else if (oTarget.detachEvent) {oTarget.detachEvent("on" + sEventType, fnHandler);} 
	else { oTarget["on" + sEventType] = null;}
};
var Marquee = Class.create();
Marquee.prototype = {
  initialize: function(id,name,out,speed) {
    this.name = name;
	this.box = $(id)
	this.out  = out;
	this.speed = speed;
	var _li = this.box.firstChild;
	while(typeof(_li.tagName)=="undefined"){
		_li = _li.nextSibling;
	}
	this.line = _li.offsetHeight;
	var tags = this.box.getElementsByTagName(_li.tagName);
	this.len = tags.length;
	var ge = Math.floor(this.box.offsetHeight/this.line);
	for(i=0;i<ge;i++){
		var __li = document.createElement(_li.tagName);
		__li.innerHTML = tags[i].innerHTML;
		this.box.appendChild(__li);
	}
	this.box.scrollTop = 0;
	this.Start();
	addEventHandler(this.box, "mouseover",Bind(this,function(){clearTimeout(this.timeout);},[]));
	addEventHandler(this.box, "mouseout",Bind(this,this.Start,[]));
  },
  Start:function (){
	  clearTimeout(this.timeout);
	  this.timeout = setTimeout(this.name+".Up()",this.out*1000)
  },
  Up:function(){
	  clearInterval(this.interval);
	  this.interval = setInterval(this.name+".Fun()",10);
  },
  Fun:function (){
	  this.box.scrollTop+=this.speed;
	  if(this.box.scrollTop%this.line==0){
	    clearInterval(this.interval);
		this.Start();
	  }
	  if(this.box.scrollTop>=this.line*this.len)this.box.scrollTop = 0;

  }
}
var  marquee,
     root,
	 msn,
	 msgClose,
	 moveR;
	 //t_w,
	 //t_h;
addEventHandler(window, "load", loadFun);
function loadFun(){
	marquee = new Marquee("top_new","marquee",4,1);
	
	msn = $("today");
	msgClose = $("msgClose");
	root = document.documentElement;
	
	setTimeout("msn.style.visibility='visible';moveR();",1000);
	
	
    //msn.style.top=root.clientHeight-msn.offsetHeight + "px";
    //msn.style.left=root.clientWidth-msn.offsetWidth + "px";
    
    moveR = function() {
      msn.style.top = root.scrollTop+root.clientHeight-msn.offsetHeight + "px";
      msn.style.left = root.clientWidth-msn.offsetWidth -2 + "px";
      setTimeout(moveR,100);
	}
   msgClose.onclick = function (){
	msn.style.visibility='hidden';
   }
}

function Wa_SetImgAutoSize(ele) 
{ 
 var img=ele;
 var MaxWidth=197;
 var MaxHeight=156;
 var HeightWidth=img.offsetHeight/img.offsetWidth;
 var WidthHeight=img.offsetWidth/img.offsetHeight;
 if(img.readyState!="complete")return false;//确保图片完全加载 
 if(img.offsetWidth>MaxWidth){
  img.width=MaxWidth;
  img.height=MaxWidth*HeightWidth;
 }
 if(img.offsetHeight>MaxHeight){
  img.height=MaxHeight;
  img.width=MaxHeight*WidthHeight;
 }
 img.style.marginTop = (MaxHeight - img.height)/2 +"px";
} 