function AlternatePhoto(obj)
{
    if(obj)
    {        
        document.getElementById("product_image").src = obj.attributes['simg'].nodeValue;
        document.getElementById("product_image").attributes['jqimg'].nodeValue = obj.attributes['bimg'].nodeValue;
    }
}	
            
var settings = {xzoom: 450,	yzoom: 600, offset: 30
,	position:"right", preload:1};			
var zoomdiv = document.getElementById("zoomdiv"); 
var zoomimg = document.getElementById("zoomdivimg"); 

function getTop(e){
	var offset=e.offsetTop;
	if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
	return offset;
}
function getLeft(e){
	var offset=e.offsetLeft;
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
	return offset;
}

function pv_onmousemove(event){	
	var img = document.getElementById("product_image");		
	var imageLeft = getLeft(img);
	var imageTop =  getTop(img);
	var imageWidth = img.offsetWidth;
	var imageHeight = img.offsetHeight;
	var imageRight = imageLeft + imageWidth;
			
	var bigimage = img.attributes["jqimg"].nodeValue;            
	
	if (zoomdiv.style.display != "block"){	
		if(settings.position == "right"){
			leftpos = imageLeft + imageWidth + settings.offset;
		}else{
			leftpos = imageLeft - settings.xzoom - settings.offset;
		}				
		zoomdiv.style.width = settings.xzoom + 'px';
		zoomdiv.style.height = settings.yzoom + 'px';
		zoomimg.src = bigimage;			
		zoomdiv.style.left = leftpos + 'px';
		zoomdiv.style.top  = imageTop + 'px';	
		zoomdiv.style.display = "block";
	}else{					
		var bigwidth = zoomimg.offsetWidth;
		var bigheight = zoomimg.offsetHeight;
		var scaley ='x';
		var scalex= 'y';
		if(isNaN(scalex)|isNaN(scaley)){
			var scalex = Math.round(bigwidth/imageWidth);
			var scaley = Math.round(bigheight/imageHeight);
		}					
		
		scrolly = event.clientY - imageTop - (zoomdiv.offsetHeight*1/scaley)/2 +60;
		zoomdiv.scrollTop = (scrolly * scaley);						
		scrollx = event.clientX - imageLeft - (zoomdiv.offsetWidth*1/scalex)/2 ;
		zoomdiv.scrollLeft = ((scrollx) * scalex);
	}
}		    

function pv_onmouseout(){	
	zoomdiv.style.display = "none";
}
