/* Util detecta ie6 ie7*/
var ie_old=false;
if((jQuery.browser.msie)&&(jQuery.browser.version.substr(0,1)<7)){ie_old=true;}
/* Carga ajax */
function ajaxLoader(url1,b){
    if(!b){b='';}
    jQuery.ajax({
        type: 'GET',
        data: 'json=true'+b,
        url: url1,
        dataType: 'html',
        error: function(){
        alert('Error loading XML document');
        },
        success: function(data){
        jQuery('#box_info_sala').html(data);
        }
    });
}
/*Menu siempre en pantallas */
var divArbre="#sala_info";
function moverFxMenu(){
    var fx_con_div=jQuery(divArbre);
    var fx_scroller_fix=190;
    var fx_scroller=jQuery(this).scrollTop()-fx_scroller_fix;//Puesta 0 scoll
    var mainHeight=parseInt(jQuery("#salas").height());
    var elementHeight=parseInt(fx_con_div.height());//Altura div
    var fx_cont=mainHeight-elementHeight-fx_scroller;//Altura maxima para el scroll
    if((jQuery(this).scrollTop()>fx_scroller_fix)&&(fx_cont>0)){
        if(ie_old){
            fx_con_div.css({"top":fx_scroller+"px"});
            /*fx_con_div.stop().animate({"top":fx_scroller+"px"},200);*/
        }else{
            fx_con_div.css({"position":"fixed","top":"0"});
        }
    }else if(fx_cont<1){//Te has pasado
        fx_con_div.css({"top":(fx_scroller+fx_cont)+"px"});
        if(!ie_old){fx_con_div.css({"position":"absolute"});}

    }else{
        fx_con_div.css({"top":"0px"});
        if(!ie_old){fx_con_div.css({"position":"absolute"});}//Relative? hack ie7 (Absolute)
    }
}
/* ScrollTo */
function f_scrollTo(a){
    var destination = jQuery('#'+a).offset().top;
    jQuery('html').stop().animate({ scrollTop: destination}, 200);
    jQuery('body').stop().animate({ scrollTop: destination}, 200,function(){location.href='#'+a;});
return false;}
/***
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/
function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');
    if ($active.length == 0 ) $active = jQuery('#slideshow IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow IMG:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .stop().animate({opacity: 1.0}, 300, function() {
            $active.removeClass('active last-active');
        });
        jQuery('.img_buttons span').text(jQuery($next).attr('alt'));
}
function slideSwitchPrev(){
    var $active = jQuery('#slideshow IMG.active');
    if ($active.length == 0 ) $active = jQuery('#slideshow IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.prev().length ? $active.prev()
        : jQuery('#slideshow IMG:last');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .stop().animate({opacity: 1.0}, 300, function() {
            $active.removeClass('active last-active');
        });
        jQuery('.img_buttons span').text(jQuery($next).attr('alt'));
}
/* Mostrar documentales */
function mostrarDoc(mes,doc){
    divMes='.doc_mesbox.m'+mes;
    jQuery(divMes).children('.doc_info.d'+doc).fadeIn();
    jQuery(divMes).children('div').removeClass('activo').filter('.doc_info').hide();
    jQuery(divMes).children('.d'+doc).addClass('activo').filter('.doc_info').show();
    
}