/* for navigating from a dropdown box */
function goToPage(theOptionValue){
   location = theOptionValue.options[theOptionValue.selectedIndex].value;
   }

// Clears the search text field when it is given the focus (if user has not entered anything)
var searchText;

function clearSearchText(formfield, text) {
	searchText = text;
	if (formfield.value == searchText) formfield.value = '';
}

// Refills the search text field on blur if it is empty
function fillSearchText(formfield) {
	if (formfield.value == '') formfield.value = searchText;
}

function init() {
   document.body.style.height = document.documentElement.scrollHeight+'px';
}

function isDefined(property) {
  return (typeof property != 'undefined');
}

// call init when document finishes loading
if (isDefined(window.addEventListener)) {
   window.addEventListener('load', init, false);
}
else if (isDefined(window.attachEvent)) {
   window.attachEvent('onload', init);
}

// get width of browser
function getInnerWidth(win) {
  var winWidth;
  if (navigator.userAgent.indexOf('Gecko') != -1 && navigator.userAgent.indexOf('Netscape6') == -1) {
    winWidth = win.document.body.clientWidth;
  }
  else if (document.compatMode == "CSS1Compat") {
    winWidth = win.document.documentElement.clientWidth;
  }
  else if (navigator.appName == 'Netscape') {
    winWidth = win.innerWidth;
  }
  else {
    winWidth = win.document.body.clientWidth;
  }
  return winWidth;
}

// write out style for main container
function positionMainContainer() {
   var winWidth = getInnerWidth(window);
   var left = parseInt((winWidth > 760) ? (winWidth - 760) / 2 : 0);
   
   doc = '<style>#mainContainer { ';
   doc += 'left: ' + left + 'px; ';
   doc += '}';
   document.write(doc + '</style>');
}

function repositionMainContainer() {
   if (document.getElementById) {
      var container = document.getElementById('mainContainer');
      var winWidth = getInnerWidth(window);
      
      if (document.getElementById('mainContainer'))
      {
      container.style.left = ((winWidth > 760) ? (winWidth - 760) / 2 : 0) + 'px';
	  }	
   }
}

onresize = repositionMainContainer;
