<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Welcome to MUCkl</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <script src="shared.js"></script>
    <script src="config.js"></script>

    <script language="JavaScript" type="text/javascript" src="lib/jsjac/JSJaC.js"></script>

    <script language="JavaScript" type="text/javascript" src="lib/Debugger/Debugger.js"></script>
    <script>
<!--<![CDATA[

 /*
  * MUCkl, a simple groupchat application
  * Copyright (C) 2004-2005 Stefan Strigler <steve@zeank.in-berlin.de>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */

var roomidx = -1;

function loginCheck(form) {
  if (form.nick.value.match(/^\s*(\S+|\S+.*\S+)\s*$/)) {
    form.nick.value = RegExp.$1;
  } else {
    alert("You need to supply a valid nickname");
    return false;
  }
  var oSel = document.getElementById('room');
  location.replace("muckl.html?nick="+escape(form.nick.value)+"&room="+roomidx);
  return false;
}

function roomSelected(oSel) {
  roomidx = oSel.selectedIndex;
  document.getElementById('room_desc').innerHTML = ROOMS[roomidx].description;
}

var Debug;
function init() {
  /* initialise debugger */
  if (!Debug || typeof(Debug) == 'undefined' || !Debug.start) {
    if (DEBUG && typeof(Debugger) == 'function')
      Debug = new Debugger(DEBUG_LVL,'MUCkl');
    else {
      Debug = new Object();
      Debug.log = function() {};
      Debug.start = function() {};
    }
  }
  Debug.start();

  var welcome = "Welcome to MUCkl v"+VERSION;
  document.title = welcome;
  document.getElementById("welcomeh1").innerHTML = welcome;

  getArgs();
  if (passedArgs['room']) {
    if (isNaN(passedArgs['room'])) { // search if name matches
      for (var i=0; i<ROOMS.length; i++)
	if (ROOMS[i].name == passedArgs['room']) {
	  
	  /* preselect room */
	  
	  roomidx = i;
	  
	  document.getElementById('roomchooser').style.display = 'none';
	  document.getElementById('roomchooser2').style.display = 'none';
	  break;
	}
      
    } else if (ROOMS[passedArgs['room']]){
      
      /* preselect room */
      
      roomidx = passedArgs['room'];
      
      document.getElementById('roomchooser').style.display = 'none';
      document.getElementById('roomchooser2').style.display = 'none';
    } 
  }
  
  if (roomidx < 0) {
    /* create room selector */
    
    var oSel = document.getElementById('room');
    for (var i in ROOMS)
      oSel.options.add(new Option(ROOMS[i]['name'],ROOMS[i]['name']+'@'+ROOMS[i]['server']));
    roomSelected(oSel);
  }
  
  // check for nick
  if (passedArgs['nick'])
    document.forms['login'].nick.value = passedArgs['nick'];
}

onload = init;
//]]>-->
    </script>
    <style type="text/css">
    /*<![CDATA[*/
			body {
			font-size: 1em;
			font-family: Verdana, sans-serif;
			color: #000033;
			margin: 8px;
			background-color: #eeeeee;
			}
			h1 { 
			font-size: 1.4em; 
			margin-top:0px;
			margin-bottom: 0px;
			}
			input,select {
			border: 1px solid black;
			padding-left: 2px;
			-moz-border-radius: 4px;
			background-color: #eeeeee;
			}
			button {
			border: 1px solid black;
			background-color: #eeeeee;
			-moz-border-radius: 4px;
			margin-left: 8px;
			}
			input:hover, input:focus {
			background-color: white;
			}
			button:hover {
			background-color: white;
			}
			td {
			font-size: 0.8em;
			font-family: Verdana, sans-serif;
			color: #000033;
			}
			#barbottom {
			position: absolute;
			bottom: 0px;
			left: 0px;
			background: url(images/redbar.jpg) no-repeat;
			background-color: white;
			font-size: 0.8em;
			font-weight: bold;
			width: 100%;
			color: black;
			}
			/*]]>*/
    </style>
  </head>
  
<body>
  <a href="http://www.jabber.org"><img src="images/jabber-powered.gif" border=0 alt="Jabber Powered" align=right></a>

  <table width="100%" height="100%">
    <tr>
      <td align="center" valign="middle">
	<div style="padding: 16px; background-color: white; border: 2px solid #babcb9; -moz-border-radius: 12px; width: 320px; text-align:left;">
	  <h1 id="welcomeh1"></h1>
	  <span style="font-size:0.8em;">An easy to use, web based groupchat application.</span>

	  <p style="padding-top:8px;">Enter your desired nickname below, choose a room and click on 'Login' to start the chat!</p>
	  <form name="login" onSubmit="return loginCheck(this);">
	    <table>
	      <tr>
		<td><label for="nick" style="font-weight:bold;font-style:italic;color:black;">Nickname: </label></td><td><input type="text" name="nick" id="nick" tabindex=1><button type="submit" tabindex=3>Login</button></td>
	      </tr>
	      <tr id="roomchooser">
		<td><label for="room" style="font-weight:bold;font-style:italic;color:black;">Room: </label></td><td><select id="room" name="room" tabindex=2 onchange="return roomSelected(this);"></select></td>
	      </tr>
	      <tr id="roomchooser2"><td>&nbsp;</td><td><small id='room_desc'></small></td></tr>
	    </table>
	  </form>
	</div>
      </td>
    </tr>
  </table>
  <div id="barbottom"><span style="padding-left: 8px;">MUCkl v<script>document.write(VERSION);</script></span> <span style="position:absolute; right:0px;">&copy; 2004-2005 by Stefan Strigler, Florian Jensen</span></div>
  </body>
</html>