$(document).ready(function(){
 /*
//	$("ul.children").parent().css(background: "url(images/header/subnav_btn.gif') no-repeat scroll center top transparent");/
$("ul.children").parent().attr("style","background: url(images/header/subnav_btn.gif) no-repeat scroll 100% 3px transparent;");
	
	$("ul.topnav li a").mouseover(function() { //When trigger is clicked...
		
		//Following events are applied to the children itself (moving children up and down)
		$(this).parent().find("ul.children").slideDown('fast').show(); //Drop down the children on click
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.children").slideUp('slow'); //When the mouse hovers out of the children, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			if($(this).parent().find("ul.children").html()!=null)
				$(this).parent().attr("style","background:url(images/header/subnav_btn.gif) no-repeat 100% -33px");
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			if($(this).parent().find("ul.children").html()!=null)
				$(this).parent().attr("style","background: url(images/header/subnav_btn.gif) no-repeat 100% 3px");
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
*/

    $("ul.children").parent().append("<span></span>");
	$("ul.topnav li a").mouseover(function() { //When trigger is clicked...
		
		//Following events are applied to the children itself (moving children up and down)
		$(this).parent().find("ul.children").slideDown('fast').show(); //Drop down the children on click
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.children").slideUp('slow'); //When the mouse hovers out of the children, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
 
$("ul.topnav li span").mouseover(function() { //When trigger is clicked...
		
		//Following events are applied to the children itself (moving children up and down)
		$(this).parent().find("ul.children").slideDown('fast').show(); //Drop down the children on click
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.children").slideUp('slow'); //When the mouse hovers out of the children, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

    $("div#page > ul.topnav > div.topnav > ul > li").each(function(){
		if($(this).find("li").find("a").attr("href")!="undefined")
		    $(this).find("a:first").attr("href",$(this).find("li").find("a").attr("href"));
    });
});

