var set = 1;

window.onload = function(e){
	resizePage();
}

function resizePage(){
	
	/*if(document.getElementById('main') && document.getElementById('submenu')){
		if((document.getElementById('main').offsetHeight + 35) > document.getElementById('submenu').offsetHeight) document.getElementById('submenu').style.height = (document.getElementById('main').offsetHeight + 35) + 'px';
		else document.getElementById('main').style.height = (document.getElementById('submenu').offsetHeight - 35) + 'px';
	}*/
	
	if(document.getElementById('main') && !document.getElementById('rightbar') && set == 1){
		document.getElementById('content').style.width = (document.getElementById('content').offsetWidth + 165) + 'px';
		set = 2;
	}
	
	var windowHeight = document.body.offsetHeight;
	var frameHeight = document.getElementById('frame').offsetHeight;
	
	document.getElementById('main').style.height = 'auto';
	if(frameHeight < windowHeight) document.getElementById('main').style.height = (document.getElementById('main').offsetHeight + (windowHeight - frameHeight - 10)) + 'px';
	
	window.onresize = resizePage;
}

function clearText(theText)
{
	theText.value = "";
}


function changeInputType
(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
  if(!oldElm || !oldElm.parentNode || (iType.length<4) || 
    !document.getElementById || !document.createElement) return;
  var newElm = document.createElement('input');
  newElm.type = iType;
  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.className) newElm.className = oldElm.className;
  if(oldElm.size) newElm.size = oldElm.size;
  if(oldElm.tabIndex) newElm.tabIndex = oldElm.tabIndex;
  if(oldElm.accessKey) newElm.accessKey = oldElm.accessKey;
  
  newElm.onfocus = function(){return function()
  {
    if(this.hasFocus) return;
    var newElm = changeInputType(this,'password',iValue,
      (this.value.toLowerCase()==iValue.toLowerCase())?true:false);
    if(newElm) newElm.hasFocus=true;
  }}();
  newElm.onblur = function(){return function(){
    if(this.hasFocus)
    if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
      changeInputType(this,'text',iValue,false,true);
    }
  }}();
 // hasFocus is to prevent a loop where onfocus is triggered over and over again
  newElm.hasFocus=false;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!blankValue) newElm.value = iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}

// go to page selected from options menu
function GoUrl(s)
{
  var d = s.options[s.selectedIndex].value
  window.top.location.href = d
  s.selectedIndex=0
}