window.onload = function()
{
	document.getElementById('txtArtistFName').focus();
}
function boothSpaces()
{
	var strTemp = trim(document.getElementById('txtArtistCode').value).toLowerCase();
	strTemp = strTemp.replace(/ /g,"_");
	document.getElementById('txtArtistCode').value = strTemp;
}
function validateRegister()
{	
	var illegalChars = /[\W]/; // allow only letters and numbers
	if (illegalChars.test(strArtistCode)) {
		alert("The Booth URL contains illegal characters. Only letters, numbers, and underscores are allowed.");
		document.getElementById('txtArtistCode').focus();
		return false;
    	} 
    	
    	if(strArtistCode == "actions" || strArtistCode == "images"
    	 	|| strArtistCode == "login" || strArtistCode == "logout"
    	 	|| strArtistCode == "register" || strArtistCode == "default"
    	 	|| strArtistCode == "home" || strArtistCode == "admin"
    	 	|| strArtistCode == "includes" || strArtistCode == "scripts"
    	 	|| strArtistCode == "styles" || strArtistCode == "templates")
    	{
    		alert("The word \""+strArtistCode+"\" is a reserved word and cannot be used in the Booth URL.");
    		document.getElementById('txtArtistCode').value = '';
    		document.getElementById('txtArtistCode').focus();
    		return false;
    	}	
	
	var strArtistFName = document.getElementById('txtArtistFName').value;
	if(!validateNotEmpty(strArtistFName))
	{
		alert("Please enter your First Name.");
		document.getElementById('txtArtistFName').focus();
		return false;
	}
	var strArtistLName = document.getElementById('txtArtistLName').value;
	if(!validateNotEmpty(strArtistLName))
	{
		alert("Please enter your Last Name.");
		document.getElementById('txtArtistLName').focus();
		return false;
	}
	
	var strArtistEmail = document.getElementById('txtArtistEmail').value;
	if(!validateNotEmpty(strArtistEmail))
	{
		alert("Please enter your Email Address.");
		document.getElementById('txtArtistEmail').focus();
		return false;
	}
	if(!validateEmail(strArtistEmail))
	{
		alert("Please enter a valid Email Address.");
		document.getElementById('txtArtistEmail').focus();
		return false;
	}

	var strArtistCode =  document.getElementById('txtArtistCode').value;
	if(!validateNotEmpty(strArtistCode))
	{
		alert("Please enter your Booth URL.");
		document.getElementById('txtArtistCode').focus();
		return false;
	}

	if(document.getElementById('txtPassword1').value == "" || document.getElementById('txtPassword2').value == "")
	{
		alert("Please enter your Password.");
		document.getElementById('txtPassword1').focus();
		return false;
	}
	if(document.getElementById('txtPassword1').value != document.getElementById('txtPassword2').value)
	{
		alert("Passwords must match.");
		document.getElementById('txtPassword1').focus();
		return false;
	}
	
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if (illegalChars.test(document.getElementById('txtPassword1').value)) {
		alert("The password contains illegal characters. Only letters and numbers are allowed.");
    		document.getElementById('txtPassword1').focus();
		return false;
    	} 
	if(document.getElementById('txtPassword1').value.length < 6)
	{
		alert("Passwords must be longer than 6 characters.");
    		document.getElementById('txtPassword1').focus();
		return false;
	}
	var strCaptcha = document.getElementById('txtCaptcha').value;
	if(!validateNotEmpty(strCaptcha))
	{
		alert("Please enter the Verification Code.");
		document.getElementById('txtCaptcha').focus();
		return false;
	}
	//var chkTerms = document.getElementById('chkTermsConditions');
	//if(!chkTerms.checked)
	//{
	//	alert("Please agree to the Terms & Conditions.");
	//	return false;
	//}
}

function redrawCaptcha()
{
	var randomNumber = Math.floor(Math.random()*1000);
	document.getElementById('imgCaptcha').src = 'captcha.php?id='+randomNumber;
}
function showTermsConditions()
{
	params  = 'width=550';
	params += ', height=400';
	params += ', top=50, left=50, scrollbars=yes';
	
	window.open("/tos","terms",params);
}
function showPromoCode()
{
	document.getElementById('promo-code').style.display = 'none';
	document.getElementById('promo-enter').style.display = 'block';
	document.getElementById('txtPromoCode').focus();
}
