// Script by Daniele Cascone - Luglio 2010
$(document).ready(function(){function visualizzaPrevNext(){if(posizioneFoto>1){$('#prevLink').show();$('#overPrevLink').show();$('#firstLink').show()}else{$('#prevLink').hide();$('#overPrevLink').hide();$('#firstLink').hide()};if(posizioneFoto<totaleFoto){$('#nextLink').show();$('#overNextLink').show();$('#lastLink').show()}else{$('#nextLink').hide();$('#overNextLink').hide();$('#lastLink').hide()}};function visualizzaFoto(){var paginaDaCaricare="genera_foto_corrente.json.php?posizione="+posizioneFoto+parametriDaPassare;$.getJSON(paginaDaCaricare,function(foto){var contenuto="";contenuto+="<div class=\"fotoLoading\" style=\"width: "+foto.width+"px;\">";contenuto+="<div class=\"foto\" style=\"background-image: url("+inizializza.base_url_img+foto.id+".jpg);\">";contenuto+="<img src=\"http://www.danielecascone.net/js/jquery.my.slideshow/images/sp_img.gif\" style=\"width: "+foto.width+"px; height: "+foto.height+"px;\" alt=\""+foto.titolo+"\" />";contenuto+="<div class=\""+foto.watermark+"\">&nbsp;</div>";contenuto+="</div>";contenuto+="</div>";$('#contentAreaInside').fadeOut('normal',function(){$('#contentAreaInside').empty();$('#titoloFoto').fadeOut('normal',function(){$('#titoloFoto').empty()});$('#overPrevLink').hide();$('#overNextLink').hide();$('#contentArea').animate({width:foto.width,height:foto.height},{duration:500,specialEasing:{width:'linear',height:'linear'},complete:function(){$('#contentAreaInside').html(contenuto);$('#titoloFoto').html(foto.titolo);$('#dettagliFoto').attr({href:inizializza.base_url_permalink+foto.id+inizializza.base_url_permalink_after});$('#overPrevLink').attr({style:"width: "+parseInt(foto.width/2,10)+"px; height: "+parseInt(foto.height)+"px;"});$('#overNextLink').attr({style:"width: "+parseInt(foto.width/2,10)+"px; height: "+parseInt(foto.height)+"px;"});visualizzaPrevNext();$('#infoSlideshow').html(posizioneFoto+" di "+totaleFoto);$('#contentAreaInside').fadeIn('normal');$('#titoloFoto').fadeIn('normal')}})})})};$('#boxInfoSlideshow').hide();$('#prevLink').hide();$('#overPrevLink').hide();$('#overNextLink').hide();$('#firstLink').hide();var parametriDaPassare=inizializza.parametri;var totaleFoto=inizializza.totale;var posizioneFoto=inizializza.posizione;var autoSlideshow=false;var espandiInfoSlideshow=false;visualizzaFoto();$(".nextLinkClass").click(function(){posizioneFoto=posizioneFoto+1;visualizzaFoto();return false});$(".prevLinkClass").click(function(){posizioneFoto=posizioneFoto-1;visualizzaFoto();return false});$("#firstLink").click(function(){posizioneFoto=1;visualizzaFoto();return false});$("#lastLink").click(function(){posizioneFoto=totaleFoto;visualizzaFoto();return false});$("#saltaFotoForm").submit(function(){var valoreInput=parseInt($('input[name=saltaFoto]').val(),10);if(valoreInput>0&&valoreInput<=totaleFoto){$('#saltaFotoErrore').empty();$('input[name=saltaFoto]').val(valoreInput);posizioneFoto=valoreInput;visualizzaFoto()}else{$('input[name=saltaFoto]').val('');$('#saltaFotoErrore').html('<br />Attenzione! Devi inserire un numero compreso tra <strong>1</strong> e <strong>'+totaleFoto+'</strong>')}return false});$("#infoSlideshow").click(function(){$("#boxInfoSlideshow").slideToggle('normal');if(espandiInfoSlideshow==false){$("#infoSlideshow").removeClass('espandi').addClass('riduci');espandiInfoSlideshow=true}else{$("#infoSlideshow").removeClass('riduci').addClass('espandi');espandiInfoSlideshow=false}return false});$("#playSlideshow").click(function(){if(autoSlideshow==false&&posizioneFoto!=totaleFoto){autoSlideshow=true;$("#playSlideshow").removeClass('play').addClass('stop');$('#playSlideshow').html('stop');posizioneFoto=posizioneFoto+1;visualizzaFoto();timer=setInterval(function(){if(posizioneFoto!=totaleFoto){posizioneFoto=posizioneFoto+1;visualizzaFoto()}else{clearInterval(timer);autoSlideshow=false;$("#playSlideshow").removeClass('stop').addClass('play');$('#playSlideshow').html('play')}},5000)}else{clearInterval(timer);autoSlideshow=false;$("#playSlideshow").removeClass('stop').addClass('play');$('#playSlideshow').html('play')}return false});$('html').bind('keydown',function(e){if(e.which==39){posizioneFoto=posizioneFoto+1;visualizzaFoto()}else if(e.which==37){posizioneFoto=posizioneFoto-1;visualizzaFoto()}})});
