//-------------------------------------------------------------------------- //
// Este script está registrado no Registro de Títulos e Documentos           //
// de Petrópolis / RJ Protocolado no livro nº 35101 livro B13 selo RDT50443  //
// A cópia não autorizada deste script acarretará em ação judicial (art 127) // 
// Desenvolvido por Peter M Jordan - tocando@tocando.com.br                  //
//-------------------------------------------------------------------------- //




































function derivacoes(chord)
{
chord = replaceChars(chord, '+', '%2b')
chord = replaceChars(chord, '#', '%23')
window.open('frm_dicionario.asp?acorde=' + chord, 'deriva', 'width=500, height=600')
}



function variaAcorde(spanId, Titulo)
{
	totalAcordes = arrAcordes[spanId - 1].length
	arrPosAcorde[spanId - 1] = (((arrPosAcorde[spanId - 1] + 1) >= totalAcordes) ? 0 : arrPosAcorde[spanId - 1] + 1);
	strAcorde = arrAcordes[spanId - 1][arrPosAcorde[spanId - 1]] 
	desenhaAcorde(spanId, Titulo, strAcorde)
}

function le(txt)
{
	rtxt = replaceChars(txt,  "A" , "2")
	rtxt = replaceChars(rtxt, "S" , "3")
	rtxt = replaceChars(rtxt, "D" , "0")
	rtxt = replaceChars(rtxt, "F" , "1")
	rtxt = replaceChars(rtxt, "G" , "5")
	rtxt = replaceChars(rtxt, "H" , "4")
	rtxt = replaceChars(rtxt, "J" , "6")
	rtxt = replaceChars(rtxt, "K" , "7")
	rtxt = replaceChars(rtxt, "L" , "8")
	rtxt = replaceChars(rtxt, "O" , "9")
	return rtxt
}
/*
function strrev(str) {
   if (!str) return '';
   var revstr='';
   for (i = str.length-1; i>=0; i--)
       revstr+=str.charAt(i)
   return revstr;
}*/
function reverseAcordes() 
{
	leftX = 0
	direcao *= -1
	if (direcao == 1) {document.getElementById("direcao2").innerHTML = "Acordes p/ Zurdo"} else {document.getElementById("direcao2").innerHTML = "Acordes p/ Diestro"}
	for (a=0; a<arrDesenhos.length; a++)
	{
		desenhaAcorde(a + 1, arrDesenhos [a], arrAcordes [a][arrPosAcorde[a]]);
	}
}
var direcao = 1

function desenhaAcorde(spanId, Titulo, strAcorde){
strAcorde = le(strAcorde)
spanAcorde = eval ("document.getElementById('acorde" + spanId + "')");
spanNotas = eval ("document.getElementById('notas" + spanId + "')");

arrAcorde = strAcorde.split(' ')
var min = 100
var max = toques = 0
tds = new Array()
var bolTonica = true
for (n = 0; n < arrAcorde.length; n++){
arrAc = arrAcorde[n]
if (arrAc != "X"){
if (arrAc != "0" && parseInt(arrAc) < min) min = parseInt(arrAc)
if (parseInt(arrAc) > max) max = parseInt(arrAc)
if (arrAc.substring(0,1) != "P" && arrAc != "0") toques ++
if (bolTonica) {tonica = n; bolTonica = false;}}}
var primeiroTraste = min
if (max <=5) min = 1
acorde = "<table border=0><tr><td width=17 valign=top align=right class=smalltext><div style='width:17px;'></div><br />" + (min == 1 ? "" : min) + "</td><td cclass='smalltext' width=130><b><a cclass=db style='cursor:pointer' onMouseOut='closeAcorde()' onMouseOver='acordeClassico(\"" + Titulo  + "\")' onclick='derivacoes(\"" + Titulo  + "\")'>" + Titulo + "</a></b><img class=noprint onClick=ouvir(\"" + Titulo  + "\") src=imagens/c/ouvir.gif /><br />";
acorde +="<img src='imagens/c/braco.gif' />"
if (spanId != 1000 && arrAcordes[spanId - 1].length > 1) {
acorde +="<table border=0 width=65 cellpadding=0 cellspacing=0 height=20>"
acorde +="<tr><td colspan=2 align=center><br /><a style='cursor:pointer' class='noprint smalltext' onClick=\"variaAcorde(" + spanId + ", '" + Titulo + "');\"><<>></a></td></tr></table>"}
acorde +="</td></tr><tr><td></td><td> </td</tr></table>"
notas = "<br /><img height=3 /><br /><table cellpadding=0 cellspacing=0 width=66 height=85>"
dedo = 1
for (traste = min; traste <= min + 4; traste ++){
notas +="<tr height=16>"
pestana = false
trasteVazio = true;
for (corda = 0; corda <= 5; corda ++){
//for (corda = 5; corda >= 0; corda --){
tds[corda] ="<td width=11 valign=bottom height=16>" 
posPestana = (arrAcorde[corda]  == "P" + traste)
if (arrAcorde[corda] == traste || pestana || posPestana){
trasteVazio = false;
if ((toques > 4 && traste == primeiroTraste) || pestana || posPestana){
if (!pestana) dedo ++
pestana = true
tds[corda] += "<img src='imagens/c/pestana.bmp' width=11 height=3 align=top />"}
else
{tds[corda] += "<img src=imagens/c/" + dedo + ".gif align=absmiddle />"; dedo ++}}
tds[corda] += "</td>"} 
if (trasteVazio && dedo > 1 && dedo < 3 && toques <4) dedo ++
if (direcao == -1) 
{
	for (n=5; n>=0; n--)
	{
		notas += tds[n]
	}
} else
{
	for (n=0; n<=5; n++)
	{
		notas += tds[n]
	}
}
notas +="</tr>"}
notas +="<tr height=16>"
if (direcao == -1) 
{
	for (n = arrAcorde.length-1; n>=0; n--){
	notas += "<td width=11 class='smalltext' align=center>" + (arrAcorde[n] == "X" ? "<img src='imagens/c/x.gif' align=absmiddle />" : (tonica == n ? "<img src='imagens/c/o_minusculo.gif' align=absmiddle />" :"<img src='imagens/c/o_minusculo2.gif' align=absmiddle />")) + "</td>"}
}
else
{
	for (n = 0; n < arrAcorde.length; n++){
	notas += "<td width=11 class='smalltext' align=center>" + (arrAcorde[n] == "X" ? "<img src='imagens/c/x.gif' align=absmiddle />" : (tonica == n ? "<img src='imagens/c/o_minusculo.gif' align=absmiddle />" :"<img src='imagens/c/o_minusculo2.gif' align=absmiddle />")) + "</td>"}
}
notas +="</tr>"
notas +="</table>"
spanAcorde.innerHTML = acorde;

if (spanId != 1000){
	if (ns6){spanNotas.style.top ='-11px'}
	spanNotas.style.left = (leftX + 25)  + 'px';
	spanAcorde.style.left = (leftX + 5) + 'px';
}
spanNotas.innerHTML = notas;
}

function ouvir(pAcorde){
for (n = 0; n < arrDesenhos.length; n++)
{ if (pAcorde == arrDesenhos[n]) {digitacao = le(arrAcordes[n][arrPosAcorde[n]]); break;} }
arrDig = digitacao.split(' ');digitacao = '';
for (n=arrDig.length - 1; n>=0; n--){digitacao += arrDig[n] + ' ';};digitacao = replaceChars(digitacao, 'X', '-1');	digitacao = replaceChars(digitacao, ' ', ':');parent.som.location = 'http://www.wholenote.com/cgi-bin/cpb.pl?pitches=' + digitacao + '&patch=3'}

function closeAcorde(){
acorde2000.innerHTML = ''
notas2000.innerHTML = ''}
function acordeClassico(pAcorde)
{
for (n=0; n< arrDesenhos.length; n++){
	if (pAcorde == arrDesenhos[n] || pAcorde == arrDesenhos[n]) break	
}
totalAcordes = arrAcordes[n].length
digitacao = arrAcordes[n][arrPosAcorde[n]] 
digitacao = le(digitacao.replace('P', ''))
spanAcorde = eval ("document.all.acorde2000" )
spanNotas = eval ("document.all.notas2000" )
arrAcorde = digitacao.split(' ')


var min = 100
var max = toques = 0
var bolTonica = true
for (n = 0; n < arrAcorde.length; n++){
arrAc = arrAcorde[n]
if (arrAc != "X"){
if (arrAc != "0" && parseInt(arrAc) < min) min = parseInt(arrAc)
if (parseInt(arrAc) > max) max = parseInt(arrAc)
if (arrAc.substring(0,1) != "P" && arrAc != "0") toques ++
if (bolTonica) {tonica = n; bolTonica = false;}
}}
var primeiroTraste = min
if (max >= 6) primeiroTraste = min - 1; else primeiroTraste=0
acorde = '<table width=280 bgcolor=#F9F9F9 cellpadding=0 cellspacing=0 border=0><tr><td align=center><br /><img src="imagens/c/braco.png" /><br /><br /></td></tr></table>'
spNotas = '<table cellpadding=0 cellspacing=0 border=0>'
spNotas += '<tr height=18><td width=46></td><td width=46></td><td width=46></td><td width=46></td>'
if (max >= 6) spNotas += '<td width=46 valign=bottom><b>' + (primeiroTraste+1) + 'ª</b></td></tr>'; else spNotas += '<td width=46></td></tr>'
for (corda = 0; corda <= 5; corda ++)
{

	spNotas += '<tr height=18>'
	for (traste = 5; traste>= 0; traste--)
	{
		spNotas += '<td width=46>'
		if ( parseInt(arrAcorde[corda]) == 0 && traste==0) spNotas += '<img src=imagens/c/o_minusculo2.gif />'
		else if ( parseInt(arrAcorde[corda] - primeiroTraste) == traste ) spNotas += '<img src=imagens/c/solta.gif />'
		else if ( arrAcorde[corda] == "X" && traste == 0 ) spNotas += '<img src=imagens/c/x.gif />'
		spNotas += '</td>'
	}
	spNotas += '</tr>'
}
spNotas += '</table>'
spanAcorde.innerHTML = acorde;
spanNotas.innerHTML = spNotas;
spanNotas.style.top = ((ns6)?event.pageY: event.clientY+ietruebody().scrollTop - 144) + 'px';
spanAcorde.style.top = (event.clientY+ietruebody().scrollTop - 138) + 'px'; //window.event.y + ietruebody().scrollTop) + 'px';
spanNotas.style.left = (window.event.x + 40)  + 'px';
spanAcorde.style.left = (window.event.x + 10)  + 'px';
spanAcorde.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(direction=130,color=gray,strength=8);'
}
function MD(e,pDetalhes)
{
	var offSetX1 = (ns6)?0:0;
	var offSetY1 = (ns6)?0:0;
	var offSetX2 = (ns6)?22:22;
	var offSetY2 = (ns6)?-11:0;
	curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;

	for (n=0; n< arrDesenhos.length; n++){if (pDetalhes == arrDesenhos[n] || pDetalhes == arrDesenhos[n]) break;}
	totalAcordes = arrAcordes[n].length
	strAcorde = arrAcordes[n][arrPosAcorde[n]] 
	document.getElementById('acorde1000').style.filter = 'progid:DXImageTransform.Microsoft.Shadow(direction=130,color=gray,strength=8);'

	document.getElementById('acorde1000').style.display = "block"

	document.getElementById('notas1000').style.display = "block"

	desenhaAcorde(1000, pDetalhes, strAcorde)

	document.getElementById('notas1000').style.top = (curY + offSetY2 - 50) + 'px'; //-80 + window.event.y + IEHorizontal
	document.getElementById('acorde1000').style.top = (curY + offSetY1 - 50) + 'px'; //-80 + window.event.y + IEHorizontal
	document.getElementById('notas1000').style.left = (curX + offSetX2 + 20) + 'px'; //window.event.x + (keyb == "true" ? 0 : 20) + 30
	document.getElementById('acorde1000').style.left = (curX + offSetX1 + 20) + 'px'; //window.event.x + 30
}

function AD(pDetalhes) {
document.getElementById('acorde1000').style.display = "none";
document.getElementById('notas1000').style.display = "none";
}
