/*********************************************************/
// Global STYLE variables 
var GeneralFont    ='STYLE="font-size:12px;color:#000000"'
var AlycatFont     ='STYLE="font-size:10px;color:#FF0000"'
var HeadingFont    ='STYLE="font-size:18px;color:#FF0000;font-weight:bold"'
var DivFont        ='STYLE="background-color:#FFFFFF"'
var FirstColumnFont='STYLE="font-size:14px;color:#FFFFFF;font-weight:bold;background-color:#0000FF"'
var QuickSignup    =''
/*********************************************************/
var AllowDisplay='No'
var DriverData=''
var SelectedClass
var SelectMeeting
var MeetingName
var MeetingDate
var SelectRaceClass
var SubmitButton1
var SubmitButton2
var SubmitButton3
var SubmitButton4
var SubmitButton5
var WorkingRawData
/*********************************************************/
var DriverNameInput='<INPUT type="TEXT" name="name" size="26" maxlength="50"'
var DriverSkillInput1='<SELECT NAME="skill">'+
                     '<OPTION VALUE=1>1</OPTION>'+
                     '<OPTION VALUE=2>2</OPTION>'+
                     '<OPTION VALUE=3>3</OPTION>'+
                     '<OPTION VALUE=4>4</OPTION>'+
                     '<OPTION VALUE=5 SELECTED>5</OPTION>'+
                     '<OPTION VALUE=6>6</OPTION>'+
                     '<OPTION VALUE=7>7</OPTION>'+
                     '<OPTION VALUE=8>8</OPTION>'+
                     '<OPTION VALUE=9>9</OPTION>'+
                     '<OPTION VALUE=10>10</OPTION>'+
 '</SELECT>'
var DriverSkillInput2='<SELECT NAME="skill">'+
                     '<OPTION VALUE=" ">default</OPTION>'+
                     '<OPTION VALUE=1>1</OPTION>'+
                     '<OPTION VALUE=2>2</OPTION>'+
                     '<OPTION VALUE=3>3</OPTION>'+
                     '<OPTION VALUE=4>4</OPTION>'+
                     '<OPTION VALUE=5>5</OPTION>'+
                     '<OPTION VALUE=6>6</OPTION>'+
                     '<OPTION VALUE=7>7</OPTION>'+
                     '<OPTION VALUE=8>8</OPTION>'+
                     '<OPTION VALUE=9>9</OPTION>'+
                     '<OPTION VALUE=10>10</OPTION>'+
 '</SELECT>'
var ClubNameInput='<INPUT type="TEXT" name="club" size="5" maxlength="50"'
var Frequency1Input='<FONT '+GeneralFont+'><\/FONT><INPUT type="TEXT" name="freq1" size="15" maxlength="10"'
var Frequency2Input='<FONT '+GeneralFont+'><\/FONT><INPUT type="TEXT" name="freq2" size="15" maxlength="10"'
var Frequency3Input='<FONT '+GeneralFont+'><\/FONT><INPUT type="TEXT" name="freq3" size="15" maxlength="10"'
var AMBrcNumInput  ='<INPUT type="TEXT" name="ambrc" size="10" maxlength="7"'
var EmailAdrInput  ='<INPUT type="TEXT" name="submit_by" size="22" maxlength="50"'
/*********************************************************/
function IdOnKeyPress()
{
var DriverName
var ClubName
var DriverSkill
var Frequency1
var Frequency2
var Frequency3
var AMBrcNum
var EmailAdr

DriverName=document.getElementById("DriverName")
ClubName=document.getElementById("ClubName")
DriverSkill=document.getElementById("DriverSkill")
Frequency1=document.getElementById("Frequency1")
Frequency2=document.getElementById("Frequency2")
Frequency3=document.getElementById("Frequency3")
AMBrcNum=document.getElementById("AMBrcNum")
EmailAdr=document.getElementById("EmailAdr")

DriverName.innerHTML=DriverNameInput+' value="(default)">'
ClubName.innerHTML=ClubNameInput+' value="(default)">'
DriverSkill.innerHTML=DriverSkillInput2
Frequency1.innerHTML=Frequency1Input+' value="(default)">'
Frequency2.innerHTML=Frequency2Input+' value="(default)">'
Frequency3.innerHTML=Frequency3Input+' value="(default)">'
AMBrcNum.innerHTML  =AMBrcNumInput+' value="(default)">'
EmailAdr.innerHTML  =EmailAdrInput+' value="(none)">'
}
/*********************************************************/
function FreqSelectionOnClick(passed)
{
var FrequencyInput
var Frequency1
var Frequency2
var Frequency3

FrequencyInput=document.getElementById("FrequencyInput")
Frequency1    =document.getElementById("Frequency1")
Frequency2    =document.getElementById("Frequency2")
Frequency3    =document.getElementById("Frequency3")

if (passed.value=='N') 
   {FrequencyInput.style.visibility='visible'
Frequency1.innerHTML=Frequency1Input+' value="">'
Frequency2.innerHTML=Frequency2Input+' value="">'
Frequency3.innerHTML=Frequency3Input+' value="">'
}
else
   {FrequencyInput.style.visibility='hidden'
Frequency1.innerHTML=Frequency1Input+' value="2.4Ghz Open">'
Frequency2.innerHTML=Frequency2Input+' value="======">'
Frequency3.innerHTML=Frequency3Input+' value="======">'
 }
}
/*********************************************************/
function SelectMeetingOnChange(temp)
{
var loop
var temp1
var temp2
var tempname
var temps2
var temps3
var tempclasses
var tempshort
var temprd
var HolderTable
var SelectClass

HolderTable=document.getElementById("HolderTable")
SelectRaceClass=document.getElementById("SelectRaceClass")
SubmitButton1=document.getElementById("SubmitButton1")
SubmitButton2=document.getElementById("SubmitButton2")
SubmitButton3=document.getElementById("SubmitButton3")
SubmitButton4=document.getElementById("SubmitButton4")
SubmitButton5=document.getElementById("SubmitButton5")
MeetingDate=document.getElementById("MeetingDate")
SelectClass=document.getElementById("SelectClass")
HolderTable.style.visibility='visible'

if (temp.selectedIndex==0) {return}

//set up raw data
temp1=0
temprd=WorkingRawData
temp2=1
//loop until we find the meeting selected
while (temp2>0) 
{
temp2=temprd.indexOf('<BR>')
if (temp2>0) 
{
temp1=temp1+1
tempname=temprd.substring(0,temp2)             //get this meeting data
temprd=temprd.substring(temp2+4,temprd.length)   //and delete this meeting from buffer
if (temp1==temp.selectedIndex)                   //if this is the selected meeting...
{
temps2=tempname                               //move all record to temp variables
temps3=tempname
tempclasses=tempname
tempshort=tempname
AllowDisplay=tempname
loop=1                                         //extract whether to allow display
while (loop<15)
{
temp2=AllowDisplay.indexOf('|')
AllowDisplay=AllowDisplay.substring(temp2+1,tempname.length)
loop=loop+1
}
temp2=AllowDisplay.indexOf('|')
loop=1                                         //extract meeting name
while (loop<3)
{
temp2=tempname.indexOf('|')
tempname=tempname.substring(temp2+1,tempname.length)
loop=loop+1
}
temp2=tempname.indexOf('|')
tempname=tempname.substring(0,temp2)
MeetingName.innerHTML='<SPAN CLASS="Highlight" STYLE="font-size:12">'+tempname+'</SPAN>'
loop=1                                         // extract meeting date
while (loop<16) 
{
temp2=temps2.indexOf('|')
temps2=temps2.substring(temp2+1,temps2.length)
loop=loop+1
}
temp2=temps2.indexOf('|')
temps3=temps2.substring(0,temp2)+' '
temps2=temps2.substring(temp2+1,temps2.length)
temp2=temps2.indexOf('|')
if (temps2.substring(0,temp2)=='1') {temps3=temps3+'Jan'}
if (temps2.substring(0,temp2)=='2') {temps3=temps3+'Feb'}
if (temps2.substring(0,temp2)=='3') {temps3=temps3+'Mar'}
if (temps2.substring(0,temp2)=='4') {temps3=temps3+'Apr'}
if (temps2.substring(0,temp2)=='5') {temps3=temps3+'May'}
if (temps2.substring(0,temp2)=='6') {temps3=temps3+'Jun'}
if (temps2.substring(0,temp2)=='7') {temps3=temps3+'Jul'}
if (temps2.substring(0,temp2)=='8') {temps3=temps3+'Aug'}
if (temps2.substring(0,temp2)=='9') {temps3=temps3+'Sep'}
if (temps2.substring(0,temp2)=='10') {temps3=temps3+'Oct'}
if (temps2.substring(0,temp2)=='11') {temps3=temps3+'Nov'}
if (temps2.substring(0,temp2)=='12') {temps3=temps3+'Dec'}

temps2=temps2.substring(temp2+1,temps2.length)
temp2=temps2.indexOf('|')
temps3=temps3+' '+temps2.substring(0,temp2)

MeetingDate.innerHTML='<SPAN CLASS="Highlight" STYLE="font-size:12px">'+temps3+'</SPAN>'

temp2=tempshort.indexOf('|')                   //extract meeting short name      
tempshort=tempshort.substring(temp2+1,tempshort.length)
temp2=tempshort.indexOf('|')
tempshort=tempshort.substring(0,temp2)

SubmitButton1.innerHTML='<INPUT type="submit" value="Submit for '+tempshort+'" STYLE="color:#FF0000;font-size:8pt">'
SubmitButton2.innerHTML='<INPUT type="HIDDEN" name="outputfile" value="DriverData-'+tempshort+'">'
SubmitButton3.innerHTML='<INPUT type="HIDDEN" name="countfile" value="DriverData-'+tempshort+'">'
SubmitButton4.innerHTML='<INPUT type="HIDDEN" name="emailfile" value="DriverData-'+tempshort+'">'
SubmitButton5.innerHTML='<INPUT type="HIDDEN" name="meeting" value="'+tempshort+'">'

loop=1                                         //extract race class names
while (loop<4) 
{
temp2=tempclasses.indexOf('|')
tempclasses=tempclasses.substring(temp2+1,tempclasses.length)
loop=loop+1
}
temps3=tempclasses
tempclasses="<SELECT NAME='raceclass'>"
temp2=temps3.indexOf('|')

loop=1
while ((temp2>0) && (loop<13)) 
{
tempclasses=tempclasses+'<OPTION value="'+
temps3.substring(0,temp2)+'">'+
temps3.substring(0,temp2)+'<\/OPTION>'
temps3=temps3.substring(temp2+1,temps3.length)
temp2=temps3.indexOf('|')  
loop=loop+1
}
tempclasses=tempclasses+'<\/SELECT>'
SelectRaceClass.innerHTML=tempclasses
}
}
}
}
var MeetingNames=['','']
/*********************************************************/
function CallAlycatOnlineEntries(ClubAbv,FormatGen,FormatFirstCol,FormatDiv,ShortcutDescription)
{
if (!FormatGen=="")           {GeneralFont=FormatGen}
if (!FormatFirstCol=="")      {FirstColumnFont=FormatFirstCol}
if (!FormatDiv=="")           {DivFont=FormatFirstCol}
if (!ShortcutDescription=="") {QuickSignup=ShortcutDescription}

var HolderDiv
var HolderHTML

HolderDiv=document.getElementById("AlycatOnlineEntries")
HolderHTML='<DIV '+DivFont+'>'+
           '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=99%>'+
           '  <TR>'+
           '    <TD NOWRAP>'+
           '      <SPAN STYLE="font-size:24px;color:#0000FF;font-weight:bold">'+
           '                  Online Entries'+
           '      </SPAN>'+
           '    </TD>'+
           '    <TD VALIGN="TOP" NOWRAP>'+
           '      <SPAN '+GeneralFont+'>'+
           '        To begin, please select a meeting...'+
           '      </SPAN>'+
           '    </TD>'+
           '    <TD ALIGN="LEFT">'+
           '      <FORM>'+
           '        <DIV ID="SelectMeeting">'+
           '        </DIV>'+
           '      </FORM>'+
           '    </TD>'+
           '    <TD ALIGN="RIGHT" VALIGN="BOTTOM" WIDTH=170>'+
           '      <SPAN '+AlycatFont+'>'+
           '        Alycat Online Entries System-v. 6.00'+
           '      </SPAN>'+
           '    </TD>'+
           '  </TR>'+
           '  <TR>'+
           '    <TD COLSPAN=4>'+
           '      <SPAN STYLE="font-size:11pt;color=#FF0000">'+
           '        This is the old browser based entry system. It has been superseded by the new Online Entry system, simply download a small program to your computer and run it (no install) - it remembers your entry details (for multiple classes), you can display up-to-the-minute entry lists, etc.'+
           '        <BR>'+
           '        Download from: <A HREF="http://www.alycat.com/DriverEntries">here</A>'+
           '      </SPAN>'+
           '    </TD>'+
           '  </TR>'+
           '</TABLE>'+
           '<HR STYLE="color:#0000BB;height:2">'+
           '<DIV ID="HolderTable"STYLE="visibility:hidden">'+
           '  <FORM METHOD="POST" ACTION="http://www.alycat.com/AlycatRC/OnlineEntries/bnbform2.cgi" STYLE="margin-top:0">'+
           '    <TABLE BORDER="0" SUMMARY="" CELLPADDING=0 CELLSPACING=0>'+
           '      <TR>'+
           '        <TD '+FirstColumnFont+' WIDTH=95>'+
           '          Event Details:'+
           '        </TD>'+
           '        <TD WIDTH=10>'+
           '        </TD>'+
           '        <TD>'+
           '          <SPAN ID="MeetingName" '+HeadingFont+'>'+
           '          </SPAN>'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <HR STYLE="color:#BB0000;height:2">'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD '+FirstColumnFont+'>'+
           '          Event Date:'+
           '        </TD>'+
           '        <TD>'+
           '        </TD>'+
           '        <TD>'+
           '          <SPAN ID="MeetingDate" '+HeadingFont+'>'+
           '          </SPAN>'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <HR STYLE="color:#BB0000;height:2">'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <TABLE BORDER=0>'+
           '            <TR>'
HolderHTML=HolderHTML+
           '              <TD WIDTH=75% VALIGN="TOP">'+
           '                <SPAN '+FirstColumnFont+'>'+
           '                  Signup'+
           '                </SPAN>'+
           '                <BR>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  Your Name:'+
           '                </SPAN>'+
           '                <SPAN ID="DriverName">'+DriverNameInput+'>'+
           '                </SPAN>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  Skill level (1-10):'+
           '                </SPAN>'+
           '                <SPAN ID="DriverSkill">'+DriverSkillInput1+
           '                </SPAN>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  Club:'+
           '                </SPAN>'+
           '                <SPAN ID="ClubName">'+ClubNameInput+'>'+
           '                </SPAN>'+
           '                <BR>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  Frequencies:'+
           '                </SPAN>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  <INPUT TYPE="radio" VALUE="O" NAME="FreqSelection" onclick="FreqSelectionOnClick(this)">2.4 Open Radio (eg. Spektrum)'+
           '                  <INPUT TYPE="radio" VALUE="N" NAME="FreqSelection"onclick="FreqSelectionOnClick(this)" checked>Enter values'+
           '                </SPAN>'+
           '                <DIV ID="FrequencyInput">'+
           '                  <SPAN ID="Frequency1">'+Frequency1Input+'>'+
           '                  </SPAN>'+
           '                  <SPAN ID="Frequency2">'+Frequency2Input+'>'+
           '                  </SPAN>'+
           '                  <SPAN ID="Frequency3">'+Frequency3Input+'>'+
           '                  </SPAN>'+
           '                  <BR>'+
           '                  <SPAN '+GeneralFont+'>'+
           '                    Please use the full frequency description, '+
           '                    e.g 40.815 not just 815 (or other notations '+
           '                    specific to your locale)'+
           '                  </SPAN>'+
           '                </DIV>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  AMBrc 7 digit no.'+
           '                </SPAN>'+
           '                <SPAN ID="AMBrcNum">'+AMBrcNumInput+'>'+
           '                </SPAN>'+
           '                <SPAN '+GeneralFont+'>'+
           '                  If you do not have an AMBrc personal, leave blank'+
           '                </SPAN>'+
           '              </TD>'+
           '            </TR>'+
           '          </TABLE>'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <HR STYLE="color:#BB0000;height:2">'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <SPAN '+FirstColumnFont+'>'+
           '            Email address'+
           '          </SPAN>'+
           '          <SPAN '+GeneralFont+'>'+
           '            To receive an acknowledgement, please enter an email address:'+
           '          </SPAN>'+
           '          <SPAN ID="EmailAdr">'+EmailAdrInput+'>'+
           '          </SPAN>'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <HR STYLE="color:#BB0000;height:2">'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD '+FirstColumnFont+'>'+
           '          Select a class'+
           '        </TD>'+
           '        <TD>'+
           '        </TD>'+
           '        <TD>'+
           '          <SPAN ID="SelectRaceClass">'+
           '          </SPAN>'+
           '          <SPAN '+GeneralFont+'>'+
           '            Note: you can only select one class - please fill out a form for each class'+
           '          </SPAN>'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=3>'+
           '          <HR STYLE="color:#BB0000;height:2">'+
           '        </TD>'+
           '      </TR>'+
           '      <TR>'+
           '        <TD COLSPAN=2>'+
           '        </TD>'+
           '        <TD COLSPAN=3>'+
           '          <SPAN '+GeneralFont+'>'+
           '            Complete the above and click'+
           '            <SPAN ID="SubmitButton1">'+
           '            </SPAN>'+
           '            <SPAN ID="SubmitButton2">'+
           '            </SPAN>'+
           '            <INPUT TYPE="HIDDEN" NAME="required" VALUE="name,raceclass">'+
           '            <INPUT TYPE="HIDDEN" NAME="data_order" VALUE="raceclass,name,freq1,freq2,freq3,submit_by,ambrc,IdNum,meeting,skill,club">'+
           '            <INPUT TYPE="HIDDEN" NAME="submit_to" VALUE="mail@alycat.com">'+
           '            <INPUT TYPE="HIDDEN" NAME="automessage" VALUE="DriverEntryMessage">'+
           '            <SPAN ID="SubmitButton3">'+
           '            </SPAN>'+
           '            <SPAN ID="SubmitButton4">'+
           '            </SPAN>'+
           '            <SPAN ID="SubmitButton5">'+
           '            </SPAN>'+
           '            <INPUT TYPE="HIDDEN" NAME="form_id" VALUE="[Alycat Online Entries System]">'+
           '            <INPUT TYPE="HIDDEN" NAME="ok_url" VALUE="http://www.alycat.com/AlycatRC/OnlineEntries/OnlineEntriesOk.html">'+
           '            <INPUT TYPE="HIDDEN" NAME="not_ok_url" VALUE="http://www.alycat.com/AlycatRC/OnlineEntries/OnlineEntriesFailed.html">'+
           '          </SPAN>'+
           '        </TD>'+
           '      </TR>'+
           '    </TABLE>'+
           '  </FORM>'+
           '</DIV>'

HolderDiv.innerHTML=HolderHTML
// If we have an abbreviation for a club passed, strip out any non-conforming records
WorkingRawData=RawData

var tempend
var templen
var temprd

templen=ClubAbv.length

if (templen>0)
  {
    tempend=1
    tempstart=0
    while (tempend>0)
      {
        temprd=WorkingRawData.substring(tempstart,WorkingRawData.length)
        tempend=temprd.indexOf('<BR>')
        if (tempend>0)
          {
            temprd=WorkingRawData.substring(tempstart,tempstart+tempend)
            // extract meeting name
            temp1=temprd.indexOf('|')
            temprd=temprd.substring(temp1+1,temprd.length)
            temp1=temprd.indexOf('|')
            temprd=temprd.substring(0,temp1)
            if (temprd.substring(0,templen)==ClubAbv)
              {
                tempstart=tempstart+tempend+4
              }
            else
              {
                WorkingRawData=WorkingRawData.substring(0,tempstart)+WorkingRawData.substring(tempstart+tempend+4,WorkingRawData.length)
              }
          }
      }
  }

var temp1
var temps1
var temps2

SelectMeeting=document.getElementById("SelectMeeting")
MeetingName=document.getElementById("MeetingName")

temps2='<SELECT size="1" onchange="SelectMeetingOnChange(this)" style="top:4;left:80" '+
       ' NAME="raceclass">'+'<OPTION value="0">Select a meeting...<\/OPTION>'

temprd=WorkingRawData
temp1=1
while (temp1>0)
  {
    temp1=temprd.indexOf('<BR>')
    if (temp1>0)
      {
        // move record across to <BR> delimiter to temp buffer
        temps1=temprd.substring(0,temp1)
        // and delete this data from overall buffer
        temprd=temprd.substring(temp1+3,temprd.length)

        // extract meeting name
        temp1=temps1.indexOf('|')
        temps1=temps1.substring(temp1+1,temps1.length)
        temp1=temps1.indexOf('|')
        temps1=temps1.substring(0,temp1)

        temps2=temps2+'<OPTION value="'+ temps1+'">'+temps1+'<\/OPTION>'
      }
  }
temps2=temps2+'<\/SELECT>'

SelectMeeting.innerHTML=temps2
}
/*********************************************************/
