function init() {
  if (!document.getElementById) return
  var imgTempOn = new Array();
  var imgTempOff = new Array();
  var imgarr = document.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc') && imgarr[i].getAttribute('ssrc')) {
        imgTempOn[i] = new Image();
        imgTempOn[i].src = imgarr[i].getAttribute('hsrc');
        imgTempOff[i] = new Image();
        imgTempOff[i].src = imgarr[i].getAttribute('src');
        imgarr[i].onmouseover = function() {
            this.setAttribute('src',this.getAttribute('hsrc'));
        }
        imgarr[i].onmouseout = function() {
            this.setAttribute('src',this.getAttribute('ssrc'));
            //this.setAttribute('hsrc',imgOriginHSrc);
        }
    }
  }
}
onload=init;

// today's date
function display_todays_date()
{

var today = new Date();
var numerical_day=today.getDay();
var numerical_month=today.getMonth();
var date=today.getDate();
var year=today.getFullYear();

var weekday_array = new Array('SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY');
var day_of_the_week = weekday_array[numerical_day];

var month_array = new Array('JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY','AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER');
var month_name = month_array[numerical_month];

var date_string= day_of_the_week + ' . ' + month_name+' '+date+', '+year;
document.write(date_string);

}

function ValidateLogin(emailId, passwordId, outputId)
{	
	var msgBox;
	msgBox = document.getElementById(outputId);

	var emailElement;	
	emailElement = document.getElementById(emailId);	

	if(emailElement != null && ( emailElement.value == null || emailElement.value == '') )
	{
		msgBox.innerHTML = '<B>Email cannot be left blank</B>';
		return false;
	}
	
	var passwordElement;
	passwordElement = document.getElementById(passwordId);
	
	if(passwordElement != null && (passwordElement.value == null || passwordElement.value == '') )
	{
		msgBox.innerHTML = '<B>Password cannot be left blank</B>';
		return false;
	}
	
	// validation successful	
	return true;
}

/*
function ValidateRegistration(nameId, passwordId, reEnterPasswordId, emailId, zipCodeId, birthDateId, genderId, statusId, outputId)
{	
	var msgBox;
	msgBox = document.getElementById(outputId);
	
	var nameElement;
	nameElement = document.getElementById(nameId);
	
	if(nameElement != null && (nameElement.value == null || nameElement.value == '') )
	{
		msgBox.innerHTML = '<B>Display name is a required field</B>';
		return false;
	}
	
	var passwordElement;
	passwordElement = document.getElementById(passwordId);
	
	if(passwordElement != null && (passwordElement.value == null || passwordElement.value == ''))
	{
		msgBox.innerHTML = '<B>Password is a required field</B>';
		return false;
	}
	
	var reEnterPasswordElement;
	reEnterPasswordElement = document.getElementById(reEnterPasswordId);
	
	if(reEnterPasswordElement != null && (reEnterPasswordElement.value == null || reEnterPasswordElement.value == ''))
	{
		msgBox.innerHTML = '<B>You are required to re-enter your password</B>';
		return false;
	}
	
	if(passwordElement.value != reEnterPasswordElement.value)
	{
		msgBox.innerHTML = '<B>Passwords do not match</B>';
		return false;
	}
	
	var emailElement;
	emailElement = document.getElementById(emailId);
	
	if(emailElement != null && (emailElement.value == null || emailElement.value == '') )
	{
		msgBox.innerHTML = '<B>Email is a required field</B>';
		return false;
	}
	
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    if(!regex.test(emailElement.value))
    {
		msgBox.innerHTML = '<B>Invalid email address</B>';
		return false;		
    }
    
    var zipCodeElement;
    zipCodeElement = document.getElementById(zipCodeId);
    
    if(zipCodeElement != null && (zipCodeElement.value == null || zipCodeElement.value == '') )
    {
		msgBox.innerHTML = '<B>Zip Code must be specified</B>';
		return false;				
    }
	
	var birthDateElement;
	birthDateElement = document.getElementById(birthDateId);
	
	if(birthDateElement != null && (birthDateElement.value == null || birthDateElement.value == ''))
	{
		msgBox.innerHTML = '<B>Birthdate is a required field</B>';
		return false;
	}
	
	if(isNaN(Date.parse(birthDateElement.value)))
	{
		msgBox.innerHTML = '<B>Invalid Birth Date</B>';
		return false;
	}
	
	var genderElement;
	genderElement = document.getElementById(genderId);
		
	if(genderElement != null && ( genderElement.selectedIndex <= 0 ))
	{
		msgBox.innerHTML = '<B>Please select your gender</B>';
		return false;
	}
	
	var statusElement;
	statusElement = document.getElementById(statusId);
	
	if(statusElement != null && (statusElement.selectedIndex <= 0))
	{
		msgBox.innerHTML = '<B>Please select marital status</B>';
		return false;
	}
		
	return true;	
}
*/
function ValidateRegistration(nameId, passwordId, reEnterPasswordId, emailId, zipCodeId, outputId)
{	
	var msgBox;
	msgBox = document.getElementById(outputId);
	
	var nameElement;
	nameElement = document.getElementById(nameId);
	
	if(nameElement != null && (nameElement.value == null || nameElement.value == '') )
	{
		msgBox.innerHTML = '<B>Display name is a required field</B>';
		return false;
	}
	
	var passwordElement;
	passwordElement = document.getElementById(passwordId);
	
	if(passwordElement != null && (passwordElement.value == null || passwordElement.value == ''))
	{
		msgBox.innerHTML = '<B>Password is a required field</B>';
		return false;
	}
	
	var reEnterPasswordElement;
	reEnterPasswordElement = document.getElementById(reEnterPasswordId);
	
	if(reEnterPasswordElement != null && (reEnterPasswordElement.value == null || reEnterPasswordElement.value == ''))
	{
		msgBox.innerHTML = '<B>You are required to re-enter your password</B>';
		return false;
	}
	
	if(passwordElement.value != reEnterPasswordElement.value)
	{
		msgBox.innerHTML = '<B>Passwords do not match</B>';
		return false;
	}
	
	var emailElement;
	emailElement = document.getElementById(emailId);
	
	if(emailElement != null && (emailElement.value == null || emailElement.value == '') )
	{
		msgBox.innerHTML = '<B>Email is a required field</B>';
		return false;
	}
	
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    if(!regex.test(emailElement.value))
    {
		msgBox.innerHTML = '<B>Invalid email address</B>';
		return false;		
    }
    
    var zipCodeElement;
    zipCodeElement = document.getElementById(zipCodeId);
    
    if(zipCodeElement != null && (zipCodeElement.value == null || zipCodeElement.value == '') )
    {
		msgBox.innerHTML = '<B>Zip Code must be specified</B>';
		return false;				
    }
			
	return true;	
}

function ValidateEmail(nameId, fromId, recipientId, messageId, outputId)
{
	var msgBox;
	msgBox = document.getElementById(outputId);
	
	var nameElement;
	nameElement = document.getElementById(nameId);
	
		if(nameElement != null && (nameElement.value == null || nameElement.value == ''))
	{
		msgBox.innerHTML = '<B>Name cannot be left blank</B>';
		return false;
	}
	
	var fromElement;
	fromElement = document.getElementById(fromId);;
	
	if(fromElement != null && (fromElement.value == null || fromElement.value == '') )
	{
		msgBox.innerHTML = '<B>Sender email cannot be left blank</B>';
		return false;
	}
	
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    
    if(!regex.test(fromElement.value))
    {
		msgBox.innerHTML = '<B>Sender email is not in a valid format</B>';
		return false;
    }
    
    var recipientElement;
    recipientElement = document.getElementById(recipientId);
    
    if(recipientElement != null && (recipientElement.value == null || recipientElement.value == ''))
    {
		msgBox.innerHTML = '<B>Recipient(s) must be specified</B>';
		return false;
    }
    
    var isMultipleRecipients;
    isMultipleRecipients = ( recipientElement.value.indexOf(',') >= 0 );
    
    if(!isMultipleRecipients)
    {
		if(!regex.test(recipientElement.value))
		{
			msgBox.innerHTML = '<B>Recipient email is not in valid format</B>';
			return false;
		}
    }
    else
    {	
		var recipients;
		recipients = recipientElement.value.split(';');
		
		for(var ctr = 0; ctr < recipients.length; ctr++ )
		{
			if(!regex.test(leftTrim(recipients[ctr])))
			{
				msgBox.innerHTML = '<B>One of the recipients\' email is not in valid format</B>';
				return false;
			}
		}		
    }    

	msgBox.innerHTML = '';
	
	return true;
}

function leftTrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	return sString;
}

function SelectUnSelectAllSection(allSectionId, otherSections)
{
	var allSectionElement;
	allSectionElement = document.getElementById(allSectionId);
	
	if(allSectionElement != null)
	{
		if(allSectionElement.checked)
		{
			for(var ctr=0; ctr< otherSections.length; ctr++)
			{
				document.getElementById(otherSections[ctr]).checked = true;
			}
		}
		else
		{
			for(var ctr=0; ctr< otherSections.length; ctr++)
			{
				document.getElementById(otherSections[ctr]).checked = false;
			}
		}
	}
}

function ValidateSearch(textId, outputId)
{
	var msgBox;
	msgBox = document.getElementById(outputId);
	
	var textElement;
	textElement = document.getElementById(textId);
	
	if(textElement != null && (textElement.value == null || textElement.value == ''))
	{
		msgBox.innerHTML = '<B>Search text not specified</B>';
		return false;
	}
	
	return true;
}

function ValidateForgetPassword(emailId, outputId)
{
	var msgBox;
	msgBox = document.getElementById(outputId);
	
	var emailElement;
	emailElement = document.getElementById(emailId);
	
	if(emailElement != null && (emailElement.value == null || emailElement.value == ''))
	{
		msgBox.innerHTML = '<B>Email cannot be left blank</B>';
		return false;
	}
	
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    
    if(!regex.test(emailElement.value))
    {
		msgBox.innerHTML = '<B>Email is not in a valid format</B>';
		return false;
    }
	
	return true;
}

function ViewComment()
{	
	/*
	var control = document.getElementById('ViewComment');
		
	if( control != null )
	{		
		control.click();
	}
	*/
}
function StartSearch(e)
{	
	/*
	var key = window.event ? e.keyCode : e.which;
	if(key == 13)
	{
		if(btnSearchId != null)
		{
			var btnSearchElement;
			btnSearchElement = document.getElementById(btnSearchId);
			
			btnSearchElement.focus();
			btnSearchElement.click();
			
			return false;
		}
	}
	*/
}
		
function SlideShow(url,features) {
location.href = url;
//  window.open(url,'SlideShowWindow',features);
}


function footnote(url) {
  window.open(url,'FootNote','width:200px;height:300px')
}


/* ---------------------------------------------------- SUB/SECTION NAV */

var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var currLayer;	// holds id of currently visible layer
function swapLayers(id) {
  if (currLayer) hideLayer(currLayer);
  showLayer(id);
  currLayer = id;
}

function showLayer(id) {
  var objLayer = getElemRefs(id);
  if (objLayer && objLayer.css) objLayer.css.visibility = "visible";
}

function hideLayer(id) {
  var objLayer = getElemRefs(id);
  if (objLayer && objLayer.css) objLayer.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}