var longRef = "document.forms.form";


function displayOrHideFormSection(formSection)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		hideFormSection(formSection);
	}
	else
	{
		displayFormSection(formSection);
	}
}

	
function displayOrHideFormRow(formRow)
{
	var curDate = new Date();
	var currentTimestamp = curDate.getTime();
	if ( (currentTimestamp - lastTimestamp) > 400)
	{
		if ((document.getElementById(formRow).style.display == 'table-row')||(document.getElementById(formRow).style.display == ''))
		{
			hideFormRow(formRow);
		}
		else
		{
			displayFormRow(formRow);
		}
		lastTimestamp = currentTimestamp;
	}
}


function changeRow(nameRow, bioRow)
{
	if (document.getElementById(nameRow).style.display == 'block')
	{
		hideFormRow(nameRow);
		displayFormRow(bioRow);
	}
	if (document.getElementById(nameRow).style.display == 'none')
	{
		hideFormRow(bioRow);
		displayFormRow(nameRow);
	}
}


function displayFormSection(formSection)
{
	document.getElementById(formSection).style.display = 'block';
}


function displayFormRow(formRow)
{   
    // set to default for browser.
    // Mozilla will interpret this as 'table-row'
    // IE will interpret this as block 
    // (IE does not support 'table-row' as a display value)
	document.getElementById(formRow).style.display = '';
	document.getElementById(formRow).style.border = '0px solid red';
}


function hideFormSection(formSection)
{
	document.getElementById(formSection).style.display = 'none';
}
	
	
function hideFormRow(formRow)
{
	document.getElementById(formRow).style.display = 'none';
}


function displayOrHideBorderRow(formCell)
{
	if (document.getElementById(formCell).style.borderBottomWidth == '0px')
	{
		displayBorderRow(formCell);
	}
	else
	{
		hideBorderRow(formCell);
	}
}


function displayBorderRow(formCell)
{
	document.getElementById(formCell).style.borderBottomWidth='1px';
	document.getElementById(formCell).style.borderBottomStyle='dotted';
	document.getElementById(formCell).style.borderBottomColor='#D6D6D6';
}


function hideBorderRow(formCell)
{
	document.getElementById(formCell).style.borderBottomWidth='0px';
}


var searchStr = 'Search This Site';


function cleanSASearch() 
{
	document.search.query.onfocus = function() {if (this.value == searchStr) this.value = ''};
	document.search.query.onblur = function() {if (this.value == '') this.value = searchStr};
}


var searchStr = 'Search This Site';
	
addEvent(window, "load", cleanSearch, false);
addEvent(window, "load", function() {enableDropdown('utilities')}, false);
addEvent(window, "load", function() {enableDropdown('nav')}, false);
addEvent(window, "load", function() {enableDropdown('chooseProgram')}, false);


function changeRsvpBtn(formSection, img_id)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		
	    document.getElementById(img_id).src = '/mph/images/btn.rsvp.active.gif';
	}
	else
	{
	    document.getElementById(img_id).src = '/mph/images/btn.rsvp.inactive.gif';
	}
}


// this function works but the initial conditional doesn't get recognized - so only the else part gets run
function changeColor(formSection)
{
	if (document.getElementById(formSection).style.backgroundColor == '#ededed')
	{
		document.getElementById(formSection).style.backgroundColor = '#faf6d7';
		alert ('wtf');
	}
	else
	{
		document.getElementById(formSection).style.backgroundColor = '#faf6d7';
		alert (document.getElementById(formSection).style.backgroundColor);
	}
}

// this guy doesn't work 
function changeColor2(formSection, zz)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		document.getElementById(zz).style.backgroundColor = '#faf6d7';
		alert ('yo this should be yellow!');
	}
	else
	{
		document.getElementById(zz).style.backgroundColor = '#ededed';
		alert ('gray gray gray');
	}
}



function displayAllCourses()
{

	var courses = document.getElementById("course").getElementsByTagName("div");

	for (var i=0; i < courses.length; i++){

		if (courses[i].style.display == 'none')
		{		
	    	courses[i].style.display = 'block';
		document.getElementById("allCourses").innerHTML ="<a href=\"javascript:displayNoCourses()\" style=\"font-size: 10px; color: gray;\">Hide All</a>"
		
		}

		
	}
}

function displayNoCourses()
{

	var courses = document.getElementById("course").getElementsByTagName("div");

	for (var i=0; i < courses.length; i++){

		if (courses[i].style.display == 'block')
		{		
	    	courses[i].style.display = 'none';
			document.getElementById("allCourses").innerHTML ="<a href=\"javascript:displayAllCourses()\" style=\"font-size: 10px; color: gray;\">Show All</a>"
		
		}		

	}
}




function selecturl(choice)
{
	var newurl = choice.options[choice.selectedIndex].value;
	
	if ((newurl !=null) && (newurl !="")){

		window.top.location.href = newurl;
	}
}
