﻿$(document).ready(function() {

    //Print link in header
    //===========================================================//
    $('#headerPrint').click(function() {
        print();
        $(this).blur();
    });


    //Font size link in header
    //===========================================================//
    $('#styleSwitch').click(function() {
        setActiveStyleSheet(null);
        $(this).blur();
    });


    //FAQ show/Hide
    //===========================================================//
    $('.answerDiv').css('display', 'none');
    $('.faqQns').attr('href', 'javascript: void(0);');

    $('.faqQns').click(function() {
        var faqQ = $('.faqQns');
        var faqA = $('.answerDiv');

        for (p = 0; p < faqQ.length; p++) {
            if (faqQ[p] == this && faqA[p].style.display == 'none') faqA[p].style.display = 'block';
            else if (faqQ[p] == this && faqA[p].style.display == 'block') faqA[p].style.display = 'none';
        }

        $(this).blur();
    });


    //Tab menu
    //===========================================================//
    $(".tabMenu a").each(function() {
    $(this).addClass("tabMenuItem");
        if ($(this).hasClass("hidden")) {
            $(this).removeClass("hidden")
            $(this).addClass("hidden")
        }
    });
    $('.tabMenuItem').attr('href', 'javascript: void(0);');

    $('.tabMenuItem').click(function() {
        var tabLinks = $('.tabMenuItem');
        var tabContents = $('.tabContent');

        for (q = 0; q < tabLinks.length; q++) {
            if (tabLinks[q] == this) tabContents[q].style.display = 'block';
            else tabContents[q].style.display = 'none';
        }

        if (!$(this).is(".selected")) $(this).addClass("selected");

        $(".tabMenu a").not(this).each(function() {
            if ($(this).is(".selected")) $(this).removeClass("selected");
        });

        $(this).blur();
    });


    //Quick Quotes Radio Control
    //===========================================================//
    $(".radioController a:eq(0)").click(function() {
        $(".radioInvisible input[type=radio]:eq(0)").attr({ checked: true, disabled: false });
        $("#childrenRow").fadeOut("normal");
        $("#childrenRow select").each(function() {
            $(this).attr({ isrequired: false });
        });
        $(".radioController a").each(function() {
            $(this).removeClass("radioSelected");
        });
        $(this).addClass("radioSelected");
        return false;

    });
    $(".radioController a:eq(1)").click(function() {
        $(".radioInvisible input[type=radio]:eq(1)").attr({ checked: true, disabled: false });
        $("#childrenRow").fadeIn("normal");
        $("#childrenRow select").each(function() {
            $(this).attr({ isrequired: true });
        });

        $(".radioController a").each(function() {
            $(this).removeClass("radioSelected");
        });
        $(this).addClass("radioSelected");
        return false;
    });
    $(".radioController a:eq(2)").click(function() {
        $(".radioInvisible input[type=radio]:eq(2)").attr({ checked: true, disabled: false })
        $("#childrenRow").fadeOut("normal");
        $("#childrenRow select").each(function() {
            $(this).attr({ isrequired: false });
        });
        $(".radioController a").each(function() {
            $(this).removeClass("radioSelected");
        });
        $(this).addClass("radioSelected");
        return false;
    });

    $(".radioInvisible input[type=radio]").each(function(i) {

        if (this.checked) {
            var query = ".radioController a:eq(" + i + ")";
            $(query).click();
        }

    });

    //Search input image
    //===========================================================//
    $(".textInput").click(function() {
        $(".searchImg").hide();
    });
    $(".searchImg").click(function() {
        $(this).hide();
        $(".textInput").focus();
    });
    $(".textInput").blur(function() {
        if ($('.textInput[value!=""]').length > 0) {
            $('.searchImg').hide();
        } else {
            $(".searchImg").show();
        }
    });


    //contact us 
    //===========================================================//
    $("#membershipNumberCheck input").click(function() {
        if (this.checked) {
            $("#membershipNumberRow").fadeIn("normal");
        }
        else {
            $("#membershipNumberRow").fadeOut("normal");
        }
    });

    $("#contactMethodRow select").change(function() {
        var selItem = this.value;
        if (selItem == "Phone") {
            $("#postalAddress").fadeOut("normal");
            $("#contactTimes").fadeIn("nomral");
        }
        if (selItem == "Post") {
            $("#postalAddress").fadeIn("normal");
            $("#contactTimes").fadeOut("nomral");
        }
        if (selItem == "Email") {
            $("#postalAddress").fadeOut("normal");
            $("#contactTimes").fadeOut("nomral");
        }
        if (selItem == "0") {
            $("#postalAddress").fadeOut("normal");
            $("#contactTimes").fadeOut("nomral");
        }
    });
});



