
function EmailLink() {
    $('#popoutEmailForm').dialog('open').dialog({ position: ['center', 'center'], title: 'Send information', open: function (type, data) { $(this).parent().appendTo("form"); }
    });
}

function validateEmail() {
    var emailaddress = document.getElementById('RightColumn1_EmailAddressTextBox').value;
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    if (!emailPattern.test(emailaddress)) {
        alert('invald email address - please try again');
        return false;
    }
    else {
        return true;
    }
} /*	Down link functions	*/
$.fn.scrollView = function () {
    return this.each(function () {
        $('html, body').animate({
            scrollTop: $(this).offset().top - 100
        }, 500);
    });
}

$.fn.scrollView2 = function () {
    return this.each(function () {
        $('html, body').animate({
            scrollTop: $(this).offset().top - 142
        }, 500);
    });
}


var outerWidth = -1;
function scrollLeft() {
    var newLeft = parseInt($("#partners-list").css('left')) - 1;

    if (outerWidth == -1) {
        outerWidth = parseInt($("#partners-list .partner-block").first().outerWidth(true));
    }

    if (-outerWidth >= newLeft) {
        $("#partners-list .partner-block").first().insertAfter($("#partners-list .partner-block").last());
        newLeft += outerWidth;
        outerWidth = -1;
    }
    $("#partners-list").css('left', newLeft + 'px');
}

$(document).ready(function () {

    $(".strikethoughHide1").toggle($(".Strikethrough1").attr("checked") == "checked");
    $(".strikethoughHide2").toggle($(".Strikethrough2").attr("checked") == "checked");
    $(".strikethoughHide3").toggle($(".Strikethrough3").attr("checked") == "checked");
    $(".Strikethrough1").click(function () {
        $(".strikethoughHide1").toggle(this.checked);
    });
    $(".Strikethrough2").click(function () {
        $(".strikethoughHide2").toggle(this.checked);
    });
    $(".Strikethrough3").click(function () {
        $(".strikethoughHide3").toggle(this.checked);
    });

    $("#front-page-form").hide();

    /*
    Homepage Carousel buttons
    */

    //DEFAULT
    $(".banner1").show();

    /*
    Homepage banner auto rotation
    */
    setInterval(function () {
        if ($("#banner .banner4").is(":visible")) {
            $("#banner img, .banner-title").hide();
            $(".banner1").fadeIn();
        }
        else {
            $("#banner img:visible").next().fadeIn();
            $(".banner-title:visible").next().fadeIn();
            $("#banner img:visible").first().hide();
            $(".banner-title:visible").first().hide();
        }

    }, 10000);



    /*	HOMEPAGE FORM SLIDER	*/

    $("#quote-header").click(function () {
        $("#front-page-form").slideToggle('slow');
        $(".down-arrow-button").toggleClass('up-arrow-button');
    });

    /*	End of HOMEPAGE FORM SLIDER	*/

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    /*	HOMEPAGE PARTNER SLIDER	*/

    //	Total banners
    total_partners = $(".partner-block").size();

    setInterval("scrollLeft()", 50);

    //	Previous button functions	
    $(".homepage-button-prev").click(function () {
        $(".partner-block:visible").last().hide();
        $(".partner-block").last().insertBefore($(".partner-block").first()).show();
    });

    //	Next button functions
    $(".homepage-button-next").click(function () {
        $(".partner-block:visible").first().insertAfter($(".partner-block").last()).hide();
        $(".partner-block:visible").last().next().show();

    });

    /*	End of HOMEPAGE PARTNER SLIDER	*/




    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    /*	HOMEPAGE COURSES SLIDER	*/

    //	Total banners
    total_courses = $(".homepage-course").size();

    if (total_courses < 11) {
        $("#featured-courses .horizontal-button .homepage-button-up").hide();
        $("#featured-courses .horizontal-button .homepage-button-down").hide();
    }

    //	Only show 3 banners
    for (i = 1; i < 11; i++) {
        $(".right-generic-course #homepage-course-" + i).show();
    }

    for (i = 1; i < 5; i++) {
        $("#homepage-course-" + i).show();
    }

    //	Previous button functions	
    $(".homepage-button-up").live('click', function () {
        $(".homepage-course:visible").last().hide();
        $(".homepage-course:visible").prevAll(":hidden").first().show();

        if ($(".homepage-course").first().is(":visible")) {
            $(".homepage-button-up").hide();
        }
        else {
            $(".homepage-button-down").show();
        }

    });

    //	Next button functions

    $(".homepage-button-down").show();


    $(".homepage-button-down").live('click', function () {
        $(".homepage-course:visible").first().hide();
        $(".homepage-course:visible").last().next().show();

        if ($(".homepage-course").last().is(":visible")) {
            $(".homepage-button-down").hide();
        }
        else {
            $(".homepage-button-up").show();
        }

    });

    /*	End of HOMEPAGE COURSES SLIDER	*/



    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    /*	GENERIC PAGE LOGOS SLIDER 	*/

    //	Total banners
    total_images = $(".generic-testimonials-block").size();

    //	Only show 4 banners
    for (i = 1; i < 6; i++) {
        $("#generic-testimonials-img-" + i).show();
    }

    //	Previous button functions	
    $("#generic-button-prev").live('click', function () {
        $(".generic-testimonials-block:visible").last().hide();
        $(".generic-testimonials-block:visible").prevAll(":hidden").first().show();

        if ($(".generic-testimonials-block").first().is(":visible")) {
            $("#generic-button-prev").hide();
        }
        else {
            $("#generic-button-next").show();
        }

    });

    //	Next button functions
    $("#generic-button-next").live('click', function () {
        $(".generic-testimonials-block:visible").first().hide();
        $(".generic-testimonials-block:visible").last().next().show();

        if ($(".generic-testimonials-block").last().is(":visible")) {
            $("#generic-button-next").hide();
        }
        else {
            $("#generic-button-prev").show();
        }

    });

    /*	End of GENERIC PAGE LOGOS SLIDER	*/

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //	Services list, toggle content

    // Default first box open		
    //$(".services-list .content").first().show();
    //$(".services-list .title a").first().addClass("opened");

    $(".services-list .title a").click(function (e) {
        e.preventDefault();

        //	Box ID
        contentID = $(this).attr("rel");

        //	Changing arrow position from top to down
        if ($(".content-" + contentID).is(':visible')) {
            $(this).removeClass("opened");
        }
        else {
            $(this).addClass("opened");
        }

        //	Toggle	
        $(".content-" + contentID).slideToggle('slow');
    });

    //	Services list, expand all
    $(".services-list .expand").click(function (e) {
        e.preventDefault();

        //	
        $(".services-list .title a").addClass("opened");

        //	Toggle	
        $(".services-list .content").slideDown('slow');

    });

    //	Services list, close all
    $(".services-list .close").click(function (e) {
        e.preventDefault();

        //	
        $(".services-list .title a").removeClass("opened");

        //	Toggle	
        $(".services-list .content").slideUp('slow');

    });

    /*	End of GENERIC PAGE LOGOS SLIDER	*/

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /*	Scroll to the top	*/

    $("#to-the-top").click(function (e) {
        e.preventDefault();

        $('html, body').animate({ scrollTop: 0 }, 'slow');
    })

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /*	share	*/

    $("#share-icon").click(function (e) {
        e.preventDefault();

        $("#share-box").slideToggle();
    })


});
