// JavaScript Document

window.onload = setDiv;
window.onresize = setDiv;
window.setTimeout("fixHieght();",30);
//document.onkeypress = test;

function test() {
	alert(screen.availHeight);
}

function goTo(url) {
	window.location	= url;
}

function fixHieght() {
	var d = document.getElementById('container');
	
//	top = window.pageYOffset;

//	top = window.body.scrollTop;
//	top = document.documentElement.scrollTop;
//	top = document.body.scrollTop;
	
//	if (top > 0) setDiv();	
	setDiv();

//	console.log('value is ' + window.pageYOffset);
	window.setTimeout("fixHieght();",30);
}

function setDiv() {

	P7_initPM(1,1,1,-20,10)
	
	// Set main content area
	var wh = getWindowHeight() - 230; // Window Height
	var d = document.getElementById('container'); // Get div element
	if (d != null)
		d.style.height = wh + 'px'; // Set div height to window height
	
	// Set side navigation panel
	var wh = getWindowHeight() - 62; // Window Height
	var d = document.getElementById('nav-panel'); // Get div element
	if (d != null)
		d.style.height = wh + 'px'; // Set div height to window height
	
	// Set side navigation
	var wh = getWindowHeight() - 225; // Window Height
	var d = document.getElementById('nav-exp'); // Get div element
	if (d != null)
		d.style.height = wh + 'px'; // Set div height to window height

//	document.documentElement.scrollTop = 0;	
//	document.body.style.overflow = 'hidden';
	
//	window.scrollTo(0,0);
	window.scrollBy(0, -9999);
	window.height = "100%";	
	
}


function getWindowHeight() {
  var windowHeight = 0;
	
  if (typeof(window.innerHeight) == 'number')
    windowHeight = window.innerHeight;
	
  else {
		
    if (document.documentElement && document.documentElement.clientHeight)
      windowHeight = document.documentElement.clientHeight;
		
    else {
      if (document.body && document.body.clientHeight)
        windowHeight = document.body.clientHeight; }; };
				
  return windowHeight;
  
};

function gotoTop() {
	document.getElementById('container').scrollTop=0;
}


function rhtmlspecialchars(str) {
 if (typeof(str) == "string") {
  str = str.replace(/&gt;/ig, ">");
  str = str.replace(/&lt;/ig, "<");
  }
 return str;
 }

var newWind;
var lOpened=false;
function openwindow(cPicture,nWidth,nHeight,cMessage,nBorder){
var output;
var tMessage=rhtmlspecialchars(cMessage);
tMessage=tMessage.replace(/<BR>/igm, " ");

if (lOpened){
}
lOpened=true;
newWind=window.open("","winnam","HEIGHT="+nHeight+",WIDTH="+nWidth+",scrollbars=no,resizable=no,top=58,left=42");
output="<HTML><TITLE>" +tMessage+ "</TITLE><BODY BGCOLOR='#FFFFEC'><CENTER>"
output+="<FONT FACE='Comic Sans MS' SIZE='+1' COLOR='Maroon'>"+cMessage+"</FONT><BR>"
if (nBorder==1) {
output+="<TABLE BORDER='8'><TR><TD>"
}
output+="<IMG SRC='"+cPicture+"'>"
if (nBorder==1){
output+="</TD></TR></TABLE>"
}
output+="<FORM><TABLE BORDER='5'><TR><TD><INPUT TYPE='button' VALUE='Close' onClick='self.close()'>"
output+="</TD></TR></TABLE></FORM></CENTER></BODY></HTML>"
newWind.document.write(output);
newWind.document.close();
newWind.focus();
}


function createWindow(cUrl,cName,cFeatures) {
	var xWin = window.open(cUrl,cName,cFeatures)
}
