﻿var reloj = null;
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ($active.length == 0) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
                : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order

    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
                .addClass('active')
                .animate({ opacity: 1.0 }, 1000, function() {
                    $active.removeClass('active last-active');
                });
}

$(function() {
    reloj = setInterval("slideSwitch()", 5000);
});

function getHeight() {
    var h = 0;

    //IE
    if (!window.innerWidth) {
        //strict mode
        if (!(document.documentElement.clientWidth == 0)) {
            h = document.documentElement.clientHeight;
        }
        //quirks mode
        else {
            h = document.body.clientHeight;
        }
    }
    //w3c
    else {
        h = window.innerHeight;
    }

    return h;
}

function comprobarTamanos() {
    if (getHeight() < 700) 
    {
        document.getElementById("decorativo_azul").style.visibility = 'hidden';
        document.getElementById("basediseno").style.visibility = 'hidden';
        document.getElementById("fotografo").style.visibility = 'hidden';
    }
    else 
    {
        document.getElementById("decorativo_azul").style.visibility = 'visible';
        document.getElementById("basediseno").style.visibility = 'visible';
        document.getElementById("fotografo").style.visibility = 'visible';
    }
}

function cambioFoto(id) {
    document.getElementById('foto1').setAttribute('class', 'active');
    document.getElementById('foto2').setAttribute('class', 'active');
    document.getElementById('foto3').setAttribute('class', 'active');
    document.getElementById('foto4').setAttribute('class', 'active');

    if (id == "foto1") {
        document.getElementById('foto1').style.visibility = 'visible';
        document.getElementById('foto2').style.visibility = 'hidden';
        document.getElementById('foto3').style.visibility = 'hidden';
        document.getElementById('foto4').style.visibility = 'hidden';
    }
    else
        if (id == "foto2") {
        document.getElementById('foto1').style.visibility = 'hidden';
        document.getElementById('foto2').style.visibility = 'visible';
        document.getElementById('foto3').style.visibility = 'hidden';
        document.getElementById('foto4').style.visibility = 'hidden';
    }
    else
        if (id == "foto3") {
        document.getElementById('foto1').style.visibility = 'hidden';
        document.getElementById('foto2').style.visibility = 'hidden';
        document.getElementById('foto3').style.visibility = 'visible';
        document.getElementById('foto4').style.visibility = 'hidden';
    }
    else
        if (id == "foto4") {
        document.getElementById('foto1').style.visibility = 'hidden';
        document.getElementById('foto2').style.visibility = 'hidden';
        document.getElementById('foto3').style.visibility = 'hidden';
        document.getElementById('foto4').style.visibility = 'visible';
    }
    clearInterval(reloj);
}
