// <![CDATA[



//--------------------------------------------------------------------
// Cufon Font Replacement https://github.com/sorccu/cufon/
//--------------------------------------------------------------------
Cufon.replace('h1, h2, h3, #globalnav a, #HeadMenuItems, #searchbox .form-button, #leftcolumn #mainnav h3, #specialoffer h3, table.footnav tr td h3');

////header - signin
//Cufon.replace('#globalnav a', {
//    fontFamily: 'Arial',
//    letterSpacing: '1px',
//    hover: true
//});

////header - signin
//Cufon.replace('.HeadMenuItems', {
//    fontFamily: 'Arial',
//    letterSpacing: '1px',
//    hover: true
//}); 

////header - search go button
//Cufon.replace('#searchbox .form-button', {
//    fontFamily: 'Arial',
//    letterSpacing: '1px',
//    hover: true
//});

////left - navigation headings.
//Cufon.replace('#leftcolumn #mainnav h3', {
//    fontFamily: 'Arial',
//    letterSpacing: '1px'
//});

////footer - join mailing list.
//Cufon.replace('#specialoffer h3', {
//    fontFamily: 'Arial',
//    letterSpacing: '1px'
//});

////footer - headings.
//Cufon.replace('table.footnav tr td h3', {
//    fontFamily: 'Arial',
//    letterSpacing: '1px'
//});


//--------------------------------------------------------------------
// Event Handlers
//--------------------------------------------------------------------
$(document).ready(pageInit);

//--------------------------------------------------------------------
// Page Start - Initialisation
//--------------------------------------------------------------------
function pageInit()
{
    //accessibility - all headings.
    $("h1,h2,h3,h4").each(function ()
    {
        var title = $(this).attr("title");
        if (title == null || title == "")
        {
            $(this).attr("title", $(this).text());
        }
    });

    //boundary list items
    $("li:first:not(.first),li:first-child:not(.first)").addClass("first");
    $("li:last-child:not(.last)").addClass("last");

    //setup forms.
    setupForms();

    //setup anchor links.
    setupLinks();
}

function setupForms()
{
    var first = $("fieldset input:text:first");
    if (null != first)
    {
        $(first).focus();
    }
}

function setupLinks()
{
    //scroll to named anchors script
    $("a[href^=#]:not(a[href='#'])").click(function ()
    {
        if (location.pathname.replace("/^\//, ''") == this.pathname.replace("/^\//, ''") && location.hostname == this.hostname)
        {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
            if ($target.length)
            {
                var targetOffset = $target.offset().top;
                try
                {
                    $('html,body').animate({ scrollTop: targetOffset }, 1000);
                }
                catch (e) { }
                return false;
            }
        }
    });
}

// ]]>

