var Browser = new Object();
Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
if (Browser.isFirefox) { // entend Event Mod for FireFox
	extendEventObject();
}
function extendEventObject() {
	Event.prototype.__defineGetter__("srcElement", function () {
		var node = this.target;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__("fromElement", function () {
		var node;
		if (this.type == "mouseover")
			node = this.relatedTarget;
		else if (this.type == "mouseout")
			node = this.target;
		if (!node) return;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__("toElement", function () {
		var node;
		if (this.type == "mouseout")
			node = this.relatedTarget;
		else if (this.type == "mouseover")
			node = this.target;
		if (!node) return;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});
}
function IsChild(cNode,pNode){
	while(cNode!=null){
		cNode=cNode.parentNode;
		if(cNode==pNode) return true; 
	}
	return false;
}


var ajccache=new Object();
var waitInterval;
var tempref;
var MouseDelayTime=150;//鼠标感应延迟300毫秒
function getTBprefixName(str,sta){
	if(str.indexOf("active")!=-1 || str.indexOf("normal")!=-1) str=str.substr(6);
		else if(str.indexOf("over")!=-1) str=str.substr(4);
			else str="";
	return sta+str;
}
function startajaxtabs(){
   
	for(var i=0;i<arguments.length;i++)
	{
	   
		var ulobj=document.getElementById(arguments[i]);
			ulist=ulobj.getElementsByTagName("li");			
			for(var j=0;j<ulist.length;j++)
			{
			    
				var thelist=ulist[j];
					if(thelist.parentNode.parentNode!=ulobj) continue;//只有第一层li有效 fixed 2006.9.29
				
				var ulistlink=thelist.getElementsByTagName("a")[0];
				var ulistlinkurl=ulistlink.getAttribute("urn");
				var ulistlinktarget=ulistlink.getAttribute("rel");
				thelist.setActive=function(bactive){
					if(bactive){
						this.status="active";
						this.className=getTBprefixName(this.className,"active");
					}else{
						this.status="normal";
						this.className=getTBprefixName(this.className,"normal");
					}
				}
				thelist.LoadTab=function(){
				
					this.setActive(true);
					this.parentNode.parentNode.activetab.setActive(false);
					this.parentNode.parentNode.activetab=this;					
					var ulistlink=this.getElementsByTagName("a")[0];
					
					loadAJAXTab(ulistlink.getAttribute("urn"),ulistlink.getAttribute("rel"));
				}
				thelist.onmouseover=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var fm=myEvent.fromElement;
					if(IsChild(fm,this) || fm==this) return;//过滤子元素event
					if(this.status=="active") return;
					tempref=this;
					clearTimeout(waitInterval);
					waitInterval=window.setTimeout("tempref.LoadTab();",MouseDelayTime);
				}

				thelist.onmouseout=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var em=myEvent.toElement;
					if(IsChild(em,this) || em==this) return; //过滤子元素event
					if(this.status=="active") return;
					clearTimeout(waitInterval);
				}

				if(ulistlinkurl.indexOf("#default")!=-1){
					thelist.setActive(true);
					ulobj.activetab=thelist;
					ajccache[ulistlinkurl]=getElement(ulistlinktarget).innerHTML;
				}else{
					thelist.setActive(false);
				}

			}
		if(ulobj.activetab==null) ulobj.activetab=ulist[0];
	}
}

function getXmlhttp()
{
	var http_request;
	
	if(window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) { 
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) { 
		window.alert("can't create XMLHttpRequest object.");
		return null;
	}	
	return http_request;
}

function loadAJAXTab(url,contentid){
 	var ocontent=getElement(contentid);
	if(ajccache[url]==null) {
		var xhttp=getXmlhttp();		
			xhttp.onreadystatechange=function(){
				if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
				{					
					ocontent.innerHTML=xhttp.responseText;
					ajccache[url]=ocontent.innerHTML;
				}
			}
		xhttp.open("GET",url,true);
		xhttp.send(null);
	}else{
		ocontent.innerHTML=ajccache[url];
	}
}
window.onerror=function(){return true}

//xml.js
var xhr;
function getXHR()
{
	try {
		xhr=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {		
		try {
			xhr=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {			
			xhr=false;
		}
	}
	if(!xhr&&typeof XMLHttpRequest!='undefined')
	{
		xhr=new XMLHttpRequest();
	}	
	
	return xhr;
}

function getElement(aID)
{
  return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}
var weather_gx;
var w_timeID;
var w_move_step=4;//值越小越平滑，速度越慢
var w_move_speed=8; // 值越小越平滑，速度越慢

function clickTime()
{
var thistime = new Date();
var years = thistime.getYear();
var days = thistime.getDay();
var hours = thistime.getHours();
var minutes = thistime.getMinutes();
var seconds = thistime.getSeconds();
var lastDate = new Date(thistime.getYear(), thistime.getMonth(), thistime.getDate(),hours,5*parseInt(minutes/5));

if(hours>17||hours<9){
document.getElementById("mainbody").parentNode.className="row11";
if(hours>=18){
document.getElementById("mainbody").innerHTML = "下次更新时间是明日9:00";
}else{
document.getElementById("mainbody").innerHTML = "下次更新时间是今日9:00";
}
document.getElementById("lastTime").innerHTML="上次更新时间18:00";
}else{
document.getElementById("mainbody").parentNode.className="row1";
minutes = 4 - minutes % 5;
seconds = 59 - seconds;
var smin = lastDate.getMinutes();
if(smin<10)smin="0"+smin;
document.getElementById("lastTime").innerHTML="上次更新时间"+(lastDate.getHours())+":"+smin;
if(minutes == 0 && seconds == 0){
//window.location.reload();
document.getElementById('timeIframe').src='message/marque_message.htm';
}else{
if(minutes<10)minutes="0"+minutes;
if(seconds<10)seconds="0"+seconds;
thistime = minutes + ":" + seconds;

document.getElementById("mainbody").innerHTML = thistime;
}
}
setTimeout("clickTime()",3000);
}

//滚动图[切换时间,数据集合,大图及链接id,切换的效果]
function FocusImg(time,foc,fbimg,show,sup)
{
	var au=document.getElementById(foc).getElementsByTagName("a");
	var bimgs=document.getElementById(foc).getElementsByTagName("img");
	var ba=document.getElementById(fbimg).getElementsByTagName("dt")[0].getElementsByTagName("a")[0];
	var now=1,tm,len=au.length;
	var img=new Image();img.src=bimgs[0].src;ba.appendChild(img);ba.href=au[0].href;
	var bi=ba.getElementsByTagName("img")[0];bi.alt=bimgs[0].alt;
	var fi=["progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,motion=forward)","progid:DXImageTransform.Microsoft.RandomDissolve(enable=true)"];
	var bp;
	if(sup){bp=document.getElementById(fbimg).getElementsByTagName("td")[0].getElementsByTagName("ul")[0];for(var i=0;i<len;i++){bp.innerHTML+="<li>"+(i+1)+"</li>";}}
	else{bp=document.getElementById(fbimg).getElementsByTagName("dd")[0].getElementsByTagName("ul")[0];for(var i=0;i<len;i++){bp.innerHTML+="<li>"+(i+1)+"</li>";}}
	var bps=bp.getElementsByTagName("li");bps[0].className="show";
	function pfn(i){bps[i].onclick=function(){go(i);}};for(var i=0;i<len;i++){pfn(i);}
	function xunhuan()
	{
		//if(/*@cc_on!@*/false){bi.style.filter=fi[show];bi.filters[0].Apply();bi.filters[0].Play(duration=1);}
		ba.href=au[now].href;bi.src=bimgs[now].src;bi.alt=bimgs[now].alt;
		for(var i=0;i<len;i++){bps[i].className="";}bps[now].className="show";(now<len-1)?now++:now=0;
	}
	function init(){tm=setInterval(xunhuan,time);}
	function go(n){	clearInterval(tm);	now=n;	xunhuan();	init();}
	init();
}

function $(id,tag){
	if(!tag){
		return document.getElementById(id);
	}else if(typeof id=='string'){
		return document.getElementById(id).getElementsByTagName(tag);
	}else{
		return id.getElementsByTagName(tag);
	}
}

Changes=function changes(id,tag,mouse,divnum){
	var objid=$(id,tag);
	var total=objid.length;
	for(i=0;i<total;i++){
		cha(i);
	}
	function cha(i){
		objid[i][mouse]=function(){
			for(b=0;b<total;b++){
				if(b==i){
					objid[b].className="on";
					$("con"+divnum+"_"+b).style.display="block";
				}else{
					objid[b].className="";
					$("con"+divnum+"_"+b).style.display="none";
				}
			}
		}
	}
}

function tabit(btn)
{
    var idname = new String(btn.id);
    var s = idname.indexOf("_");
    var e = idname.lastIndexOf("_")+1;
    var tabName = idname.substr(0, s);
    var id = parseInt(idname.substr(e, 1));
    var tabNumber = btn.parentNode.childNodes.length;    //IE和FF的值不同    
    for(i=0;i<tabNumber;i++)
    {
        if(document.getElementById(tabName+"_div_"+i)!=null)    //这里需要进行判断
       {
        document.getElementById(tabName+"_div_"+i).style.display = "none";
        document.getElementById(tabName+"_btn_"+i).className = "";
        }
    }
    document.getElementById(tabName+"_div_"+id).style.display = "block";
		btn.className = "curr";
}
startList = function() { 

  for(var i=1;i<4;i++) {
	if (document.all&&document.getElementById) {
	  cssdropdownRoot = document.getElementById("info_list0"+i);
	  for (ii=0; ii<cssdropdownRoot.childNodes.length; ii++) {
		node = cssdropdownRoot.childNodes[ii];
		if (node.nodeName=="LI") {
		  node.onmouseover=function() {
		  //this.className+="over";
		  this.className="over";
		  }
		  node.onmouseout=function() {
		 //this.className=this.className.replace("over", "");
		  this.className="on";
		  }
		}
	  }
	}
  }
}
if (window.attachEvent)
window.attachEvent("onload", startList)
else
window.onload=startList;