

var IE = document.all?true:false;
//if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var mousex = 0;
var mousey = 0;
var srcMain = 'img/items/thumbs/';
var srcHov = 'img/items/250wide/';
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
	mousex = event.clientX + document.documentElement.scrollLeft;
	mousey = event.clientY + document.documentElement.scrollTop;
	
}
else {  // grab the x-y pos.s if browser is NS
	mousex = e.pageX;
	mousey = e.pageY;
}  
if (mousex < 0){mousex = 0;}
if (mousey < 0){mousey = 0;}  


return true;
}
//  End -->
//	onchange="if
//(=='M')

function changeImage(id, src) {

document.getElementById(id).src= src;

}

function restoreImage(i){	
	var name = 'i' + i; 
	var img = document.images[name];
	img.src = srcMain + i + ".jpg";	
	img.style.position= "relative";
	img.style.left='0px';
	img.style.top = '0px';
	
	}
	
	
	
function floatOrderImage(i){
	var name = 'i' + i; 		
	var img = document.images[name];
	
//	var offsetL = img.width;
	var offsetT = img.height/2;

//change the source folder of thie image for the new version
	img.src = srcHov + i + ".jpg";
	img.style.position= "absolute";
	//IE issue
/*	if(offsetL == 0){
	offsetL = 150;
	offsetT = 150;
	}
	*/
	//set the left position	
	var pos = parseInt(mousex); //x is the mouse x co-ordinate
		pos -= (250);
		
	var posStr = new String(pos);
		posStr = posStr.concat("px");
		img.style.left = posStr;
	//set the right position
		pos = parseInt(mousey); //x is the mouse x co-ordinate
		pos -= offsetT;
		posStr = new String(pos);
		posStr = posStr.concat("px");
		img.style.top = posStr;
	// make the image visible
	//	img.style.display = "block";
	// change the setting to on again

}


function floatImage(i){
	var name = 'i' + i; 	
	var img = document.images[name];
	
	var offsetL = img.width/2;
	var offsetT = img.height/2;
	
	//IE issue
	if(offsetL == 0){
	offsetL = 150;
	offsetT = 150;
	}
	
	//set the left position	
	var pos = parseInt(mousex); //x is the mouse x co-ordinate
		pos -= offsetL;
	var posStr = new String(pos);
		posStr = posStr.concat("px");
	img.style.left = posStr;
	//set the right position
		pos = parseInt(mousey); //x is the mouse x co-ordinate
		pos -= offsetT;
		posStr = new String(pos);
		posStr = posStr.concat("px");
		img.style.top = posStr;
	// make the image visible
		img.style.display = "block";
		hovered = i;
	// change the setting to on again


}
	
// i is the image number or image source
//p is the desired placement of the image
// px is left right placement, py is up down placement
//choices for px are - l - left c - center r - right
// choices for py are t - top,  m - middle, b - bottom
// s is optional, if present the image source is used
function hoverOver(i, px, py){
	
	var img = document.images['hov'];
	var offsetL = 0;
	var offsetT = 0;
	img.style.display="none";
	switch (px){
		case 'l':  offsetL = img.width;		break;
		case 'c':	offsetL = img.width/2;	break;
		case 'r':	offsetL = -40;				break;
		default: 	offsetL = img.width/2;
	}
	
	switch (py){
		case 't':   offsetT = img.height + 50;		break;
		case 'm':	offsetT = img.height/2;	break;
		case 'b':	offsetT = -50;				break;
		default:		offsetT = img.height/2; 
	}

//set the source for the new image 
		 
	if(i.charAt(0) == "i") {// this will mean that a source has been passed in as all image sources start with "i"
		img.src = i;	
	}else{ // use the item number as image name and add to source file
	img.src = srcHov + i + ".jpg";
	}
	
	
	//IE issue
	if(offsetL == 0){
	offsetL = 150;
	offsetT = 150;
	}
	
	//set the left position	
	var pos = parseInt(mousex); //x is the mouse x co-ordinate
		pos -= offsetL;
	var posStr = new String(pos);
		posStr = posStr.concat("px");
	img.style.left = posStr;
	
	
	//set the position from top
		pos = parseInt(mousey); //x is the mouse x co-ordinate
		pos -= offsetT;
		posStr = new String(pos);
		posStr = posStr.concat("px");
		img.style.top = posStr;
	// make the image visible
		img.style.display = "block";
	
}
		
function showImage(i){	
	var img = document.images[i];
	img.style.display = "block";
	}
	
		
function hideImage(i){	
	var img = document.images[i];
	img.style.display = "none";
	}
			
function hideHovered(){	
	var img = document.images[hovered];
	img.style.display = "none";
	}
	
function toggleImage( i_old, i_new ){

		hideImage(i_old);
		showImage(i_new);

}

function swapbgimage( id, src, pos ){
	var element = document.getElementById(id);
	element.style.background = "url('" + src +"') " + pos + " no-repeat" ;
		
}




