<!--

function prefillClear(field) {

	if (field.defaultValue==field.value) {
		field.value = '';
		field.style.color='#000';
	}
	else if (field.value == '') {
		field.value = field.defaultValue;
		field.style.color='#bbb';
	}

}

function toggleDivImage(strShow, strImageID, strImageOn, strImageOff) { 
	 
	if ($("#" + strShow).css("display") == "none") {
		$("#" + strShow).show();
		$("#" + strImageID).attr("src", strImageOff);
	} else {
		$("#" + strShow).hide();
		$("#" + strImageID).attr("src", strImageOn);
	} 
	
}

//******************************************************

function showOnClick(strCheckbox, strTarget) {
	if ($('#' + strCheckbox).is(':checked')) {
		$("#" + strTarget).show("slow");
	}
	else {
		$("#" + strTarget).hide("slow");
	}
}

//******************************************************

function toggleDiv(strShow, strImageID) { 
	 
	if ($("#" + strShow).css("display") == "none") {
		$("#" + strShow).show();
	} else {
		$("#" + strShow).hide();
	} 
}

//******************************************************

function replaceImage(imgID, imgNew) {

	document.getElementById(imgID).src=imgNew;
	
}

//******************************************************

function doCallBack(strThis, arrCourses) {
	checkField(strThis, 'Telephone', 'showTelephoneMessage'); 
	triggerCheckboxDiv(strThis, 'showTelephoneCallTimes'); 
	
	checkCallSettings('showInterestMessage', arrCourses);	
	
}

//******************************************************

function checkSMS(strTarget) {
	var intSuccess = 0;
	var eleSMS = $('#SMS');
	
	if (eleSMS.is(':checked')) {
		$("#" + strTarget).show("slow");
	} else {
		$("#" + strTarget).hide("slow");
	}
	
	//alert("checkCallSettings " + intSuccess);
	
}

//******************************************************

function checkBrochure(arrCourses, strTarget) {
	var intSuccess = 0;
	var eleBrochure = document.getElementById('Brochure');
	var eleTarget = document.getElementById(strTarget);
	
	if (eleBrochure.checked) {
	
		intSuccess = checkTrue(arrCourses);
		
		eleTarget.style.display = intSuccess == 0 ? "block":"none";
	} else {
		eleTarget.style.display = "none";
	}
	
	//alert("checkCallSettings " + intSuccess);
	
}

//******************************************************

function checkCallSettings(strTarget, arrCourses) {
	var intSuccess = 0;
	var eleCallBack = document.getElementById('CallBack');
	var eleTarget = document.getElementById(strTarget);
	
	if (eleCallBack.checked) {
	
		intSuccess = checkTrue(arrCourses);
		
		var eleSource = document.getElementById('Enquiry');
		if (eleSource.value.length > 0) { intSuccess = 1; }
		
		
		
		eleTarget.style.display = intSuccess == 0 ? "block":"none";
	} else {
		eleTarget.style.display = "none";
	}
	
	//alert("checkCallSettings " + intSuccess);
	
}

//******************************************************

function checkTrue(arrTarget) {
	var intReturn = 0;
	for ( var i in arrTarget )
	{
		//alert("checkTrue " + arrTarget[i]);
		var eleTarget = document.getElementById(arrTarget[i]);
		 
		if (eleTarget.checked) {
			intReturn = 1;
		}
	}
	return intReturn;
}
	
//******************************************************

function hideWhenText(strSource, strTarget) {
	// alert("hideWhenText " + strSource.value.length);
	var eleTarget = document.getElementById(strTarget);
 	eleTarget.style.display = strSource.value.length == 0 ? "block":"none";
}

//******************************************************

function triggerCheckboxDiv(strSource, strTarget) {
	var eleTarget = document.getElementById(strTarget);
 	eleTarget.style.display = strSource.checked? "block":"none";
} 

//******************************************************

function checkField(strSource, strCheck, strTarget) {
	var eleTarget = document.getElementById(strTarget);
	var eleCheck = document.getElementById(strCheck);
	
	if (strSource.checked) {
		eleTarget.style.display = (eleCheck.value.length == 0)? "block":"none";
	} else {
		eleTarget.style.display = "none";
	}
}

//******************************************************

function checkSpryFormHTTP(form) {
	var theForm = typeof form != 'object' ? document.getElementById(form): form;
	var ret = Spry.Widget.Form.validate(theForm);
	if (!ret) {
		
		var objMessageID = document.getElementById("formIncomplete");
		objMessageID.innerHTML = '<p>Please check back through the form to see the fields that need to be completed</p>';
		alert("The form is not complete yet. Please check the form for the information we need.");
		return false;
	} else {
   		return true;
	}
}

//******************************************************

function processPaymentChoiceCommon(obj) {
	
	var o=document.getElementById('PayBalance1');
	if(o) {
		if (document.getElementById("PayBalance1").checked == true) { // balance
			document.getElementById("PayBalanceRow").style.background = "#e8ffe8";
			document.getElementById("PayDepositRow").style.background = "#ffffff";
			if (document.getElementById('AmountToPay')) {
				document.getElementById('AmountToPay').innerHTML  = strAmountPayableBalance;
			}
		} 
		
		if (document.getElementById("PayBalance2").checked == true) { // deposit
			document.getElementById("PayDepositRow").style.background = "#e8ffe8";
			document.getElementById("PayBalanceRow").style.background = "#ffffff";
			if (document.getElementById('AmountToPay')) {
				document.getElementById('AmountToPay').innerHTML  = strAmountPayableDeposit;
			}
		}
	}
}

//******************************************************

function showCVV() {
	var eleTarget = document.getElementById('cvv');
	
	if (eleTarget.style.display == "block") {
		eleTarget.style.display = "none";
	} else {
		eleTarget.style.display = "block";
	}
}


//******************************************************

function showLanguageOption(intField, objSource) {
	var eleTarget = document.getElementById('examLanguage' + intField);
	
	
	if (objSource.value >= 30 &&  objSource.value <= 36) {
		eleTarget.innerHTML = "<div class=\"formItem\"><label>Which language?</label>" +
						"<div class=\"inputColumn\"><input type=\"text\" name=\"otherLanguage" + intField + "\" id=\"otherLanguage" + intField + "\" " + 
						"class=\"fieldWidth\" /></div></div>";
	} else {
		eleTarget.innerHTML = "";
	}
}

//*************************************************************************

function getArticle(objSelect) {
	
	var idField = document.getElementById(objSelect);
	var intArticleSectionID = idField.options[idField.selectedIndex].value;  
	//alert(intArticleSectionID + " " + strTargetID);
	
	window.location = "/ib-resources/default.asp?categoryid=25&pageid=290&article=" + intArticleSectionID;

}

//******************************************************

function getNewsletter(objSelect) {
	
	var idField = document.getElementById(objSelect);
	var intArticleSectionID = idField.options[idField.selectedIndex].value;  
	//alert(intArticleSectionID + " " + strTargetID);
	
	window.location = "/ib-resources/default.asp?categoryid=25&pageid=288&newsletter=" + intArticleSectionID;

}
 
//******************************************************

function getTool(objSelect) {
	
	var idField = document.getElementById(objSelect);
	var intArticleSectionID = idField.options[idField.selectedIndex].value;  
	//alert(intArticleSectionID + " " + strTargetID);
	
	window.location = "/ib-resources/default.asp?categoryid=25&pageid=291&tool=" + intArticleSectionID;

}
 
// sets the wait image to visible after transaction

//******************************************************

function setWaitImage() {
	
	var objWait = document.getElementById("waitImage");
	
	objWait.style.display = "block";
	
	return true;
}

//******************************************************

function select_text(objField)
{
	objField.focus();
	objField.select();
}

// AJAX calls

//****************************************************** 

function bindForm(strFormName) {

	
	// bind 'myForm' and provide a simple callback function 

	$('#' + strFormName).ajaxForm({

		 target: '#photoStudent',
		 
		 beforeSubmit: function(a,f,o) {
			  $("#waitingImage").show("slow"); //animation
		  },
 
		  success: function() {
			  $("#waitingImage").hide("slow"); //animation
			  $('#uploadOutput').fadeIn('slow');
		  }

		

	});
	
}

function getQuestionForm(intStudentID, intID, strFile) {
 
	//$("#questiondisplay" + intID).slideUp("slow"); 
	
	$(".waitingAnimation").slideDown("slow");
	
	$.ajax( {
		type: "GET",
		url: "ajax-students.asp",  
		cache: false,
		data: "op=showQuestionnaire&studentid=" + intStudentID + "&question=" + intID + "&file=" + strFile,
		dataType: "html",
		beforeSend: function() {  
			$("#questionDisplay").slideUp("slow"); //animation 
			
			//alert("Status: op=showQuestionnaire&studentid=" + intStudentID + "&question=" + intID + "&file=" + strFile);
		}, //show loading just when link is clicked
		complete: function(XMLHttpRequest, textStatus) { 
			$("#questionDisplay").hide();
			$(".waitingAnimation").slideUp("fast");
			//alert("Status: " + textStatus);
		}, //stop showing loading when the process is complete
		success: function(data, textStatus) { //so, if data is retrieved, store it in html
			//alert(data);
			
			$("#questionDisplay").html(data); //show the html inside .questiondisplay div
			$("#questionDisplay").show("slow"); //animation
			
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert('Error loading document ' + textStatus);
		}
	}); //close $.ajax
	
} // end function

//*************************

function copyAddressGeneral() {
	
	if ($('#Address1').val().length > 0) {
		$('#ParentAddress1').val($('#Address1').val());
	}
	if ($('#Address2').val().length > 0) {
		$('#ParentAddress2').val($('#Address2').val());
	}
	if ($('#City').val().length > 0) {
		$('#ParentCity').val($('#City').val());
	}
	if ($('#PostCode').val().length > 0) {
		$('#ParentPostcode').val($('#PostCode').val());
	}
	if ($('#CountryID').val() > 0) {
		$('#ParentCountryID').val($('#CountryID').val());
	}	
	
}

// -->