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 validateForm(myform) {
<!-- Check for required fields when Enter pressed or Submit clicked -->

<!-- FirstName Field is required -->
  if (myform.firstName.value=="") {
    alert("The first name is required.");
    myform.firstName.focus();
    return false;
  }

<!-- LastName Field is required -->
  if (myform.lastName.value=="") {
    alert("The last name is required.");
    myform.lastName.focus();
    return false;
  }

<!-- Address1 Field is required -->
  if (myform.address1.value=="") {
    alert("The street address is required.");
    myform.address1.focus();
    return false;
  }

<!-- City Field is required -->
  if (myform.city.value=="") {
    alert("The city is required.");
    myform.city.focus();
    return false;
  }

<!-- State Field is required -->
  if (myform.state.value=="") {
    alert("The state is required.");
    myform.state.focus();
    return false;
  }

<!-- Zip Code Field is required -->
  if (myform.zipCode.value=="") {
    alert("The zip code is required.");
    myform.zipCode.focus();
    return false;
  }

<!-- Email Field is required -->
  if (myform.email.value=="") {
    alert("The email address is required.");
    myform.email.focus();
    return false;
  }

  return true;
}

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 writeMenu(level)
{
  var s1;
  s1 = "<ul>";
  s1 += "<li><a href=\"/index.html\">Home</a></li>";
  s1 += "<li><a href=\"/leaderspecific.html\">Leader Specific</a></li>";
  s1 += "<li><a href=\"/cgi-bin/register.pl\">Registration</a></li>";
  s1 += "<li><a href=\"/dutchoven/index.html\">Dutch Oven Recipies</a></li>";
  s1 += "<li><a href=\"http://www.mesavarsity.org/calendar/index.html\">calendar</a></li>";
  s1 += "<li><a href=\"http://huddle.mesavarsity.org\">Huddle</a></li>";
  s1 += "<li><a href=\"http://training.mesavarsity.org\">Training</a></li>";
  s1 += "<li><a href=\"http://ontarget.mesavarsity.org\">On-Target</a></li>";
  s1 += "<li><a href=\"http://rendezvous.mesavarsity.org\">Rendezvous</a></li>";
  s1 += "</ul>";
  document.write(s1);
}

function writeNavBar()
{
  var s1;
  s1 = "<ul>";
  s1 += "<li><a href=\"/contact.html\">contact us</a></li>";
  s1 += "<li><a href=\"http://www.mesavarsity.org\">Mesa Varsity Home</a></li>";
  s1 += "</ul>";

  document.write(s1);
}

function Highlight(id)
{
  var div = document.getElementById(id);
  //div.style.fontWeight = "bold";
  div.style.color = "black";
  var colors = ["white", "black", "white", "black", "white", "black"];
  var nextColor = 0;
  var intervalId = setInterval(animate, 500);

  function animate() {
    div.style.color = colors[nextColor++%colors.length];
    if (nextColor == colors.length) {
      clearInterval(intervalId);
    }
  }
  return false;
}

function writeSideBar()
{
  var s1;
  s1 = "<div id=\"everyboy\">Every Boy Deserves a Trained Leader!!!</div>";
  s1 += "<b>Indoor Training:</b><br />September 11, 2010<br /><br>";
  s1 += "<b>Outdoor Training:</b><br />September 24-25, 2010<br /><br />";
  s1 += "Register for it now!<br />";
  s1 += "Click <a href=\"/cgi-bin/register.pl\">here</a>.";

  document.write(s1);
  Highlight("everyboy");
}

function getX(element)
{
  var x = element.offsetLeft;
  return x;
}

function getY(element)
{
  var y = element.offsetTop;
  return y;
}

var movePass = 0;

function moveButton(object, event)
{
  var e = event || window.event; // Get event details for IE
  var left = getX(object);
  if (movePass > 2) {
    movePass = 0;
    object.style.position = "static";
    alert("Have you figured it out yet?  You are not going to have much success clicking on the \"Don't Need Training\" button.  And clearly you will be a lot more effective with much less effort if you are properly trained!!!");
    Highlight("everyboy");
    return;
  }
  else {
    var top = getY(object);
    top += ((movePass == 0) || (movePass == 2))? -30 : 30;
    object.style.position = "absolute";
    object.style.top = top + "px";
    object.style.left = left + "px";
  }
  movePass++;
}

function writeAboveTraining()
{
  var s1;
  s1 = "<hr>";
  s1 += "<div id=\"aboveTraining\">Never been trained and don't believe you need any?";
  s1 += "<br /><br />Click here:<br />";
  s1 += "<button id='move' style='width: 150' onmouseover='moveButton(this, event)'>Don't Need Training</button>";
  s1 += "</div>";
  s1 += "<hr>";

  document.write(s1);
  Highlight("everyboy");
}

function writeFooter()
{
  var s1;
  var CurrentYear = new Date();
  CurrentYear = CurrentYear.getFullYear();
  s1 = "<div id=\"copyright\">";
  s1 += "For information about this website contact:&nbsp;";
  s1 += "<a href=\"mailto:mikeheaton@cox.net\">webmaster@mesavarsity.org</a><br />";
  s1 += "&copy;&nbsp;COPYRIGHT 2008-" + CurrentYear.toString() + " by Mesa District Varsity B.S.A. - All Rights Reserved.<br />";
  s1 += "All other trademarks are property of their respective holders.<br />";
  s1 += "Not an official site of the Boy Scouts of America";
  s1 += "</div>";
  document.write(s1);
}
function doSubmit(object)
{
  object.form.submit();
}
function confirmDelete()
{
 return confirm("Confirm Delete?")
}  // conform

