/**
 * Created by .
 * User: mikehamilton
 * Date: 3/31/11
 * Time: 4:23 PM
 * Notes: This script has the following dependencies:
 *         - jquery
 *         - jquery.cycle
 */

$(document).ready(function() {
    // HomePage Feature Rotator Config
    $('#featureRotator').cycle({
        fx: 'fade',
        speed: 500,
        timeout: 5000,
        pause: 1,
        random: 0,
        pagerAnchorBuilder: pageinate,
        pager: '#rotatorNav',
        pagerevent: 'click',
        fastOnEvent: 1,
        before: onBefore

    });
    function onBefore(currSlideElement, nextSlideElement, options, forwardFlag) {
        $("#rotator" + $(currSlideElement).attr("rel")).removeClass("selected");
        $("#rotator" + $(nextSlideElement).attr("rel")).addClass("selected");
    }
    function pageinate(index, el) {
        if (index == 0) return '<div id="rotator' + index + '" class="selected"></div>';
        else return '<div id="rotator' + index + '"></div>';
    }
    // Causal Nav Logic
    $('#causalNav').change(function() {
        var url = $('#causalNav').val();

        if (url != 'null') {
            window.location.href = url;
        }
    });
});

