function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

$(document).ready(function(){
	$("input:radio").attr("checked", false); 
	prop = '';
	prop2 = '';
	
	
	x_durationlist(prop2,prop,cb_durationlist);	
	document.getElementById('centreselect').selectedIndex =0;
	document.getElementById('centreselect').disabled=true;
	$("#program").attr("disabled", true);
	$('#duration').bind('load', function() {
		$("#duration").attr("disabled", true);
	});

	$("#duration").change(function () {
	
	
	});	
	
	
});
function medicalclick(prop){
		if(document.applynow.medicoption.checked == true){
			document.getElementById('totalhidden').value = ( document.getElementById('totalhidden').value * 1 ) + ( document.getElementById('medicalhidden').value * 1);
			document.getElementById('total').innerHTML = 'RM '+ document.getElementById('totalhidden').value;	
						formatNumber(document.getElementById('total'));
		}
		if(document.applynow.medicoption.checked == false){
			document.getElementById('totalhidden').value = ( document.getElementById('totalhidden').value * 1 ) - ( document.getElementById('medicalhidden').value * 1);
			document.getElementById('total').innerHTML = 'RM '+ document.getElementById('totalhidden').value;	
						formatNumber(document.getElementById('total'));
		}	
}
function apply_citizen(prop){
	
	if(prop == 'yes'){	
			
			document.applynow.centre.selectedIndex =0;
			
			//document.getElementById("malaysia").style.display = 'block';	
			//document.getElementById("malaysia").removeAttribute('style');	
			$('#malaysia').removeAttr("style");
			document.getElementById("notmalaysia").style.display = 'none';
			document.getElementById('programprice').innerHTML = 'RM 0.00';
			document.getElementById('notmalaysiaregistrationprice').value = '0.00';
			document.getElementById('lforprice').innerHTML = 'RM 0.00';
			document.getElementById('placementtestpricehidden').value = '0.00';
			document.getElementById('placementtestprice').innerHTML = 'RM 0.00';
			document.getElementById('malaysiaregistrationprice').value = '0.00';
			document.getElementById('lmyprice').innerHTML = 'RM 0.00';			
			document.getElementById("monthciep").style.display = 'none';	
			//document.getElementById("placementtest").style.display = 'block';
			//document.getElementById("placementtest").removeAttribute('style');	
			$('#placementtest').removeAttr("style");
			//document.getElementById("medical").setAttribute( "style" , "" );		
			//document.getElementById("medical").style.display = 'none';	
			$('#medical').removeAttr("style");
			document.getElementById("stationary").setAttribute( "style" , "" );		
			document.getElementById("stationary").style.display = 'none';			
			totalrm = ( document.getElementById('malaysiaregistrationprice').value * 1) + (document.getElementById('placementtestpricehidden').value * 1);
			document.getElementById('total').innerHTML = 'RM'+ totalrm;
			document.getElementById('totalhidden').value =  ( document.getElementById('malaysiaregistrationprice').value * 1) + (document.getElementById('placementtestpricehidden').value * 1);
			formatNumber(document.getElementById('total'));
			$("#medicoption").attr("checked", false); 
					document.getElementById('centreselect').disabled=false;
			$("#program").attr("disabled", true); 
			document.applynow.program.selectedIndex =0;
			$("#duration").attr("disabled", true);
			document.getElementById('duration').selectedIndex =0;
		
	}
	if(prop == 'no'){	
			document.applynow.centre.selectedIndex =0;
			document.getElementById("malaysia").style.display = 'none';	
			//document.getElementById("notmalaysia").removeAttribute('style');	
			$('#notmalaysia').removeAttr("style");
			document.getElementById('programprice').innerHTML = 'RM 0.00';
			document.getElementById('notmalaysiaregistrationprice').value = '0.00';
			document.getElementById('lforprice').innerHTML = 'RM 0.00';
			document.getElementById('placementtestpricehidden').value = '0.00';
			document.getElementById('placementtestprice').innerHTML = 'RM 0.00';
			document.getElementById('malaysiaregistrationprice').value = '0.00';
			document.getElementById('lmyprice').innerHTML = 'RM 0.00';			
			document.getElementById("monthciep").style.display = 'none';				
			//document.getElementById("placementtest").style.display = 'block';	
			$('#placementtest').removeAttr("style");
			document.getElementById("placementtest").removeAttribute('style');
			//document.getElementById("medical").style.display = 'block';	
			//document.getElementById("medical").removeAttribute('style');	
			$('#medical').removeAttr("style");
			document.getElementById("stationary").setAttribute( "style" , "" );		
			document.getElementById("stationary").style.display = 'none';			
			totalrm = ( document.getElementById('notmalaysiaregistrationprice').value * 1) + (document.getElementById('placementtestpricehidden').value * 1);
			document.getElementById('total').innerHTML = 'RM'+ totalrm;
			document.getElementById('totalhidden').value = ( document.getElementById('notmalaysiaregistrationprice').value * 1) + (document.getElementById('placementtestpricehidden').value * 1);
			$("#medicoption").attr("checked", false); 
			formatNumber(document.getElementById('total'));
					document.getElementById('centreselect').disabled=false;
			$("#program").attr("disabled", true); 
			document.applynow.program.selectedIndex =0;
			$("#duration").attr("disabled", true);
			document.getElementById('duration').selectedIndex =0;

	}

}
function cb_proglist(result){
	if(result != ''){
		document.getElementById('centreselect').disabled=false;
		document.getElementById('divprogram').innerHTML = result;
		document.getElementById('program').disabled=false;
		$('#loading').remove();
	}
}
function changemonth(prop){
	document.applynow.duration.selectedIndex =0;	
	document.getElementById('applysubmit').disabled = true;	
	
	document.getElementById('totalhidden').value = ( document.getElementById('totalhidden').value * 1 ) - ( document.getElementById('programpricehidden').value * 1 ) - ( document.getElementById('stationaryhidden').value * 1 );
	document.getElementById('total').innerHTML = 'RM '+ document.getElementById('totalhidden').value + '.00';
	
	document.getElementById('programprice').innerHTML = 'RM 0.00';
	document.getElementById('programpricehidden').value = '0.00';
	
	document.getElementById('stationarylabel').innerHTML = 'RM 0.00';
	document.getElementById('stationaryhidden').value = '0.00';	
}
function startyear(prop){
	cb_msg_loading();
	// populate new month list
	document.applynow.duration.selectedIndex =0;	
	document.getElementById('applysubmit').disabled = true;	
	
	document.getElementById('totalhidden').value = ( document.getElementById('totalhidden').value * 1 ) - ( document.getElementById('programpricehidden').value * 1 );
	document.getElementById('total').innerHTML = 'RM '+ document.getElementById('totalhidden').value + '.00';
	
	document.getElementById('programprice').innerHTML = 'RM 0.00';
	document.getElementById('programpricehidden').value = '0.00';

	x_startmonth(prop.value,cb_startmonth);
}
function cb_startmonth(result){
	if(result != ''){
		document.getElementById('startmonth').innerHTML = result;
		$('#loading').remove();
	}
	
}
function cb_calculate(result){
	document.getElementById('total').innerHTML = result;
	document.getElementById('totalhidden').value = result;
}
function applyduration(prop){

	cb_msg_loading();
	if(document.applynow.yes.checked == true){
		centre = document.getElementById('centreselect').value;
		program = document.getElementById('program').value;
		monthciepselect = document.getElementById('monthciepselect').value;
		yearciep = document.getElementById('yearciep').value;
		x_applyduration(prop,'yes',centre,program,monthciepselect,yearciep,cb_applyduration);
		
	}
	if(document.applynow.no.checked == true){
		centre = document.getElementById('centreselect').value;
		program = document.getElementById('program').value;
		monthciepselect = document.getElementById('monthciepselect').value;
		yearciep = document.getElementById('yearciep').value;
		
		x_applyduration(prop,'no',centre,program,monthciepselect,yearciep,cb_applyduration);
		
	}
	
}

function cb_durationlist(result){
	$('#duration').remove();
	if(result != ''){
		
		document.getElementById('divduration').innerHTML = result;
		$('#loading').remove();
	}else{
		
	
	}
}
function cb_register(result){
	var ca = result.split(',');
	
	if(document.getElementById('yes').checked == true){
		
		document.getElementById('malaysiaregistrationprice').value = ca[0];
		document.getElementById('lmyprice').innerHTML = ca[0];
		formatNumber(document.getElementById('lmyprice'));
	}
	if(document.getElementById('no').checked == true){
		document.getElementById('notmalaysiaregistrationprice').value = ca[0];
		document.getElementById('lforprice').innerHTML = ca[0];
		formatNumber(document.getElementById('lforprice'));
	}
		document.getElementById('placementtestpricehidden').value = ca[1];
		document.getElementById('placementtestprice').innerHTML = ca[1];
		formatNumber(document.getElementById('placementtestprice'));
		if(document.applynow.yes.checked == true){		
			var price = document.getElementById('malaysiaregistrationprice').value;
			var placementtest = document.getElementById('placementtestpricehidden').value;
			
			totalase =( price * 1 ) + ( placementtest * 1) ;	
			document.getElementById('total').innerHTML = 'RM'+ totalase;
			document.getElementById('totalhidden').value = totalase;
		}
		if(document.applynow.no.checked == true){
			var price = document.getElementById('notmalaysiaregistrationprice').value;
			var placementtest = document.getElementById('placementtestpricehidden').value;

			if(document.applynow.medicoption.checked == true){
				totalase = ( price * 1 ) + ( placementtest * 1) + ( document.getElementById('medicalhidden').value * 1);	
				document.getElementById('total').innerHTML = 'RM'+ totalase;
				document.getElementById('totalhidden').value = totalase;
			}
			if(document.applynow.medicoption.checked == false){
				totalase = ( price * 1 ) + ( placementtest * 1);	
				document.getElementById('total').innerHTML = 'RM'+ totalase;
				document.getElementById('totalhidden').value = totalase;

			}				
		}
	$('#loading').remove();
//	alert(document.getElementById('yes').checked);
}
function applycentre(prop){
	if(prop != '') {
		document.getElementById('program').disabled=false;
			type = 'yes';
		if(document.getElementById('yes').checked == true){
			type = 'yes';
		}
		if(document.getElementById('no').checked == true){
			type = 'no';
		}
		if( document.applynow.duration.value > 0 ){
			applyduration(document.applynow.duration.value);
		}
			
		cb_msg_loading();
		if( $('#hep-apply-now').length > 0 ){
		
			var centreselect = $('#centreselect').val();
			x_proglist('hep-apply-now',centreselect,cb_proglist);

			x_register(type,prop,cb_register);		
		}
		if( $('#apply-now').length > 0 ){
			var centreselect = $('#centreselect').val();
			x_proglist('apply-now',centreselect,cb_proglist);

			x_register(type,prop,cb_register);		
		}
		
	}
	if(prop == '' ){
		
		document.getElementById('program').disabled = true;
		document.applynow.program.selectedIndex =0;
		document.getElementById('duration').disabled = true;
		document.applynow.duration.selectedIndex =0;
		document.getElementById('applysubmit').disabled = true;
		document.getElementById('programprice').innerHTML = 'RM 0.00';
		document.getElementById('programpricehidden').value = '0.00';
		document.getElementById('stationarylabel').innerHTML = 'RM 0.00';
		document.getElementById('stationaryhidden').value = '0.00';
		
		document.getElementById('malaysiaregistrationprice').value = '0.00';
		document.getElementById('lmyprice').innerHTML = 'RM 0.00';
		
		
		document.getElementById('notmalaysiaregistrationprice').value = '0.00';
		document.getElementById('lforprice').innerHTML = 'RM 0.00';
		$('#monthciep').css("display","none");
		$('#monthbox').empty();	
		if(document.applynow.yes.checked == true){		
			var price = document.getElementById('malaysiaregistrationprice').value;
			var placementtest = document.getElementById('placementtestpricehidden').value;
			$("#medicoption").attr("checked", false); 
			totalase =( price * 1 ) + ( placementtest * 1) ;	
			document.getElementById('total').innerHTML = 'RM'+ totalase;
			document.getElementById('totalhidden').value = totalase;
		}
		if(document.applynow.no.checked == true){
			var price = document.getElementById('notmalaysiaregistrationprice').value;
			var placementtest = document.getElementById('placementtestpricehidden').value;
			var medical = document.getElementById('medicalhidden').value;
			totalase = ( price * 1 ) + ( placementtest * 1) + ( medical * 1);	
			document.getElementById('total').innerHTML = 'RM'+ totalase;
			document.getElementById('totalhidden').value = totalase;
			
		}		
	}
	
}
function applyprogram(prop){
	// prop = programme name

	document.applynow.duration.selectedIndex =0;
	document.getElementById('duration').disabled = true;
	document.getElementById('programprice').innerHTML = 'RM 0.00';
	document.getElementById('programpricehidden').value = '0.00';
	document.getElementById('applysubmit').disabled = true;


	if(document.applynow.yes.checked == true){	

		var price = document.getElementById('malaysiaregistrationprice').value;
		var placementtest = document.getElementById('placementtestpricehidden').value;

		totalase =( price * 1 ) + ( placementtest * 1);	
		document.getElementById('total').innerHTML = 'RM'+ totalase;
		document.getElementById('totalhidden').value = totalase;
	}
	if(document.applynow.no.checked == true){
		var price = document.getElementById('notmalaysiaregistrationprice').value;
		var placementtest = document.getElementById('placementtestpricehidden').value;
		var medical = document.getElementById('medicalhidden').value;			

		totalase =( price * 1 ) + ( placementtest * 1) + ( medical * 1 );	
		document.getElementById('total').innerHTML = 'RM'+ totalase;
		document.getElementById('totalhidden').value = totalase;
	}

	
	cb_msg_loading();
	if(document.applynow.program.selectedIndex == 1){
		$('#monthbox').empty();
		x_ciep_schedule(prop,cb_ciep_schedule);
		var prop2 = $('input[name=citizen]:checked').val();
		x_durationlist(prop2,prop,cb_durationlist);
		
	}
	if(document.applynow.program.selectedIndex == 2){
		$('#monthbox').empty();
		x_ciep_schedule(prop,cb_ciep_schedule);
		var prop2 = $('input[name=citizen]:checked').val();
		x_durationlist(prop2,prop,cb_durationlist);
	}
	if(document.applynow.program.selectedIndex == 3){
		$('#monthbox').empty();	
		x_ciep_schedule(prop,cb_ciep_schedule);
		var prop2 = $('input[name=citizen]:checked').val();
		
		x_durationlist(prop2,prop,cb_durationlist);
		
	}	
	if(document.applynow.program.selectedIndex == 0){
		document.getElementById('stationarylabel').innerHTML = 'RM 0.00';
		document.getElementById('stationaryhidden').value = '0.00';	
		$('#monthciep').css("display","none");
		$('#monthbox').empty();
	}
	
}
function cb_ciep_schedule(result){
	
	document.getElementById('monthbox').innerHTML = result;
	$('#monthciep').removeAttr("style");
}
function cb_applyduration(result){
	
	if(result)	{
		var ca = result.split('~~|~~');
		
		document.getElementById("stationary").style.display = 'block';	
		document.getElementById("stationary").removeAttribute('style');	
		document.getElementById("stationaryhidden").value = ca[0];
		document.getElementById("stationaryname").innerHTML = ca[1];
		document.getElementById("stationarylabel").innerHTML = ca[0];
		formatNumber(document.getElementById('stationarylabel'));
		document.getElementById('programprice').innerHTML = ca[2];
		formatNumber(document.getElementById('programprice'));
		document.getElementById('programpricehidden').value = ca[2];
		
		if(document.applynow.yes.checked == true){
			var programprice = document.getElementById('programpricehidden').value;
			var price = document.getElementById('malaysiaregistrationprice').value;
			var placementtest = document.getElementById('placementtestpricehidden').value;
			
			var stationary = document.getElementById('stationaryhidden').value;

			if( document.applynow.centre.selectedIndex == 0){
				totalase =( price * 1 ) + ( placementtest * 1);	
			}
			if( document.applynow.centre.selectedIndex > 0 ){
				totalase =( price * 1 ) + ( programprice * 1 ) + ( placementtest * 1) +  ( stationary * 1);
			}

			document.getElementById('total').innerHTML = 'RM'+ totalase;
			document.getElementById('totalhidden').value = totalase;
			formatNumber(document.getElementById('total'));

		}
		if(document.applynow.no.checked == true) {
			var programprice = document.getElementById('programpricehidden').value;
			var price = document.getElementById('notmalaysiaregistrationprice').value;
			var placementtest = document.getElementById('placementtestpricehidden').value;
			var medical = document.getElementById('medicalhidden').value;
			var stationary = document.getElementById('stationaryhidden').value;

			if( document.applynow.centre.selectedIndex == 0){
				if(document.applynow.medicoption.checked == true){
					totalase =( price * 1 ) + ( placementtest * 1) + ( medical * 1);					
				}
				if(document.applynow.medicoption.checked == false){
					totalase = ( price * 1 ) + ( placementtest * 1);					
				}			
			}
			if( document.applynow.centre.selectedIndex > 0 ){
				if(document.applynow.medicoption.checked == true){
					totalase =( price * 1 ) + ( programprice * 1 ) + ( placementtest * 1) + ( medical * 1) + ( stationary * 1);
					
				}
				if(document.applynow.medicoption.checked == false){
					totalase =( price * 1 ) + ( programprice * 1 ) + ( placementtest * 1)  + ( stationary * 1);
					
				}
			}

			
			document.getElementById('total').innerHTML = 'RM'+ 	totalase;
			document.getElementById('totalhidden').value = totalase;
			formatNumber(document.getElementById('total'));
			
			
		}
		if(	document.applynow.duration.selectedIndex == 0 ) document.getElementById('applysubmit').disabled = true;
		if(	document.applynow.duration.selectedIndex != 0 ) document.getElementById('applysubmit').disabled = false;
	}
	$('#loading').remove();
}
// msg
function cb_msg_loading()
{


	if ($('#loading').length < 1) {
		parentObj = document.getElementById( 'applynow' );
		mynewparagraph=document.createElement('div');
		mynewparagraph.setAttribute( "id" , "loading" );
		parentObj.appendChild( mynewparagraph ) ;

		document.getElementById("loading").innerHTML = 'Loading... Please wait.';
	}
}
function removeElement(divNum) {
  var oNodeToRemove = document.getElementById(divNum);
  oNodeToRemove.parentNode.removeChild(oNodeToRemove);  
}

// step one
function stepone(prop){
	scroll(0,0);
	if(prop == 1){
		
		document.getElementById("steponetable").style.display = 'block';	
		
		document.getElementById("steptwotable").style.display = 'none';
		
		document.getElementById("stepthreetable").style.display = 'none';

		document.getElementById("stepfourtable").style.display = 'none';
		
	}		
	if(prop == 2){
		var check = true;		

		
		if( document.getElementById("visastatusyes").checked == false && document.getElementById("visastatusno").checked == false){
				alert('Please select "Do you have a current Malaysian Visa?".');
				document.getElementById("visastatusyes").focus();
			check = false;
			return false;
		}

		if( document.getElementById("gendermale").checked == false && document.getElementById("genderfemale").checked == false){
				alert('Please select a gender.');
				document.getElementById("gendermale").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponename").value == ''){
				alert('Please type in your name.');
				document.getElementById("steponename").focus();
			check = false;
			return false;
		}		
		if( document.getElementById("steponeaddress").value == ''){
				alert('Please type in the address.');
				document.getElementById("steponeaddress").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponecity").value == '' ){
				alert('Please type in the City.');
				document.getElementById("steponecity").focus();
			check = false;
			return false;
		}
				
		if( document.getElementById("steponepostcode").value == '' ){
				alert('Please type in the Postal Code.');
				document.getElementById("steponepostcode").focus();
			check = false;
			return false;
		}		
		if( document.applynowstepone.steponestate.selectedIndex == ''){
				alert('Please select Country.');
				document.getElementById("steponestate").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponeemail").value == ""){
				alert('Please type in your email address.');
				document.getElementById("steponeemail").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponeemail").value != ""){
				var x = document.getElementById("steponeemail").value;
				var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (filter.test(x)){}
				else {alert('Incorrect email address');
				document.getElementById("steponeemail").focus();
			check = false;
			return false;
				}
		}		
		/*if( document.getElementById("steponeconfirmemail").value == ""){
				alert('Please type in your email address.');
				document.getElementById("steponeconfirmemail").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponeconfirmemail").value != ""){
				var x = document.getElementById("steponeconfirmemail").value;
				var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (filter.test(x)){}
				else {alert('Incorrect email address');
				document.getElementById("steponeconfirmemail").focus();
			check = false;
			return false;
				}
		}		
		if( document.getElementById("steponeemail").value != document.getElementById("steponeconfirmemail").value){
				alert('Email address not match.');
				document.getElementById("steponeconfirmemail").focus();
			check = false;
			return false;
		}		*/	
		if( document.getElementById("steponetel").value == ""){
				alert('Please type in your home telephone number.');
				document.getElementById("steponetel").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponetel").value != ""){
			var phone2 = /^(\+\d)*\s*(\(\d{1,4}\)\s*)*\d{1,4}(-{0,1}|\s{0,1})\d{1,4}(-{0,1}|\s{0,1})\d{1,4}$/; 
			var phone1 = document.getElementById("steponetel").value;
			if (phone1.match(phone2)) {
			} else {
				alert('Please type in a proper home telephone number.');
				document.getElementById("steponetel").focus();
				check = false;
				return false;
			}
		}

		if( document.getElementById("steponedobday").value == ""){
				alert('Please type in your  day of birth.');
				document.getElementById("steponedobday").focus();
			check = false;
			return false;
		}
		if( !IsNumeric(document.getElementById("steponedobday").value) ){
			alert('Please type in your day of birth.');
			document.getElementById("steponedobday").focus();
			check = false;
			return false;
		}	
		if( IsNumeric(document.getElementById("steponedobday").value) && document.getElementById("steponedobday").value > 31 ){
			alert('Please type in your birth day correctly.');
			document.getElementById("steponedobday").focus();
			check = false;
			return false;
		}			
		if( document.getElementById("steponedobmonth").value == ""){
				alert('Please type in your  month of birth.');
				document.getElementById("steponedobmonth").focus();
			check = false;
			return false;
		}
		if( !IsNumeric(document.getElementById("steponedobmonth").value) ){
			alert('Please type in your month of birth.');
			document.getElementById("steponedobmonth").focus();
			check = false;
			return false;
		}	
		if( IsNumeric(document.getElementById("steponedobmonth").value) && document.getElementById("steponedobmonth").value > 12 ){
			alert('Please type in your birth month correctly.');
			document.getElementById("steponedobmonth").focus();
			check = false;
			return false;
		}		
		if( document.getElementById("steponedobyear").value == ""){
				alert('Please type in your  year of birth.');
				document.getElementById("steponedobyear").focus();
			check = false;
			return false;
		}
		if( !IsNumeric(document.getElementById("steponedobyear").value) ){
			alert('Please type in your birth year correctly.');
			document.getElementById("steponedobyear").focus();
			check = false;
			return false;
		}
		if( IsNumeric(document.getElementById("steponedobyear").value) && document.getElementById("steponedobyear").value < 1900 ){
			alert('Please type in your birth year correctly.');
			document.getElementById("steponedobyear").focus();
			check = false;
			return false;
		}

		if( document.getElementById("steponework").value == ''){
				alert('Please type in your occupation.');
				document.getElementById("steponework").focus();
			check = false;
			return false;
		}
		if( document.getElementById("steponepassport").value == ''){
				alert('Please type in your I.C or Passport number.');
				document.getElementById("steponepassport").focus();
			check = false;
			return false;
		}

		if( document.getElementById("steponenatioanlity").value == ''){
				alert('Please select your Nationality.');
				document.getElementById("steponenatioanlity").focus();
			check = false;
			return false;
		}		
		//if( document.getElementById("steponephoto").value == ''){
				//alert('Please upload your recent passport photo.');
				//document.getElementById("steponephoto").focus();
			//check = false;
			//return false;
		//}		
 
		if(check){
		document.getElementById("steponetable").style.display = 'none';	
		
		document.getElementById("steptwotable").style.display = 'block';

		document.getElementById("stepthreetable").style.display = 'none';
		
		document.getElementById("stepfourtable").style.display = 'none';
		
		}else{
			return false;
			
		}
	}
	if(prop == 3){
		var checkthree = true;
		if( document.getElementById("steptwoname").value == ''){
				alert('Please type in contact person name.');
				document.getElementById("steptwoname").focus();
			check = false;
			return false;
		}		
		if( document.getElementById("steptworelationship").value == ''){
				alert('Please type in relationship field.');
				document.getElementById("steptworelationship").focus();
			check = false;
			return false;
		}		
		if( document.getElementById("steptwotel").value == ''){
				alert('Please type in contact person telephone number.');
				document.getElementById("steptwotel").focus();
			check = false;
			return false;
		}	
		if( document.getElementById("steptwotel").value != ""){
			var phone2 = /^(\+\d)*\s*(\(\d{1,4}\)\s*)*\d{1,4}(-{0,1}|\s{0,1})\d{1,4}(-{0,1}|\s{0,1})\d{1,4}$/; 
			var phone1 = document.getElementById("steptwotel").value;
			if (phone1.match(phone2)) {
			} else {
				alert('Please type in a proper person telephone number.');
				document.getElementById("steptwotel").focus();
				check = false;
				return false;
			}
		}

		
		if(checkthree){
			document.getElementById("steponetable").style.display = 'none';	
			
			document.getElementById("steptwotable").style.display = 'none';
	
			document.getElementById("stepthreetable").style.display = 'block';

			document.getElementById("stepfourtable").style.display = 'none';

		}
	
		
	}	
	if(prop == 4){
		var checkfour = true;
		if(checkfour){
			document.getElementById("steponetable").style.display = 'none';	
			
			document.getElementById("steptwotable").style.display = 'none';
	
			document.getElementById("stepthreetable").style.display = 'none';

			document.getElementById("stepfourtable").style.display = 'block';
			
		}
		if( document.getElementById("accommodationyes").checked == false && document.getElementById("accommodationno").checked == false){
				alert('Please select "Would you like ELS to help you find accommodation?".');
				document.getElementById("accommodationyes").focus();
			check = false;
			return false;
		}				
	}
	
}

function stepfieldghost(prop){
	if(prop){	
		if( prop.id == "visastatusyes") {
			document.getElementById('summary-visastatusyes').style.display = "inline";
			document.getElementById('summary-visastatusno').style.display = "none";
		}
		if( prop.id == "visastatusno") {
			document.getElementById('summary-visastatusyes').style.display = "none";
			document.getElementById('summary-visastatusno').style.display = "inline";
		}
		if( prop.id == "gendermale") {
			document.getElementById('summary-gendermale').style.display = "inline";
			document.getElementById('summary-genderfemale').style.display = "none";
		}
		if( prop.id == "genderfemale") {
			document.getElementById('summary-gendermale').style.display = "none";
			document.getElementById('summary-genderfemale').style.display = "inline";
		}		
		if( prop.id == "accommodationyes") {
			document.getElementById('summary-accommodationyes').style.display = "inline";
			document.getElementById('summary-accommodationno').style.display = "none";
		}
		if( prop.id == "accommodationno") {
			document.getElementById('summary-accommodationyes').style.display = "none";
			document.getElementById('summary-accommodationno').style.display = "inline";
		}			

		var divid = document.getElementById('summary-'+ prop.id);
		divid.innerHTML = prop.value;
	}
}

// step one check form
function steponecheck(){

}
// step three submit
function stepthree(){
	if(	document.getElementById("stepthreecondition").checked == true ){
		if(document.applynowstepone.stepthreefindout.selectedIndex == 0){
			alert('Please select "How did you find out about ELS Language Centres?"');
			document.getElementById("stepthreefindout").focus();
			check = false;
			return false;
			
		}		
		if(document.applynowstepone.stepthreefindout.selectedIndex != 0){
			document.getElementById("stepthreesubmit").disabled = false;
		}
	}
	if(	document.getElementById("stepthreecondition").checked == false ){
		document.getElementById("stepthreesubmit").disabled = true;
	}	
}

// step four submit
function stepfour(){
	var checkfour = true;
	if(	document.getElementById("declare").checked == false ){
		document.getElementById("stepfoursubmit").disabled = true;
		checkfour = false;
	}	
	if(	document.getElementById("understood").checked == false ){
		document.getElementById("stepfoursubmit").disabled = true;
		checkfour = false;
	}	
	if(	document.getElementById("owing").checked == false ){
		document.getElementById("stepfoursubmit").disabled = true;
		checkfour = false;
	}	
	if(	document.getElementById("acceptance").checked == false ){
		document.getElementById("stepfoursubmit").disabled = true;
		checkfour = false;
	}	
	if(checkfour){
		document.getElementById("stepfoursubmit").disabled = false;
	}
}
//function stepfour(prop){
	//if( prop != ''){
		//if( document.getElementById( 'steponephotopreview' )){
			//removeElement('steponephotopreview');			
		//}
		//propphoto = 'file:///'+ prop;
		//parentObj = document.getElementById( 'steponephotoplace' );
		//photo=document.createElement('img');
		//photo.setAttribute( "src" , propphoto );
		//photo.setAttribute( "id" , "steponephotopreview" );
		//parentObj.appendChild( photo );
	//}
//}
// step three how did you find out?
function stepthreefo(){
	if(document.applynowstepone.stepthreefindout.selectedIndex == 0){
		document.getElementById("stepthreesubmit").disabled = true;
		alert('Please select "How did you find out about ELS Language Centres?"');
		document.getElementById("stepthreefindout").focus();
		check = false;
		return false;		
	}
	if(document.applynowstepone.stepthreefindout.selectedIndex != 0 && document.getElementById("stepthreecondition").checked == true){
		document.getElementById("stepthreesubmit").disabled = false;
	}
}
// mredkj.com
function NumberFormat(num, inputDecimal)
{
this.VERSION = 'Number Format v1.5.4';
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-'; 
this.LEFT_PAREN = '('; 
this.RIGHT_PAREN = ')'; 
this.LEFT_OUTSIDE = 0; 
this.LEFT_INSIDE = 1;  
this.RIGHT_INSIDE = 2;  
this.RIGHT_OUTSIDE = 3;  
this.LEFT_DASH = 0; 
this.RIGHT_DASH = 1; 
this.PARENTHESIS = 2; 
this.NO_ROUNDING = -1 
this.num;
this.numOriginal;
this.hasSeparators = false;  
this.separatorValue;  
this.inputDecimalValue; 
this.decimalValue;  
this.negativeFormat; 
this.negativeRed; 
this.hasCurrency;  
this.currencyPosition;  
this.currencyValue;  
this.places;
this.roundToPlaces; 
this.truncate; 
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF; 
this.setSeparators = setSeparatorsNF; 
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF; 
this.setNegativeRed = setNegativeRedNF; 
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF; 
this.setCurrencyPosition = setCurrencyPositionNF; 
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.moveDecimalRight = moveDecimalRightNF;
this.moveDecimalLeft = moveDecimalLeftNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.expandExponential = expandExponentialNF;
this.getZeros = getZerosNF;
this.moveDecimalAsString = moveDecimalAsStringNF;
this.moveDecimal = moveDecimalNF;
this.addSeparators = addSeparatorsNF;
if (inputDecimal == null) {
this.setNumber(num, this.PERIOD);
} else {
this.setNumber(num, inputDecimal); 
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH); 
this.setNegativeRed(false); 
this.setCurrency(false); 
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num, inputDecimal)
{
if (inputDecimal != null) {
this.setInputDecimal(inputDecimal); 
}
this.numOriginal = num;
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.numOriginal);
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal) {
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
} else {
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p, tr)
{
this.roundToPlaces = !(p == this.NO_ROUNDING); 
this.truncate = (tr != null && tr); 
this.places = (p < 0) ? 0 : p; 
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}
function toFormattedNF()
{	
var pos;
var nNum = this.num; 
var nStr;            
var splitString = new Array(2);   
if (this.roundToPlaces) {
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum)); 
} else {
nStr = this.expandExponential(Math.abs(nNum)); 
}
if (this.hasSeparators) {
nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
} else {
nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue); 
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c0 = this.currencyValue;
} else if (this.currencyPosition == this.LEFT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0) {
nStr = '<font color="red">' + nStr + '</font>';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getZerosNF(places)
{
var extraZ = '';
var i;
for (i=0; i<places; i++) {
extraZ += '0';
}
return extraZ;
}
function expandExponentialNF(origVal)
{
if (isNaN(origVal)) return origVal;
var newVal = parseFloat(origVal) + ''; 
var eLoc = newVal.toLowerCase().indexOf('e');
if (eLoc != -1) {
var plusLoc = newVal.toLowerCase().indexOf('+');
var negLoc = newVal.toLowerCase().indexOf('-', eLoc); 
var justNumber = newVal.substring(0, eLoc);
if (negLoc != -1) {
var places = newVal.substring(negLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
} else {
if (plusLoc == -1) plusLoc = eLoc;
var places = newVal.substring(plusLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
}
newVal = justNumber;
}
return newVal;
} 
function moveDecimalRightNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, false);
} else {
newVal = this.moveDecimal(val, false, places);
}
return newVal;
}
function moveDecimalLeftNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, true);
} else {
newVal = this.moveDecimal(val, true, places);
}
return newVal;
}
function moveDecimalAsStringNF(val, left, places)
{
var spaces = (arguments.length < 3) ? this.places : places;
if (spaces <= 0) return val; 
var newVal = val + '';
var extraZ = this.getZeros(spaces);
var re1 = new RegExp('([0-9.]+)');
if (left) {
newVal = newVal.replace(re1, extraZ + '$1');
var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');		
newVal = newVal.replace(re2, '$1$2.$3');
} else {
var reArray = re1.exec(newVal); 
if (reArray != null) {
newVal = newVal.substring(0,reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length); 
}
var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
newVal = newVal.replace(re2, '$1$2$4.');
}
newVal = newVal.replace(/\.$/, ''); 
return newVal;
}
function moveDecimalNF(val, left, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimalAsString(val, left);
} else {
newVal = this.moveDecimalAsString(val, left, places);
}
return parseFloat(newVal);
}
function getRoundedNF(val)
{
val = this.moveDecimalRight(val);
if (this.truncate) {
val = val >= 0 ? Math.floor(val) : Math.ceil(val); 
} else {
val = Math.round(val);
}
val = this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val)
{
var i;
val = this.expandExponential(val);
if (this.places <= 0) return val; 
var decimalPos = val.indexOf('.');
if (decimalPos == -1) {
val += '.';
for (i=0; i<this.places; i++) {
val += '0';
}
} else {
var actualDecimals = (val.length - 1) - decimalPos;
var difference = this.places - actualDecimals;
for (i=0; i<difference; i++) {
val += '0';
}
}
return val;
}
function justNumberNF(val)
{
newVal = val + '';
var isPercentage = false;
if (newVal.indexOf('%') != -1) {
newVal = newVal.replace(/\%/g, '');
isPercentage = true; 
}
var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');	
newVal = newVal.replace(re, '');
var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
var treArray = tempRe.exec(newVal); 
if (treArray != null) {
var tempRight = newVal.substring(treArray.index + treArray[0].length); 
newVal = newVal.substring(0,treArray.index) + this.PERIOD + tempRight.replace(tempRe, ''); 
}
if (newVal.charAt(newVal.length - 1) == this.DASH ) {
newVal = newVal.substring(0, newVal.length - 1);
newVal = '-' + newVal;
}
else if (newVal.charAt(0) == this.LEFT_PAREN
&& newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
newVal = newVal.substring(1, newVal.length - 1);
newVal = '-' + newVal;
}
newVal = parseFloat(newVal);
if (!isFinite(newVal)) {
newVal = 0;
}
if (isPercentage) {
newVal = this.moveDecimalLeft(newVal, 2);
}
return newVal;
}
function formatNumber(prop)
{
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(prop.innerHTML); // obj.value is '-1000.247'
num.setPlaces('2', false);
num.setCurrencyValue('RM ');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
prop.innerHTML = num.toFormatted();

}