/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
*    derived from: http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm
***********************************************/
//formatting the tool tip

// need to display....
// <div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100;filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);"></div>
// links:  <a  href="#" onmouseover="javascript: doTooltip(event,{position()-1})" onmouseout="javascript: hideTip()"  onclick="javascript:return bigImagePopup('prodimage{product_id}','{$popup_width}');">

var offsetxpoint=100; //Customize x offset of tooltip
var offsetypoint=-225; //Customize y offset of tooltip
var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
var tipWidth = 375;
var _allowTipMove = false;
var _fixedLeftAlignment = "";
var _fixAlignmentRightEdge = false;
var _swapLeftDisplayPadding="-60px"

//sets width of tip... important for calcs
function setTipWidth(newWidth) {
    tipWidth=newWidth;
}
//set to fixed left alignment
function setFixedLeftAlignment(leftAlign) {
    _fixedLeftAlignment=leftAlign;
}
//set to right edge [not ready yet...]
function setFixAlignmentRightEdge(rightEdge, offsetX) {
    _fixAlignmentRightEdge=rightEdge;
    offsetxpoint = offsetX;
}
//allows visible tip to move with mouse...
function setAllowTipMove(allowMove) {
    _allowTipMove=allowMove;
}
function setOffset(xOff, yOff) {
    offsetxpoint=xOff;
    offsetypoint=yOff;
}

//not sure needed....
function setEnabletip(isEnabled) {
    enabletip=isEnabled;
}

var tipobj=null;
function initTip() {
    if (document.all && document.all["tipDiv"]) {
      tipobj= document.all["tipDiv"];
    } else if (document.getElementById && document.getElementById("tipDiv")) {
      tipobj=document.getElementById("tipDiv");
    } 
}

function writeTipDiv() {
   var divExists = false;
   if (document.all && document.all["tipDiv"]) {
      divExists=true;
   }
   if (document.getElementById && document.getElementById("tipDiv")) {
      divExists=true;
   }
   if (!divExists) {
     document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>');
   }
}

function ietruebody(){
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

//to show basic text tool tip... text/html
function ddrivetip(thetext, thecolor, thewidth){
    if ((ns6||ie) && tipobj!= null){
        if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
        if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
        tipobj.innerHTML=thetext;
        enabletip=true;
        return false;
    }
}


var messages = new Array();
var messages2 = new Array(); //2nd array if needed
var messages3 = new Array(); //2nd array if needed

// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
/*
messages[0] = new Array('images/products/lm095_lg.jpg','ITEM #LM095');
messages[1] = new Array('images/products/lm042m_lg.jpg','ITEM #LM042M');
messages[2] = new Array('images/products/lm042l_lg.jpg','ITEM #LM042L');
messages[3] = new Array('images/products/lm013_lg.jpg','ITEM #LM013');
messages[4] = new Array('images/products/lm097_lg.jpg','ITEM #LM097');
messages[5] = new Array('images/products/lm007_lg.jpg','ITEM #LM007');
messages[6] = new Array('images/products/lm008_lg.jpg','ITEM #LM008');
*/

function preloadTooltipImages() {
   if (document.images) {
       //assert: can preload
	    var theImgs = new Array();
	    for (var i=0; i<messages.length; i++) {
  	    theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
        }
        
        
    }
}
function preloadTooltipImages2() {
   if (document.images) {
       //assert: can preload, and didnt do it already
	    var theImgs2 = new Array();
	    for (var i=0; i<messages2.length; i++) {
  	    theImgs2[i] = new Image();
		theImgs2[i].src = messages2[i][0];
        }        
    }
}

function preloadTooltipImages3() {
   if (document.images) {
       //assert: can preload, and didnt do it already
	    var theImgs3 = new Array();
	    for (var i=0; i<messages3.length; i++) {
  	    theImgs3[i] = new Image();
		theImgs3[i].src = messages3[i][0];
        }        
    }
}

// to show image tool tip...

function doTooltip(evt,num) {
  
   if ((ns6||ie) && tipobj!= null){
       var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
       var tipFontSize= "8pt";
       var tipFontColor= "#000000";
       var tipBgColor= "#FFFFFF"; 
       var tipBorderColor= "#0000CC";
       var tipBorderWidth= 1;
       var tipBorderStyle= "ridge";
       var tipPadding= 4;

       var startStr = '<table width="' + tipWidth + '" style="background-color: ' + tipBgColor+ '; border: '+ tipBorderStyle + ' ' + tipBorderWidth + 'px ' + tipBorderColor + ';"><tr><td align="center" width="100%"><img src="';
       var midStr = '" border="0"></td></tr><tr><td valign="top" bgcolor="#CCCCCC">';
       var endStr = '<\/td><\/tr>'; //</table>';
       //var tip = startStr + messages[num][0] + midStr + '<span style="width:100%;font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + messages[num][1] + '</span>' + endStr;
       var tip = startStr + messages[num][0] + midStr + endStr + '<tr><td style="text-align:center;width:100%;font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + messages[num][1] + endStr+ '<\/table>'; // + endStr;
       tipobj.innerHTML=tip;
       enabletip=true;
       return false;
   }
}

function doTooltip2(evt,num) {
 if ((ns6||ie) && tipobj!= null){
       var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
       var tipFontSize= "8pt";
       var tipFontColor= "#000000";
       var tipBgColor= "#FFFFFF"; 
       var tipBorderColor= "#0000CC";
       var tipBorderWidth= 1;
       var tipBorderStyle= "ridge";
       var tipPadding= 4;

       var startStr = '<table width="' + tipWidth + '" style="background-color: ' + tipBgColor+ '; border: '+ tipBorderStyle + ' ' + tipBorderWidth + 'px ' + tipBorderColor + ';"><tr><td align="center" width="100%"><img src="';
       var midStr = '" border="0"></td></tr><tr><td valign="top" bgcolor="#CCCCCC">';
       var endStr = '<\/td><\/tr>'; //</table>';
       //var tip = startStr + messages[num][0] + midStr + '<span style="width:100%;font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + messages[num][1] + '</span>' + endStr;
       var tip = startStr + messages2[num][0] + midStr + endStr + '<tr><td style="text-align:center;width:100%;font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + messages2[num][1] + endStr+ '<\/table>'; // + endStr;
       tipobj.innerHTML=tip;
       enabletip=true;
       return false;
   }
}

function doTooltip3(evt,num) {
 if ((ns6||ie) && tipobj!= null){
       var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
       var tipFontSize= "8pt";
       var tipFontColor= "#000000";
       var tipBgColor= "#FFFFFF"; 
       var tipBorderColor= "#0000CC";
       var tipBorderWidth= 1;
       var tipBorderStyle= "ridge";
       var tipPadding= 4;

       var startStr = '<table width="' + tipWidth + '" style="background-color: ' + tipBgColor+ '; border: '+ tipBorderStyle + ' ' + tipBorderWidth + 'px ' + tipBorderColor + ';"><tr><td align="center" width="100%"><img src="';
       var midStr = '" border="0"></td></tr><tr><td valign="top" bgcolor="#CCCCCC">';
       var endStr = '<\/td><\/tr>'; //</table>';
       //var tip = startStr + messages[num][0] + midStr + '<span style="width:100%;font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + messages[num][1] + '</span>' + endStr;
       var tip = startStr + messages3[num][0] + midStr + endStr + '<tr><td style="text-align:center;width:100%;font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + messages3[num][1] + endStr+ '<\/table>'; // + endStr;
       tipobj.innerHTML=tip;
       enabletip=true;
       return false;
   }
}

function positiontip(e){
    var redraw = true;
    if (!_allowTipMove && tipobj!= null && tipobj.style.visibility =="visible" ) {
        redraw=false;   
    }
    if (enabletip && tipobj!= null && redraw){
        
        var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
        var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
        var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;
        var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;

        //set left alignment        
        if (_fixedLeftAlignment!="") {
           tipobj.style.left=_fixedLeftAlignment;
        } else if (_fixAlignmentRightEdge && tipobj.offsetWidth && tipobj.style.left) {
           //alert(tipobj.offsetWidth);
           //rjf - 12 dec 2008 - just uncommented following 2 lines
           var fixedOff = parseInt(tipobj.offsetWidth) + offsetxpoint;
           tipobj.style.left = tipobj.offsetWidth + "px";
        } else {
            //if the horizontal distance isn't enough to accomodate the width of the context menu
            if (rightedge<tipobj.offsetWidth)
            //move the horizontal position of the menu to the left by it's width
            tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth - 10 +"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth - 10 +"px"
            else if (curX<leftedge)
            tipobj.style.left=_swapLeftDisplayPadding;
            else
            //position the horizontal position of the menu where the mouse is positioned
            tipobj.style.left=curX+offsetxpoint+"px";
        } 
        
        
        //handle top-bottom....

        //same concept with the vertical position
        if (bottomedge<tipobj.offsetHeight)
        tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
        else
        tipobj.style.top=curY+offsetypoint+"px";
        tipobj.style.visibility="visible";
    }
    
    
}



function hideddrivetip(){
if ((ns6||ie) && tipobj!= null){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

function hideTip() {
  hideddrivetip();
}

window.onload = initTip;
document.onmousemove=positiontip;

//-------------------------------
// end



