// JavaScript Document

(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 Obbligatorio",
						"alertTextCheckboxMultiple":"* Seleziona un'opzione",
						"alertTextCheckboxe":"* Questa checkbox è obbligatoria"},
					"length":{
						"regex":"none",
						"alertText":"*Between ",
						"alertText2":" and ",
						"alertText3": " characters allowed"},
					"maxCheckbox":{
						"regex":"none",
						"alertText":"* Checks allowed Exceeded"},	
					"minCheckbox":{
						"regex":"none",
						"alertText":"* Please select ",
						"alertText2":" options"},	
					"confirm":{
						"regex":"none",
						"alertText":"* Your field is not matching"},		
					"telephone":{
						"regex":"/^[0-9\-\(\)\ ]+$/",
						"alertText":"* Numero di telefono non valido"},	
					"email":{
						"regex":"/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/",
						"alertText":"* Indirizzo email non valido"},	
					"date":{
                         "regex":"/^[0-9]{2}\-\[0-9]{2}\-\[0-9]{4}$/",
                         "alertText":"* Data non valida, deve essere nel formato GG-MM-AAAA "},
					"onlyNumber":{
						"regex":"/^[0-9\ ]+$/",
						"alertText":"* Campo numerico"},	
					"noSpecialCaracters":{
						"regex":"/^[0-9a-zA-Z]+$/",
						"alertText":"* Non sono permessi caratteri speciali"},	
					"ajaxUser":{
						"file":"validateUser.php",
						"extraData":"name=eric",
						"alertTextOk":"* This user is available",	
						"alertTextLoad":"* Loading, please wait",
						"alertText":"* This user is already taken"},	
					"ajaxName":{
						"file":"validateUser.php",
						"alertText":"* This name is already taken",
						"alertTextOk":"* This name is available",	
						"alertTextLoad":"* Loading, please wait"},		
					"onlyLetter":{
						"regex":"/^[a-zA-Z\ \']+$/",
						"alertText":"* Letters only"},
					"validate2fields":{
    					"nname":"validate2fields",
    					"alertText":"* You must have a firstname and a lastname"},	
          "codiceconvenzione":{
              "nname":"validateconvenzione",
              "alertText":"* E' necessario specificare il codice della convenzione"}
					}	
					
		}
	}
})(jQuery);

$(document).ready(function() {	
	$.validationEngineLanguage.newLang()
});

function validateconvenzione(){
   if($("#categoriavendita").val() =="") return true;
   
   if ($("#codiceconvenzione").val() == 'C1' || $("#codiceconvenzione").val() == 'C2' || $("#codiceconvenzione").val() == 'C3'
    || $("#codiceconvenzione").val() == 'c1' || $("#codiceconvenzione").val() == 'c2' || $("#codiceconvenzione").val() == 'c3')
    return true;
   
   return false;
  }
