function trace(s) {
  if (this.console && typeof console.log != "undefined")
    console.log(s);
}


$(document).ready(function(){

	
/*navbar hover*/
	$('#main-nav a').hover(function()
	{
		var target = $(this).parent();
		
			if(target.hasClass('active') == false && target.hasClass('parent-menu-item') == false )
			{
				target.css('background-position', ' 0px 30px')
				target.stop().animate({backgroundPosition: '-15px 0px'},500,  'linear', function()
				{
					target.animate({backgroundPosition: '-1500px 0px'}, 70000, 'linear')
				}) 
			}
	},
	function()
	{
		var target = $(this).parent();
		if(target.hasClass('parent-menu-item') == false)
			{
				unHilite( $(this) )
			}
	})
	.click(function() //reset background
	{
		unHilite( $(this) )
		$(this).blur();
	})

/*Sub menus*/
	
	$('#product-menu').data('height', 535)
	$('#quality-menu').data('height', 400)

	$('.parent-menu-item').hover(function(){
		//$(this).find('.subnav').fadeIn()
		menu = 	$(this).find('.subnav')	
		menu.css('opacity', 0).css('height', '200px').show().stop().animate({opacity:1, height: menu.data('height')},400)
		$('.active').addClass('hide-active')
	},
	function(){
		//$(this).find('.subnav').fadeOut();
		menu = 	$(this).find('.subnav')	
		menu.stop().animate({opacity:0, height: '200px'},300, function(){
			menu.hide()
			
		})
		
		$('.active').removeClass('hide-active')
		
	})
	
//Content Link hover
//link hover
$('.content-link').hover(
	function()
		{
			target = $(this);
			if (target.data('bgcolor') == null )
				{
				target.data('bgcolor', target.css('backgroundColor'))	
				}
			target.stop().animate({'backgroundColor':'#F17225'},300, function()
				{
					target .css('backgroundColor','#F17225')
				})
		},
	function()
		{
			$(this).stop().animate({'backgroundColor':target.data('bgcolor')} ,300, function()
				{
					$(this).css('backgroundColor',target.data('bgcolor'))
				})
		}
	)
	
	
	
}) //End document ready


function unHilite(link)
{
	var target = link.parent();
	if(target.hasClass('active') == false)
	{
		BGx = target.css('backgroundPosition');
		space = BGx.indexOf(' ');
		BGx = BGx.substring(0, space);
		target.stop().animate({backgroundPosition: BGx + ' 30px'}, 500) 
	}
}

function setActiveNav(target)
{
	$('#' + target).addClass('active')
	

}



