function isPin(item) { }

function isName(item)
{
	if (allTrim(item.value) == '')  return false;

	for ( a = 0 ; a < item.value.length ; a++)
		if (!( (item.value.substring(a,a+1) < '0' || item.value.substring(a,a+1) > '9' ) && item.value.substring(a,a+1) != '-' && item.value.substring(a,a+1) != '+' && item.value.substring(a,a+1) != ' ' && item.value.substring(a,a+1) != ',')    ) return true

    item.focus();
    alert('Please enter your name correctly!'); 
    return false;
	
}

function isEmpty(item,title)
{	
  if ( ! item.value ) 
  {
    item.focus();
	alert(title +' can not be blank !');
    return true;  
  }
  else return false;
}	

function isNumber(item,title)
{
	if ( !isEmpty(item,title) )
	{
		for ( a = 0 ; a < item.value.length ; a++)
		{
		  if ( item.value.substring(a,a+1) < '0' || item.value.substring(a,a+1) > '9' )
		  {
		    item.focus();
		    alert('Enter a valid number!'); 
		    return false;
		  }
		}
	}
	else return false;
}


function isPhone(item,title)
{
	if ( !isEmpty(item,title) )
	{
		for ( a = 0 ; a < item.value.length ; a++)
		{
		  if ( ( item.value.substring(a,a+1) < '0' || item.value.substring(a,a+1) > '9' ) && item.value.substring(a,a+1) != '-' && item.value.substring(a,a+1) != '+' && item.value.substring(a,a+1) != ' ' && item.value.substring(a,a+1) != ',')
		  {
		    item.select();
		    alert('Not a valid phone number!'); 
		    return false;
		  }
		}
	}
	else return false;
}


function isEmail(item)
{
  if ( item.value.indexOf(' ') != -1 || item.value.indexOf('.') == -1 || item.value.indexOf('.') < item.value.indexOf('@') || item.value.indexOf('@') == -1 || item.value.lastIndexOf('.') < item.value.length -4 || item.value.indexOf('.') == 0  || item.value.lastIndexOf('@') == item.value.lastIndexOf('.') - 1 )
  {
    item.select();
    alert('Not a valid email address!');
    return false;  
  }
}

// Trim leading and trailing spaces in a string
function allTrim(item)
{
var leftx = 0;
var rightx = item.length -1;
while ( item.charAt(leftx) == ' ') leftx++;
while ( item.charAt(rightx) == ' ') --rightx;
var newItem = item.substring(leftx,rightx+1);
if ( (leftx == item.length) && (rightx == -1) ) newItem ='';
return(newItem);
}