<!--
/* POSICIONAMENTO DO ACORDE */
var curX;
var curY;
var ns6=document.getElementById && !document.all
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}



if (document.referrer.substr(0, 24) == 'http://www.kboing.com.br' || document.referrer.substr(0, 20) == 'http://kboing.com.br')
{
	if (! (document.getElementById("logo") == null)) document.getElementById("logo").src = "http://www.cifras.com.br/imagens/logo_kboing_cifras.gif";
}

notas_musicais = new Array ();
notas_musicais[1] = new Array('C', '')
notas_musicais[2] = new Array('C#', 'Db')
notas_musicais[3] = new Array('D', '')
notas_musicais[4] = new Array('Eb', 'D#')
notas_musicais[5] = new Array('E', '')
notas_musicais[6] = new Array('F', '')
notas_musicais[7] = new Array('F#', 'Gb')
notas_musicais[8] = new Array('G', '')
notas_musicais[9] = new Array('G#', 'Ab')
notas_musicais[10] = new Array('A', '')
notas_musicais[11] = new Array('Bb', 'A#')
notas_musicais[12] = new Array('B', '')
	
function retornaCifra(){
arrayTags = document.getElementsByTagName("u")
for (n = 0; n < arrayTags.length; n++)
{
if (ns6){arrayTags[n].innerHTML = "" + retornaNovaNota2(arrayTags[n].innerHTML, tom, true) + ""}
else{arrayTags[n].innerHTML = "<pre style='margin-left:0'>" + retornaNovaNota2(arrayTags[n].innerHTML, tom, true) + "</pre>"}
}
}

function retornaCifra1() {
tamanho1 = cifra.length;
nova_cifra = ''
for (n = 0; n<tamanho1; n++) {
char1 = cifra.substr(n,3);
if (char1 == '<U>') {
nota = ''; n +=3;
while (cifra.substr(n,4) != '</U>' && n < tamanho1) 
{
nota += cifra.substr(n,1); n++; 
} 
n +=4; nova_cifra += retornaNovaNota2(nota, tom, true);
} // if (char1 == '<U>'...
nova_cifra += cifra.substr(n,1);} // for (n=0...
document.getElementById("spCifra").innerHTML  = "<pre>" + nova_cifra + "</pre>"  
}

if (ns6) 
	retornaCifra() 
else 
	retornaCifra1()
	
function procuraNota(strNota3) {
	for (n1=1; n1<=12; n1++) {if (notas_musicais[n1][0] == strNota3 || notas_musicais[n1][1] == strNota3) break	}
	return n1;
}
function retornaNota(strNota1, intTom) {
id = procuraNota(strNota1);
if (id == 13) return strNota1
if (intTom < 0) {intTom += 12;}
if (intTom > 12) intTom = intTom % 12;
var novo_id = id + intTom;
if (novo_id > 12) novo_id = novo_id % 12;
strNota1 = notas_musicais[novo_id][0];
return strNota1;
}
function retornaNovaNota2(strNota2, intTom, poeTags) {
strNota2 += ' ';nova_nota = ''; nota_2 = ''; tamanho = strNota2.length; acorde = '';aberto = false
for (pos = 0; pos < tamanho; pos ++)
{
	nova_nota += strNota2.substr(pos, 1);
	notaFutura = nova_nota + strNota2.substr( pos + 1, 1) // + '*'
	if ((strNota2.substr(pos, 1) == ' ' || strNota2.substr(pos, 1) == '\t') && aberto)  
	{
		aberto = false
		if (poeTags)
			nota_2 += '<a onMouseOver="MD(event,\'' + acorde + '\')" onMouseOut="AD(\'\')">' + acorde + '</a>' 
		else
			nota_2 += acorde
		acorde = ''
		txtAcorde = ''
	}
	if (strNota2.substr(pos, 1) != ' ' && strNota2.substr(pos, 1) != '\t' && !aberto) 
	{ aberto= true;acorde = '';txtAcorde = '' }
	if (procuraNota(notaFutura) == 13) 
	{
		if (intTom == 0) acorde += nova_nota
		else 
		acorde += retornaNota (nova_nota, intTom);nova_nota = '';
	} 
	if (!aberto && pos < tamanho - 1) nota_2 += strNota2.substr(pos, 1)
}
return nota_2;
}


function escondeAcordes()
{
	if (!letra)
	{
		letra = true
		result1 = replaceChars(cifra, "<U>", '[')
		result1 = replaceChars(result1, "</U>", ']')
		result = ""
		for (n=0; n<result1.length; n++)
		{
			char1 = result1.charAt(n)
			if (char1 != "[")
			{
				result += char1
			}
			else
			{
				while (char1 != "]" && n<result1.length)
				{
					n ++;
					char1 = result1.charAt(n)
				}
			}
		}

		result = replaceChars(result, "Introdução", '')
		result = replaceChars(result, "Introd", '')
		result = replaceChars(result, "Intro", '')
		result = replaceChars(result, "://", '@//')
		result = replaceChars(result, ":", '')
		result = replaceChars(result, "@//", '://')
		result = replaceChars(result, "2x", '')
		result = replaceChars(result, "2X", '')
		result = replaceChars(result, "()", '')
		result = replaceChars(result, "\r", '\n')
		result = replaceChars(result, "\n\n", '<br>')
		result = replaceChars(result, "<br><br>", '<br>')
		//result = replaceChars(result, "<PRE>", '<font style="font-family:arial;margin-left:10px">')
		//result = replaceChars(result, "</PRE>", '</font>')
		document.getElementById("spCifra").innerHTML  = "<div style='margin-left:20px'>" + result + "</div>"
		cifraquebrada = false
	}
	else
	{
		letra = false
		document.getElementById("spCifra").innerHTML  = cifra;
		retornaCifra()
	}
}


function quebraCifra()
{

	if (!cifraquebrada)
	{

		cifra2 = cifra.split('\n')
		cifra2[0] = "<table width='100%' border=0><tr><td width='50%' valign=top>" + cifra2[0]
		ref = false
		for (n = 1; n < cifra2.length; n ++)
		{ 
			if (cifra2[n].indexOf("<table") > -1) // refrao aberto
			{
				ref = true
			}
			if (cifra2[n].indexOf("</table") > -1) // refrao fechado
			{
				ref = false
			}
		
			if (n >= parseInt(cifra2.length / 2) && !ref && (cifra2[n].indexOf("<U>") > -1 || (cifra2[n].indexOf("<U>") == -1 && cifra2[n-1].indexOf("<U>") == -1) ) ) 
			{
			
				cifra2[n] = "</pre></td><td width='50%' valign=top style='border-left:dashed 1px #CCC'><pre>" + cifra2[n]
				break;
			}
	}
	cifra2[cifra2.length -1] =  cifra2[cifra2.length - 1] + "</td></tr></table>"
	cifra2 = cifra2.join ("\n")
	
	document.getElementById("spCifra").innerHTML  =	cifra2;
	retornaCifra()

	}
	else
	{
		document.getElementById("spCifra").innerHTML  = cifra;
		retornaCifra()
	}
	cifraquebrada = !cifraquebrada
	notation(parseInt(get_cookie("notation")), true);
}
function changeNotation(chord, typeNotation)
{
	if (typeNotation == 2)
	{
		chord = replaceChars(chord, "D", "Re")
		chord = replaceChars(chord, "C", "Do")
		chord = replaceChars(chord, "E", "Mi")
		chord = replaceChars(chord, "F", "*a")
		chord = replaceChars(chord, "*", "F")
		chord = replaceChars(chord, "G", "Sol")
		chord = replaceChars(chord, "A", "La")
		chord = replaceChars(chord, "B", "Si")
		return "<font class=lat>" + chord + "</font>"
	}
	else //if (typeNotation == 1)
	{
		chord = replaceChars(chord, "Do", "C")
		chord = replaceChars(chord, "Re", "D")
		chord = replaceChars(chord, "Mi", "E")
		chord = replaceChars(chord, "Fa", "F")
		chord = replaceChars(chord, "Sol", "G")
		chord = replaceChars(chord, "La", "A")
		chord = replaceChars(chord, "Si", "B")
		return chord
	}

}
function notation(typeNotation, force)
{
	//alert(parseInt(get_cookie("notation")) + " - " + typeNotation)
	if (parseInt(get_cookie("notation")) != typeNotation || force) 
	{
		var obj = document.getElementById("spCifra")
		var arrayTags = obj.getElementsByTagName("A")
	
		for (n = 0; n < arrayTags.length; n++)
		{
			arrayTags[n].innerHTML = changeNotation(arrayTags[n].innerHTML, typeNotation)
		}
	
		var obj = document.getElementById("acordes")
		var arrayTags = obj.getElementsByTagName("A")
		for (n = 0; n < arrayTags.length; n++)
		{
			arrayTags[n].innerHTML = changeNotation(arrayTags[n].innerHTML, typeNotation)
		}
	
		if (typeNotation == 1)
		{
			document.getElementById("not1").src = "imagens/chk_on.gif"
			document.getElementById("not2").src = "imagens/chk_off.gif"
			document.cookie = "notation=" + escape("1") + "; expires=Wed, 1 Jan 2020 01:00:00 UTC; path=/";
		}
		else
		{
//		=testcookie; expires=Wed, 1 Jan 2020 01:00:00 UTC; path=/'

			document.getElementById("not1").src = "imagens/chk_off.gif"
			document.getElementById("not2").src = "imagens/chk_on.gif"
			document.cookie = "notation=" + escape("2") + "; expires=Wed, 1 Jan 2020 01:00:00 UTC; path=/";
		}
	}
}
function openTab(nTab)
{
obj = document.getElementById("tab" + nTab)
if (obj.style.display == 'block')
{
obj.style.display = 'none'
return;
}
obj.style.display = 'block'
id = setInterval('expand(' + nTab + ')', 10)	
}
function expand(nTab)
{
obj = document.getElementById("tab" + nTab)
obj.style.width = nn + 'px'
if (nn < 80) obj.style.height = nn + 'px'
nn += nn2
nn2 ++
if (nn > 350) {
clearInterval(id)
obj.style.width = null
obj.style.height = null
nn = 1;
nn2 = 2;
}
}
//-->