﻿// JavaScript Document
function xhr()
{
 var xmlhttp;
	try {
            // Mozilla / Safari
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
		// IE
		var XMLHTTP_IDS = new Array(
                'MSXML2.XMLHTTP.5.0',
                'MSXML2.XMLHTTP.4.0',
                'MSXML2.XMLHTTP.3.0',
                'MSXML2.XMLHTTP',
                'Microsoft.XMLHTTP' );
		var success = false;
		for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {
			try {
				xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
				success = true;
			} catch (e) {}
		}
		if (!success) {
			throw new Error('Unable to create XMLHttpRequest.');
		}
        }
	var self = xmlhttp;
	xmlhttp.onreadystatechange = function() {
		if (self.readyState == 4) {
			if (self.status == 200) {
				self.onComplete(self.responseText);
			}
			else {
				throw new Error('Loading Error: ['+req.status+'] '+req.statusText);
			}
		}
	}
	return xmlhttp;
}
function doc(objectId) {if(document.getElementById && document.getElementById(objectId)){/* W3C DOM*/   return document.getElementById(objectId);}else if (document.all && document.all(objectId)){/* MSIE 4 DOM*/ return document.all(objectId);}else if (document.layers && document.layers[objectId]){/* NN 4 DOM.. note: this won't find nested layers*/return document.layers[objectId];}else{return false;}} 
function GetPageValue(Urll,viewpara,msg){
	var url=Urll;
	var xmlhttp=xhr();
	var requestType =viewpara;
    xmlhttp.open("get", url, true);
	xmlhttp.onreadystatechange = function() 
	{
	 if (xmlhttp.readyState==1)
    {
    doc(requestType).innerHTML="页面访问中……<br />";
    }

         else if(xmlhttp.readyState==4&& xmlhttp.status == 200)
    {
     	
	 		if(xmlhttp.responseText=='1')
			{
			   doc(requestType).innerHTML+=msg+"成功！<br />";
			}
			 else
			 {
			   doc(requestType).innerHTML+=msg+"失败！<br />";
			}
    }
	}
   
	xmlhttp.setRequestHeader("If-Modified-Since","0");
	xmlhttp.send(null);

}
function show_para(Urll,divid)
{
	var url=Urll;
	var xmlhttp=xhr();
	var requestType =divid;
    xmlhttp.open("get", url, true);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState==1)
		{
			doc(requestType).innerHTML="Loading……";
		}
		else if(xmlhttp.readyState==4&& xmlhttp.status == 200)
		{
			doc(requestType).innerHTML=xmlhttp.responseText;
		}
	}
   
	xmlhttp.setRequestHeader("If-Modified-Since","0");
	xmlhttp.send(null);

}
function trim(inputString){if (typeof inputString != "string") { return inputString; }var retValue = inputString;var ch = retValue.substring(0, 1);while (ch == " ") {/*检查字符串开始部分的空格*/ retValue = retValue.substring(1, retValue.length);ch = retValue.substring(0, 1);}ch = retValue.substring(retValue.length-1, retValue.length);while (ch == " ") {/*检查字符串结束部分的空格*/ retValue = retValue.substring(0, retValue.length-1);ch = retValue.substring(retValue.length-1, retValue.length);}while (retValue.indexOf("  ") != -1) {/*将文字中间多个相连的空格变为一个空格*/retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);}return retValue;}
function addfavorite(){//加入收藏
      try{window.external.addFavorite("http://"+document.location.host+"/",document.title); } 
	  catch(e){(window.sidebar)?window.sidebar.addPanel(document.title,"http://"+document.location.host+"/", ""):alert('请使用按键 Ctrl+d，收藏'+document.title+'网址'); }
}
//监听事件
function sEvent(remove){
 if (window.attachEvent)window.attachEvent("onload", remove);//IE下
 else if (window.addEventListener)window.addEventListener("load", remove, false);//火狐下
}
//导航下拉效果
function sfHover()
{
		var sfEls = doc("navMenu").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++){
			sfEls[i].onmouseover=function(){this.className+=" navhover";}
			sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" navhover\\b"), "");}
		}
}
//活动列表效果
function actHover()
{
		var sfEls = doc("figurelist").getElementsByTagName("dd");
		for (var i=0; i<sfEls.length; i++){
			sfEls[i].onmouseover=function(){this.className+=" shover";}
			sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" shover\\b"), "");}
		}
}
// --- 获取ClassName
    document.getElementsByClassName = function(cl) {
        var retnode = [];
        var myclass = new RegExp('\\b'+cl+'\\b');
        var elem = this.getElementsByTagName('*');
        for (var j = 0; j < elem.length; j++) {
            var classes = elem[j].className;
            if (myclass.test(classes)) retnode.push(elem[j]);
        }
        return retnode;
    }

function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
	    if(image.width/image.height>= iwidth/iheight){
		    if(image.width>iwidth){
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
        }
		else{
			if(image.height>iheight){
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
        }
    }
}
/*
函数说明Jsecho(Ttitle,str,msgw,msgh,titleheight,bordercolor,titlecolor)
	Ttitle 		提示框信息标题 可以为空
	str 		提示窗口内容信息 可以为空
	msgw 		提示窗口的宽度 可以为空
	msgh 		提示窗口的高度 可以为空
	titleheight 提示窗口标题高度 可以为空
	bordercolor 提示窗口的边框颜色 可以为空
	titlecolor  提示窗口的标题颜色 可以为空
	调用方法：Jsecho("Ttitle","str")
*/
function Jsecho(Ttitle,str,msgw,msgh,titleheight,bordercolor,titlecolor){
			var Ttitle,str,msgw,msgh,titleheight,bordercolor,titlecolor;
			if(msgw==null) msgw=200;//提示窗口的宽度
			if(msgh==null) msgh=80;//提示窗口的高度
			if(titleheight==null) titleheight=25;//提示窗口标题高度
			if(bordercolor==null) bordercolor="#8ACC00";//提示窗口的边框颜色#336699
			if(titlecolor==null) titlecolor="#99CCFF";//提示窗口的标题颜色
			if(Ttitle==null) Ttitle="信息提示框";//提示窗口标题信息
			if(str==null) str="请返回！";//提示窗口内容信息
			var sWidth,sHeight;
			sWidth=document.body.offsetWidth;
			sHeight=document.body.offsetHeight;//screen.height;
			var bgObj=document.createElement("div");
			bgObj.setAttribute('id','bgDiv');
			bgObj.style.position="absolute";
			bgObj.style.top="0";
			bgObj.style.background="#777";
			bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
			bgObj.style.opacity="0.6";
			bgObj.style.left="0";
			bgObj.style.width=sWidth + "px";
			bgObj.style.height=sHeight + "px";
			bgObj.style.zIndex = "10000";
			document.body.appendChild(bgObj);			
			var msgObj=document.createElement("div")
			msgObj.setAttribute("id","jkrmsgDiv");
			msgObj.setAttribute("align","left");
			msgObj.style.background="white";
			msgObj.style.border="1px solid " + bordercolor;
	    	msgObj.style.position = "absolute";
            msgObj.style.left = "35%";
            msgObj.style.top = "25%";
            msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
            msgObj.style.marginLeft = "0px" ;
            msgObj.style.marginTop = document.documentElement.scrollTop+"px";
            msgObj.style.width = msgw + "px";
            msgObj.style.height =msgh + "px";
            msgObj.style.textAlign = "center";
            msgObj.style.lineHeight ="25px";
            msgObj.style.zIndex = "10001";
   
		   var title=document.createElement("div");
		   title.setAttribute("id","jkrmsgTitle");
		   title.setAttribute("align","right");
		   title.style.margin="0";
		   title.style.padding="0px";
		   title.style.background=bordercolor;
		   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
		   title.style.opacity="0.75";
		   title.style.border="1px solid " + bordercolor;
		   title.style.height=titleheight;
		   title.style.cursor="pointer";
		   title.innerHTML="<div style='float:left;color:#FFFFFF;padding-left:10px;font-size:14px;'>"+Ttitle+"</div>×";
		   title.onclick=function(){
		        document.body.removeChild(bgObj);
                document.getElementById("jkrmsgDiv").removeChild(title);
                document.body.removeChild(msgObj);
                }
		   document.body.appendChild(msgObj);
		   document.getElementById("jkrmsgDiv").appendChild(title);
		   var txt=document.createElement("div");
		   txt.style.margin="1em 0"
		   txt.setAttribute("id","jkrmsgTxt");
		   txt.innerHTML=str;
           document.getElementById("jkrmsgDiv").appendChild(txt);

}
/*参数说明:showpara(Urll,tid,meth,text) 
例如:<script language="javascript">showpara("a.php","bid","get","a页面信息载入中...");</script>
 	Urll为要调用的网址信息;
 	tid为要输出的ID名称；
 	meth调用的方法：可以为get或post;
 	text为预留信息。
*/
function showpara(Urll,tid,meth,text){
    var strtime = getDataTimes();var methods=meth;var pretext=text;var url=Urll;var requestType =tid;
	if(methods==null || methods=='') methods="get";
	if(pretext==null || pretext=='') pretext="载入中……";
	var xmlhttp=xhr();	
    xmlhttp.open(methods, url, true);
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState==1)
		{
			G(requestType).innerHTML=pretext;
			}
		else if(xmlhttp.readyState==4&& xmlhttp.status == 200)
			{
				G(requestType).innerHTML=xmlhttp.responseText;
			}
	}   
	xmlhttp.setRequestHeader("If-Modified-Since","0");xmlhttp.send(null);}
// --- 设置cookie
    function setCookie(sName,sValue,expireHours){
        var cookieString = sName + "=" + escape(sValue);
        //;判断是否设置过期时间
        if (expireHours>0) {
             var date = new Date();
             date.setTime(date.getTime + expireHours * 3600 * 1000);
             cookieString = cookieString + "; expire=" + date.toGMTString();
        }
        document.cookie = cookieString;
    }
    
//--- 获取cookie
    function getCookie(sName) {
      var aCookie = document.cookie.split("; ");
      for (var j=0; j < aCookie.length; j++){
        var aCrumb = aCookie[j].split("=");
        if (escape(sName) == aCrumb[0])
          return unescape(aCrumb[1]);
      }
      return null;
    }
//
function delCookie(name){ 
	var exp = new Date(); //当前时间
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
}
