﻿
function cFadingImageController() {

}
cFadingImageController.prototype = {
    BannerObject: new Object(),
    CurrentIndex: 0,
    FadeTime: 2000,
    DelayBetweenFades: 4000,
    NumberOfItems: 0,
    Timer: null,
    Setup: function (banner, fadeTime, delayBetweenFades) {
        var that = this;
        that.BannerObject = banner;
        that.FadeTime = fadeTime;
        that.NumberOfItems = that.BannerObject.find('>.slide').length;
        that.DelayBetweenFades = delayBetweenFades;
        that.BannerObject.find('.slide').not(':first-child').hide();
        that.StartMove();
    },
    StartMove: function () {
        var that = this;
        $(this).everyTime(that.DelayBetweenFades, function (i) {
            that.Transition();
        });
    },
    GetByIndex: function (index) {
        return this.BannerObject.find('>.slide:eq(' + index % this.NumberOfItems + ')');
    },
    Transition: function () {
        var that = this;
        var Current = this.GetByIndex(this.CurrentIndex);
        var Next = this.GetByIndex(this.CurrentIndex + 1);
        this.CurrentIndex++;
        Current.fadeOut(this.FadeTime);
        Next.fadeIn(this.FadeTime);
    }
}
var Banners = new Array();
var BannerObj = new cFadingImageController();
$(document).ready(function () {

    $('.featuredPod').each(function (index) {
        var slide1 = $(this).find('.slide1');
        var slide2 = $(this).find('.slide2');
        slide1.mouseenter(function () {
            slide1.attr('style', 'display:none;');
            slide2.attr('style', 'display:inline;');
        });
        slide2.mouseleave(function () {
            slide2.attr('style', 'display:none;');
            slide1.attr('style', 'display:inline;');
        });
    });
    var timerDelay = 4000;
    if ($('.offerSlidy') != null) {

        $('.offerSlidy').each(function (index) {
            BannerObj = new cFadingImageController();
            BannerObj.Setup($(this), 1000, 2000);
            Banners.push(BannerObj);
        })
    }


});

function ImgError(source) {
    source.src = "/images/featured/noimage.gif";
    source.onerror = "";
    return true;
} 

/****Lower Pod Code*****/
$(document).ready(function () {
    // Handler for .ready() called.
    $(".MainCategories").hide();
    $("#mainContent").css({"margin-left": "0px"});
    $(".LowerPodHolder .LowerPod .Overlay-Inner")
        .removeClass("Overlay")
        .addClass("Text")
        .append('<div class="Corner"></div>')
        .children("span").css({ "position": "relative",
            "display": "block",
            "opacity": "0",
            "z-index": "75"
        });

    // Case study hover behaviour
    $(".LowerPodHolder .LowerPod .Text").hoverIntent(function () {
        $(this).addClass("Item-Hover");
        $(".Corner", this).animate({ borderWidth: 255 }, 250).siblings("span").delay(250).animate({ opacity: 1 }, 150);
    },
    function () {
        $(this).removeClass("Item-Hover");
        $(this).children("span").animate({ opacity: 0 }, 100).siblings(".Corner").delay(100).animate({ borderWidth: 20 }, 250);
    });
});




