function show_additional() {
	frm=document.apply_1;
	if ((frm.query_type.value == "a") || (frm.query_type.value == "b")) {
		toggleVisibility('additional','visible','visible','visible');
	} else {
		toggleVisibility('additional','hidden','hidden','hidden');
	}
}

function toggleVisibility(id, NNtype, IEtype, W3Ctype) {
	if (document.getElementById) {
		eval("document.getElementById(id).style.visibility = \"" + W3Ctype + "\"");
	} else {
		if (document.layers) {
			document.layers[id].visibility = NNtype;
		} else {
			if (document.all) {
				eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
			}
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function disableEnterKey(){
	if (window.event.keyCode == 13)
		window.event.keyCode = 0;
}


function checkAmount(){
	frm=document.apply_1;
	if(frm.app_loan_amount.value<0 || frm.app_loan_amount.value>4000000){
		alert("Amount should be more than"+" £ "+"0 and less than"+" £ "+"4,000,000")
		frm.app_loan_amount.select();
		return true;
	}
	return false;
}

function checkMonths(){
	frm=document.apply_1;
	if(frm.hlMonths.value>11){
		alert("Months should not be more than 11")
		frm.hlMonths.select();
		return true;
	}
	return false;
}


function fnValidate() {
	frm=document.apply_1;
	if(fnIsNull(frm.app_1_forename,LAST_NAME)) {
		return false;
	} else if(fnIsValidChar1(frm.app_1_forename,"First name is not valid name")) {
		return false;	
	} else if(fnIsNull(frm.app_1_surname,LAST_NAME)) {
		return false;
	} else if(fnIsValidChar1(frm.app_1_surname,"Last name is not a valid name")) {
		return false;
	} else if(fnIsNull(frm.app_home_number,TELEPHONE)) {
		return false;
	} else if(AllowNumeric(frm.app_home_number,VALID_TELEPHONE)) {
		return false;
	} else if(fnIsValidChar2(frm.app_home_number,VALID_TELEPHONE)) {
		return false;		
	} else if(fnIsNull(frm.app_email_address,VALID_EMAIL)) {
		return false;	
	} else if(fnIsQuotes(frm.app_email_address,VALID_EMAIL)) {
		return false;
	} else if(emailcheck(frm.app_email_address,VALID_EMAIL)) {
		return false;
	} else if(dropDownMenu(frm.query_type,QUERY_TYPE)) {
		return false;
	} else if ((frm.query_type.value == "a") || (frm.query_type.value == "b")) {
		if(fnIsNull(frm.app_cur_address_1,"Please Enter the House number and Street")) {
			return false;
		} else if(fnIsQuotes(frm.app_cur_address_1,"Please Enter the House number and Street")) {
			return false;
		} else if(fnIsNull(frm.app_cur_address_post_code,POST_CODE)) {
			return false;
		} else if(fnIsQuotes(frm.app_cur_address_post_code,"Postcode is not valid")) {
			return false;
		} else 	if(fnIsNull(frm.app_loan_amount,AMOUNT)) {
			return false;
		} else if(fnNumberOnly(frm.app_loan_amount,VALID_AMOUNT)) {
			return false;	
		} else if(fnIsValidChar2(frm.app_loan_amount,VALID_AMOUNT)) {
			return false;			
		} else if(checkAmount()) {
			return false;
		} else if(frm.chkConfirm.checked == false) {
			alert("Please confirm to have read Data Protection Information before submitting the loan application");
			return false;	
		} else {
			document.apply_1.action="/applicationform/form_handler.asp";
		}
	} else {
		document.apply_1.action="/includes/sendmail.asp";
	}
}


