// New Library
function getX( oElement ) {
  var iReturnValue = 0;
  while( oElement != null ) { iReturnValue += oElement.offsetLeft;  oElement = oElement.offsetParent; }
  return iReturnValue;
}
function getY( oElement ) {
  var iReturnValue = 0;
  while( oElement != null ) { iReturnValue += oElement.offsetTop;  oElement = oElement.offsetParent; }
  return iReturnValue;
}
function CenterDiv( aDiv ) { 
  aWidth = 800;  aHeight = 400;  ScrollLeft = 0;  ScrollTop = 0;
  if( window.pageYOffset ) {
    ScrollLeft = window.pageXOffset;  aWidth  = window.innerWidth;
    ScrollTop  = window.pageYOffset;  aHeight = window.innerHeight;
    }
  else if( document.body && document.body.clientWidth ) {
    ScrollLeft = document.body.scrollLeft;  aWidth  = document.body.clientWidth;   
    ScrollTop  = document.body.scrollTop;   aHeight = document.body.clientHeight;  
    }
  else if( document.documentElement && document.documentElement.clientWidth  ) {
    ScrollLeft = document.documentElement.scrollLeft;  aWidth  = document.documentElement.clientWidth;
    ScrollTop  = document.documentElement.scrollTop;   aHeight = document.documentElement.clientHeight;  
  } 
  aDate = new Date();  aDate.setDate( aDate.getDate() + 365 );   
  document.cookie = 'ScrollLeft=' + ScrollLeft + '; expires=' + aDate;
  document.cookie = 'ScrollTop='  + ScrollTop  + '; expires=' + aDate;
  aDiv.style.left = ScrollLeft + aWidth  / 2 - aDiv.offsetWidth  / 2 + 'px';
  aDiv.style.top  = ScrollTop  + aHeight / 2 - aDiv.offsetHeight / 2 + 'px';
}  
function ShowRequired( aElement ) {
  aDiv = document.getElementById( 'RequiredDiv' );  
  aDiv.style.left  = getX( aElement ) + 2 + 'px';
  aDiv.style.top   = getY( aElement ) + aElement.offsetHeight + 2; 
  aDiv.style.width = '160px'; 
  aDiv.style.visibility = 'visible';
  window.setTimeout( "document.getElementById('RequiredDiv').style.visibility='hidden'", 5000 );
  aElement.style.borderColor = 'red';  aElement.focus();  
} 
// Login
function SaveLogin() {
  aDate = new Date();  aDate.setDate( aDate.getDate() + 365 );   
  document.cookie = 'Cart_ID='    + document.getElementById( 'Cart_ID'    ).value + '; expires=' + aDate;
  document.cookie = 'Cart_OID='   + document.getElementById( 'Cart_OID'   ).value + '; expires=' + aDate;
  document.cookie = 'Cart_Name='  + document.getElementById( 'Cart_Name'  ).value + '; expires=' + aDate;
  document.cookie = 'Cart_eMail=' + document.getElementById( 'Cart_eMail' ).value + '; expires=' + aDate;
  document.cookie = 'Cart_PWD='   + document.getElementById( 'Cart_PWD'   ).value + '; expires=' + aDate;
  document.cookie = 'Cart_Clear=0; expires=' + aDate;
}
function ClearLogin() {
  aDate = new Date();  aDate.setDate( aDate.getDate() + 365 );   
  document.cookie = 'Cart_ID=0; expires=' + aDate;
  document.cookie = 'Cart_OID=0; expires=' + aDate;
  document.cookie = 'Cart_Name=; expires=' + aDate;
  document.cookie = 'Cart_eMail=; expires=' + aDate;
  document.cookie = 'Cart_PWD=; expires=' + aDate;
  document.cookie = 'Cart_Clear=1; expires=' + aDate;
}                
function Logout() {
  if( confirm( 'Click OK to Logout' ) ) { ClearLogin();  window.location = '/index.php?Clear=1'; }
}
function Login() {
  LoginWindow()
}
function LoginWindow() {
//  $Frame = document.getElementById( 'Tour' ); 
//       if( $Frame && $Frame.contentDocument ) { $Frame.contentDocument.location = 'WIP.htm'; }  // DOM
//  else if( $Frame && $Frame.contentWindow   ) { $Frame.contentWindow.document.location = 'WIP.htm';; }  // IE win
  aDiv   = document.getElementById( 'LoginDiv'   );  
  aFrame = document.getElementById( 'LoginFrame' ); 
  document.getElementById( 'LoginTitle' ).innerText = 'Login to your Account'; 
    aDiv.style.width = '300px';    aDiv.style.height = '300px';
  aFrame.style.width = '100%';   aFrame.style.height = '100%';
  CenterDiv( aDiv );
  aTemp = 'WIP_Login.php';
       if( aFrame.contentDocument ) { aFrame.contentDocument.location = aTemp;        }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  aDiv.style.visibility = 'visible';  
}
function CreateAccount() {
  $Div   = document.getElementById( 'LoginDiv'   );  
  $Frame = document.getElementById( 'LoginFrame' ); 
  document.getElementById( 'LoginTitle' ).innerText = 'Create an Account'; 
  CenterDiv( $Div );
  $S = 'WIP_Create.php';
       if( $Frame.contentDocument ) { $Frame.contentDocument.location = $S;        }  // DOM
  else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = $S; }  // IE win
  $Div.style.visibility = 'visible';
}
function CMS_Edit( Element ) {
  aDiv   = document.getElementById( 'EditDiv'   );  
  aFrame = document.getElementById( 'EditFrame' );  
  aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
       if( aFrame.contentDocument ) aFrame.contentDocument.body.innerHTML        = aTemp;  // DOM
  else if( aFrame.contentWindow   ) aFrame.contentWindow.document.body.innerHTML = aTemp;  // IE win
  CenterDiv( aDiv );
       if( aFrame.contentDocument ) aFrame.contentDocument.location        = 'Blank.htm';  // DOM
  else if( aFrame.contentWindow   ) aFrame.contentWindow.document.location = 'Blank.htm';  // IE win
  aDiv.style.visibility = 'visible';
  aTemp = 'WIP_Edit.php?ID=' + Element.id + '&FileName=CMS_index.txt';  
       if( aFrame.contentDocument ) aFrame.contentDocument.location        = aTemp;  // DOM
  else if( aFrame.contentWindow   ) aFrame.contentWindow.document.location = aTemp;  // IE win
} 
// Resources
function UpdResourceKey( Event, aID ) {
  if( window.event ) { Event = window.event; }   // IE
  if( Event.which ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
               else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { UpdResource( aID ); }
}
function UpdResource( aID ) {
//aCode   = document.getElementById( 'Code_'  + aID ).value;  
  aName  = document.getElementById( 'Name_'  + aID ).value;  
  aPrice = document.getElementById( 'Price_' + aID ).value;  
  aDiv   = document.getElementById( 'UpdateDiv'   );  
  aFrame = document.getElementById( 'UpdateFrame' );  
  aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
       if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
  CenterDiv( aDiv );
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
  aDiv.style.visibility = 'visible';
  aTemp = 'WIP_UpdResource.php?AID=' + aID + '&Name=' + escape( aName ) + '&Price=' + aPrice;  
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
}
// Contacts
function UpdContactKey( Event, aID ) {
  if( window.event ) { Event = window.event; }   // IE
  if( Event.which ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
               else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { UpdContact( aID ); }
}
function UpdContact( CID ) {
  aType = document.getElementById( 'Type'        );  if( aType )  aType = aType.value;  else aType = '';
  aPWD  = document.getElementById( 'PWD_'  + CID );
  if( aPWD && aPWD.value != aPWD.defaultValue ) {
    aPWD2 = document.getElementById( 'PWD2_' + CID ).value;  
    if( aPWD.value != aPWD2 ) {
      aElement = document.getElementById( 'PWD2_' + CID );  
      aDiv     = document.getElementById( 'PasswordDiv' );  
      aDiv.style.left  = getX( aElement ) + 'px';
      aDiv.style.top   = getY( aElement ) + aElement.offsetHeight + 2; 
      aDiv.style.width = '90px'; 
      aDiv.style.visibility = 'visible';
      window.setTimeout( "document.getElementById('PasswordDiv').style.visibility='hidden'", 5000 );
      aElement.style.borderColor = 'red';  aElement.focus();  return false;
  } }    
  aExp = document.getElementById( 'Expiry_'  + CID );
  if( aExp && aExp.value != aExp.defaultValue )  aExpiry = aExp.value;  else aExpiry = '';
  if( aExp )  PID = aExp.name.split( '_' )[ 1 ];  // name="Expiry_PackageID
  if( aExpiry == '' || aExp.defaultValue != '' || 
      confirm( 'Add a new Membership ending on ' + aExpiry ) ) {
    aName   = document.getElementById( 'Name_'  + CID );  
    eMail   = document.getElementById( 'eMail_' + CID );  
    aPhone  = document.getElementById( 'Phone_' + CID );  
    aActive = document.getElementById( 'Active_' + CID );  
    if( aActive && ! aActive.checked ) { eMail = eMail.value;  aPhone = aPhone.value;  aName = aName.value; }  
    else {
      if(  eMail.value !== '' )   eMail =  eMail.value;  else { ShowRequired( eMail  );  return false; }  
      if( aPhone.value !== '' )  aPhone = aPhone.value;  else { ShowRequired( aPhone );  return false; }  
      if(  aName.value !== '' )   aName =  aName.value;  else { ShowRequired( aName  );  return false; } 
    }
    aFirst = document.getElementById( 'First_' + CID );  
    if( aFirst ) {
      if( aFirst.value == '' )  { ShowRequired( aFirst ); return false; } 
      if( aFirst.value != aName ) { aLast = aName;  aName = aFirst.value + ' ' + aLast; } 
    }  
    aCard    = document.getElementById( 'Card_'    + CID );  
    aBlast   = document.getElementById( 'Blast_'   + CID );  
    aMobile  = document.getElementById( 'Mobile_'  + CID );  
    if( aMobile ) {
      aAddress = document.getElementById( 'Address_' + CID ).value;  
      aCity    = document.getElementById( 'City_'    + CID ).value;  
      aState   = document.getElementById( 'State_'   + CID ).value;  
      aPostal  = document.getElementById( 'Postal_'  + CID ).value;  
      aDOB     = document.getElementById( 'DOB_'     + CID );  
      if( aDOB.value !== '' )  aDOB = aDOB.value;  else { ShowRequired( aDOB );  return false; }  
      aStudent = document.getElementById( 'Student_' + CID ).value;  
    }
    aAdmin  = document.getElementById( 'Admin_'  + CID );
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_UpdContact.php?CID=' + CID + '&Name='  + escape( aName  ) + '&eMail=' + escape( eMail ) + 
                                              '&Phone=' + escape( aPhone ) + '&Type='  + escape( aType );
    if( aFirst && aFirst.value != aName ) 
                   aTemp = aTemp + '&First='   + escape( aFirst.value ) + '&Last=' + escape( aLast ); 
    if( aCard   )  aTemp = aTemp + '&Card='    + escape( aCard.value   );
    if( aBlast  )  aTemp = aTemp + '&Blast='   + escape( aBlast.value  );
    if( aMobile )  aTemp = aTemp + '&Mobile='  + escape( aMobile.value ) + '&Address=' + escape( aAddress ) + 
                                   '&City='    + escape( aCity         ) + '&State='   + escape( aState   ) + 
                                   '&Postal='  + escape( aPostal       ) + '&DOB='     + escape( aDOB     ) +
                                   '&Student=' + escape( aStudent      );
    if( aAdmin  ) {
      aTemp = aTemp + '&Admin=';  if( aAdmin.checked ) aTemp = aTemp + escape( aAdmin.value );
    }
    if( aActive ) {
      aTemp = aTemp + '&Active=';  if( aActive.checked ) aTemp = aTemp + '1'; else  aTemp = aTemp + '0';
    }
    if( aExp && aExp.value != aExp.defaultValue ) 
      aTemp = aTemp + '&Expiry='  + escape( aExpiry ) + '&PID=' + PID;
    if( aPWD && aPWD.value != aPWD.defaultValue ) {
      aTemp = aTemp + '&PWD=' + escape( aPWD.value ) + '&PWD2=' + escape( aPWD2 ); 
      if( document.getElementById( 'Cart_ID' ).value == CID ) {
        aDate = new Date();  aDate.setDate( aDate.getDate() + 365 );   
        document.cookie = 'Cart_PWD=' + aPWD.value + '; expires=' + aDate;
      }
    }  // alert( aTemp );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} } 
function DelContact( CID, aName ) {
  if( confirm( 'Delete Contact ' + aName ) ) {  
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelContact.php?CID=' + CID; 
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function FindContactKey( Event, EID ) {
  if( window.event ) Event   = window.event;  // IE
  if( Event.which  ) KeyCode = Event.which;   // Netscape/Firefox/Opera
                else KeyCode = Event.keyCode; 
  if( KeyCode == 13 ) FindContact( EID );
}
function FindContact( EID ) {
  aInput = document.getElementById( 'Find' );
  document.location = 'admin.php?EID=' + EID + '&View=Clients&Find=' + escape( aInput.value );
}
// News
function UpdNewsKey( Event, NID ) {
  if( window.event ) Event   = window.event;   // IE
  if( Event.which  ) KeyCode = Event.which;    // Netscape/Firefox/Opera
                else KeyCode = Event.keyCode; 
  if( KeyCode == 13 ) UpdNews( NID ); 
}
function UpdNews( NID ) {
  aDiv   = document.getElementById( 'UpdateDiv'   );  
  aFrame = document.getElementById( 'UpdateFrame' );  
  aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
       if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
  CenterDiv( aDiv );
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
  aDiv.style.visibility = 'visible';
  aDate = document.getElementById( 'Date_' + NID ).value;  
  aName = document.getElementById( 'Name_' + NID ).value;  
//aNote = document.getElementById( 'Note_' + NID ).value;  
  aTemp = 'WIP_UpdNotes.php?NID=' + NID + '&Date=' + escape( aDate ) + '&Name=' + escape( aName ); // + '&Note=' + escape( aNote );  
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
}
function DelNews( NID, aName ) {
  if( confirm( 'Delete News for ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_UpdNotes.php?NID=' + NID; 
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
// Packages
function UpdPackageKey( Event, aID ) {
  if( window.event ) { Event = window.event; }   // IE
  if( Event.which ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
               else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { UpdPackage( aID ); }
}
function UpdPackage( PID ) {  
  aExp = document.getElementById( 'Expiry_'  + PID );
  if( aExp && aExp.value != aExp.defaultValue )  aExpiry = aExp.value;  else aExpiry = '';
  if( aExp )  PID = aExp.name.split( '_' )[ 1 ];  // name="Expiry_PackageID
  aDiv   = document.getElementById( 'UpdateDiv'   );  
  aFrame = document.getElementById( 'UpdateFrame' );  
  aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
       if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
  CenterDiv( aDiv );
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
  aDiv.style.visibility = 'visible';
  aTemp = 'WIP_UpdPackage.php?PID=' + PID + '&Expiry=' + escape( aExpiry );
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} 
function onAddPkg( aSelect ) {
  aCID  = aSelect.id.substr( 4 );
  aPkg  = aSelect.options[ aSelect.selectedIndex ].value;
  aName = document.getElementById( 'Name_' + aCID ).value;
  if( aPkg != '' && confirm( 'Add Package ' + aPkg + ' to ' + aName + '?' ) ) {
    $Div   = document.getElementById( 'UpdateDiv'   );  
    $Frame = document.getElementById( 'UpdateFrame' );  
    $S = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( $Frame.contentDocument ) { $Frame.contentDocument.body.innerHTML = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.body.innerHTML = $S; }  // IE win
    CenterDiv( $Div );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    $Div.style.visibility = 'visible';
    $S = 'WIP_AddRow.php?Code=' + aPkg + '&CID=' + aCID; 
         if( $Frame.contentDocument ) { $Frame.contentDocument.location = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = $S; }  // IE win
  }
}
function DelPackage( LID, aName ) {  
  if( confirm( 'Delete manually entered Package ' + aName ) ) {
    $Div   = document.getElementById( 'UpdateDiv'   );  
    $Frame = document.getElementById( 'UpdateFrame' );  
    $S = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( $Frame.contentDocument ) { $Frame.contentDocument.body.innerHTML = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.body.innerHTML = $S; }  // IE win
    CenterDiv( $Div );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    $Div.style.visibility = 'visible';
    $S = 'WIP_DelRow.php?LID=' + LID;  // alert( $S );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = $S; }  // IE win
} }
// Orders
function Buy( aCheckBox ) {  
  aPending = document.getElementById( 'PayPending' );  
  if( aPending && aPending.value == '1' ) {
    alert( 'PayPal payment in process, continue with Pay Now or Pay Later, or Cancel this Order and start a New one' );
    document.location.reload();
  } else {
    $Div     = document.getElementById( 'UpdateDiv'   );  
    $Frame   = document.getElementById( 'UpdateFrame' );  
    $S = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( $Frame.contentDocument ) { $Frame.contentDocument.body.innerHTML = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.body.innerHTML = $S; }  // IE win
    CenterDiv( $Div );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    $Div.style.visibility = 'visible';
    SaveLogin();
    if( aCheckBox.checked ) $S = 'WIP_AddRow.php?Code=' + aCheckBox.value; 
                       else $S = 'WIP_DelRow.php?Code=' + aCheckBox.value;  // alert( $S );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = $S; }  // IE win
} }
function BuyClass( AID, EID, aEvent ) {  
  if( confirm( 'Buy a Package for ' + aEvent + '?  You will be taken to our eStore' ) ) {
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    SaveLogin();  aTemp = aEvent.toLowerCase();
         if( aTemp.indexOf( 'trx xpress' ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'trx'        ) >= 0 ) aPKG = 'A6';
    else if( aTemp.indexOf( 'pilates'    ) >= 0 ) aPKG = 'A6';
    else if( aTemp.indexOf( 'reformer'   ) >= 0 ) aPKG = 'B6';
    else if( aTemp.indexOf( 'prenatal'   ) >= 0 ) aPKG = 'B6P';
    else if( aTemp.indexOf( 'blast'      ) >= 0 ) aPKG = 'BB6';
    else if( aTemp.indexOf( 'zumba'      ) >= 0 ) aPKG = 'C6';
    else if( aTemp.indexOf( 'contemp'    ) >= 0 ) aPKG = 'C6';
    else if( aTemp.indexOf( 'baladi'     ) >= 0 ) aPKG = 'C6';
    else if( aTemp.indexOf( 'belly'      ) >= 0 ) aPKG = 'C6';
    else if( aTemp.indexOf( 'expressive' ) >= 0 ) aPKG = 'C6';
    else if( aTemp.indexOf( 'ritmos'     ) >= 0 ) aPKG = 'C6';
    else if( aTemp.indexOf( 'toning'     ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'tone'       ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'chillates'  ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'hoop'       ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'condition'  ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'resist'     ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'stretch'    ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'monster'    ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'kickboxing' ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'sword'      ) >= 0 ) aPKG = 'D6';
    else if( aTemp.indexOf( 'circuit'    ) >= 0 ) aPKG = 'D6';  else aPKG = '';
    aTemp = 'WIP_AddRow.php?Code=' + aPKG + '&AID=' + AID + // '&Exp=' + aExpiry + 
                         '&Event=' + escape( aEvent ) + '&EID=' + EID;  
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function Renew( AID, EID, aEvent ) {  
  if( confirm( 'Renew your Annual Web Management Fee for ' + aEvent + '?  You will be taken to our eStore' ) ) {
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    SaveLogin();  aTemp = aEvent.toLowerCase();
    aPKG = 'MF';
    aTemp = 'WIP_AddRow.php?Code=' + aPKG + '&AID=' + AID + // '&Exp=' + aExpiry + 
                         '&Event=' + escape( aEvent ) + '&EID=' + EID;  
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function AddOrderKey( Event ) {
  if( window.event ) { Event   = window.event;  } // IE
  if( Event.which  ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
                else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { AddOrder(); }
}
function AddOrder() {
  aName = document.getElementById( 'Name_0' ).value;
  if( aName.toLowerCase().indexOf( 'new client name' ) != - 1 ) {
    aSelect = document.getElementById( 'Client_0' );
    aName = aSelect.options[ aSelect.selectedIndex ].value;
  }  
  if( aName.toLowerCase().indexOf( 'selected client' ) != - 1 )
    alert( 'Please enter a New Client Name or select an existing Client from the list' );
  else if( confirm( 'Add Order for ' + aName ) ) {
    aDOB = document.getElementById( 'Date_0' ).value;  if( aDOB == 'yyyy-mm-dd' ) aDOB = '';
    aSID = document.getElementById( 'SID_0' ).value;   if( aSID == 'Student ID' ) aSID = '';
    $Div   = document.getElementById( 'UpdateDiv'   );  
    $Frame = document.getElementById( 'UpdateFrame' );  
    $S = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( $Frame.contentDocument ) { $Frame.contentDocument.body.innerHTML = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.body.innerHTML = $S; }  // IE win
    CenterDiv( $Div );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    $Div.style.visibility = 'visible';
    $S = 'WIP_AddOrder.php?Name=' + aName + '&DOB=' + aDOB + '&SID=' + aSID + '&PKGS=';  
    aCheck = document.getElementById( 'MF'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'TW'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'RB1'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'FD1'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'PR1'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'PM1'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'SPR1' );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'SPM1' );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'A6'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'A12'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'B6'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'B6P'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'B12'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'BB6'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'BB12' );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'C6'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'C15'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'D6'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'D12'  );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'DM'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
    aCheck = document.getElementById( 'DY'   );  if( aCheck.checked == true ) $S = $S + aCheck.id + ',';
//    alert( $S );
         if( $Frame.contentDocument ) { $Frame.contentDocument.location = $S;        }  // DOM
    else if( $Frame.contentWindow   ) { $Frame.contentWindow.document.location = $S; }  // IE win
} }
function UpdOrderKey( Event, OID ) {
  if( window.event ) { Event = window.event; }   // IE
  if( Event.which ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
               else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { UpdOrder( OID ); }
}
function UpdOrder( OID ) {
  aName      = document.getElementById( 'Name'      ).value;  
  aPhone     = document.getElementById( 'Phone'     ).value;  
  eMail      = document.getElementById( 'eMail'     ).value;  
  aAddress   = document.getElementById( 'Address'   ).value;  
  aCity      = document.getElementById( 'City'      ).value;  
  aState     = document.getElementById( 'State'     ).value;  
  aPostal    = document.getElementById( 'Postal'    ).value;  
  aReference = document.getElementById( 'Reference' ).value;  
  aDiv       = document.getElementById( 'UpdateDiv'   );  
  aFrame     = document.getElementById( 'UpdateFrame' );  
  aTemp = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
       if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
  CenterDiv( aDiv );
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
  aDiv.style.visibility = 'visible';
  aTemp = 'WIP_UpdOrder.php?OID=' + OID + '&Name='   + escape( aName   ) + '&Phone='     + escape( aPhone     ) +
                                          '&eMail='  + escape( eMail   ) + '&Address='   + escape( aAddress   ) +    
                                          '&City='   + escape( aCity   ) + '&State='     + escape( aState     ) +    
                                          '&Postal=' + escape( aPostal ) + '&Reference=' + escape( aReference );    
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
}
function DelAllOrders( CID ) {
  if( confirm( 'Remove All Items - You can add later' ) ) {
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    SaveLogin();
    aTemp = 'WIP_DelRow.php?CID=' + CID;  // alert( aTemp );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function DelOrder( OID, aName ) {
  if( confirm( 'Delete Order for ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelOrder.php?OID=' + OID; 
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function DelOrderItem( LID, aName ) {
  if( confirm( 'Delete Order Item ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelOrder.php?LID=' + LID;
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function LockOrder( OID, aName ) {
  if( confirm( 'Invoice Order for ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelOrder.php?LockID=' + OID;
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function VoidInvoice( OID, aName ) {
  if( confirm( 'Void Invoice for ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelOrder.php?VoidID=' + OID;
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function GoPayPal( OID, Amount ) {
  if( confirm( 'You will be taken to PayPal for payment - Continue?' ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_UpdOrder.php?OID=' + OID + '&PayPal=' + Amount ;
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function BillLater( OID ) {
  alert( 'You can Pay for your Order when you visit us and will be granted access then' ); 
}
// Classes
function SetClassesLeftKey( Event, CID, PKG ) {
  if( window.event ) { Event = window.event; }   // IE
  if( Event.which ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
               else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { SetClassesLeft( CID, PKG ); }
}
function SetClassesLeft( CID, PKG ) {
  aInput  = document.getElementById( PKG + '_' + CID ); 
  if( aInput.defaultValue <= Math.abs( aInput.value ) ) { 
    alert( 'You can only decrease Classes Left here - ' + 
           'Click on the Package or the Participant page to delete some history to increase them' );
    aInput.value = aInput.defaultValue;  aInput.focus();
    }
  else if( confirm( 'Reduce Classes Left from ' + aInput.defaultValue + ' to ' + aInput.value ) ) {  
    aDiv    = document.getElementById( 'UpdateDiv'     );  
    aFrame  = document.getElementById( 'UpdateFrame'   );  
    aTemp   = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_AddActivity.php?AID=Null&CID=' + CID + '&PKG=' + PKG + 
                               '&Repeat=' + ( aInput.defaultValue - Math.abs( aInput.value ) ) + 
                               "&aEvent=Class from previous system";   
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
LastScan = new Date();  
function ScanClassKey( Event, aInput ) {
  if( window.event ) Event   = window.event;  // IE
  if( Event.which  ) KeyCode = Event.which;   // Netscape/Firefox/Opera
                else KeyCode = Event.keyCode; 
//       if( KeyCode == 13 ) ScanClass( aInput.value, aInput );
//  else 
  aDate = new Date();  aDate.setTime( aDate.getTime() - 2000 );
  if( LastScan < aDate ) aInput.value = '';
  if( aInput.value.length == 11 ) ScanClass( aInput.value + String.fromCharCode( KeyCode ), aInput );
  LastScan = new Date();
}
function ScanClass( aCardID, aInput ) {
  aID    = document.getElementById( 'Event_ID' );  //alert( aID );
  aEvent = document.getElementById( 'Event'    );  //alert( aID );
  if( ! aID ) { aInput.value = ''; alert( 'Class is full' ); }
  else {
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_ScanClass.php?CardID=' + aCardID + '&AID=' + aID.value + '&Event=' + escape( aEvent.value ); // alert( aTemp );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function JoinClass( AID, CID, PKG, aEvent ) {
  if( confirm( 'Join the ' + aEvent + ' class? - Remove later by clicking on the Red "-" Minus Icon' ) ) {
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_AddActivity.php?AID=' + AID + '&CID=' + CID + '&PKG=' + PKG + '&aEvent=' + escape( aEvent );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function LeaveClass( AID, CID, aEvent ) {
  if( confirm( 'Leave the ' + aEvent + ' class? - Join later by clicking on the Green "+" Plus Icon' ) ) {
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelActivity.php?AID=' + AID + '&CID=' + CID;
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }
function CancelActivity( AID ) {
  aEvent = document.getElementById( 'Name_' + AID );
  if( aEvent.tagName == 'INPUT' )  aName = aEvent.value;  else aName = aEvent.innerText;
  if( confirm( 'Cancel Class ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_UpdActivity.php?AID=' + AID + '&Note=' + escape( 'TO_CANCEL' ); // alert( aTemp );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function DelActivity( AID ) {
  aEvent = document.getElementById( 'Name_' + AID );
  if( aEvent.tagName == 'INPUT' )  aName = aEvent.value;  else aName = aEvent.innerText;
  if( confirm( 'Delete Activity for ' + aName ) ) { 
    aDiv   = document.getElementById( 'UpdateDiv'   );  
    aFrame = document.getElementById( 'UpdateFrame' );  
    aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
         if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
    CenterDiv( aDiv );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
    aDiv.style.visibility = 'visible';
    aTemp = 'WIP_DelActivity.php?AID=' + AID + '&Event=' + escape( aName ); // alert( aTemp );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
  }
}
function UpdActivityKey( Event, aID ) {
  if( window.event ) { Event = window.event; }   // IE
  if( Event.which ) { KeyCode = Event.which;   } // Netscape/Firefox/Opera
               else { KeyCode = Event.keyCode; } 
  if( KeyCode == 13 ) { UpdActivity( aID ); }
}
function UpdActivity( aID ) {
  aTeacher = document.getElementById( 'Contact_Name_' + aID );
  aStart   = document.getElementById( 'Date_Start_'   + aID );  
  aMinutes = document.getElementById( 'Minutes_'      + aID );  
  aEvent   = document.getElementById( 'Name_'         + aID );  
  aMin     = document.getElementById( 'Min_'          + aID );  
  aMax     = document.getElementById( 'Max_'          + aID );  
  aRepeat  = document.getElementById( 'Repeat_'       + aID );
  aDiv     = document.getElementById( 'UpdateDiv'   );  
  aFrame   = document.getElementById( 'UpdateFrame' );  
  aTemp  = '<div style="font: 12pt arial bold; text-align: center;">Please Wait...</div>';
       if( aFrame.contentDocument ) { aFrame.contentDocument.body.innerHTML        = aTemp; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.body.innerHTML = aTemp; }  // IE win
  CenterDiv( aDiv );
       if( aFrame.contentDocument ) { aFrame.contentDocument.location        = 'Processing.htm'; }  // DOM
  else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = 'Processing.htm'; }  // IE win
  if( aRepeat && aRepeat.value < aRepeat.defaultValue ) { 
    alert( 'Please delete repeating classes manually' );  document.location = document.location;
    }
  else {
    aDiv.style.visibility = 'visible';
         if( aRepeat && aRepeat.value > aRepeat.defaultValue ) aID = 0; 
    else if( aRepeat ) aRepeat.value = 0;
    aTemp = 'WIP_UpdActivity.php?AID=' + aID;   
    if( aStart   )  aTemp = aTemp + '&Start='   + escape( aStart.value   );  
    if( aMinutes )  aTemp = aTemp + '&Minutes=' + escape( aMinutes.value ); 
    if( aEvent   )  aTemp = aTemp + '&Event='   + escape( aEvent.value   );  
    if( aMin     )  aTemp = aTemp + '&Min='     + escape( aMin.value     );  
    if( aMax     )  aTemp = aTemp + '&Max='     + escape( aMax.value     );  
    if( aRepeat  )  aTemp = aTemp + '&Repeat='  + escape( aRepeat.value  );  
    if( aTeacher )  aTemp = aTemp + '&Teacher=' + escape( aTeacher.options[ aTeacher.selectedIndex ].value );  
    if( aEvent   ) {
      if( aEvent.value == 'Add new Class and press Enter' ) aTemp = aTemp + '&Event=' + escape( 'New Class'  );  
                                                       else aTemp = aTemp + '&Event=' + escape( aEvent.value );  
    } //  alert( aTemp );
         if( aFrame.contentDocument ) { aFrame.contentDocument.location        = aTemp; }  // DOM
    else if( aFrame.contentWindow   ) { aFrame.contentWindow.document.location = aTemp; }  // IE win
} }

