﻿// JScript 文件
Number.prototype.NaN0=function(){return isNaN(this)?0:this;}
function getLeft(string,cell)
{
	return string.substring(0,string.indexOf(cell));
}
function mouseCoords(ev){
    if(ev.pageX || ev.pageY){
    return {x:ev.pageX, y:ev.pageY};
    }
    return {
        x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft,
        y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop
    };
}
function getPosition(cell){
	var left = 0;
	var top  = 0;
	while (cell.parentNode){
		if (cell.tagName != "TR" && cell.tagName != "TBODY")
		{
			left += cell.offsetLeft + (cell.currentStyle?(parseInt(cell.currentStyle.borderLeftWidth)).NaN0():0);
			top  += cell.offsetTop  + (cell.currentStyle?(parseInt(cell.currentStyle.borderTopWidth)).NaN0():0);
		}
		cell  = cell.parentNode;
	}
	return {x:left, y:top};
}
function request(strname)
{
    var hrefstr,pos,parastr,para,tempstr;
    hrefstr = window.location.href;
    pos = hrefstr.indexOf("?")
    parastr = hrefstr.substring(pos+1);
    para = parastr.split("&");
    tempstr="";
    for(i=0;i<para.length;i++)
    {
        tempstr = para[i];
        pos = tempstr.indexOf("=");
        if(tempstr.substring(0,pos) == strname)
        {
            return tempstr.substring(pos+1);
        }
    }
   return null;
}
var nowaddStyle;
function addGlobalStyle(css) {
    var head;
    head = document.getElementsByTagName("head")[0];
    if (!head) { return; }
    nowaddStyle = document.createElement("style");
    nowaddStyle.type = 'text/css';
    nowaddStyle.innerHTML = css;
    head.appendChild(nowaddStyle);
}
//判断是否是IE
var agt=navigator.userAgent.toLowerCase();
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));
var tBodyNode;
if (ie) {tBodyNode = 0;}else{tBodyNode = 1};

function replaceAll(s,y,t) 
{ 
     var i; 
     var s2=s; 
     var y2=y;
     var t2=t;
     
     while(s2.indexOf(y2)>=0)
     {
         i = s2.indexOf(y2); 
         s2 = s2.substring(0, i) + t2 + s2.substring(i + y2.length, s2.length); 
     } 
     return s2; 
}
function pageNoSelect(bool){
	if (bool){
		if (ie){
			document.body.onselectstart = function(){return false};
		}else{
			addGlobalStyle('body { -moz-user-select : none !important; }');
		}
	}
	else
	{
		if (ie){
			document.body.onselectstart = function(){return true};
		}else{
			nowaddStyle.innerHTML = "";
		}
	}
}
//格式化时间
function formatTime(cell){
    if (cell.toString().length == 1){
        cell = "0"+cell;
    }
    return cell
}
String.prototype.trim= function()  
{
    return this.replace(/(^\s*)|(\s*$)/g, "");  
}
function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure){
    var sCookie = sName + "=" + encodeURIComponent(sValue);
    if (oExpires){
        sCookie += "; expiress=" + oExpires.toGMTString();
    }
    if (sPath){
        sCookie += "; path=" + sPath;
    }
    if (sDomain){
        sCookie += "; domain=" + sDomain;
    }
    if (bSecure){
        sCookie += "; secure";
    }
    document.cookie = sCookie;
}
function getCookie(sName){
    var sRE = "(?:; )?" + sName + "=([^;]*);?";
    var oRE = new RegExp(sRE);
    if (oRE.test(document.cookie)){
        return decodeURIComponent(RegExp["$1"]);
    }else{
        return null;
    }
}
function deleteCookie(sName, sPath, sDomain){
    setCookie(sName, "", new Date(0), sPath, sDomain);
}

function getScrollHT(){
    return {
        top:document.documentElement.scrollTop,
        left:document.documentElement.scrollLeft
    }
}