//returnd true if password and confirm pasword are same.. 
function StringsAreNotSame(string1, string2) {
	if (Trim(string1) == Trim(string2))
		{return false;}
	
	return true;
}

//removes blank spaces from a string 
function Trim(x) {
	while (x.substring(0,1) == ' ') 
		{x = x.substring(1);}
 
	return x;
}

// check if there is anything; if empty, returns false; otherwise returns true;
function IsStringNotEmpty(strVal) {
	if (!strVal) return false;

    var Chars = "0123456789-+.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*|,\":<>[]{}`\';()&@$#%\\/";

	for (var i = 0; i < strVal.length; i++) {
		if (Chars.indexOf(strVal.charAt(i)) > -1)
			{return true;}
		}
		
	return false;
}

// Purpose		: check for character in a number - TRUE if not a number
// Author		: Philip Ng
// Modified Date: 21 FEB 02
function IsNotNumber(strVal) 
{
    if (!strVal) return true;
		    
    var Chars = "0123456789-+.";// character allow to be allow in a number string
	var bolFirstPos = true;		// +/- sign can only appear at the beginning of a number, not in the middle or at the end
	var bolNums	= false;		// flag to check if there is number in string at all.
	var Nums = "0123456789";	// check if user has put any number, not just (+/-) sign
	var TotalDot = 0;			// keep track how many dot occurences; maximum is 1 dot
	var TotalSign = 0;			// keep track how many sign (+/-) occurences; maximum is 1 sign

	for (var i = 0; i < strVal.length; i++) 
	{

		if (Chars.indexOf(strVal.charAt(i)) == -1)
			return true;

		// double check if there is a number in the string at all, not just sign (+/-)
		if (Nums.indexOf(strVal.charAt(i))!= -1)
			bolNums = true;

		// check +/- sign. if first position, it is ok; 
		// if not first position, return true to indicate isNaN
		if ( ((strVal.charAt(i) == '+') || (strVal.charAt(i) == '-')) && (!bolFirstPos) )
			return true;

		// check (+/-) sign. if more than 1, return true to indicate isNaN
		if ( ((strVal.charAt(i) == '+') || (strVal.charAt(i) == '-')) && (++TotalSign > 1) )
			return true;
		
		// check . sign. if more than 1, return true to indicate isNaN
		if ( (strVal.charAt(i) == '.') && (++TotalDot > 1) )
			return true;
				
		// set flag to indicate index checking is not at the beginning of string anymore
		// no more accepting +/- sign in any position of a number string
		bolFirstPos = false;
	}		


	if (bolNums)
		return false	// this is a valid string
	else
		return true		// something wrong
} 

//check for a number in a string  - true if all characters
function IsNotString(strVal) {
	if (!strVal) return true;
		
	var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

	for (var i = 0; i < strVal.length; i++) {
		if (Chars.indexOf(strVal.charAt(i)) == -1)
			{return true;}
		}
		
	return false;
} 

//valid email check .. returns false if the string contains invalid variables
function EMailAddressIsValid(strVal) {
	var strV1;
	var strV2;
	      
	if (!strVal) 
		{return true;}
	
	var iChars = "*|,\":<>[]{}`\';()&$#%' '";
	   
	//check for @ , dot and 3 valid characters in email ..
	   
	strV1 = strVal.indexOf("@");
	strV2 = strVal.indexOf(".");
	    
	if (strV1!=-1 && strV2!=-1) 
		{return false;}

	return true;
} 


// validate strString1 with strInvalidList, if any invalid character found in strString1 with strInvalidList
// return true; if not found any invalid, return false
function InvalidCharacter(strInvalidList, strString1) {

	for (var i = 0; i < strString1.length; i++)
		if (strInvalidList.indexOf(strString1.charAt(i)) > 0)
			return true;

	return false;
} 


function DisplayError(el, strMsg) 
{
	alert(strMsg);
	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 echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if(str!="")
		{
			if (str.indexOf(at)==-1){
			   return false
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   return false
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    return false
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
			    return false
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			    return false
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
			    return false
			 }
	
			 if (str.indexOf(" ")!=-1){
			    return false
			 }
		}	
 		 return true					
	}


