//--------------------------- Per la pagina contatti -------------------------------- //function disableTextArea(elementId) { // var textarea = document.getElementById(elementId); // if (textarea.disabled == false) { // se e' abilitato // textarea.disabled = true; // textarea.value = ''; // } //} // //function enableTextArea(elementId) { // var textarea = document.getElementById(elementId); // if (textarea.disabled == true) { // se e' disabilitato // textarea.disabled = false; // textarea.value = ''; // } //} // Nascondere - Mostrare DIV //function hideDiv(elementId) { // if (document.getElementById) { // DOM3 = IE5, NS6 // document.getElementById(elementId).style.visibility = 'hidden'; // document.getElementById(elementId).style.display = 'none'; // } //} // //function showDiv(elementId) { // if (document.getElementById) { // document.getElementById(elementId).style.visibility = 'visible'; // document.getElementById(elementId).style.display = 'block'; // } //} // Far comparire //function enable(elementId) { // if (document.getElementById(elementId).style.visibility == "hidden") { // alert("in if HIDDEN"); // document.getElementById(elementId).style.visibility = 'visible'; // } //} function visualizza(id) { if (document.getElementById){ if(document.getElementById(id).style.display == 'none'){ document.getElementById(id).style.display = 'block'; }else{ document.getElementById(id).style.display = 'none'; } } } //Rename Element function rename(elementId,doc){ document.getElementById(elementId).innerHTML = doc; } //valida una input text function validateInputNumber(e){ var eventResult; e = e || event; eventResult= /[0-9]/i.test( String.fromCharCode(e.charCode || e.keyCode) ) || !e.charCode && e.keyCode < 48; return eventResult; } // Switch persona $(document).ready(function(){ var forms = $('.container').find('form'); $('#loadingGif').hide(); $('#content-middle').fadeTo(1); var containerChilds = $('#wrap.container').find('> div').not('#loadingGif'); containerChilds.removeClass('opacity'); checkRequiredPiva(); //checkMarket(); if($('input#pG1').is(':checked')){ disablePersFis(); } else { disablePersGiur(); } if($('input#me1').is(':checked')){ disableMercatoItaliano(); } else { disableMercatoEstero(); } var checkbox = $('#checkWithSelect').find('input[type="checkbox"]'); $(checkbox).each(function(){ disableSelect($(this)); }); checkbox.on('click', function(){ disableSelect($(this)); }); var checkRegProd = $("#areaProdottoReg").find('input[type="checkbox"]'); $(checkRegProd).each(function(){ var select = $(this).attr('id') == 'carb' ? $('select#tipologiaCarburanti') : ($(this).attr('id') == 'lube' ? $('select#tipologiaLubrificanti') : $('select#tipologiaEnifuel')); if($(this).is(':checked')){ select.removeAttr('disabled').addClass('required'); select.addClass('required'); } else { select.attr('disabled','disabled').removeClass('required'); select.removeClass('required, error'); } }); checkRegProd.on('click', function(){ var select = $(this).attr('id') == 'carb' ? $('select#tipologiaCarburanti') : ($(this).attr('id') == 'lube' ? $('select#tipologiaLubrificanti') : $('select#tipologiaEnifuel')); if($(this).is(':checked')){ select.removeAttr('disabled').addClass('required'); select.addClass('required'); } else { select.attr('disabled','disabled').removeClass('required'); select.removeClass('required, error'); } }); checkRegProd.on('change', function(){ //checkMarket(); }); $('.numeric').on('keypress', function(e){ return validateInputNumber(e); }); $('.telephone').on('keypress', function(e){ var eventResult; e = e || event; eventResult= /[0-9,\/,\-,+]/i.test( String.fromCharCode(e.charCode || e.keyCode) ) || !e.charCode && e.keyCode < 48; return eventResult; }); forms.on('submit', function(e){ containerChilds.fadeTo( 0, 0.3 , function(){ $('#loadingGif').css("position","absolute"); $('#loadingGif').css("top", Math.max(0, (($(window).height() - $('#loadingGif').outerHeight()) / 2) + $(window).scrollTop()) + "px"); $('#loadingGif').show(); }); }); $("#nation").change( function(){ checkRequiredPiva(); checkMarket(); }); }); function validazione_email(email) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if (!reg.test(email)) return false; else return true; } function checkRequiredPiva(){ var personType = $('input[name="tipo"]:checked').val(); if(personType == '1'){ if($('#nation').find('option:selected').attr('data-inputs') == "CEE"){ $('#piva').find('.star').hide(); $('#pivacee').find('.star').show(); } else if($('#nation').find('option:selected').attr('data-inputs') == "EXTRA_CEE"){ $('#piva').find('.star').hide(); $('#pivacee').find('.star').hide(); } else { $('#piva').find('.star').show(); $('#pivacee').find('.star').hide(); } } if(personType == '0'){ $('#piva').find('.star').show(); $('#pivacee').find('.star').show(); } } function disablePersGiur(){ $('#ragioneSocialeRow').hide(); $('#docAnagrRagSoc').hide(); $('#nomeCognome').show(); $('#docAnagrCodFisc').show(); $('#nomeCognome').find('input').addClass('required'); $('#ragioneSocialeRow').find('input').removeClass('required'); checkRequiredPiva(); } function disablePersFis(){ $('#nomeCognome').hide(); $('#docAnagrCodFisc').hide(); $('#ragioneSocialeRow').show(); $('#docAnagrRagSoc').show(); $('#ragioneSocialeRow').find('input').addClass('required'); $('#nomeCognome').find('input').removeClass('required'); checkRequiredPiva(); } function disableMercatoEstero(){ $('#nazioneRow').hide(0, function(){ $('#capProvincia').show(); }); } function disableMercatoItaliano(){ $('#capProvincia').hide(0, function(){ $('#nazioneRow').show(); }); } function disableSelect(checkbox){ var select = checkbox.parent('.checkSelect').find('.productSelect'); if(checkbox.is(':checked')){ select.removeAttr('disabled').addClass('required'); select.addClass('required'); } else { select.attr('disabled','disabled').removeClass('required'); select.removeClass('required, error'); } } function checkMarket(){ var nation = $('#nation'); var nationVal = nation.val(); var selected = nation.find('option:selected'); var dataInputs = selected.attr('data-inputs'); var lube = $('#lube').is(':checked'); var carb = $('#carb').is(':checked'); var enifuel= $('#enifuel').is(':checked'); $('#extraCEE').attr ("value", "false"); if( (dataInputs == "EXTRA_CEE" ) ) { $('#extraCEE').attr ("value", "true"); } if( (dataInputs == "EXTRA_CEE" && (carb || lube)) || (dataInputs == "CEE" && carb) ) { // $('#extraCEE').attr ("value", "true"); // $('#alertMarket').show(); } if(dataInputs == "CEE" && lube && !carb) { // $('#alertMarket').hide(); // $('#extraCEE').attr ("value", "false"); } if( !lube && !carb ) { // $('#extraCEE').attr ("value", "false"); // $('#alertMarket').hide(); } if(dataInputs == "Italy" || nationVal == "-1"){ // $('#extraCEE').attr ("value", "false"); // $('#alertMarket').hide(); } }