// Code to check that the form fields look ok

// Preload button alternate images
if (document.images)
{
  var pic1= new Image(); pic1.src="styles/DownloadMouseover.gif"; 
//  var pic2= new Image(); pic2.src="styles/RegisterMouseover.gif"; 
  var pic3= new Image(); pic3.src="styles/DonateMouseover.gif"; 
  var pic4= new Image(); pic4.src="styles/5_Mouseover_Donate.gif"; 
  var pic5= new Image(); pic5.src="styles/10_Mouseover_Donate.gif"; 
  var pic6= new Image(); pic6.src="styles/25_Mouseover_Donate.gif"; 
}

function displayNone(id)
{
 document.getElementById(id).style.display='none';
//	obj = getObject(id);
//	obj.style.display='none';
	
//	if (IEDOM) alert("displayNone()");

}

function displayBlock(id)
{
	document.getElementById(id).style.display='block';
//	obj = getObject(id);
//	obj.style.display='block';
//	if (IEDOM) alert("displayBlock()");

}

function mouseIn(id)
{
//	displayNoneClass('hide');
	displayBlock(id);
}

function mouseOut(id)
{
	displayNone(id);
}

// **************************************************************

function donate(amount)
{
	document.getElementById('donateForm').amount.value = amount;
	document.getElementById('donateForm').submit();
}

// **************************************************************

function validateDownload()
{
	alert("NOTE: You must also download and install the FREE Bang!Core Addon");
}

function validateServer(droplist)
{
	var other = document.getElementById('serverName');
	if (droplist.selectedIndex == 0) {
		other.disabled = false;
		}
	else {
		other.disabled = true;
		other.value = "";
	}

}

function validateDonateButton()
{
	document.getElementById('DonateButtonForm').submit();
}


function validateRegButton()
{
	document.getElementById('RegButtonForm').submit();
}

function validateRegForm(theForm)
{
	theForm.playerName.value = trim(theForm.playerName.value);
	theForm.serverName.value = trim(theForm.serverName.value);

	if ( isEmpty(theForm.playerName.value)) {
		alert("Please specify a character name");
		theForm.playerName.focus();
		return (false);
		}
	if (hasWhiteSpace(theForm.playerName.value)) {
		alert("Character name is invalid... no spaces allowed");
		theForm.playerName.focus();
		return (false);
		}
	if (theForm.realmList.selectedIndex == 0) {
		if (isEmpty(theForm.serverName.value)) {
			alert("Please specify a Server name");
			theForm.serverName.focus();
			return (false);
			}
		}
	return (true);
}


function hasWhiteSpace(s) {
	if (/\s/.test(s)) 
		return true;
	return false;
}


function isEmpty(s) 
{
	if ( s == "") 
		return (true);
	return (false);
}

function trim(s) 
{
	return s.replace(/^\s+|\s+$/g, '')
}
