﻿$(document).ready(function(){
	var resx = $('.listAlbum li a:first').attr('href');
	
	
	if(resx != undefined){
	
	$('.imgBig').hide();
	$('a').click(function(){ $(this).blur(); $('#box').hide(); $('.imgBig').show();});
	$('.listAlbum').jcarousel({ scroll: 2 });
	$('.listAlbum li a').fadeTo('fast', 0.6);
	$('.listAlbum li a:first').addClass('hover').fadeTo('fast', 1.0);
	$('.listAlbum li a').hoverIntent(function(){ $(this).fadeTo('normal', 1.0) }, function(){ if($(this).hasClass('hover') == false) $(this).fadeTo('normal', 0.6) });
	
	carregaImagem($('.listAlbum li a:first').attr('href'), $('.listAlbum li a:first').find('img').attr('alt'));
	$('.listAlbum li a').click(function(){
		$('.listAlbum li a.hover').removeClass('hover').fadeTo('fast', 0.6);
		$(this).addClass('hover').fadeTo('slow', 1.0);
		carregaImagem($(this).attr('href'), $(this).find('img').attr('alt'));		
		
		return false;	
	
	});
}else{

$(".imgBig").hide();
}

function carregaImagem($imagemUrl, $imagemLegenda){
	
	$('.imgBig').html('<img id="imgLoading" src="http://www.viladosipes.com.br/html/wp-content/themes/vila/img/ajax-loader.gif" style="margin-left:45%; margin-top:25%" alt="Carregando" />').animate({opacity: 1.0}, 1000, function(){
		$img = new Image();
		$($img).load(function(){
	   		$(this).css('display', 'none');
	       	$('.imgBig').html(this);//.append('<br /><span>' + $imagemLegenda + '</span>');
			$(this).fadeIn();
	    }).error(function(){
	      	$('.imgBig').append('<p>Ocorreu um erro durante o carregamento da imagem.</p>');
	    }).attr('src', $imagemUrl).height('').width('');
		
	});
}


		   $("#menu li a.open-menu").hover(function() {
				var hidden = $(this).parents("li").children("ul").is(":hidden");
				
				$("#menu>ul>li>ul").hide()        
				$("#menu>ul>li>a").removeClass();
					
				if (hidden) {
					$(this)
						.parents("li").children("ul").toggle()
						.parents("li").children("a").addClass("zoneCur");
					} 
			   });
			   
			   
});


/**
 * Item html creation helper.
 */


