﻿
(function ($) {
    $.fn.validationEngineLanguage = function () { };
    $.validationEngineLanguage = {
        newLang: function () {
            $.validationEngineLanguage.allRules =
                 	{ "required": {    			// Add your regex rules here, you can take telephone as an example
                 	    "regex": "none",
                 	    "alertText": "* Campo richiesto",
                 	    "alertTextCheckboxMultiple": "* Please select an option",
                 	    "alertTextCheckboxe": "* Campo Privacy  richiesto "
                 	},
                 	    "length": {
                 	        "regex": "none",
                 	        "alertText": "* Tra ",
                 	        "alertText2": " e ",
                 	        "alertText3": " caratteri consentiti"
                 	    },
                 	    "maxCheckbox": {
                 	        "regex": "none",
                 	        "alertText": "* Checks allowed Exceeded"
                 	    },
                 	    "minCheckbox": {
                 	        "regex": "none",
                 	        "alertText": "* Please select ",
                 	        "alertText2": " options"
                 	    },
                 	    "confirm": {
                 	        "regex": "none",
                 	        "alertText": "* Your field is not matching"
                 	    },

                 	    "Subject": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "* Subject"
                 	    },

                 	    "telephone": {
                 	        "regex": "/^[0-9\-\(\)\ ]+$/",
                 	        "alertText": "* Numero telefonico non valido"
                 	    },
                 	    "lastname": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "* Cognome richiesto"
                 	    },
                 	    "firstname": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "* Nome richiesto"
                 	    },


                 	    "Company": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "*Nome Azienda richiesto"
                 	    },
                 	    "address": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "* Indirizzo richiesto"
                 	    },

                 	    "Country": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "*Nome Azienda richiesto"
                 	    },

                 	    "City": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "* Citt&agrave; richiesta"
                 	    },
                 	    "pcode": {
                 	        "regex": "/^[0-9\-\(\)\ ]+$/",
                 	        "alertText": "* Codice postale non valido"
                 	    },
                 	    "email": {
                 	        "regex": "/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/",
                 	        "alertText": "* Indirizzo email non valido"
                 	    },
                 	    "txtdate": {
                 	        "regex": "/^[0-9]{4}\-\[0-9]{1,2}\-\[0-9]{1,2}$/",
                 	        "alertText": "* Invalid date, must be in YYYY-MM-DD format"
                 	    },
                 	  
                 	    "onlyNumber": {
                 	        "regex": "/^[0-9\ ]+$/",
                 	        "alertText": "* Numbers only"
                 	    },
                 	    "noSpecialCaracters": {
                 	        "regex": "/^[0-9a-zA-Z]+$/",
                 	        "alertText": "* No special caracters allowed"
                 	    },
                 	    "ajaxUser": {
                 	        /*	"file":"validateUser.php",
                 	        "file": "http://www..com",*/

                 	        "extraData": "name=eric",
                 	        "alertTextOk": "* This user is available",
                 	        "alertTextLoad": "* Loading, please wait",
                 	        "alertText": "* This user is already taken"
                 	    },
                 	    "ajaxName": {

                 	        /*	"file":"validateUser.php",*/
                 	        "file": "http://www..com",
                 	        "alertText": "* This name is already taken",
                 	        "alertTextOk": "* This name is available",
                 	        "alertTextLoad": "* Loading, please wait"
                 	    },
                 	    "onlyLetter": {
                 	        "regex": "/^[a-zA-Z\ \']+$/",
                 	        "alertText": "* Solo lettere consentite"
                 	    }


                 	}

        }

    }

})(jQuery);

$(document).ready(function () {
    $.validationEngineLanguage.newLang()
});

$(document).ready(function () {

    $("#BookingformID").validationEngine({
        success: function () {
            // $("#divEmailSent").validationEngine({ returnIsValid: false })
            //alert($("#formID").validationEngine({ returnIsValid: true }));
            $("#loading").show();
            document.getelementbyid('BookSubmitForm').click();
            // setTimeout("ajaxSend();",5000);
        },
        failure: function () {

            $("#failure").validationEngine({ returnIsValid: false })
            //alert($("#formID").validationEngine({ returnIsValid: false }));
        }
    });
    // CLOSE ALL OPEN PROMPTS
});

