/*****************************************************
**
**  Description: Misc. helper functions
**  Date: 2005/12/31
**  Author: raceves
**
**  Copyright: Nord Country School, All rights reserved
**
*****************************************************/
if ( typeof(startUrl) == 'undefined' ) startUrl = "./";

function ClassRoomMenuOn(nextTD)
{
    var menuTable = document.getElementById('navTable2');
    menuTable.style.display = "";

    if ( document.all )
    {
        menuTable.style.top = "309px";
        menuTable.style.left = "187px";
    }
    else
    {
        menuTable.style.top = "296px";
        menuTable.style.left = "167px";
    }
}

function OpenClass(classRoom)
{
   var menuTable = document.getElementById('navTable2');
   menuTable.style.display = "none";

   var nw = parseInt((screen.width * .90));
   var nh = parseInt((screen.height * .90));
   var x = parseInt(((screen.width-nw)/2));
   var y = parseInt(((screen.height-nh)/3));
   var s = 'resizable=1,toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,dependent=0,width='+nw+',height='+nh+',alwaysRaised=1,left='+x+',screenX='+x+',top='+y+',screenY='+y;
   window.open(startUrl + "classes/" + classRoom + "/index.html","classes",s).focus();
}

function OpenFull(urlopen)
{
   var nw = parseInt((screen.width * .80));
   var nh = parseInt((screen.height * .80));
   var x = parseInt(((screen.width-nw)/2));
   var y = parseInt(((screen.height-nh)/3));
   var s = 'resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,dependent=0,width='+nw+',height='+nh+',alwaysRaised=1,left='+x+',screenX='+x+',top='+y+',screenY='+y;
   window.open(urlopen,null,s).focus();
}

function HighLightRow(rowNum)
{
    var e = document.getElementById('navTable');
    if ( e )
        e.rows[rowNum].cells[0].className = "overlink-down";
}

function RollOverOn(e)
{
    if ( e.id == "rlink" )
    {
        if ( e.className != "overlink-down" )
            e.className = "overlink";

        var menuTable = document.getElementById('navTable2');
        menuTable.style.display = "none";

        var expandMenu = document.getElementById('expand');
        expandMenu.className = "";
    }
    else if ( e.id == "expand-child" )
    {
         e.className = "overlinkexpandon";
    }
    else
    {
        e.className = "overlinkexpand";
    }
}

function RollOverOut(e)
{
    if ( e.className != "overlink-down"  )
        e.className = "";
}

function RollOverDown(e)
{
    var r = document.getElementById('navTable');

    for ( var i = 0; i < r.rows.length; i ++ )
        r.rows[i].cells[0].className = "";

    e.className = "overlink-down";
}

function WriteDate()
{
    var date = new Date();
    var d = date.getDate();
    var day = (d < 10) ? '0' + d : d;
    var m = date.getMonth() + 1;
    var month = (m < 10) ? '0' + m : m;
    var yy = date.getYear();
    var year = (yy < 1000) ? yy + 1900 : yy;

    return (month + "/" + day + "/" + year);
}

function WriteMenu()
{
    document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">'+
                   '<tr>'+
                   '<td class="overlap-head" valign="top"><a href='+startUrl+'"index.html" title="Home" target="_top"><img src="'+startUrl+'images/top_nav_full.gif" alt="" border="0" align="bottom"></a></td>'+
                   '<td class="overlap-head" valign="top" width="20%">&nbsp;</td>'+
                   '<td class="overlap-head" valign="top"><img src="'+startUrl+'images/title4.gif" alt="" border="0" align="top"></td>'+
                   '<td class="overlap-head" valign="top" width="20%"><div style="margin-top:85px;font-weigth:bold;font-size:11px;color:black;">Website Updated: 08/05/2010<br/>Current Date: '+WriteDate()+'</div></td>'+
                   '</tr>'+
                   '<tr>'+
                   '<td id="navTableMenu" width="148" height="100%" valign="top">');

    document.write('<table id="navTable" width="148" style="border: 1px solid black;" cellpadding="3" cellspacing="0">'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'index.html\'"><a title="Home" href="'+startUrl+'index.html">Home</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'offer.html\'"><a title="What We Offer" href="'+startUrl+'offer.html">What We Offer</a></td>'+
                   '</tr>'+
                  '<tr>'+
                    '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'contact.html\'"><a title="Contact Information" href="'+startUrl+'contact.html">Contact Information</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'2010_2011_events.html\'"><a title="Event Calendar" href="'+startUrl+'2010_2011_events.html">Event Calendar</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'daily_sched.html\'"><a title="Daily Schedule" href="'+startUrl+'daily_sched.html">Daily Schedule</a></td>'+
                   '</tr>'+
                   '<tr>'+
                    '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'pto.html\'"><a title="P.T.O." href="'+startUrl+'pto.html">P.T.O.</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'ed_links.php\'"><a title="Educational Links" href="'+startUrl+'ed_links.php">Educational Links</a></td>'+
                   '</tr>'+
                   '<tr>'+
                      '<td id="expand" onmouseover="RollOverOn(this);ClassRoomMenuOn(this);" onclick="ClassRoomMenuOn(this); return false;"><a title="Classrooms" href="#" onclick="ClassRoomMenuOn(this); return false;">Classrooms</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'staff.html\'"><a title="Faculty &amp; Staff" href="'+startUrl+'staff.html">Faculty & Staff</a></td>'+
                   '</tr>'+
                  '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'history.html\'"><a title="Our History" href="'+startUrl+'history.html">Our History</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'bod.html\'"><a title="School Board" href="'+startUrl+'bod.html">School Board</a></td>'+
                   '</tr>'+
                    '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'school_docs.html\'"><a title="School Documents" href="'+startUrl+'school_docs.html">School Documents</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'faq.html\'"><a title="Frequently Asked Questions" href="'+startUrl+'faq.html">F.A.Q</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'donations.html\'"><a title="Donations" href="'+startUrl+'donations.html">Donations</a></td>'+
                   '</tr>'+
                   '<tr>'+
                     '<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'gallery.html\'"><a title="Image Gallery" href="'+startUrl+'gallery.html">Image Gallery</a></td>'+
                   '</tr>'+
                   //'<tr>'+
                     //'<td id="rlink" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onmousedown="RollOverDown(this);" onclick="javascript:location.href=\''+startUrl+'student_cal.html\'"><a title="Student Calendar" href="'+startUrl+'student_cal.html">Student Calendar</a></td>'+
                   //'</tr>'+
                   '</table>');

        document.write('<table id="navTable2" width="148" style="display: none; z-index: 1099; position: absolute; border: 1px solid black;" cellpadding="3" cellspacing="0">'+
                       '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm3\');"><a title="Kindergarten" href="#" onclick="OpenClass(\'rm3\');">Kindergarten</a></td>'+
                       '</tr>'+
                       '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm4\');"><a title="First Grade" href="#" onclick="OpenClass(\'rm4\');">First Grade</a></td>'+
                       '</tr>'+
                       '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm2\');"><a title="Second Grade" href="#" onclick="OpenClass(\'rm2\');">Second Grade</a></td>'+
                       '</tr>'+
                       '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm8\');"><a title="Third Grade" href="#" onclick="OpenClass(\'rm8\');">Third Grade</a></td>'+
                       '</tr>'+
                       '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm7\');"><a title="Fourth Grade" href="#" onclick="OpenClass(\'rm7\');">Fourth Grade</a></td>'+
                       '</tr>'+
					   '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm10\');"><a title="Fifth Grade" href="#" onclick="OpenClass(\'rm10\');">Fifth Grade</a></td>'+
                       '</tr>'+
                       '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm6\');"><a title="Sixth Grade" href="#" onclick="OpenClass(\'rm6\');">Sixth Grade</a></td>'+
                       '</tr>'+
					   '<tr>'+
                         '<td id="expand-child" onmouseover="RollOverOn(this);" onmouseout="RollOverOut(this);" onclick="OpenClass(\'rm9\');"><a title="Resource/ELD" href="#" onclick="OpenClass(\'rm9\');">Resource/ELD</a></td>'+
                       '</tr>'+			   
                   '</table>');

    document.write('</td>'+
                   '<td valign="top" colspan="3" style="padding:0px;margin:0px;">');
}

function BeginContent()
{
    document.write('<div id="content" style="height:100%;width:100%;overflow:auto;margin:0px;">');
    document.write('<img src="'+startUrl+'images/cell-nav-bg2.gif" style="display:none;"/>');
    document.write('<img src="'+startUrl+'images/cell-nav-bg-over2.gif" style="display:none;"/>');
}

function EndContent()
{
    document.write('</div></td></tr><tr><td>'+
                   '<a title="Sign up today!" href="http://www.escrip.com/program/3ways/index.jsp" target="_blank"><img src="'+startUrl+'images/3ways_siderbar.gif" width="155" alt="eScrip" border="0"></a><br>'+
                   //'<img src="'+startUrl+'images/nav_spacer.gif" alt="" border="0"><br>'+
                   '<img src="'+startUrl+'images/bottom-line.gif" width="158" alt="" border="0">'+
                   '</td><td colspan="3" valign="bottom" class="copyright">'+
                   //'<div align="right" style="padding:0px;padding-right:4px;margin:0px;"><IMG SRC="http://visit.webhosting.yahoo.com/counter.gif" ALT="Counter"></div>'+
                   '<div id="navsite"><ul>'+
                   '<li>[<a title="Home" href="'+startUrl+'index.html">Home</a>] | </li>'+
                   '<li>[<a title="What We Offer" href="'+startUrl+'offer.html">What We Offer</a>] | </li>'+
                   '<li>[<a title="Contact Information" href="'+startUrl+'contact.html">Contact Information</a>] | </li>'+
                   '<li>[<a title="Event Calendar" href="'+startUrl+'2009_2010_events.html">Event Calendar</a>] | </li>'+
                   '<li>[<a title="Daily Schedule" href="'+startUrl+'daily_sched.html">Daily Schedule</a>]</li>'+
                   '</ul><ul style="padding-top:1px;">'+
                   //'<li>[<a title="Nighthawk News Letter" href="'+startUrl+'news_letter.html">Nighthawk News Letter</a>] | </li>'+
                   '<li>[<a title="P.T.O." href="'+startUrl+'pto.html">P.T.O.</a>] | </li>'+
                   '<li>[<a title="Educational Links" href="'+startUrl+'ed_links.php">Educational Links</a>] | </li>'+
                   '<li>[<a title="Faculty &amp; Staff" href="'+startUrl+'staff.html">Faculty & Staff</a>] | </li>'+
                   '<li>[<a title="Our History" href="'+startUrl+'history.html">Our History</a>]</li>'+
                   '</ul><ul style="padding-top:1px;">'+
                   '<li>[<a title="School Board" href="'+startUrl+'bod.html">School Board</a>] | </li>'+
                   '<li>[<a title="School Documents" href="'+startUrl+'school_docs.html">School Documents</a>] | </li>'+
                   '<li>[<a title="Frequently Asked Questions" href="'+startUrl+'faq.html">F.A.Q</a>] | </li>'+
                   '<li>[<a title="Donations" href="'+startUrl+'donations.html">Donations</a>] | </li>'+
                   '<li>[<a title="Donations" href="'+startUrl+'gallery.html">Image Gallery</a>]</li>'+
                   //'<li>[<a title="Student Calendar" href="'+startUrl+'student_cal.html">Student Calendar</a>]</li>'+
                   '</ul></div><br/>'+
                   '© Copyright 2005-2009 Nord Country School. All rights reserved.'+
                   '</td></tr></table><br>');
}

function TrimBothSides(str) { return(str.replace(/^\s+/g,'').replace(/\s+$/g,'')); }

function CheckEmpty(s)
{
    var ws = " \t\n\r";

    if ( (s == null) || (s.length == 0))
        return true;

    for (var i = 0; i < s.length; i ++) {
        var c = s.charAt(i);
            if ( ws.indexOf(c) == -1)
            return false;
    }

    return true;
}
