﻿var $=function(tagName){return document.getElementById(tagName);}
function $G(){ 
    var Url=top.window.location.href; 
    var u,g,StrBack=''; 
    if(arguments[arguments.length-1]=="#") 
    u=Url.split("#"); 
    else 
    u=Url.split("?"); 
    
    if (u.length==1) g=''; 
    else g=u[1]; 
    if(g!=''){ 
        gg=g.split("&"); 
        var MaxI=gg.length; 
        str = arguments[0]+"="; 
        for(i=0;i<MaxI;i++){ 
            if(gg[i].indexOf(str)==0) { 
            StrBack=gg[i].replace(str,""); 
            break; 
            } 
        }
    } 
    return StrBack; 
}
function DivChange(name,splittime,count,ismove,changed_callback)
{
    this.count = count;
    this.splittime = splittime;
    this.now = 0;
    this.name = name;
    this.timeid1;
    this.timeid2;
    this.ismove = ismove;
    this.changed_callback = changed_callback;
    this.next_button = document.getElementById(name+"_next_button");
    this.previous_button = document.getElementById(name+"_previous_button");
    this.isplay = true;
    var self = this;
    this.SetFocus = function() {
		if(self.now>=self.count) self.now=0;
		self.now = self.now+1;
        self.SelectLayer(self.now);
    };
	this.SelectLayer = function(i) {
      for(var j=1;j<=self.count;j++) {
        try
		    {
            if (j==i) {
                document.getElementById(name+"_panel_"+j).style.display="block";
            } else {
		        document.getElementById(name+"_panel_"+j).style.display="none";
            }
        }catch(e)
		    {}
      }
      if(typeof self.changed_callback == "function")
      {
        self.changed_callback(i);
      }
    };
    this.ChangeImg = function() {
        if(self.isplay)
        {
            self.timeid1 = setTimeout(self.SetFocus,self.splittime);
        }
        self.timeid2 = setTimeout(self.ChangeImg,self.splittime);
    };
	this.ChangeImg();
    
    this.Stop = function()
    {
        clearTimeout(this.timeid1);
        clearTimeout(this.timeid2);
    };
    this.Start = function()
    {
        this.ChangeImg();
    };
    this.Reset = function()
    {
        this.Stop();
        this.Start();
    };
    
	if(this.ismove!=1)
	{
        if(this.next_button)
        {
            this.next_button.onclick = function()
            {
			    self.Stop();
                if(self.now>=self.count)
                {
                    self.now = 0;
                }
                self.SelectLayer(self.now+1);
		        self.now = self.now+1;
			    self.Start();
            }
        }
        if(this.previous_button)
        {
            this.previous_button.onclick = function()
            {
			    self.Stop();
                if(self.now<=1)
                {
                    self.now = self.count+1;
                }
                self.SelectLayer(self.now-1);
			    self.now = self.now-1;
			    self.Start();
            }
        }
        for(var j=1;j<=count;j++)
        {
		    try
		    {
			    var now_button = document.getElementById(name+"_button_"+j);
			    if(now_button)
			    {
				    now_button.onclick = function()
				    {
					    self.Stop();
					    var num = parseInt(this.id.replace(name+"_button_",""));
					    self.SelectLayer(num);
					    self.now = num;
					    self.Start();
				    }
			    }
		    }catch(e)
		    {}
        }
    }
    else
    {
        if(this.next_button)
        {
            this.next_button.onmouseover = function()
            {
			    self.Stop();
                if(self.now>=self.count)
                {
                    self.now = 0;
                }
                self.SelectLayer(self.now+1);
		        self.now = self.now+1;
			    self.Start();
            }
        }
        if(this.previous_button)
        {
            this.previous_button.onmouseover = function()
            {
			    self.Stop();
                if(self.now<=1)
                {
                    self.now = self.count+1;
                }
                self.SelectLayer(self.now-1);
			    self.now = self.now-1;
			    self.Start();
            }
        }
        for(var j=1;j<=count;j++)
        {
		    try
		    {
			    var now_button = document.getElementById(name+"_button_"+j);
			    if(now_button)
			    {
				    now_button.onmouseover = function()
				    {
					    self.Stop();
					    var num = parseInt(this.id.replace(name+"_button_",""));
					    self.SelectLayer(num);
					    self.now = num;
				    }
				    now_button.onmouseout = function()
				    {
					    self.Start();
				    }
			    }
		    }catch(e)
		    {}
        }
    }
    for(var j=1;j<=count;j++)
    {
		try
		{
			var now_panel = document.getElementById(name+"_panel_"+j);
			if(now_panel)
			{
				now_panel.onmouseover = function()
				{
					self.Stop();
				}
				now_panel.onmousemove = function()
				{
					self.Stop();
				}
				now_panel.onmouseout = function()
				{
					self.Start();
				}
			}
		}catch(e)
		{}
    }
};
function CreateAlphaBg() {
    var height= document.documentElement.clientHeight>document.body.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;
	document.write('<div id="AlphaBg" style="width:100%; display:none; top:0; left:0; position:absolute; z-index:6;"><div style="height:'+height+'px; background:black;filter:alpha(opacity=30);-moz-opacity:0.30;opacity:0.30;">&nbsp;</div></div>');
}
function ShowAlphaBg() {
	document.getElementById("AlphaBg").style.display="block";
}
function UnShowAlphaBg() {
	document.getElementById("AlphaBg").style.display="none";
}
function InfoWindow(windowid,titleid,closeid,r)
{
	this.move = false;
	this.windowObject = $(windowid);
	this.windowTitle = $(titleid);
	this.windowClose = $(closeid);
	this.windowObject.style.display = "block";
	this.r = r;
	var self = this;
	this.windowObject.style.left = document.documentElement.clientWidth/2-250;
	this.windowObject.style.top = document.documentElement.scrollTop  +150;
	ShowAlphaBg();
	//this.windowObject.firstChild.onmousedown=function(){return false;};
		//this.windowObject.firstChild.onmousedown=function(){return false;};
	this.windowTitle.onmousedown=function(a){
		var d=document;if(!a)a=window.event;
			var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
			if(self.windowTitle.setCapture)
				self.windowTitle.setCapture();
			else if(window.captureEvents)
				window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
			self.windowTitle.onmousemove=function(a){
				if(!a)a=window.event;
				if(!a.pageX)a.pageX=a.clientX;
				if(!a.pageY)a.pageY=a.clientY;
				var tx=a.pageX-x,ty=a.pageY-y-5;
				var newx = tx<self.r[0]?self.r[0]:tx>self.r[1]?self.r[1]:tx;
				var newy = ty<self.r[2]?self.r[2]:ty>self.r[3]?self.r[3]:ty;
				self.windowObject.style.left = newx+"px";
				self.windowObject.style.top = newy+"px";
			};
	
			self.windowTitle.onmouseup=function(){
				if(self.windowTitle.releaseCapture)
					self.windowTitle.releaseCapture();
				else if(window.captureEvents)
					window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
				self.windowTitle.onmousemove=null;
				self.windowTitle.onmouseup=null;
			};
	};
	this.windowClose.onclick = function()
	{
	    UnShowAlphaBg();
		self.windowObject.style.display = "none";
	};
}
function Ajax() {
	this.xmlhttp = false;
	if(window.XMLHttpRequest) { 
		this.xmlhttp = new XMLHttpRequest();
		if (this.xmlhttp.overrideMimeType)
			this.xmlhttp.overrideMimeType("text/xml");
	}
	else if (window.ActiveXObject) {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
		} catch (e) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	this.GetData = function(url, obj) {
		var self = this;
		if(!this.xmlhttp) { alert("请更新你的浏览器"); return; }
		this.xmlhttp.onreadystatechange = function() {
			if (self.xmlhttp.readyState == 4) {
			    if(typeof obj == "function")
			    {
			        obj(self.xmlhttp.responseText);
			    }
			    else if($(obj))
			    {
				if (self.xmlhttp.status == 200)
					$(obj).innerHTML = self.xmlhttp.responseText;
				else
					$(obj).innerHTML = "加载失败";
			    }
			}
		}
		this.xmlhttp.open("GET", url, true);
		this.xmlhttp.setRequestHeader("If-Modified-Since", "0");
		this.xmlhttp.send(null);
	}
}  
function ShowRes(txt)
{
    alert(txt);
}
function TrackSource() {
    var t = $G("t"); 
    if (t != "") {
        var as = document.getElementsByTagName("A");
        for (var i = 0; i < as.length; i++) {
            if (as[i].href.indexOf("javascript") < 0) {
                var sign = "";
                if (as[i].href.indexOf("?") > 0) {
                    sign = "&";
                }
                else {
                    sign = "?";
                }
                as[i].href = as[i].href + sign + "t=" +  t;
            }
        }
    }
}
function showflash(url, w, h, t) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">');
    document.write('<param name="movie" value="'+url+'">');
    document.write('<param name="quality" value="high">');
    if(t) document.write('<param name="wmode" value="transparent">');
    document.write('<param name="menu" value="false">');
    document.write('<embed src="'+url+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
    document.write('</object>');
}
function sdnClick(num) {
	(new Image()).src = "http://tongji.528day.com/link.ashx?aid="+num+"&t="+ Math.random();
}
