﻿// JScript 文件

//创建Cookie=========================================
function createCookie(name,value,days) 
{
	if(days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000) );
		var expires = "; expires="+date.toGMTString();
	}
	else 
	{
	   var expires = "";
	 }
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') 
		{
		   c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0) 
		{
		    return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}
//创建Cookie=========================================
function XmlHttpHelper(){}

XmlHttpHelper.__getXmlHttpObj = function()
{
	try
	{
		return new ActiveXObject("MSXML2.XMLHTTP");
	}
	catch(e)
	{
		return new XMLHttpRequest();
	}
};

//
//  使用XMLHTTP和远程服务器通信。
//
//  参数名称        必须    类型        取值范围            描述
//-------------------------------------------------------------------------------------------
//	async			是      boolean     true/false          是否使用异步方式
//	httpMethod		是      string      "post"/"get"        http方法
//	responseType	否      string      "text"/"xml"        返回数据的类型
//	url				是      string                          接收请求的URL地址
//	callback		否      function                        异步方式操作完成时执行的回调函数
//	postData		否      string                          post方式时发送的数据
//
//  注：非必须的参数，如不被传递时使用null代替。
//
XmlHttpHelper.transmit = function(async, httpMethod, responseType, url, callback, postData)
{
    httpMethod = httpMethod.toLowerCase();
    if(responseType != null) responseType = responseType.toLowerCase();
    
    var xmlhttp = this.__getXmlHttpObj();
	xmlhttp.open(httpMethod, url, async);
	
	if(!async && httpMethod == "post")
	    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

	if(async)
	{
		xmlhttp.onreadystatechange = function()
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
			{
			    try
			    {
			        if(typeof(callback) == "function")
			        {
			            switch(responseType)
			            {
			                case "text":
			                    callback(xmlhttp.responseText);
			                    break;
			                case "xml":
					            callback(xmlhttp.responseXML);
					            break;
					        default:
					            callback(null);
			            }
			        }
				}
				finally
				{
				    xmlhttp = null;
				}
			}
		}
		xmlhttp.send(postData);
	}
	else
	{
		xmlhttp.send(postData);
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
    		switch(responseType)
			{
			    case "text":
			        return xmlhttp.responseText;
			    case "xml":
			        return xmlhttp.responseXML;
			    default:
			        return null;
			}
		}
		else
		{
		    return null;
		}
	}
}
function ShowPop(obj)
{
   var v = document.getElementById(obj);
   GetCenterXY_ForLayer(v);
  getbyid(obj).style.display = "block";
}
function ClosePop(obj)
{
  getbyid(obj).style.display = "none";
}
//将悬浮层的位置定位在屏幕中央
function GetCenterXY_ForLayer(objdiv)
{
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
	
	//获取屏幕宽度
	availWidth = parseInt(window.screen.availWidth);
	availHeight = parseInt(window.screen.availHeight);
	
	tblWidth = parseInt(objdiv.offsetLeft);
	
		
	y = y + availHeight/6;
	x = (availWidth-600)/2;
	
	objdiv.style.top = y;
	objdiv.style.left = x;
}
function getbyid(id) {
	if (document.getElementById) 
	{
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	} else if (document.layers) {
		return document.layers[id];
	} else {
		return null;
	}
}
//showPop=====================================
/*
function kstatus()
{
  self.status="如果你喜欢本站,别忘了把本站的网址告诉给你QQ/MSN上的朋友哦!谢谢你的支持----Jixiao.Com:)";
  setTimeout("kstatus()",0);
}
kstatus();
*/
