$(document).ready(function() {
	/* Round Corner */
	$(".panel").corner("cc:#EDEEF0 tl tr");
	$(".panel").corner("cc:#E5EAEE bl br");
	$(".news_content").corner("cc:#B8D9EC bl br");
	
	$("#footer").css("float", "left");
	//$("#footer").css("margin", "-31px auto 0 5px");
	if ( $("#footer").hasClass('footer_articles') == false ){
		$("#footer").css("margin", "-31px auto 0 10px");
	};
		
	/* Fade Banner Home */
	//$('#banner_home').innerfade({
	//	speed: 1000,
	//	timeout: 5000,
	//	type: 'sequence',
	//	containerheight: '331px'
	//}); 
	
	/* Hover MEDS Home */
	$("#btn_container li a img").hover(
		function(){
			src = $(this).attr('src');
			src2 = src.split(".");
			src3 = src2[0] + "2.png";
			$(this).attr("src", src3);		
		}, 
		function () {
			$(this).attr("src", src);		
		}
	);
	
	$("#btn_container_christmas li a img").hover(
		function(){
			src = $(this).attr('src');
			src2 = src.split(".");
			src3 = src2[0] + "-2.png";
			$(this).attr("src", src3);		
		}, 
		function () {
			$(this).attr("src", src);		
		}
	);
	
	/* Hover MEDS Extranet */
	$(".link_extranet").hover(function(){
			$(this).attr('src', '/img/extranet-h.gif');
		},function(){
			$(this).attr('src', '/img/extranet.gif');
	});

	
	/* Panels Home */
	$("#five_panels_home h3").hover(		
		function(){		
			$(this).css("color", "#EEE3FF");
		}, 
		function () {			
			$(this).css("color", "#FFFFFF");
		}	
	);
	
	/* Menu News */
	$("#news_menu li").hover(		
		function(){		
			$(this).css("background", "url(/img/news_menu_bg_li.jpg)");	
		}, 
		function () {			
			$(this).css("background", "transparent");
			
		}	
	);
	
	/* Hover Read-More */
	$(".read-more img").hover(
		function(){		
			$(this).attr("src", "/img/read-more2.jpg");
		}, 
		function () {
			$(this).attr("src", "/img/read-more.jpg");		
		}
	);
	
	
	showBanner();
	//showNews();
	
	$(".items_submenu:last").css("border","none");
	$("#items_submenu_blue li:last").css("border","none");
	
	$("#list_sports_container").jcarousel({
		scroll: 1,
		wrap: 'last',
		animation: 300,
		initCallback: deportes_carousel_initCallback
	});
	
	//$("#np_news_current_issues #carHomeNews").jcarousel({
	//	scroll: 1,
	//	wrap: 'last',
	//	animation: 700,
	//	auto: 8,
	//	initCallback: news_carousel_initCallback,
	//	itemVisibleInCallback: {
	//		onBeforeAnimation: function(asdf, asdf1){
	//			var currentItem = jQuery(asdf1).attr('jcarouselindex');
	//			jQuery('.np_paginator_news_home li').removeClass('current_pag');
	//			jQuery('.np_paginator_news_home li a[rel="'+currentItem+'"]').parent().addClass('current_pag');
	//			
	//		}
	//	}
	//});
	//
	    
});


//carrusel listado de deportes
function deportes_carousel_initCallback(carousel) {
	jQuery('#sports_list_ctrl .np_rarrow').click(function() {
		carousel.next();
		return false;
	});

	jQuery('#sports_list_ctrl .np_larrow').click(function() {
		carousel.prev();
		return false;
	});
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});

};

function news_carousel_initCallback(carousel) {
	jQuery('.np_paginator_news_home li a').click(function(e) {
		e.preventDefault();
		var thisRel = jQuery(this).attr('rel')
		carousel.scroll(jQuery.jcarousel.intval(thisRel));
		return false;
	});

	//jQuery('#sports_list_ctrl .np_larrow').click(function() {
		//carousel.prev();
		//return false;
	//});
	//carousel.clip.hover(function() {
		//carousel.stopAuto();
	//}, function() {
		//carousel.startAuto();
	//});

};

function showNews(){
	var div = new Array("news", "articles", "patients"); 	
	for (t=0;t<=2;t++){
		section = div[t];
		$.ajax({
			type: "POST",
			async: false,
			url: "/news/list_home_news/" + (t+1),			
			success: function(msg){
				$("#"+section+"_list_home").html(msg);		
			}
		});
	}	
}

function showBanner(){
	$.ajax({
		type: "POST",
		url: "/banners/show_home/",
		async: false,
		success: function(msg){			
			$("#banner_home").html(msg);
		}
	});
}
