$.fn.softAnchorScroll = function(){
	$(this).each(function(){
		var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
		var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
		if ($target) {
			var targetOffset = $target.offset().top;
			$(this).click(function() {
			var href = $(this).attr('href');
			$('html').animate({scrollTop: targetOffset}, 'slow',function(){
				document.location.hash = '#'+$target.attr('id');
				document.location = href;
			});
				return false;
			});
		}
	});
};

$(function(){

	$('a[rel~=external]').each(function(){
		$(this).attr('target','_blank');
	});

	$('.email').pMail();

	$('.paging').center();
	if($.addPlugin('color')){
		$('#produtos_menu ul li h3 a').hover(function(){
			$(this).stop().animate({
				color: '#FF7100'
			},'normal');
		},function(){
			$(this).stop().animate({
				color: '#000'
			},'normal');
		});
		$('#menu li a').hover(function(){
			$(this).stop().animate({
				color: '#FCFF00'
			},'normal');
		},function(){
			$(this).stop().animate({
				color: '#FFF'
			},'normal');
		});
	}
	
	if($('#capa').length > 0){
		if($.addPlugin('flash')){
			$('#capa #conteudo #flashTopo').flash({
				src: DEFAULT_URL + 'swf/capa.swf?1',
				width: 714,
				height: 295,
				wmode: 'transparent',
				variables: {
					defaultUrl: DEFAULT_URL
				}
			});
		}
	}
	
	if($('#noticias.index').length > 0){
		if($.addPlugin('biggerlink')){
			$('#noticias.index #conteudo ul.listagem li').biggerlink();
		}
	}
	
	$('#BuscaProduto').initValue('Produto...');
	
	$('#BuscaCategoria').sexyCombo();
	
	$('#BuscaCategoria').change(function(){
		c = 'initValue';
		if($(this).val().length < 1){
			$(this).next('input').addClass(c);
		}else{
			$(this).next('input').removeClass(c);
		}
	}).change();
	
	$('.tooltip').tooltip();
	
	$.UtilAjax();

	$('#produtos.buscar #conteudo ul.listagem li p a.orcamento').softAnchorScroll();
	
});
$(window).load(function(){

	if($.browser.msie && $.browser.version < 7){
		if($.addPlugin('ifixpng','ifixpng/ifixpng2')){
			var fix_this = new Array(
				'#formProdutoBuscar button',
				'#topo .orcamento'
			);
			$(fix_this.join(',')).ifixpng();
		}
	}
	
	$('#produtos.buscar #conteudo ul.listagem li').normalizeHeight(null,4);

});