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("Please provide your first name.");
    myform.FirstName.focus();
    return false;
  }

<!-- LastName Field is required -->
  if (myform.LastName.value=="") {
    alert("Please provide your last name.");
    myform.LastName.focus();
    return false;
  }

<!-- Address1 Field is required -->
  if (myform.Address1.value=="") {
    alert("Please provide your street address.");
    myform.Address1.focus();
    return false;
  }

<!-- City Field is required -->
  if (myform.City.value=="") {
    alert("Please provide your city.");
    myform.City.focus();
    return false;
  }

<!-- State Field is required -->
  if (myform.State.value=="") {
    alert("Please provide your state.");
    myform.State.focus();
    return false;
  }

<!-- Zip Code Field is required -->
  if (myform.ZipCode.value=="") {
    alert("Please provide your zip code.");
    myform.ZipCode.focus();
    return false;
  }

<!-- Email Field is required -->
  if (myform.Email.value=="") {
    alert("Please provide your email address.");
    myform.Email.focus();
    return false;
  }

  return true;
}

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';
}

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 getX(element)
{
  var x = 0;
  for (var e = element; e; e = e.offsetParent) {
    x += e.offsetLeft;
  }
  for (e = element.parentNode; e && e != document.body; e = e.parentNode) {
    if (e.scrollLeft) {
      x -= e.scrollLeft;                // subtract scrollbar values
    }
  }
  return x;
}

function getY(element)
{
  var y = 0;
  for (var e = element; e; e = e.offsetParent) {
    y += e.offsetTop;
  }
  for (e = element.parentNode; e && e != document.body; e = e.parentNode) {
    if (e.scrollTop) {
      x -= e.scrollTop;                // subtract scrollbar values
    }
  }
  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("sidebar");
    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 = "<center>";
  s1 += "<hr>";
  s1 += "<table cellpadding=\"10\"><tr><td>";
  s1 += "<div id=\"sidebarAboveTraining\" style=\"color: black; text-align: center; font-size: 14px; font-weight: bold\">Never been trained<br />and don't believe you<br />need any?<br /><br />Click here:</div>";
  s1 += "<br />";
  s1 += "<button id='move' style='width: 150' onmouseover='moveButton(this, event)'>Don't Need Training</button>";
  s1 += "</td></tr></table>";
  s1 += "</center>";
  s1 += "<hr>";

  document.write(s1);
  Highlight("sidebar");
}
function writeMenu()
{
  var s1;
  s1 = "<ul>";
  s1 += "<li><a href=\"/index.html\">Home</a></li>";
  s1 += "<li><a href=\"/past.html\">Past Huddles</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 writeSideBar()
{
  var s1;
  s1 = "<div style=\"text-align: center\">";
  s1 += "<b>Huddle provides the ongoing training you need and is a great resource that will help you to be successful in running your varsity program.</b>";
  s1 += "</div>";
  document.write(s1);
}  // writeSideBar

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);
}


