function setFocus() {
  if ((navigator.userAgent.toLowerCase().indexOf("msie") < 0) || (parseInt(navigator.appVersion) >= 4)) {
    focus();
  }
}
function requireFrames(Url) {
	if (top.frames.length < 1) {
		top.location = Url;
	}
}
function breakFrames() {
  if (top.location != self.location) {
	  top.location = self.location
	}
}
function status() {
	open('../stat.html','NewWindow', 'status=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes');
}
function fccApps(License) {
	open('http://wireless2.fcc.gov/UlsApp/ApplicationSearch/applMain.jsp?applID=' + License,'NewWindow', 'status=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes');
}
function fccCall(CallSign) {
	open('http://gullfoss2.fcc.gov/cgi-bin/ws.exe/genmen/uls/call_res.hts?db_id=19&rows=&callsign=' + CallSign,'NewWindow', 'status=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes');
}
function fccLics(License) {
	open('http://wireless2.fcc.gov/UlsApp/UlsSearch/license.jsp?licKey=' + License,'NewWindow', 'status=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes');
}
function validateForm(myform) {
<!-- Check for required fields when Enter pressed or Submit clicked -->

<!-- Name Field is required -->
  if (email.mailFromName.value=="") {
    alert("Please provide your name for this message.");
    myform.mailFromName.focus();
    return false;
  }

<!-- Email Field is required -->
  if (email.mailFrom.value=="") {
    alert("Please provide your Email for this message.");
    myform.mailFrom.focus();
    return false;
  }

<!-- Subject Field is required -->
  if (email.mailSubject.value=="") {
    alert("Please provide a subject for this message.");
    myform.mailSubject.focus();
    return false;
  }

<!-- Subject Field is required -->
  if (email.mailBody.value=="") {
    alert("Please provide the text of your message.");
    myform.mailBody.focus();
    return false;
  }

  return true;
}

function GotoPage(APageNo) {
  if (APageNo > 1) {
    location.href = GPageURL.replace(/{%PAGENO%}/,APageNo);
  } else {
    location.href = GPageURL.replace(/{%PAGENO%}/,"");
  }
}

function NextPage() {
  if (GPageNo < GPageCount)
    {GotoPage(GPageNo + 1);}
  else
    {window.alert("This is the last page.")}
}

function PrevPage() {
  if (GPageNo > 1)
    {GotoPage(GPageNo - 1);}
  else
    {window.alert("This is the first page.")}
}

function SelectPage() {
  var i = document.forms[0].elements["TextCurrentPage"].value;
  while ((i.length > 0) && (i.charAt(0) == '0')) {
    i = i.substring(1);
  }
  if ((i > 0) && (i <= GPageCount)) {
    GotoPage(i);
  }
  else {
    window.alert(i + ' is an Invalid Page Number Request');
  }
}

function setStyle(theCell, newClass){
  cells = theCell.parentNode.cells;
  for(i=0;i<cells.length;i++){
    if(newClass){
      cells[i].orgClass = cells[i].className;
      cells[i].className = newClass;
    } else {
      cells[i].className = cells[i].orgClass;
    }
  }
}
function navClick(url) {
	location.href = url;
}

function stopRKey(evt) {
  var evt  = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text")) { return false; }
}
function resetTarget()
{
  aspnetForm.target='_self';
} 

// Make sure the main column is as high as the sidebar or nav columns
// in order to fix the css issues with them not having equal heights.
function adjustMainHeight()
{
  var mainDiv;
  var navHeight;
  var mainHeight;
  var sideBarHeight;
  navHeight = document.getElementById("nav").offsetHeight;
  mainDiv = document.getElementById("main");
  mainHeight = mainDiv.offsetHeight;
  sideBarHeight = document.getElementById("sidebar").offsetHeight;
  
  if (mainHeight < navHeight) {
    mainDiv.style.height = navHeight + "px";
  }
  if (mainHeight < sideBarHeight) {
    mainDiv.style.height = (sideBarHeight - 20) + "px";
  }
}

// Makes the page always show the copyright at the bottom of the page.
function setPageHeight()
{
  var mainDiv;
  var clientHeight = 0;
  // Window dimensions: 
  if (window.innerHeight) {
    clientHeight=window.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
    clientHeight=document.documentElement.clientHeight;
  }
  else if (document.body) {
    clientHeight=document.body.clientHeight;
  }

  mainDiv = document.getElementById("main");
  mainHeight = mainDiv.offsetHeight;
  
  if (mainHeight < clientHeight) {
    mainDiv.style.height = (clientHeight - 140) + "px";
  }
}
