var iNbZoomWnd = 0;
var iZoomZindex = 100;

var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;



function zoomImage(folder, id, width, height)
{
	
	var zoomDiv = document.getElementById('divZoom' + folder + "-" + id);
	if(zoomDiv == null)
	{
		var sZoomDivContent = "<IMG SRC='Images/Hotels/" + folder + "/" + id + ".jpg' WIDTH="+ width + " HEIGHT=" +  height + " BORDER=0>";
		sZoomDivContent += "<IMG CLASS='Close' SRC='images/Close.jpg' BORDER=0 WIDTH=51 HEIGHT=13 onclick='javascript:removeZoom(this)'>";

		//zoomDiv = document.createElement('div');
		//zoomDiv.setAttribute('class','Zoom');
		zoomDiv = document.getElementById("myZoom");
		zoomDiv.style.display = "block";
		
		zoomDiv.style.width = width + 'px';
		zoomDiv.style.height = height + 'px';

		zoomDiv.className = 'Zoom';
		if (iNbZoomWnd==0)
		{
			iZoomZindex = 100;
		}
		else
		{
			iZoomZindex++;
		}
		zoomDiv.style.zIndex = iZoomZindex;

		var offsetY = (document.body.clientHeight > 700)?100:0;
		zoomDiv.style.top =((document.body.clientHeight - (offsetY + parseInt(height,10) ))/2) + (iNbZoomWnd*15) + offsetY + document.body.scrollTop;
		zoomDiv.style.left = ((document.body.clientWidth - parseInt(width,10))/2) + (iNbZoomWnd*15);
		zoomDiv.innerHTML = sZoomDivContent;


		zoomDiv.setAttribute('id', 'divZoom' + folder + "-" + id);
		//document.body.appendChild(zoomDiv);
		document.getElementById("myZoom").appendChild(zoomDiv);
		
		iNbZoomWnd ++;
	}
} 

function removeZoom(obj)
{
    var parent = obj.parentNode;
    
	//document.body.removeChild(parent);
    parent.style.display = "none";
	iNbZoomWnd --;
}


function movemouse(e)
{
	if (isdrag)
	{
		dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
		dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
		return false;
	}
}

function selectmouse(e) 
{
	var fobj       = nn6 ? e.target : event.srcElement;
	var topelement = nn6 ? "HTML" : "BODY";

	while (fobj.tagName != topelement && fobj.className != "Zoom")
	{
		fobj = nn6 ? fobj.parentNode : fobj.parentElement;
	}

	if (fobj.className=="Zoom")
	{
		isdrag = true;
		dobj = fobj;
		if (dobj.style.zIndex != iZoomZindex)
		{
			iZoomZindex++;
			dobj.style.zIndex = iZoomZindex;
		}
		tx = parseInt(dobj.style.left+0);
		ty = parseInt(dobj.style.top+0);
		x = nn6 ? e.clientX : event.clientX;
		y = nn6 ? e.clientY : event.clientY;
		document.onmousemove=movemouse;
		return false;
	}
}

//document.onmousedown=selectmouse;
//document.onmouseup=new Function("isdrag=false");
