
//Make new text window

var newTextWindow;
function makeNewTextWindow(url,wid,hgt,noResize){
	var right = 100;
	var down = 50;
	if (noResize){
	} else {
	checkWindowSize();
	if (screen.availHeight){
	hgt = screen.availHeight * .7;
	wid = screen.availWidth * .85;
	}
	right = screen.availWidth * .075;
	down = screen.availHeight * .05;
	
	if (myWidth < wid){wid = myWidth * .8}
	if (myHeight < hgt){hgt = myHeight * .8}
	}
	var parameters = "status,menubar,location,resizable,titlebar,toolbar,height=" + hgt + ",width=" + wid + ",left=" + right + ",top=" + down + ",scrollbars";
	if(!newTextWindow || newTextWindow.closed){
	newTextWindow = window.open(url,"",parameters)
	if (!newTextWindow.opener) {
	newTextWindow.opener = window;
	}
	} else {
	newTextWindow.location = url;
	newTextWindow.focus()
	}
}

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

//end new window stuff

//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
	}
	if(1){
	newWindow.moveTo(100,0);}
	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()
	}
}