// Visa Centre Modules Javascript Code

			function mailinglist_subscribe_validate() {
				if(document.getElementById('mailinglist_first_name') && document.getElementById('mailinglist_last_name')) mailinglist_concat_name();
				if (document.getElementById("mailinglist_name").value == '' || document.getElementById("mailinglist_name").value == ' ' || document.getElementById("mailinglist_name").value == 'Name') {
					alert('You must enter your name');
				} else if (document.getElementById("mailinglist_email").value == '' || document.getElementById("mailinglist_email").value == 'Email') {
					alert('You must enter your email address');
				} else {
					return true;
				}
				return false;
			}
			function mailinglist_unsubscribe_validate() {
				if (document.getElementById("mailinglist_email").value == '' || document.getElementById("mailinglist_email").value == 'Email') {
					alert('You must enter your email address');
				} else {
					return true;
				}
				return false;
			}
			function mailinglist_concat_name() {
				document.getElementById('mailinglist_name').value = document.getElementById('mailinglist_first_name').value + ' ' + document.getElementById('mailinglist_last_name').value;
			}
			function migrationbureau_checkDateReference(theForm) {
				var status = true;
				if(status == true) status = migrationbureau_requiredDate(theForm);
				if(status == true) status = migrationbureau_requiredReference(theForm);
				return status;
			}

			function migrationbureau_requiredDate(theForm) {
				if (theForm.requireddate.value == "") {
					alert("Please enter the date to continue.");
					return false;
				} else {
					return true;
				}
			}

			function migrationbureau_requiredReference(theForm) {
				var countryCodes = new Array("GB","NL","NLR","D","ZA","NZ","OS","AU");
				var theReferenceNumber = theForm.requiredreference.value;
				
				var success = 0;
				
				for (var count = 0; count < countryCodes.length; count++) {
		
					var theirCountryCode = theReferenceNumber.substring(0,countryCodes[count].length).toUpperCase();
					
					if (theirCountryCode == countryCodes[count]) {
						success = 1;
					}
				}
				
				if (success == 0) {
					alert("You have entered an invalid reference number.");
					return false
				} else {
					return true;
				}
			}

			function migrationbureau_requiredName(theForm) {
				if (theForm.requiredname.value == "") {
					alert("Please enter your consultant's name to continue.");
					theForm.requiredname.focus();
					return false;
				} else {
					return true;
				}
			}

			function migrationbureau_requiredID(theForm) {
				if (theForm.required_applicationid.value == "") {
					alert("Please enter your customer # to continue.");
					theForm.required_applicationid.focus();
					return false;
				} else {
					return true;
				}
			}
            function migrationbureau_checkGoAheadForm() {
                if (document.getElementById('accept').checked == false) {
                    alert('You must accept the terms and conditions by ticking the box at the bottom of the page');
                    return false;
                } else if (document.getElementById('destination_country').value == '') {
                    alert('You must select your destination county');
                    return false;
                } else if (document.getElementById('location').value == '') {
                    alert('You must select the location of your agency');
                    return false;
                } else if (document.getElementById('email').value == '') {
                    alert('You must enter your email address');
                    return false;
                } else if (!isEmailAddressValid(document.getElementById('email').value)) {
                    alert('You must enter a valid email address');
                    return false;
                } else if (document.getElementById('client_first_name').value == '') {
                    alert('You must enter your first name');
                    return false;
                } else if (document.getElementById('client_last_name').value == '') {
                    alert('You must enter your last name');
                    return false;
                } else if (document.getElementById('client_address').value == '') {
                    alert('You must enter your address');
                    return false;
                } else if (document.getElementById('phone').value == '') {
                    alert('You must enter your contact telephone number');
                    return false;
                } else {
                    return true;
                }
            }
            function migrationbureau_checkGoAheadClientLoginForm(theForm) {
                if (theForm.name.value == "") {
                    alert("Please enter your name to continue.");
                    return false;
                }
                if (theForm.client_number.value == "") {
                    alert("Please enter your reference number to continue.");
                    return false;
                }

                var countryCodes = new Array("GB","NL","NLR","D","ZA","NZ","OS","AU");
                var theReferenceNumber = theForm.client_number.value;

                var success = 0;

                for (var count = 0; count < countryCodes.length; count++) {

                    var theirCountryCode = theReferenceNumber.substring(0,countryCodes[count].length).toUpperCase();

                    if (theirCountryCode == countryCodes[count]) {
                        success = 1;
                    }
                }

                if (success == 0) {
                    alert("You have entered an invalid reference number.");
                    return false
                }
            }			function search_check(url) {
				var search = document.getElementById("id_search_box").value;
				if(search != '' && search != 'Search...') {
					if(!document.getElementById("id_search_form")) {
						window.location.href = url + '?search=' + search;
					} else {
						document.getElementById("id_search_form").submit();
					}
				}
			}

			function search_enter(e, url) {
				if(window.event) { // IE
					keynum = e.keyCode;
				} else if(e.which) { // Netscape/Firefox/Opera
					keynum = e.which;
				}
				if(keynum == 13) search_check(url);
			}