function isText(str)
{
	var i=0;
	if(str.charAt(0)==' ')i++;
	while(i<str.length)
	{
		if (str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)=='+' || str.charAt(i)=='-' || str.charAt(i)=='*' || str.charAt(i)=='/' || str.charAt(i)=='\\' || str.charAt(i)=='\'' || str.charAt(i)=='@' || str.charAt(i)=='!' || str.charAt(i)=='~' || str.charAt(i)=='`' || str.charAt(i)=='#' || str.charAt(i)=='$' || str.charAt(i)=='%' || str.charAt(i)=='^' || str.charAt(i)=='&' || str.charAt(i)=='(' || str.charAt(i)==')' || str.charAt(i)=='_' || str.charAt(i)=='=' || str.charAt(i)=='?' || str.charAt(i)=='.' || str.charAt(i)==',' || str.charAt(i)==';' || str.charAt(i)==':' || str.charAt(i)=='"' || str.charAt(i)=='{' || str.charAt(i)=='}' || str.charAt(i)=='[' || str.charAt(i)==']' || str.charAt(i)=='<' || str.charAt(i)=='>' || str.charAt(i)=='|')
		return false;
		i++;
	}
	return true;
}

// Check Phone Number or not
function isTelephoneNumber(str)
{
	var i=0;
	if(str.charAt(0)=='+')i++;
	while(i<str.length)
	{
		if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' ' || str.charAt(i)=='-' || str.charAt(i)=='(' || str.charAt(i)==')') )
			return false;
		i++;
	}
	return true;
}

// Check Phone Number length
function isLength(str)
{
	var len=str.length;
		if(len<10)
		{
			return false;
		}
		return true;
}

// Check Number or Not
function isNumeric(str)
{
	var i=0;
	while(i<str.length)
	{
		if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' '))
		return false;
		i++;
	}
	return true;
}

// Remove the empty space
function trim(String)
{
   if (String == null)
   {   
   	return ("");
   }
   return String.replace(/(^\s+)|(\s+$)/g,"");
}

// Check the E-Mail Id
function isMailid(str) 
{
	var emailPat = /^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/;
	var matchArray = str.match(emailPat);
		if (matchArray == null)
		{
		alert("Invalid E-Mail Address");
		return false;
		}
}

function formCarrier()
{
	document.carrier.name.value=trim(document.carrier.name.value);
	name=document.carrier.name.value;
	if (document.carrier.name.value=="")
	{
		alert("Enter Your Name");		
		document.carrier.name.focus();		
		return false;
	}
	else
		if(!isText(name))
		{
			alert("Check Your Name");
			document.carrier.name.focus();
			return false;
		}
		
		
	phone=trim(document.carrier.phone.value);
	mobile=trim(document.carrier.mobileno.value);
	if (((phone==null)||(phone=="")) && ((mobile==null) || (mobile=="")))
	{
		//document.carrier.ph.value="?";
		alert("Enter Contact Phone No or Mobile No")
		document.carrier.phone.focus()
		return false
	}
	if(!isTelephoneNumber(document.carrier.mobileno.value))
		{
			alert("Check Contact mobile No");
			document.carrier.mobileno.focus();
			return false;
		}

	document.carrier.email.value=trim(document.carrier.email.value);
	email=trim(document.carrier.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter E-Mail Address")
		document.carrier.email.focus()
		return false
	}
	if (isMailid(email)==false)
	{
		document.carrier.email.focus()
		return false
	}

	filename=document.carrier.upload.value;
	if (filename!="")
	{
  	 	var dot = filename.lastIndexOf("."); 
		 if( dot == -1 ) return ""; 
		 	var extension = filename.substr(dot,filename.length); 
	 	 if(extension==".doc" || extension==".rtf" || extension==".pdf")
			return true;
		else
		{
			alert("Your resume should be doc or rtf or pdf file format only");
			 return false;		
		}
	}
	return true;
}
