//Global variables
strNavImagesPath = "images/nav/index.html";
//Global calls all other functions used on page load
//The 2 arguments are used specifically on the search results page only
function global(intNumberOfResults, strSearchTerm)
{
  positionFooter();
}
//Positions footer to be bottom of page if HTML is smaller in height than window
function positionFooter()
{
  var intWinHeight, intPageHeight = document.body.scrollHeight;
  if(typeof(window.innerWidth) == 'number' ) 
  {
    //Non-IE
    intWinHeight = window.innerHeight;
  } 
  else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
  {
    //IE 6+
    intWinHeight = document.documentElement.clientHeight;
  } 
  else if(document.body && (document.body.clientWidth || document.body.clientHeight)) 
  {
    //IE 4 compatible
    intWinHeight = document.body.clientHeight;
  }
  if(intWinHeight > intPageHeight)
  {
    document.getElementById("footer").style.position = "absolute"; 
  }
  else
  {
    document.getElementById("footer").style.position = "relative"; 
  }
}
function testFunction()
{
  alert("Do validation");
}
//Preloads images set in an array on each page, function is called onload
function preloadImages()
{
  var arrImages=new Array();
  for (i=0;i<preloadImages.arguments.length;i++)
  {
    arrImages[i]=new Image();
    arrImages[i].src=preloadImages.arguments[i];
  }
}
//Switches images on onmouseover and onmouseout using global variable strNavImagesPath
//Requirements: rollover image must be named the original image's name + "over"
function switchImage(strState, objImage)
{
  strNewImageSrc = strNavImagesPath;
  strImageName = objImage.name;
  if(strState == "over")
  {
    strNewImageSrc +=  strImageName + "over.gif";
  }
  else if(strState == "out")
  {
    strNewImageSrc +=  strImageName + ".gif";
  }
  objImage.src = strNewImageSrc;
}
//Clears the input of an input field if it is the same as the alt value
function clearInput(objInput)
{
  strOriginalValue = objInput.alt;
  strCurrentValue = objInput.value; 
  if (strOriginalValue == strCurrentValue)
  {
	  objInput.value = "";
  }
}
//Controls sub navigation display
//Requirements: Sub menu div must be named the parent menu item's name + "div"
function subNavControl(objParentMenu)
{
  strParentMenuName = objParentMenu.name;
  strSubMenuDivName = strParentMenuName + "div";
  strSubMenuDivStatus = document.getElementById(strSubMenuDivName).style.visibility;
  if (strSubMenuDivStatus == "visible")
  {
    document.getElementById(strSubMenuDivName).style.visibility = "hidden";
    document.getElementById(strSubMenuDivName).style.display = "none";
  }
  else
  {
    document.getElementById(strSubMenuDivName).style.visibility = "visible";
    document.getElementById(strSubMenuDivName).style.display = "block";
  }
}
//Show/hide div using the argument of the div name
function controlDiv(strDivName)
{
  strDivNameStatus = document.getElementById(strDivName).style.visibility;
  if (strDivNameStatus == "visible")
  {
    document.getElementById(strDivName).style.visibility = "hidden";
    document.getElementById(strDivName).style.display = "none";
  }
  else
  {
    document.getElementById(strDivName).style.visibility = "visible";
    document.getElementById(strDivName).style.display = "block";
  }
}
//PupUp Function
function popUp(strURL) 
{ 
  var intPopupWidth = 458;
  var intPopupHeight = 467;
  var intScreenCenterWide = ((screen.width) / 2) - (intPopupWidth);
  var intScreenCenterLong = ((screen.height) / 2) - (intPopupHeight / 2);
  window.open(strURL,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+intPopupWidth+',height='+intPopupHeight+',left='+intScreenCenterWide+',top='+intScreenCenterLong+'').focus();
}
//Parent Refresh
function popupHandle(strNewURL)
{
  opener.location = strNewURL;
  self.close(); 
  return false;
}
