
function showCommonMenu(index)
{
    var bHTML = '';

    bHTML += '<table width="100%" border="0" align="center" cellspacing="1" cellpadding="4">';
    
    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="home") {
        bHTML += '<a href="welcome.html" onMouseOver="roll_over(\'home\', \'images/home-hover.gif\')" onMouseOut="roll_over(\'home\', \'images/home-on.gif\')">';
        bHTML += '<img src="images/home-on.gif" border="0" name="home"></a>';
    } else {
        bHTML += '<a href="welcome.html" onMouseOver="roll_over(\'home\', \'images/home-hover.gif\')" onMouseOut="roll_over(\'home\', \'images/home-off.gif\')">';
        bHTML += '<img src="images/home-off.gif" border="0" name="home"></a>';
    }
    bHTML += '</td></tr>';
    
    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="goals") {
        bHTML += '<a href="goals.html" onMouseOver="roll_over(\'goals\', \'images/goals-hover.gif\')" onMouseOut="roll_over(\'goals\', \'images/goals-on.gif\')">';
        bHTML += '<img src="images/goals-on.gif" border="0" name="goals"></a>';
    } else {
        bHTML += '<a href="goals.html" onMouseOver="roll_over(\'goals\', \'images/goals-hover.gif\')" onMouseOut="roll_over(\'goals\', \'images/goals-off.gif\')">';
        bHTML += '<img src="images/goals-off.gif" border="0" name="goals"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="curriculum") {
        bHTML += '<a href="curriculum.html" onMouseOver="roll_over(\'curriculum\', \'images/curriculum-hover.gif\')" onMouseOut="roll_over(\'curriculum\', \'images/curriculum-on.gif\')">';
        bHTML += '<img src="images/curriculum-on.gif" border="0" name="curriculum"></a>';
    } else {
        bHTML += '<a href="curriculum.html" onMouseOver="roll_over(\'curriculum\', \'images/curriculum-hover.gif\')" onMouseOut="roll_over(\'curriculum\', \'images/curriculum-off.gif\')">';
        bHTML += '<img src="images/curriculum-off.gif" border="0" name="curriculum"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="enrollment") {
        bHTML += '<a href="enrollment.html" onMouseOver="roll_over(\'enrollment\', \'images/enrollment-hover.gif\')" onMouseOut="roll_over(\'enrollment\', \'images/enrollment-on.gif\')">';
        bHTML += '<img src="images/enrollment-on.gif" border="0" name="enrollment"></a>';
    } else {
        bHTML += '<a href="enrollment.html" onMouseOver="roll_over(\'enrollment\', \'images/enrollment-hover.gif\')" onMouseOut="roll_over(\'enrollment\', \'images/enrollment-off.gif\')">';
        bHTML += '<img src="images/enrollment-off.gif" border="0" name="enrollment"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="contactus") {
        bHTML += '<a href="contactus.html" onMouseOver="roll_over(\'contactus\', \'images/contactus-hover.gif\')" onMouseOut="roll_over(\'contactus\', \'images/contactus-on.gif\')">';
        bHTML += '<img src="images/contactus-on.gif" border="0" name="contactus"></a>';
    } else {
        bHTML += '<a href="contactus.html" onMouseOver="roll_over(\'contactus\', \'images/contactus-hover.gif\')" onMouseOut="roll_over(\'contactus\', \'images/contactus-off.gif\')">';
        bHTML += '<img src="images/contactus-off.gif" border="0" name="contactus"></a>';
    }
    bHTML += '</td></tr></table>';

    document.getElementById("menu").innerHTML = bHTML;
}

function showMenu(index)
{
    var bHTML = '';

    bHTML += '<table width="100%" border="0" align="center" cellspacing="1" cellpadding="4">';
    
    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="home") {
        bHTML += '<a href="welcome.html" onMouseOver="roll_over(\'home\', \'../images/home-hover.gif\')" onMouseOut="roll_over(\'home\', \'../images/home-on.gif\')">';
        bHTML += '<img src="../images/home-on.gif" border="0" name="home"></a>';
    } else {
        bHTML += '<a href="welcome.html" onMouseOver="roll_over(\'home\', \'../images/home-hover.gif\')" onMouseOut="roll_over(\'home\', \'../images/home-off.gif\')">';
        bHTML += '<img src="../images/home-off.gif" border="0" name="home"></a>';
    }
    bHTML += '</td></tr>';
    
    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="newsletter") {
        bHTML += '<a href="newsletter.html" onMouseOver="roll_over(\'newsletter\', \'../images/newsletter-hover.gif\')" onMouseOut="roll_over(\'newsletter\', \'../images/newsletter-on.gif\')">';
        bHTML += '<img src="../images/newsletter-on.gif" border="0" name="newsletter"></a>';
    } else {
        bHTML += '<a href="newsletter.html" onMouseOver="roll_over(\'newsletter\', \'../images/newsletter-hover.gif\')" onMouseOut="roll_over(\'newsletter\', \'../images/newsletter-off.gif\')">';
        bHTML += '<img src="../images/newsletter-off.gif" border="0" name="newsletter"></a>';
    }
    bHTML += '</td></tr>';
     
    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="goals") {
        bHTML += '<a href="goals.html" onMouseOver="roll_over(\'goals\', \'../images/goals-hover.gif\')" onMouseOut="roll_over(\'goals\', \'../images/goals-on.gif\')">';
        bHTML += '<img src="../images/goals-on.gif" border="0" name="goals"></a>';
    } else {
        bHTML += '<a href="goals.html" onMouseOver="roll_over(\'goals\', \'../images/goals-hover.gif\')" onMouseOut="roll_over(\'goals\', \'../images/goals-off.gif\')">';
        bHTML += '<img src="../images/goals-off.gif" border="0" name="goals"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="curriculum") {
        bHTML += '<a href="curriculum.html" onMouseOver="roll_over(\'curriculum\', \'../images/curriculum-hover.gif\')" onMouseOut="roll_over(\'curriculum\', \'../images/curriculum-on.gif\')">';
        bHTML += '<img src="../images/curriculum-on.gif" border="0" name="curriculum"></a>';
    } else {
        bHTML += '<a href="curriculum.html" onMouseOver="roll_over(\'curriculum\', \'../images/curriculum-hover.gif\')" onMouseOut="roll_over(\'curriculum\', \'../images/curriculum-off.gif\')">';
        bHTML += '<img src="../images/curriculum-off.gif" border="0" name="curriculum"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="enrollment") {
        bHTML += '<a href="enrollment.html" onMouseOver="roll_over(\'enrollment\', \'../images/enrollment-hover.gif\')" onMouseOut="roll_over(\'enrollment\', \'../images/enrollment-on.gif\')">';
        bHTML += '<img src="../images/enrollment-on.gif" border="0" name="enrollment"></a>';
    } else {
        bHTML += '<a href="enrollment.html" onMouseOver="roll_over(\'enrollment\', \'../images/enrollment-hover.gif\')" onMouseOut="roll_over(\'enrollment\', \'../images/enrollment-off.gif\')">';
        bHTML += '<img src="../images/enrollment-off.gif" border="0" name="enrollment"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="calendar") {
        bHTML += '<a href="calendar.html" onMouseOver="roll_over(\'calendar\', \'../images/calendar-hover.gif\')" onMouseOut="roll_over(\'calendar\', \'../images/calendar-on.gif\')">';
        bHTML += '<img src="../images/calendar-on.gif" border="0" name="calendar"></a>';
    } else {
        bHTML += '<a href="calendar.html" onMouseOver="roll_over(\'calendar\', \'../images/calendar-hover.gif\')" onMouseOut="roll_over(\'calendar\', \'../images/calendar-off.gif\')">';
        bHTML += '<img src="../images/calendar-off.gif" border="0" name="calendar"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="photos") {
        bHTML += '<a href="photos.html" onMouseOver="roll_over(\'photos\', \'../images/photos-hover.gif\')" onMouseOut="roll_over(\'photos\', \'../images/photos-on.gif\')">';
        bHTML += '<img src="../images/photos-on.gif" border="0" name="photos"></a>';
    } else {
        bHTML += '<a href="photos.html" onMouseOver="roll_over(\'photos\', \'../images/photos-hover.gif\')" onMouseOut="roll_over(\'photos\', \'../images/photos-off.gif\')">';
        bHTML += '<img src="../images/photos-off.gif" border="0" name="photos"></a>';
    }
    bHTML += '</td></tr>';

    bHTML += '<tr><td align="center" bgcolor="#FFFFFF">';
    if (index=="contactus") {
        bHTML += '<a href="contactus.html" onMouseOver="roll_over(\'contactus\', \'../images/contactus-hover.gif\')" onMouseOut="roll_over(\'contactus\', \'../images/contactus-on.gif\')">';
        bHTML += '<img src="../images/contactus-on.gif" border="0" name="contactus"></a>';
    } else {
        bHTML += '<a href="contactus.html" onMouseOver="roll_over(\'contactus\', \'../images/contactus-hover.gif\')" onMouseOut="roll_over(\'contactus\', \'../images/contactus-off.gif\')">';
        bHTML += '<img src="../images/contactus-off.gif" border="0" name="contactus"></a>';
    }
    bHTML += '</td></tr></table>';

    document.getElementById("menu").innerHTML = bHTML;
}

function roll_over(img_name, img_src)
{
   document[img_name].src = img_src;
}

//-------------------------------------------------------------------
// Trim functions
//   Returns string with whitespace trimmed
//-------------------------------------------------------------------

function LTrim(str) 
{
    if (str==null)
    {
        return str;
    }
    
    for (var i=0; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i++);
    
    return str.substring(i,str.length);
}

function RTrim(str) 
{
    if (str==null)
    {
        return str;
    }
    
    for (var i=str.length-1; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i--);
    
    return str.substring(0,i+1);
}

function Trim(str)
{
    return LTrim(RTrim(str));
}

//-------------------------------------------------------------------
// isNull(value)
//   Returns true if value is null
//-------------------------------------------------------------------
function isNull(val)
{
    return (val==null);
}

//-------------------------------------------------------------------
// isBlank(value)
//   Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val)
{
    if (val==null)
    {
        return true;
    }

    for (var i=0;i<val.length;i++) 
    {
	if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
        {
            return false;
        }
    }
    
    return true;
}

//-------------------------------------------------------------------
// isInteger(value)
//   Returns true if value contains all digits
//-------------------------------------------------------------------
function isInteger(val)
{
    if (isBlank(val))
    {
        return false;
    }
	
    for(var i=0;i<val.length;i++)
    {
	if(!isDigit(val.charAt(i)))
        {
            return false;
        }
    }

    return true;
}

//-------------------------------------------------------------------
// isNumeric(value)
//   Returns true if value contains a positive float value
//-------------------------------------------------------------------
function isNumeric(val)
{
    return(parseFloat(val,10)==(val*1));
}


//-------------------------------------------------------------------
// isDigit(value)
//   Returns true if value is a 1-character digit
//-------------------------------------------------------------------
function isDigit(num) 
{
    if (num.length>1)
    {
        return false;
    }

    var string="1234567890";

    if (string.indexOf(num)!=-1)
    {
        return true;
    }
	
    return false;
}

function compareDates (value1, value2)    
{   
    var date1, date2;   
    var month1, month2;   
    var year1, year2;   
    
    year1 = value1.substring (0, value1.indexOf("."));   
    month1 = value1.substring (value1.indexOf(".")+1, value1.lastIndexOf("."));   
    date1 = value1.substring (value1.lastIndexOf(".")+1, value1.indexOf(" "));   
    
    year2 = value2.substring (0, value2.indexOf ("."));   
    month2 = value2.substring (value2.indexOf (".")+1, value2.lastIndexOf ("."));   
    date2 = value2.substring (value2.lastIndexOf (".")+1, value2.indexOf(" "));   
    
    if (year2 > year1) return 1;   
    else if (year2 < year1) return -1;   
    else if (month2 > month1) return 1;   
    else if (month2 < month1) return -1;   
    else if (date2 > date1) return 1;   
    else if (date2 < date1) return -1;   
    else return 0;   
} 

function element_exists(element_name) {
    if (document.getElementsByName(element_name).length > 0) 
    {
        return true;
    } else {
        return false;
    }
}

function isValidEmailAddress(val)
{
	if (isNull(val)||isBlank(val))
	{
		return false;
	}
	
	pos1 = val.indexOf("@");
	pos2 = val.indexOf(".");
	pos3 = val.lastIndexOf("@");
	pos4 = val.lastIndexOf(".");
	if ((pos1 <= 0)||(pos1 == val.length)||(pos2 <= 0)||(pos2 == val.length-1)||(pos4 == val.length-1))
	{		
		return false;
	}else if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) || ( pos1 != pos3 ) || ( pos4 < pos3 ) ) 
	{
		return false;
	}
	
	for(var i=0;i<val.length;i++)
	{
		if(!isValidEmailString(val.charAt(i)))
		{
			return false;
		}
	}
	
	return true;
}

function isValidEmailString(val)
{
	if(val.length>1)
	{
		return false;
	}
	var string="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@";
	if(string.indexOf(val)!=-1)
	{
		return true;
	}
	return false;
}

function isValidTelephone(val)
{
	if(isNull(val)||isBlank(val))
	{
		return false;
	}
	for(var i=0;i<val.length;i++)
	{
		if(!isNumConn(val.charAt(i)))
		{
			return false;
		}
	}
	return true;
	
}

function isNumConn(val)
{
	if(val.length>1)
	{
		return false;
	}
	var string="0123456789-";
	if(string.indexOf(val)!=-1)
	{
		return true;
	}
	return false;
}

function isValidName(val)
{
	if(isNull(val)||isBlank(val))
	{
		return false;
	}
	for(var i=0;i<val.length;i++)
	{
		if(!isValidNameString(val.charAt(i)))
		{
			return false;
		}
	}
	return true;
	
}

function isValidNameString(val)
{
	if(val.length>1)
	{
		return false;
	}
	var string="~`!@#$%^&*()+=?<>{}[]':;\",|\\/";
	if(string.indexOf(val)==-1)
	{
		return true;
	}
	return false;
}

function isValidDate(year,month,day)
{
	if(month<1 || month>12)
	{
		alert('@@ALERT_MONTH_ISINVALID@@');
		return false;
	}
	if(day<1 || day>31)
	{
		alert('@@ALERT_DAY_ISINVALID@@');
		return false;
	}
	if ((month==2) && (day==30 || day==31))
	{
		alert('@@ALERT_DAY_BT_TWENTYNINE@@');
		return false;
	}
	if (!((year % 4)==0) && (month==2) && (day==29))
	{
		alert('@@ALERT_LEAP_YEAR_ERR@@');
		return false;
	}
	if ((month<=7) && ((month % 2)==0) && (day>=31))
	{
		alert('@@ALERT_DAY_BT_THIRTY@@');
		return false;
	}
	if ((month>=8) && ((month % 2)==1) && (day>=31))
	{
		alert('@@ALERT_DAY_BT_THIRTY@@');
		return false;
	}
	
	return true;
}

function openImage(imageName) 
{
    document.getElementById('newsFrame').src="photos/"+imageName;
} 
