// JavaScript Document
//Sriram 10-Feb-2010

function information(s1)
{
	if(trimString(s1.Name.value)==""){
		alert("Please enter your Name.")
		s1.Name.value = ""
		s1.Name.focus()
		return false
	}	
	else
	{	var tName = trimString(s1.Name.value);
		if (CheckName(tName) == false)
		{ 
			s1.Name.value = ""
			s1.Name.focus()
			return false;
		}
		else
		{
		 if ( tName.length >= 3 )
		 {
			s1.Name.value = tName; 
		 }
		 else
		 {
			alert("Name should have atleast 3 characters.")
			s1.Name.focus();					
			return false
		 }
		
		}
	}
	
	if(trimString(s1.Organisation.value)=="")
	{
		alert("Please enter your Organisation.")
		s1.Organisation.value=""
		s1.Organisation.focus()
		return false
	}
	
	if(trimString(s1.Title.value)=="")
	{
		alert("Please enter your Title.")
		s1.Designation.value=""
		s1.Designation.focus()
		return false
	}
	
	if(trimString(s1.City.value)=="")
	{
		alert("Please enter your City.")
		s1.City.value = ""
		s1.City.focus()
		return false
	}
	else
	{
	var tName = trimString(s1.City.value);
	if (CheckCity(tName) == false)
		{ 
			s1.City.value = ""
			s1.City.focus()
			return false;
		}
	}

	
	if(trimString(s1.Country.value)=="")
	{
		alert("Please select your Country.")
		s1.Country.value=""
		s1.Country.focus()
		return false
	}	
	
	if(trimString(s1.Email.value)=="")
	{
		alert("Please enter your Email address.")
		s1.Email.value=""
		s1.Email.focus()
		return false
	}
	else
	{	
		st=s1.Email.value;
		if(checkEmail(st)==false)
		{
			alert("Please enter correct Email address.")
			s1.Email.focus();
			return false;
		}
	}
	
	if(trimString(s1.Phone.value)=="")
	{
		alert("Please enter your Phone Number.")
		s1.Phone.value=""
		s1.Phone.focus()
		return false
	}	
	else
	{	
		st=s1.Phone.value;
		if(IsNumeric(st)==false)
		{
			alert("Please enter correct Phone Number.")
			s1.Phone.value=""
			s1.Phone.focus();
			return false;
		}
	}	
	
}

//Trimming the string
function trimString (str)
   {   
        str = this != window? this : str;
        return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
   } 
   
function checkEmail(str)
{   
    var filterEmail =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})$/;     
    if(filterEmail.test(str))
    {
		return true;
	}
	else
	{
		return false;
	}
}

function IsNumeric(sText)
{
var ValidChars = "0123456789+-()";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++) 
{ 
Char = sText.charAt(i); 
if (ValidChars.indexOf(Char) == -1) 
{
IsNumber = false;
}
}
return IsNumber; 
}

function CheckName(str)
{
	if (!str.match(/^[a-zA-Z ]+$/))
	{
	    alert("Please enter alphabets only.");
		return false;
	}
	else
	{
	   return true;
	}
}


function CheckCity(str)
{
	if (!str.match(/^[a-zA-Z0-9 .]+$/))
	{
	    alert("Please enter your City.");
		return false;
	}
	else
	{
	   return true;
	}
}