<!-- Code after this will be ignored by older browsers

String.prototype.trim = function()
{
	return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"");
}

String.prototype.fulltrim = function()
{
	return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"").replace(/\s+/g," ");
}

var dom = document.getElementById;
var ie = document.all;
var ns4 = document.layers;
var opera = window.opera;

var intSubmitCount = 0;

function SubmitOnce()
{
	if (intSubmitCount == 0)
	{
		intSubmitCount++;
		
		return true;
	}
	else 
	{
		return false;
	}
}

function setInitials()
{
	var strFirstName = document.newboardform.firstname.value.trim();
	var strLastName = document.newboardform.lastname.value.trim();
	var strInitials = "";
		
	if ((strFirstName) || (strLastName))
	{
		if (strFirstName)
		{
			strInitials = strFirstName.substring(0, 1)
		}
	
		if (strLastName)
		{
			strInitials += strLastName.substring(0, 1)
		}

		if (strInitials)
		{
			document.newboardform.initials.value = strInitials;
		}
	}
}

function setTitle()
{
	var strFirstName = document.newboardform.firstname.value.trim();
	var strLastName = document.newboardform.lastname.value.trim();
	var strTitle = "";
	
	if ((strFirstName) || (strLastName))
	{
		strTitle = strFirstName + " " + strLastName
		
		strTitle = strTitle.fulltrim();
		
		if (strTitle)
		{
			var strLastChar = strTitle.substr(strTitle.length - 1);

			if ((strLastChar != 's') && (strLastChar != 'S'))
			{
				strTitle += "'s";
			}
			else
			{
				strTitle += "'";
			}
			

			strTitle += " Virtual Whiteboard.";
		}
		
		document.newboardform.boardtitle.value = strTitle;
	}
}

function validateBoardSettings(theform)
{
	var strFirstName = theform.firstname.value;
	var strLastName = theform.lastname.value;
	var strInitials = theform.initials.value;
	var strTitle = theform.boardtitle.value;
	var intWidth = theform.boardwidth.value;
	var intHeight = theform.boardheight.value;
	var strCode = theform.authcode.value;
	var strErrorMsg = '';
		
	if ((!strName) || (!strTitle) || (!intWidth) || (!intHeight) || (!strCode))
	{
		if (!strName)
		{
			strErrorMsg = strErrorMsg + '- You have not entered your name.\n';
		}
		if (!strTitle)
		{
			strErrorMsg = strErrorMsg + '- You have not entered a title for this whiteboard.\n';
		}
		if (!intWidth)
		{
			strErrorMsg = strErrorMsg + '- You have not entered a width for this whiteboard.\n';
		}
		if (!intHeight)
		{
			strErrorMsg = strErrorMsg + '- You have not entered a height for this whiteboard.\n';
		}
		if (!strCode)
		{
			strErrorMsg = strErrorMsg + '- You have not entered the authentication code.\n';
		}
	}
	else
	{
		intWidth = parseInt(intWidth, 10);
		intHeight = parseInt(intHeight, 10);
		
		if ((intWidth < 600) || (intWidth > 2000))
		{
			strErrorMsg = strErrorMsg + '- The width value entered is outside the valid range (600 - 2000).\n';
		}
		
		if ((intHeight < 600) || (intHeight > 4000))
		{
			strErrorMsg = strErrorMsg + '- The height value entered is outside the valid range (600 - 4000).\n';
		}
	}
	
	if (!strErrorMsg)
	{
		theform.dom.value = dom;
		theform.ie.value = ie;
		theform.ns4.value = ns4;
		theform.opera.value = opera;
			
		return SubmitOnce();
	}
	else
	{
		alert ('Unable to create the new whiteboard:\n\n' + strErrorMsg);
		
		return false;
	}
}

// Stop hiding the code here -->
