String.prototype.lTrim=function(){return this.replace(/^\s*/,"");};
String.prototype.rTrim=function(){return this.replace(/\s*$/,"");};
String.prototype.trim=function(){return this.rTrim().lTrim();};
function enc(s){
	return s==null?null:s.toString ().replace(/\%/g,"%00").replace(/=/g,"%3D");
}

function setCookie(name,value,day){
	var expdate=new Date();
	var argv=setCookie.arguments;
	var argc=setCookie.arguments.length;
	var expires=(argc>2)?argv[2]:null;
	var path=(argc>3)?argv[3]:null;
	var domain=(argc>4)?argv[4]:null;
	var secure=(argc>5)?argv[5]:false;
	if(expires!=null)expdate.setTime(expdate.getTime()+(expires*3600000*24));
	document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expdate.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
	
}
function deleteCookie(name){
	var exp=new Date();
	exp.setTime(exp.getTime()-1); 
	var cval=getCookie(name);
	document.cookie=name+"="+cval+"; expires="+exp.toGMTString();
	
}
function setfintsize(size){
	$('Main_cont_txt').style.fontSize=size+"px";
	
	}
function getCookie(cn){
	var dc=document.cookie;
	var prefix=cn+"=";
	var begin=dc.indexOf("; "+prefix);
	if(begin==-1){
		begin=dc.indexOf(prefix);
		if(begin!=0)return null;
		
	}else {
		begin+=2;
		
	}var end=document.cookie.indexOf(";",begin);
	if(end==-1){
		end=dc.length;
		
	}return unescape(dc.substring(begin+prefix.length,end));
	
}
function getWindowSize(){
	var myWidth=0,myHeight=0;
	if(typeof(window.innerWidth)=='number'){
		myWidth=window.innerWidth;
		myHeight=window.innerHeight;
	}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
		myWidth=document.documentElement.clientWidth;
		myHeight=document.documentElement.clientHeight;
	}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
		myWidth=document.body.clientWidth;
		myHeight=document.body.clientHeight;
	}
	return {Width:myWidth,Height:myHeight};
}
function getDocumentSize(){
    var winSize = getWindowSize();
    var docHeight=0,docWidth=0;
    if (window.innerWidth && window.scrollMaxX) {
        docWidth = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollWidth > document.body.offsetWidth){
        docWidth = document.body.scrollWidth;
    } else {
        docWidth = document.body.offsetWidth;
    }
    if(docWidth < winSize.Width) docWidth = winSize.Width;
    if (window.innerHeight && window.scrollMaxY) {
        docHeight = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){
        docHeight = document.body.scrollHeight;
    } else {
        docHeight = document.body.offsetHeight;
    }
    if(docHeight < winSize.Height) docHeight = winSize.Height;
    // temp
    if(document.body.offsetWidth && docWidth > document.body.offsetWidth)
        docWidth = document.body.offsetWidth;
    return {Width:docWidth,Height:docHeight};
}
function sAlert(_sContent,_sTitle,msgWidth,msgHeight,msgLeft,msgTop){   
	if(!$("__msgContainer")){
	    this.winSize = getWindowSize();
	    this.docSize = getDocumentSize();
	    this.scrollHeight = document.documentElement.scrollTop;
	    this.scrollWidth = document.documentElement.scrollLeft;
	    
	    var docWidth = docSize.Width; 
        var docHeight = docSize.Height;
	    
        if(!msgWidth) msgWidth = 400;
        if(msgWidth > docWidth) msgWidth = docWidth-40;
	    if(!msgHeight) msgHeight = 120;
	        if(msgHeight > docHeight) msgHeight = docHeight-40;
        if(!msgLeft) msgLeft = (winSize.Width-msgWidth)/2+this.scrollWidth;
		if(!msgTop) msgTop = (winSize.Height-msgHeight)/2+this.scrollHeight;
		if(!_sTitle) _sTitle = '提 示';
		var _salertObj = document.createElement("DIV");
		_salertObj.setAttribute("id","__msgContainer");
		_salertObj.style.width = docWidth+"px";
		_salertObj.style.height = docHeight+"px";
        _salertObj.style.position="absolute";
	    _salertObj.style.top="0";
	    _salertObj.style.background="#777";
	    _salertObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	    _salertObj.style.opacity="0.6";
	    _salertObj.style.left="0";
	    _salertObj.style.zIndex = "10000";
		
		document.body.appendChild(_salertObj);
		
		var _salertMsgObj=document.createElement("div");
		_salertMsgObj.setAttribute("id","__msgMain");
        _salertMsgObj.style.textAlign = "center";
        _salertMsgObj.style.backgroundColor = "#fff";
        _salertMsgObj.style.border = "1px solid #0C4175";
        _salertMsgObj.style.position="absolute";
        _salertMsgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=95,finishOpacity=100);";
        _salertMsgObj.style.opacity='0.95';
        _salertMsgObj.style.width = msgWidth+"px";
		_salertMsgObj.style.height = msgHeight+"px";
		_salertMsgObj.style.left = msgLeft+"px";
		_salertMsgObj.style.top = msgTop+"px";
	    _salertMsgObj.style.zIndex = "10001";
		_salertMsgObj.innerHTML = '<div id="__msgTitle" style="height:28px;line-height:28px;text-align:left;background-color:#336699;font-size:12px;"><span id="__msgTitleText" style="font-size:12px;float:left;height:28px;line-height:28px;margin-left:7px;color:#fff;">'+_sTitle+'</span><span id="__msgWinClose" title="关闭窗口" style="width:50px;height:28px;float:right;background-image:url(/Images/close.gif);background-repeat:no-repeat;background-position:right center;cursor:pointer;"></span></div><div id="__msgContent" style="margin:17px;font-family:宋体,"Comic Sans MS",Arial,Helvetica,sans-serif;"></div>';
		
		document.body.appendChild(_salertMsgObj);
		$("__msgWinClose").onclick = function(){
		    sAlertClose();
		};
		Element.update('__msgContent',_sContent);
	}else {
		sAlertClose();
	}
}
function sAlertClose(){
    if($("__msgMain")){
        $("__msgMain").remove();
        $("__msgContainer").remove();
    }
}
function getControl(path,parm,onInteractiveFunction,onSuccessFunction,onFailureFunction){
    var temp=(new Date()).getTime();
    new Ajax.Request('/UserControls/req.aspx?path='+path+'&temp='+temp,{
        method: parm==null?'get':'post',
        parameters:parm == null?'':parm,
        onInteractive:onInteractiveFunction,
        onSuccess:function(req){
            var rg = '<html>[\\S\\s]*<\/html>';
            var html = req.responseText.replace(new RegExp(rg, 'img'), '');
            if(typeof onSuccessFunction == 'function'){
                try {
                  onSuccessFunction(html);
                } catch (e) {}
            }
        },
        onFailure:onFailureFunction
    });
}

function setContainerHeight(){
    setTimeout(function(){
    
    $('div_LeftMenuContainer').style.height = '';
    $('div_LeftMenuContainer').style.height = (document.body.offsetHeight-125)+'px';
    },100);
}

var addToOnload = function(fn){
    Event.observe(window, 'load',fn);
};

Element.addMethods({
    isEmpty:function(element){
        element = $(element);
        if($F(element) == ''){
            $(element).setStyle({backgroundColor: '#ffeffd'});
            return true;
        }else{
            $(element).setStyle({backgroundColor: ''});
            return false;
        }
    }
});

 

function requestQuery(key){
    var rutrunVal = null;
    var query = location.search;
    if(key==null || typeof key == 'undefined')
        return query;
    var pkey = key+'=';
    if(query.length > 0){
       query = query.substring(1,query.length);
       if(query.indexOf(pkey)!=-1){
            query = query.split('&');
            query.each(function(parm){
                if(parm.startsWith(pkey)){
                    rutrunVal = parm.replace(pkey,'');
                }
            });
       }
    }
    return unescape(rutrunVal);
}
function isEnsure() {
    if(confirm("确定要注销退出吗？")){
        return true;
    }
    return false;
}
 
 
 

