﻿
var activeItem = null;
var currentSlide = 0;

$(document).ready(function () {


    // Homepage Accordion
    $("#accordion li.slideControl");
    activeItem = $("#accordion li.slideControl:first");
    $(activeItem).addClass('active').css({ width: '830px' });

    $("#accordion li.slideControl").click(function () {
        if (this != activeItem) {

            if ($('a', this).hasClass('instantdemo')) {
                currentSlide = 0;
            }

            if ($('a', this).hasClass('educate')) {
                currentSlide = 1;
            }

            if ($('a', this).hasClass('entertain')) {
                currentSlide = 2;
            }

            if ($('a', this).hasClass('engage')) {
                currentSlide = 3;
            }



            $(activeItem).removeClass('active').animate({ width: "50px" }, { duration: 300, queue: false });
            $(this).addClass('active').animate({ width: "830px" }, { duration: 300, queue: false });
            activeItem = this;
        }
        return false;
    });

    //Pricing Plan Accordian

    //Set default open/close settings
    //$('.acc_container').hide(); //Hide/close all containers
    //$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

    //On Click
    // $('.acc_trigger').click(function () {

    //     if ($(this).not(':hidden'))
    //         $(this).toggleClass('active').next().slideUp();

    //     if ($(this).next().is(':hidden')) { //If immediate next container is closed...
    //         $('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
    //         $(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
    //     }
    //    return false; //Prevent the browser jump to the link anchor
    //});



    $(function () {
        setInterval("slideSwitch()", 10000);
    });

    $('.moreInfo').click(function () {
        window.location = $(this).attr('href');
    });




    // Add the Facebook Like button dynamicaly for validation purposes
    var $fbLike = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + window.location.href + '&amp;layout=standard&amp;show_faces=false&amp;width=300&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:40px;" allowTransparency="true"></iframe>';
    $($fbLike).appendTo('.likeButton');

    // Set default values for input elements
    $('input[title], textarea[title]').each(function () {
        if ($(this).val() === '') {
            $(this).val($(this).attr('title'));
        }

        $(this).focus(function () {
            if ($(this).val() == $(this).attr('title')) {
                $(this).val('');
            }
        });
        $(this).blur(function () {
            if ($(this).val() === '') {
                $(this).val($(this).attr('title'));
            }
        });
    });

    $('form').submit(function () {
        $('input[title], textarea[title]', this).each(function () {
            if ($(this).val() == $(this).attr('title')) {
                $(this).val("");
            }
        });
        return true;
    });


    $('.referralSubmit').click(function () {
        $(this).parent('form').submit();
    });

    $('.headerSubmit').click(function () {
        $(this).parent('form').submit();
    });

    $('.footerSubmit').click(function () {
        $(this).parent('form').submit();
    });

    $('.headerLogin').click(function () {
        $(this).parent('form').submit();
    });


    $('.contactUsMasterForm').click(function () {
        $(this).parent('form').submit();
    });





    $(".infoBtn").hover(function () {
        $(".infoCont").stop(true, true).fadeIn("fast");
    },
    function () {
        $(".infoCont").stop(true, true).fadeOut("fast");
    });


    $('.referralMainSubmit').click(function () {
        $('#referalForm').submit();
        return false;
    });



    $('.footerSubmit').click(function () { $(this).parent('form').submit(); return false; });

});

function slideSwitch() {
    currentSlide++;
    if (currentSlide == 4) {
        currentSlide = 0;
        $(activeItem).removeClass('active').animate({ width: "50px" }, { duration: 300, queue: false });
        activeItem = $("#accordion li.slideControl:first");
        $(activeItem).addClass('active').animate({ width: "830px" }, { duration: 300, queue: false });
    } else {
        $(activeItem).removeClass('active').animate({ width: "50px" }, { duration: 300, queue: false });
        $(activeItem).next().addClass('active').animate({ width: "830px" }, { duration: 300, queue: false });
        activeItem = $(activeItem).next();
    }
}

$(document).ready(function () {
    $(".submitImageForm").keypress(function (e) {
        if (e.which == 13) {
            $("#LoginForm").submit();
            return false;
        }

    });
});
