var ajfuncs=
{
    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,
    isChrome:navigator.userAgent.toLowerCase().indexOf('chrome')!=-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)
        {
           
        }
    },
    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(nd[o])=="object") ch+=this.enumObj(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;
    },
    pos:function(n)
    {
      n=this.isUndefined(n)?0:n;
      if (isNaN(n)) if (n.indexOf("px")>0) n=n.substring(0,n.indexOf("px")); else return n;
      return Number(n);
    },
    GetWidth:function(e)
    {
    	if (e==null) return null;
    	var n=this.isUndefined(e.width)?e.style.width:e.width;
    	if (n==0 && e.clientWidth) n=e.clientWidth;
    	return this.pos(n);
    },
    GetHeight:function(e)
    {
    	if (e==null) return null;
    	var n=this.isUndefined(e.height)?e.style.height:e.height;
    	if (n==0 && e.clientHeight) n=e.clientHeight;
    	return this.pos(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();
  	},
    setCookie:function(name,value,days) 
    {
      var expires="";
      var pth=""; //; path=/";
    	if (days) 
    	{
    		var date = new Date();
    		date.setTime(date.getTime()+(days*24*60*60*1000));
    		expires = "; expires="+date.toGMTString();
    	}
    	document.cookie = name+"="+value+expires+pth;
    },
    getCookie:function(name) 
    {
    	var cook = name + "=";
    	var ca = document.cookie.split(';');
    	for(var i=0;i < ca.length;i++) 
    	{
    		var c = ca[i];
    		while (c.charAt(0)==' ') c = c.substring(1,c.length);
    		if (c.indexOf(cook) == 0) return c.substring(cook.length,c.length);
    	}
    	return null;
    },   
    killCookie:function(name) 
    {
    	this.setCookie(name,"",-1);
    }
}

