    function pageLoad(sender, e) {
        updateClock();
        setInterval('updateClock()', 1000);
	    dynamicLayout();	    	    
	    ReadFile("content", "/inc/Home.html");
        MenuHome_Click();
    }

    /* Layout BEGIN */
    function dynamicLayout() {
        var browserWidth = getBrowserWidth();
       // try{ window.resizeTo(1024,600); } catch{}        
        if (browserWidth < 800) {
            changeActiveStyleSheet("default", "lowres")
        }
    }
    function getBrowserWidth() {
        if (typeof window.innerWidth != 'undefined'){
            return window.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientWidth != 0) {
            return document.documentElement.clientWidth;
        }
        else if (document.body) { return document.body.clientWidth; }
        return 0;
    }
    function changeActiveStyleSheet(previous, new1) {
        if(document.styleSheets){
             for (var StyleSheetIterator = 0; StyleSheetIterator < document.styleSheets.length; StyleSheetIterator++) {
                 if(document.styleSheets[StyleSheetIterator].title == previous) {
                    document.styleSheets[StyleSheetIterator].disabled = true;
                 };
                 if(document.styleSheets[StyleSheetIterator].title == new1) {
                    document.styleSheets[StyleSheetIterator].disabled = false;
                 };
             };
        };
    }
    function updateClock() {
        var currentTime = new Date();

        var currentHours = currentTime.getHours();
        var currentMinutes = currentTime.getMinutes();
        var currentSeconds = currentTime.getSeconds();

        // Pad the minutes and seconds with leading zeros, if required
        currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
        currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;

        // Choose either "AM" or "PM" as appropriate
        var timeOfDay = (currentHours < 12) ? "AM" : "PM";

        // Convert the hours component to 12-hour format if needed
        currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;

        // Convert an hours component of "0" to "12"
        currentHours = (currentHours == 0) ? 12 : currentHours;

        // Compose the string for display
        var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

        // Update the time display
        document.getElementById("spnClock").firstChild.nodeValue = currentTimeString;
        //document.getElementById("spnClock").value = currentTimeString;
    }
    /* Layout END */
    
    /* Nav BEGIN */
	function MenuHome_Click(){
		SetMenuItemsGray();
		document.getElementById("spnMenuHome").style.fontWeight = "bold";
		ReadFile("content", "/inc/Home.html");
	}	
	function MenuClients_Click(){
		SetMenuItemsGray();
		document.getElementById("spnMenuClients").style.fontWeight = "bold";
		ReadFile("content", "/inc/Clients.html");
	}	
	function MenuPpl_Click(){
		SetMenuItemsGray();
		document.getElementById("spnMenuPpl").style.fontWeight = "bold";
		ReadFile("content", "/inc/people.html");
    }	
    /*
	function MenuBlog_Click(){
		SetMenuItemsGray();
		document.getElementById("spnMenuBlog").style.color = "#ffffff";
		ReadFile("content", "/inc/Blog.html");	;	
		window.open("http://otherworldsolutions.wordpress.com");
    }
    */
    function MenuRaceHorses_Click() {
        SetMenuItemsGray();
        document.getElementById("spnMenuResources").style.fontWeight = "bold";;
        ReadFile("content", "/inc/Resources.html"); ;
    }
	function MenuContact_Click(){
		SetMenuItemsGray();
		document.getElementById("spnMenuContact").style.fontWeight = "bold";
		ReadFile("content", "/inc/Contact.html");
	}
	function SetMenuItemsGray(){
		document.getElementById("spnMenuHome").style.fontWeight="normal";
		document.getElementById("spnMenuClients").style.fontWeight="normal";	
		document.getElementById("spnMenuPpl").style.fontWeight="normal";
		//document.getElementById("spnMenuBlog").style.fontWeight="normal";
		document.getElementById("spnMenuResources").style.fontWeight="normal";
		document.getElementById("spnMenuContact").style.fontWeight="normal";
    }
    function CommunityLink_Click() {
        document.location = "./community/index.html";
    }
    /* Nav END */

    function submitContactForm() {
        var mContent = "";
        var mRecipient = "sheldyck@live.ca";
        var mSender = "info@otherworld-systems.net";

        var tName = document.getElementById("txtName").value;
        var tAddress = document.getElementById("txtAddress").value;
        var tCity = document.getElementById("txtCity").value;
        var tEmail = document.getElementById("txtEmail").value;
        var tWebsite = document.getElementById("txtWebsite").value;
        var tProvstate = document.getElementById("txtProvstate").value;
        var tPostal = document.getElementById("txtPostal").value;
        var tPhone1 = document.getElementById("txtPhone1").value;
        var tPhone2 = document.getElementById("txtPhone2").value;
        var tPhone3 = document.getElementById("txtPhone3").value;
        var tPhone = tPhone1 + "-" + tPhone2 + "-" + tPhone3;
        var tComments = document.getElementById("txtComments").value;

        mContent += tName + "\n" + tAddress + "\n" + tCity + "\n" + tEmail + "\n" + tWebsite + "\n" + tProvstate + "\n" + tPostal + "\n" + tPhone + "\n\n" + tComments;
        sendMail(mSender, mRecipient, mContent);
    }


	/* ajax BEGIN */

	function ReadFile(targetDiv, strFileName) {
	    var oRequest = new XMLHttpRequest();
	    var sURL = "http://" + self.location.hostname + strFileName;

	    oRequest.open("GET", sURL, false);
	    oRequest.setRequestHeader("User-Agent", navigator.userAgent);
	    oRequest.send(null)

	    if (oRequest.status == 200) {
	        document.getElementById(targetDiv).innerHTML = oRequest.responseText;
	    }
	    else {
	        //alert("Error executing XMLHttpRequest call!");
	    }
	}

	function sendMail(mSender, mRecipient, mContent) {
   
	    var xhr = createXHR();
	    var jsonobj;
	    
	    xhr.open("POST", "http://otherworld-systems.net/wss/sendmail.aspx/send_mail", true);
	    xhr.onreadystatechange = function () {
	        if (xhr.readyState === 4) {
	                /* the returned value, xhr.responseText contains a complex JSON data string:  {"d":"you chose Storm"}
	                the builtin javascript eval function can convert it to an object */
	            jsonobj = eval('(' + xhr.responseText + ')');
	                /* now we can call for the value of the object's 'd' property */
	           document.getElementById("spnSendMailReturnValue").innerHTML = jsonobj.d;
	        }
	     };
	     xhr.setRequestHeader("content-type", "application/json");
	     var postData = '{"strSender":"'+mSender+'", "strEmailAddr": "'+mRecipient+'", "strBody": "'+mContent+'"}';
	     xhr.send(postData);
	}
	
	function createXHR() {
	    var xhr;

	    if (window.XMLHttpRequest) {
	        /* if browser is not IE or is IE >= 7 XMLHttpRequest */
	        /* will be exposed in the window namespace */
	        xhr = new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject) {
	        /* if IE < 7 create via ActiveX */
	        xhr = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    else {
	        throw new Error("Could not create XMLHttpRequest object.");
	    }
	    return xhr;
	}
	/* ajax END */
