(function($) {
    var sb_Slideshow = {
        options: { timeout: 5000, fadeDelay: 500, active: 0, last: 0 },
        _slides: null,
        _init: function() {
            //get all DIVs inside the containing element
            this._slides = $(this.element).find("div");
            if (this._slides) {
                this._slides.css("display", "none");
                this._slides.css("position", "absolute");
                if (this.options.active < 0 || this.options.active >= this._slides.length) { this.options.active = 0 }
                $(this._slides.get(0)).css('display', 'block');
                var me = this;
                window.setInterval(function() { me.showNext(); }, this.options.timeout);
            }
        },
        hideLast: function() {
            $(this._slides.get(this.options.last)).css('display', 'none');
        },
        showNext: function() {
            try {
                var current = $(this._slides.get(this.options.active));
                var nextIndex = (this.options.active + 1) % this._slides.length;
                var next = $(this._slides.get(nextIndex));

                //place the current under the next
                current.css("z-index", "100");
                next.css("z-index", "200");

                //Fade in the next one, with a callback to hide the last
                var me = this;
                next.show("fade", null, this.options.fadeDelay, function() { me.hideLast() })

                //set the current indices
                this.options.last = this.options.active;
                this.options.active = nextIndex;
            } catch (ex) { }
        },
        destroy: function() {
            //call the factory destroy
            $.Widget.prototype.destroy.call(this);
        }
    }

    $.widget("ui.slideshow", sb_Slideshow);
})(jQuery);

$(document).ready(function() { $("#c470_wrap").slideshow(); });

// Added By Elisha Cornelius, 20th December 2011
// Alpha Dezine (NZ) Ltd. www.alphadezine.com
//Added function to submit form using javascript
//as nested form tags are not allowed and the system is
//based on ASP.Net which by default has a Form Tag 
Included
    function RegisterNewsLetter()
    {

        document.forms['Form1'].action = 'http://www.aweber.com/scripts/addlead.pl';
        document.forms['Form1'].target= '_new';
        document.forms['Form1'].submit();
 
        return false;

    }
