
function mudaTipo(codproduto_tipo){
	GTR_AjaxClick('lisProduto.php?codproduto_tipo=' + codproduto_tipo, 'conteudo');
}

function mudaSubTipo(codproduto_subtipo, codproduto_tipo){
	GTR_AjaxClick('lisProduto.php?codproduto_subtipo=' + codproduto_subtipo+ '&codproduto_tipo='+codproduto_tipo, 'conteudo');
}


function trocaDestaque(imagemM, imagemG, titulo)
{
	MagicZoom_stopZooms();
	
	// Step 2
	var zoomLink = document.getElementById('img_produto');
	zoomLink.href = "../../" + imagemG;
	zoomLink.title = titulo;
	zoomLink.innerHTML = '<img src="../../'+imagemM+'" style="width: auto; height: auto" />';
	
	// Step 3
	MagicZoom_findZooms();
	MagicThumb.refresh();
	scrollTop();
}

function tooltip_end_x() {
	obj	= document.getElementById("img_tooltip_end");
	obj.style.display='none';
}
function tooltip_end()  {
	obj	= document.getElementById("img_tooltip_end");
	obj.style.display='';
}

function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

// Para usar coloque o comando: "javascript:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "javascript:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '11px','13px','15px' );
var tamanhoInicial = 0;
 
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 2 ) tamanho = 2;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
	dives	= document.getElementsByTagName('div');
	for (i=0;i<dives.length;i++)  {
		if (dives[i].id==idAlvo)  {
			dives[i].style.fontSize = tamanhos[ tamanho ];
		}
	}
}

function scrollTop()  {
	window.scroll(0,0); 
}

function voltaBack()  {
	history.back();
}

function botaoAtivo(ativo){
	var num_botoes = document.getElementsByName("menu_lateral").length;
	for (i = 0; i < num_botoes; i++){
		if (ativo == document.getElementsByName("menu_lateral")[i].id)
			document.getElementsByName("menu_lateral")[i].className = 'ativo';
		else
			document.getElementsByName("menu_lateral")[i].className = '';
	}
}

function applySelectedTo(link, abrir) {
	var ul = document.getElementById("sanfona"); // get the first ul tag on the page
	var allLinks = ul.getElementsByTagName("h3"); // get all the links within that ul
	
	for (var i=0; i<allLinks.length; i++) { // iterate through all those links
		allLinks[i].className = ""; // and assign their class names to nothing
		document.getElementById(allLinks[i].lang).style.display='none';
	}
	link.className = "ativo";  // finally, assign class="selected" to our chosen link
	document.getElementById(abrir).style.display='';
}


// lisRepresentante
function mudaPais(){
	var pais = document.getElementById('codpais').options[document.getElementById('codpais').selectedIndex].text;
	var codpais = document.getElementById('codpais').options[document.getElementById('codpais').selectedIndex].value;
	
	gtr_makeRequest('manEstados.php?codpais=' + codpais, 'cboestados');
	
	if (pais.toLowerCase() == 'brasil' || pais.toLowerCase() == 'brazil'){
		document.getElementById('mapa_flash').style.display = '';
		document.getElementById('mapa_mundi').style.display = 'none';
	}else{
		document.getElementById('mapa_flash').style.display = 'none';
		document.getElementById('mapa_mundi').style.display = '';
	}
}

var modoPagina = "";
function pesquisaRepresentante(modo){
	if (modo==undefined) modo = modoPagina;
	var codpais		= document.getElementById('codpais').value;
	var nompais		= document.getElementById('codpais').options[document.getElementById('codpais').selectedIndex].text;
	var codestado	= document.getElementById('nn_codestado').value;
	
	if (codpais == ''){
		alert('Selecione um País!');
		document.getElementById('codpais').focus();
		return;
	}
	
	if((nompais.toLowerCase() == 'brasil') && (codestado == '')){
		alert('Selecione um Estado!');
		document.getElementById('nn_codestado').focus();
		return;
	}
	gtr_makeRequest('lisReprePesq.php?modo='+modo+'&codpais=' + codpais + '&nompais=' + nompais + '&codestado=' + codestado, 'resultado_pesq');
}

function selecionaEstado(codEstado){
	var cboPais		= document.getElementById('codpais');
	var cboEstado	= document.getElementById('nn_codestado');
	var i, nompais;
	//seleciona o Brasil como País
	/*
	for (i = 0; i < cboPais.length; i++){
		nompais	= cboPais.options[i].text;
		if (nompais.toLowerCase() == 'brasil' || nompais.toLowerCase() == 'brazil'){
			cboPais.selectedIndex = i;
		}
	}
	*/
	// seleciona o estado indicado
	for (i = 0; i < cboEstado.length; i++){
		if (cboEstado.options[i].value == codEstado){
			cboEstado.selectedIndex = i;
		}
	}
	//libera campo estado
	cboEstado.disabled = false;
	pesquisaRepresentante();
}
