
/*--------------------------------------------------
 college-courses.js

 Date: 4/23/2008
 Purpose: JavaScript functionality for course search
/--------------------------------------------------*/



var _clearFormSessionURL = "/energyapi/college-courses/clear-form-session.asp";



/*******************************************************************
 clearSelectBox( elem )

 Date: 4/13/2007
 Purpose: Clear a select box's selected values
********************************************************************/	

function clearSelectBox( elementID ) {
	var e;
	if( e = $(elementID) ) {
		e.selectedIndex = 0;
		//for( i = 0; i < e.options.length; i++ ) {
			//alert(e.options[i].selected);
		//	e.options[i].selected = false;
		//}
	}
}



/*******************************************************************
 resetSearchForm()

 Date: 6/14/2007
 Purpose: Reset the form
********************************************************************/	

function resetSearchForm( event ) {

	if( event != null ) {
		// Stop event propagation
		Event.stop( event );
	}

	// Clear select box selections
	var selectBoxes = [ 
		"ProgramLevelID", 
		"StateID", 
		"CountryID",
		"InstitutionID"
	];
	try {
			selectBoxes.each( function(e){ clearSelectBox(e); } );
	} catch(ex) {}
		
	// Clear the session
	clearFormSession();
}



/*******************************************************************
 clearFormSession()

 Date: 6/14/2007
 Purpose: Clear form session via Ajax.Request
********************************************************************/

function clearFormSession() {
	// Set post parameters
	var pars = {};
	// Set Ajax.Request options
	var options = {
		method: "post", 
		generateUniqueUrl: true, 
		parameters: pars
	};
	// Run the request
	var myAjax = new Ajax.Request( _clearFormSessionURL, options );
}





