/***********************************************
* Image Thumbnail viewer- ? Dynamic Drive (www.dynamicdrive.com)
* Last updated Sept 26th, 03'. This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

curwindow = "";
ie="";
ns6="";
dragapproved=false;
crossobj=null;

function stopDrag() {
	dragapproved=false;	
}

function ietruebody(){
	curwindow = parent.frames.contents;
	ie=curwindow.document.all;
	ns6=curwindow.document.getElementById&&!curwindow.document.all;
	return (curwindow.document.compatMode && curwindow.document.compatMode!="BackCompat" && !window.opera)? curwindow.document.documentElement : curwindow.document.body
}

function enlarge(which, e, position, imgwidth, imgheight) {
	if (parent.frames.contents.document.onmousedown == null) {
		parent.frames.contents.document.onmousedown=initializedrag;	
		//parent.frames.contents.document.onmouseup=new Function("dragapproved=false");
		parent.frames.contents.document.onmouseup=new Function("stopDrag()");
	}
	curwindow = parent.frames.contents;
	ie=curwindow.document.all;
	ns6=curwindow.document.getElementById&&!curwindow.document.all;
	position="center";
	imgwidth=0;
	imgheight=0;
	if (ie||ns6){
		crossobj=curwindow.document.getElementById? curwindow.document.getElementById("showimage") : curwindow.document.all.showimage;
		if (position=="center"){
			pgyoffset=ns6? parseInt(curwindow.pageYOffset) : parseInt(ietruebody().scrollTop);
			horzpos=ns6? curwindow.pageXOffset+curwindow.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2;
			//vertpos=ns6? pgyoffset+curwindow.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2;
			vertpos=ns6? pgyoffset+100 : pgyoffset+100;
			if (window.opera && curwindow.innerHeight) //compensate for Opera toolbar
				vertpos=pgyoffset+curwindow.innerHeight/2-imgheight/2
				vertpos=Math.max(pgyoffset, vertpos)
			} else{
				var horzpos=ns6? curwindow.pageXOffset+e.clientX : ietruebody().scrollLeft+curwindow.event.clientX
				var vertpos=ns6? curwindow.pageYOffset+e.clientY : ietruebody().scrollTop+curwindow.event.clientY
			}
			//alert(horzpos);
			crossobj.style.left=20+"px";
			crossobj.style.top=vertpos+"px";
	
			crossobj.innerHTML='<div align="right" id="dragbar"><span id="closetext" onClick="parent.closepreview()">close</span> </div><img src="'+which+'">';
			crossobj.style.visibility="visible";
			return false
	} else { //if NOT IE 4+ or NS 6+, simply display image in full browser window
		return true
	}
}

function closepreview() {
	curwindow = parent.frames.contents;
	ie=curwindow.document.all;
	ns6=curwindow.document.getElementById&&!curwindow.document.all;
	crossobj.style.visibility="hidden";
}

function drag_drop(e){
	curwindow = parent.frames.contents;
	ie=curwindow.document.all;
	ns6=curwindow.document.getElementById&&!curwindow.document.all;
	if (ie&&dragapproved){
		crossobj.style.left=tempx+curwindow.event.clientX-offsetx+"px";
		crossobj.style.top=tempy+curwindow.event.clientY-offsety+"px";
	}
	else if (ns6&&dragapproved){
		crossobj.style.left=tempx+e.clientX-offsetx+"px";
		crossobj.style.top=tempy+e.clientY-offsety+"px";
	}
return false
}

function initializedrag(e){
	curwindow = parent.frames.contents;
	ie=curwindow.document.all;
	ns6=curwindow.document.getElementById&&!curwindow.document.all;
	if (ie&&curwindow.event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
		offsetx=ie? curwindow.event.clientX : e.clientX;
		offsety=ie? curwindow.event.clientY : e.clientY;
		
		tempx=parseInt(crossobj.style.left);
		tempy=parseInt(crossobj.style.top);
		
		dragapproved=true;
		curwindow.document.onmousemove=drag_drop;
	}
}


