//<script language="JavaScript" src="../shared/scripts/popimg.js"></script>
//<div id="showimage" style="position:absolute; visibility:hidden; border:#000000 solid 1px; background-color:#A9A9A9; z-index:7;"></div>
//onClick="return enlarge('uploadimages/180/154798.JPG',event)"

var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all
function placeDiv(x,y){
	var crossobj = document.getElementById ? document.getElementById("showimage") : document.all.showimage;
	if( crossobj ){
		if( x < 0 ){
			crossobj.style.right = 10;
		}else if( x ){
			crossobj.style.left = x;
		}else{
			crossobj.style.left = (document.body.offsetWidth/2) - (crossobj.offsetWidth/2);
		}
		
		if( y < 0 ){
			crossobj.style.top = document.body.scrollTop + 10;
		}else if( y ){
			crossobj.style.top = document.body.scrollTop + y;
		}else{
			crossobj.style.top = document.body.scrollTop + ((document.body.clientHeight/2) - (crossobj.offsetHeight/2));
		}
	}
}
function enlarge(which,e,title,userX,userY){
//Render image code for IE 4+ and NS6
	if (ie||ns6){
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		if ( 1 || crossobj.style.visibility=="hidden"){
			if( !title ){
				var title = '&nbsp;';
			}
			if( !userX ){
				var userX = 0;
			}
			if( !userY ){
				var userY = 0;
			}
			var cont = '';
			cont += '<table border="0" bordercolor="red" height="1" cellspacing="0" cellpadding="0">';
				cont += '<tr><td style="height:1px;">';
					cont += '<table border="0" bordercolor="red" width="100%" height="100%" cellspacing="0" cellpadding="0">';
						cont += '<tr>';
							cont += '<td id="drag" class="white12bold">&nbsp;' + unescape(title) + '</td>';
							cont += '<td class="white12bold" style="width:20px; text-align:center; cursor:pointer;" onClick=closepreview()>X</td>';
						cont += '</tr>';
					cont += '</table>';
				cont += '</td></tr>';
				cont += '<tr><td><img id="imgimg" src="' + which + '" onload="placeDiv('+userX+','+userX+')" /></td></tr>';
			cont += '</table>';
			crossobj.innerHTML = cont;

			if( userX ){
				crossobj.style.left = userX;
			}else{
				crossobj.style.left = 50;
			}
			if( userY ){
				crossobj.style.top = userY;
			}else{
				crossobj.style.top = 50;
			}
			
			crossobj.style.visibility = 'visible';
		}else
			crossobj.style.visibility="hidden"
		return false
	//Render image code for NS 4
	}else if (document.layers){
		if (document.showimage.visibility=="hide"){
			document.showimage.document.write('<a href="#" onMouseover="drag_dropns(showimage)"><img src="'+which+'" border=0></a>')
			document.showimage.document.close()
			document.showimage.left=e.x
			document.showimage.top=e.y
			document.showimage.visibility="show"
		}else
			document.showimage.visibility="hide"
		return false
	//if NOT IE 4+ or NS 4, simply display image in full browser window
	}else
		return true
}

function closepreview(){
	crossobj.style.visibility="hidden"
}



//drag drop function for NS 4////
/////////////////////////////////

var nsx,nsy,nstemp

function drag_dropns(name){
	temp=eval(name)
	temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
	temp.onmousedown=gons
	temp.onmousemove=dragns
	temp.onmouseup=stopns
}

function gons(e){
	temp.captureEvents(Event.MOUSEMOVE)
	nsx=e.x
	nsy=e.y
}
function dragns(e){
	temp.moveBy(e.x-nsx,e.y-nsy)
	return false
}

function stopns(){
	temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for IE 4+ and NS6////
/////////////////////////////////

function drag_drop(e){
	if (ie&&dragapproved){
		crossobj.style.left=tempx+event.clientX-offsetx
		crossobj.style.top=tempy+event.clientY-offsety
	}else if (ns6&&dragapproved){
		crossobj.style.left=tempx+e.clientX-offsetx
		crossobj.style.top=tempy+e.clientY-offsety
	}
	return false
}

function initializedrag(e){
	if (ie&&event.srcElement.id=="drag"||ns6&&e.target.id=="drag"){
		offsetx=ie? event.clientX : e.clientX
		offsety=ie? event.clientY : e.clientY
		tempx=parseInt(crossobj.style.left)
		tempy=parseInt(crossobj.style.top)
		dragapproved=true
		document.onmousemove=drag_drop
	}
}

document.onmousedown = initializedrag
document.onmouseup = new Function("dragapproved=false")
