﻿$(document).ready(function () {
    var atf = 250; // Animation Time Frame
    var satf = 500; // Shadow Animation Time Frame
    var aHex = '#EFF9FF'; // Animated Hex
    var iHex = '#fff'; // Idle Hex
    var id = '';
    var imgHost = 'http://workstation.nscorpstaging.com/FileUploads/CMS/Images/';
    $('.shadow').animate({ 'opacity': 0 }, atf);
    $('.webbing').animate({ 'opacity': .1 }, atf);

    $('#NewsTicker #NewsList').cycle({
        fx: 'scrollHorz',
        prev: '#Previous',
        next: '#Next',
        width: '100%',  
        timeout: 0,
        speed: atf
    });
    $('#AutoNewsCycle #NewsTicker #NewsList').cycle({
        fx: 'scrollHorz',
        prev: '#Previous',
        next: '#Next',
        width: '100%',
        timeout: 8000,
        speed: atf
    });
    $('#NewsRoller #NewsList').cycle({
        fx: 'scrollVert',
        prev: '#Previous',
        next: '#Next',
        width: '100%',
        timeout: 0,
        speed: atf
    });
    $('#AutoNewsCycle #NewsRoller #NewsList').cycle({
        fx: 'scrollVert',
        prev: '#Previous',
        next: '#Next',
        width: '100%',
        timeout: 8000,
        speed: atf
    });
    $('#Slideshow').cycle({
        fx: 'scrollHorz',
        pager: '#SlideshowNav',
        timeout: 0,
        speed: atf,
        pagerAnchorBuilder: function (idx, slide) {
            return '<a href="javascript:void(0)" class="UI-slideshow-icons icon-slideshow-bullet"><span class="slideShowThumb' + idx + '"><img src="' + imgHost + 'slideShowImg'+idx+'.gif"/></span></a>';
        }
    });
    $('#FeatureSlideshow').cycle({
        fx: 'scrollHorz',
        pager: '#SlideshowNav',
        timeout: 4000,
        speed: atf,
        pagerAnchorBuilder: function (idx, slide) {
            var classArray = ['UI-slideshow-icons icon-mobile-home', 'UI-slideshow-icons icon-mobile-performance', 'UI-slideshow-icons icon-mobile-network', 'UI-slideshow-icons icon-mobile-parties', 'UI-slideshow-icons icon-mobile-orders']
            var altArray = ['Home', 'Performance', 'Network', 'Parties', 'Orders']
            return '<a href="javascript:void(0)" class="' + classArray[idx] + '">' + altArray[idx] + '</a>';
        }
    });
    $('#FeatureContainer #SlideshowNav a').click(
        function () {
            $('#FeatureSlideshow').cycle('pause');
        }
    );

    $('#Modal1').jqm();

    $('.column').hover(
        function () {
            id = '#' + $(this).attr('id');
            $(id + ' .shadow').animate({ 'opacity': .6 }, satf),
            $(id).animate({ 'backgroundColor': aHex }, atf),
            $(id + ' img').animate({ 'top': '-=20px' }, atf);
        },
        function () {
            $(id + ' .shadow').animate({ 'opacity': 0 }, atf),
            $(id).animate({ 'backgroundColor': iHex }, atf),
            $(id + ' img').animate({ 'top': '+=20px' }, atf);
        }
    );

    $('.biography').hover(
        function () {
            id = '#' + $(this).attr('id');
            $(id + ' .webbing').animate({ 'opacity': .25 }, atf);
        },
        function () {
            $(id + ' .webbing').animate({ 'opacity': .1 }, atf);
        }
    );
    $('.biography ' + id + ' a').click(
        function () {
            $(id + ' p').slideToggle(atf);
            $(this).text($(this).text() == 'Read more' ? 'Show less' : 'Read more');
        }
    );

    if ($('.ContactForm input').val() != '') {
        $('input').removeClass('watermark');
    }
    $('.ContactForm .field').focus(
        function () {
            id = '#' + $(this).attr('id');
            $(id).removeClass('watermark');
        }
    );
    $('.ContactForm .field').blur(
        function () {
            if ($(id).val() == '') {
                $(id).addClass('watermark');
            }
        }
    );
});

