/* ---------------------------------------------------------------------------
 * SCRIPT MADE BY EL PRESY EXCLUSIVELY FOR GTA-DOWNLOADS.COM AND NFSNETWORK.IT
 * All the data and routines of this script are covered by
 * copyright and the reproduction and/or copy is forbidden
 * ---------------------------------------------------------------------------
 * Last Revision: 13/08/2009
 * ---------------------------------------------------------------------------
 */
$(document).ready(function(){inizializzaPopup()});var popup=null,popup_width=0,popup_height=0,popup_loading=new Image();popup_loading.src="http://www.nfsnetwork.it/img/popup/loading.gif";function inizializzaPopup(){$(".popup").click(function(o){if($.browser.msie&&$.browser.version.substr(0,1)<7){return true}if(popup==null){$("body").append('<div id="sfondo"></div><div id="loading"><img src="'+popup_loading.src+'" alt="Caricamento in corso..." /></div><div id="scrollpanel"><div id="popup"><table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td class="top_left"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td><td class="top"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td><td class="top_right"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td></tr><tr><td class="middle_left"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td><td class="middle" id="popup_content"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="loading" alt="" /></td><td class="middle_right"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td></tr><tr><td class="bottom_left"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td><td class="bottom"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td><td class="bottom_right"><img src="http://www.nfsnetwork.it/img/comune/blank.gif" class="spacer" alt="" /></td></tr></table></div></div>');$("html,body").addClass("noscroll");popup=$("#popup").hide().css("overflow","hidden");popup_width=$("#popup").width();popup_height=$("#popup").height();var c=$(this).attr("href"),p=$(this).attr("type");if(c!=null){var g=c.substring(c.lastIndexOf("/")+1,c.length),f=c.substring(c.lastIndexOf("."),c.length);if(g.indexOf("?")!=-1){g=g.substring(c.indexOf("?")+1,c.indexOf("&"));f=".html"}}if(f==".jpg"||f==".png"||f==".gif"){var n=new Image();n.src=c;$("#popup_content").html('<img id="screenshot" src="'+c+'" alt="" />');$("#screenshot").load(function(){popup_width=n.width+22;popup_height=n.height+22;apriPopup()}).click(chiudiPopup).css("cursor","pointer")}else{if(f==".html"){$("#popup_content").load(c+" #testo",null,function(){$(this).html($("#testo").html());switch(g){case"act=preview":case"act=modify_category":a(popup_loading);break}if($("#popup_content input[type='submit']").length==0){$(this).append('<div id="buttons" style="text-align: center"><input type="submit" id="close" value="Chiudi" /></div>');$("#close").click(function(){chiudiPopup();return false})}else{$("#abort").click(function(){chiudiPopup();return false});$("#submit").click(function(){b(popup_loading);return false})}apriPopup()});popup.css("overflow","visible")}else{if(p=="submit"){var d=$(this).parents("form"),q=d.find(":input"),m=null,j=$(this).attr("value"),i=$(this),l=q.filter(".required").filter(function(e){return ($.trim($(this).attr("value")).length==0||$(this).attr('value')==0)});if(l.length>0){m="campi_obbligatori"}$(this).attr("disabled","disabled").attr("value","Uploading...Please wait");if(m==null){var h=new Array();q.filter(":file").each(function(s){var w=$(this).attr("value");if(w.length>0){var r=$(this).attr("name"),t=w.substring(w.lastIndexOf("."),w.length).toUpperCase(),v=$('input[name="'+r+'_consentiti"]').attr("value").split(", "),u=false;for(var e=0;e<v.length;e++){if(t=="."+v[e]){u=true;break}}if(!u){m="estensione_file";h.push(r+"|"+w)}}})}q.each(function(){var e=$(this).attr("name");$('td[title="'+e+'"]').removeClass("errore")});if(m==null){$.post("/ajax/segnalazione.php",{error:"upload_in_corso"},function(e){stop=false;popup.css("overflow","visible");$("#popup_content").html($(e).find("#content").html()).removeClass().addClass($(e).find("#content").attr("class"));apriPopup();d.submit()},"html")}else{var k;switch(m){case"campi_obbligatori":k="error="+m;l.each(function(){var e=$(this).attr("name");k+="&"+e+"=true";$('td[title="'+e+'"]').addClass("errore")});break;case"estensione_file":k={error:m,"non_consentiti[]":h};break}$.post("/ajax/segnalazione.php",k,function(e){popup.css("overflow","visible");$("#popup_content").html($(e).find("#content").html()).removeClass().addClass($(e).find("#content").attr("class")).append('<div style="text-align: center"><input type="submit" id="close" value="Chiudi" /></div>');$("#close").click(chiudiPopup);apriPopup();skipPopup();i.removeAttr("disabled").attr("value",j)},"html")}}}}}return false});function b(c){var e=$("#popup_content form").attr("action"),d;$("#popup_content form").append('<input type="hidden" name="submit" value="true" />');d=$("#popup_content form").find(":input").serializeArray();$("#popup_content").html('<img id="loading" src="'+c.src+'" alt="Caricamento in corso..." />');$.post(e,d,function(f){$("#loading").remove();$("#popup_content").html($(f).find("#content").html()).removeClass().addClass($(f).find("#content").attr("class"));skipPopup()},"html");return false}function a(c){$(".edit").click(function(){if($("#submit").length==0){$("#popup_content").wrapInner('<form action="?act=do" method="post"></form>');$("#buttons").append('<input type="hidden" name="mode" value="modifica_convalida" /><input type="submit" id="submit" value="Salva" />');$("#close").val("Annulla");$("#submit").click(function(){b(c);return false})}id_campo=$(this).attr("href");$(id_campo).html($(id_campo+" .replacement").html()).children().removeAttr("disabled");return false});$("#tabs").tabs()}}function apriPopup(){$("#loading").remove();popup.css({marginLeft:"auto",marginRight:"auto",width:popup_width+"px",height:popup_height+"px"}).fadeIn("slow")}function chiudiPopup(){popup.fadeOut("slow",function(){$(this).remove();$("#scrollpanel").remove();$("#sfondo").remove();$("html,body").removeClass("noscroll");popup=null})}function skipPopup(){var a=$("#skip");if(a.length!=0){a.click(function(){$(this).stop();chiudiPopup();return false}).animate({opacity:1},5000,function(){chiudiPopup()})}};
