/**
 * Creator: Kevin Hastie
 * Date: Feb 13, 2007
 * Time: 6:31:09 PM
 * Contents are property of Cappex.com LLC, and strictly confidential.
 **/

/**
 * Associated with: retrieveHSFromZip.jsp
 **/

/********************************/
/***** DECLARE GLOBAL VARS ******/
/********************************/

var g_oldHsID;

/********************************/
/******* DECLARE CLASSES ********/
/********************************/

/********************************/
/******** EVENT HANDLERS ********/
/********************************/

window.addEvent("domready", function() {
	g_oldHsID = $("hsID").value.toString();
	checkShowInviteGCLink();
	$('hsID').addEvent('change', checkShowInviteGCLink);
});

/********************************/
/********** FUNCTIONS ***********/
/********************************/

/**
 * Does an ajax call to retrieve a SELECT dropdown populated with high schools matching the zip code
 * @param hsZip - the zip code to search on 
 **/
function retrieveGCs(hsID) {

	g_oldHsID = hsID;
	new AjaxCpx('/ajax/retrieveGCsFromHS.jsp', {
		data:'hsID=' + hsID,
		update: 'hsGuidanceCounselorTarget',
		onSuccess : function () {
			formHighlighting(); // redo formhighlighting events
			checkShowInviteGCLink();
			// NOTE: this only refers to profileRetriever_ without a moduleID
			if (typeof profileRetriever_ != 'undefined') {
				global.trace('retrieveGCs.onSuccess: updating invisibleUnderCssDropdown');
				profileRetriever_.invisibleUnderCssDropdown = $$('.invisibleUnderCssDropdown');
			}
		}
	}).request();

}

function checkShowInviteGCLink() {

	if (typeof $('pageId') != 'undefined' && $('pageId').value == 'studentAcademic') { // only show invite GC link on studentAcademic

		// show invite GC if...
		if ($('hsID').value == 1 || 									// 'My high school is not listed'
			($('hsID').value == -1 && $('hsID').options[0].title != 'First enter a ZIP code') || // 'No high schools match that zipcode'
			$('hsGuidanceCounselor').value == 3 ||						// 'My counselor is not listed'
			$('hsGuidanceCounselor').value == 2) {						// 'No counselors from this school are listed'
			$('inviteGCLink').removeClass('jsHide');
			new Animator().pulseElem($('inviteGCLink'));
		} else {
			$('inviteGCLink').addClass('jsHide');
		}
	}
}