//strip tags
jQuery.fn.stripTags = function() {
	if(this.html())
		return this.replaceWith( this.html().replace(/<\/?[^>]+>/gi, '') );
	else
		return(false);
};

// Abre Janela
function AbreJanela(theURL,winName,features) {
	window.open(theURL,winName,features);
}

// JavaScript do Menu
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("menuTopo");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace
	(" over", "");
   }
   }
  }
 }
}
//window.onload=startList;

$(document).ready(function(){
	fnDescricao();
	
	$('#cycleDestaques #slideDestaques').after('<div id="barraDestaques">').cycle({ 
		fx:     'turnDown', 
		speed:  600, 
		timeout: 6000, 
		random: 0,
		pager:  '#barraDestaques' 
		
	});
	
	$('#imvDestaques').after('<div id="barraImvDestaques">').cycle({ 
		next: '.next',
		prev: '.prev',
		fx:     'scrollHorz', 
		speed:  600, 
		timeout: 6000, 
		random: 0,
		pager:  '#barraImvDestaques' 
	});
	
	/*
	$('#imvDestaques').jCarouselLite({
		btnNext: '#imvDestaques .next',
		btnPrev: '#imvDestaques .prev',
		auto: 5000,
		speed: 600,
		timeout: 2000,
		visible: 3
	}); 	
	*/
	
	/*$('.imvSemelhantes').jCarouselLite({
		btnNext: '#imvSemelhantes .nextSem',
		btnPrev: '#imvSemelhantes .prevSem',
		auto: 1000,
		speed: 600,
		timeout: 2000,
		visible: 2
	});*/
	

	
	jQuery('#rankingAccordion').accordion(); 
	
	lastBlock = $("#a1");
	maxWidth = 264;
	minWidth = 88;
	
	$("#abasAssociada ul li a").hover(
		function() {
			$(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:1000 });
			$(this).animate({width: maxWidth+"px"}, { queue:false, duration:1000});
			lastBlock = this;
		}
	);	
	
		$(".imvCaptador").corner("cc:#4E4E4E");
	//$(".imvSemelhantes").corner("cc:#2B2B2B");
	
	$("#busca_por_id").click(function(){ 
		$("#busca_ID").toggle("fast",function(){$("#busca_ID #txtRef").focus();}); 
		$("#busca_ID").css("left",$(this).offset().left);
		$("#busca_ID").css("top",$(this).offset().top + 14);
		$(this).toggleClass("busca_por_id_ativo");
		return(false)
	});
	



});

function fnDescricao(){
	if($(".imvInformacoes").length > 0){
		$(".imvInformacoes .descricao p").stripTags();
		mostra_descricao = true;	
		limite_descricao = 340;
		texto_descricao = $(".imvInformacoes .descricao").html();
		texto_descricao = texto_descricao.substr(18,texto_descricao.length);
		if(texto_descricao.length > limite_descricao){
			mostra_descricao = false;
			$(".imvInformacoes .descricao").html("<h2>Descri&ccedil;&atilde;o</h2><p><span>" + texto_descricao.substr(0,limite_descricao) + "... </span><a href='#' id='descricao_leia_mais'>veja mais</a></p>");
			$(".imvInformacoes .descricao p #descricao_leia_mais").click(function(){
				if(!mostra_descricao){
					$(".imvInformacoes .descricao span").html(texto_descricao);
					$(this).text("veja menos")
					mostra_descricao = true;
				}else{
					$(".imvInformacoes .descricao span").html(texto_descricao.substr(0,limite_descricao) + "...");
					$(this).text("veja mais")
					mostra_descricao = false;				
				}
				return(false);				
			})
		}else{
			$(".imvInformacoes .descricao").html("<h2>Descri&ccedil;&atilde;o</h2><p><span>" + texto_descricao + "</span></p>");		
		}	
	}
}





