// JavaScript Document

jQuery(document).ready(function() { 

	/**
	 * Main navigation
	 */
	jQuery("div#mainnav li").each( function() {
											   
		var link = jQuery(this).find('a');
		
		// If this is the home page
		if (location.pathname == '/' && link.attr('href') == '/') {
			jQuery("div#mainnav li a").removeClass("on");
			link.addClass("on");
			
		// Check to see if this is a top level nav item
		} else if ((location.pathname.indexOf(link.attr('href')) > -1) && link.attr('href') != '/') {
			jQuery("div#mainnav li a").removeClass("on");
			link.addClass("on");
			
		// Is this a sub page (We're using the Breadcrumbs to work this out - is there a better way?)
		} else {
			/*jQuery("div#breadcrumbs a").each( function() {							
				if ((link.attr('href').indexOf(jQuery(this).attr('href')) > -1) && jQuery(this).attr('href') != '/') {
					jQuery("div#navigation li a").removeClass("on");
					link.addClass("on");
				}
			});*/
		}
	});
	
	
	/**
	 * Language selector
	 */
	
	jQuery('#language_selector').change( function(event) {
		location.href = jQuery(this).val();								   
	});

});