function changeClass(id, newClass) {
	identity = document.getElementById(id);
	identity.className = newClass;
}

function switchToRoundTrip() {
	changeClass('searchBox', 'roundTrip');
	document.getElementById('farefinder').tripType.value = 2;
}

function switchToOneWay() {
	changeClass('searchBox', 'oneWay');
	document.getElementById('farefinder').tripType.value = 1;
}

function switchToOpenJaw() {
	changeClass('searchBox', 'openJaw');
	document.getElementById('farefinder').tripType.value = 3;
}

// ***************************** AJAX ***************************** //

function xmlRequest(url, obj, func) {
if (!url) return false;

if (window.XMLHttpRequest) var http = new XMLHttpRequest();
	
else if (window.ActiveXObject)
	try { http = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e) { http = new ActiveXObject("Microsoft.XMLHTTP"); }
	
if (!http) return false;

if (func)  http.onreadystatechange = function() {
	if (http.readyState != 4) return;
	func(obj, returnXMLOrText(http) );
};
else
	http.onreadystatechange = function() { return; }

http.open('GET', url, true);
http.send(null);
if (func) {} 
else return returnXMLOrText(http);
return false;
}

function returnXMLOrText(responseObj) {
	if (responseObj.responseText.indexOf('<?xml') == 0) return responseObj.responseXML;
	else return responseObj.responseText;
}




function lookupAirport(apCode) {
	if ( apCode != null && apCode.length >= 3 ) {
		xmlRequest("/validation/validation.jsp?apCode=" + apCode, document.getElementById('resultsArea'), showResponse);
	}
	else {
		document.getElementById('resultsArea').style.display = "none";
	}
}

function showResponse(outputDiv,response) {
	outputDiv.innerHTML = response;
	if ( response != null && response != "" ) {
		outputDiv.style.display = "block";
	}
	else {
		document.getElementById('resultsArea').style.display = "none";
	}
}

// ***************************** propop stuff ***************************** //

defaultEmailText = 'Enter your email';
defaultCodeText = ' City name or code'; // default descriptive text to replace in blank airport code boxes

// ***************************** javascript.jsp stuff ***************************** //

defaultCodeText = ' City name or code'; // default descriptive text to replace in blank airport code boxes
enterButtonEnabled = true; 
document.onkeypress = searchOrLogin;
document.onmousemove = captureMousePosition;

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

// ***************************** GO PROMO COUNTDOWN STUFF ***************************** //

// Update display (strContent, countdownId)
function CD_UD(s, id) {
	eval('CD_OBJS.' + id + '.innerHTML = s');
};

// Tick (countdownId, eventDate)
function CD_T(id, e) {
	n = new Date(n.getTime() + 1000);
	var p	= 1E3 - n.getMilliseconds();
	if ( (e - n) >= 0 ) 
		setTimeout("CD_T('" + id + "', " + e + ")", 1000);
	else {
		document.getElementById('goLink').innerHTML = document.getElementById('clickNowLink').innerHTML;
	}
	CD_D(+n, id, e);
};
// Calculate time and invoke draw routine (dateNow, countdownId, eventDate)
function CD_D(n, id, e) {
	var ms = e - n;
	if (ms <= 0) ms *= -1;
	var d = Math.floor(ms / 864E5);
	ms -= d * 864E5;
	var h = Math.floor(ms / 36E5);
	ms -= h * 36E5;
	var m = Math.floor(ms / 6E4);
	ms -= m * 6E4;
	var s = Math.floor(ms / 1E3);
	h += (24 * d) ;
	CD_UD(CD_ZP(h) + ":" + CD_ZP(m) + ":" + CD_ZP(s), id);
};
// Prefix single integers with a zero
function CD_ZP(i) {
	return (i<10 ? "0" + i : i);
};
// Initialisation
function CD_Init() {
	var pref = "countdown";
	var objH = 1; // temp boolean true value
	if (document.getElementById || document.all) {
		for (var i=1; objH; ++i) {
			var id	= pref + i;
			objH	= document.getElementById ? document.getElementById(id) : eval('document.all.' + id);
			if (objH && (typeof objH.innerHTML) != 'undefined') {
				var s	= objH.innerHTML;
				var dt	= new Date(s);
				if (!isNaN(dt)) {
					eval('CD_OBJS.' + id + ' = objH'); // Store global reference to countdown element object
					CD_T(id, dt.valueOf());
					if (objH.style) {
						objH.style.visibility = "visible";
					}
				}
				else {
					objH.innerHTML = s + "<a href=\"http://andrewu.co.uk/clj/countdown/\" title=\"Countdown Error: Invalid date format used, check documentation (see link)\">*";
				}
			}
		}
	}
};

var CD_OBJS = new Object();

// ***************************** ABSOLUTE POSITIONING STUFF ***************************** //

function getTopPos(div) {
	pos = div.offsetTop; //init
	while ( div.offsetParent ) {
		div = div.offsetParent;
		pos += div.offsetTop;
	}
	return pos;
}

function getBottomPos(div) {
	return div.offsetHeight + getTopPos(div);
}

function positionUnder(div,upperDiv) {
	if ( div && upperDiv ) {
		div.style.top = getBottomPos(upperDiv) + "px";
	}
	else alert('POSITIONING FAILED');
}

function placeFooter() { 
	 var divs = document.getElementsByTagName('div');
     var lowestDiv = document.getElementById('sulogo');
	 var footer = document.getElementById('footer');
	 for( var i = 0 ; i < divs.length; i++ ) { 
		thisDiv = divs[i];
		if ( !childOf(thisDiv,footer) && getBottomPos(thisDiv) > getBottomPos(lowestDiv) ) {
			lowestDiv = thisDiv;
		}
     }
	 positionUnder(footer,lowestDiv);
	 footer.style.display = "block";
}

function childOf(thisObj,parentObj) {
	while ( thisObj.id != parentObj.id && thisObj.parentNode ) {
		thisObj = thisObj.parentNode;
	}
	return(thisObj.id==parentObj.id);
}

function growDivs(objToTraverse) {
	lowestBottom = getBottomPos(objToTraverse);
	var divs = objToTraverse.getElementsByTagName('div');
	for( var i = 0 ; i < divs.length; i++ ) { 
		thisDiv = divs[i];
		lowestBottom = Math.max(lowestBottom,growDivs(thisDiv));
	}
	totalHeight = lowestBottom - getTopPos(objToTraverse);
	if ( objToTraverse.style ) {
		objToTraverse.style.height = totalHeight + "px";
	}
	return lowestBottom;
}

function layoutPage() {
	setTimeout('placeFooter()',100);
}

window.onload = layoutPage;
window.onresize = layoutPage;

// ***************************** POPUPS.JS ***************************** //

// Popup window functions
// Author: Dale Wiggins
// standard popup window, with no window options
function popupWindow(path,width,height,argumentsStr) {
    popupWindowFull(path,'popmeup',width,height,0,0,argumentsStr);
}

// Popup window functions
// Author: Dale Wiggins
// standard popup window, with no window options
function popupNamedWindow(path,name,width,height,argumentsStr) {
    popupWindowFull(path,name,width,height,0,0,argumentsStr);
}

// full-featured popup window
function popupWindowFull(path,name,width,height,xOffset,yOffset,argumentsStr) {
if (window.thisPopWin && !window.thisPopWin.closed) // checks if window is already open.  if it is, closes it, so it can re-open at correct size
  thisPopWin.close(); 
argumentsStr += ''; // if arguments are undefined, converting to a string makes testing easier.
var options = new Array('toolbar','location','directories','status','titlebars','menubar','resizable','copyhistory','scrollbars');
if (argumentsStr == 'undefined')
  optionsString = 'toolbar=no,location=no,directories=no,status=no,titlebars=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,';
else
  {
  optionsString = ''
  for ( i = 0 ; i < options.length ; i++ )
    {
    if (argumentsStr.indexOf(options[i]) != -1)
	  optionsString += options[i] + '=yes,'
    else
      optionsString += options[i] + '=no,'
    }
  }
  
centeredLeftPos = (screen.width / 2 - width / 2) / 2;  // these 2 lines center the popup on the user's screen
centeredTopPos = (screen.height / 2 - height / 2) / 2;

leftPos = xMousePos - width + 3 + xOffset; // get the cursor on the close button by default
topPos = yMousePos - 10 + yOffset;

optionsString += 'width=' + width + ',height=' + height + ',left=' + centeredLeftPos + ',top=' + centeredTopPos + ',screenX=' + leftPos + ',screenY=' + topPos;

thisPopWin = window.open(path,name,optionsString);
}

function infopop( source, sourceId ) {
	var sURL = "/common/tools/hotDealsFareRules.jsp?source=" + source + "&sourceId=" + sourceId;
	popupWindow(sURL,425,430,'scrollbars');
}

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX+screenX;
        yMousePos = e.pageY+screenY;
        xMousePosMax = window.innerWidth+window.pageXOffset+screenX;
        yMousePosMax = window.innerHeight+window.pageYOffset+screenY;
    } else if (document.all) {
        xMousePos = window.event.x + self.screenLeft;
        yMousePos = window.event.y + self.screenTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft+self.screenLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop+self.screenTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX+self.screenTop;
        yMousePos = e.pageY+self.screenTop;
        xMousePosMax = window.innerWidth+window.pageXOffset+self.screenLeft;
        yMousePosMax = window.innerHeight+window.pageYOffset+self.screenTop;
    }
	//window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;
}

function trackAndRedirectPageTitle(url,pageTitle,newWindow) {
	redirectURL = '/common/tools/trackAndRedirect.jsp?contentCategory=/partners&redirectURL=' + escape(url);
	redirectURL += '&hitboxTitle=' + pageTitle;
	if (newWindow == 1) {
		window.open(redirectURL,'externalSite');
	}
	else {
		window.location = redirectURL;
	}
}

function skipToPage(thisURL) {
  windowToChange = parent.window;
  if (!parent.hiddenFrame) { // this isn't a child frame (shouldn't happen)
    windowToChange = window;
  }
  var version = parseInt(navigator.appVersion)
  // replace is supported
  if (version>=4 || window.location.replace)
    windowToChange.location.replace(thisURL);
  else
    windowToChange.location.href = thisURL;
}

function redirectFrom(referer_code) {
	pageURL = '/?referer=' + referer_code;
	setTimeout("skipToPage(pageURL)",6000);
}

// ***************************** AIRSEARCH.JS ***************************** //

function getSearchForm() {
	return document.farefinder;
}

function matchOutboundWithReturnAirport() {
	getSearchForm().inboundJawAirport.value = getSearchForm().outboundAirport.value;
}

function onSubmit() {
    getSearchForm().submit();
}

function onFlySearch (tripType){
	getSearchForm().action = '/airsearch/';
    getSearchForm().tripType.value = tripType;
    getSearchForm().submit();
}

function show_calendar( form, formElement, selectedMonth) {	
	var today = new Date();
	currentMonth = today.getMonth();
    currentYear = today.getFullYear();
	
	if (currentMonth > selectedMonth) {
	    currentYear++;
	}
	
	popupWindowFull("/includes/calendarWindow.jsp?displayMonth=" + selectedMonth + "&displayDay=1&displayYear=" + currentYear + "&targetInputID=" + formElement + "&targetFormID=" + form,'calendar',410,195,90,-95);
}

function advanceInboundMonth() {
	if (getSearchForm().inboundMonth.selectedIndex <= getSearchForm().outboundMonth.selectedIndex ) {
        getSearchForm().inboundMonth.selectedIndex = getSearchForm().outboundMonth.selectedIndex;
		if ( getSearchForm().inboundDay.selectedIndex <= getSearchForm().outboundDay.selectedIndex ) {
			if (getSearchForm().outboundMonth.selectedIndex >= (getSearchForm().outboundMonth.length - 1) ) {
				return; // if advancing one more month outsteps the month bounds, abort function
			}
			getSearchForm().inboundMonth.selectedIndex = getSearchForm().inboundMonth.selectedIndex + 1;
		}
	}
}

function aironClick( field) {
	popupWindow('/includes/airportCodesPopup.jsp?field=' + field,625,510,'scrollbars,resizable');
}

function outboundChoice_onchange( input_data ) {
	getSearchForm().outboundAirport.value = input_data;
	inboundJawChoice_onchange(input_data);
}

function inboundChoice_onchange( input_data ) {
	getSearchForm().inboundAirport.value = input_data;
}

function outboundJawChoice_onchange( input_data ) {
	getSearchForm().outboundJawAirport.value = input_data;
}

function inboundJawChoice_onchange( input_data ) {
	getSearchForm().inboundJawAirport.value = input_data;
}

function prePopCodes(advSearchFlag) { // replaces blank airport code boxes with default description (i.e. "City name or code")
	if (getSearchForm().outboundAirport.value == '') {
        getSearchForm().outboundAirport.value = defaultCodeText;
    }
    
    if (getSearchForm().inboundAirport.value == '') {
        getSearchForm().inboundAirport.value = defaultCodeText;
    }
	
	if (advSearchFlag) {
        if (getSearchForm().outboundJawAirport.value == '') {
            getSearchForm().outboundJawAirport.value = defaultCodeText;
        }
        
        if (getSearchForm().outboundAirport.value != defaultCodeText) {
		    getSearchForm().inboundJawAirport.value = getSearchForm().outboundAirport.value;
		}
		else if (getSearchForm().inboundJawAirport.value == '') {
            getSearchForm().inboundJawAirport.value = defaultCodeText;
        }
	}
}


function resetCodes(advSearchFlag) { // replaces all instances of " City name or code" with empty string

	if (getSearchForm().outboundAirport.value == defaultCodeText) {
        getSearchForm().outboundAirport.value = '';
    }
    
    if (getSearchForm().inboundAirport.value == defaultCodeText) {
        getSearchForm().inboundAirport.value = '';
    }
    
	if (getSearchForm().outboundJawAirport != null && getSearchForm().outboundJawAirport.value == defaultCodeText) {
        getSearchForm().outboundJawAirport.value = '';
    }
	
	if (getSearchForm().outboundJawAirport != null && getSearchForm().inboundJawAirport.value == defaultCodeText) {
        getSearchForm().inboundJawAirport.value = '';
    }

}

function searchOrLogin(){
	if (window.event) { // if supported
		theKey = window.event.keyCode;
		if(theKey==13 && enterButtonEnabled){
		    window.event.cancelBubble = true;  // for disabling BEEP when hitting enter button to submit
    	    window.event.returnValue = false;  // for disabling BEEP when hitting enter button to submit
			if (document.farefinder) {
				onSubmit();
			}
			else if (document.login) {
				document.login.submit();
			}
		}
	}
}

function enableEnterButton() {
    enterButtonEnabled = true;
}

function disableEnterButton() {
    enterButtonEnabled = false;
}

// ***************************** PROFILE.JSP ***************************** //

function getJoinForm() {
	return document.form1;
}

function login(entryPage,selectedItin,eduPrice) {
	if (entryPage != null) {
	    loginLink += '?entryPage=' + escape(entryPage);
	}
	if (selectedItin != null) {
	    loginLink += '&selectedItin=' + selectedItin;
	}
	if (eduPrice != null) {
	    loginLink += '&eduPrice=' + eduPrice;
	}
	window.location = loginLink;
}
		
function submitForm() {
		if ( getJoinForm().permissionToEmailBox.checked ) {
			getJoinForm().permissionToEmail.value = 'true';
		}
		else {
			getJoinForm().permissionToEmail.value = 'false';
		}
		
		if ( getJoinForm().permissionToSMSBox.checked ) {
			getJoinForm().permissionToSMS.value = 'true';
		}
		else {
			getJoinForm().permissionToSMS.value = 'false';
		}
		getJoinForm().submit();
}
		
function confirmTermsJoin() {
		if ( getJoinForm().permissionToVerify.checked ) {
			submitForm();
		}
		else {
			alert('You must check the box above the Continue button, agreeing to the Terms and Conditions.');
		}
}

function checkSMSPref(origCellValue, newCellValue) {
	if ( origCellValue == '' && newCellValue != '') {
		getJoinForm().permissionToSMSBox.checked = true;
	}
}

function uncheckSMSPref(newCellValue) {
	if ( newCellValue == '') {
		getJoinForm().permissionToSMSBox.checked = false;
	}
}

function handleCheckBoxes(){
		if(document.form1.permissionToEmail.checked){
			document.form1.permissionToEmail.value = 'true';
		}
		else {
			document.form1.permissionToEmail.value = 'false';
		}
		return true;
	}
// resets appropriate values and attempts to join
function submitJoinForm() { 
		handleCheckBoxes();
		getJoinForm().submit();
}
		
function useNoEduForm(flag) {
	getJoinForm().action = '/register/saveData';
	getJoinForm().noEduForm.value = flag;
	getJoinForm().suppressErrors.value = 'true';
	getJoinForm().submit();
}
		
function matchEduEmail() {
    if ( getJoinForm().email.value.indexOf('.edu') >= 0 ) {
	    getJoinForm().universityEmail.value = getJoinForm().email.value;
	}
}

function mySchoolIsNotListed() {
    popupLink = '/member/sendSchoolInfo';
	if (getJoinForm()) formRef = getJoinForm();
	
	if ( formRef.universityLocationID.options[formRef.universityLocationID.selectedIndex].value == '-1' ) {
		alert('Please select a state to see if your school is listed');
		return;
	}

	if (formRef.universityCountryID.options[formRef.universityCountryID.selectedIndex].value != -1) {
		popupLink += '?countryID=';
		popupLink += formRef.universityCountryID.options[formRef.universityCountryID.selectedIndex].value;
	}
	if (formRef.universityLocationID.options[formRef.universityLocationID.selectedIndex].value != -1) {
		popupLink += '&stateID=';
		popupLink += formRef.universityLocationID.options[formRef.universityLocationID.selectedIndex].value;
	}
	popupLink += '&email=' + formRef.email.value;
	if (formRef.firstname.value != '' || formRef.lastname.value != '') {
		popupLink += '&name=';
		if ( formRef.firstname.value != '') {
			popupLink += formRef.firstname.value;
		}
		if ( formRef.lastname.value != '') {
			popupLink += '+' + formRef.lastname.value;
		}
	}
	popupNamedWindow(popupLink, 'mySchoolIsNotListed',550,620,'resizable,scrollbars');
}

function submitSchoolInfo() {
	document.schoolInfo.country.value = document.schoolInfo.countryID.options[document.schoolInfo.countryID.selectedIndex].text;
	document.schoolInfo.state.value = document.schoolInfo.stateID.options[document.schoolInfo.stateID.selectedIndex].text;
	document.schoolInfo.submit();
}

function populateUniversityInfo() {
	if (document.form1.universityLocationID.selectedIndex != 0)
		document.form1.universityState.value = document.form1.universityLocationID.options[document.form1.universityLocationID.selectedIndex].text;
	if (document.form1.universityID.selectedIndex != 0)
		document.form1.universityName.value = document.form1.universityID.options[document.form1.universityID.selectedIndex].text;
}

function testMe() {
alert(getJoinForm().universityID.options[getJoinForm().universityID.selectedIndex].text);
}

function resendEduEmail() {
    window.location.href = '/register/resendemail';
}

function forgotPassword() {
    email = document.login.email.value;
	forgotPasswordURL = '/membership/forgotPassword';
	if (email != null && email.indexOf('@') > 0) {
	    forgotPasswordURL += '?email=' + email;
	}
	window.location = forgotPasswordURL;
}

function getHint() {
    document.forgotPassword.actionvar.value = 'ShowHintAction';
    document.forgotPassword.submit();
}

function emailPassword() {
    document.forgotPassword.actionvar.value = 'EmailPasswordAction';
    document.forgotPassword.submit();
}

// ***************************** SHOPPINGCART.JSP ***************************** //

    function deleteItem(id) {
        if (confirm('Are you sure you want to delete this entry?')) {
        	getJoinForm().action='/shoppingcart/delete';
            getJoinForm().item_pk.value = id;
            getJoinForm().submit();
        }
    }
	
	function focusOnPhone() {
		if ( getJoinForm().passengerPhone.value == '') {
			getJoinForm().passengerPhone.focus();
		}
	}
    
    function check_onClick(checked) {
		if ( getJoinForm() ) thisForm = getJoinForm();
		else thisForm = document.requestToPayForm;
		
		if ( checked ) {
			thisForm.shipname.value = thisForm.nameoncard.value;
			thisForm.shipaddress1.value = thisForm.billaddress1.value;
        	thisForm.shipaddress2.value = thisForm.billaddress2.value;
        	thisForm.shipcity.value = thisForm.billcity.value;
        	thisForm.shipstate.value = thisForm.billstate.value;
        	thisForm.shipcountry.value = thisForm.billcountry.value;
        	thisForm.shippostalcode.value = thisForm.billpostalcode.value;
			if ( !getJoinForm() ) {
				thisForm.shipphone.value = thisForm.billphone.value;
			}
			else {
				thisForm.shipphone.value = thisForm.billingPhone.value;
			}
		}
		
		else { //not checked - clear shipping info
			thisForm.shipname.value = '';
			thisForm.shipaddress1.value = '';
        	thisForm.shipaddress2.value = '';
        	thisForm.shipcity.value = '';
        	thisForm.shipstate.value = '';
        	thisForm.shipcountry.value = '';
        	thisForm.shippostalcode.value = '';
			thisForm.shipphone.value = '';
		}
		
	}
    
	function confirmFinalize() {
		if ( getJoinForm().agreeToTerms.checked ) {
			finalizeOrder();
		}
		else {
			alert('You must check the box above the Finalize Order button, agreeing to the Fare Rules & Terms of Use');
		}
	}
	
	function finalizeOrder() {
	    getJoinForm().action = '/shoppingcart/finalizeWait';
		getJoinForm().submit();
	}
	
	function showFinalizeTimeoutWarning() {
	    alert('We\'re sorry, we could not get confirmation for your flight from the airline, so you have not yet purchased a ticket for this flight.  Please contact us at 800-272-9676 (outside the U.S. 617-321-3100) to book this flight.  Our agents are available 9AM-9PM Monday-Friday, 11AM-6PM Saturday-Sunday, ET.');
	}
	
	function showOptions(query){
    document.airOptionsForm.deal.value = query;
    document.airOptionsForm.submit();
}
	
	function selectOption(query, outindex, inindex){
    document.airOptionsForm.deal.value = query;
    document.airOptionsForm.inboundOption.value = inindex;
    document.airOptionsForm.outboundOption.value = outindex;
    document.airOptionsForm.submit();
}

function buyNow(uuid,outboundIndex,inboundIndex){
    document.buyNowForm.itinUUID.value = uuid;
    document.buyNowForm.outboundIndex.value = outboundIndex;
    document.buyNowForm.inboundIndex.value = inboundIndex;
    document.buyNowForm.submit();
}

function chooseProgram(destContentName,programIndex) {
	document.requestToPayChooser.destContentName.value = destContentName;
	document.requestToPayChooser.programIndex.value = programIndex;
	document.requestToPayChooser.submit();
}

// **************** Load University Data Dropdowns ****************************

var loadDataOutputField;

function iFramesSupported() {
	if (window.hiddenFrame) return true;
	else return false;
}

function loadStates(idNum, outputField, showOtherFlag) {
	displayWaitMsg(outputField,"-- Please wait while state location data is loading --");
	loadData(idNum, 'states', outputField, showOtherFlag);
}

function loadUniversities(idNum, outputField, showOtherFlag) {
	displayWaitMsg(outputField,"-- Please wait while university data is loading --");
	loadData(idNum, 'universities', outputField, showOtherFlag);
}

function loadUniversitiesInCountry(countryID, outputField, showOtherFlag) {
	displayWaitMsg(outputField,"-- Please wait while university data is loading --");
	loadData(countryID, 'universitiesInCountry', outputField, showOtherFlag);
}

function loadData(idNum, type, outputField, showOtherFlag) {
	loadDataOutputField = outputField;
	url = '/aboutus/loadData?type=' + type + '&id=' + idNum;
	if ( showOtherFlag ) url += '&showOther=true';
	
	if (iFramesSupported()) {
		window.hiddenFrame.location = url;
	}
	else {
		hiddenWindow = window.open(url,'hiddenWindow','top=2000,left=2000,width=300,height=300,toolbar=no,location=no,directories=no,status=no,titlebars=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
	}
}

function displayWaitMsg(outputField, waitMsg) {
	outputField.length = 0;
	outputField.length++;
	newOption = new Option(waitMsg);
	newOption.value =  "-1";
	outputField.options[0] = newOption;
}

function populateDropdown() {
	if (iFramesSupported()) {
		reference = window.hiddenFrame;
	}
	else {
		reference = hiddenWindow;
	}
	
	loadDataOutputField.length = 0;
	for ( i = 0 ; i < reference.names.length ; i++ ) {
		loadDataOutputField.length++;
		newOption = new Option( reference.names[i] );
		newOption.value =  reference.values[i];
		loadDataOutputField.options[i] = newOption;
	}
	loadDataOutputField.options[0].selected = true;
	
	if (!iFramesSupported()) {
	}
		reference.close();
}

function getStateProvincePrompt(countrySelectObj) {
	if ( countrySelectObj[countrySelectObj.selectedIndex].text == 'CANADA' ) {
		return "-- Please choose your school's province --";
	}
	else {
		return "-- Please choose your school's state --";
	}
}

function getUniversityProvincePrompt(countrySelectObj) {
	if ( countrySelectObj[countrySelectObj.selectedIndex].text == 'CANADA' ) {
		return "-- First choose a province above --";
	}
	else {
		return "-- First choose a state above --";
	}
}

function focusOnField() {
	if (document.form1.email.value == '') 
		document.form1.email.focus();
	else if (document.form1.firstname.value == '') 
		document.form1.firstname.focus();
	else if (document.form1.lastname.value == '') 
		document.form1.lastname.focus();
	else if (document.form1.universityLocationID.value == '') 				
		document.form1.universityLocationID.focus();
	else if (document.form1.universityCountryID.value == '') 			
		document.form1.universityCountryID.focus();		
	else if (document.form1.universityID.value == '') 				
		document.form1.universityID.focus();
}

function monitorFields() {
	if (document.form1 != null && document.form1.universityLocationID != null && document.form1.universityLocationID.options != null && document.form1.universityLocationID.options.length > 1 
	 && document.form1.universityLocationID.selectedIndex == 0
	 && document.form1.universityID.options[document.form1.universityID.options.selectedIndex].value == '-1') {
    	resetUniv();
	}
}

function resetUniv() {
	document.form1.universityID.length = 0;
	document.form1.universityID.length++;
	newOption = new Option(getUniversityProvincePrompt(document.form1.universityCountryID));
	newOption.value =  "-1";
	document.form1.universityID.options[0] = newOption;
	document.form1.universityID.options[0].selected = true;
}

function getCountrySelectObj() {
	if ( parent.document.form1 != null ) {
		return parent.document.form1.universityCountryID;
	}
	else if ( parent.document.schoolInfo != null ) {
		return parent.document.schoolInfo.countryID;
	}
}

function getStateSelectObj() {
	if ( parent.document.form1 != null ) {
		return parent.document.form1.universityLocationID;
	}
	else if ( parent.document.schoolInfo != null ) {
		return parent.document.schoolInfo.stateID;
	}
}
