var useScript="";var operatorName="vivaticket";
$(document).ready(function(){var datepickerConfig={changeMonth:true,changeYear:true,yearRange:"-120:+0",autoclose:true,buttonImage:hostServerImage+"wms_images/calendario.jpg",buttonImageOnly:true};var showDatepickerFuture={changeMonth:true,changeYear:true,yearRange:"-10:+10",autoclose:true,buttonImage:hostServerImage+"wms_images/calendario.jpg",buttonImageOnly:true};$(".showDatepicker").datepicker(datepickerConfig);$(".showDatepickerFuture").datepicker(showDatepickerFuture);switch(useScript){case "SHOWTabPrezziManual":SHOW.sceltaManuale.impostaEventiMappa();
break;case "SHOWTabPrezziBS":SHOW.tabellaPrezzi.impostaEventi();SHOW.tabellaPrezzi.impostaEventiMappa();break;case "CTUEvent":SHOW.changeUserTicket.impostaSceltaTipo();break;case "CTUAnagrafica":SHOW.changeUserTicket.impostaEventi();break;case "TdtSelection":case "TDTSelection":SHOW.emissioneTdT.impostaEventiSelezioneTdt();break;case "TDTUser":SHOW.emissioneTdT.impostaEventi();SHOW.emissioneTdT.impostaSpedizione();break;case "TDTUserSummary":SHOW.emissioneTdT.caricaFoto();break;case "TDTReplacementSummary":SHOW.emissioneTdT.impostaSpedizione();
break;case "SetAnagrafiche":default:SHOW.SetAnagrafiche.impostaEventi();SHOW.SetAnagrafiche.impostaDatiAnagraficheErrate();SHOW.SetAnagrafiche.impostaDatiRiduzioni();break}});staticAreaOption={fillOpacity:.5,mapKey:"data-key",staticState:true};
rebindOption={fillOpacity:.5,mapKey:"data-key",isSelectable:false,highlight:false,singleSelect:true,render_highlight:{fillColor:"d6eaff"},render_select:{fillColor:"d6eaff",stroke:true,strokeColor:"ff0000",strokeWidth:2},showToolTip:true,toolTipClose:["area-mouseout"],onMouseover:function(data){if($(".mapster_tooltip").length==0)$("#mappaEvento img").mapster("tooltip",this,frasi.tabellaPrezzi["noSeat"])}};
var SHOW={chargeData:function(_data,field,selectedValue){$.each(_data,function(key,value){var sel=selectedValue==key;$(field).append($("<option>",{value:key,text:value,selected:sel}))})},changeEstero:function(nazione,provincia,comune,reset){if(nazione.is(":visible")){var parent=nazione.parents("fieldset");if(parent.length==0)parent=nazione.parents("form");if(nazione.val()==""){parent.find(".soloItalia").hide();parent.find(".soloEstero").hide();parent.find(".soloItalia input, .soloItalia select").prop("disabled",
true);parent.find(".soloEstero input, .soloEstero select").prop("disabled",true)}else if(nazione.val()=="ITA"){parent.find(".soloItalia").show();parent.find(".soloItalia input, .soloItalia select").prop("disabled",false);parent.find(".soloEstero").hide();parent.find(".soloEstero input, .soloEstero select").prop("disabled",true)}else{parent.find(".soloItalia").hide();parent.find(".soloItalia input, .soloItalia select").prop("disabled",true);parent.find(".soloEstero").show();parent.find(".soloEstero input, .soloEstero select").prop("disabled",
false)}if(reset!=false){parent.find(".soloItalia "+provincia).val("");parent.find(".soloItalia "+comune).empty();parent.find(".soloItalia input, .soloEstero input").val("")}}},changeComuni:function(provincia,setComune,field){if(provincia.val()=="")return;var url="/inc/show_retriever.php?nome_provincia="+provincia.val();var parent=provincia.parents("fieldset");if(parent.length==0)parent=provincia.parents("form");parent.find(".stillWait").html('<img alt="" src="'+hostServerImage+'wms_images/icons/spinner.gif">');
$.getJSON(url,function(comuniHash){SHOW.fillComuni(provincia,comuniHash,setComune,field)})},fillComuni:function(provincia,comuniHash,setComune,field){var parent=provincia.parents("fieldset");if(parent.length==0)parent=provincia.parents("form");var campo=parent.find(".soloItalia "+field);campo.empty();if(comuniHash!==null)$.each(comuniHash,function(key,value){var sel=setComune==value;campo.append($("<option>",{value:value,text:value,selected:sel}))});parent.find(".stillWait").html("")},changeAddressData:function(dati,
selectNazione,selectProvincia,selectComune){SHOW.chargeData(dati.countryHash,selectNazione,$(selectNazione).attr("data-selected")?$(selectNazione).attr("data-selected"):"ITA");SHOW.chargeData(dati.regionHash,selectProvincia,$(selectProvincia).attr("data-selected"));SHOW.changeComuni($(selectProvincia),$(selectComune).attr("data-selected"),selectComune);SHOW.changeEstero($(selectNazione),selectProvincia,selectComune,false);$(selectNazione).change(function(){SHOW.changeEstero($(this),selectProvincia,
selectComune)});$(selectProvincia).change(function(){SHOW.changeComuni($(this),null,selectComune)})}};
SHOW.tabellaPrezzi={impostaEventi:function(){$("#tablePrice .tipoPosto").click(function(){$("#tablePrice tr.settore, #tablePrice tr.sceltaposti").hide();$("#tablePrice .arrow").removeClass("downArrow").addClass("rightArrow");id=$(this).attr("data-id");$("#arrow_"+id).removeClass("rightArrow").addClass("downArrow");$("#tablePrice tr.settore[data-tipoPosto='"+id+"'],#tablePrice tr.sceltaposti[data-tipoPosto='"+id+"']").show()});$("map").click(SHOW.tabellaPrezzi.controlloLogin);$("input[type=radio][name=sector]").change(SHOW.tabellaPrezzi.controlloLogin);
$("#tablePriceSubmit #acquistaShow").click(function(e){sector=$("input[name=sector]:checked").val();if(sector==undefined){$("#nTickets").val(0);alert(frasi.tabellaPrezzi["zonaSel"]);e.preventDefault();return false}data=sector.split("-");if($("#nTickets_"+data[0]).length>0)$("#nTickets").val($("#nTickets_"+data[0]).val());if($("input[name=pua_"+data[0]+"]").length>0)$("#pua").val($("input[name=pua_"+data[0]+"]:checked").val());if($("#nTickets").val()==0){alert(frasi.tabellaPrezzi["nTickets"]);e.preventDefault();
return false}if($("input[type=radio][name=pua]:enabled, input[type=radio][name=pua_"+data[0]+"]:enabled").length>0&&$("input[type=radio][name=pua]:checked, input[type=radio][name=pua_"+data[0]+"]:checked").length==0){alert(frasi.tabellaPrezzi["scegliPua"]);e.preventDefault();return false}if($("input[name=pua]").length>0){var namici=parseInt($("#tablePrice tr.Prezzi[data-id="+data[0]+"]").attr("data-pua"));if($("input[type=radio][name=pua]:checked, input[type=hidden][name=pua]").val()==1&&$("#nTickets").val()>
namici+1){alert("Puoi scegliere al massimo "+(namici+1)+" biglietti");e.preventDefault();return false}}return true})},controlloLogin:function(){if($("#btnAccediRegistrati").length>0)alert(frasi.tabellaPrezzi["accediRegistrati"]);if($("#btnCompleta").length>0)alert(frasi.tabellaPrezzi["completaAnagrafica"])},impostaEventiMappa:function(){if($("map").length==0)return;staticArea=new Array;rebindArea=new Array;$("tr.settore").each(function(){color=$(this).attr("data-color").substr(1);a={key:$(this).attr("data-sector"),
staticState:false};ra={key:$(this).attr("data-sector"),highlight:true,isSelectable:true,toolTip:$(this).attr("data-tooltip")};staticArea.push(a);rebindArea.push(ra)});$.extend(staticAreaOption,{areas:staticArea});$.extend(rebindOption,{areas:rebindArea,onClick:SHOW.tabellaPrezzi.clickMappa});$("#mappaEvento img").mapster(staticAreaOption).mapster("snapshot").mapster("rebind",rebindOption,true);$("tr.settore").mouseover(function(e){$("#mappaEvento img").mapster("highlight",$(this).attr("data-sector"))}).mouseout(function(e){$("#mappaEvento img").mapster("highlight",
false)}).click(function(e){$("#mappaEvento img").mapster("set",true,$(this).attr("data-sector"))})},clickMappa:function(data){$("#tablePrice tr.Prezzi, #tablePrice tr.settore").hide();$("#tablePrice tr.sceltaPua").hide();$("#tablePrice tr.sceltaPua input[name=pua]").prop("disabled",true).prop("checked",false);if(data.selected){var k=data.key.split("-");$("h4.selectDescr").show();$("#tableWrap").show();$("#tablePrice [data-id="+k[0]+"]").show();$("#tablePriceSubmit").show();$("input[type=radio][value="+
data.key+"]").attr("checked","checked");namici=parseInt($("#tablePrice tr.Prezzi[data-id="+k[0]+"]").attr("data-pua"),10);if($("#tablePrice tr.sceltaPua").length>0&&namici>0){$("#tablePrice tr.sceltaPua").show();$("#tablePrice tr.sceltaPua input[name=pua]").prop("disabled",false);var amici=namici>1?eng==0?"amici":"friends":eng==0?"amico":"friend";$("#tablePrice tr.sceltaPua #namici").html(namici+" "+amici)}if($(window).scrollTop()<$("#mappaEvento").offset().top)$("html, body").animate({scrollTop:$("#mappaEvento").offset().top},
2E3)}else{$("h4.selectDescr").hide();$("#tableWrap").hide();$("#tablePriceSubmit").hide();$("input[type=radio]").attr("checked","");$("#tablePrice tr.sceltaPua").hide();$("#tablePrice tr.sceltaPua input[name=pua]").prop("disabled",true).prop("checked",false)}return true}};
SHOW.sceltaManuale={impostaEventiMappa:function(){if($("#mappaEvento.mappahtml img").length==0)return;staticArea=new Array;rebindArea=new Array;$.each(tipoPostoJSON,function(){var tp=$(this)[0];$.each(tp.settori,function(){var s=$(this)[0];if(s.posti>0){a={key:tp.id+"-"+s.id,staticState:false};if(s.id=="NOCODE")sett="";else sett=s.id;ra={key:tp.id+"-"+s.id,tp:tp.id,sector:s.id,highlight:true,isSelectable:true,toolTip:tp.descrizione+" - "+sett+"<br>DISPONIBILITA': "+s.posti};staticArea.push(a);rebindArea.push(ra)}})});
$.extend(staticAreaOption,{areas:staticArea});$.extend(rebindOption,{areas:rebindArea,onClick:SHOW.sceltaManuale.clickMappa});$("#mappaEvento.mappahtml img").mapster(staticAreaOption).mapster("snapshot").mapster("rebind",rebindOption,true);$("#btnMappa").click(function(){$("#mappaEvento.mappahtml").show();$("#mappaSettori.mappahtml").hide();$(".mappahtml.istruzioni").hide();$("#mappaSettori.mappahtml td.stato_S").addClass("stato_L").removeClass("stato_S");showSeatDescription();$(".mappahtml.buttons").hide();
$("map[name=map] area").mapster("deselect")});$("#loading").bind("ajaxStart",function(){$(this).show()}).bind("ajaxStop",function(){$(this).hide()});$("#eventPricesMaps form").submit(function(e){var postiSel=$("#mappaSettori.mappahtml td.stato_S");if(postiSel.length==0||postiSel.length<minBuy){e.preventDefault();if(minBuy==1)alert(frasi.tabellaPrezzi["nTickets"]);else alert(frasi.tabellaPrezzi["nTickets_var"].call(this,minBuy));return}if(pua>0&&$("input[name=pua]:checked").length==0){alert(frasi.tabellaPrezzi["scegliPua"]);
e.preventDefault();return false}if(pua>0&&$("input[name=pua]:checked").val()==1&&postiSel.length>parseInt(pua,10)+1){e.preventDefault();alert(frasi.tabellaPrezzi["nPua_var"].call(this,parseInt(pua,10)+1));return}postiSel.each(function(){desc=tipoPostoName+(eng==0?" Fila ":" Row ")+$(this).attr("data-fila")+(eng==0?" Posto ":" Seat ")+$(this).attr("data-posto");if($("#mappahtml_seats").val().length==0){$("#mappahtml_seats").val($(this).attr("data-idposto"));$("#mappahtml_descs").val(desc);$("#mappahtml_zone").val(tipoPostoCode);
$("#mappahtml_reds").val(reduction)}else{$("#mappahtml_seats").val($("#mappahtml_seats").val()+","+$(this).attr("data-idposto"));$("#mappahtml_descs").val($("#mappahtml_descs").val()+"||"+desc);$("#mappahtml_zone").val($("#mappahtml_zone").val()+","+tipoPostoCode);$("#mappahtml_reds").val($("#mappahtml_reds").val()+","+reduction)}})})},clickMappa:function(request){if(request.selected)$.ajax({url:"/extscript/getShowStatoPostiInPianta.php",type:"POST",data:{sector:request.key,operator:operatorName},
dataType:"html",cache:false,success:function(data,stato){$("#mappaEvento.mappahtml").hide();$("#mappaSettori.mappahtml").html(data).css("display","inline-block");$(".mappahtml.istruzioni").show();$(".mappahtml.buttons").show();$("#mappaSettori.mappahtml td.stato_L").click(bindStatoL);$("#mappaSettori.mappahtml td.stato_S").click(bindStatoS);if(parseInt(pua)>1){$(".mappahtml tr.sceltaPua").show();var amici=parseInt(pua)>1?eng==0?"amici":"friends":eng==0?"amico":"friend";$("#namici").html(parseInt(pua)+
" "+amici)}else $(".mappahtml tr.sceltaPua").hide()},error:function(request,stato,errori){alert("E' evvenuto un errore. Il stato della chiamata: "+stato)}})}};function bindStatoS(){$(this).addClass("stato_L").removeClass("stato_S");$("#mappaSettori.mappahtml td.stato_L").click(bindStatoL);showSeatDescription()}
function bindStatoL(){if($("#mappaSettori.mappahtml .stato_S").length>=maxBuy)return;$(this).addClass("stato_S").removeClass("stato_L");$("#mappaSettori.mappahtml td.stato_S").click(bindStatoS);showSeatDescription()}
function showSeatDescription(){var scelti="";$("#mappaSettori.mappahtml td.stato_S").each(function(){scelti=scelti+"<tr><td>"+tipoPostoSector+"</td><td>"+$(this).attr("data-fila")+"</td><td>"+$(this).attr("data-posto")+"</td></tr>"});$(".mappahtml.postiScelti tbody").html(scelti);if(scelti.length==0)$(".mappahtml.postiScelti").hide();else $(".mappahtml.postiScelti").show()}
SHOW.SetAnagrafiche={_data:{tipoPosto:"",prTessera:new Array,squadraDiCasa:"",countryHash:"",regionHash:"",anagrafiche:null},impostaDati:function(options){_data=$.extend(SHOW.SetAnagrafiche._data,options)},impostaEventi:function(){if(typeof _data=="undefined"||typeof _data.tipoPosto=="undefined"||_data.tipoPosto.length==0)return;if(_data.pua==1)if(_data.puatype==2)$("fieldset").find(".anagrafica").show();else{$("fieldset[data-idAnagrafica=0] .tesseraDelTifoso").show();$("fieldset").not($("fieldset[data-idAnagrafica=0]")).find(".anagrafica").show()}else if(_data.tipoPosto==
"P"||_data.tipoPosto=="O"||typeof _data.abbonamento!="undefined"&&_data.abbonamento=="1")$(".tesseraDelTifoso").show();else if(_data.tipoPosto=="I")$(".anagrafica").show();else if(_data.tipoPosto=="F"&&_data.prTessera.length==1&&_data.prTessera[0]=="")$(".sceltaTessera").show();$("select.residenza").change(function(){var set="fieldset[data-idAnagrafica="+$(this).parents("fieldset").attr("data-idAnagrafica")+"]";SHOW.SetAnagrafiche.resetScelta(set);SHOW.SetAnagrafiche.resetTessera(set);SHOW.SetAnagrafiche.resetAnagrafica(set);
SHOW.SetAnagrafiche.mostraPerResidenza(set)});$(".sceltaTessera input[type=radio]").click(function(){if($(this).is(":visible")){var set="fieldset[data-idAnagrafica="+$(this).parents("fieldset").attr("data-idAnagrafica")+"]";SHOW.SetAnagrafiche.resetTessera(set);SHOW.SetAnagrafiche.resetAnagrafica(set);SHOW.SetAnagrafiche.mostraPerSceltaTessera(set)}});$("select.squadra").click(function(){if($(this).is(":visible")){var set="fieldset[data-idAnagrafica="+$(this).parents("fieldset").attr("data-idAnagrafica")+
"]";if($(this).val()==""||$(this).val()==_data.squadraDiCasa)SHOW.SetAnagrafiche.resetAnagrafica(set);SHOW.SetAnagrafiche.mostraPerSquadra(set)}});SHOW.chargeData(_data.countryHash,"select[name^=nazioneNascita]","ITA");SHOW.chargeData(_data.regionHash,"select[name^=provinciaNascita]");$("select[name^=nazioneNascita]").change(function(){SHOW.changeEstero($(this),"select[name^=provinciaNascita]","select[name^=comuneNascita]")});$("select[name^=provinciaNascita]").change(function(){SHOW.changeComuni($(this),
null,"select[name^=comuneNascita]")});$(".setAnagrafica #btnAvanti").click(function(e){var ok=true;$("fieldset").each(function(){if($(this).find("select.residenza").length>0&&$(this).find("select.residenza").is(":visible")&&$(this).find("select.residenza").val()=="")ok=false;if($(this).find(".sceltaTessera input[type=radio]").length>0&&$(this).find(".sceltaTessera input[type=radio]").is(":visible")&&!$(this).find(".sceltaTessera input[type=radio]").is(":checked"))ok=false});if(!ok){alert(frasi.tabellaPrezzi["checkAnagrafica"]);
e.preventDefault();return false}return true})},impostaDatiRiduzioni:function(){if(typeof _data=="undefined"||typeof _data.riduzioni=="undefined"||_data.riduzioni==null||typeof _data.anagrafiche!="undefined"&&_data.anagrafiche!=null)return;$.each(_data.riduzioni,function(index,value){var set="fieldset[data-idAnagrafica="+index+"]";$(set+" select[name^=riduzione]").val(value)})},impostaDatiAnagraficheErrate:function(){if(typeof _data=="undefined"||typeof _data.anagrafiche=="undefined"||_data.anagrafiche==
null)return;$.each(_data.anagrafiche,function(index,value){var set="fieldset[data-idAnagrafica="+index+"]";$(set+" select[name^=riduzione]").val(value.riduzione);if($(set+" select.residenza").length>0){$(set+" select.residenza").val(value.residenza);SHOW.SetAnagrafiche.mostraPerResidenza(set)}if($(set+" .sceltaTessera input[type=radio]").length>0&&$(set+" .sceltaTessera input[type=radio]").is(":visible")){$(set+" .sceltaTessera input[type=radio][value="+value.sceltaTessera+"]").attr("checked","checked");
SHOW.SetAnagrafiche.mostraPerSceltaTessera(set)}if($(set+" select.squadra").length>0&&$(set+" select.squadra").is(":visible")){$(set+" select.squadra").val(value.squadra);SHOW.SetAnagrafiche.mostraPerSquadra(set)}$(set+" input[name^=tessera]").val(value.tessera);if($(set+" .anagrafica").is(":visible")){$(set+" input[name^=nome]").val(value.nome);$(set+" input[name^=cognome]").val(value.cognome);$(set+" input[name^=sesso][value="+value.sesso+"]").click();dataNascita=value.dataNascita.substr(6,2)+"/"+
value.dataNascita.substr(4,2)+"/"+value.dataNascita.substr(0,4);if(dataNascita!="//")$(set+" input[name^=dataNascita]").val(dataNascita);$(set+" select[name^=nazioneNascita]").val(value.nazioneNascita);if(value.nazioneNascita=="ITA"){$(set+" .soloItalia").show();$(set+" select[name^=provinciaNascita]").val(value.provinciaNascita);SHOW.changeComuni($(set+" select[name^=provinciaNascita]"),value.comuneNascita,"select[name^=comuneNascita]")}else $(set+" .soloItalia").hide()}puatdt=$("#puatdt");if(puatdt.length>
0&&puatdt.val()=="")puatdt.addClass("error");if(typeof value.error!="undefined")if(value.error.indexOf("|")==-1){$("#errorBox>div").html(value.error);$(set).find("[name^=squadra], [name^=tessera]").addClass("error")}else if($(set+" .anagrafica").is(":visible")){errori=value.error.split("|");$.each(errori,function(i,v){$(set).find("[name^="+v+"]").addClass("error")})}else if(value.residenza=="")$(set).find("[name^=residenza]").addClass("error")})},resetAnagrafica:function(set){set=set+" .anagrafica";
$(set+" input[type=text]").val("");$(set+" select[name^=nazioneNascita]").val("ITA");$(set+".soloItalia").show();$(set+" select[name^=provinciaNascita]").val("");$(set+" select[name^=comuneNascita]").empty();$(set+" input[name^=sesso][value=M]").attr("checked",true)},resetTessera:function(set){$(set+" .tesseraDelTifoso select").val("");$(set+" .tesseraDelTifoso .squadra option:first").attr("selected","selected")},resetScelta:function(set){$(set+" .sceltaTessera input").attr("checked",false)},mostraPerResidenza:function(set){var val=
$(set+" select.residenza").val();if(val==""){$(set+" .sceltaTessera").hide();$(set+" .tesseraDelTifoso").hide();$(set+" .anagrafica").hide()}else if($.inArray(val,_data.prTessera)!=-1){$(set+" .sceltaTessera").hide();$(set+" .tesseraDelTifoso").show();$(set+" .anagrafica").hide()}else{$(set+" .sceltaTessera").show();$(set+" .tesseraDelTifoso").hide();$(set+" .anagrafica").hide()}},mostraPerSceltaTessera:function(set){var val=$(set+" .sceltaTessera input[type=radio]:checked").val();if(val=="1"){$(set+
" .tesseraDelTifoso").show();$(set+" .anagrafica").hide()}else{$(set+" .tesseraDelTifoso").hide();$(set+" .anagrafica").show()}},mostraPerSquadra:function(set){var val=$(set+" select.squadra").val();if(val==""||val==_data.squadraDiCasa)$(set+" .anagrafica").hide();else{$(set+" .anagrafica").show();$(set+" .anagrafica.soloItalia").show()}}};
SHOW.changeUserTicket={_data:{countryHash:"",regionHash:""},impostaDati:function(options){_data=$.extend(SHOW.SetAnagrafiche._data,options)},impostaSceltaTipo:function(){$(".modeType input[type=radio]").click(function(){if($(this).val()==1){$(".tdtenable").show();$(".ticketenable").hide()}else{$(".tdtenable").hide();$(".ticketenable").show()}})},impostaEventi:function(){SHOW.changeAddressData(_data,"select#NazioneNascita","select#ProvinciaNascita","select#LuogoNascita");if(typeof anaError!="undefined"){errori=
anaError.split("|");$.each(errori,function(i,v){$("#"+v).addClass("error")})}}};
SHOW.emissioneTdT={_data:{countryHash:"",regionHash:""},impostaDati:function(options){_data=$.extend(SHOW.SetAnagrafiche._data,options)},impostaEventiSelezioneTdt:function(){$("#requiredcmd input[type=radio]").change(function(){var txt=$("label[for="+$(this).attr("id")+"]").text();$("#submit").val(txt)});$("#fotoValide").dialog({autoOpen:false,modal:true,resizable:false,draggable:false,width:"830px"});$("#linkFotoValide").click(function(){$("#fotoValide").dialog("open")});$("#frmTdtSelection").submit(function(e){if($("#tdtType").val().length==
0){alert("Selezionare la tessera del tifoso");return false}})},caricaFoto:function(){$("#photoPreview").css({width:boxW+"px",height:boxH+"px",top:boxY+"px",left:boxX+"px"});if(photoName!=""){$("<img />").load(function(){$("#photoPreview").html($(this));showPreview({x:0,y:0,w:photoWidth,h:photoHeight},$("#photoPreview img"))}).attr("src","/extscript/fileUpload.php?download=1&fototesser="+photoName);$("#photo").val(photoName)}$("#fotoValide").dialog({autoOpen:false,modal:true,resizable:false,draggable:false,
width:"830px"});$("#linkFotoValide").click(function(){$("#fotoValide").dialog("open")})},impostaSpedizione:function(){if($("input[name=tdt_creq_collection_mode]").val()=="S"){$("fieldset#spedizione").show();$("fieldset#inforitiro").hide()}else if($("input[name=tdt_creq_collection_mode]").val()=="R"){$("fieldset#spedizione").hide();$("fieldset#inforitiro").show()}else{$("fieldset#inforitiro").hide();$("fieldset#spedizione").hide()}$("input[type=radio][name=tdt_creq_collection_mode]").change(function(){if(this.value==
"S"){$("fieldset#spedizione").show();$("fieldset#inforitiro").hide()}else{$("fieldset#spedizione").hide();$("fieldset#inforitiro").show()}});SHOW.changeAddressData(_data,"select#tdt_creq_ship_nazione","select#tdt_creq_ship_prov","select#tdt_creq_ship_citta")},impostaEventi:function(){$("#photoPreview").css({width:boxW+"px",height:boxH+"px",top:boxY+"px",left:boxX+"px"});if(photoName!=""){$("<img />").load(function(){$("#photoPreview").html($(this));showPreview({x:0,y:0,w:photoWidth,h:photoHeight},
$("#photoPreview img"))}).attr("src","/extscript/fileUpload.php?download=1&fototesser="+photoName);$("#photo").val(photoName)}SHOW.changeAddressData(_data,"select#tdt_creq_tit_nazionen","select#tdt_creq_tit_provn","select#tdt_creq_tit_comn");var docN="select#tdt_creq_doc_nazione";var docPr="select#tdt_creq_doc_prov";var docCom="select#tdt_creq_doc_com";SHOW.chargeData(_data.regionHash,docPr,$(docPr).attr("data-selected"));SHOW.changeComuni($(docPr),$(docCom).attr("data-selected"),docCom);SHOW.changeEstero($(docN),
docPr,docCom,false);$(docN).change(function(){SHOW.changeEstero($(this),docPr,docCom)});$(docPr).change(function(){SHOW.changeComuni($(this),null,docCom)});$("#tdt_creq_tit_minore").change(function(){if($(this).val()!="")$("fieldset#tutore").show();else $("fieldset#tutore").hide()});SHOW.changeAddressData(_data,"select#tdt_creq_tut_nazionen","select#tdt_creq_tut_provn","select#tdt_creq_tut_comn");SHOW.changeAddressData(_data,"select#tdt_creq_res_nazione","select#tdt_creq_res_prov","select#tdt_creq_res_citta");
$("#tdt_creq_same_dom_res").click(function(){if($(this).is(":checked"))$("fieldset#domicilio").hide();else $("fieldset#domicilio").show()});SHOW.changeAddressData(_data,"select#tdt_creq_dom_nazione","select#tdt_creq_dom_prov","select#tdt_creq_dom_citta");$("#file_upload").fileupload({url:"extscript/fileUpload.php",dataType:"json",acceptFileTypes:/(\.|\/)(jpe?g|png)$/i,maxFileSize:4E6,minWidth:600,minHeight:600,add:function(e,data){var theFile=data.originalFiles[0];var options=$("#file_upload").data("fileupload").options;
var error=[];$(".openCropModal").hide();if(theFile["type"].length&&!options.acceptFileTypes.test(theFile["type"]))error.push("Il file "+theFile.name+" non \ufffd valido. Tipi accettati: .jpg .png");if(theFile["size"]>options.maxFileSize)error.push("Il file "+theFile.name+" e' troppo grosso: la sua dimensione non deve eccedere i 4.0MByte.");if(error.length>0){alert(error.join("\n"));$("#filePreview").hide();$("#filename").text("");$("#photo").val("")}else{$("#filePreview").show();$("#filename").text(data.originalFiles[0].name);
data.submit()}},progressall:function(e,data){var progress=parseInt(data.loaded/data.total*100,10);$(".uploadProgress .uploadBar").css("width",progress+"%")},done:function(e,data){var options=$("#file_upload").data("fileupload").options;var error=[];$.each(data.result,function(index,file){if(file[0].width<options.minWidth||file[0].height<options.minHeight)error.push("L'immagine caricata \ufffd troppo piccola! Assicurati di caricarne una di almeno 600x600 pixels");if(error.length>0){alert(error.join("\n"));
$("#filePreview").hide();$("#filename").text("");$("#photo").val("");return}var newWidth=file[0].width>818?818:file[0].width;$("<img />").load(function(){$("#photoPreview").html($(this));$("#fileimage").html($(this).clone());var left=(file[0].width-photoWidth)/2;var top=(file[0].height-photoHeight)/2;$("#fileimage img").Jcrop({allowResize:false,allowSelect:false,onChange:function(coords){showPreview(coords,$("#fileimage img"))},boxWidth:newWidth,setSelect:[left,top,left+photoWidth,top+photoHeight]});
if(file[0].width!=photoWidth||file[0].height!=photoHeight){$(".openCropModal").show();$("#fileimage").dialog({minWidth:newWidth+26}).dialog("open")}}).attr("src",file[0].url);$("#photo").val(file[0].name)})}});$("#fileimage").dialog({autoOpen:false,modal:true,resizable:false,draggable:false,buttons:{"Ritaglia la foto":function(){$(this).dialog("close")}}});$(".openCropModal").click(function(){$("#fileimage").dialog("open")})}};
function showPreview(coords,source){$("#x").val(coords.x);$("#y").val(coords.y);var rx=$("#photoPreview").width()/coords.w;var ry=$("#photoPreview").height()/coords.h;$("#photoPreview img").css({width:Math.round(rx*source.width())+"px",height:Math.round(ry*source.height())+"px",marginLeft:"-"+Math.round(rx*coords.x)+"px",marginTop:"-"+Math.round(ry*coords.y)+"px"})};
