function adapta(){
    $("body").width($("html").width());
    if ($("body").width() <= 969) {
        $("body").width(970);
    }
}

//
$(window).bind('resize', function(){
    adapta();
});
function carga_video(){
	$("#placa_negra").fadeTo(1000,0.7);
	margentop = ($(window).height()/2) - 240;
	margenleft = ($(window).width()/2) - 300;
	$("#video").css("top",margentop);
	$("#video").fadeIn(1000);
	$("#video").css("left",margenleft);
	$("#placa_negra").css("height", $(window).height() + "px");
    $("#placa_negra").css("width", $(window).width() + "px");
}
function cierra_video(){
	$("#placa_negra").fadeOut(1000);
}
function columna_gris(){
    left_imagen = 305 + (($("body").width() - 970) / 2);
    ancho_imagen = left_imagen;
    alto_imagen = $("#contenido_general_con_columna").height() + 104;
    $("#columna_gris").css("height", alto_imagen + "px");
    $("#columna_gris").css("width", ancho_imagen + "px");
}

function imagen_lateral(){
    left_imagen = 761 + (($("body").width() - 970) / 2);
    ancho_imagen = $("body").width() - left_imagen;
    alto_imagen = $("#contenido_general").height() + 104;
    top_imagen = $("body").height() - alto_imagen - 165;
    $("#imagen_lateral").css("top", top_imagen + "px");
    $("#imagen_lateral").css("height", alto_imagen + "px");
    $("#imagen_lateral").css("width", ancho_imagen + "px");
    $("#imagen_lateral").css("left", left_imagen + "px");
}

function cambia_inmueble(){
    inmuebles_destacados_actual++;
    if (inmuebles_destacados_actual > cantidad_inmuebles_destacados) {
        inmuebles_destacados_actual = 1;
    }
    $(".inmuebles_destacados").fadeOut(1000);
    $("#inmuebles_destacados" + inmuebles_destacados_actual).fadeIn(1000);
}

function cambia_header(){
    header_actual++;
    if (header_actual > cantidad_headers) {
        header_actual = 1;
    }
	//alert(header_actual);
    $(".slide_home_header").fadeOut(1000);
    $("#slide_home" + header_actual).fadeIn(1000);
    $(".titulo_encabezado_home").animate({
        top: '355px'
    }, 1000);
    $("#back_titulo_encabezado_home").animate({
        top: '355px'
    }, 1000);
    $("#back_titulo_encabezado_home").animate({
        top: '222px'
    }, 1500);
    $("#titulo_encabezado_home" + header_actual).animate({
        top: '220px'
    }, 1500);
}


$("#flecha1").click(function(){
    clearInterval(intervalo2);
    inmuebles_destacados_actual--;
    if (inmuebles_destacados_actual < 1) {
        inmuebles_destacados_actual = cantidad_inmuebles_destacados;
    }
    $(".inmuebles_destacados").fadeOut(1000);
    $("#inmuebles_destacados" + logo_actual).fadeIn(1000);
});
$("#flecha2").click(function(){
    clearInterval(intervalo2);
    inmuebles_destacados_actual++;
    if (inmuebles_destacados_actual > cantidad_inmuebles_destacados) {
        inmuebles_destacados_actual = 1;
    }
    $(".inmuebles_destacados").fadeOut(1000);
    $("#inmuebles_destacados" + inmuebles_destacados_actual).fadeIn(1000);
});

