// Start Comment Script
var commentOffset = 10; // how far away x/y the comment will appear from the mouseover

var commentWidth = 250; // how wide the comment images are

var visibleComment = false; // stores the vibilized comment

function showComment(e,id) { /*
description: Shows a comment element
arguments: 
    e = event object, used to get the mouse position
    id = the id of the comment element to be made visible
returns: null
*/
    if(!e) var e = window.event; // IE enable
    if(!visibleComment) { // There are no visible comments
        if(document.getElementById) {  // browser is smart
            visibleComment = document.getElementById(id);
        } else { // browser is stupid
            visibleComment = document.all[id];
        }
        visibleComment.style.visibility = 'visible'; // visiblize the comment
        visibleComment.style.position = 'absolute';
        
        var posX; // the position of the comment horizontal
        var posY; // the position of the comment vertical
    
        if (e.pageX || e.pageY) { // FF/Saf
            posX = e.pageX + commentOffset + 'px';
            posY = e.pageY + commentOffset + 'px';
        } else if (e.clientX || e.clientY) { // IE
            var root;
            if(document.documentElement) { // IE 6 Strict
                root = document.documentElement;
            } else { // old IE
                root = document.body;
            }
            posX = e.clientX + root.scrollLeft + commentOffset + 'px';
            posY = e.clientY + root.scrollTop + commentOffset + 'px';
        }
        
        /* Use this to position comments on the left
        // Figure the vertical position
        posY = e.clientY + commentOffset + 'px';
        
        // Figure the horizontal position
        if(e.clientX < (window.innerWidth / 2)) { // the event happened BEFORE the horizontal middle of the screen
            posX = e.clientX + commentOffset + 'px'; // figure the horizontal position
            //window.alert('posX('+posX+') = e.clientX('+e.clientX+') + commentOffset('+commentOffset+')');
        } else { // the event happened AFTER the horizontal middle of the screen
            posX = (e.clientX - commentWidth) - commentOffset + 'px'; // figure the horizontal position
            //window.alert('posX('+posX+') = (e.clientX('+e.clientX+') - commentWidth('+commentWidth+')) - commentOffset('+commentOffset+')');
        }*/
        
        // Move the comment
        visibleComment.style.left = posX; // move the comment horizontal
        visibleComment.style.top = posY; // move the comment vertical
        
    }
}
function hideComment(id) { /*
description: Shows a comment element
arguments: id = the id of the comment element to be hidden
returns: null
*/
    visibleComment.style.visibility = 'hidden'; // hide the comment
    visibleComment = false; // clear the comment object holder so the script knows there are no visible comments
}
// End Comment Script

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
window.attachEvent("onload", correctPNG);
