$(document).ready(function() {
		
	$("#menu_subcategories").corner().parent().css('padding', '2px').corner("cc:#EEF0EF tr tl");
	$("#menu_subcategories").corner().parent().css('padding', '2px').corner("cc:#CEDEEB br bl");
	$("#menu_subcategories_blue").corner().parent().css('padding', '2px').corner("cc:#D5E2EB");
	$(".gym_branch").corner("cc:#E0E7ED tl tr");
	$(".gym_branch").corner("cc:#D3E1EA bl br");
	$(".rounded_no_border").corner("5px");
	$(".rounded_content").corner("5px").parent().css('padding', '1px').corner("5px");
	$(".rounded_content").each(function(){
		var w = $(this).css('width');		
		if(w != 'auto'){
			w = w.substr(0, (w.length-2));
			w = eval(Number(w)+10);
			$(this).parent().css('width', w+"px");
		}
	});
	$(".rounded_button").corner("5px").parent().css('padding', '1px').corner("cc:#D9E3EC 5px");	
	
	
	//$("#menu_items_specialities").corner("cc:#EFEFEF bl br").parent().css('padding', '2px').corner("bl br");
	//$("#menu_items_container").corner();
	//$(".rounded_button").corner("5px");
	//$("#column_news").corner().parent().css('padding', '2px').corner("cc:#C7DDEA tr tl");
	//$("#column_news").corner().parent().css('padding', '2px').corner("cc:#B8D9EA br bl");
	
	$(".items_submenu:last").css("border","none");
	$(".news_block:last").css("border","none");
	$("#items_submenu_blue li:last").css("border","none");
	
	$('.hideme').hide();
	
	$(".show_hide_content a").click(function(){
		id = $(this).parent().attr('id');
		$('.show_button_content').html($('.content_'+id).html());
	});
	  
	/* Font Size Element */
	$('.upFontSize').fontSizer({
		action: "up",
		elements: ".text"
	});
	  
	$('.downFontSize').fontSizer({
		action: "down",
		elements: ".text"
	});
	  
	$('.restoreFontSize').fontSizer({
		action: "restore",
		elements: ".text"
	});
	
	$(".read-more-inside").hover(
		function(){
			src = $(this).attr('src');
			src2 = src.split(".");
			src3 = src2[0] + "-hover.gif";
			$(this).attr("src", src3);
		},
		function () {
			$(this).attr("src", src);
		}
	);
	
	
	$(".toggle li h1").toggle(
		function(){
			$(this).next("p").show();
		}, 
		function () {
			$(this).next("p").hide();
		}
	);
	
	jQuery.each($('.searchPaginat a'), function() {		
		link = $(this).attr('href');
		link = link.substr(17, link.length);
		newLink = "/buscar/news/list/" + $("#category_id").val() + "/" + link;		
		$(this).attr('href', newLink);
	});
	
	jQuery.each($('.text img'), function() {		
		img = $(this).attr('src');
		if (img.substr(0, 8) == "/webroot"){
			img = img.substr(8, img.length);
		}		
		
		$(this).attr('src', img);
	});
	
	
	$(".print").click(function(){
		$("#content_text").printArea();
	});
	
	$("#header_menu").css("z-index", "1");
	
	/* Funciones Carrusel*/
	
	jQuery(".video_list_container").jCarouselLite({
		vertical: false,
		scroll: 1,
		visible: 3,
		rows: 1,
		circular: false,
		btnNext: "#mycarousel-video-next",
		btnPrev: "#mycarousel-video-prev"
	});

	jQuery(".image_list_container").jCarouselLite({
		vertical: false,
		scroll: 2,
		visible: 3,
		rows: 2,
		circular: false,
		btnNext: "#mycarousel-next",
		btnPrev: "#mycarousel-prev"	
	});
	

	$('.video_list_container li img').click(function(){
		id = $(this).attr('rel');
		$('.video_big').load('/galleries_contents/get_video_content/' + id);
	});
	
	$('.image_list_container li img').hover(function(){
		$('.image_big_image').attr('src', $(this).attr('rel'));
		$('.image_big a').attr('href', $(this).attr('rel2'));
	});
	
	/* Recupero el tamaño del cuadro de imagen */
	if (($('.video_box').css('visibility') == 'visible') && $('.image_box').css('visibility') == 'hidden'){
		$('.image_box').hide();
	}
	
	$('#image_tab').click(function(){
		current_class = $(this).attr('class');
		if (current_class !='multimedia_image_tab_single'){
			if (current_class == 'multimedia_image_tab_active'){
				$(this).attr('class', 'multimedia_image_tab');
				$('.image_box').attr('style','display: none');			
				$('#video_tab').attr('class', 'multimedia_video_tab_active');
				$('.video_box').attr('style','display: block');
				
			} else {
				$(this).attr('class', 'multimedia_image_tab_active');
				$('.image_box').attr('style','display: block');
				$('#video_tab').attr('class', 'multimedia_video_tab');
				$('.video_box').attr('style','display: none');
				style = $('.image_list_container').attr('style');
				$('.image_list_container').attr('style', style + '; visibility: visible !important');
			}
		}
	});

	$('#video_tab').click(function(){
		current_class = $(this).attr('class');
		if (current_class !='multimedia_video_tab_single'){
			if (current_class == 'multimedia_video_tab_active'){
				$(this).attr('class', 'multimedia_video_tab');
				$('.video_box').attr('style','display: none');
				$('#image_tab').attr('class', 'multimedia_image_tab_active');
				$('.image_box').attr('style','display: block');
			} else {
				$(this).attr('class', 'multimedia_video_tab_active');
				$('.video_box').attr('style','display: block');
				$('#image_tab').attr('class', 'multimedia_image_tab');
				$('.image_box').attr('style','display: none');
			}
		}
	});	

});


	
function validate(){ 
	if($('#SendmailName').val()==""){
		alert("Debe ingresar su nombre");
		$('#SendmailName').focus();
		return false;
	}
	
	//if (!validaMail($('#SendmailEmail'))){ return false;}
	
	if($('#SendmailComments').val()==""){
		alert("Debe ingresar su comentario");
		$('#SendmailComments').focus();
		return false;
	}
	return true;
}

function validateSuscribe(){
	if($('#SendmailName').val()==""){
		alert("Debe ingresar su nombre");
		$('#SendmailName').focus();
		return false;
	}
	
	if (!validaMail($('#SendmailEmail'))){ return false;}
	
	if($('#SendmailComments').val()==""){
		alert("Debe ingresar su comentario");
		$('#SendmailComments').focus();
		return false;
	}
	
	if($('#SendmailBranch').val()==""){
		alert("Debe ingresar la Sucursal deseada");
		$('#SendmailBranch').focus();
		return false;
	}
	return true;
}

function validaMail(email){
	emailValue = $(email).val();
	if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailValue))==false){
		alert("La dirección de email ingresada no es válida.");
		$(email).focus();
		return (false);
	}
	return true;
}