﻿// JScript File

$(document).ready(function (){
    initialiseSearch();
    applyCufon();
    
    // initialise hint.js
    $('input:text').hint();
});

function initialiseSearch() {
	
    $('fieldset.search input.search_button').bind('click', function(){
        //alert("test");
        fireSearch();
    });

    $('fieldset.search input').bind('keypress', function(e) {
        if(e.keyCode==13){
            fireSearch();
            e.preventDefault();
        }
    });
}

function fireSearch(btn, event, URL) {
    var searchTerm = $('.search_input').attr("value");
    
    //alert(searchTerm);
    
    // navigate the url with the value as query string
    window.document.location.href = "/pages/home/search.aspx?s=" + searchTerm;
}
    
function applyCufon() {
    Cufon.replace
    ('h1', { textShadow: '#D7EFF8 1px 1px' })
    ('h1 span.subHead', { hover: true, textShadow: 'none' })
    ('h2', { textShadow: '#D7EFF8 1px 1px' })
    ('h2 span.subHead', { hover: true, textShadow: 'none' })
    ('h3', { textShadow: '#D7EFF8 1px 1px', hover: true })
    ('h3 span.subHead', { hover: true, textShadow: 'none' })
    ('.rotatorPanelInfo span.title', { textShadow: '#D7EFF8 1px 1px' })
    ('ul#main_navigation > li > a', { textShadow: '#D7EFF8 1px 1px'})
    ('#breadcrumbContainer ul#breadcrumb span')
    ('#breadcrumbContainer ul#breadcrumb li a', { hover: true });
    
    $('ul#main_navigation > li').hover(updateMenu, updateMenu); 
}

function updateMenu() {
    setTimeout(function() {
        Cufon.replace('ul#main_navigation > li > a', { textShadow: '#D7EFF8 1px 1px' }, false); // false =  ignored by Cufon.refresh()
    }, 10);
}
