/**
 * @author Francesco
 */

function FotoGallery()
{
	this.script_page = "/ajax/gallery.php";
	
	this.loadPhotos = function(id)
	{
		if (document.getElementById("php_response").innerHTML.length <= 0)
		{
			this.setLoadingSrc("/immagini/vote_loader.gif");
			this.setLoadingTarget(document.getElementById("php_response"));
			this.setTarget(this.gestisciRisposta);
			this.params["idc"] = parseInt(id);
			this.makeRequest(this.script_page);
		}
	}
	
	this.gestisciRisposta = function(response)
	{
		document.getElementById("php_response").innerHTML = response;
		
		$(".listing_opere img").hover(function(){
			if($(this).hasClass('selected'))
			{}else{
				$(this).stop().fadeTo(500, 1.0); // This should set the opacity to 100% on hover
				}
			},function(){
			if($(this).hasClass('selected'))
			{}else{
				$(this).stop().fadeTo(500, 0.2); // This should set the opacity back to 60% on mouseout
			}
		});
		$(".listing_opere div a > img").click(function(){
			$(".listing_opere div a > img").removeClass();
			 $(this).addClass('selected'); 
			 if($(".listing_opere div a img")){
			  $(".listing_opere div a img:not(.selected)").stop().fadeTo(500, 0.2);
			 }
			});
		 		
		
		$(".listing_expo").css("display", "none");
		$(".listing_expo").jScrollPane({showArrows:false});
		$('.listing_opere').jScrollPane({showArrows:true});
		$('.torna_dettaglio').css("display", "block");
		$('.listing_opere').css("display", "block");
	}
}

FotoGallery.prototype = new AjaxModule();
FotoGallery.prototype.constructor = FotoGallery;