/*********************************************************
		Title Validation.js
		Author : Harish Chauhan
		Date   : 24 Aug,2004
		This file contains the functions for input data validation
		at client side with the help of java script.
*********************************************************/

//  this function checks the email format is correct or not
//  and return true or false accordingly.
	function is_email(email)
	{
		if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
			return false;
		return true;
	}


//  this function checks the given number is signed/unsigned number
//  and return true or false accordingly.
	function is_number(number)
	{
		if(!number.match(/^[\-\+0-9e1-9]+$/))
			return false;
		return true;
	}


//  this function checks the given number is unsigned number
//  and return true or false accordingly.
	function is_unsign_number(number)
	{
		if(!number.match(/^[\+0-9]+$/))
			return false;
		return true;
	}
	
//  this function checks the given string is alphanumeric(-_) word or not
//  and return true or false accordingly.
	function is_alpha_numeric(str)
	{
		//var strMatch = "/^[A-Za-z0-9 \-_\/]+$/";
		//strMatch = "/^[A-Za-z0-9 \-_\/\\,.<>|'`;:+=()[]{}*^#@!~]+$/";
		
		if(!str.match(/^[A-Za-z0-9 \-_\/.<>|`;:+=\(\)\[\]\{\}*^#@!~]+$/))	//forbidden charecters: ?"&%$\,'
			return false;
		return true;
	}
	function is_valid_description(str)
	{	
		if(!str.match(/^[A-Za-z0-9 \-_\/,.<>|`;:+=\(\)\[\]\{\}*^#@!~\r\n]+$/))	//include: newline(\n)	//forbidden charecters: ?"&%$\'
			return false;
		return true;
	}


//  this function checks the given string is empty or not
//  and return true or false accordingly.
	function is_empty(str)
	{
  		 str=trim(str);
		 if ((str.length==0)||(str==null))
			return true;
		 return false;
	}

//	this function remove leading and trailing spaces
	function trim(inputString) 
	{
		// Removes leading and trailing spaces from the passed string.
		if (typeof inputString != "string") { return inputString; }
		var retValue = inputString;
		var ch = retValue.substring(0, 1);
		
		while (ch == " ")
		{ // Check for spaces at the beginning of the string
		  retValue = retValue.substring(1, retValue.length);
		  ch = retValue.substring(0, 1);
		}
		ch = retValue.substring(retValue.length-1, retValue.length);
		while (ch == " ")
		{ // Check for spaces at the end of the string
		  retValue = retValue.substring(0, retValue.length-1);
		  ch = retValue.substring(retValue.length-1, retValue.length);
		}
		return retValue; // Return the trimmed string back to the user
	}	
/******************************************************************************************************************/	
	function isInteger(s)
	{   var i;
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}	
/*******************************************************************************************************************
        -*- File: Validation.js
        -*- modify: S. M. Quamruzzaman Rahmani (Byron)
        -*- Date: 20.07.2006
*********************************************************/
	function contain_unexpected_string(str)
	{
		if(!str.match(/^[^\û\ù\ÿ\Ö\Ü\¢\£\"]+$/))	//from alt+150-->to->alt+156 reserved  & (") is for error
		{
			return true;
		}
		return false;
	}
	

