function basename (path, suffix) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ash Searle (http://hexmen.com/blog/)
    // +   improved by: Lincoln Ramsay
    // +   improved by: djmix
    // *     example 1: basename('/www/site/home.htm', '.htm');
    // *     returns 1: 'home'
    // *     example 2: basename('ecra.php?p=1');
    // *     returns 2: 'ecra.php?p=1'

    var b = path.replace(/^.*[\/\\]/g, '');
    
    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    
    return b;
}

$(document).ready(function(){

	/*COLORBOX*/
	$('a[rel=individual]').colorbox({rel:'nofollow'});
	$("a[rel=lightbox]").colorbox({width:700});
	$(".html_lightbox").colorbox({iframe:true, innerWidth:760, innerHeight:500});
	
	
	/*MENU*/	
	$('#menu li a').each(function () {
		if (basename(window.location.href) == basename($(this).attr('href')))
			$(this).addClass('activo');
		else
			$(this).removeClass('activo');
	});
	
	
	$('#menu li ul li a').each(function () {
		if (basename(window.location.href) == basename($(this).attr('href'))) {
			$(this).addClass('activo');
			if ($(this).parents('[id^=m_]').size() == 0)
				$(this).parent().parent().parent().children().slice(0, 1).addClass('activo');
			/*else
				$(this).parents('[id^=m_]').addClass('activo');*/
		} else
			$(this).removeClass('activo');
	});

    /*HOSPITALES*/
	mostrar('');
    prepara();
	
	
	
});


function mostrar(id){
 $('.donde_hospital').show();
 $('.donde_hospital').children('div').hide();
 if ($('#'+id).size() > 0)
     $('#'+id).show();
 else if (id != '')
     $('#NoDisponible').show();
}

function prepara() {
    $('area').mouseover(function () {
        $('#provincia').html($(this).attr('alt'));
        $('.explica_hospital').hide();
        eval($(this).attr('href'));
    });
    $('area').click(function () {
        $('#provincia').html($(this).attr('alt'));
        $('.explica_hospital').hide();
        return true;
    });
}

