// Create namespace for out classes
if (!window.heateddetails) { window.heateddetails = {}; }
var hd = window.heateddetails;

hd.utils =
{
    docBody : ((document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body ? document.body : null),
    
    // setTimeout override to handle parameters, since IE doesn't support the optional argumenets
    setTimeout: function(fnPointer, ms)
    {
        var args = arguments;
        function proxy()
        {
            var params = new Array();
            var i;
            for (i = 3; i < args.length; i++)
            { params.push(args[i]); }
        
            fnPointer.apply(args[2], params);
        }
        return window.setTimeout(proxy, ms);
    },
    // used to show attributes - good for trouble-shooting cross-browser bugs
    dumpAttributes: function( obj, bUsePrompt )
    {
        var strT = "";
        var i = 0;
        for ( var prop in obj )
        {
            i++;
            strT += prop + " = " + obj[ prop ] + "\x0a\x0d";
            if ( !bUsePrompt && i == 10 )
            {
                alert( strT );
                strT = "";
                i = 0;
            }
        }
        if ( bUsePrompt )
            prompt( "DUMP", strT );
    },
    dumpInnerHTML: function( obj )
    {
        var strHTML = obj.innerHTML;
        prompt( "HTML", strHTML );
    },
    includeScript: function( strFile )
    {
        try
        {
            var htmHead = document.getElementsByTagName('head').item(0);
            var htmJs = document.createElement('script');
            htmJs.setAttribute('language', 'javascript');
            htmJs.setAttribute('type', 'text/javascript');
            htmJs.setAttribute('src', strFile);
            htmHead.appendChild(htmJs);
        }
        catch(e){}
    },
    toInt: function( strValue )
    {
            var nRet;
            return isNaN( nRet = parseInt(strValue) ) ? 0 : nRet;
    },
    deAltObject: function( obj )
    {
        if(obj)
        {
            if(obj.alt) 
                obj.alt = "";
            if(obj.title) 
                obj.title = "";

            var child = obj.children || obj.childNodes || null;

            if(child)
            {
                for(var i = child.length; i; )
                    this.deAltObject( child[ --i ] );
            }
        }
    },
    addPageLoadEvent: function( fnOnLoadEvent )
    {
        var fnPrevEventHandler = window.onload;
        if ( typeof window.onload != 'function' )
        {
            window.onload = fnOnLoadEvent;
        }
        else
        {
            window.onload = function()
            {
                if ( fnPrevEventHandler )
                {
                    fnPrevEventHandler();
                }
                fnOnLoadEvent();
            }
        }
    },
    addBodyLoadEvent: function( fnOnLoadEvent )
    {
        var objBody = hd.utils.browser.getDocumentTags("body")[0];
        
        var fnPrevEventHandler = objBody.onload;
        if ( typeof objBody.onload != 'function' )
        {
            objBody.onload = fnOnLoadEvent;
        }
        else
        {
            objBody.onload = function()
            {
                if ( fnPrevEventHandler )
                {
                    fnPrevEventHandler();
                }
                fnOnLoadEvent();
            }
        }
    },
	getUrlParameter: function( name )
	{  
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
		var regexS = "[\\?&]"+name+"=([^&#]*)";  
		var regex = new RegExp( regexS, "i" );
		var strHref = window.location.href;
		var results = regex.exec( strHref );  
		if( results == null )    
			return "";  
		else    
			return results[1];
	},
	getUrlParameterCase: function( name )
	{  
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
		var regexS = "[\\?&]"+name+"=([^&#]*)";  
		var regex = new RegExp( regexS, "i" );
		var strHref = window.location.href;
		var results = regex.exec( strHref );  
		if( results == null )    
			return "";  
		else    
			return results[1];
	},
	getType: function( v )
	{   
		var result = typeof(v);   
		if (result == "object")
		{   
			result = "@unknown";   
			if(v.constructor)
			{   
				var sConstructor = v.constructor.toString();   
				var iStartIdx = sConstructor.indexOf(' ' ) + 1;   
				var iLength = sConstructor.indexOf('(' ) - iStartIdx;   
				var sFuncName = sConstructor.substr(iStartIdx, iLength);   
				if (iStartIdx && sFuncName) result = sFuncName;   
			}   
		}   
		return result.toLowerCase();   
	}
};

// browser namespace
hd.utils.browser =
{
//    // convert all characters to lowercase to simplify testing
    agt: navigator.userAgent.toLowerCase(),
    appVer: navigator.appVersion.toLowerCase(),
    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    is_major: parseInt(navigator.appVersion),
    is_minor: parseFloat(navigator.appVersion),
    init: function()
    {
        // Note: you don't want your Nav4 or IE4 code to "turn off" or
        // stop working when Nav5 and IE5 (or later) are released, so
        // in conditional code forks, use this.is_nav4up ("Nav4 or greater")
        // and this.is_ie4up ("IE4 or greater") instead of this.is_nav4 or this.is_ie4
        // to check version in code which you want to work on future
        // versions. For DOM tests scripters commonly used the 
        // this.is_getElementById test, but make sure you test your code as
        // filter non-compliant browsers (Opera 5-6 for example) as some 
        // browsers return true for this test, and don't fully support
        // the W3C's DOM1.
        this.is_opera = (this.agt.indexOf("opera") != -1);
        this.is_opera2 = (this.agt.indexOf("opera 2") != -1 || this.agt.indexOf("opera/2") != -1);
        this.is_opera3 = (this.agt.indexOf("opera 3") != -1 || this.agt.indexOf("opera/3") != -1);
        this.is_opera4 = (this.agt.indexOf("opera 4") != -1 || this.agt.indexOf("opera/4") != -1);
        this.is_opera5 = (this.agt.indexOf("opera 5") != -1 || this.agt.indexOf("opera/5") != -1);
        this.is_opera6 = (this.agt.indexOf("opera 6") != -1 || this.agt.indexOf("opera/6") != -1);
        this.is_opera7 = (this.agt.indexOf("opera 7") != -1 || this.agt.indexOf("opera/7") != -1);
        this.is_opera8 = (this.agt.indexOf("opera 8") != -1 || this.agt.indexOf("opera/8") != -1);
        this.is_opera9 = (this.agt.indexOf("opera 9") != -1 || this.agt.indexOf("opera/9") != -1);
        
        this.is_opera5up = (this.is_opera && !this.is_opera2 && !this.is_opera3 && !this.is_opera4);
        this.is_opera6up = (this.is_opera && !this.is_opera2 && !this.is_opera3 && !this.is_opera4 && !this.is_opera5);
        this.is_opera7up = (this.is_opera && !this.is_opera2 && !this.is_opera3 && !this.is_opera4 && !this.is_opera5 && !this.is_opera6);
        this.is_opera8up = (this.is_opera && !this.is_opera2 && !this.is_opera3 && !this.is_opera4 && !this.is_opera5 && !this.is_opera6 && !this.is_opera7);
        this.is_opera9up = (this.is_opera && !this.is_opera2 && !this.is_opera3 && !this.is_opera4 && !this.is_opera5 && !this.is_opera6 && !this.is_opera7 &&!this.is_opera8);
        
        // Note: On IE, start of appVersion return 3 or 4
        // which supposedly is the version of Netscape it is compatible with.
        // So we look for the real version further on in the string
        // And on Mac IE5+, we look for this.is_minor in the ua; since 
        // it appears to be more accurate than appVersion
        
        this.is_mac = (this.agt.indexOf("mac")!=-1);
        iePos  = this.appVer.indexOf('msie');
        if (iePos !=-1)
        {
            if(this.is_mac)
            {
                iePos = this.agt.indexOf('msie');
                this.is_minor = parseFloat(this.agt.substring(iePos+5,this.agt.indexOf(';',iePos)));
            }
            else
                this.is_minor = parseFloat(this.appVer.substring(iePos+5,this.appVer.indexOf(';',iePos)));
            
            this.is_major = parseInt(this.is_minor);
        }
        
        // ditto Konqueror
        this.is_konq = false;
        kqPos   = this.agt.indexOf('konqueror');
        if (kqPos !=-1)
        {                 
            this.is_konq  = true;
            this.is_minor = parseFloat(this.agt.substring(kqPos+10,this.agt.indexOf(';',kqPos)));
            this.is_major = parseInt(this.is_minor);
        }                                 
        
        this.is_getElementById   = (document.getElementById) ? "true" : "false";
        this.is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false";
        this.is_documentElement = (document.documentElement) ? "true" : "false";
        
        this.is_safari = ((this.agt.indexOf('safari')!=-1)&&(this.agt.indexOf('mac')!=-1))?true:false;
        this.is_khtml  = (this.is_safari || this.is_konq);
        
        this.is_gecko = ((!this.is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
        this.is_gver  = 0;
        if (this.is_gecko) this.is_gver=navigator.productSub;
        
        this.is_fb = ((this.agt.indexOf('mozilla/5')!=-1) && (this.agt.indexOf('spoofer')==-1) && (this.agt.indexOf('compatible')==-1) && (this.agt.indexOf('opera')==-1)  && (this.agt.indexOf('webtv')==-1) && (this.agt.indexOf('hotjava')==-1) && (this.is_gecko) && (navigator.vendor=="Firebird"));
        this.is_fx = ((this.agt.indexOf('mozilla/5')!=-1) && (this.agt.indexOf('spoofer')==-1) && (this.agt.indexOf('compatible')==-1) && (this.agt.indexOf('opera')==-1)  && (this.agt.indexOf('webtv')==-1) && (this.agt.indexOf('hotjava')==-1) && (this.is_gecko) && ((navigator.vendor=="Firefox")||(this.agt.indexOf('firefox')!=-1)));
        this.is_moz   = ((this.agt.indexOf('mozilla/5')!=-1) && (this.agt.indexOf('spoofer')==-1) && (this.agt.indexOf('compatible')==-1) && (this.agt.indexOf('opera')==-1)  && (this.agt.indexOf('webtv')==-1) && (this.agt.indexOf('hotjava')==-1) && (this.is_gecko) && (!this.is_fb) && (!this.is_fx) && ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
        if ((this.is_moz)||(this.is_fb)||(this.is_fx))
        {  
            this.is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
            if(this.is_fx&&!this.is_moz_ver)
            {
                this.is_moz_ver = this.agt.indexOf('firefox/');
                this.is_moz_ver = this.agt.substring(this.is_moz_ver+8);
                this.is_moz_ver = parseFloat(this.is_moz_ver);
            }
            if(!(this.is_moz_ver))
            {
                this.is_moz_ver = this.agt.indexOf('rv:');
                this.is_moz_ver = this.agt.substring(this.is_moz_ver+3);
                this.is_paren   = this.is_moz_ver.indexOf(')');
                this.is_moz_ver = this.is_moz_ver.substring(0,this.is_paren);
            }
            this.is_minor = this.is_moz_ver;
            this.is_major = parseInt(this.is_moz_ver);
        }
        this.is_fb_ver = this.is_moz_ver;
        this.is_fx_ver = this.is_moz_ver;
		
		this.is_nav  = ((this.agt.indexOf('mozilla')!=-1) && (this.agt.indexOf('spoofer')==-1) && (this.agt.indexOf('compatible') == -1) && (this.agt.indexOf('opera')==-1) && (this.agt.indexOf('webtv')==-1) && (this.agt.indexOf('hotjava')==-1) && (!this.is_khtml) && (!(this.is_moz)) && (!this.is_fb) && (!this.is_fx));
        
        // Netscape6 is mozilla/5 + Netscape6/6.0!!!
        // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
        // Changed this to use navigator.vendor/vendorSub - dmr 060502   
        // nav6Pos = this.agt.indexOf('netscape6');
        if ((navigator.vendor)&& ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&& (this.is_nav))
        {
            this.is_major = parseInt(navigator.vendorSub);
            // here we need this.is_minor as a valid float for testing. We'll
            // revert to the actual content before printing the result. 
            this.is_minor = parseFloat(navigator.vendorSub);
        }
        
        this.is_nav2 = (this.is_nav && (this.is_major == 2));
        this.is_nav3 = (this.is_nav && (this.is_major == 3));
        this.is_nav4 = (this.is_nav && (this.is_major == 4));
        this.is_nav4up = (this.is_nav && this.is_minor >= 4);
        this.is_navonly      = (this.is_nav && ((this.agt.indexOf(";nav") != -1) || (this.agt.indexOf("; nav") != -1)) );
        
        this.is_nav6   = (this.is_nav && this.is_major==6); 
        this.is_nav6up = (this.is_nav && this.is_minor >= 6); 
		
        this.is_nav5   = (this.is_nav && this.is_major == 5 && !this.is_nav6); // checked for ns6
        this.is_nav5up = (this.is_nav && this.is_minor >= 5);
        
        this.is_nav7   = (this.is_nav && this.is_major == 7);
        this.is_nav7up = (this.is_nav && this.is_minor >= 7);
        
        this.is_nav8   = (this.is_nav && this.is_major == 8);
        this.is_nav8up = (this.is_nav && this.is_minor >= 8);
        
        this.is_ie   = ((iePos!=-1) && (!this.is_opera) && (!this.is_khtml));
        this.is_ie3  = (this.is_ie && (this.is_major < 4));
        
        this.is_ie4   = (this.is_ie && this.is_major == 4);
        this.is_ie4up = (this.is_ie && this.is_minor >= 4);
        this.is_ie5   = (this.is_ie && this.is_major == 5);
        this.is_ie5up = (this.is_ie && this.is_minor >= 5);
        
        this.is_ie5_5  = (this.is_ie && (this.agt.indexOf("msie 5.5") !=-1));
        this.is_ie5_5up =(this.is_ie && this.is_minor >= 5.5);        
        
        this.is_ie6   = (this.is_ie && this.is_major == 6);
        this.is_ie6up = (this.is_ie && this.is_minor >= 6);
        
        this.is_ie7   = (this.is_ie && this.is_major == 7);
        this.is_ie7up = (this.is_ie && this.is_minor >= 7);
        
        this.is_w3c = (!this.is_ie4 && !this.is_nav6 && !this.is_opera && document.getElementById);
        
        this.is_ieCE = (document.captureEvents && !this.is_nav6);
        
        // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
        // or if this is the first browser window opened.  Thus the
        // variables this.is_aol, this.is_aol3, and this.is_aol4 aren't 100% reliable.
        
        this.is_aol   = (this.agt.indexOf("aol") != -1);
        this.is_aol3  = (this.is_aol && this.is_ie3);
        this.is_aol4  = (this.is_aol && this.is_ie4);
        this.is_aol5  = (this.agt.indexOf("aol 5") != -1);
        this.is_aol6  = (this.agt.indexOf("aol 6") != -1);
        this.is_aol7  = ((this.agt.indexOf("aol 7")!=-1) || (this.agt.indexOf("aol7")!=-1));
        this.is_aol8  = ((this.agt.indexOf("aol 8")!=-1) || (this.agt.indexOf("aol8")!=-1));
        
        this.is_webtv = (this.agt.indexOf("webtv") != -1);
        
        this.is_TVNavigator = ((this.agt.indexOf("navio") != -1) || (this.agt.indexOf("navio_aoltv") != -1)); 
        this.is_AOLTV = this.is_TVNavigator;
        
        this.is_hotjava = (this.agt.indexOf("hotjava") != -1);
        this.is_hotjava3 = (this.is_hotjava && (this.is_major == 3));
        this.is_hotjava3up = (this.is_hotjava && (this.is_major >= 3));
        
    },
    getNav4Tags: function( tagtyp, objDoc, arTags )
    {
        objDoc = objDoc || document;
        arTags = arTags || new Array();

        var obj = (tagtyp == "a") ? objDoc.links : objDoc.layers;

        for(var z = obj.length; z--;) 
                arTags[ arTags.length ] = obj[z];

        for(z = objDoc.layers.length; z--;) 
                arTags = this._navUA4Tags( tagtyp, objDoc.layers[z].document, arTags );

        return arTags;
    },
    getDocumentTags: function( strTag )
    {
		return this.getDocumentTagsInElement( document, strTag );
    },
    getDocumentTagsInElement: function( objElement, strTag )
    {
        var tags;
        
        //if ( !this.is_nav4 && strTag == "a" )
            //tags = objElement.links;
        if ( this.is_ie4 )
            tags = objElement.all.tags( strTag );
        else // standard way of doing things
            tags = objElement.getElementsByTagName( strTag );
        
        if ( hd.utils.browser.is_nav4 && (strTag == "a" || strTag == "layer") )
            tags = hd.utils.browser.getNav4Tags( strTag, objElement );
            
        return tags;
    },
    showObjectByID: function( objectID, bShow )
    {
        var obj = this.getObject( objectID );
        if ( obj )
        {
            this.showObject( obj, bShow );
        }
    },
    showObject: function( obj, bShow )
    {
        if ( obj )
        {
            if( this.is_nav4 ) 
                obj.setAttribute( "visibility", (bShow ? 'show' : 'hide') );
            else
            {
                var objTarget = obj.style || obj;
                if ( objTarget )
                    objTarget.visibility = (bShow ? 'visible' : 'hidden');
            }
            
        }
    },
    getObject: function( id )
    {
        return( this.is_nav4 ? (document.layers[ id ] || null) : this.is_ie4 ? (document.all[ id ] || null) : (document.getElementById( id ) || null) );
    },
    getObjectWidth: function( obj )
    {
        if ( !obj ) return 0;    
        return hd.utils.toInt( this.is_nav4 ? obj.clip.width : (obj.style.pixelWidth || obj.offsetWidth) );
    },
    setObjectWidth: function( obj, nWidth )
    {
        if ( !obj ) return;
        
        if ( this.is_nav4 )
            obj.clip.width = nWidth;
        else
        {
            if ( obj.style.pixelWidth != this._undefined )
                obj.style.pixelWidth = nWidth;
            else if ( obj.offsetWidth != this._undefined )
                obj.offsetWidth = nWidth;
        }
        
    },
    getObjectHeight: function( obj )
    {
        if ( !obj ) return 0;    
        return hd.utils.toInt( this.is_nav4 ? obj.clip.height : (obj.style.pixelHeight || obj.offsetHeight) );
    },
    setObjectHeight: function( obj, nHeight )
    {
        if ( !obj ) return;
        
        if ( this.is_nav4 )
            obj.clip.height = nHeight;
        else
        {
            if ( obj.style.pixelHeight != this._undefined )
                obj.style.pixelHeight = nHeight;
            else if ( obj.offsetHeight != this._undefined )
                obj.offsetHeight = nHeight;
        }
    },
    getObjectAbsoluteX: function( obj )
    {
        var nX = obj.offsetLeft;
        while( (obj = obj.offsetParent) != null )
        {
              nX += obj.offsetLeft;
        }
        return nX;
    },
    getObjectAbsoluteY: function( obj )
    {
        var nY = obj.offsetTop;
        while( (obj = obj.offsetParent) != null )
        {
              nY += obj.offsetTop;
        }
        return nY;
    },
    setObjectZ: function( obj, ieframe )
    {
        if ( !obj ) return;    
        obj = obj.style || obj;
        if( obj )
        {
            if(window.dd && dd.z)
                obj.zIndex = Math.max(dd.z+1, obj.zIndex);
            
            if( ieframe ) 
                ieframe.style.zIndex = obj.zIndex - 1;
        }
    },
    setObjectPos: function( obj, ieframe, x, y )
    {
        if ( !obj ) return;    
        obj = obj.style || obj;
        var px = (hd.utils.browser.is_opera6 || hd.utils.browser.is_nav4) ? '' : 'px';

        obj.left = x + px;
        obj.top = y + px;

        //  window... to circumvent the FireFox Alzheimer Bug
        if( ieframe)
        {
                ieframe.style.left = obj.left;
                ieframe.style.top = obj.top;
        }
    },
    showIEFrame: function( objCurrent, ieframe, bShow )
    {
        if(!objCurrent || !ieframe) return;
        
        if( bShow )
        {
            ieframe.style.width = hd.utils.browser.getObjectWidth( objCurrent ) + 'px';
            ieframe.style.height = hd.utils.browser.getObjectHeight( objCurrent ) + 'px';
            ieframe.style.display = "block";
        }
        else 
            ieframe.style.display = "none";
    },
    getFlashMovie: function( objectID )
    {
        return window.document[objectID];
    },
	setAttribute: function( obj, strName, strValue )
	{
		if ( this.is_ie )
			obj[ strName ] = strValue;
		else
			obj.setAttribute( strName, strValue );
	}
};

hd.utils.browser.init();
