/// <reference path="libs/jquery-1.6.2.js" />
$(function () {
    // logo link
    $(".containerWideHeader header h1").click(function (e) {
        document.location.href = $(this).find("a").attr("href");
    });

    // preload images
    var gallery = $(".gallery"), images = '';
    gallery.children("img").each(function (index) {
        // Create string og sources
        images += (index == 0) ? $(this).attr("src") : ',' + $(this).attr("src");

        // Create div and remove image
        gallery.append($('<div class="galleryImage"></div>').css('background-image', 'url(' + $(this).attr("src") + ')'));
        $(this).remove();
    });

    $.loadImages(images.split(","), function () {
        // Remove loading
        $(".gallery.loading").removeClass("loading");

        // Start Cycle
        $('.gallery').before('<ul class="gallerypager">').cycle({
            fx: 'fade',
            timeout: 10000,
            speed: 3000,
            pager: '.gallerypager',
            // callback fn that creates a thumbnail to use as pager anchor 
            pagerAnchorBuilder: function (idx, slide) {
                return '<li><a href="javascript:void();">' + (idx + 1) + '</a></li>';
            }
        });
    });

});
$("#main").height($("#contentHolder").height());
$("a.spamMail").each(function (index) { // Replace mails
    var $this = $(this);
    $this.text("info@salonpremier.dk");
    $this.attr("href", "mailto:info@salonpremier.dk");
});
