﻿$(document).ready(function () {

    if ($("#ctl00_cphMain_ucNewsModule_rptNews_ctl00_imgNews").attr("src") != null) 
    {
        $("#divNewsContent").removeClass("content");
        $("#divNewsContent").addClass("contentWithPicture");
    }

    //rollover effect on links  
    $("a.simplehover img, img.simplehover").mouseover(function () {
        $(this).attr("src", $(this).attr("src").replace("-off.", "-on."));
    }).mouseout(function () {
        $(this).attr("src", $(this).attr("src").replace("-on.", "-off."));
    });

    VerticalCenteringForIE();

    //Banners slideshow
    $('#slideshow').cycle({ timeout: 10000, next: '#slideshow-next' });
    $('#slideshowtop').cycle({ timeout: 10000, next: '#slideshow-next' });

    $("#slideshow-play").hide();
    $('#slideshow-play').click(function () { $("#slideshow").cycle('resume'); $("#slideshowtop").cycle('resume'); $("#slideshow-play").hide(); $("#slideshow-pause").show(); })
    $('#slideshow-pause').click(function () { $("#slideshow").cycle('pause'); $("#slideshowtop").cycle('pause'); $("#slideshow-pause").hide(); $("#slideshow-play").show(); })

    //Product drop-downs
    $("ul.sf-menu").superfish({
        animation: { height: 'show' },   // slide-down effect without fade-in 
        autoArrows: false,
        delay: 1200               // 1.2 second delay on mouseout 
    });

    //ScrollTo 

    // Scroll initially if there's a hash (#something) in the url 
    $.localScroll.hash({
        target: '#content', // Could be a selector or a jQuery object too.
        queue: true,
        duration: 1000
    });

    $.localScroll({
        target: '#content', // could be a selector or a jQuery object too.
        queue: true,
        duration: 1000,
        hash: true
    });

});

//¤¤¤ FUNCTIONS & UTILITIES ¤¤¤

function VerticalCenteringForIE() {
    $(".category-image").load(function () {
        $(this).css("top", ($(this).parent().height() - $(this).height()) / 2);
    }).each(function () {
        if (this.complete) $(this).trigger("load"); //Patch for IE cached images
    });
}

