//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 initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
var xpos=0;
var ypos=0;
var open;
if (!ie5) {
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = getMouseXY;

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function loadwindow(url,width,height, isOpen){

    if (document.getElementById('infoDiv') ) {
        document.getElementById('infoDiv').innerHTML='';
    }
	if (!ie5&&!ns6){
		window.open(url,"","width=width,height=height,scrollbars=1")
	}
	else{
    if(ie5) {
		mHeight = document.body.clientHeight;
    }
    else{
		mHeight = document.body.clientHeight;
    }
    document.getElementById("cframe").src=url;
    document.getElementById("dwindow").style.display='';
    //document.getElementById("dwindow").style.position = "fixed";
    //document.getElementById("dwindow").style.width=initialwidth=width+"px";

    document.getElementById("dwindow").style.left = 300;

    document.getElementById("dwindow").style.height="200px";
    document.getElementById("dwindow").style.width="500px";

    //document.getElementById("dwindow").style.top="20px"; //document.body.scrollTop + 20;
    document.getElementById("dwindow").style.top=document.body.scrollTop + 20;
	if( typeof( window.innerWidth ) == 'number' ) {
		var lPos = (window.innerWidth / 2) - 250;
        var rPos = (window.innerWidth / 2) + 250;
        document.getElementById("dwindow").style.left = lPos + "px";
        document.getElementById("dwindow").style.right = rPos + "px";
  }
}
}

	iframeMaxHeight = 500;
	iframeMinHeight = 300;
	iframeMaxWidth = 800;
	iframeMinWidth = 500;
	var actualHeight =0;
	var actualWidth =0;
function resizeWindow(iframe,divName) {
	//id
	if(document.getElementById(iframe.id).document) {
	  actualHeight = document.frames[iframe.name].document.body.scrollHeight + 21;
	  actualWidth = document.frames[iframe.name].document.body.scrollWidth + 35;
	}
	else {
      actualHeight = document.getElementById(iframe.id).contentDocument.documentElement.scrollHeight + 21;
	  //I can't get the width to work right
	  actualWidth = document.getElementById(iframe.id).contentWindow.document.body.scrollWidth+20;
	  //actualWidth = document.getElementById(iframe.id).contentDocument.documentElement.scrollWidth+20;
	  //actualWidth=570;
	}

	if (  parent.document.getElementById('scrollText') != null ) {
      parent.document.getElementById('scrollText').style.display = 'none';
      parent.document.getElementById('scrollText').style.backgroundColor = 'transparent'
	}
    //set Heights
    if(actualHeight > iframeMaxHeight) {
      iframe.height=iframeMaxHeight;
        parent.document.getElementById('scrollText').style.display = 'inline';
    }
    else {
      if(actualHeight < iframeMinHeight) {
        iframe.height=iframeMinHeight
      }
      else {
        iframe.height = actualHeight;
      }
    }

    //Set Widths
    if(actualWidth > iframeMaxWidth) {
      iframe.width=iframeMaxWidth;
    }
    else {
      if(actualWidth < iframeMinWidth) {
        iframe.width=iframeMinWidth
      }
      else {
        iframe.width = actualWidth;
      }
    }
    height = iframe.height;
    //document.getElementById(divName).style.display='';
    document.getElementById(divName).style.width=actualWidth;
    document.getElementById(divName).style.height=height;
    //document.getElementById(divName).style.left=xpos-width;
    w = document.body.scrollWidth/2 - actualWidth/2;
    if(document.body.scrollLeft > w) {
      w = document.body.scrollLeft + 20;
    }

    document.getElementById(divName).style.left=w;
    document.getElementById(divName).style.top=document.body.scrollTop + 20;
    document.getElementById(divName).style.zIndex="100"
  } 

function getMouseXY(e) {
  if (ie5) {
    if ( document.body != null ) {
    	xpos = event.clientX + document.body.scrollLeft
    	ypos = event.clientY + document.body.scrollTop
    }
  }
  else {
    xpos = e.pageX
    ypos = e.pageY
  }  
  if (xpos < 0) {
    xpos = 0
  }
  if (ypos < 0) {
    ypos = 0
  }
}

function closeit(){
parent.document.getElementById('cframe').src='/loading.htm';
parent.document.getElementById("dwindow").style.display="none"
}


