function FormValidator(joinForm)
{
	if (document.joinForm.Name.value == "")
	{
	alert("You must enter your Name before continuing.");
	document.joinForm.Name.focus();
	document.joinForm.Name.select();
	return false;
	}

	if (document.joinForm.Email.value.indexOf("@") == -1 || document.joinForm.Email.value.indexOf(".") == -1|| document.joinForm.Email.value == "")
	{
	alert("Please enter a proper email address.");
	document.joinForm.Email.focus();
	document.joinForm.Email.select();
	submitcount = 0;
	return false;
	}

	if (document.joinForm.Email.value.indexOf(" ") != -1)
	{
	alert("Your email address should not contain any spaces.");
	document.joinForm.Email.focus();
	document.joinForm.Email.select();
	submitcount = 0;
	return false;
	}
	
	if (document.joinForm.Password1.value == "")
	{
	alert("Please enter a password.");
	document.joinForm.Password1.focus();
	document.joinForm.Password1.select();
	submitcount = 0;
	return false;
	}
	
	if (document.joinForm.Password1.value.length < 8)
	{
	alert("Your password must be at least 8 characters in length.");
	document.joinForm.Password1.focus();
	document.joinForm.Password1.select();
	submitcount = 0;
	return false;
	}	
	
	if (document.joinForm.Password1.value != document.joinForm.Password2.value)
	{
	alert("Your passwords do not match.  Please enter your passwords again.");
	document.joinForm.Password2.value = "";
	document.joinForm.Password1.focus();
	document.joinForm.Password1.select();
	submitcount = 0;
	return false;
	}	

  return (true);
}

function AlphaNumericCheck(handle,strAllowed) {

	var charOK = strAllowed;

	var allValid = true;
		for (i = 0;  i < handle.length;  i++)
		{
			ch = handle.charAt(i);
			for (j = 0;  j < charOK.length;  j++)
				if (ch == charOK.charAt(j))
					break;
			if (j == charOK.length)
			{
				allValid = false;
				break;
			}
		}
	return allValid;
}

function limitDescription(msg,count,maxLength) {

if (msg.value.length > maxLength)
	{
	msg.value = msg.value.substring(0, maxLength);
	count.value = '0';
	}
else
	count.value = maxLength - msg.value.length;
}


function confirmDelete(ChannelID) {
	input_box = confirm("Are you sure you want to delete this channel?");
	
	if (input_box == true) { 
		window.location.href = "DeleteChannel.php?ChannelID=" + ChannelID; 
	}
	else {
		alert ("Channel has not been deleted.");
	}
}

function confirmDeleteMovie(MovieID) {
	input_box = confirm("Are you sure you want to delete this movie?");
	
	if (input_box == true) { 
		window.location.href = "DeleteMovie.php?MovieID=" + MovieID; 
	}
	else {
		alert ("Movie has not been deleted.");
	}
}

function confirmDeleteSport(SportID) {
	input_box = confirm("Are you sure you want to delete this live sport stream?");
	
	if (input_box == true) { 
		window.location.href = "DeleteSport.php?SportID=" + SportID; 
	}
	else {
		alert ("Live Sports stream has not been deleted.");
	}
}

function confirmDeleteShow(ShowID) {
	input_box = confirm("Are you sure you want to delete this TV show?");
	
	if (input_box == true) { 
		window.location.href = "DeleteShow.php?ShowID=" + ShowID; 
	}
	else {
		alert ("TV show has not been deleted.");
	}
}
