var EmailRegExp = /^\w(\.?\w)*@\w(\.?[-\w])*\.([a-z]{2,4}(\.[a-z]{3})?|[a-z]{2}(\.[a-z]{2})?)$/i;
var PhoneNumberRegExp = /^[\d ,-]+$/;
//var OnlySpaceRegExp = /^[ ]+$/;

//this function check validity of the press release receiver entry form of the admin panel
function RegisterFormValidation(form)
{
	var FormIsValid = true;

	
	if(form.User_IDx.value=="" || EmailRegExp.test(form.User_IDx.value))
	{
		FormIsValid = false;
		alert("Please Enter User ID that is not any email address.");
		form.User_IDx.focus();
	}
	else if((form.Passwordx.value=="" && form.Passwordy.value=="") || (form.Passwordx.value != form.Passwordy.value))
	{
		FormIsValid = false;
		alert("Passwords did not match or left blank.");
		form.Passwordx.focus();
	}
	else if(!EmailRegExp.test(form.Emailx.value))
	{
		FormIsValid = false;
		alert("Please enter valid email address");
		form.Emailx.focus();
	}
	else if(form.ToS.value!="Yes")
	{
		FormIsValid = false;
		alert("You must agree to Terms of Service of Bdtips.com. Please read it before you Submit.");
		form.ToS.focus();
	}
	else if(form.Country.value=="xxx")
	{
		FormIsValid = false;
		alert("You must select your country of residence.");
		form.Country.focus();
	}

	return FormIsValid;
}
function UserSignInFormValid(form)
{
	var FormIsValid = true;

	 
	if(form.User_ID.value=="")
	{
		FormIsValid = false;
		alert("Please Enter User ID");
		form.User_ID.focus();
	} 
	else if(form.Password.value=="")
	{
		FormIsValid = false;
		alert("Please Enter Password");
		form.Password.focus();
	}
	return FormIsValid;
}

function RetrivePassFormValid(form)
{
	var FormIsValid = true;

	if(!EmailRegExp.test(form.Emailx.value))
	{
		FormIsValid = false;
		alert("Please enter valid email address");
		form.Emailx.focus();
	}
	return FormIsValid;
}

function PostTipsFormValidation(form)
{
	var FormIsValid = true;

	if(form.Article_Title.value=="")
	{
		FormIsValid = false;
		alert("Please give a Title to your Article.");
		form.Article_Title.focus();
	}
	else if(form.Keywords.value=="")
	{
		FormIsValid = false;
		alert("You left the keyword section blank. (These are the words people may google to find something like your article.)");
		form.Keywords.focus();
	}
	else if(form.Article_Text.value=="")
	{
		FormIsValid = false;
		alert("You haven't inserted Article Body yet.");
		form.Article_Text.focus();
	}
    else if(form.Article_Text.value.length<700)
	{
		FormIsValid = false;
		alert("Your Article is too Short!! Minimum 700 characters including spaces (roughly 150 words) are required");
		form.Article_Text.focus();
	}
	else if(form.Article_Text.value.length>21000)
	{
		 FormIsValid = false;
		alert("Your Article is too Big!! Maximum 21000 characters including spaces (roughly 4500 words) are allowed!");
		form.Article_Text.focus();
	}
	else if(form.Source.value=="")
	{
		FormIsValid = false;
		alert("You must include the source! It could be the name of the person, book or website from where you get this article.");
		form.Source.focus();
	}
	else if(form.Agreement.value!="Yes")
	{
		FormIsValid = false;
		alert("You must agree to Terms and Conditions of Bdtips.com. Please read it before you Check this button and submit.");
		form.Agreement.focus();
	}
	
	return FormIsValid;
}

function ManuallySubmit(form)
{
	form.submit();
}
