//判断浏览器 true是IE false是ff
var isIe=(document.all)?true:false;
// AJAX类
function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	try { xmlObj=new XMLHttpRequest; }
	catch(e) {
		try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e2) {
			try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e3) { xmlObj=false; }
		}
	}
	if (!xmlObj) return false;
	this.method="POST";
	this.url;
	this.async=true;
	this.content="";
	this.callback=function(cbobj) {return;}
	this.send=function() {
		if(!this.method||!this.url||!this.async) return false;
		xmlObj.open (this.method, this.url, this.async);
		if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlObj.onreadystatechange=function() {
			if(xmlObj.readyState==4) {
				if(xmlObj.status==200) {
					ObjSelf.callback(xmlObj);
				}
			}
		}
		if(this.method=="POST") xmlObj.send(this.content);
		else xmlObj.send(null);
	}
}

//弹出方法 弹出DIV
function showMessageBox(DivId,wTitle,mContent,wHeight,wWidth,contentType,showback){
	closeWindow(DivId);
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}


	var bWidth = parseInt(myWidth);
	var bHeight = parseInt(myHeight) > parseInt(document.documentElement.scrollHeight)? parseInt(myHeight) : parseInt(document.documentElement.scrollHeight);
	if(isIe){setSelectState('hidden');}
	var Content = (contentType == 1 ? "<iframe id='mIframe' src='' frameborder='0' width='100%' scrolling='no' height='" + (wHeight - 10) + "'>正在加载...</iframe>" : mContent);
	var styleStr = (showback == 0?("position:absolute;background:#000;width:" + (wWidth + 36) + "px;height:" + (wHeight + 60) + "px;left:" + (myWidth - wWidth - 20)/2 + "px;top:" + (myHeight - wHeight - 20)/2 + "px;z-index:999;"):("top:0px;left:0px;position:absolute;background:#666;width:" + "100%" + ";height:" + bHeight + "px" + ";z-index:999;"));
	styleStr += (isIe)?"filter:alpha(opacity=40);":"opacity:0.40;";
	if(document.getElementById('back') == null){
		var back = document.createElement("div");
		back.id = "back";
		back.style.cssText = styleStr;
		document.body.appendChild(back);
	}else{
		var back = document.getElementById('back');
		back.style.cssText = styleStr;
		back.style.visibility = "visible";
	}


	styleStr = "position:absolute;width:" + wWidth + "px;left:" + (myWidth - wWidth)/2 + "px;top: " + (myHeight - wHeight)/2 + "px;z-index:1000;";
	if(document.getElementById(DivId)==null){
		var mesW = document.createElement("div");
		mesW.id = DivId;
		mesW.className = "mesWindow";
		mesW.innerHTML = "<div class='mesWindowTop'><div class='mesWindowtitle'>" + wTitle + "</div><div class='mesWindowclose'><a href=\"javascript:void(0);\" onclick=\"closeWindow('" + DivId + "')\"></a></div></div>" + Content + "";
		mesW.style.cssText = styleStr;
		document.body.appendChild(mesW);
	}else{
		var mesW = document.getElementById(DivId);
		mesW.style.visibility = "visible";
		mesW.style.cssText = styleStr;
	}
	if(contentType == 1)$('mIframe').src = mContent;
}
//弹出DIV后的背影
function showBackground(obj,endInt){
	obj.filters.alpha.opacity+=5;
	if(obj.filters.alpha.opacity<endInt){
		setTimeout(function(){showBackground(obj,endInt)},8);
	}
}
//设置select的可见状态 
function setSelectState(state){
	var objl=document.getElementsByTagName('select');
	for(var i=0;i<objl.length;i++){
		objl[i].style.visibility=state;
	}
}
//关闭弹出窗口
function closeWindow(s){
	if(document.getElementById('back') != null){
		//document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
		document.getElementById('back').style.visibility = "hidden";
	}
	if(document.getElementById(s) != null){
		//document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
		document.getElementById(s).style.visibility = "hidden";
	}
	if(document.getElementById('mIframe') != null){
		document.getElementById('mIframe').src = "";
	}
	if(isIe){setSelectState('');}
}
//鹏。小猪 2008-4-1 v1.0
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1) 
      return element;
    elements.push(element);
  }

  return elements;
}

function setCookie (name, value) {
	   var Days = 30; //此 cookie 将被保存 30 天
       var exp = new Date();
	   exp.setTime(exp.getTime() + 1000);
	   if(value==""||value=="null"||value=="null"||value==" "){}else{
       document.cookie = name + "="+ escape(value) +";expires=Sun, 17-Jan-2038 19:14:07 GMT";
	   }
}
function getCookie(sName){
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
        {
            return aCrumb[1];
        }
    }
    return null;
}