﻿// JScript File

var Swatchoffsetxpoint=5 //Customize x offset of tooltip
var Swatchoffsetypoint=3 //Customize y offset of tooltip
var Swatchie=document.all
var Swatchns6=document.getElementById && !document.all
var Swatchenabletip=false
if (Swatchie||Swatchns6)
var tipSwatchObj=document.all? document.all["dhtmlSwatchtooltip"] : document.getElementById? document.getElementById("dhtmlSwatchtooltip") : ""
var tipSwatchDescription=document.all? document.all["SwatchDescription"] : document.getElementById? document.getElementById("SwatchDescription") : ""
var tipSwatchFooter=document.all? document.all["SwatchFooter"] : document.getElementById? document.getElementById("SwatchFooter") : ""

function Swatchietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function Swatchddrivetip(Footer, backgroundImage, thewidth)
{
    if (Swatchns6||Swatchie)
    {
        tipSwatchDescription.style.backgroundImage="url("+ backgroundImage +")"
        tipSwatchFooter.innerHTML=Footer
        Swatchenabletip=true
        document.onmouseover=Swatchpositiontip
        return false
}
}

function Swatchpositiontip(e)
{
    if (Swatchenabletip)
    {
        var SwatchCurX=(Swatchns6)?e.pageX : event.clientX+Swatchietruebody().scrollLeft;
        var SwatchCurY=(Swatchns6)?e.pageY : event.clientY+Swatchietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var Swatchrightedge=Swatchie&&!window.opera? Swatchietruebody().clientWidth-event.clientX-Swatchoffsetxpoint : window.innerWidth-e.clientX-Swatchoffsetxpoint-20
        var Swatchbottomedge=Swatchie&&!window.opera? Swatchietruebody().clientHeight-event.clientY-Swatchoffsetypoint : window.innerHeight-e.clientY-Swatchoffsetypoint-20

        //var Swatchleftedge=(Swatchoffsetxpoint<0)? Swatchoffsetxpoint*(-1) : -1000
        var Swatchleftedge=ie&&!window.opera? event.clientX-Swatchoffsetxpoint : e.clientX-Swatchoffsetxpoint-20
        
        if (Swatchrightedge<tipSwatchObj.offsetWidth)
        {            
            //move the horizontal position of the menu to the left by it's width
            if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("MSIE")!=-1)
                if(Swatchleftedge > tipSwatchObj.offsetWidth)
               	    tipSwatchObj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipSwatchObj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipSwatchObj.offsetWidth+"px";
               	else if(Swatchleftedge < tipSwatchObj.offsetWidth)
               	    tipSwatchObj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipSwatchObj.offsetWidth/2+"px" : window.pageXOffset+e.clientX-tipSwatchObj.offsetWidth/2+"px";    
            else// Safari
                if(Swatchleftedge > tipSwatchObj.offsetWidth)
				    tipSwatchObj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipSwatchObj.offsetWidth+"px" : e.clientX-tipSwatchObj.offsetWidth+"px";
				else if(Swatchleftedge < tipSwatchObj.offsetWidth)
				    tipSwatchObj.style.left=ie? ietruebody().scrollLeft+event.clientX+Swatchleftedge-tipSwatchObj.offsetWidth+"px" : e.clientX+Swatchleftedge-tipSwatchObj.offsetWidth+"px";
	    }
        else if (SwatchCurX<Swatchleftedge)
           tipSwatchObj.style.left="5px";         
        else
        {
            //position the horizontal position of the menu where the mouse is positioned
            tipSwatchObj.style.left=SwatchCurX+Swatchoffsetxpoint+"px"
        }

        //same concept with the vertical position
        if (Swatchbottomedge<tipSwatchObj.offsetHeight)
			if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("MSIE")!=-1)
				tipSwatchObj.style.top=ie? ietruebody().scrollTop+event.clientY-tipSwatchObj.offsetHeight-Swatchoffsetypoint+"px" : window.pageYOffset+e.clientY-tipSwatchObj.offsetHeight-Swatchoffsetypoint+"px";
			else// Safari
				tipSwatchObj.style.top=ie? ietruebody().scrollTop+event.clientY-tipSwatchObj.offsetHeight-Swatchoffsetypoint+"px" : e.clientY-tipSwatchObj.offsetHeight-Swatchoffsetypoint+"px";      
        else
        {
            tipSwatchObj.style.top=SwatchCurY+Swatchoffsetypoint+"px";
        }
        tipSwatchObj.style.visibility="visible"
    }
}

function Swatchhideddrivetip(){
if (Swatchns6||Swatchie){
Swatchenabletip=false
tipSwatchObj.style.visibility="hidden"
tipSwatchObj.style.left="-1000px"
tipSwatchObj.style.backgroundColor=''
tipSwatchObj.style.width=''
}
}