var tsfuncs=
{
    starttime:new Date(),
    isWin:navigator.appVersion.indexOf("Windows")!=-1,
    isIE:navigator.appName.indexOf("Internet Explorer")!=-1,
    isOpera:navigator.userAgent.indexOf("Opera")!=-1,
    isFF:navigator.userAgent.indexOf("Firefox")!=-1,
    isSaf:navigator.userAgent.toLowerCase().indexOf("safari")!=-1,
    geID:function(e)
    {
    	return e.toUpperCase()=="BODY"?document.body:this.isOpera?document.all[e]:document.getElementById(e);
    },
    setevent:function(ev,dom,callback)
    {
        try
        {
            if(dom.addEventListener) 
            {
                dom.addEventListener(ev,callback,false);
            }
            else if (dom.attachEvent) 
            {
                dom.attachEvent("on"+ev,callback);    
            }
            else
            {
                dom[ev]=callback;
            }
        }
        catch(e)
        {
           
        }
    },
    GetCookie:function(cOption,noExistVal,rVal)
    {
    	cOption=cOption+'=';
    	if (this.isUndefined(rVal)) rVal=false;
    	var b=document.cookie.indexOf(cOption);
    	if (b>=0)
    	{
    		if (rVal)
    		{
    			var e=document.cookie.indexOf(";",b);
    			if (e==-1) e=document.cookie.length;
    			return document.cookie.substring(b+cOption.length,e);
    		}
    		else
    		{
    			if (document.cookie.substr(b+cOption.length,1)=="1") return true; else return noExistVal;
    		}
    	}
    	else 
    	{
    		if (this.isUndefined(noExistVal)) 
    		{
    			if (rVal) return undefined; else return false;
    		}
    		else
    		{
    			return noExistVal;
    		}
    	}
    },
    SetCookie:function(c,v,l)
    {
        l=this.isUndefined(l)?365:l;
    	var expire = new Date();
    	var now=new Date();
    	expire.setTime(now.getTime() + 3600000*24*l);
    	var w=c+"="+v;
    	w=w + ";expires="+expire.toGMTString();
    	document.cookie = w;
    },
    enumObj:function(nd,cl,levs)
    {
        if (cl>levs && levs!=undefined) return "";
        var st="",ch="";
        st="["+nd.name+"]\n";
        for (var o in nd)
        {
            if (typeof(o)=="object") ch+=enumObjs(nd[o],cl+1,levs); else ch+="{"+o+"}="+nd[o]+"\n";
        }
        return st+ch;
    },
    getDB:function()
    {
        return document.body.parentNode.clientHeight==0?document.body:document.body.parentNode;
    },
    getTH:function()
    {
    	var ch=window.screen.height;
    	ch=this.getDB().clientHeight>ch?this.getDB().clientHeight:ch;
    	var nh=this.getDB().scrollHeight;
        return Number(nh<ch?ch:nh);
    },
    getTW:function()
    {
    	var sw=window.screen.width;
    	var nw=document.body.scrollWidth;
        return Number(nw<sw?sw:nw)-(this.isIE?0:6);//<cw?cw:nw;
    },
    getST:function()
    {
        return Number(document.body.scrollTop);
    },
    getSL:function()
    {
        return Number(document.body.scrollLeft);
    },
    getVW:function()
    {
        return Number(this.getDB().clientWidth);
    },
    getVH:function()
    {
        var db=this.getDB();
        return Number((this.isIE?db.clientHeight:window.innerHeight));
    },
    isUndefined:function(v)
    {
    	if (typeof(v)=="undefined" || v==undefined || v=="undefined") return true; else return false;
    },
    GetWidth:function(e)
    {
    	if (e==null) return null;
    	var n=this.isUndefined(e.width)?e.style.width:e.width;
    	if (isNaN(n)) if (n.indexOf("px")>0) n=n.substring(0,n.indexOf("px")); else return n;
    	return Number(n);
    },
    GetHeight:function(e)
    {
    	if (e==null) return null;
    	var n=this.isUndefined(e.height)?e.style.height:e.height;
    	if (isNaN(n)) if (n.indexOf("px")>0) n=n.substring(0,n.indexOf("px")); else return n;
    	return Number(n);
    },
    GetLeft:function(e)
    {
        if (e==null) return 0;
        var pos = e.offsetLeft;
        var ePar = e.offsetParent;
        while (ePar != null)
        {
            pos += ePar.offsetLeft;
            ePar = ePar.offsetParent;
        }
        return Number(pos);
    },
    GetTop:function(e)
    {
        if (e==null) return 0;	
        var pos = e.offsetTop;
        var ePar = e.offsetParent;
        while (ePar != null)
        {
            pos += ePar.offsetTop;
            ePar = ePar.offsetParent;
        }
        return Number(pos);
    },
    getTimer:function()
	{
	    var nd=new Date();
	    return nd.getTime()-this.starttime.getTime();
	}
}

