// AfterNET WebChat

// Sample HTML code:
//   <!-- AfterNET WebChat: Start -->
//   <script src="http://www.afternet.org/chat/afterjavachat.js" type="text/javascript">
//   </script>
//   <script type="text/javascript">
//   after_nickname = 'Traveler';
//   after_channel  = '#afternet';
//   after_width    = '800';
//   after_height   = '600';
//   after_newwin   = 'true';
//   after_webchat();
//   </script>
//   <!-- AfterNET WebChat: End -->

// Login form settings
var after_nickname    = '';                                              // nickname
var after_channel     = '';                                              // channel
var after_username    = '';                                              // login-on-connect username
var after_password    = '';                                              // login-on-connect password
var after_showchan    = 'true';                                          // show channel box in login form
var after_loccolor    = 'blue';                                          // login-on-connect link color
var after_loctext     = 'underline';                                     // login-on connect link style

// Java applet settings
var after_newwin      = 'false';                                         // open applet in new window
var after_width       = '800';                                           // applet width
var after_height      = '600';                                           // applet height
var after_name        = 'AfterNET WebChat';                              // full name
var after_userid      = 'webchat';                                       // userid in userid@host
var after_quitmessage = 'Goodbye!';                                      // quit message
var after_fontface    = 'Arial';                                         // chat font typeface
var after_fontsize    = '12';                                            // chat font size
var after_useinfo     = 'false';                                         // status or infos window
var after_smileys     = 'false';                                         // use graphical smileys
var after_bgimage     = 'false';                                         // use background image
var after_bgimageurl  = 'pjirc-logo6.gif';                               // background url (pjirc-logo6.gif)
var after_helppage    = 'http://www.afternet.org/help';                  // help button url

// Java applet colors
var after_color11     = 'ff0000';                                        // operator
var after_color12     = 'ff6600';                                        // halfoperator
var after_color10     = '009900';                                        // voice
var after_color0      = '';                                              // black
var after_color1      = '';                                              // white
var after_color2      = '';                                              // dark gray
var after_color3      = '';                                              // gray
var after_color4      = '';                                              // light gray
var after_color5      = '';                                              // foreground
var after_color6      = '';                                              // background
var after_color7      = '';                                              // selection
var after_color8      = '';                                              // event
var after_color9      = '';                                              // close

// AfterNET specific settings
function after_control()
{
  // Status and advertisements
  after_loading       = 'Please wait while the applet loads...';
  after_promo1        = '';
  after_promo2        = '';
  after_promowintitle = after_name;
  // Server listing
  // Update the array count below too!
  after_servers[0]    = 'java.afternet.org';
}
var after_servers     = new Array(1)
var after_loading     = '';
var after_promo1      = '';
var after_promo2      = '';
var after_promowintitle = '';

// Draw the webchat login form
function after_webchat()
{
  after_control();
  document.write('<div id="afterwebchat" style="width: 100%; text-align: center;">');
  document.write('<div id="afterchatapplet" style="width: 100%; text-align: center; display: none;">');
  document.write('</div>');
  document.write('<div id="afterchatloc" style="width: 100%; text-align: center; display: none;">');
  document.write('<table border="0" align="center">');
  if (after_showchan == 'true')
  {
    document.write('<tr><td style="text-align: left;">Nickname:</td><td style="text-align: left;"><input size="25" type="text" id="afternickname" name="afternickname" value="'+after_nickname+'"></td></tr>');
    document.write('<tr><td style="text-align: left;">Channel:</td><td style="text-align: left;"><input size="25" type="text" id="afterchannel" name="afterchannel" value="'+after_channel+'"></td></tr>');
  }
  else {
    document.write('<tr><td style="text-align: left;">Nickname:</td><td style="text-align: left;"><input size="25" type="text" id="afternickname" name="afternickname" value="'+after_nickname+'"><input type="hidden" id="afterchannel" name="afterchannel" value="'+after_channel+'"></td></tr>');
  }
  document.write('<tr><td colspan=2><span style="font-size: small;">Log in using your AfterNET account (<a style="font-size: small;" target="_blank" href="http://www.afternet.org/help/connecting/login-on-connect">?</a>):</span></td></tr>');
  document.write('<tr><td style="text-align: left;">Username:</td><td style="text-align: left;"><input size="25" type="text" id="afterusername" name="afterusername"></td></tr>');
  document.write('<tr><td style="text-align: left;">Password:</td><td style="text-align: left;"><input size="25" type="password" id="afterpassword" name="afterpassword"></td></tr>');
  document.write('<tr><td style="text-align: left;"> </td><td style="text-align: left;"><button onclick="after_gatherloc();" name="OK" text="text">Continue</button></td></tr>');
  document.write('</table>');
  document.write('</div>');
  document.write('<div id="afterchatprep" style="width: 100%; text-align: center;">');
  document.write('<table border="0" align="center">');
  if (after_showchan == 'true')
  {
    document.write('<tr><td style="text-align: left;">Nickname:</td><td style="text-align: left;"><input size="25" type="text" id="afternickname2" name="afternickname2" value="'+after_nickname+'"></td></tr>');
    document.write('<tr><td style="text-align: left;">Channel:</td><td style="text-align: left;"><input size="25" type="text" id="afterchannel2" name="afterchannel2" value="'+after_channel+'"></td></tr>');
  }
  else {
    document.write('<tr><td style="text-align: left;">Nickname:</td><td style="text-align: left;"><input size="25" type="text" id="afternickname2" name="afternickname2" value="'+after_nickname+'"><input type="hidden" id="afterchannel2" name="afterchannel2" value="'+after_channel+'"></td></tr>');
  }
  document.write('<tr><td style="text-align: left;" colspan="2"><span style="font-size: small; color: '+after_loccolor+'; text-decoration: '+after_loctext+'; cursor: pointer;" onclick=after_addloc()>Log in using your AfterNET account</span><span style="font-size: small;"> (<a target="_blank" href="http://www.afternet.org/help/connecting/login-on-connect">?</a>)</span></td></tr>');
  document.write('<tr><td style="text-align: left;"> </td><td style="text-align: left;"><button onclick="after_gatherbasic();" name="OK" text="text">Continue</button></td></tr>');
  document.write('</table>');
  document.write('</div>');
  document.write('<div id="afterchatstatus" style="width: 100%; text-align: center; display: none;">');
  document.write(after_loading);
  document.write('</div>');
  document.write('<div id="afterchatpromo" style="width: 100%; text-align: center; display: none;">');
  document.write(after_promo1+after_promo2);
  document.write('</div>');
  document.write('</div>');
}

// Switch from the basic to the login-on-connect form
function after_addloc()
{
  chdiv = document.getElementById('afterchatprep');
  chdiv.style.display = 'none';
  locdiv = document.getElementById('afterchatloc');
  locdiv.style.display = 'block';
}

// Gather variables from the login-on-connect form
function after_gatherloc()
{
  nickbox=document.getElementById('afternickname');
  after_nickname = nickbox.value;
  chanbox=document.getElementById('afterchannel');
  after_channel = chanbox.value;
  userbox=document.getElementById('afterusername');
  after_username = userbox.value;
  passbox=document.getElementById('afterpassword');
  after_password = passbox.value;
  after_drawapplet();
}

// Gather variables from the basic form
function after_gatherbasic()
{
  nickbox=document.getElementById('afternickname2');
  after_nickname = nickbox.value;
  chanbox=document.getElementById('afterchannel2');
  after_channel = chanbox.value;
  after_drawapplet();
}

// Draw the java webchat applet
function after_drawapplet()
{
  if (after_newwin != 'true')
  {
    after_control();
    var buf = '';
    var randy = '';
    statdiv = document.getElementById('afterchatstatus');
    statdiv.style.display = 'block';
    setTimeout("statdiv.style.display = 'none';",10000);
    promodiv = document.getElementById('afterchatpromo');
    setTimeout("promodiv.style.display = 'block';",10000);
    randy = Math.floor(Math.random()*after_servers.length); 
    buf += '<applet code="IRCApplet.class" archive="irc-unsigned.jar,pixx.jar" codebase="http://'+after_servers[randy]+'/afternet/pjirc/" width="'+after_width+'" height="'+after_height+'">';
    buf += '<param name="host" value="'+after_servers[randy]+'">';
    buf += '<param name="password" value="authserv '+after_username+' :'+after_password+'">';
    buf += '<param name="autoconnection" value="true">';
    buf += '<param name="nick" value="'+after_nickname+'">';
    buf += '<param name="alternatenick" value="'+after_nickname+'???">';
    buf += '<param name="userid" value="'+after_userid+'">';
    buf += '<param name="name" value="'+after_name+'">';
    buf += '<param name="quitmessage" value="'+after_quitmessage+' ('+document.domain+')">';
    buf += '<param name="asl" value="false">';
    buf += '<param name="useinfo" value="'+after_useinfo+'">';
    buf += '<param name="highlight" value="true">';
    buf += '<param name="command1" value="/join '+after_channel+'">';
    buf += '<param name="style:floatingasl" value="true">';
    buf += '<param name="style:sourcefontrule1" value="all all '+after_fontface+' '+after_fontsize+'">';
    buf += '<param name="style:backgroundimage" value="'+after_bgimage+'">';
    buf += '<param name="style:backgroundimage1" value="all all 0 '+after_bgimageurl+'">';
    buf += '<param name="gui" value="pixx">';
    buf += '<param name="pixx:helppage" value="'+after_helppage+'">';
    buf += '<param name="pixx:showabout" value="false">';
    buf += '<param name="pixx:nickfield" value="false">';
    buf += '<param name="pixx:timestamp" value="true">';
    buf += '<param name="pixx:highlight" value="true">';
    buf += '<param name="pixx:highlightnick" value="true">';
    buf += '<param name="pixx:nickfield" value="true">';
    buf += '<param name="pixx:styleselector" value="true">';
    buf += '<param name="pixx:setfontonstyle" value="true">';
    buf += '<param name="pixx:color0" value="'+after_color0+'">';
    buf += '<param name="pixx:color1" value="'+after_color1+'">';
    buf += '<param name="pixx:color2" value="'+after_color2+'">';
    buf += '<param name="pixx:color3" value="'+after_color3+'">';
    buf += '<param name="pixx:color4" value="'+after_color4+'">';
    buf += '<param name="pixx:color5" value="'+after_color5+'">';
    buf += '<param name="pixx:color6" value="'+after_color6+'">';
    buf += '<param name="pixx:color7" value="'+after_color7+'">';
    buf += '<param name="pixx:color8" value="'+after_color8+'">';
    buf += '<param name="pixx:color9" value="'+after_color9+'">';
    buf += '<param name="pixx:color10" value="'+after_color10+'">';
    buf += '<param name="pixx:color11" value="'+after_color11+'">';
    buf += '<param name="pixx:color12" value="'+after_color12+'">';
    if (after_smileys == 'true')
    {
      buf += '<param name="style:bitmapsmileys" value="true">';
      buf += '<param name="style:smiley1" value=":) img/sourire.gif">';
      buf += '<param name="style:smiley2" value=":-) img/sourire.gif">';
      buf += '<param name="style:smiley3" value=":-D img/content.gif">';
      buf += '<param name="style:smiley4" value=":d img/content.gif">';
      buf += '<param name="style:smiley5" value=":-O img/OH-2.gif">';
      buf += '<param name="style:smiley6" value=":o img/OH-1.gif">';
      buf += '<param name="style:smiley7" value=":-P img/langue.gif">';
      buf += '<param name="style:smiley8" value=":p img/langue.gif">';
      buf += '<param name="style:smiley9" value=";-) img/clin-oeuil.gif">';
      buf += '<param name="style:smiley10" value=";) img/clin-oeuil.gif">';
      buf += '<param name="style:smiley11" value=":-( img/triste.gif">';
      buf += '<param name="style:smiley12" value=":( img/triste.gif">';
      buf += '<param name="style:smiley13" value=":-| img/OH-3.gif">';
      buf += '<param name="style:smiley14" value=":| img/OH-3.gif">';
      buf += '<param name="style:smiley15" value=":\'( img/pleure.gif">';
      buf += '<param name="style:smiley16" value=":$ img/rouge.gif">';
      buf += '<param name="style:smiley17" value=":-$ img/rouge.gif">';
      buf += '<param name="style:smiley18" value="(H) img/cool.gif">';
      buf += '<param name="style:smiley19" value="(h) img/cool.gif">';
      buf += '<param name="style:smiley20" value=":-@ img/enerve1.gif">';
      buf += '<param name="style:smiley21" value=":@ img/enerve2.gif">';
      buf += '<param name="style:smiley22" value=":-S img/roll-eyes.gif">';
      buf += '<param name="style:smiley23" value=":s img/roll-eyes.gif">';
    }
    else
    {
      buf += '<param name="style:bitmapsmileys" value="false">';
    }
    buf += '<p>Java Required</p>';
    buf += '<p>Sorry, but you need to download and install <a href="http://java.com/en/download/">Java</a>.</p>';
    buf += '</applet>';
    apdiv = document.getElementById('afterchatapplet');
    apdiv.innerHTML = buf;
    apdiv.style.display = 'block';
    chdiv = document.getElementById('afterchatprep');
    chdiv.style.display = 'none';
    locdiv = document.getElementById('afterchatloc');
    locdiv.style.display = 'none';
    }
  else {
    after_control();
    var buf = '';
    var randy = '';
    randy = Math.floor(Math.random()*after_servers.length); 
    buf += '<html><head><title>'+after_promowintitle+'</title></head><body style="margin: 0;">';
    buf += '<applet code="IRCApplet.class" archive="irc-unsigned.jar,pixx.jar" codebase="http://'+after_servers[randy]+'/afternet/pjirc/" width="100%" height="100%">';
    buf += '<param name="host" value="'+after_servers[randy]+'">';
    buf += '<param name="password" value="authserv '+after_username+' :'+after_password+'">';
    buf += '<param name="autoconnection" value="true">';
    buf += '<param name="nick" value="'+after_nickname+'">';
    buf += '<param name="alternatenick" value="'+after_nickname+'???">';
    buf += '<param name="userid" value="'+after_userid+'">';
    buf += '<param name="name" value="'+after_name+'">';
    buf += '<param name="quitmessage" value="'+after_quitmessage+' ('+document.domain+')">';
    buf += '<param name="asl" value="false">';
    buf += '<param name="useinfo" value="'+after_useinfo+'">';
    buf += '<param name="highlight" value="true">';
    buf += '<param name="command1" value="/join '+after_channel+'">';
    buf += '<param name="style:floatingasl" value="true">';
    buf += '<param name="style:sourcefontrule1" value="all all '+after_fontface+' '+after_fontsize+'">';
    buf += '<param name="style:backgroundimage" value="'+after_bgimage+'">';
    buf += '<param name="style:backgroundimage1" value="all all 0 '+after_bgimageurl+'">';
    buf += '<param name="gui" value="pixx">';
    buf += '<param name="pixx:helppage" value="'+after_helppage+'">';
    buf += '<param name="pixx:showabout" value="false">';
    buf += '<param name="pixx:nickfield" value="false">';
    buf += '<param name="pixx:timestamp" value="true">';
    buf += '<param name="pixx:highlight" value="true">';
    buf += '<param name="pixx:highlightnick" value="true">';
    buf += '<param name="pixx:nickfield" value="true">';
    buf += '<param name="pixx:styleselector" value="true">';
    buf += '<param name="pixx:setfontonstyle" value="true">';
    buf += '<param name="pixx:color0" value="'+after_color0+'">';
    buf += '<param name="pixx:color1" value="'+after_color1+'">';
    buf += '<param name="pixx:color2" value="'+after_color2+'">';
    buf += '<param name="pixx:color3" value="'+after_color3+'">';
    buf += '<param name="pixx:color4" value="'+after_color4+'">';
    buf += '<param name="pixx:color5" value="'+after_color5+'">';
    buf += '<param name="pixx:color6" value="'+after_color6+'">';
    buf += '<param name="pixx:color7" value="'+after_color7+'">';
    buf += '<param name="pixx:color8" value="'+after_color8+'">';
    buf += '<param name="pixx:color9" value="'+after_color9+'">';
    buf += '<param name="pixx:color10" value="'+after_color10+'">';
    buf += '<param name="pixx:color11" value="'+after_color11+'">';
    buf += '<param name="pixx:color12" value="'+after_color12+'">';
    if (after_smileys == 'true')
    {
      buf += '<param name="style:bitmapsmileys" value="true">';
      buf += '<param name="style:smiley1" value=":) img/sourire.gif">';
      buf += '<param name="style:smiley2" value=":-) img/sourire.gif">';
      buf += '<param name="style:smiley3" value=":-D img/content.gif">';
      buf += '<param name="style:smiley4" value=":d img/content.gif">';
      buf += '<param name="style:smiley5" value=":-O img/OH-2.gif">';
      buf += '<param name="style:smiley6" value=":o img/OH-1.gif">';
      buf += '<param name="style:smiley7" value=":-P img/langue.gif">';
      buf += '<param name="style:smiley8" value=":p img/langue.gif">';
      buf += '<param name="style:smiley9" value=";-) img/clin-oeuil.gif">';
      buf += '<param name="style:smiley10" value=";) img/clin-oeuil.gif">';
      buf += '<param name="style:smiley11" value=":-( img/triste.gif">';
      buf += '<param name="style:smiley12" value=":( img/triste.gif">';
      buf += '<param name="style:smiley13" value=":-| img/OH-3.gif">';
      buf += '<param name="style:smiley14" value=":| img/OH-3.gif">';
      buf += '<param name="style:smiley15" value=":\'( img/pleure.gif">';
      buf += '<param name="style:smiley16" value=":$ img/rouge.gif">';
      buf += '<param name="style:smiley17" value=":-$ img/rouge.gif">';
      buf += '<param name="style:smiley18" value="(H) img/cool.gif">';
      buf += '<param name="style:smiley19" value="(h) img/cool.gif">';
      buf += '<param name="style:smiley20" value=":-@ img/enerve1.gif">';
      buf += '<param name="style:smiley21" value=":@ img/enerve2.gif">';
      buf += '<param name="style:smiley22" value=":-S img/roll-eyes.gif">';
      buf += '<param name="style:smiley23" value=":s img/roll-eyes.gif">';
    }
    else
    {
      buf += '<param name="style:bitmapsmileys" value="false">';
    }
    buf += '<p>Java Required</p>';
    buf += '<p>Sorry, but you need to download and install <a href="http://java.com/en/download/">Java</a>.</p>';
    buf += '</applet>';
    buf += '</body></html>';
    afterwindow = window.open('', "afterwindow", 'width=' +after_width+ ', height=' +after_height);
    afterwindow.document.open('text/html');
    afterwindow.document.write(buf);
    afterwindow.document.close();
    afterwindow.focus();
  }
}
