var homeSelected = 1;
var homeClicked = false;

$(function() {
    $("a.fbox").fancybox({
        'transitionIn'	:	'elastic',
        'transitionOut'	:	'elastic',
        'speedIn'	:	600,
        'speedOut'	:	300,
        'overlayShow'	:	false,
        'hideOnContentClick'   :   true,
        'showCloseButton'   :   false,
        'enableEscapeButton'   :   true,
        'opacity'   :   true,
        'centerOnScroll'   :   true
    });
});

function home_highlights(call, block) {
    var css_path = 'div.banners div.window';
    var interval = 10; // Segundos para cambiar el destacado
    var part = 1024; // Pixeles de ancho de cada uno
    var total = $(css_path + ' div.slider').children('div.banner').length; // Numero de destacados
    var position = $(css_path).scrollLeft(); // Posicion horizontal
    var scrollTo = 0; // Posicion a la que haremos scroll
    var speed = 750; // Velocidad del scroll (ms)

    if (total == 1) {
        $('div.left_arrow').css('display', 'none')
        $('div.right_arrow').css('display', 'none')
    } else {
        if (call == true) {
            // Primera llamada
            setTimeout("home_highlights()", interval*1000);
            return false
        }
    }

    if (total > 0) {
        if (block) {
            if (block < 1) block = total;
            if (block > total) block = 1;
            scrollTo = (part*(block-1))
            homeSelected = (scrollTo/part) + 1;
            homeClicked = true;
            $(css_path).animate({scrollLeft: scrollTo}, speed);
        } else {
            if (position == ((total*part)-part)) {
                // Final, volvemos a 0
            } else {
                scrollTo = position + part;
            }
            if (homeClicked == false) {
                homeSelected = (scrollTo/part) + 1;
                $(css_path).animate({scrollLeft: scrollTo}, speed);
                setTimeout("home_highlights()", interval*1000);
            }
        }
    }
    //console.log(homeSelected)
}

$(document).ready(function() {
    $('.two-columns').columnize({ columns: 2 });
})

function email_this()
{
    mail_str = "mailto:?subject=" + document.title;
    mail_str += "&body=" + location.href;
    location.href = mail_str;
}
