// JavaScript Document

addLoadEvent( function(){
	
	Cufon.now();
	Cufon.replace('.cufon_Chopin', { fontFamily: 'Chopin Script' });
	
	$('.abox').click(function() {
		location.href = $(this).find('a').attr('href');
	});
	
	$(window).ready(function() {
		$('.cyrcle').show();
		$('.cyrcle').cycle({ 
			fx:     'growX', 
			timeout: 5000
		});
	});
	
	switch (pag) {
		case 'lojas':
			$(window).ready(function() {
				$('.containerLojas').equalHeightColumns();
			});
			break;
			
		case 'categoria1':
		
			$(window).ready(function() {
				
				$('#mycarousel').fadeIn();
								
				$('#mycarousel').jcarousel({
					visible: 10
				});
				
				var atual = 0;
				var alt = "";
				var maximo = $('#mycarousel li').length;
				maximo--;
				
				function hideShowBTNS() {
					if (atual == 0) {
						$("#foto_prev").addClass('dn');
					} else {
						$("#foto_prev").removeClass('dn');
					}
					if (atual == maximo) {
						$("#foto_next").addClass('dn');
					} else {
						$("#foto_next").removeClass('dn');
					}
					$('#mycarousel li').eq(atual).find("a").addClass('select');
				}
				
				function passPics(direcao) {
					$('#mycarousel li').eq(atual).find("a").removeClass('select');
					if (direcao == 'next') {
						atual++;
					} else {
						atual--;
					}
					var img = $('#mycarousel li').eq(atual).find("a").attr('href');
					$(".fotoChange").find("span").hide();
					$(".fotoChange").find("img").remove();
					$('.fotoChange').find("span").prepend('<img alt="" src="'+img+'" />') 
					$(".fotoChange").find("span").fadeIn();
					hideShowBTNS();	
				}
							
				$('#mycarousel li').click(function() {
					$('#mycarousel li').eq(atual).find("a").removeClass('select');
					atual = $(this).index();
					var img = $(this).find("a").attr('href');
					$(".fotoChange").find("span").hide();
					$(".fotoChange").find("img").remove();
					$('.fotoChange').find("span").prepend('<img alt="" src="'+img+'" />') 
					$(".fotoChange").find("span").fadeIn();
					hideShowBTNS();
					return false;
				});
				
				$("#foto_prev").click(function() {
					passPics('prev');
				});
				
				$("#foto_next").click(function() {
					passPics('next');
				});
				
			});
		
			break;
			
		case 'categoria2':
		
			Shadowbox.init({ 
				slideshowDelay: 6,
				overlayOpacity: 0.8,
				troubleElements: ["select", "object", "embed"]
			});
		
			break;

	}
	
	$('ul#nav li').each(function(){ 
		$(this).css('width' , ( $(this).width() + 10) + 'px'); 
	});
		
});
