<!--
/* =============================================================================
	Function:	popUpNewWin(url)
	Purpose:	open a new window. For the javascript navigation arrays.
	Parameters:1)url
				Data type:String
				Description:Url of the website to be opened in a new window
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(2/08/2006)
	============================================================================= */
	function popUpNewWin(url)
		{
	 
			window.open(url,"","");
		}
/* =============================================================================
	Function:	fnCalcPurchaseOrder(intTotalProducts)
	Purpose:	Calculates and assigns the value of the total order and the individual products
	Parameters:	Required:	intTotalProducts			
				Data type:  integer
				Desc.:		Total number of products as per the course selected
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function fnCalcPurchaseOrder(intTotalProducts) {

		  orderTotal = 0;
		  //evaluate if we use the member fee or not
			if (document.orderForm.rdAPESMAMember[0].checked)
				{			
					blnMember = true;
				}
			else
				{			
					blnMember = false;
				}
			for (i = 1; i <= intTotalProducts; i++)
			{
				var strProductSubTotal="";				
				strProductSubTotal="product"+i+"subTotal";				
				if (eval("document.orderForm.Course"+i+".checked"))
				{				
					if(blnMember)
						productprice[i-1]= decMemberFee;
					else
						productprice[i-1]= decNonMemberFee;						
				}
				else
				{
						productprice[i-1] = 0;						
				}
				orderTotal = orderTotal + Number(productprice[i-1]);
				//update product sub total variables
				 document.getElementById(strProductSubTotal).value = cCurrency(productprice[i-1]);
			}

			//convert order total to currency format
			 document.orderForm.orderTotal.value = cCurrency(orderTotal);
		}
		
/* =============================================================================
	Function:	fnValidatePurchaseForm(orderForm,strCourseName)
	Purpose:	Validates the form fields of the purchase form
	Parameters:	Required:	orderForm,strCourseName			
				1)orderForm
				Data type:  object
				Desc.:		form object
				2)strCourseName
				Data type:  string
				Desc.:		name of the course selected				
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(31/07/2006)
	============================================================================= */

	function fnValidatePurchaseForm(orderForm,strCourseName)
	{
		//**** The below switch case checks if any product is selected ****		
//**** if statement must be updated if number of products changes ****
	
	switch(strCourseName)
		{
			case 'Certificate IV in Frontline Management':
				//check all product quantities				
				blnChecked=checkCheckBox('orderForm',13);
					if (!blnChecked) {
							alert('You must choose at least one course.');
							document.orderForm.Course1.focus();
							return false;
					  }
			  break;
			  
			case 'Diploma of Management':
				//check all product quantities
				blnChecked=checkCheckBox('orderForm',12);
					if (!blnChecked) {
							alert('You must choose at least one course.');
							document.orderForm.Course1.focus();
							return false;
					  }			 
			  break;
			  
			case 'DIPLOMA OF PROJECT MANAGEMENT':
				//check all product quantities
				blnChecked=checkCheckBox('orderForm',7);
					if (!blnChecked) {
						alert('You must choose at least one course.');
						document.orderForm.Course1.focus();
						return false;
				  }
			  break;
			  
			default:
			 
		}
		
		if (document.orderForm.txtName.value == "")
		{
			alert ('Please enter your Full Name including your title.');
			document.orderForm.txtName.focus();
			return false;
		}
		
		else if (document.orderForm.txtStreet.value == "")
		{
			alert ('Please enter your Address.');
			document.orderForm.txtStreet.focus();
			return false;

		}
		else if (document.orderForm.txtSuburb.value == "")
		{			
			alert ('Please enter your Suburb.');
			document.orderForm.txtSuburb.focus();
			return false;
		}
		else if(document.orderForm.selState.value == ""){
			alert ("Please enter your state.");
			document.orderForm.selState.focus();
			return false;
		}		
		else if (document.orderForm.txtPostcode.value == "")
		{
			alert ('Please enter your Postcode.');
			document.orderForm.txtPostcode.focus();
			return false;
		}
		else if (document.orderForm.txtPhone.value == "")
		{
			alert ('Please enter your Phone.');
			document.orderForm.txtPhone.focus();
			return false;
		}
		
		else if (document.orderForm.txtEmail.value == "")
		{
			alert ('Please enter your Email.');
			document.orderForm.txtEmail.focus();
			return false;
		}		
		else if (emailcheck(document.orderForm.txtEmail.value)==false){
			document.orderForm.txtEmail.select();
			document.orderForm.txtEmail.focus();
			return false;
		}
		
		else if ((document.orderForm.rdAPESMAMember[0].checked == true) && (document.orderForm.txtAPESMAMemberNo.value == ""))
		{
			alert ('Please enter your APESMA Membership number.');
			document.orderForm.txtAPESMAMemberNo.focus();
			return false;
		}
		
		else if ((document.orderForm.rdBooker[0].checked == false) && (document.orderForm.rdBooker[1].checked == false))
		{
			alert ('Please indicate if you are the booker or participant of the program.');
			document.orderForm.rdBooker[0].focus();
			return false;
		}			
		else if ((document.orderForm.rdPaymentOption[0].checked == false) && (document.orderForm.rdPaymentOption[1].checked == false) && (document.orderForm.rdPaymentOption[2].checked == false))
		{
			alert ('Please select a payment option.');
			document.orderForm.rdPaymentOption[0].focus();
			return false;
		}
		else if (document.orderForm.rdPaymentOption[1].checked )
		{
			
			if (document.orderForm.PO_OrderNo.value == "")
				{
					alert ('Please enter your order number.');
					document.orderForm.PO_OrderNo.focus();
					return false;
				}
			else if (document.orderForm.PO_ContactName.value == "")
				{
					alert ('Please enter the contact name.');
					document.orderForm.PO_ContactName.focus();
					return false;
				}
			else if (document.orderForm.PO_Telephone.value == "")
				{
					alert ('Please enter the telephone number.');
					document.orderForm.PO_Telephone.focus();
					return false;
				}			
		}
		else if(document.orderForm.accept_policy.checked == false)
		{
			alert ('Please accept the terms and conditions to continue with your registration.');
			document.orderForm.accept_policy.focus();
			return false;
		}
		
		if (confirm ("By proceeding, you are confirming your enrolment/s.")) 
			return true;
 		else 
			return false;	
		
		
	}
	/* =============================================================================
	Function:	fnClearPo_details()
	Purpose:	Clears and disables the purchase order details when the payment options other than the purchase order is selected.	
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */

	function fnClearPo_details()
	{
		if (document.orderForm.PO_ContactName.value != "")
		{
			document.orderForm.PO_ContactName.value = "";
		}
		document.orderForm.PO_ContactName.disabled = true;
		if (document.orderForm.PO_OrderNo.value != "")
		{
			document.orderForm.PO_OrderNo.value = "";
		}
		document.orderForm.PO_OrderNo.disabled = true;
		if (document.orderForm.PO_Telephone.value != "")
		{
			document.orderForm.PO_Telephone.value = "";
		}
		document.orderForm.PO_Telephone.disabled = true;
			
	}
	/* =============================================================================
	Function:	fnClearPo_details()
	Purpose:	Enables the purchase order fields when the purchase order payment option is selected	
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
	function fnEnable_Po_details()
	{
		document.orderForm.PO_ContactName.disabled=false;
		document.orderForm.PO_OrderNo.disabled=false;
		document.orderForm.PO_Telephone.disabled=false;
		document.orderForm.PO_OrderNo.focus();
	}
/* =============================================================================
	Function:	cOrder(intTotalProducts)
	Purpose:	Calculates and assigns the value of the total order and the individual products
	Parameters:	Required:	intTotalProducts			
				Data type:  integer
				Desc.:		Total number of products as per the course selected
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function cOrder(intTotalProducts) {
		
		  orderTotal = 0;
		  //evaluate if we use the member fee or not
			if (document.orderForm.other4[0].checked)
				{			
					blnMember = true;
				}
			else
				{			
					blnMember = false;
				}
			for (i = 1; i <= intTotalProducts; i++)
			{
				var strProductQty="";
				var strProductPrice="";	
				var strProductSubTotal="";
				strProductQty="product"+i+"Qty";
				strProductPrice="productPrice"+i;
				strProductSubTotal="product"+i+"subTotal";				
				if (eval("document.orderForm.Course"+i+".checked"))
				{				
					document.getElementById(strProductQty).value=1;	
					if(blnMember)
						productprice[i-1]= decMemberFee;
					else
						productprice[i-1]= decNonMemberFee;						
				}
				else
				{
						productprice[i-1] = 0;
						document.getElementById(strProductQty).value = 0;
				}
				document.getElementById(strProductPrice).value = cCurrency(productprice[i-1]);
				orderTotal = orderTotal + Number(productprice[i-1]);
				//update product sub total variables
				 document.getElementById(strProductSubTotal).value = cCurrency(productprice[i-1]);
			}

			//convert order total to currency format
			 document.orderForm.orderTotal.value = cCurrency(orderTotal);
		}
		
/* =============================================================================
	Function:	checkCheckBox(frmName,chkLength)
	Purpose:	Checks if any of the boxes are checked
	Parameters:	Required:	frmName,chkLength			
				1)frmName
				Data type:  string
				Desc.:		form name
				2)chkLength
				Data type:  integer
				Desc.:		total number of products				
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(2/07/2008)
	============================================================================= */

function checkCheckBox(frmName,chkLength){
		var blnChecked;
		blnChecked= false;
		for (var i=1; i<=chkLength; i++) { // check if any of the boxes are checked
			if(eval("document."+ frmName +".Course" + i + ".checked")){
				blnChecked= true;
				break;
			}
		}
		if(blnChecked)
		{
			return true;	
		}
		else
		{
			return false;
		}
	}
/* =============================================================================
	Function:	validateRegister(orderForm,strCourseName)
	Purpose:	Validates the form controls of the credit card purchase form
	Parameters:	Required:	orderForm,strCourseName			
				1)orderForm
				Data type:  object
				Desc.:		form object
				2)strCourseName
				Data type:  string
				Desc.:		name of the course selected				
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function validateRegister(orderForm,strCourseName) {

	var blnChecked;
//**** The below switch case checks if any product is selected ****		
//**** if statement must be updated if number of products changes ****
	switch(strCourseName)
		{
			case 'Certificate IV in Frontline Management':
				//check all product quantities
					blnChecked=checkCheckBox('orderForm',13);
					if (!blnChecked) {
							alert('You must choose at least one course.');
							document.orderForm.Course1.focus();
							return false;
					  }
			  break;
			case 'Diploma of Management':
				//check all product quantities
				blnChecked=checkCheckBox('orderForm',12);
				
				if (!blnChecked) {
					alert('You must choose at least one course.');
					document.orderForm.Course1.focus();
					return false;
			  }
			  break;
			case 'DIPLOMA OF PROJECT MANAGEMENT':
				//check all product quantities
				blnChecked=checkCheckBox('orderForm',7);
				if (!blnChecked) {
						alert('You must choose at least one course.');
						document.orderForm.Course1.focus();
						return false;
				  }
			  break;
			default:
			 
		}
 
	if(document.orderForm.b_name.value == ""){
		alert ("Please enter your name");
		document.orderForm.b_name.focus();
		return false;
	}
	else if(document.orderForm.b_street.value == ""){
		alert ("Please enter your street");
		document.orderForm.b_street.focus();
		return false;
	}
	else if(document.orderForm.b_suburb.value == ""){
		alert ("Please enter your suburb");
		document.orderForm.b_suburb.focus();
		return false;
	}
	else if(document.orderForm.b_state.value == ""){
		alert ("Please enter your state.");
		document.orderForm.b_state.focus();
		return false;
	}	
  
	else {
		if (document.orderForm.other4[0].checked){
			  var isOK = checkBlank(
									document.orderForm.b_postCode, "your post code",
									document.orderForm.phone, "your phone number",
									document.orderForm.email, "your email address",					    
									document.orderForm.other1, "your APESMA membership number");
		}
		else	
			{
			  var isOK = checkBlank(					
							document.orderForm.b_postCode, "your post code",
							document.orderForm.phone, "your phone number",
							document.orderForm.email, "your email address");
			}
	}
	if (!isOK) {
		return false;
	  }
	if (emailcheck(document.orderForm.email.value)==false){
			document.orderForm.email.select();
			document.orderForm.email.focus();
			return false;
		}
		
 	
var blnCheckRadio = checkRadio(document.orderForm.other2, "whether you are the booker or attendee.");
	if (!blnCheckRadio) {
				    return false;
				  }
 

  if (!document.orderForm.accept_policy.checked) {
    alert ("Please accept the terms and conditions to continue with your registration.");
    document.orderForm.accept_policy.focus();
    return false;
  }

  if (confirm ("You are about to proceed into a secure payment site. Once your transaction is complete, you will be presented with a Payment Receipt/Tax Invoice. Please PRINT the Payment Receipt/Tax Invoice as proof of payment.")) {
    return true
  }
  else return false;

  return true;
}
//** end function validateRegister **

/* =============================================================================
	Function:	cCurrency(sInput)
	Purpose:	Converts the value passed in the currency format	
	Parameter:  Required:sInput
				data type:Integer
				description:It's a numeric value which is to be formatted as a currency value
	Returns:	The formatted currency value
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function cCurrency(sInput) {
  var sOutput;
  sOutput=Math.round(sInput*100)/100;
  sOutput+=""
  if(sOutput.indexOf(".")+2==sOutput.length && sOutput.indexOf(".")!=-1 && sOutput.indexOf(".")!="")
    sOutput+="0";
  if(sOutput.indexOf(".")==-1||sOutput.indexOf(".")=="")
  sOutput+=".00"
  return sOutput;
}

/* =============================================================================
	Function:	checkBlank()
	Purpose:	Checks if the textbox fields are blank
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */

function checkBlank() {
  for (var i = 0; i < arguments.length; i += 2) {
    if (!arguments[i].value) {
      alert("Please enter " + arguments[i+1] + ".");
      arguments[i].focus();
      return false;
    }
  }
  return true;
}

/* =============================================================================
	Function:	checkDropList()
	Purpose:	Checks if the value is selected in the drop down box
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function checkDropList() {
	if (arguments[0].selectedIndex == 0) {
  		alert("Please select " + arguments[1]);
  		arguments[0].focus();
  		return false;
	}
	else return true;
}

/* =============================================================================
	Function:	validateEnrol(form)
	Purpose:	Validates the form fields of the enrol.asp page
	Parameters:	Required:form
				Data type:form object
				Description:Form object of the validating form
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function validateEnrol(form)
{
	var blnCheckRadio = checkRadio(form.rdCourse, "a course you wish to enrol in.");
	if (!blnCheckRadio) {
				    return false;
				  }
				  
	var blnCheckRadio1 = checkRadio(form.rdPayment, "a payment option.");
	if (!blnCheckRadio1) {
				    return false;
				  }
				  
	if (confirm("Proceed to course registration"))
		{
			return true;
		}
		else
		{
			return false;
		}
	
}
/* =============================================================================
	Function:	checkRadio
	Purpose:	Checks whether a radio button has been selected from a group.
	Parameters:	* form field name [req] - the radio button group you want to test
            	* "error message" [req] (string) - display text must be enclosed in double quotation marks.
	Returns:	Boolean. True if an radio button has been selected, False if no radio button has been selected.
	Calling:	Usually used in the form validate function: 
				<form method="post" action="destination.asp" onsubmit="return validate(this)">
				* Validate function code
				function validate(form) {
				  var isSelected = checkRadio(form.radioGroupName, "an option from the radio button group.");
				  if (!isSelected) {
				    return false;
				  }
				}
	Notes:		Limitations - This function is only useful if no radio button has been pre-selected when page is loaded.
	============================================================================= */
	function checkRadio() {
	  var checkedButton = false;
	  var question = arguments[0];
	  var message = arguments[1];
	  for (var b = 0; b < question.length; b++) {
		if (question[b].checked) {
		  checkedButton = true;
		}
	  }
	  if (checkedButton == false) {
		alert("Please select " + message);
		question[0].focus();
	  }
	  return checkedButton;
	} 

/* =============================================================================
	Function:	validateContact(form)
	Purpose:	Validates the form fields of the contact.asp form
	Parameters:	Required:form
				Data type:form object
				Description:Form object of the validating form
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function validateContact(form)
	{
		var isSelected = checkDropList(form.selTitle, "your title.");
	
	  	if (!isSelected) {
	  	 return false;
	  	}
	  
		var isOK = checkBlank(	
							form.txtFirstName, "your first name",
						  	form.txtLastName, "your last name",
							form.txtAddress, "postal address",
							form.txtSuburb, "your suburb",
							form.txtState, "your state",
							form.txtPostcode, "your post code",
							form.txtCountry, "your country",
						  	form.txtPhone, "your phone number",
							form.txtEmail, "your e-mail id"
						  	);
		  if (!isOK) {
			return false;
		  } 
		 else if (emailcheck(form.txtEmail.value)==false){
			form.txtEmail.select();
			form.txtEmail.focus();
			return false;
		}

		if (confirm("Do you wish to send the enquiry?"))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
/* =============================================================================
	Function:	emailcheck(str)
	Purpose:	checks for valid email address
	Parameters:	Required:str
				Data type:String
				Description:String to be validated
	Returns:	boolean
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */
function emailcheck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email address.");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid email address.");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid email address.");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid email address.");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid email address.");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid email address.");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid email address.");
		    return false;
		 }

 		 return true;					
	}

	/* =============================================================================
	Function:	openWindowDetails()
	Purpose:	Opens the customer Login screen in a separate window
	Parameters:	none
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(28/07/2006)
	============================================================================= */

	function openWindowDetails() {
		var propStr = 'toolbar=1,location=0,directories=0,menubar=0,status=0,scrollbars=1,resizable=1,width='+screen.width+',height='+screen.height+',top=0,left=0'
		popupWin = window.open('https://federal.apesma.asn.au/source/security/member-logon.cfm?section=customer', 'popup_eseries', propStr)
	}
	
/* =============================================================================
	Function:	fnFocustTextBox(objForm,strWhereHear)
	Purpose:	The function is called onchange of the where did your hear about chifley drop down and it focuses on the text box if the value corresponding the selected value needs to be specified.
	Parameters:	Required:objForm,strWhereHear
				1)objForm
				Data type:form object
				Description:The form object
				2)strWhereHear
				Data type:string
				Description:Value chosen from the drop down
	Returns:	nothing
	Author:		Shefali Adlakha Joshi(28/08/2006)
	============================================================================= */
		
	function fnFocustTextBox(objForm,strWhereHear){
			
		if (strWhereHear=="Magazine" || strWhereHear=="Newspaper" || 
			strWhereHear=="Internet Search Engine" || strWhereHear== "Website Referral" ||
			strWhereHear=="Hobsons Guide" ||
			strWhereHear=="Exhibitions / Conferences"){				
			
				alert("Please specify the " + strWhereHear);
				if(document.getElementById("wherehear").style.display != '')
				{
					document.getElementById("wherehear").style.display='';
				}
				objForm.txtWhereHear.select();
				objForm.txtWhereHear.focus();
		}
		else if (strWhereHear=="Other"){			
				alert("Please specify " + strWhereHear);
				if(document.getElementById("wherehear").style.display != '')
				{
					document.getElementById("wherehear").style.display='';
				}
				objForm.txtWhereHear.select();
				objForm.txtWhereHear.focus();
		}
		else
		{
			objForm.txtWhereHear.value="";
			document.getElementById("wherehear").style.display='none';
		}
		
		
		
	} 
	/*=============================================================================
	Function:	fnValidateEmailFriend()
	Purpose:	Validates the form fields of the forward_url_to_friend.asp form
	Parameters:	none
	Returns:	none
	Author:		Shefali Adlakha Joshi(12/06/2008)
============================================================================= */
	

function fnValidateEmailFriend()
	{
		var blnSubmit = true;
		if (document.getElementById("txtFriendName").value == "") 
		{
			alert('Please enter the name of your friend');
			document.getElementById("txtFriendName").focus();
			blnSubmit=false;
		}
		else if (document.getElementById("txtFriendEmail").value == "") 
		{
			alert('Please enter the email id of your friend');
			document.getElementById("txtFriendEmail").focus();
			blnSubmit=false;
		}
		else if (!emailcheck(document.getElementById("txtFriendEmail").value)) 
		{
			document.getElementById("txtFriendEmail").select();
			document.getElementById("txtFriendEmail").focus();
			blnSubmit=false;
		}
		else if (document.getElementById("txtYourName").value == "") 
		{
			alert('Please enter your name');
			document.getElementById("txtYourName").focus();
			blnSubmit=false;
		}
		else if (document.getElementById("txtYourEmail").value == "") 
		{
			alert('Please enter your email id');
			document.getElementById("txtYourEmail").focus();
			blnSubmit=false;
		}
		else if (!emailcheck(document.getElementById("txtYourEmail").value)) 
		{
			document.getElementById("txtYourEmail").select();
			document.getElementById("txtYourEmail").focus();
			blnSubmit=false;
		}
		if(blnSubmit == true){
		document.frmEmailFriend.submit();
		
		}
		
		
	}

//-->