function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function findLivePageHeight() {
	if (window.innerHeight) {
		return window.innerHeight;
		}
	if (document.body.clientHeight) {
		return document.body.clientHeight;
		}
	return (null);
}

function findLivePageWidth() {
	if (window.innerWidth)
		return window.innerWidth;
	if (document.body.clientWidth)
		return document.body.clientWidth;
	return (null);
}
function findRight(objectID) {
	var object = document.getElementById(objectID);
	 if (object.offsetLeft) {
		return (object.offsetLeft + object.offsetWidth);
	}
	return (null);
}

function findBottom(objectID) {
	var object = document.getElementById(objectID);
	if (object.offsetTop) {
		return (object.offsetTop + object.offsetHeight);	
	}
	return (null);
}
function setRight() {
	livePageWidth = findLivePageWidth();
	if (livePageWidth > 0) {
		var object = document.getElementById('rightside');
		var mainRight = findRight('main');
		var topRight = findRight('decbar');
		object.style.left=mainRight + 12;
		object.style.width=(topRight - mainRight -12);
		var  mainBottom = findBottom('main');
		if (document.getElementById('botnav') != null){
			var object = document.getElementById('botnav');
			object.style.top=mainBottom + 10;
		}
		if ( readCookie("menu1") == "block") {
			toggleClamShellMenu('menu1');
		}
		if ( readCookie("menu2") == "block") {
			toggleClamShellMenu('menu2');
		}	
		if ( readCookie("menu3") == "block") {
			toggleClamShellMenu('menu3');
		}			
	}	
}

function toggleClamShellMenu(objectID) {
	var object = document.getElementById(objectID);
	if (object.style.display =='block') {
		object.style.display='none';
		var menstate = 'none';
	} else {
		object.style.display='block';
		var menstate = 'block';
	}	
	writeCookie(objectID,menstate,30);
	return;
}

function readCookie(namevar)
{  
  var cookieValue = "";
  var search = namevar + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}


function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}



function openRemote(contentURL,windowName,x,y) {
	widthHeight = 'height=' + y + ',width=' + x;
	if (remote) remote.focus();
	else var remote = window.open(contentURL,windowName,widthHeight);
}

function closeRemote() {
	if (remote)  {	
	 remote.close();
	 remote = null;
	}
}
function openRemoteOO(contentURL,windowName,x,y) {
	widthHeight = 'height=' + y + ',width=' + x;
	if (remoteOO) remoteOO.focus();
	else var remoteOO = window.open(contentURL,windowName,widthHeight);
}

function closeRemoteOO() {
	if (remoteOO)  {	
	 remoteOO.close();
	 remoteOO = null;
	}
}
function sfocus(TextBox) 
{ 
	var object = document.getElementById(TextBox);
	if (object && document.getElementById(TextBox).type != 'hidden') {
		document.getElementById(TextBox).focus();
		if (document.getElementById(TextBox).type != 'select-one' && document.getElementById(TextBox).type != 'select-multiple'){
			document.getElementById(TextBox).select(); 
		} 
	} 
}



