function iniciaBusca() {
	document.formulario.action = document.formulario.acao.value;
	document.getElementById('carregando').style.visibility = 'visible';
	parent.publicidade.location = parent.publicidade.location;
	document.formulario.submit();
	linkinho();
	return false;
}

function cancelaBusca() {
	document.getElementById('carregando').style.visibility = 'hidden';
}

function linkinho(x) {
	if(quallink == 0) {
		var t = "<a href='http://www.vinilator.com.br/treino' target='_blank'><span style='font-size: 7pt;'>Treine seu inglês!</span></a>";
		quallink = 1;
	} else {
		var t = "<a href='http://www.vinilator.com.br/forum.php' target='_blank'><span style='font-size: 7pt;'>Dê a sua opinião sobre o Vinilator!</span></a>";
		quallink = 0;
	}
	document.getElementById('linkinho').innerHTML = t;
	if(x == 1) setTimeout("linkinho()", 10000);
}

function someBabylon(y, sel) {
	ie=document.all?1:0;
	if(ie) {
		for(ii=0; ii<y; ii++) {
			if(document.getElementById('aba'+ ii).title == 'Firefox Only') {
				document.getElementById('aba'+ ii).style.display = 'none';
				return sel;
			}
		}
	} else {
		return 0;
	}
}

function mudaOpcao(x, y, m) {
	document.getElementById('comando').innerHTML = document.getElementById('quadro'+ x).innerHTML;
	for(ii=0; ii<y; ii++) document.getElementById('aba'+ ii).className = 'naoSelecionado';
	document.getElementById('aba'+ x).className = 'selecionado';
	if(m == 1) document.getElementById('texto').style.height='30px';
	else document.getElementById('texto').style.height='20px';
	document.getElementById('texto').focus();
	document.getElementById('texto').select();
}

function config() {
	var w=600;
	var h=370;
	var y = screen.availHeight/2-h/2;
	var x = screen.availWidth/2-w/2;
	window.open('config.php', 'ConfigVinilator', 'width='+ w +', height='+ h +', left='+ x +', top='+ y);
}

/*CONFIGURAÇÕES*/
var ordem;

function inicia_config() {
	lista = document.getElementById('engines');

	ie=document.all?1:0;
	if(ie) {
		for(i=0; i<lista.length; i++) {
			if(lista.options[i].text == "Babylon") {
				lista.remove(i);
			}
		}
	}

	lista.selectedIndex=0;
	mostraInfoEngine(lista, 0);
}

function mostraInfoEngine(x, y) {
	x = x.options[x.selectedIndex].value;
	for(ii=1; ii<=y; ii++) {
		if(document.getElementById('engine'+ii) != "undefined") {
			document.getElementById('engine'+ii).style.visibility='hidden';
			document.getElementById('engine'+ii).style.position='absolute';
		}
	}
	document.getElementById('engine'+x).style.visibility='visible';
	document.getElementById('engine'+x).style.position='relative';
}

function matrix(valor, texto) {
   this.valor = valor
   this.texto = texto
}

function moveitem(sobe) {
	lista = document.getElementById('engines');
	indice = lista.selectedIndex;
	if(sobe) indice2 = indice-1;
	else indice2 = indice+1;

	matriz = new Array();
	for(i=0; i<lista.length; i++) {
		tempvalor = lista.options[i].value;
		temptexto = lista.options[i].text;
		matriz[i] = new matrix(tempvalor, temptexto);
	}
	if (((indice > 0) && (sobe)) || ((indice < lista.length-1) && (!sobe))) {
		tempvalor = matriz[indice2].valor;
		temptexto = matriz[indice2].texto;
		matriz[indice2].valor = matriz[indice].valor;
		matriz[indice2].texto = matriz[indice].texto;
		matriz[indice].valor = tempvalor;
		matriz[indice].texto = temptexto;
		indice = indice2;
	}
	for(a=lista.length; a>=0; a--) lista.options[a]=null;
	ordem = "";
	i = 0;
	while(i < matriz.length) {
		lista.options[lista.length] = new Option(matriz[i].texto,matriz[i].valor);
		ordem += "," + matriz[i].valor;
		i++;
	}
	ordem = ordem.slice(1);
	lista.selectedIndex = indice;
	document.getElementById('ordemEngines').value = ordem;
}

function selecionaPadrao(x, y) {
	document.getElementById('opcaoPrincipal'+ x).value = x +", "+ y;
}

function defineLingua(x) {
	var ling = x.options[x.selectedIndex].value;
	document.getElementById('ajax').src = 'includes/ajax.php?com=mudaLingua&ling='+ ling;
}

function salvar_config() {
	var z = prompt('Digite seu nome para identificar esta configuração:', '');
	if ((z!=null) && (z!='')) {
		document.getElementById('nomeUser').value=z;
		document.formulario.submit();
	}
}

function abrir_config() {
	var z = prompt('Digite o código de identificação de sua configuração:', '');
	if ((z!=null) && (z!='')) document.getElementById('ajax').src = 'includes/ajax.php?com=abrirConfig&cod='+ z;
}

var quallink=0;
