/**
* Scripting general del sitio
*
* @date			08 de Junio 2009
* @version		v.3
* @autor		Jose Delgado Aranda

*/

/*------------------------------------------------------------------*/
$(document).ready(function() {

	// Código para que aparezca la ventana de imprimir
	$('.print').click(function(){							   
		window.print();
		return false;
	});
	
	// Código para que aparezca target
	$('.target').attr("target","_blank");
	
	jQuery('a[rel$=\'external\']').attr("target","_blank");
	
	if($('body').hasClass('home_cassinelli')){
		$('#content_carrusel_cassinelli1').show();
		$('#content_carrusel_cassinelli2').hide();
	}else{
		$('#content_carrusel_cassinelli1').hide();
		$('#content_carrusel_cassinelli2').show();
	}
	
	$('#buscar_text').example('Ingresa tu mail');
	$('#buscar_concurso_text').example('Ingresa tu mail');
	
	
	$('#nav > li').hover(						 
		function(){
			$('#nav > li > .sub_nav').hide();
			$(this).find('> a').addClass('active').next().show();
			$(this).addClass('over');
		},
		function(){
			$(this).find('> a').removeClass('active').next().hide();
			$('#nav > li.active > .sub_nav').show();
			$(this).removeClass('over');
		}
		);
		
	$('#nav > li.active > .sub_nav').show();
	
	$('.link_thumb_deco ').hover(
		function(){
			$(this).css('border-color','#AAC902');
		},
		function(){
			$(this).css('border-color','#3C3C3C');
		}
	);
	/*$('#nav > li').hover(						 
		function(){
			$('#nav > li > div').hide();
			$(this).find('> a').next().show();
		},
		function(){
			$(this).find('> a').next().hide();
			$('#nav > li.active > div').show();
		}
	);*/
	
	/*$('#nav > li').hover(						 
		function(){
			$('#nav > li > div').hide();
			$(this).find('> a').next().show();
			$(this).find('> span').next().show();
			$(this).addClass('over');
		},
		function(){
			$(this).find('> a').next().hide();
			$(this).find('> span').next().hide();
			$('#nav > li.active > div').show();
			$(this).removeClass('over');
		}
	);
	
	$('.index').find('#fan_link').addClass('active');*/
	
	/*$('#fan_link').not('.form_index').hover(						 
		function(){
			$('#form_fan_header').show();
		},
		function(){
			$('#form_fan_header').hide();
		}
	);*/
	
	//$('#nav > li.active > div').show();
	
	$('#nav_sidebar li a.open_sub').toggle(function(){
		  $(this).parent().find('.open_sub').addClass('active');
		  $(this).parent().find('ul').show();
	 },function(){
		  $(this).parent().find('.open_sub').removeClass('active');
		 $(this).parent().find('ul').hide();
	 });
	
	  $('.subnav_sidebar').each(function (i) {
        $(this).find('li:last').addClass('no_bg');
      });

	/*$('.item_product').hover(
		function(){
			$(this).find('span:first').hide();
			$(this).find('.image_product').show();
		},
		function(){
			$(this).find('span:first').show();
			$(this).find('.image_product').hide();
		}
	);*/
	
	$('#sidebar_left_products ul li').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
				$(this).removeClass('hover');
		}
	);
	
	$('.item_product .image_product').hover(
		function(){
			$(this).find('strong').css('text-decoration','underline');
		},
		function(){
			$(this).find('strong').css('text-decoration','none');
		}
	);
																					
	$('.#info_product_detail_in ul li').hover(
		function(){
			$(this).find('.arrow_orange').css('height','6px');
		},
		function(){
			if($(this).find('.arrow_orange').hasClass('active')){return false;}
			$(this).find('.arrow_orange').css('height','0');
		}
	);
	
	$('#info_product_detail ul li a').click(function(){
		$('.info_text_product').show();
		$('#info_product_detail_in ul li a').removeClass('active');
		$('.arrow_orange').css('height','0');
		$(this).find('.arrow_orange').css('height','6px');
		$('.arrow_orange').removeClass('active');
		$(this).find('.arrow_orange').addClass('active');
		$(this).addClass('active');
		var rel = $(this).attr('rel');
		$('.info_text').hide();
		$('.info_text_'+rel).show();

		return false;
	});
	
	
	var numSubCat = 0;
	numSubCat = $('.sub_cat_list li').length;
	//console.log(numSubCat);
	if($('.box_recomendar').length){
		if(numSubCat>3) {
			$('#sidebar_left_products ul.sub_cat_list').css('height','190px');
			$('#pane2').css('height','180px');
			$('#sidebar_left_products ul li').css('width','160px');

		}
	}else{
		if(numSubCat>7) {
			
			$('#sidebar_left_products ul.sub_cat_list').css('height','350px');
			$('#pane2').css('height','300px');
			$('#sidebar_left_products ul li').css('width','160px');
		}		
	}
	
	$('.item_product').hover(
		function(){
			$(this).find('strong').css('text-decoration','underline');
		},
		function(){
			$(this).find('strong').css('text-decoration','none');
		}
	);
	
}); 


