﻿// JScript File

$(document).ready(function (){

    // initialise hint.js
    //$('input:text').hint();
    
    // navigation functions
    initialiseNav();

    indicateChildNav();
});

function applyCufon() {

}

function initialiseNav() {
    $('.navOn1 > li:first-child').addClass('first');
    $('.navOn1 > li:last-child').addClass('last');    
}

function indicateChildNav(){
    //$('#main_navigation .navOn2 ul').each(function() {
    //    var currentClass = $(this).parent().attr("class");
    //    $(this).parent().attr("class", currentClass + " hasChildren");
    //});
    
    $('#main_navigation .navOn2 li').each(function() {
        if( $(this).has('ul').length ) {
            var currentClass = $(this).attr("class");
            $(this).attr("class", currentClass + " hasChildren");  
        }
        else
        {
            var currentClass = $(this).attr("class");
            $(this).attr("class", currentClass + " noChildren");  
        }
    });
} 

// Search box
jQuery(function($) {

	$('fieldset.search a').bind('click', function(){
	    fireSearch();
	});

	$('fieldset.search input').bind('keyup', function(e) {
	    if(e.keyCode==13){
		fireSearch();
	    }
	});

	function fireSearch(btn, event, URL) {
	    var searchTerm = $('.search_input').attr("value");

	    searchTerm = "/pages/home/search.aspx?s=" + searchTerm;
	    // navigate the url with the value as query string
	    top.location=searchTerm;
	}

});
