var tsfuncs=
{
    starttime:new Date(),
    isWin:navigator.appVersion.toLowerCase().indexOf("windows")!=-1,
    isIE:navigator.appName.toLowerCase().indexOf("internet explorer")!=-1,
    isOpera:navigator.userAgent.toLowerCase().indexOf("opera")!=-1,
    isFF:navigator.userAgent.toLowerCase().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);
    },
    parseError:function(e)
    {
    	var z="e line: " + e.lineNumber + "\n";
    	z+="e.number is: " + (e.number & 0xFFFF) + "\n";
    	z+="e.description is: " + e.description + "\n";
    	z+="e.name is: " + e.name + "\n";
    	z+="e.message is: " + e.message + "\n";
    	return z;
	},
	lzero:function(n,z)
	{
		var st=n.toString(10);
		for (var c=1;c<=z-st.length;c++)
		{
			st="0"+st;
		}
		return st;
	},
    outdiv:function(divid,dta)
    {
    	var e=this.geID(divid);
    	if (e) 
    	{
    		var h=e.innerHTML;
    		e.innerHTML=e.innerHTML+dta+"<br>";
    	}
	},
	alignobject:function(id,initid,x,y)
	{
	    var e=this.geID(initid);
	    if (e)
	    {
	        x=this.GetLeft(e)+x;
	        y=this.GetTop(e)+y;
	    }
	    e=this.geID(id);
	    if (e)
	    {
	        e.style.left=x+"px";
	        e.style.top=y+"px";
	    }
	    return new Object({x:x,y:y});
	},
    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";
        try
        {
	        for (var o in nd)
	        {
	            if (typeof(o)=="object") ch+=enumObjs(nd[o],cl+1,levs); else ch+="{"+o+"}="+nd[o]+"\n";
	        }
	    }
	    catch(e)
	    {
	    	//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.getVH()>ch?getVH():ch;
    	var nh=this.getDB().scrollHeight;
        return Number(nh<ch?ch:nh);
    },
    getTW:function()
    {
    	var sw=window.screen.width;
    	var nw=this.getDB().scrollWidth;
        return Number(nw<sw?sw:nw)-(this.isIE?0:6);//<cw?cw:nw;
    },
    getSH:function()
    {
        return Number(this.getDB().scrollHeight);
    },    
    getST:function()
    {
        return Number(this.getDB().scrollTop);
    },
    getSL:function()
    {
        return Number(this.getDB().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();
	}
}

