// JavaScript Document
var timer="";
var controllo1="0";
var timer_cc="";
var mem_src="";
var id_n_photo=1;

function StartTempo(){
clearTimeout(timer);
timer=setInterval("StopTempo()",5000);
$("#BoxSliderImg").css("display","block");
$("#DivPhotoAvanti").css("display","block");
$("#DivPhotoIndietro").css("display","block");
$("#Play").css("display","block");
$("#Stop").css("display","block");

}


function Automatico(){

timer_cc=setInterval("PhotoAvanti()",5000); 


}

function StopAutomatico(){

clearTimeout(timer_cc);
}



function StopTempo(){
$("#BoxSliderImg").css("display","none");
$("#DivPhotoAvanti").css("display","none");
$("#DivPhotoIndietro").css("display","none");
$("#Play").css("display","none");
$("#Stop").css("display","none");
clearTimeout(timer);
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




    function CaricaPhoto(src,n_foto){
		id_n_photo=n_foto;
		
mem_src=src;
src="../photo_gallery/mega/"+src;
$('#ImgPhoto').fadeOut(250, function(){ 
  $(this).attr('src',src) 
      .bind('onreadystatechange load', function(){ 
     if (this.complete) $(this).fadeIn(500); 
  }); 
}); 

}


function ApriPopUp(){
	$("img[rel]").overlay();
var src="../photo_gallery/mega/"+mem_src;
	$('#BigImgPhoto').fadeOut(250, function(){ 
  $(this).attr('src',src) 
      .bind('onreadystatechange load', function(){ 
     if (this.complete) $(this).fadeIn(500); 
  }); 
}); 
	
	
	}

function CaricaPhotoGallery(){

var img_preload="qtk_photo_gallery/images/preload3.gif";
$("#qtk_photo_gallery").css('backgroundImage','url(' + img_preload +')'); 
$.ajax({
   type: "POST",
   url: "qtk_photo_gallery/photo_gallery.php",
   data: "funzione=1&id_photo_gallery="+id_photo_gallery,

	success: function(risposta){
	
switch (risposta) {
         case 'Errore_01':
			alert("Attenzione!");
         break;

		 
		  default:

$("#qtk_photo_gallery").html(risposta);

	  }}});}




function PhotoAvanti(){
	
id_n_photo++;

if($("#n_fine").val()<id_n_photo){
	id_n_photo=1;
var src = $("#photo_"+id_n_photo).val();

}else{ 

var src = $("#photo_"+id_n_photo).val();}

src="../photo_gallery/mega/"+src;

$('#ImgPhoto').fadeOut(250, function(){ 
  $(this).attr('src',src) 
      .bind('onreadystatechange load', function(){ 
     if (this.complete) $(this).fadeIn(500); 
  }); 
}); 	
	
	
}

function PhotoIndietro(){
	
id_n_photo--;

if(id_n_photo==0){
	id_n_photo=$("#n_fine").val();
var src = $("#photo_"+id_n_photo).val();

}else{ var src = $("#photo_"+id_n_photo).val();}


src="../photo_gallery/mega/"+src;
$('#ImgPhoto').fadeOut(250, function(){ 
  $(this).attr('src',src) 
      .bind('onreadystatechange load', function(){ 
     if (this.complete) $(this).fadeIn(500); 
  }); 
}); 	
	
	
}
