$(document).ready(function(){
//form buscar********************************************************
	var searchBox2 = $("#buscaValor");
	var searchBox2Default = "Buscar";
	
	//Searchbox2 show/hide default text if needed
	searchBox2.focus(function(){
		if($(this).attr("value") == searchBox2Default) $(this).attr("value", "");
	});
	
	searchBox2.blur(function(){
		if($(this).attr("value") == "") $(this).attr("value", searchBox2Default);
	});
	
	$("#busc").click(function(){
		var valor = $("#buscaValor").val();
		if (valor == '' | valor == 'Buscar'){
			document.getElementById('busca').value = 'Buscar';
		}else{
			window.location = "/produtos/busca/"+valor;
		}
	});
	$('#mycarousel').jcarousel({
        visible: 3,
		wrap: 'circular'
    });

	$(".botaoExcel").click(function(event) {
		$("#dados_a_enviar").val( $("<div>").append( $("#listapreco").eq(0).clone()).html());
		$("#expExcel").submit();
	});

//fim form buscar*****************************************************
		  //$("div:odd").css("background-color", "#CCC");
		  //$("div:even").css("background-color", "#666");
		  //$(".vAlign").vAlign('p');//vertical align
		  //$(".b1").border('1px solid #000');
		  $(".crop-img").each(function(){
				  img = $(this).attr("src");
				  alt = $(this).attr("alt");
				  h = $(this).attr("height");
				  w = $(this).attr("width");
				  alg = $(this).attr("align");
				  //alert(img);
				  $(this).attr("src", "/tpl/default/images/space.gif");
				  $(this).css("background-image", "url("+img+")");
				  if (alg == "top") {
				  	$(this).css("backgroundPosition", "top center");
				  }else if (alg == "left") {
					$(this).css("backgroundPosition", "left top");
				  }else if (alg == "right") {
					$(this).css("backgroundPosition", "right top");
				  }else {
				  	$(this).css("backgroundPosition", "center center");
				  }
				  $(this).css("background-repeat", "no-repeat");
				  //$(this).append('<img src="/tpl/default/images/space.gif" alt="'+alt+'" border="0"  width="'+w+'" height="'+h+'" style="background:url('+img+') center center no-repeat"  />');
		});
		
		$('#direction-fade-slider').aviaSlider({
			blockSize: {height: 3, width:'full'},
			display: 'topleft',
			transition: 'fade',
			betweenBlockDelay:10,
			animationSpeed: 400,
			switchMovement: true
		});	  
		  
		$(".mapa").colorbox({width:"800", height:"500", iframe:true, scrolling:false, href:"http://maps.google.com.br/maps/ms?hl=pt-BR&amp;gl=br&amp;ie=UTF8&amp;oe=UTF8&amp;msa=0&amp;msid=107543957322627813210.000494b1f92994ad828ef&amp;t=h&amp;ll=-25.509797,-54.60866&amp;spn=0.000877,0.003905&amp;output=embed", title:"Clique no marcador para mais detalhes."});
		//$('a[href^="http://"]')	.attr({ target: "_blank" });
		$("a[rel='galeria']").colorbox();
		
		$("#too img[title]").tooltip();
	
		// Ordenar tags de busca********************
		var sortstrength = $('<a href="javascript:void(0)" class="btn">Ordenar Tags</a>').toggle(
		function(){
			$("#tags ul li").tsort({order:"desc",attr:"value"});
		},	
		function(){
			$("#tags ul li").tsort({order:"asc",attr:"value"});
		}		
		);
 		$('#tags').append(sortstrength);
		// FIM Ordenar tags de busca****************
		
	});




//Desabilita tecla enter******************************
function bloqEnter(objEvent) {
	var iKeyCode;
	iKeyCode = objEvent.keyCode;
	if(iKeyCode == 13) return false;
	return true;
}
//FIM Desabilita tecla enter**************************
