﻿//Funcion Bajar pie abajo
function fillthescreen(){
    winH = windowHeight();
    heightNeeded=winH-293;//Los 242px son 170 de la cabecera,72 del pie
    if( typeof( window.innerWidth ) != 'number' ) { //Explorer no reconoce min-height	
//	        if (winH > 0) {
//	        var contentHeight = document.getElementById('div_content').offsetHeight;
//	        var footerHeight  = document.getElementById('div_pie').offsetHeight;
//	        if (winH - (contentHeight + footerHeight + 170) >= 0) {
//	            document.getElementById('div_content').style.height=(winH - 242) +'px';
//	            document.getElementById('div_pie').style.top = (winH - 242)+'px';
//	        }
//        }
    }
    else{ //Para cualquier otro navegador-> minHeight
        heightNeeded = winH - 293; //Los 242px son 170 de la cabecera,72 del pie
        document.getElementById('div_content').style.minHeight=heightNeeded +'px';
    }
}

function fillthescreen2(){
    winH = windowHeight();
    heightNeeded=winH-411;//Los 242px son 170 de la cabecera,241 del pie
    if( typeof( window.innerWidth ) != 'number' ) { //Explorer no reconoce min-height	
	        if (winH > 0) {
	        var contentHeight = document.getElementById('div_content').offsetHeight;
	        var footerHeight  = document.getElementById('div_pie').offsetHeight;
	        if (winH - (contentHeight + footerHeight + 170) >= 0) {
	            document.getElementById('div_content').style.height=(winH - 411) +'px';
	            document.getElementById('div_pie').style.top = (winH - 411)+'px';
	        }
        }
    }
    else{ //Para cualquier otro navegador-> minHeight
        heightNeeded=winH-411; //Los 242px son 170 de la cabecera,72 del pie
        document.getElementById('div_content').style.minHeight=heightNeeded +'px';
    }
}
        
function windowHeight(){
    var alto= 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        alto= window.innerHeight; //Firefox
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        alto= document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        alto = document.body.clientHeight; //Explorer
    }
        return alto;
}

function redimensionar_menu(){

// Calculate total width of list items
var lis = $('#menu_ofita ul li a');

//Medida del separador, multiplicaremos por el numero de elementos - 1.
var separador = 3;
separador = separador * (lis.length-1);
var menuwidth = 936; //Medida del menu
var actualWidth = menuwidth - separador;
var totalLIWidth = 0;



lis.each(function(){
    totalLIWidth += $(this).find('div:first').width();
});

// Work out how much padding we need
var requiredPadding = Math.round(((actualWidth-totalLIWidth)/lis.length)/2);

// To account for rounding errors, the error is going to be forced into the first tab.
var roundingErrorFix = (requiredPadding*lis.length*2)+totalLIWidth-actualWidth;

// Apply padding to list items
var isFirst = true;
lis.each(function() {
    if(isFirst) {
        $(this).find('div:first').css('padding-left',requiredPadding-roundingErrorFix+'px')
                .css('padding-right',requiredPadding-roundingErrorFix+'px');
        isFirst = false;
    }
    else
        $(this).find('div:first').css('padding-left',requiredPadding+'px')
                .css('padding-right',requiredPadding+'px');
});

}

//IMAGENES RELACIONADAS
function CargarImagen(imagen,descripcion, imagen_a) {
         $('#imagen_producto').fadeOut("slow", function() {
             $('#imagen_producto').attr("src",imagen).load(function() {
                 $('#imagen_producto').fadeIn("slow");
                 $('#imagen_producto').attr("alt",descripcion);
                 $('#imagen_producto').attr("title",descripcion);
                 $('#enlace_ampliar').attr("href",imagen_a);
             });
         });
     }

