$(document).ready(function(){
						   
	var theid = $("#menu a.active");
    var theidx = $("a.be").index(theid);
    var theh = (theidx*32)+94;
       
    $(theid).animate({"height":"359px"},1200,"easeOutQuart");
    
    $("#menu").css({"width":"260px"});
   
    $("#uno,#due,#quattro").css({"top":theh+"px"});
    $(".scroll-pane").jScrollPane({scrollbarWidth: 8});
    $(".scroll-pane").hide();
    
    $(theid).data("ck","ok");
	$(theid).trigger("mouseover");
	setTimeout(function(){
    
        $("#uno").animate({"left":"0px"},1000,"easeOutQuart");

    },500);
    setTimeout(function(){
    
        $("#due").animate({"left":"240px"},1500,"easeOutQuart");

    },1500);
    
    setTimeout(function(){
    
        $("#quattro").animate({"left":"653px"},2200,"easeOutQuart");
        
    },2000);
    
    setTimeout(function(){
    	
		$(".selector a:eq(0)").trigger("click");
    
    },3000);
    
    $(".selector a").each(function(){
		
		
		
		$(this).click(function(){
			
			$(this).parent().parent().find(".active").removeClass("active");
			$(this).addClass("active");
			var idx = $(".selector a").index(this);
			
			var ccontent = $(".seltext:eq("+idx+")").html();
			var ctitle = $(".seltext:eq("+idx+")").attr("title");
			var cgallery = $(".selgal:eq("+idx+")").html();
			
			$(".duetitle").empty().html(ctitle);
			$("#listpager").empty().hide();
        	$(".scroll-pane").empty().hide().html(ccontent).jScrollPane({scrollbarWidth: 8}).fadeIn({duration:1200});
			$(".mini").empty().hide().html(cgallery);
			
			
			
			$(".mini img").each(function(){
										 
				//var miniatura = new Image();
				//$(miniatura).attr("src", $(this).attr("rel")).appendTo($("#pager"));
				$("#listpager").append('<li><a href="#"><img src="'+$(this).attr("rel")+'" width="40" height="40"/></a></li>');
										 
			});
			
			$(".mini").cycle({
                        startingSlide: 0,
                        speed:  1200, 
    				    timeout: 0, 
    				    next:   $(".mini"), 
    				    fx:     'fade',
						pager:  '#pager',
    					pagerAnchorBuilder: function(idx, slide) { 
       					 // return selector string for existing anchor 
       					 return '#listpager li:eq(' + idx + ') a'; 
    					
    					}
			
    		});
			
			$(".mini,#listpager").fadeIn({duration:1200});
			
		});
	
	});
	
     
});


