﻿$(document).ready(function () {

    

    setTimeout(showContent, 1000);
    function showContent() {
        $("body").addClass("hasJavascript");
    };


    // eqaul height
    //time out used becasue the font-face rendering is happening after doc load and messing the height - Stuart Johnston
    setTimeout(setHeights, 1000);
    function setHeights() {
        $(".promoWidget").equalHeight();
        $("#candidateAction .unit").equalHeight();
    };

    $(".focusClear").focus(function () {
        $(this).val("");
    });

    //clear the search field just once
    $("#uiSearchFreeText input").one("focus", function () {
        $(this).val("");
    });

    //show hide currency converter
    $("#currencyConverter .gutter").hide();

    $('#currencyConverter .trigger').toggle(function () {
        $("#currencyConverter .gutter").show();
        $(this).addClass("open");
    }, function () {
        $("#currencyConverter .gutter").hide();
        $(this).removeClass("open");
    });

    //zebra
    $("table").each(function () {
        $(this).find("tbody tr:odd").addClass("odd");
    })

    //if only 1 candidate action position it off the top
    function onlyOneGeneral() {
        if ($("#candidateAction #general div").length == 2) {
            $("#candidateAction #general").addClass("twoElements");
        }
        else {
            $("#candidateAction #general").addClass("oneElement");
        }
    };
    onlyOneGeneral();

    //specialism fake multi select

    function setSpecialismsCheckedStatus() {

        //are any already checked? If so add a class to say "Selected"
        $("#uiSpecialism input:checked").each(
        function () {
            $(this).closest("li").find("label").addClass("selected");
        });

        //are any already unchecked? If so add a class to say "Not Selected"
        $("#uiSpecialism input:not(:checked)").each(
        function () {
            $(this).closest("li").find("label").addClass("notSelected");
        });

    };

    setSpecialismsCheckedStatus();

    $("#uiSpecialism ul .selected").toggle(
    function () {
        $(this).removeClass("selected");
        $(this).addClass("notSelected");
        $(this).closest("li").find("input").trigger("click");
    }, function () {
        $(this).addClass("selected");
        $(this).removeClass("notSelected");
        $(this).closest("li").find("input").trigger("click");
    });

    $("#uiSpecialism ul .notSelected").toggle(
    function () {
        $(this).removeClass("notSelected");
        $(this).addClass("selected");
        $(this).closest("li").find("input").trigger("click");
    }, function () {
        $(this).addClass("notSelected");
        $(this).removeClass("selected");
        $(this).closest("li").find("input").trigger("click");
    });

    $(".teamResult").last().addClass('last');

    //equal height secondary navigation
    $("#secondaryNavigation li a").equalHeight();

    
});
