function checkemail(email){
 var str=email.value;
// var filter=/^.+@.+\..{2,3}$/
 var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

 if (filter.test(str))
    testresults=true;
 else {
    testresults=false;
}
 return (testresults);
}

/*function validateEmail( strValue) {
	var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	return objRegExp.test(strValue);
}*/
function isInteger(s)
{
     reInt = new RegExp(/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/);
     if (!reInt.test(s)) {
          return false;
     }
	return true;
} 
function isEmpty(strValue)
{
	var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return false;
   }
   return true;
}
function trimAll(strValue)
{
var objRegExp = /^(\s*)$/;
    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}
function isOnlyString(strValue)
{
	var objRegExp = /^[a-zA-Z]+$/;
	return objRegExp.test(strValue);
}
function isValidCity(strValue)
{
	var objRegExp = /^[a-zA-Z ]+$/;
	return objRegExp.test(strValue);
}
function validateValue( strValue, strMatchPattern ) {
var objRegExp = new RegExp( strMatchPattern);
 //check if string matches pattern
 alert(objRegExp.test(strValue));
 return objRegExp.test(strValue);
}
function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}
function alphanumericTribe(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			if(hh==32)
			{}
			else{
			 return false;
			 }
		  }
		}
 return true;
}
function isUserNameValid(strValue)
{
	var res = "";
	if(isEmpty(strValue))
		res = "\nPlease Enter Username";
	else if(!alphanumeric(strValue)  || isInteger(strValue) )
		res = "\nUsername not valid. Please enter valid username";
	else if(strValue.length<4)
		res = "\nPlease Enter Username of Minimum 4 Characters";
	return res;		
}
function isTribeNameValid(strValue)
{
	var res = "";
	if(isEmpty(strValue))
		res = "\nPlease Enter Tribename";
	else if(!alphanumericTribe(strValue)  || isInteger(strValue) )
		res = "\nTribename not valid. Please enter valid Tribename";
	else if(strValue.length<4)
		res = "\nPlease Enter Tribename of Minimum 4 Characters";
	return res;		
}

function validUSZip(strValue)
{
	var regZipcode = /^([0-9]){5}(([ ]|[-])?([0-9]){4})?$/;
	return regZipcode.test(strValue); 
}
