/* -------------- JavaScript Document --------------
Date Created: Jul 9, 2008
Last Updated: Jul 9, 2008
-----------------------------------*/


// ================START FORM VALIDATION ("ContactInfo)================
function validString(str)  //Checking empty text field
{
	if (str.length != 0) 
		return true
	else
		return false
}



//---------------FUNCTION TO VALIDATE ATTENTION FIELD--------------
function getSelectvalue(list) 
	{
		var listval = list.options[list.selectedIndex].value
		return listval
	}




function validEmail(email)  //Validating email address
{
 	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");  //Checking the "@" sign
	
	if (index > 0)
  	{
    	var pindex = theStr.indexOf(".",index);  //Checking the "." sign (ie - .com., .net etc) 
    		if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
  	}
  	return result;
}

function checkform(form) 		
{
		if (validString(form.y_name.value) == false)  //Checking empty name text box
		{
			alert("Please provide your full name")
			form.y_name.focus()   
			return false;
		}
		
		if (form.y_email.value == "")  //Checking empty email address field
    	{
      		alert("Please enter your email address");
      		form.y_email.focus();
      		return false;
    	}

    	if (!validEmail(form.y_email.value))  //Return error message if the value is invalid
    	{
    		alert("Please enter a valid email address: yourname@yourdomain.com");
    		form.y_email.focus();
    		return false;
    	}
		
		if (validString(form.f_name.value) == false)  //Checking empty name text box
		{
			alert("Please provide your friend's name")
			form.f_name.focus()   
			return false;
		}
		
		
		if (form.f_email.value == "")  //Checking empty email address field
    	{
      		alert("Please enter your friend's email address");
      		form.f_email.focus();
      		return false;
    	}

    	if (!validEmail(form.f_email.value))  //Return error message if the value is invalid
    	{
    		alert("Please enter a valid email address: yourname@yourdomain.com");
    		form.f_email.focus();
    		return false;
    	}

			
}
		

// ----------END OF JAVASCRIPT CODE---------




