/*** CUFON ***/
Cufon.replace('.cufon, h1, h2, h3, .getInTouch a, .podLinkButton', { hover: true, fontFamily: 'din-alternate-black' });
Cufon.replace('.cufonAB', { hover: true, fontFamily: 'arial-black' });

$(function () {
    // Activate accordion menu.
    $('#contentWrapper .sideNav ul li a.plus ').click(
            function () {
                var theUL = $(this).parent().find('ul');
                var topUL = $('.sideNav ul li ul').not(theUL);
                if (theUL.length > 0) {
                    topUL.filter(':visible').slideUp();
                    if (theUL.is(':visible')) theUL.slideUp();
                    else theUL.stop().slideDown('slow')
                }
                return false;
            }
        );
    $('#contentWrapper .selected ul').show();
    $('#contentWrapper .sideNav.alt ul li ul, #contentWrapper .selectedChild').parent().parent().show();


    /*** create 'accordion' functionality for the FAQ's ***/
    $('.accordionButton').click(function () {
        $('.accordionButton').removeClass('on');
        $('.accordionContent').slideUp('normal');
        if ($(this).next().is(':hidden') == true) {
            $(this).addClass('on');
            $(this).next().slideDown('normal');
        }
        return false;
    });
    $('.accordionButton')
        .mouseover(function () { $(this).addClass('over'); })
        .mouseout(function () { $(this).removeClass('over'); });
    $('.accordionContent').hide();

    /*** Add the date picker to the DOB field on forms ***/
    $(".dob").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: '-100:+0',
        dateFormat: 'dd/mm/yy'
    });


    /**** create custom select ****/
    $('.quickQuote, .form').jqTransform({ replaceRadio: true, replaceSelect: true });


    var searchField = $('input.searchBox');
    var searchFieldInitialValue = searchField.val();
    searchField.focus(function () {
        if (searchField.val() == searchFieldInitialValue)
            searchField.val('');
    }).blur(function () {
        if (searchField.val() == '')
            searchField.val(searchFieldInitialValue);
    });
});
