var open_char		= null		// usa essa variável para esconder o menu atual antes de abrir um novo
var on_char			= null
var char_out		= null		// hora da saída do mouse do caractere
var div_bands_char	= false
var c				= null		// caractere de busca de banda

function oasisnow(){}
	
function submitForm(formulario, valor){
	a = document.forms[formulario];
	a.etapa.value = valor;
	setTimeout("a.submit()", 0);}

function openTips(pagina, janela, titulo){
	pagina = (pagina != null) ? pagina : "http://oasisnow.com/tips.html" ;
	janela = (janela != null) ? janela : "Dicas de formatação" ;
	window.open("http://oasisnow.com/tips.html", 1, "width=520, height=400, scrollbars=NO")}

function confirma(pergunta, formu, valor){
	if (confirm(pergunta)){submitForm(formu, valor)}}

function mostra(campo, valor1){
	valor	= (valor1 == 'auto') ? ((document.getElementById(campo).style.display !== "none") ? "none" : "block") : valor1;
	document.getElementById(campo).style.display = valor}

function alteraBanda(){
	bandaID		= document.selectBanda.banda[document.selectBanda.banda.selectedIndex].value
	window.location = "http://oasisnow.com/" + bandaID}
	
function mudaFoto(imag, ft){
	document.images[imag].src						= cdCapa[ft];
	document.getElementById("capaObs").innerHTML	= cdObs[ft];}
	
function selectAll(formu, name, valor){
	boxes	= document.getElementById(name)
	window.alert(boxes.length)
	for (i=0; i<boxes.length; i++){
		boxes[i].checked = valor}}

function changeNode(nodeN, content, classe){
	node						= document.getElementById(nodeN)
	if(node){
		if(content == "" || content == null || !content){
			node.innerHTML		= content}
		else if(content.nodeType == '1'){		// caso em que se está adicionando um elemento novo
		nodes			= node.childNodes.length
			for( i=0; i < nodes; i++ ){
				node.removeChild(node.childNodes[(nodes - i - 1 )]);}
			node.appendChild(content)}
		else{								// caso em que se está adicionando texto HTML
			node.innerHTML		= content}
		if(classe != null){
			node.className			= classe}}}

function show_char(c){
	if(open_char != c && on_char == c){		// a letra q estava sendo mostrada era outra ou não havia nenhuma sendo mostrada
		mostra('char_'+c, 'block');}
		open_char		= c;}

function hide_char(c, h){
	if(c == open_char && (c != on_char || h == true) && c != null){
		if(h == null || h == char_out || h == true){	// se a última saída do mouse se deu antes dessa execuão, ou seja, H = char_out
			mostra('char_'+c, 'none');
			open_char	= null}}}

function char_Mon(c){
	hideTheme();
	on_char = c;
	hide_char(open_char, null);
	show_char(c);}

function char_Mout(c){
	char_out		= new Date()
	char_out		= char_out.getSeconds()+'.'+char_out.getMilliseconds()
	on_char = null;
	setTimeout('hide_char(\''+c+'\', \''+char_out+'\')','500')}

function char_select(c){
	var vars			= new Array();
	vars['c']			= c
	hide_char(open_char, true)
	this_ajax	= ajax();
	if(this_ajax == null){		// navegador não suporta objeto xmlHTTP...
		window.location		= 'http://oasisnow.com/'+c+'.html';}
	else{		
	if(div_bands_char == true){
			div_rem			= document.getElementById('bands_char');
			div_rem.parentNode.removeChild(div_rem);}
		div					= document.createElement('div');
		div.setAttribute('id', 'bands_char');
		table1				= document.createElement('table');
		table1.className	= 'divs';
		tbody1				= document.createElement('tbody');
		table1.setAttribute('cellSpacing', '0px');
		tr1					= document.createElement('tr');
		td1					= document.createElement('td');
		td1.className		= 'topl';
		td2					= document.createElement('td');
		td2.className		= 'top';
		td2.colsplan		= '2';
		title				= document.createElement('h1');
		title.innerHTML		= 'Bandas com a letra '+c;
		title.setAttribute('style', 'float: left');
		closea				= document.createElement('a');
		closea.href			= 'javascript: oasisnow(0)';
		closea.setAttribute('style', 'float: right');
		closea.setAttribute('onclick', 'document.getElementById(\'bands_char\').parentNode.removeChild(document.getElementById(\'bands_char\')); div_bands_char = false');
		closeb				= document.createElement('img');
		closeb.src			= 'http://www.pracasaolourenco.com.br/close.gif';
		closeb.setAttribute('style', 'margin-top: 12px');
		closea.appendChild(closeb);
		td2.appendChild(title);
		td2.appendChild(closea);
		td3					= document.createElement('td');
		td3.className		= 'topr';
		tr1.appendChild(td1);
		tr1.appendChild(td2);
		tr1.appendChild(td3);
		tbody1.appendChild(tr1);
		table1.appendChild(tbody1);
		table2				= document.createElement('table');
		table2.className	= 'divs';
		tbody2				= document.createElement('tbody');
		table2.setAttribute('cellSpacing', '0px');
		tr2					= document.createElement('tr');
		td4					= document.createElement('td');
		td4.className		= 'midl';
		td5					= document.createElement('td');
		td5.className		= 'mid';
		td5.colsplan		= '2';
		td5.setAttribute('style', 'text-align: center');
		td5.setAttribute('id', 'show_char');
		loading				= document.createElement('img');
		loading.src			= 'http://www.fee.rs.gov.br/feedados/images/loading.gif';
		td5.appendChild(loading);
		td6					= document.createElement('td');
		td6.className		= 'midr';
		tr2.appendChild(td4);
		tr2.appendChild(td5);
		tr2.appendChild(td6);
		tbody2.appendChild(tr2);
		table2.appendChild(tbody2);
		table3				= document.createElement('table');
		table3.className	= 'divs';
		tbody3				= document.createElement('tbody');
		table3.setAttribute('cellSpacing', '0px');
		tr3					= document.createElement('tr');
		td7					= document.createElement('td');
		td7.className		= 'botl';
		td8					= document.createElement('td');
		td8.className		= 'bot';
		td8.colsplan		= '2';
		td9					= document.createElement('td');
		td9.className		= 'botr';
		tr3.appendChild(td7);
		tr3.appendChild(td8);
		tr3.appendChild(td9);
		tbody3.appendChild(tr3);
		table3.appendChild(tbody3);
		parente				= document.getElementById('caixa');
		local				= parente.childNodes[0];
		linha				= document.createElement('br');
		div.appendChild(table1);
		div.appendChild(table2);
		div.appendChild(table3);
		div.appendChild(linha);
		parente.insertBefore(div, local);
		div_bands_char		= true;
		resposta	= xmlHTTP(this_ajax, 'char='+c, location.protocol+'//'+location.hostname+'/'+c+'.html', 'bands_char1', 'scrap_ajax2', vars);
	}}

function console(campo, i){
	/*
	Propriedades ajustáveis
	- before; (antes de obj.id)
	*/
	exist			= document.getElementById('console_'+i);
	this.div			= document.createElement('div');
	this.div.className	= 'console';
	this.div.id		= 'console_'+i;
	this.ul			= document.createElement('ul');
	this.li1			= document.createElement('li');
	this.li2			= document.createElement('li');
	this.li3			= document.createElement('li');
	this.li3.className	= 'trash_icon';
	this.conf_a		= document.createElement('a');
	this.conf_a.href	= 'javascript: oasisnow(0)';
	this.conf			= document.createElement('img');
	this.conf.src		='/img/conf_icon.gif';
	this.canc_a		= document.createElement('a');
	this.canc_a.href	= 'javascript: oasisnow(0)';
	this.canc			= document.createElement('img');
	this.canc.src		= '/img/cancel_icon.gif';
	this.tra_a		= document.createElement('a');
	this.tra_a.href	= 'javascript: oasisnow(0)';
	this.tra			= document.createElement('img');
	this.tra.src		= 'http://oasisnow.com/img/b.gif';
	this.append	= function(){
		if(!exist){
			this.conf_a.appendChild(this.conf);
			this.canc_a.appendChild(this.canc);
			this.tra_a.appendChild(this.tra);
			this.li1.appendChild(this.conf_a);
			this.li2.appendChild(this.canc_a);
			this.li3.appendChild(this.tra_a);
			this.ul.appendChild(this.li1);
			this.ul.appendChild(this.li2);
			this.ul.appendChild(this.li3);
			this.div.appendChild(this.ul);
			document.getElementById(campo).appendChild(this.div);}
		else return false;}}

function interat(campo, mostrar){
	obj			= document.getElementById(campo);
	if(obj){		// esconde os outros
		document.getElementById(campo+'_1').style.display	= 'none';
		document.getElementById(campo+'_2').style.display	= 'none';
		document.getElementById(campo+'_3').style.display	= 'none';
		document.getElementById(campo+'_'+mostrar).style.display	= 'block';}
	else return false;}