var idx
var but1
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false
var x,y
var dobj

if ( typeof( window[ 'i_exist' ] ) == "undefined" ) {
	
	var i_exist=1
	frameHeight=9999
	frameWidth=99999
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth
		frameHeight = self.innerHeight
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth
		frameHeight = document.documentElement.clientHeight
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth
		frameHeight = document.body.clientHeight
	}
	
	function iecompattest(){
		return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	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 != "dragme")
		{
			fobj = nn6 ? fobj.parentNode : fobj.parentElement
		}
		if (fobj.className=="dragme")
		{
			isdrag = true
			dobj = fobj
			tx = parseInt(dobj.style.left+0,10)
			ty = parseInt(dobj.style.top+0,10)
			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")
	
	function loadwindow(url,width,height,anch){
		if (!ie5&&!ns6)
			window.open(url,"","width=width,height=height,scrollbars=1")
		else{
//			var offsets = getScrollXY()
			scrollTo(0,getScrollXY())
//			alert(offsets.x + ':' + offsets.y)
			document.getElementById("dwindow").style.display=''
			document.getElementById("dwindow").style.width=initialwidth=width+"px"
			document.getElementById("dwindow").style.height=initialheight=height+"px"
			var leftOff = (frameWidth-width)/2;
			if (leftOff < 0 && frameWidth < width)
			    leftOff = 10;
			document.getElementById("dwindow").style.left=leftOff
			document.getElementById("dwindow").style.top=getScrollXY()+10
			document.getElementById("cframe").src=url
			var pos1 = url.indexOf('p/')
			var searchval = url.substring(pos1+2)
			but1 = searchval
			document.getElementById(but1).style.display='none'

//			location.href = document.referrer.location + "/#" + anch
		}
	}
	
	function maximize(){
		if (minrestore==0){
			minrestore=1 //maximize window
			document.getElementById("maxname").setAttribute("src","/popdiv/restore.gif")
			document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
			document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
		}
		else{
			minrestore=0 //restore window
			document.getElementById("maxname").setAttribute("src","/popdiv/max.gif")
			document.getElementById("dwindow").style.width=initialwidth
			document.getElementById("dwindow").style.height=initialheight
		}
		document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
		document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
	}
	
	function closeit(){
		document.getElementById("cframe").src=""
		document.getElementById(but1).style.display="block"
		document.getElementById("dwindow").style.display="none"
	}
	
	function stopdrag(){
		dragapproved=false;
		document.getElementById("dwindow").onmousemove=null;
		document.getElementById("dwindowcontent").style.display="" //extra
	}
	document.write('<div id=\"dwindow\" class=\"dragme\" style=\"position:absolute;background-color:#EBEBEB;cursor:hand;left:0px;top:0px;display:none\" >\n');
	document.write('<div align=\"right\" style=\"background-color:navy\"><img src=\"/popdiv/max.gif\" id=\"maxname\" onClick=\"maximize()\"><img src=\"/popdiv/close.gif\" onClick=\"closeit()\"></div>\n');
	document.write('<div id=\"dwindowcontent\" style=\"height:100%;border:3px solid #000;\">\n');
	document.write('<iframe id=\"cframe\" src=\"\" width=100% height=100% border=5></iframe>\n');
	document.write('</div></div>\n');

	function getScrollXY() {
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
		}
		return (scrOfY);
	}
}