////////////////////////////
/*
Developed By: Mohammed S Alabsi
Title: Web Developer
Date: July 24th, 2005
System: Mobile
Objective: Performs Client-Side Validation for the "Tell Friend" from. Applied on the English section 
		only
*/
/////////////////////////////
function validateForm(theForm)
{

if (!theForm.sender_name.value)
{
window.alert("Please enter your name");
return false;
}

var no_digit= theForm.sender_name.value.search (/\d/);
var ok_name = theForm.sender_name.value.length;

  if ((no_digit < 0) && (ok_name > 0))
  {
  }
  else
  {
    window.alert ("Please enter your name correctly\n" + "A name Should not contain numbers, only letters");
	return false;
  }

if(!theForm.sender_email.value)
{
window.alert("Please enter your email address");
return false;
}

var i = 0;
var email = theForm.sender_email.value;
var validEmail = "Please enter a correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }


if (!theForm.reciever_1.value)
{
window.alert("Please enter at least the name of one contact");
return false;
}

if ((theForm.reciever_1.value) && (!theForm.re_email_1.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_2.value) && (!theForm.re_email_2.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_3.value) && (!theForm.re_email_3.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_4.value) && (!theForm.re_email_4.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_5.value) && (!theForm.re_email_5.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_6.value) && (!theForm.re_email_6.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_7.value) && (!theForm.re_email_7.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_8.value) && (!theForm.re_email_8.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_9.value) && (!theForm.re_email_9.value))
{
window.alert("Please enter your friend's email address");
return false;
}

if ((theForm.reciever_10.value) && (!theForm.re_email_10.value))
{
window.alert("Please enter your friend's email address");
return false;
}

 i = 0;
 email = theForm.re_email_1.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }


if (theForm.re_email_2.value)
{
i = 0;
 email = theForm.re_email_2.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_3.value)
{
i = 0;
 email = theForm.re_email_3.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_4.value)
{
i = 0;
 email = theForm.re_email_4.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_5.value)
{
i = 0;
 email = theForm.re_email_5.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_6.value)
{
i = 0;
 email = theForm.re_email_6.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_7.value)
{
i = 0;
 email = theForm.re_email_7.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_8.value)
{
i = 0;
 email = theForm.re_email_8.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_9.value)
{
i = 0;
 email = theForm.re_email_9.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

if (theForm.re_email_10.value)
{
i = 0;
 email = theForm.re_email_10.value;
 validEmail = "Please enter your friend's correct email address"

	    if ( email.length < 3)
	    {
		window.alert(validEmail);
		return false;
	    }

	    var at = email.indexOf("@")

	    if (at == -1 || at == 0 || at == email.length - 1)
	    {
	    window.alert(validEmail);
		return false;
	    }
}

return true;

}