﻿function fnCheckOne(me)
{
me.checked=true;
var chkary=document.getElementsByTagName('input');
for(i=0;i<chkary.length;i++)
{
if(chkary[i].type=='checkbox')
{
   if(chkary[i].id!=me.id)
   chkary[i].checked=false;
}
}
}

function validateForm()
{
var x=document.forms["tabForm"]["Tabarea"].value
if (x==null || x=="")
  {
  alert("Please paste chords or tabs in the text area before clicking 'Transpose'");
  return false;
  }
}

function insertsample() {
var output = "";
if (document.getElementById("getsample").href) {
output = output + "G                     D                Em          C" + "\n" + "When I find myself in times of trouble mother Mary comes to me" + "\n" + "G                 D              C     G" + "\n" + "Speaking words of wisdom, let it be." + "\n" + "G                 D               Em                C" + "\n" + "And in my hour of darkness she is standing right in front of me" + "\n" + "G                 D              C     G" + "\n" + "Speaking words of wisdom, let it be." + "\n\n" + "E|----------------------------------------------------------------0-|" + "\n" + "B|--1-------1-------3---------3------1--------1----------1----3-----|" + "\n" + "G|------0-------0-------0---------0------2--------2----2--------2---|" + "\n" + "D|----2-------2-------0---------0------2--------2----3------3-------|" + "\n" + "A|--3-----3--------------------------0------0-----------------------|" + "\n" + "E|------------------3------3----------------------------------------|";
document.getElementById('Tabarea').style.fontFamily='Courier New'
document.getElementById('Tabarea').style.fontSize='10px'
document.getElementById('Tabarea').style.height='315px'
}
document.getElementById("Tabarea").value = output;
}

 window.onload=function() {  
  if (document.getElementById) { 
 document.getElementById("w").onchange=function() { switchme(this); }  
  } 
 } 
 function switchme(SNewSel) { 
 var ind = SNewSel.selectedIndex; 
 var txt = document.getElementById('s'); 
 switch (ind) { 
 case 0:
 txt.value = "Beatles"; 
 break; 
 case 1:
 txt.value = "A Hard Days Night" 
 break; 
 case 2:
 txt.value = "Beatles" 
 break; 
 case 3:
 txt.value = "Beatles"; 
 break;
 case 4:
 txt.value = "Beatles"; 
 break;
 case 5:
 txt.value = "Practice Session"; 
 break;
 default:
 txt.value=''; 
 break; 
 } 
}

// Verify Chords or Tabs

var tab_find_arr=new Array("E |","A |","D |","G |","B |","E|","A|","D|","G|","E-","A-","D-","G-","B-","---------");

var tab_alert_arr=new Array;
var tab_alert_count=0;

function reset_alert_count()
{
 tab_alert_count=0;
}

function validate_chords()
{
 reset_alert_count();
 var compare_text=document.tabForm.Tabarea.value;
 for(var i=0; i<tab_find_arr.length; i++)
 {
  for(var j=0; j<(compare_text.length); j++)
  {
   if(tab_find_arr[i]==compare_text.substring(j,(j+tab_find_arr[i].length)).toUpperCase())
   {
    tab_alert_arr[tab_alert_count]=compare_text.substring(j,(j+tab_find_arr[i].length));
    tab_alert_count++;
   }
  }
 }
 var alert_text="";
 for(var k=1; k<=tab_alert_count; k++)
 {
  alert_text+="\n" + "(" + k + ")  " + tab_alert_arr[k-1];
 }
 if(tab_alert_count<1)
 {
  document.tabForm.D3.selectedIndex = 1;
  document.tabForm.submit();
 }
 else
 {
  document.tabForm.submit();
 }
}

window.onload=reset_alert_count;
