function getSelectedIndex(what) {
        oSel=document.getElementById(what);
        oOtherHidden=document.getElementById('sourceOtherSelected');
        oOtherBox=document.getElementById('source_specified_id');
        if(oSel.selectedIndex == (oSel.options.length - 1) ) {
                oOtherHidden.value=1;
                oOtherBox.style.display='block';
                oOtherBox.name='source_dropdown';
                oSel.name='source_inactive';
        } else {
                oOtherHidden.value=0;
                oOtherBox.style.display='none';
                oOtherBox.name='source_specified';
                oSel.name='source_dropdown';
        }
}

jQuery.metadata.setType("attr", "validate");

jQuery.noConflict();
jQuery(document).ready(function($){
//--------------------------
/*
$.validator.setDefaults({
    submitHandler: function() {
        //alert("Thank you!");
        $("#enquiriesForm input#isOK").val('1');
        $("#enquiriesForm").submit();
    }
});
*/

$("input").click(function() {
    $(this).select();
});

//show asterisks
var arr = [ "emailme", "callme", "postme" ];
jQuery.each(arr, function() {
    var chkbox = this;
    $("#"+chkbox+"_checkbox_id").click(function() {
        if(this.checked) {
            $("."+chkbox+"_required").after('<span class="'+chkbox+'_star" style="color:red">*</span>');
        } else {
            $("."+chkbox+"_star").replaceWith('');
        }
    })
});

$("#enquiriesForm").validate({
    rules: {
        title:          "required",
        firstname:      "required",
        lastname:       "required",
        email: {
            required: "#emailme_checkbox_id:checked",
            email: true
        },
        phone: {
            required: "#callme_checkbox_id:checked"
        },
        country: {
            required: "#postme_checkbox_id:checked"
        },
        postcode: {
            required: "#postme_checkbox_id:checked"
        },
        address1: {
            required: "#postme_checkbox_id:checked"
        },
        city: {
            required: "#postme_checkbox_id:checked"
        },
        hearabout: {
            required: true
        },
        /*
        hearabout_specify: {
            required: true
        },
        */
        legal:         "required",
        properties:    "required"
    },
    messages: {
        title:          "X",
        firstname:      "X",
        lastname:       "X",
        email:          "X",
        country:        "X",
        postcode:       "X",
        address1:       "X",
        city:           "X",
        phone:          "X",
        legal:          "X",
        hearabout:      "X",
        hearabout_specify:      "X",
        howtocontactyou:    "X",
        emailme_checkbox_id:    "",
        other:          "" ,
        properties:     "X"
    }
    
});


//--------------------------
});
