//-------------------------------------------------------------------------- //
// 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 replaceChars(entry, out, add)
 {
	temp = ""  + entry;
	while (temp.indexOf(out)>-1) {
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

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]] 
	leftX = ((spanId % 8) == 0 ? 8 * 80 : (spanId % 8) * 80) - 80
	desenhaAcorde(spanId, Titulo, strAcorde)
}
stop=1;

function replaceSubstring(inputString, fromString, toString) {
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { 
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { 
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } 
	     while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } 
   return temp; 
} 

function desenhaAcorde(spanId, Titulo, strAcorde){
//if (document.referrer  != '' && document.referrer.substr(0, 25) != 'http://www.tocando.com.br' && document.referrer.substr(0, 24) != 'http://www.cifras.com.br' && document.referrer.substr(0, 20) != 'http://cifras.com.br' && document.referrer.substr(0, 21) != 'http://tocando.com.br') return
spanAcorde = eval ("document.all.acorde" + spanId)
spanNotas = eval ("document.all.notas" + spanId)
arrAcorde = strAcorde.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 <=5) min = 1
acorde = "<table border=0><tr><td width=17 valign=top align=right class=smalltext><br>" + (min == 1 ? "" : min + "ª") + "</td><td class='smalltext'><b><a class=acorde style='cursor:hand'>" + Titulo + "</a></b><br>";
acorde +="<img src='images/cavaq.gif'>"

if (spanId != 1000 && arrAcordes[spanId - 1].length > 1) {
acorde +="<table border=0 width=48 cellpadding=0 cellspacing=0 height=20>"
//acorde +="<tr><td colspan=2 align=center><br><a style=cursor:hand class=smalltext onClick=\"variaAcorde(" + spanId + ", ",",",",",",",",'" + Titulo + "');\">variação</a></td></tr></table>"}
acorde +="<tr><td colspan=2 align=center><br><a style=cursor:hand class=smalltext onClick=\"variaAcorde(" + spanId + ", '" + Titulo + "');\">variation</a></td></tr></table>"}


acorde +="</td></tr><tr><td></td><td> </td></tr></table>"
notas = "<br><img height=3><br><table border=0 cellpadding=0 cellspacing=0 width=52 height=85>"
dedo = 1
//-----

for (traste = min; traste <= min + 4; traste ++){
notas +="<tr height=16>"
pestana = false
trasteVazio = true;
for (corda = 0; corda <= 3; corda ++){
notas +="<td width=13 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
notas += "<img src='images/pestana.bmp' width=13 height=3 align=top>"}
else
{notas += "<img src=images/" + dedo + ".gif align=absmiddle>"; dedo ++}}
notas += "</td>"} 
if (trasteVazio && dedo > 1 && dedo < 3 && toques <4) dedo ++
notas +="</tr>"}
notas +="<tr height=16>"
for (n = 0; n < arrAcorde.length; n++){
notas += "<td width=13 class='smalltext' align=center>" + (arrAcorde[n] == "X" ? "<img src='images/x.gif' align=absmiddle>" : (tonica == n ? "<img src='images/o_minusculo.gif' align=absmiddle>" :"<img src='images/o_minusculo2.gif' align=absmiddle>")) + "</td>"}
notas +="</tr>"
notas +="</table>"
spanAcorde.innerHTML = acorde;
if (spanId != 1000) {
spanAcorde.style.left = leftX + 30;
spanNotas.style.left = leftX + 20 + 30;}
spanNotas.innerHTML = notas;
leftX += 80
if (leftX == 640) leftX = 0


}
-->
