/* luke: upload as a design file */

/* JS: vale nicali */

jQuery(document).ready(function(){
	
	if(jQuery('#sidebar-container') && jQuery('#sidebar')){
	  jQuery('#sidebar-container').before(jQuery('#sidebar'));
	  // add events to vale nicali navigation:
	  jQuery('#sidebar li a').click(function(e){
		  // unmark old current:
		  jQuery('#sidebar li').removeClass('current');
		  // mark current:
		  jQuery(this).parent().addClass('current');
			// hide all sections:
			jQuery('.page-main-content .page-section').hide();
		  // show next section:
		  var nextSection = jQuery(this).attr('href');
			jQuery(nextSection).show();
			// prevenir default:
			e.preventDefault();
	  });
  }

  // remove old sidebar container:
	jQuery('#sidebar-container').remove();
	
	// hide all sections:
	jQuery('.page-main-content .page-section').hide();
	// show current section:
	if(window.location.hash.length >= 1){
		jQuery(window.location.hash).show();
	} else {
		// show the first section:
		jQuery('.page-main-content .page-section:first-child').show();
	}
	
	// ocultar contenidos de la home:
	if(jQuery("div.banner-home").length > 0){
		$('#content, #sidebar').hide();
		if(window.location.hash == "#productos"){
			jQuery("div.banner-home").animate({opacity: 0, height: 0}, 300, function(){jQuery("div.banner-home").remove();});
			jQuery('#content, #sidebar').animate({opacity: 1, height: 'show'}, 300);
		}
	}
	// ocultar contenidos de la categoria:
	if(jQuery("div.foto-categoria").length > 0){
		$('ul.product-listing').hide();
		if(window.location.hash == "#productos"){
			jQuery("div.foto-categoria").animate({opacity: 0, height: 0}, 300, function(){jQuery(this).remove();});
			jQuery('ul.product-listing').animate({opacity: 1, height: 'show'}, 300);
		}
	}
	
	// click sobre el banner de la home
	jQuery("img.banner-home-principal").click(function(){
		jQuery("div.banner-home").animate({opacity: 0, height: 0}, 300, function(){jQuery("div.banner-home").remove();});
		jQuery('#content, #sidebar').animate({opacity: 1, height: 'show'}, 300);
	});
	
	jQuery("div.foto-categoria").click(function(){
		jQuery(this).animate({opacity: 0, height: 0}, 300, function(){jQuery(this).remove();});
		jQuery('ul.product-listing').animate({opacity: 1, height: 'show'}, 300);
	});
	
});
