$(document).ready( function() 
{
	//galeria de imagens
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',slideshow:10000});
	$("a[rel^='prettyPopin']").prettyPopin();	
	
	//PESQUISA
	$("#pesquisa").focus(function() {
		var val = $(this).val();
		if(val == pesquisar_txt) 
		{
			$(this).val("");
		}
	});
	
	$("#pesquisa").blur(function() {
		var val = $(this).val();
		if(val == "") 
		{
			$(this).val(pesquisar_txt);
		}
	});
	
	// AO CARREGAR ENTER SUBMETE A PESQUISA
	$('input').keypress(function (e) {
		var code = null;
		code = (e.keyCode ? e.keyCode : e.which);
		if (code == 13)
		{	
			//return false;
			e.preventDefault();
			var url=$("#pesquisa").val();
			if($("#pesquisa").val()!="" && $("#pesquisa").val()!=pesquisar_txt)
				document.location.href='/pesquisa/?s='+encodeURI(url);
		}
		else
			return true;
	});
	// FIM PESQUISA
	
	
	//catalogos, cores e ambientes, novidades, soluções 
	$(".over_item").hover(function() {
		$(this).find('.over_item_div').removeClass('h');
	}, function() {
	    $(this).find('.over_item_div').addClass('h');
	});
	
	//catalogos contador update
	$(".over_item_link").click(function(e) {
		
		var catalogo_sel=($(this).attr("id")).replace('catalogo-','');
		$.get("/include/ajax_functions.php",{'action':'contador','id':catalogo_sel,'rand':Math.random()},function(msg){

		});
		//e.preventDefault();
	});
	
});	

$(window).bind("load", function() {

  var diferenca=0;
  if($('#main').height()<$(window).height())
  {
	diferenca=  parseInt($(window).height() - $('#main').height());
	$("#footer_rodape_w").height(diferenca+'px');
	$('#main_bg').height($(window).height());
  }
  else
	{
		$("#footer_rodape_w").height('50px');
	}
	
});

$(window).bind('resize', function() {
	var diferenca=0;
	
	if($('#main').height()<$(window).height())
    {
		//ver qdo redensiona para mais ou para menos se dá para distinguir
		diferenca=parseInt($("#footer_rodape_w").height() + $(window).height() - $('#main').height());
		$("#footer_rodape_w").height(diferenca+'px');
		$('#main_bg').height($(window).height());
	}
	else
	{
		$("#footer_rodape_w").height('50px');
	}	
});

function inserir_newflash(file,w,h,div)
{

	var flashvars = {};
	var params = {			
		wmode: "transparent"
	};
	var attributes = {};

		$.swfobject.embedSWF(file, div, w, h, "8.0.0", "expressInstall.swf", flashvars, params, attributes);
}

