$(window).load(function() {
    $('#slider').nivoSlider({'controlNav':true, 'pauseTime':6000, 'directionNavHide':false});
});



$(document).ready(function(){
	
	
	$('#header li').hover(function(){
		
		$(this).addClass('hover');
		
	}, function(){
		
		$(this).removeClass('hover');
		
	});
	
	
	if($('body').attr('id') != 'luxaflex')
	{
		$('.menu>li').hover(function() {
			$(this).stop().animate({backgroundColor:'#00aeef'}, 200);
			}, function () {
			$(this).stop().animate({backgroundColor:'#333333'}, 800);
		});
	} else {
		$('.menu>li').hover(function() {
			$(this).stop().animate({backgroundColor:'#00aeef'}, 200);
			}, function () {
			$(this).stop().animate({backgroundColor:'#e1e1e1'}, 800);
		});
	}
	
	
	$('#header a').click(function(){
		
		if($(this).attr('href') == '#')	return false;
	
	});
	
	
	
	$('#sidebar ul li a').click(function(){
		var posicao, label = $(this).html();
		$('#content h3').each(function(){
			if($(this).html() == label){
				posicao = $(this).offset();
				console.log(posicao.top);
			}
		});	
		
		$("html,body").animate({ scrollTop: posicao.top-250}, 800);		
		
		return false;
	});	
	
	if($('.list-produtos').length>0)
	{
		
		$(document).scroll(function(){
			if($(document).scrollTop() > 170 && $(document).scrollTop() < $(document).height() - 900){
				$('#sidebar').addClass('fixed');	
			} else {
				$('#sidebar').removeClass('fixed');	
			}
		});
		
		
		var count = 0;
		$('.list-produtos').each(function(){
			if(count > 1) $(this).append('<a class="scrolltop" href="#"></a>');	
			count++;
		});
		
		$('a.scrolltop').live('click', function(){
			$("html,body").animate({ scrollTop: 0}, 800);	
			return false;			
		});
		
	}
	
	
});


/*
 * jQuery Placeholder Plugin.
 * http://github.com/mudge/jquery_placeholder
 *
 * A plugin to make HTML5's placeholder attribute work in non-HTML5-supporting
 * browsers.
 *
 * Copyright (c) Paul Mucur (http://mucur.name), 2010.
 * Licensed under the MIT licence (see LICENSE.txt).
 */
(function(a){a.placeholder={className:"jquery_placeholder",supportedNatively:function(c){var b=document.createElement(c);return"placeholder" in b},backwardsCompatibility:function(){if(!a.placeholder.supportedNatively("input")&&!a.placeholder.supportedNatively("textarea")){var b=":input"}else{if(!a.placeholder.supportedNatively("textarea")){var b="textarea"}else{var b=null}}if(b){a(window).unload(function(){a(b+"."+a.placeholder.className).val("")});a(b+"[placeholder]").each(function(){var c=a(this);var d=c.attr("placeholder");if(!c.attr("defaultValue")&&c.val()==d){c.val("")}c.blur(function(){if(this!=document.activeElement&&c.val()==""){c.addClass(a.placeholder.className).val(d)}}).focus(function(){if(c.hasClass(a.placeholder.className)){c.val("").removeClass(a.placeholder.className)}}).change(function(){if(c.hasClass(a.placeholder.className)){c.removeClass(a.placeholder.className)}}).parents("form:first").submit(function(){c.triggerHandler("focus")}).end().triggerHandler("blur")})}}};a(a.placeholder.backwardsCompatibility)})(jQuery);
