function InteractiveBlock(oControl) {

    if (typeof (_interactive_prototype_called) == 'undefined') {
        if ($.browser.msie && parseInt($.browser.version) == 6) {
            document.execCommand('BackgroundImageCache', false, true);
        }
        _interactive_prototype_called = true;
        InteractiveBlock.prototype.StartTransition = StartTransition;
        InteractiveBlock.prototype.FireTransition = FireTransition;
        InteractiveBlock.prototype.Resume = Resume;
        InteractiveBlock.prototype.Interrupt = Interrupt;
    }

    this.$contents = oControl.children(".contentArea").children("div");
    this.$navigationItems = oControl.children(".navigationArea").children("div.navigationElement");
    this.totalContents = this.$contents != null || undefined ? this.$contents.length : 0;
    this.currentIndex = 0;
    this.nextIndex = null;
    this.timer = null;
    this.fadeDelay = oControl.attr("fadeDelay") != null || undefined ? parseInt(oControl.attr("fadeDelay")) : 5000;
    this.fadeDelayAfterInterrupt = oControl.attr("fadeDelayAfterInterrupt") != null || undefined ? parseInt(oControl.attr("fadeDelayAfterInterrupt")) : 7000;
    this.fadeInTime = oControl.attr("fadeInTime") != null || undefined ? parseInt(oControl.attr("fadeInTime")) : 3000;
    this.fadeOutTime = oControl.attr("fadeOutTime") != null || undefined ? parseInt(oControl.attr("fadeOutTime")) : 2000;

	this.isNavigationOn = this.$navigationItems.length > 0 ? true : false;

    if (this.isNavigationOn) {
        var navigationAlign = oControl.attr("navAlign");
        var navigationOffsetLeft = oControl.attr("navOffsetLeft");
        var firstNavElementMarginLeft = 0;
        var navigationAreaTotalWidth = 600;
        var navElementsTotalWidth = 0;

        oControl.children(".navigationArea").children("div").each(function(index) {
            navElementsTotalWidth = navElementsTotalWidth + $(this).outerWidth(true);            
        });
        switch (navigationAlign) {
            case "center":
                firstNavElementMarginLeft = parseInt((parseInt(navigationAreaTotalWidth) - parseInt(navElementsTotalWidth)) / 2);
                break;

            case "right":
                firstNavElementMarginLeft = parseInt(navigationAreaTotalWidth) - parseInt(navElementsTotalWidth);
                break;

            case "left":
            default:            
                break;
        }
        // Dynamically find the postioning and fixing the IE6 problem		
		$(oControl.children(".navigationArea").children("div")[0]).css("margin-left", (firstNavElementMarginLeft + parseInt(navigationOffsetLeft)) + "px").css("display", "inline");

        this.$navigationItems.data('event.data', this).mouseover(function() {
            $(this).data('event.data').Interrupt($(this).data('event.data').$navigationItems.index($(this)), $(this).data('event.data'));
            $(this).toggleClass($(this).attr("splActive"));
            if ($(this).attr("splHover") != null && $(this).attr("splHover") != undefined) {
                $(this).toggleClass($(this).attr("splHover"));
            }
        })
		.mouseout(function() {
        	if ($(this).attr("splHover") != null && $(this).attr("splHover") != undefined) {
            	$(this).toggleClass($(this).attr("splHover"));
	        }
    	});
    }

    function StartTransition() {
        if (this.$contents.length > 1) {
            if (this.currentIndex >= this.totalContents - 1) {
                this.nextIndex = 0;
            } else {
                this.nextIndex = this.currentIndex + 1;
            }
        } else {
            return;
        }
        this.FireTransition();
    }

    function FireTransition() {
        $(this.$contents[this.currentIndex]).fadeOut(this.fadeOutTime);
        $(this.$contents[this.nextIndex]).hide();
        $(this.$contents[this.nextIndex]).fadeIn(this.fadeInTime);
        if (this.isNavigationOn) {
            $(this.$navigationItems[this.currentIndex]).toggleClass($(this.$navigationItems[this.currentIndex]).attr("splActive"));
            $(this.$navigationItems[this.nextIndex]).toggleClass($(this.$navigationItems[this.nextIndex]).attr("splActive"));
        }
        this.currentIndex = this.nextIndex;
        this.Resume(this.fadeDelay);
    }

    function Interrupt(index) {
        if (this.totalContents >= index) {
            clearTimeout(this.timer);
            $(this.$contents[this.currentIndex]).hide();
            $(this.$navigationItems[this.currentIndex]).toggleClass($(this.$navigationItems[this.currentIndex]).attr("splActive"));
            this.currentIndex = index;
            $(this.$contents[this.currentIndex]).show();
            this.Resume(this.fadeDelayAfterInterrupt);
        }
    }

    function Resume(delay) {
        var thisRef = this;
        thisRef.timer = setTimeout(function() { thisRef.StartTransition(); }, delay);
    }


    this.Resume(this.fadeDelay);

}
