$(document).ready(function(){

	

	$(function(){
   		// get current location
   		var path = location.href;//location.pathname.substring(7);
   		//var baseurl = location.hostname;
   		//var sitehref = location.href;
   		//var path = location.pathname;
   		//alert(path);
   		//alert(sitehref);
   		
   		if ( path )
   			
   			//target menu
   			$('#targetmenu a[@href$="' + path + '"]').attr('class', 'selected');
   			
     		//main menu
     		// if a href matches current location, set a with class 'selected'
     		$('#nav a[@href$="' + path + '"]').attr('class', 'selected');
     		// selected a, give the h2 
     		$('.selected').parents('ul').prev().addClass("current");
     		$('h3.handle a.selected:first').parent().addClass('current');
	});
	// -- start off with sub uls hidden 
	// 1st level > hide children ul, except for current page
	//$("h2.handle:not(.current)").next().hide();
	// 2nd level > hide children ul, except for current page
	$("h3.handle:not(.current)").next().hide();
	$("h2.resellers").next().hide();
	
	// -- open the 3rd level when on the sesond level homepage
	$("h3 a.selected").next().show();
	
	$("h2.handle a").click(function(){  //do the following when drawer is clicked
		
		$("h2.handle").next().slideUp("fast"); //closes all drawers 
		
		$(this).parent().next('ul:hidden').slideToggle("fast"); //opens child of clicked H2.

 		
		//$("h2").removeClass("selected"); //removes all 'on' drawers
		//$(this).parent().addClass("selected"); //turns 'on' current drawer	

		return false; //prevents default hyperlink behaviour	
	
	});

	
 
 	//$("#nav a").addClass("test");
 	
 	//alert($("adjustedPrice").length());
 	
});
