Cufon.replace('fieldset legend, .heading,.heading2,.nav-pages,#section .teaser h3,#section .teaser2 h3,.map h3,#section .user-login legend, .news-teaser h3, .main .content h1, .main .content h2, .main .content h3,.tag-cloud h4,fieldset legend, .heading h2, .suppliers h4, .suppliers2 h4, .nav-supp h3, .blobs1 a span', { fontFamily: 'ConduitITCStd Bold' });

jQuery(function ($) {
    /* nav-main hover fade */
    if ($.browser.msie && $.browser.version == "6.0") {

    } else {
        $('.nav-main li:not(.active) span').css({ 'opacity': '0' });

        $('.nav-main li:not(.active)').hover(function () {
            $(this).find('span').stop().animate({ 'opacity': '1' });
        }, function () {
            $(this).find('span').stop().animate({ 'opacity': '0' }, 100);
        });
    }

    /* global search */
    /*$('.search-block .form-button').click(function () {
    top.location.href = "/soek.aspx?q=" + $('.search-block .q').val();
    });*/

    /* slideshow */
    var slideLength = $('.slideshow .slide').length;
    var currentSlide = 0;

    $('.slideshow').append('<ul class="slideNav"></ul>');

    $('.slide').each(function (index) {
        $('.slideNav').append('<li>' + (index + 1) + '</li>');
    });

    if ($(".slide").length < 2)
        $(".slideNav").hide();

    $('.slideNav li:first').addClass('active');

    $('.slideWrapper').css({ 'width': slideLength * 680 });

    $('.slideNav li').live('click', function () {
        $('.slideNav li').removeClass('active');
        $(this).addClass('active');
        currentSlide = $(this).index();
        $('.slideWrapper').animate({ left: -(680 * currentSlide) }, { queue: false });
        return false;
    });

    $('.slideshow .next').live('click', function (e) {
        e.preventDefault();
        nextSlide();
    });

    $('.slideshow .last').live('click', function (e) {
        e.preventDefault();
        prevSlide();
    });

    $('.slideshow .next,.slideshow .last').hover(function () {
        $(this).stop().animate({ 'opacity': '0.4' }, 300);
    }, function () {
        $(this).stop().animate({ 'opacity': '0.2' }, 200);
    });

    function nextSlide() {
        if (currentSlide + 1 == slideLength) {
            $('.slideNav li:eq(0)').trigger('click');
        } else {
            $('.slideNav li:eq(' + (currentSlide + 1) + ')').trigger('click');
        }
    }

    function prevSlide() {
        if (currentSlide === 0) {
            $('.slideNav li:eq(' + (slideLength - 1) + ')').trigger('click');
        } else {
            $('.slideNav li:eq(' + (currentSlide - 1) + ')').trigger('click');
        }
    }

    function autoPlay() {
        rotate = setInterval(function () { nextSlide(); }, 4500);
    } autoPlay();

    $('.slideshow').hover(function () {
        clearInterval(rotate);
    }, function () {
        autoPlay();
    });

    $('.slideNav li:first').addClass('active');


    $('.slideshow .slide, .nav-sub li, .nav-main li, .nav-sub ul.last').click(function () {
        window.location.href = $('a:first', this).attr('href');
    });

    $(window).load(
	    function () {
	        var navWidth = $('.slideNav').width();
	        $('.slideNav').css({ 'margin-left': '-' + (navWidth / 2) + 'px' });
	    }
	);

    /* footer */
    var _currentId = $("#footer .varuhus-list").val();
    $("#footer-address-" + _currentId).css("display", "block");
    $("#footer .varuhus-list").change(function () {
        $("#footer-address-" + _currentId).css("display", "none");
        _currentId = $("#footer .varuhus-list").val();
        $("#footer-address-" + _currentId).css("display", "block");
    });

    /* share by email */
    $(".share .tipsa-form").dialog({
        modal: true,
        resizable: false,
        draggable: false,
        autoOpen: false
    });
    $(".share .email").click(function () {
        $(".tipsa-form").dialog("open");
    });
    $(".tipsa-form .close").click(function () {
        $(".tipsa-form").dialog("close");
    });
});






