$(document).ready(function(){
	$(".menu li.institucional").click(function () {
		document.location.href = "/index.php";
		return false;
	});
	$(".menu .socios").click(function () {
		document.location.href = "/index.php/socios";
		return false;
	});
	$(".menu .noticias").click(function () {
		document.location.href = "/index.php/noticias";
		return false;
	});
	$(".menu .futbol").click(function () {
		document.location.href = "/index.php/futbol";
		return false;
	});
	$(".menu .disciplinas").click(function () {
		document.location.href = "/index.php/disciplinas";
		return false;
	});
	$(".menu .multimedia").click(function () {
		document.location.href = "/index.php/multimedia";
		return false;
	});
	$(".menu li.institucional li a, .menu .socios li a, .menu .noticias li a, .menu .futbol li a, .menu .disciplinas li a, .menu .multimedia li a,").click(function () {
		document.location.href = $(this).attr("href");
		return false;
	});

	$.address.init(function(event) {
	}).change(function(event) {
		if(event.path != "/") {
			var selection = $('a[rel=address:' + event.value + ']');
			if($("body#inicio").length > 0) {
				if(selection.hasClass("institucionales") || selection.hasClass("futbolisticas")) {
					// Poner en negrita el link
					$("#inicio .tipos-noticias a").css("font-weight", "normal");
					selection.css("font-weight","bold");
				}
				$.get(event.value, {}, function (data) {
					$(".novedades-home .goto").replaceWith("");
					$(".novedades-home .news").replaceWith(data);
				});
				$.address.title($.address.title().split(' | ')[0] + ' | ' + selection.text());
			} else if($("body#noticias").length > 0) {
				d = selection.parents(".goto").parent();
				$.get(event.value, {}, function (data) {
					$(d).html(data);
				});
			} else if($("body#disciplinas").length > 0) {
				$.get(event.value, {}, function (data) {
					$("#colder .goto").replaceWith("");
					$("#colder .news").replaceWith(data);
				});
			}
		}
	});
	/*
	$(".editar-inline").click(function () {
		h = $(this).attr("href");
		$bloque = $(this).parents(".bloque-texto");
		$bloque.find(".body-texto").editInline({url: h});
		return false;
	});
	*/
	if($("a.lightbox").length > 0) {
    $('a.lightbox').lightBox({
		imageLoading:			'/images/lightbox-ico-loading.gif',	
		imageBtnPrev:			'/images/lightbox-btn-prev.gif',	
		imageBtnNext:			'/images/lightbox-btn-next.gif',	
		imageBtnClose:			'/images/lightbox-btn-close.gif',
		imageBlank:				'/images/lightbox-blank.gif',
		txtImage:				'Imagen',
		txtOf:			'de'
	});
	}
});
//  Slideshow
function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

setInterval( "slideSwitch()", 5000 );