<!-- Javascript adapted by serge@antor.com for Dubai Tourism Marketing Form --!>
<!-- with thanks to The JavaScript Source http://javascript.internet.com for some useful tips and examples -->

<!-- Begin

function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}


function checkForm(inForm) {
    var msg;
    var empty_fields = "";
    var errors = "";
/***	optwin = window.open("", "opt", "resizable,scrollbars,status,width=625,height=400");
	var d = optwin.document;    // variable used to save typing! 
***/


    // Loop through the elements of the form, looking for all 
    // elements that have no property options defined 
    // Put together error messages for fields that are wrong.
		
    for(var i = 0; i < inForm.length; i++) {
        var e = inForm.elements[i];
        if ((e.type == "text") || (e.type == "textarea")) {
            // check if specific fields are missing
			if ((e.name == "realname") && ((e.value == null) || (e.value == "") || isblank(e.value))) {
				empty_fields += "\n          " + "Please input your Name";
				continue;
			}
			if (e.name == "Email_Address") {
				if ((e.value == null) || (e.value == "") || isblank(e.value)) {
					empty_fields += "\n          " + "Please input your Email address";
					continue;
				}
			}
			if ((e.name == "Street") && ((e.value == null) || (e.value == "") || isblank(e.value))) {
				empty_fields += "\n          " + "Please input your Street (address)";
				continue;
			}
			if ((e.name == "Town") && ((e.value == null) || (e.value == "") || isblank(e.value))) {
				empty_fields += "\n          " + "Please input your Town (address)";
				continue;
			}
			if ((e.name == "County") && ((e.value == null) || (e.value == "") || isblank(e.value))) {
				empty_fields += "\n          " + "Please input your County / State (address)";
				continue;
			}
			if ((e.name == "Country") && ((e.value == null) || (e.value == "") || isblank(e.value))) {
				empty_fields += "\n          " + "Please input your Country (address)";
				continue;
			}
			if ((e.name == "Postcode") && ((e.value == null) || (e.value == "") || isblank(e.value))) {
				empty_fields += "\n          " + "Please input your Zip / Postcode";
				continue;
			}

		}

        if (e.type == "select-one") {
			// scan through all options[]
			for (var j = 0; j < e.options.length; j++) {

				// check for title errors
				if ((e.name == "Sendto") && (e.options[j].selected)) {
					if (e.options[j].value == "select") {
						empty_fields += "\n          " + "Please select your nearest Luxembourg Tourist Office";
						continue;
					}
				}
			}
		}
	}
    // Now, if there were any errors, then display the messages, and
    // return true to prevent the form from being submitted.  Otherwise
    // return false
    if (!empty_fields && !errors) return true;


    msg  = "______________________________________________________\n\n"
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "Please correct these error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
        msg += "" + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}



// End -->
