// JavaScript Document

//Open Picture Window
var newWindow;
function makeNewWindow(img,wid,ht,msg){
	if (newWindow){newWindow.close()};
	var winWid = parseInt(wid) + 40;
	var heightPad = 100 + (Math.floor((msg.length*10)/wid))*30;
	var winHt = parseInt(ht) + heightPad;
	
	if(screen.availHeight < winHt + 100){
	winHt = screen.availHeight - 70}
	var features = "\"status,scrollbars,height=" + winHt + ",width=" + winWid + "\"";
	if(!newWindow || newWindow.closed){
	newWindow = window.open("", "", features)
	if (!newWindow.opener) {
	newWindow.opener = window
	}
	checkWindowSize();
	var moveWidth = (myWidth - wid)/2;
	var moveHeight = (myHeight - ht)/2;	
	if(newWindow.moveTo(moveWidth,moveHeight)){
	
	}	

var winContent = "<html><head><title>Pop-Up Window</title></head>";
	winContent += "<body bgcolor='#ffffcc'><div align='center'><img border = '0' src='" + img + "' width='" + wid + "' height='" + ht + "'></div>";
	if (msg){
	winContent += "<p align='center' style='color: #cc0033; font-family: sans-serif; font-size: 12pt'>" + msg + "</p>";
	}
	winContent += "<p><form action='' name='but'><div align='center'><input type='button' value='Close this Window' name='btnCancel' onclick='window.close();'></form></div></p></body></html>";
	newWindow.document.write(winContent);
	newWindow.document.close();
	} else {
	newWindow.focus()
	}
}

//Make new text window
var newTextWindow;
var oldUrl;
function makeNewTextWindow(url,hgt,wid){
	if (newTextWindow && oldUrl != url){newTextWindow.close()};
	oldUrl = url;
	checkWindowSize();
	var moveWidth = (myWidth - wid)/2;
	var moveHeight = (myHeight - hgt)/2;	
	
	//if (hgt > screen.availHeight){
	//hgt = screen.availHeight - 50}
	//if (wid > screen.availWidth){
	//wid = screen.availWidth - 50}
	var parameters = "status,height=" + hgt + ",width=" + wid + ",scrollbars";
	if(!newTextWindow || newTextWindow.closed){
	newTextWindow = window.open(url,"",parameters)
	if (!newTextWindow.opener) {
	newTextWindow.opener = window
	}
	} else {
	newTextWindow.focus()
	}
		if(newTextWindow.moveTo(moveWidth,moveHeight)){
	
	}	
}
//end new window stuff

var myWidth = 0, myHeight = 0;  // These will be current window's dimensions

//  This funcion gets the width and height of the current window. This information is then used so that the new window will not cover the current one.

function checkWindowSize() {
  //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 );
}

// End function to get size of current window
