var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all

function galenlarge(which,e){
	imag = new Image();
	imag.src = which;
	
	imgWidth = imag.width;
	imgHeight = imag.height;
	
	//window.alert("imgWidth :" + imgWidth + "\nimgHeight :" + imgHeight)
	if (imgWidth>0)
	{	
		winLeft = ((screen.width - imgWidth)/2)
	} else if (screen.width>=800)
		{
			winLeft = 250;
		} else
			{
				winLeft = 50;
			}

	if (imgHeight>0)
	{	
		winTop = ((screen.height - imgHeight)/2)
	} else if (screen.height>=600)
		{
			winTop = 100;
		} else
			{
				winTop = 10;
			}


	//winLeft = ((screen.width - imgWidth)/2);
	//winTop = ((screen.height - imgHeight)/2);
//window.alert("winLeft :" + winLeft + "\winTop :" + winTop)
//Render image code for IE 4+ and NS6
	if (ie||ns6)
	{
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		if (crossobj.style.visibility=="hidden")
		{
			//crossobj.style.left=ns6? pageXOffset+e.clientX : document.body.scrollLeft+event.clientX
			//crossobj.style.top=ns6? pageYOffset+e.clientY : document.body.scrollTop+event.clientY
			crossobj.style.left= Math.round(winLeft) ;
			crossobj.style.top=ns6? pageYOffset+winTop : document.body.scrollTop+winTop
			crossobj.innerHTML='<div align=right id=drag><img src=images/Close.gif onClick=closepreview()></div><img src="'+which+'">'
			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.left=Math.round(winLeft) ;
			document.showimage.top =Math.round(winTop) ;
			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 enlarge(which,e){
	imag = new Image();
	imag.src = which;
	
	
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
	
	
	
	imgWidth = imag.width;
	imgHeight = imag.height;

	winLeft = ((myWidth - imgWidth)/2);
	winTop = ((myHeight - imgHeight) /2);
//	window.alert(winTop)
	//Render image code for IE 4+ and NS6
	if (ie||ns6)
	{
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		if (crossobj.style.visibility=="hidden")
		{
			//crossobj.style.left=ns6? pageXOffset+e.clientX : document.body.scrollLeft+event.clientX
			//crossobj.style.top=ns6? pageYOffset+e.clientY : document.body.scrollTop+event.clientY
			crossobj.style.top=ns6? pageYOffset+Math.round(winTop)  + "px" : document.body.scrollTop+Math.round(winTop)  + "px"
			//crossobj.style.top = Math.round(winTop) ;
			crossobj.style.left= Math.round(winLeft)  + "px" ;
			crossobj.innerHTML='<div align=right id=drag><img src=../images/Close.gif onClick=closepreview()></div><img src="'+which+'">'
			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.left=Math.round(winLeft) ;
			document.showimage.top =Math.round(winTop) ;
			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"
}

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")


