var ie=document.all;
var ns6=document.getElementById&&!document.all;
var alreadyFloating = false;

function ietruebody() {
	return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body;
}


function createFloat(imgID, e, imgWidth, imgHeight) {
	if (alreadyFloating) {
		closepreview();
	}
	if (ie||ns6){
		if (!imgHeight) {
			imgHeight = 200;
		}
		if (!imgWidth) {
			imgWidth = 400;
		}
		//testVar = document.getElementById(imgID);
		//document.write(testVar);
		imgValue = document.getElementById ? document.getElementById(imgID) : document.all.showimage
		var horzpos = ns6 ? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
		var vertpos = ns6 ? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
		imgValue.style.left = horzpos-imgWidth/2-2+"px"
		imgValue.style.top = vertpos-imgHeight/2-10+"px"

		imgValue.style.visibility="visible";
		alreadyFloating = true;
		return false
	}
	else { // old browser, just display the alternate page
	return true

	}
}

function closepreview() {
	imgValue.style.visibility="hidden";
	alreadyFloating = false;
}

function drag_drop(e) {
	if (ie&&dragapproved) {
		imgValue.style.left=tempx+event.clientX-offsetx+"px"
		imgValue.style.top=tempy+event.clientY-offsety+"px"
	}
	else if (ns6&&dragapproved) {
		imgValue.style.left=tempx+e.clientX-offsetx+"px"
		imgValue.style.top=tempy+e.clientY-offsety+"px"
	}
	return false
}

function initializedrag(e) {
	if (ie&&event.srcElement.id=="titlebar"||ns6&&e.target.id=="titlebar") {
		offsetx=ie? event.clientX : e.clientX
		offsety=ie? event.clientY : e.clientY
		tempx=parseInt(imgValue.style.left)
		tempy=parseInt(imgValue.style.top)
		dragapproved=true
		document.onmousemove=drag_drop
	}
}

document.onmousedown=initializedrag;
document.onmouseup=new Function("dragapproved=false");
