/**
 * Load the carousel on document ready
 */
var moo;
$(document).ready(function() {
    var totalImages = $('#carouselCount').val();
    var randImage = parseInt((Math.random() * 10) % totalImages, 10);
    moo = $("#headCarousel").moodular({
        controls: 'index', 
        auto: true,
        dispTimeout: 5000,
        speed: 500,
        api: true,
        startOn : randImage
    });

    $('.moodular_itemList_li').click(function () { 
        var idcko = $(this).attr('rel');
        moo.moveTo(idcko);
        return false;
    });
});

$(document).ready(function() {
    $('.moodular_itemList_li').qtip({
        prerender: true,
       content: {
          text: function(api) {
             text = $(this).text();
             return $("#carousel_" + text).attr('title');
          }
       },
       style: {
          classes: 'ui-tooltip-dark ui-tooltip-tipped'
       }
    })
});

/**
 * Display hidden e-mail links
 */
$(document).ready(function() {
   $('a.mail_link').each(function() {
       $(this).html($(this).attr("x-addr")+"@comap.cz");
   })
});

/**
 * Helper to send e-mail
 */
function sendMail(address, domain) {
    window.location.href = 'mailto:' + address + '@' + domain;
}

/**
 * Print page helper
 */
function printMe() {
  window.print();
}
