﻿var Browser=new Object();
Browser.isMozilla=(typeof document.implementation!='undefined')&&(typeof document.implementation.createDocument!='undefined')&&(typeof HTMLDocument!='undefined');
Browser.isIE=window.ActiveXObject?true:false;
Browser.isGecko=navigator.userAgent.indexOf("Gecko")!=-1;
Browser.isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
 $=function(A){
    
    return document.getElementById(A);
 }
 
function trim(temp) 
{
	return temp.replace(/(^\s*)|(\s*$)/g, "");
}

function getURL(hrefStr)
{
    window.location=hrefStr;
}

function getCookie(name)  
{
    var value="";
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) { value=decodeURI(arr[2]); }
    return value;
}

function getCookiePara(cookieName,Param)
{ 
    var url = "?"+getCookie(cookieName);
    var str = "[\?&]"+Param+"=([^&]*)";
    var re = new RegExp(str,"gi");
    if(!re.test(url))return "";
    re.exec(url);
    return RegExp.$1;
}

function getscrollHeight()
{
	if(document.body.scrollHeight>document.documentElement.clientHeight)
	{
		return document.body.scrollHeight
	}
	else
	{
		return document.documentElement.clientHeight
	}
}
var bigDiv=null;
function showmask()//制作透明DIV
{
	if(bigDiv==null||!bigDiv)
	{
		bigDiv=document.createElement("DIV");
		//bigDiv.attachEvent('onclick',closebiDiv);
		bigDiv.style.cssText="position:absolute;top:0px;left:0px;background-color:#000;";
	if(Browser.isMozilla)
	{
		bigDiv.style.cssText="position:absolute;top:0px;left:0px;background-color:#000;opacity:.1;";
	}
	else
	{
		bigDiv.style.cssText="position:absolute;top:0px;left:0px;background-color:#000;filter:alpha(opacity=10);";
	}
		bigDiv.style.height=getscrollHeight()+"px";
		bigDiv.style.width=document.body.clientWidth+"px";
		document.body.appendChild(bigDiv);
	}
}
function closebigDiv()
{
    if(bigDiv==null)
    {
        return;
    }
    else
    {
        document.body.removeChild(bigDiv);
	    bigDiv=null;
    }
}

/*
*函数名：getXY:	 获取元素在屏幕内的绝对位置及高度和宽度；
*@param obj:	要检测的元素；
*@type array; 
*@return: a[0]:顶部位置、a[1]:左边位置、a[2]:宽度、a[3]:高度；
*/
function getXY(obj)
{
	var a= new Array();/*返回对象*/ 
	var t = obj.offsetTop;
	var l = obj.offsetLeft;
	var w = obj.offsetWidth;
	var h = obj.offsetHeight;
	while(obj=obj.offsetParent){
		t+=obj.offsetTop;
		l+=obj.offsetLeft;
	}
	a[0] = t;
	a[1] = l;
	a[2] = w;
	a[3] = h;
	return a;
}

var AlphaDiv=null;
var PopDiv=null;//弹出窗口
function AddAlphaDiv()//添加透明Div
{
    if(AlphaDiv==null||!AlphaDiv)
	{
		AlphaDiv=document.createElement("DIV");
		if(Browser.isMozilla)
	    {
		    AlphaDiv.className="FFAlphaDiv";
	    }
	    else
	    {
		    AlphaDiv.className="IEAlphaDiv";
	    }
	}

	AlphaDiv.style.height=getscrollHeight()+"px";
	AlphaDiv.style.width=document.body.clientWidth+"px";
	document.body.appendChild(AlphaDiv);

}

function AddPopDiv(leftValue,topValue,widthValue,heightValue,HtmlStr)
{
    if(PopDiv==null||!PopDiv)
	{
		PopDiv=document.createElement("DIV");
		PopDiv.id="PopDivBox";
	}
	PopDiv.style.left=leftValue+"px";
	PopDiv.style.top=topValue+"px";
	if(widthValue!=0)
	{
	    PopDiv.style.width=widthValue+"px";
	}
	if(heightValue!=0)
	{
	    PopDiv.style.height=heightValue+"px";
	}
	PopDiv.innerHTML=HtmlStr;
	document.body.appendChild(PopDiv);
}

function closePopDiv()
{
    if(PopDiv!=null)
	{
	    document.body.removeChild(PopDiv);
	    PopDiv=null;
	}   
	
    if(AlphaDiv!=null)
    {
        document.body.removeChild(AlphaDiv);
	    AlphaDiv=null;
    }
}

/*
    全选取消,
    参数ischeck,true全选,false全不选
    参数sDspStr,限定某个checkbox的name
    参数form,限定某个form窗体
*/
function selAll(ischeck,sDspStr,form)
{   
    var items=form.all.tags("input");
    if(ischeck)
    {
        
        for(var i=0;i<items.length;i++)
        {
            if(items(i).type=="checkbox"&&items(i).name.toUpperCase()==sDspStr.toUpperCase())
            {
                items(i).checked="checked";
            }
        }
    }
    else
    {
        for(var i=0;i<items.length;i++)
        {
            if(items(i).type=="checkbox"&&items(i).toUpperCase()==sDspStr.toUpperCase())
            {
                items(i).checked="";
            }
        }
    }
}




