function fn_CheckForm (form) {
        var missing = false;
        form.template.value = "";
	for (var i = 9; i < form.elements.length-2; i++) {
                var field = form.elements[i];
		field.style.backgroundColor="white"
		if (field.getAttribute("isRequired") == "1" && field.value == "") {
			missing = true;
			field.style.backgroundColor = "tomato";
		}
		form.template.value += field.name + ": " + field.value + "\n\n";
	}
        if (missing) {
            alert ("Some information is still missing. \nPlease fill out the whole form.")
            return false;
        }
}

_insertEmailAddress = function () {
var which = document.getElementsByName("Email");
for (var i = 0; i < which.length; i++) {
   which[i].innerHTML = "contact us at info@harvsair.com";
   which[i].setAttribute("href", "mailto:info@harvsair.com");
}
}

_STARTUP = function () {
   _insertEmailAddress()
   MTAdminControls_Init();
   document.body.style.height = "1px";
   document.body.style.height = "auto";
}


function openBooking () {
   if (document.attachEvent) window.open("online-booking.html", "booking","width=800,height=600,resizable,resize");
}

MTAdminControls_Init = function (skipCheck) {
   if (!skipCheck && document.cookie && document.cookie.indexOf("MTAdminControl_Cookie") >= 0) {
      return MTAdminControls_Callback(document.cookie.split(";")[0].split("=")[1])
   }
   
   var script = document.createElement("script");
   script.src= "/mt/4/mt-admincontrols.cgi?"+new Date();
   document.getElementsByTagName("head")[0].appendChild(script);
}

MTAdminControls_Callback = function (user) {
   var elm = document.all ? document.all["MTAdminControls"] : document.getElementById("MTAdminControls");
   var span = document.all ? document.all["MTAdminControls-User"] : document.getElementById("MTAdminControls-User");
   if (!elm) return //alert ("MTLoggedIn html element could not be found");
   elm.style.display = "block";
   //span.innerHTML = user;
   document.cookie = "MTAdminControl_Cookie="+user+"; path=/;"
}

MTAdminControls_Reject = function (cookie) {}

if (window.addEventListener) 
  window.addEventListener("load", _STARTUP, false);
else if (window.attachEvent) 
  window.attachEvent("onload", _STARTUP);
else 
  window.onload = _STARTUP;

var FLASH_STR = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="48" height="45" id="ortodocs" align="left">\
<param name="allowScriptAccess" value="sameDomain" />\
<param name="movie" value="http://harvsair.com/site/_static/font.swf" />\
<param name="quality" value="high" />\
<param name="salign" value="lt" />\
<param name="scale" value="noscale" />\
<param name="bgcolor" value="#000000" />\
<param name="FlashVars" value="isCalendar=true&dayToShow=DATETOSHOW&monthToShow=MONTHTOSHOW" />\
<embed src="http://harvsair.com/site/_static/font.swf" FlashVars="isCalendar=true&dayToShow=DATETOSHOW&monthToShow=MONTHTOSHOW" quality="high" bgcolor="#000000" width="48" height="45" name="bar" align="middle" scale="noscale" allowScriptAccess="sameDomain" salign="lt" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
</object>'

var FLASH_HEADER_STR = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="25" id="ortodocs" align="top">\
<param name="allowScriptAccess" value="sameDomain" />\
<param name="movie" value="http://harvsair.com/site/_static/font.swf" />\
<param name="quality" value="high" />\
<param name="salign" value="lt" />\
<param name="scale" value="noscale" />\
<param name="menu" value="false" />\
<param name="bgcolor" value=" #16224a" />\
<param name="FlashVars" value="textToShow=TEXTTOSHOW&textAlignTo=TEXTALIGNTO&textSizeTo=TEXTSIZETO" />\
<embed src="http://harvsair.com/site/_static/font.swf" FlashVars="textToShow=TEXTTOSHOW&textAlignTo=TEXTALIGNTO&textSizeTo=TEXTSIZETO" quality="high" bgcolor=" #16224a" width="100%" height="25" wmode="transparent" name="bar" align="middle" scale="noscale" allowScriptAccess="sameDomain" salign="lt" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

function ReplaceHeaders () {
   //if (navigator.userAgent.toLowerCase().indexOf("mac") < 0) 
   setTimeout("ReplaceHeaders2()", 1);
}

var Log = new Array();

function ReplaceHeaders2 () {
	
	var divs_ar = document.getElementsByTagName("div");
	for (var i = 0; i < divs_ar.length; i++) {
		var div = divs_ar[i];
		if (div.className != "FlashCalendar" || div.flashed) continue;
		var split = div.innerHTML.split(" ")
		div.innerHTML = "<span style='color: black; font: bold 14px georgia;'>" + split[0] + "</span><br /><span style='color: white; font: bold 22px arial, tahoma;'>" + split[1] + "</span>";
        	div.style.textAlign = "center";
		div.style.backgroundColor = "#8cabeb"
		div.flashed = true;		
	}
	
	var h1_ar = document.getElementsByTagName("h1");
	for (var i = 0; i < h1_ar.length; i++) {
		var H1 = h1_ar[i]
		if (H1.className != "FlashHeader" || H1.flashed) continue;
		
		var text = H1.innerHTML.toUpperCase();
		text = text.replace(/'/g, "’");
		if (document.body.className == "PageCategory") 
		  text = text.replace ("OTHER", "");
		var width = H1.offsetWidth-6;
		
		str = FLASH_HEADER_STR.replace(/TEXTTOSHOW/g, text).replace(/TEXTALIGNTO/g, "center").replace(/TEXTSIZETO/g, width);
		H1.innerHTML = str;
		Log.push(str);
		H1.flashed = true;
	}   
}

ToggleActiveMenu = function (currCat) {
   var loc = location.href;
   var which = "Main";
   if (loc.indexOf("/school") > 0) which = "School";
   else if (loc.indexOf("/information") > 0) which = "Information";
   else if (loc.indexOf("/services") > 0) which = "Services";
   else if (loc.indexOf("/bookings") > 0) which = "Bookings";

   var elm = document.all ? document.all[which+"Link"] : document.getElementById(which+"Link");
   elm.className = elm.className + " MenuActive";
   
   var subCat = document.all ? document.all[currCat] : document.getElementById(currCat);
   
   if (subCat) subCat.className = "Current" 

}
