// JavaScript Document
//Equal column heigh Function
function setEqualHeight(columns) {
    var tallestcolumn = 0;
    columns.each(

    function () {
        currentHeight = $(this).height();
        if (currentHeight > tallestcolumn) {
            tallestcolumn = currentHeight;
        }
    });
    columns.height(tallestcolumn);
}
//document ready commands
$(document).ready(function () {
	//Set equal height to speficic columns
	setEqualHeight($("#calltoaction aside"));
	//Slider Setup
    $('#slider1').anythingSlider({
        hashTags: false, 									//overide using hashes at the URL
        delay: 10000,										//Slide animation time
        autoPlay: true,										//Force Autoplay
        animationTime: 1000,								//overall total slide transition time
        buildStartStop: false,								//Force Stop button to not be built
        buildArrows: false,									//force arrows to not be built
        onInitialized: function (e, slider) {				//OnInitalized: Initial script setup, on final page load and slider setup
            var time = 1000,
                // allow movement if < 1000 ms (1 sec)
                range = 50,
                // swipe movement of 50 pixels triggers the slider
                x = 0,
                t = 0,
                touch = "ontouchend" in document,
                st = (touch) ? 'touchstart' : 'mousedown',
                mv = (touch) ? 'touchmove' : 'mousemove',
                en = (touch) ? 'touchend' : 'mouseup';
            slider.$window.bind(st, function (e) {
                // prevent image drag (Firefox)
                e.preventDefault();
                t = (new Date()).getTime();
                x = e.originalEvent.touches ? e.originalEvent.touches[0].pageX : e.pageX;
            }).bind(en, function (e) {
                t = 0;
                x = 0;
            }).bind(mv, function (e) {
                e.preventDefault();
                var newx = e.originalEvent.touches ? e.originalEvent.touches[0].pageX : e.pageX,
                    r = (x === 0) ? 0 : Math.abs(newx - x),
                    // allow if movement < 1 sec
                    ct = (new Date()).getTime();
                if (t !== 0 && ct - t < time && r > range) {
                    if (newx < x) {
                        slider.goForward();
                    }
                    if (newx > x) {
                        slider.goBack();
                    }
                    t = 0;
                    x = 0;
                }
            });Cufon.refresh();
        },
        navigationFormatter: function (index, panel) {
            return ""; 										//create empty link bubbles
     		   },											
        easing: 'easeInOutQuart',							//Animation flow
        onSlideBegin: function (event, slider) {			//what happens AFTER a slide trigger event is called but BEFORE the slide moves.
            var beginSlide = slider.$currentPage.attr('class');
            var endSlide = slider.$targetPage.attr('class');
            if (beginSlide != endSlide) {
                var targetSlide = slider.$targetPage.find('div').attr('data-theColor');
                $('#featureClone').removeClass();
                $('#featureClone').addClass('feature-' + targetSlide);
                if ($.browser.msie) {
                    $('#featureWrap').hide();
                } else {
                    $('#featureWrap').fadeOut(500);
                }
                $('.heroShadow').show();
            }
        },
        onSlideComplete: function (slider) {				///what happens AFTER the slide event is completed sucessfully
            $('#featureWrap').removeClass();
            var currentSlide = slider.$currentPage.find('div').attr('data-theColor');
            $('#featureWrap').addClass('feature-' + currentSlide);
            $('#featureWrap').show();
            if ($.browser.msie) {
                $('.heroShadow').hide();
            } else {
                $('.heroShadow').fadeOut();
            }
        }
    });
});
