// JavaScript Document
$('ul.jqMenu').ready(function(){
	$('ul.jqMenu > li:has(ul)').each(function() {
		$(this)
			.hover(function() {
				$('ul', this)
					.css({
						display:'block',
						left: $(this).position().left + $(this).width()+10, //make certain the submenu is correctly positioned
						top: $(this).position().top + 5 
					})
				;
			},
			function() {
				$('ul', this)
					.css({
						 display:'none'
					})
				;
			})
			.find('li')
			.each(function() {
				$(this)
					.hover(function() {
						$(this)
							.css('background','#CCCC33')
							.find('a')
							.css('color','#ffffff')
						;
					},
					function() {
						$(this)
							.css('background','#ffffff')
							.find('a')
							.css('color','')
						;
					})
				;
			})
		;
			
		$('li', this).each(function(n) {
			$(this).css('width','100%');
			if( $(this).find(' > a').length > 0 ) {
				$(this).find(' > a').html( $(this).find(' > a').html().replace(/ /g,'&nbsp;') )
			}
		});
	});
	
	$('ul.jqMenu > li').each(function() {
		
		$(this)
			.click(function() {
				if( $(this).find(' > a').length ) {
					window.location = $(this).find(' > a')[0];
				}
			})
			.hover(function() {
				$(this)
					.css({
						backgroundImage:'url(../images/nav_button_over.gif)',
						color: '#ffffff'
					})
					.find('> a')
					.css({
						 color:'#ffffff' //default the color
					})
				;
			},function() {
				$(this)
					.css({
						backgroundImage:'url(../images/nav_button.gif)',
						color: '' //default the color
					})
					.find('> a')
					.css({
						 color:'' 
					})
				;
			})
		;
	})
});