/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var imageName;
	var fullsize;
	//hard-code the window name...
	var windowID = 'Model';

	var aImages = document.getElementsByTagName('img');
	
	function getOffsetLeft (el) {
	var ol = el.offsetLeft;
	while ((el = el.offsetParent) != null)
	ol += el.offsetLeft;
	return ol;
	}
	function getOffsetTop (el) {
	var ot = el.offsetTop;
	while((el = el.offsetParent) != null)
	ot += el.offsetTop;
	return ot;
	}
	function showXY(image){
	var x = getOffsetLeft(image);
	var y = getOffsetTop(image);
	//alert(x+' , '+y);
	return y;
	}

	function showX(image){
	var x = getOffsetLeft(image);		
	return x;
	}
	
	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imagehover') {
			
			aImages[i].onmouseover = function() {				
				var w = document.getElementById(windowID);
				if (w != null)
				{	
					w.style.display = 'block';
					w.style.visibility = 'visible';						
					//w.style.top = 5 + showXY(this) -40; //185
					//w.style.left = 5; //60
					
					w.style.pixelTop = document.body.scrollTop + 100;
					w.style.pixelLeft = showX(this) +100;
					
					imageName = this.getAttribute('src');					
					fullsize = imageName.substring(0, imageName.length - 6) + ".jpg";

					//write HTML to the layer so that the full size image is displayed...					
					//changed from fullsize to the original image...
					//w.innerHTML = "<img src=\""+ fullsize + "\">";
					w.innerHTML = "<img src=\""+ imageName + "\">";
																						//need to write dom version of this innerhtml thing...
					//menu = new getObj('Model');
					//movemenu();
				}				
			}			
			
			aImages[i].onmouseout = function() {				
				var w = document.getElementById(windowID);
				if (w != null)
				{
					w.style.display = 'none';
					w.style.visibility = 'hidden';					
					w.top = -999;
					w.left = -999;
				}
			}
		}
	}
}

window.onload = initRollovers;
