/*******************************************************************************************************************************************/
/*****************************************************    	CORE GESTOR       **************************************************************/
/*******************************************************************************************************************************************/

//DETECTION NAVEGADOR
nav_detection=navigator.userAgent.search(/MSIE 6/)
if(nav_detection>0)var IE6=true
else var IE6=false

/*SHADOWBOX Options*/
var shadowbox_options = {
    autoplayMovies: false,
    counterType: 'default',
    counterLimit: 15,
    displayNav: true,
    fadeDuration: 0.40,
    handleOversize: 'resize',
    initialWidth: 66,
    initialHeight: 66,
    overlayOpacity: 0.85,
    overlayColor: '#FFFFFF',
    scrolling: 'NO',
    resizeDuration: 0.40,
    onFinish: function(){
        /** controls **/
        var h = $("#shadowbox_body_inner img").css("height");
        var hb = $('.shadowbox_nav_next').css('height');
        var top = (h.substring(0,h.length-2)/2) + (hb.substring(0,hb.length-2)/2);
        $('.shadowbox_nav_next').css({
            'top': top + 'px',
            'display' : 'block'
        });
        $('.shadowbox_nav_prev').css({
            'top': top + 'px',
            'display' : 'block'
        });
    },
    onOpen:    function(){
       $(".shadowbox_nav_next").css("display","none");
       $(".shadowbox_nav_prev").css("display","none");
    },
    onChange:   function(){
        $(".shadowbox_nav_next").css("display","none");
        $(".shadowbox_nav_prev").css("display","none");
    }
};

/*function pngFIX(){
                
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])

    if ((version >= 5.5) && (document.body.filters))
    {
        for(var i=0; i<document.images.length; i++)
        {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if (img.className=="pngfix" )
            {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
                + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i-1
            }
        }
    }
}*/

function pngFIX(){

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters))
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (img.className=="pngfix" )
      { 
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
                                i = i-1
      }
   }
}
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;
    if(!d) d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document;
        n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) x=d.all[n];
    for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n) ;
    return x;
}

function MM_preloadImages() { //v3.0
    var d=document;
    if(d.images){
        if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
        for(i=0; i<a.length; i++)
            if (a[i].indexOf("#")!=0){
                d.MM_p[j]=new Image;
                d.MM_p[j++].src=a[i];
            }
        }
}

function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr;
    for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments;
    document.MM_sr=new Array;
    for(i=0;i<(a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null){
            document.MM_sr[j++]=x;
            if(!x.oSrc) x.oSrc=x.src;
            x.src=a[i+2];
        }
}

function bookmark(bookmarkTitle,bookmarkUrl,bookmarkError){

    if (window.sidebar) { // For Mozilla Firefox Bookmark
        window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
    } else if( window.external || document.all) { // For IE Favorite
        window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
    } else if(window.opera) { // For Opera Browsers
        $("a.jQueryBookmark").attr("href",bookmarkUrl);
        $("a.jQueryBookmark").attr("title",bookmarkTitle);
        $("a.jQueryBookmark").attr("rel","sidebar");
    } else { // for other browsers which does not support
        alert(bookmarkError);
        return false;
    }
}

function CreateBookmarkLink(title,url) {

    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title);
    }
    else if(window.opera && window.print) { // Opera Hotlist
        return true;
    }
}
/*******************************************************************************************************************************************/
/*****************************************************    	CORE GESTOR       **************************************************************/
/*******************************************************************************************************************************************/


function changeMailto(href,id){
    var html = $.ajax({
        url: ruta+"content/comun/ponmailto.php?url="+href,
        async: false,
        cache: true
    }).responseText;

    $('#'+id).attr("href","mailto:"+html);
}





/* DATEPICKER */
function openDatePicker(ci,cf,hoy) {
    $('#'+cf).datepicker({
        showOn: 'both',
        buttonImage: ruta+'content/imgs/forms/calendar.png',
        buttonImageOnly: true,
        minDate: $.datepicker.parseDate("dd/mm/yy", $('#'+hoy).get(0).value),
        onSelect: function(dateText, inst) {
            //$('#'+cf).css("border","1px solid #939495");
            var f1 = $('#'+ci).datepicker("getDate");
            var f2 = $('#'+cf).datepicker("getDate");
			
            var dias = Math.ceil((f2.getTime()-f1.getTime())/(1000*60*60*24));
        }
    });
		
    $('#'+ci).datepicker({
        showOn: 'both',
        buttonImage: ruta+'content/imgs/forms/calendar.png',
        buttonImageOnly: true,
        minDate: 0,
        onSelect: function(dateText, inst) {
            updateSalida("#"+cf,$('#'+ci).datepicker("getDate"))
        //$('#'+ci).css("border","1px solid #939495")
        }
    });
}
function updateSalida(id,date){	
    var one_day=24*60*60*1000
    $(id).datepicker('option','minDate',new Date(date.getTime()+one_day));
    $(id).datepicker('option','maxDate',new Date(date.getTime()+one_day*360));
		  
    //Hacemos que se seleccione la fecha de salida un dia despues
    var new_salida=new Date(date.getTime())
	
    if(new_salida>=$(id).datepicker('getDate')){
        $(id).datepicker('setDate',new Date(date.getTime()+one_day*1));
    }
}
function showDatePicker(ci,hoy) {			
    $('#'+ci).datepicker({
        showOn: 'both',
        buttonImage: ruta+'content/imgs/forms/calendar.png',
        buttonImageOnly: true,
        changeYear: true,
        yearRange: 'c-50:c',
        onSelect: function(dateText, inst) {
            /*updateSalida("#"+cf,$('#'+ci).datepicker("getDate"))*/
            $('#'+ci).css("border","1px solid #939495")
        }
    });
}

var openShadowbox = function(content, player, title){
   
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title
    });
};

function submenuOver(iditem){
    var id="#"+iditem;
    var itemenu=id+".itemsub";
    $(itemenu).css({
        "color":"#ffffff"
    })
	
/*$(itemenu).css({"font-weight":"bold"})*/
		
}
function submenuOut(iditem)
{
    var id="#"+iditem;
    var itemenu=id+".itemsub";
    $(itemenu).css({
        "color":"#ffcccc"
    })
	
/*$(itemenu).css({"font-weight":"normal"})*/
}
	
function abrepesta(tipo)
{
    if(tipo==1){
        $('#ccompartir').css("display","inline");
        $('#cemail').css("display","none");
        $('#cmarcador').css("display","none");
        $('#pestcomp').removeClass("off");
        $('#pestemail').addClass("off");
        $('#pestmarc').addClass("off");
    }
    if(tipo==2){
        $('#ccompartir').css("display","none");
        $('#cemail').css("display","inline");
        $('#cmarcador').css("display","none");
        $('#pestcomp').addClass("off");
        $('#pestemail').removeClass("off");
        $('#pestmarc').addClass("off");
    }
    if(tipo==3){
        $('#ccompartir').css("display","none");
        $('#cemail').css("display","none");
        $('#cmarcador').css("display","inline");
        $('#pestcomp').addClass("off");
        $('#pestemail').addClass("off");
        $('#pestmarc').removeClass("off");
    }
}
function abrepesta2(tipo)
{
    if(tipo==1){
        $('#ccompartir2').css("display","inline");
        $('#cemail2').css("display","none");
        $('#cmarcador2').css("display","none");
        $('#pestcomp2').removeClass("off");
        $('#pestemail2').addClass("off");
        $('#pestmarc2').addClass("off");
    }
    if(tipo==2){
        $('#ccompartir2').css("display","none");
        $('#cemail2').css("display","inline");
        $('#cmarcador2').css("display","none");
        $('#pestcomp2').addClass("off");
        $('#pestemail2').removeClass("off");
        $('#pestmarc2').addClass("off");
    }
    if(tipo==3){
        $('#ccompartir2').css("display","none");
        $('#cemail2').css("display","none");
        $('#cmarcador2').css("display","inline");
        $('#pestcomp2').addClass("off");
        $('#pestemail2').addClass("off");
        $('#pestmarc2').removeClass("off");
    }
}

function abrepesta3(tipo,k)
{
    var ccompartir = "#ccompartir3"+k;
    var cemail = "#cemail3"+k;
    var cmarcador = "#cmarcador3"+k;
	
    var pestcomp = "#pestcomp3"+k;
    var pestemail = "#pestemail3"+k;
    var pestmarc = "#pestmarc3"+k;
	
    if(tipo==1){
        $(ccompartir).css("display","inline");
        $(cemail).css("display","none");
        $(cmarcador).css("display","none");
        $(pestcomp).removeClass("off");
        $(pestemail).addClass("off");
        $(pestmarc).addClass("off");
    }
    if(tipo==2){
        $(ccompartir).css("display","none");
        $(cemail).css("display","inline");
        $(cmarcador).css("display","none");
        $(pestcomp).addClass("off");
        $(pestemail).removeClass("off");
        $(pestmarc).addClass("off");
    }
    if(tipo==3){
        $(ccompartir).css("display","none");
        $(cemail).css("display","none");
        $(cmarcador).css("display","inline");
        $(pestcomp).addClass("off");
        $(pestemail).addClass("off");
        $(pestmarc).removeClass("off");
    }
}


function abrepesta4(tipo)
{
    if(tipo==1){
        $('#ccompartir4').css("display","inline");
        $('#cemail4').css("display","none");
        $('#cmarcador4').css("display","none");
        $('#pestcomp4').removeClass("off");
        $('#pestemail4').addClass("off");
        $('#pestmarc4').addClass("off");
    }
    if(tipo==2){
        $('#ccompartir4').css("display","none");
        $('#cemail4').css("display","inline");
        $('#cmarcador4').css("display","none");
        $('#pestcomp4').addClass("off");
        $('#pestemail4').removeClass("off");
        $('#pestmarc4').addClass("off");
    }
    if(tipo==3){
        $('#ccompartir4').css("display","none");
        $('#cemail4').css("display","none");
        $('#cmarcador4').css("display","inline");
        $('#pestcomp4').addClass("off");
        $('#pestemail4').addClass("off");
        $('#pestmarc4').removeClass("off");
    }
}

function abrepesta5(tipo)
{
    if(tipo==1){
        $('#ccompartir5').css("display","inline");
        $('#cemail5').css("display","none");
        $('#cmarcador5').css("display","none");
        $('#pestcomp5').removeClass("off");
        $('#pestemail5').addClass("off");
        $('#pestmarc5').addClass("off");
    }
    if(tipo==2){
        $('#ccompartir5').css("display","none");
        $('#cemail5').css("display","inline");
        $('#cmarcador5').css("display","none");
        $('#pestcomp5').addClass("off");
        $('#pestemail5').removeClass("off");
        $('#pestmarc5').addClass("off");
    }
    if(tipo==3){
        $('#ccompartir5').css("display","none");
        $('#cemail5').css("display","none");
        $('#cmarcador5').css("display","inline");
        $('#pestcomp5').addClass("off");
        $('#pestemail5').addClass("off");
        $('#pestmarc5').removeClass("off");
    }
}


function ponFichaHotel($idficha){
    $('#ficha_hotelhome_'+$idficha).css("display","block");
    $('#ficha_hotelhome_mapa').css("display","none");
}

function ocultaFichaHotel($idficha){
    $('#ficha_hotelhome_'+$idficha).css("display","none");
    $('#ficha_hotelhome_mapa').css("display","block");
}



/* GALERIA DE IMAGENES */

var posg=new Array();
function initGaleria(obj,fleft,fright,bot,npags,speed,label)
{
    var iii=posg.length;
    var _bot = bot;
    posg[iii]=0;
    $("#"+fleft).hide();
    if (npags==1) $("#"+fright).fadeOut(100);
    var desp=$("#"+obj).find("div:first").css("width");
    desp=desp.substring(0,desp.length-2);
	
    var tama = (npags*desp);
	
    $("#"+obj).find("div:first").css("width",tama);
    // Asigna eventos a las flechas
    $("#"+fleft).click(function() {
        mueveGal(-1,obj,npags,fleft,fright,desp,speed,iii,_bot,label);
        return false;
    });
    $("#"+fright).click(function() {
        mueveGal(1,obj,npags,fleft,fright,desp,speed,iii,_bot,label);
        return false;
    });
    // Comprueba el movimiento por el tamaņo de capa
	
    if(label) {
        var nobj = $("#"+obj).find(".titulos_alpha").get(posg[iii]);
        var tit = $(nobj).find("div:first").find(".titorange").html();
        if (tit!="undefined" && tit!="") {
            $(nobj).css("display", "block");
        }
    }
	
    var actual=$("#"+bot+" .itm").get(posg[iii])
    $(actual).removeClass("itm").addClass("itm_on");
	
}

function mueveGal(sent,obj,npags,fleft,fright,desp,speed,iii,bot,label)
{ //alert(sent);
    //alert(desp);
    if(label) {
        var nobj = $("#"+obj).find(".titulos_alpha").get(posg[iii]);
        var tit = $(nobj).find("div:first").find(".titorange").html();
        if (tit!="undefined" && tit!="") {
            $(nobj).css("display", "none");
        }
    }
	
    var left;
	
    if (sent=="-1") {
        left="+="+desp;
        posg[iii]-=1;
        if (posg[iii]<0) posg[iii]=0;
    } else if (sent=="1"){
        left="-="+desp;
        posg[iii]+=1;
        if ((posg[iii]+1)>npags) posg[iii]=npags-1;
    } else {
        var a = (sent*desp);
        left="-="+a;
        posg[iii]-=a;
        if ((posg[iii]+1)>npags) posg[iii]=0;
    }
		
    $('#'+obj).find("div:first").animate({
        marginLeft: left
		
		
		
    }, speed, function() {
        // Animation complete.
        if (posg[iii]==0)
        {
            $("#"+fleft).hide();
		
        } else {
            $("#"+fleft).show();
        }
        if ((posg[iii]+1)==npags)
        {
            $("#"+fright).hide();
            if(bot != "") {
                $("#"+bot+" .itm_on").removeClass("itm_on").addClass("itm");
                $("#"+bot+" .itm[id=bot_"+(posg[iii]+1)+"_"+bot+"]").removeClass("itm").addClass("itm_on");
            }

        } else {
            $("#"+fright).show();
            if(bot != "") {
                $("#"+bot+" .itm_on").removeClass("itm_on").addClass("itm");
                $("#"+bot+" .itm[id=bot_"+(posg[iii]+1)+"_"+bot+"]").removeClass("itm").addClass("itm_on");
            }
        }
	
        if(label) {
            var nobj = $("#"+obj).find(".titulos_alpha").get(posg[iii]);
            var tit = $(nobj).find("div:first").find(".titorange").html();
            if (tit!="undefined" && tit!="") {
                $(nobj).fadeIn();
            }
        }
    });
}



var lastid = 0;
var situacion = 0;
var girando = 0;
var velocidad = 1000;
var eles_go_back = null;
function pasaFoto(id,ancho,total,theight,autor,video,bucle){
    if (eles_go_back == null && activoActual>id) eles_go_back = id;
    idOri = id;
    nfotos = total;
    lanza_pasaFoto = 0;
    if ($(window).width()<1280) ancho = $(window).width();
    out = false;
    checkPause();
    if (girando==0) {
        //si el ultimo id es mayor al ultimo boton, estamos al principio.
        if (situacion>=total) situacion = 0;
        if (id==null) {
            //esta es la llamada automatica del interval.
            id = lastid+1;
            autoBucle=true;
        }
        else {
            if (bucle && (typeof galInterval  != "undefined") ) clearInterval(galInterval);
            autoBucle = false;
            if (id==-1) {
                id = lastid-1;
                if (id<0) id =0;
            }
            else if (id==1000) {
                id = lastid+1;
            } else {
                $('.cajahome div').each(function(i){
                    cl = $(this).attr('class');
                    cl = cl.replace("f","");
                    if (cl == id) {
                        posicion = i
                        if (situacion==posicion) {
                            out = true;
                        }
                    }
                });
                if (activoActual-eles_go_back==0 && eles_go_back!=null){
                    eles_go_back = null;
                    if (!autoBucle && bucle) galInterval = setInterval("pasaFoto(null,"+ancho+","+total+","+theight+",'','',true)",velocidad);
                    return false;
                }
                if (activoActual>eles_go_back && eles_go_back!=null) {
                    lanza_pasaFoto = 1;
                    id = lastid;
                } else id = lastid+posicion;
            }
			
        }
        if (out) return false;
        if (video!="") total+=1;
        for(i=0;i<(total);i++)	{
            $('#punto'+i).find('img').attr('src',ruta+'content/imgs/comunes/btn_slide_off.gif');
        }
        if (lastid<id || !bucle) {
            var mleft = (ancho * (parseInt(id) - parseInt(lastid)))*(-1);
            girando = 1;
            $('.cajahome').animate({
                marginLeft: mleft,
                height : theight
            }, 1200, function(){
                for(i=0;i<(total);i++)	{
                    if(i!=id){
                        if (video!="" && i==0)
                            $('#btn-video img').attr('src',ruta+idioma+'/imgs/btn-video-off.png')
                        else
                            $('#capa'+i).css("visibility","hidden");
                    }else{
                        if (video!="" && i==0) {
                            $('#btn-video img').attr('src',ruta+idioma+'/imgs/btn-video.png')
                        } else {
                    //situacion++;
                    //$('#punto'+situacion).find('img').attr('src',ruta+'content/imgs/comunes/btn_slide_on.gif');
                    }
                    }
                }
                if (bucle) {
                    elems =  parseInt(id) - parseInt(lastid);
                    for (i=0;i<elems;i++) {
                        $(".cajahome div:first").clone().appendTo(".cajahome");
                        $(".cajahome div:first").remove();
                    }
                    $(".cajahome").css('margin-left',0);
                }
                lastid = id;
                girando = 0;
                checkPosicion();
                if (!autoBucle && bucle) galInterval = setInterval("pasaFoto(null,"+ancho+","+total+","+theight+",'','',true)",velocidad);
				
            });
        } else {
            elems = 1;
            mleft = 0;
            for (i=0;i<elems;i++) {
                $(".cajahome div:last").clone().prependTo(".cajahome");
                $(".cajahome div:last").remove();
                $(".cajahome").css('margin-left',ancho*(-1));
            }
            girando = 1;
            veloAtr = (lanza_pasaFoto == 1)? 50 : 1200
            $('.cajahome').animate({
                marginLeft: mleft,
                height : theight
            }, veloAtr, function(){
                for(i=0;i<(total);i++)	{
                    if(i!=id){
                        if (video!="" && i==0)
                            $('#btn-video img').attr('src',ruta+idioma+'/imgs/btn-video-off.png')
                        else
                            $('#capa'+i).css("visibility","hidden");
                    }else{
                        if (video!="" && i==0) {
                            $('#btn-video img').attr('src',ruta+idioma+'/imgs/btn-video.png')
                        } else {
                    //situacion--;
                    //$('#punto'+situacion).find('img').attr('src',ruta+'content/imgs/comunes/btn_slide_on.gif');
                    }
                    }
                }
                lastid = id;
                girando = 0;
                checkPosicion();
                if (!autoBucle && bucle) galInterval = setInterval("pasaFoto(null,"+ancho+","+total+","+theight+",'','',true)",velocidad);
                if (lanza_pasaFoto==1) {
                    pasaFoto(idOri,ancho,total,theight,autor,video,true);
                }
            });
        }
    }
}

function pausa(el,ancho,total,theight) {
    $('.pauser').hide();
    $('.pauserh').show();
    clearInterval(galInterval);
}

function play(el,ancho,total,theight) {
    $('.pauser').show();
    $('.pauserh').hide();
    pasaFoto(null,ancho,total,theight,'','',true);
    galInterval = setInterval("pasaFoto(null,"+ancho+","+total+","+theight+",'','',true)",velocidad);
}

function checkPause() {
    if ($(".pauserh").is(":visible")) {
        $('.pauser').show();
        $('.pauserh').hide();
    }
}

activoActual = 0;
function checkPosicion() {
    //c = $('.cajahome ul li:first').attr('class');
    c = $('.cajahome div:first').attr('class');
    c = c.replace("f","");
    activoActual = c;
    $('#punto'+c).find('img').attr('src',ruta+'content/imgs/comunes/btn_slide_on.gif');
    return c;
}

function ajustaGaleria() {
    if(velocidad==0){
        velocidad = 10000;
    } // velocidad por defecto
    // Anchura
    w=$(window).width();
    if (w>1280) w=1280;
    $("#flash_home").css("width",w+"px");
    $(".cajahome").css("width",(w*nfotos)+"px");
    $("#contentgal .cajahome div").each(function()
    {
        $(this).css("width",w+"px");
    });
    ml = (w*1025)/1280;
    if (w>=1280) ml = 1025;
    if (w<1200){
        ml=ml+80;
        $("#pagina_home").css("margin-left",ml+"px");
		
    }
    else
        $("#pagina_home").css("margin-left","1005px");
	
    nav_msie=navigator.userAgent.search(/MSIE/)
    if(nav_msie>0)var IEnav=true
    else var IEnav=false
    if(IEnav==true){
        $("#pagina_home").css("margin-left","150px");
		
    }
	
	
    nav_msie=navigator.userAgent.search(/MSIE 6/)
    if(nav_msie>0)var IEnav=true
    else var IEnav=false
    if(IEnav==true){
        $("#pagina_home").css("margin-left","-150px");
		
    }
	
    $(".cajahome").stop();
    if (typeof galInterval  != "undefined")
        clearInterval(galInterval);
    $("#conthome").css("marginLeft",0-(checkPosicion())*w+"px");
    if (nfotos>1)
        galInterval = setInterval("pasaFoto(null,w,nfotos,509,'','',true)",velocidad);
    else {
        $("#pagina_home").hide();
    }

}

function ajustaGaleriaInterior() {
    // Anchura
    w=$(window).width();
    if (w>1280) w=1280;
    $("#flash_home").css("width",w+"px");
    $(".cajahome").css("width",(w*nfotos)+"px");
    $("#contentgal .cajahome div").each(function()
    {
        $(this).css("width",w+"px");
    });
    ml = (w*1025)/1280;
    if (w>=1280) ml = 1025;
    if (w<1200){
        ml=ml+80;
        $("#pagina_home").css("margin-left",ml+"px");
		
    }
    else
        $("#pagina_home").css("margin-left","1005px");
	
    nav_msie=navigator.userAgent.search(/MSIE/)
    if(nav_msie>0)var IEnav=true
    else var IEnav=false
    if(IEnav==true){
        $("#pagina_home").css("margin-left","150px");
		
    }
	
	
    nav_msie=navigator.userAgent.search(/MSIE 6/)
    if(nav_msie>0)var IEnav=true
    else var IEnav=false
    if(IEnav==true){
        $("#pagina_home").css("margin-left","-150px");
		
    }
	
    $(".cajahome").stop();
    if (typeof galInterval  != "undefined")
        clearInterval(galInterval);
    $("#conthome").css("marginLeft",0-(checkPosicion())*w+"px");
    if (nfotos>1)
        galInterval = setInterval("pasaFoto(null,w,nfotos,449,'','',true)",velocidad);
    else {
        $("#pagina_home").hide();
    }

}
function menuInteriorOver(iditem){
	
    var id="#"+iditem;
    var itemenu=id+".item";

    $(itemenu).css({
        'background':'#333333 url('+ruta+'content/imgs/fondos/flechablanca.png) no-repeat'
        })
    $(itemenu).css({
        'background-position':'182px 12px'
    })
    $(itemenu).css({
        "color":"#ffffff"
    })
		
}
function menuInteriorOut(iditem)
{
    var id="#"+iditem;
    var itemenu=id+".item";
		
    $(itemenu).css({
        'background':'#f2f2f0 url('+ruta+'content/imgs/fondos/flechanegra.png) no-repeat'
        })
    $(itemenu).css({
        'background-position':'182px 12px'
    })
    $(itemenu).css({
        "color":"#333333"
    })
}
function menuInteriorOverres(iditem){
	
    var id="#"+iditem;
    var itemenu=id+".itemres";
    var itemenu2=id+".itemres .contres";

    $(itemenu).css({
        'background':'#333333 url('+ruta+'content/imgs/fondos/flechablanca.png) no-repeat'
        })
    $(itemenu).css({
        'background-position':'182px 12px'
    })
    $(itemenu2).css({
        "color":"#ffffff"
    })
		
}
function menuInteriorOutres(iditem)
{
    var id="#"+iditem;
    var itemenu=id+".itemres";
    var itemenu2=id+".itemres .contres";
		
    $(itemenu).css({
        'background':'#f2f2f0 url('+ruta+'content/imgs/fondos/flechagrana.png) no-repeat'
        })
    $(itemenu).css({
        'background-position':'182px 12px'
    })
    $(itemenu2).css({
        "color":"#a40a40"
    })
}
	
function menuSubInteriorOver(iditem){
    var id="#"+iditem;
    var itemenu=id+".itemint";

    $(itemenu).css({
        "font-weight":"bold"
    })
		
}
function menuSubInteriorOut(iditem)
{
    var id="#"+iditem;
    var itemenu=id+".itemint";
		
    $(itemenu).css({
        "font-weight":"normal"
    })
}
	
function menuInteriorOn(iditem){
    var id="#"+iditem;
    var itemenu=id+".item .cont";
    $(itemenu).css({
        "border-bottom":"3px solid #c9282d"
    })
		
}

function changeColorOver(iditem,color){
    var id="#"+iditem;
    var itemexp=id+" .intiem2";

    $(itemexp).css({
        "color":color
    })
		
}
function changeColorOut(iditem,color)
{
    var id="#"+iditem;
    var itemexp=id+" .intiem2";

    $(itemexp).css({
        "color":color
    })
}
	
	
function print_r (array, return_val) {
    // Prints out or returns information about the specified variable  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/print_r
    // +   original by: Michael White (http://getsprink.com)
    // +   improved by: Ben Bryan
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +      improved by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: echo
    // *     example 1: print_r(1, true);
    // *     returns 1: 1
    
    var output = "", pad_char = " ", pad_val = 4, d = this.window.document;
    var getFuncName = function (fn) {
        var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
        if (!name) {
            return '(Anonymous)';
        }
        return name[1];
    };
 
    var repeat_char = function (len, pad_char) {
        var str = "";
        for (var i=0; i < len; i++) {
            str += pad_char;
        }
        return str;
    };
 
    var formatArray = function (obj, cur_depth, pad_val, pad_char) {
        if (cur_depth > 0) {
            cur_depth++;
        }
 
        var base_pad = repeat_char(pad_val*cur_depth, pad_char);
        var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char);
        var str = "";
 
        if (typeof obj === 'object' && obj !== null && obj.constructor && getFuncName(obj.constructor) !== 'PHPJS_Resource') {
            str += "Array\n" + base_pad + "(\n";
            for (var key in obj) {
                if (obj[key] instanceof Array) {
                    str += thick_pad + "["+key+"] => "+formatArray(obj[key], cur_depth+1, pad_val, pad_char);
                } else {
                    str += thick_pad + "["+key+"] => " + obj[key] + "\n";
                }
            }
            str += base_pad + ")\n";
        } else if (obj === null || obj === undefined) {
            str = '';
        } else { // for our "resource" class
            str = obj.toString();
        }
 
        return str;
    };
 
    output = formatArray(array, 0, pad_val, pad_char);
 
    if (return_val !== true) {
        if (d.body) {
            this.echo(output);
        }
        else {
            try {
                d = XULDocument; // We're in XUL, so appending as plain text won't work; trigger an error out of XUL
                this.echo('<pre xmlns="http://www.w3.org/1999/xhtml" style="white-space:pre;">'+output+'</pre>');
            }
            catch (e) {
                this.echo(output); // Outputting as plain text may work in some plain XML
            }
        }
        return true;
    } else {
        return output;
    }
}



$(window).resize(function() {
    var winwi = "100%";
    $("#central").css("width", winwi);
});



function valida_busqueda(texto) {
    if (document.form_buscar.busca.value!='' && document.form_buscar.busca.value!=texto) return true;
    else return false;
}


//funciones bk
function NewWindowScrollResize(theURL, hauteur, largeur) 
{
var winl = (screen.width - largeur) / 2;
var wint = (screen.height - hauteur) / 2;
winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+',scrollbars=1,resizable=1'
win = window.open(theURL, "", winprops)
}
