//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved = false;
var minrestore = 0;
var initialwidth;
var initialheight;
var ie5 = ( document.all && document.getElementById );
var ns6 = ( document.getElementById && !document.all );

var floatwrap = document.getElementById( "floatwrap" );
var floatcontent = document.getElementById("floatcontent");

function iecompattest() {
	return ( !window.opera && document.compatMode && document.compatMode != 'BackCompat' )? document.documentElement : document.body;
}

function drag_drop( e ){
	if ( ie5 && dragapproved && event.button == 1 ) {
		floatwrap.style.left = ( tempx + event.clientX - offsetx ) + "px";
		floatwrap.style.top = ( tempy + event.clientY - offsety ) + "px";
	}
	else if (ns6&&dragapproved){
		floatwrap.style.left = ( tempx + e.clientX - offsetx ) + "px";
		floatwrap.style.top = ( tempy + e.clientY - offsety ) + "px";
	}
}

function initializedrag( e ){
	offsetx = ie5 ? event.clientX : e.clientX;
	offsety = ie5 ? event.clientY : e.clientY;
	tempx = parseInt( floatwrap.style.left, 10 );
	tempy = parseInt( floatwrap.style.top, 10 );
	
	dragapproved = true;
	floatwrap.onmousemove = drag_drop;
}

function loadwindow( url, width, height ) {
	if ( !ie5 && !ns6) {
		window.open( url, '', "width=width,height=height,scrollbars=1");
	}
	else{
		floatwrap.style.display = 'block';
		floatwrap.style.width = initialwidth = width + "px";
		floatwrap.style.height = initialheight = height + "px";
		floatwrap.style.left = "30px";
		floatwrap.style.top = ns6 ? ( window.pageYOffset + 30 ) + "px" : ( iecompattest().scrollTop  + 30 ) + "px";
		floatcontent.style.width = width + 'px';
		floatcontent.style.height = height + 'px';
		floatcontent.style.overflow = 'auto';
		floatcontent.innerHTML = '<img src="' + url + '" />';
	}
}

function loadwindow2( url, width, height ) {
	width = width > 780 ? 780 : width;
	height = height + 22 > 450 ? 450 : height + 22;
	
	if ( !ie5 && !ns6) {
		window.open( url, '', "width=width,height=height,scrollbars=1");
	}
	else{
		floatwrap.style.display = 'block';
		floatwrap.style.width = initialwidth = width + "px";
		floatwrap.style.height = initialheight = height + "px";
		floatwrap.style.left = "30px";
		floatwrap.style.top = ns6 ? ( window.pageYOffset + 30 ) + "px" : ( iecompattest().scrollTop  + 30 ) + "px";
		floatcontent.style.width = width + 'px';
		floatcontent.style.height = height + 'px';
		floatcontent.style.overflow = 'auto';
		floatcontent.innerHTML = '<img src="' + url + '" />';
	}
}

function maximize(){
	if ( !minrestore ){
		minrestore = 1; //maximize window
		document.getElementById("maxname").setAttribute( "src", "http://runescape.salmoneus.net/images/d_restore.gif" );
		document.getElementById("maxname").setAttribute( "alt", "Restore" );
		floatwrap.style.width = ns6 ? ( window.innerWidth - 20 ) + "px" : iecompattest().clientWidth + "px";
		floatwrap.style.height = ns6 ? ( window.innerHeight - 20 ) + "px" : iecompattest().clientHeight + "px";
		floatcontent.style.width = floatwrap.style.width;
		floatcontent.style.height = parseInt( floatwrap.style.height, 10 ) - 20 + 'px';
	}
	else{
		minrestore = 0; //restore window
		document.getElementById("maxname").setAttribute( "src", "http://runescape.salmoneus.net/images/d_max.gif" );
		document.getElementById("maxname").setAttribute( "alt", "Maximize" );
		floatwrap.style.width = initialwidth;
		floatwrap.style.height = initialheight;
		floatcontent.style.width = floatwrap.style.width;
		floatcontent.style.height = floatwrap.style.height;
	}
	floatwrap.style.left = ns6 ? window.pageXOffset + "px" : iecompattest().scrollLeft + "px";
	floatwrap.style.top = ns6 ? window.pageYOffset + "px" : iecompattest().scrollTop + "px";
}

function closeit(){
	floatwrap.style.display = "none";
}

function stopdrag(){
	dragapproved = false;
	floatwrap.onmousemove = null;
}