function MessageBox(_message)
{
    alert(_message);
}
function IsEmail(Expression)
{
	if (Expression == null)
		return (false);

	var supported = 0;
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) 
		return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(Expression) && r2.test(Expression));
}

	
/*****
 DetectBrowser: Return a string that contains the current 
                browser name and version used.

 Parameters:

 Returns: String
***************************************************************/
function DetectBrowser()
{
	var temp = navigator.appName;
	temp = temp.toLowerCase();
	
	if (temp == 'microsoft internet explorer')
		return 'IE'; 
	else
		return 'NS';
}

/**************************************************************
 LTrim: Returns a String containing a copy of a specified 
        string without leading spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

/**************************************************************
 RTrim: Returns a String containing a copy of a specified 
        string without trailing spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

/**************************************************************
 Trim: Returns a String containing a copy of a specified 
        string without both leading and trailing spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function Trim(String)
{
	if (String == null)
		return (false);
	return RTrim(LTrim(String));
}



	function AllowOnly(Expression,e)
    {    
	    Expression = Expression.toLowerCase();
	    Expression = Replace(Expression, 'text', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890_-,.&*:;+#/');	 
	    Expression = Replace(Expression, 'softname', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890-.+');	 //Added for NSG Software
	    Expression = Replace(Expression, 'softversion', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890.'); //Added for NSG Software
	    Expression = Replace(Expression, 'softlic', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890-');	 //Added for NSG Software	 
	    Expression = Replace(Expression, 'alphanumeric', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890');
	    Expression = Replace(Expression, 'textOnly', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ');
	    Expression = Replace(Expression, 'a..z', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ');		    
	    Expression = Replace(Expression, '0..9', '0123456789.');
	    Expression = Replace(Expression, '09', '0123456789');
	    Expression = Replace(Expression, 'phone', '0123456789 -.()');
	    Expression = Replace(Expression, 'email', '0123456789_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@');
	    Expression = Replace(Expression, 'username', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._');
	    Expression = Replace(Expression, 'remark', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._()- /.:');
	    Expression = Replace(Expression, 'password', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#@%!');
	    Expression = Replace(Expression, 'pageName', ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#@%!&$*(\")-_+\\|/?.,;:]}[{');
	    Expression = Replace(Expression, 'null', '');       //Added by me(Syed)..its for date text field....
	    Expression = Replace(Expression, '|', '');
    	
	    var key = window.event ? e.keyCode : e.which;
	    if (key == 8 || key == 0 || key == 13)
		    return true;

	    var ch = String.fromCharCode(key);
    		
	    ch = ch.toLowerCase();
	    Expression = Expression.toLowerCase();
	    var a = Expression.indexOf(ch);
    		
	    if (a == -1) 
	    {						
		    return false;
	    }	
	    else
	    {
		    return true;
	    }
    }


	

    function chkAlphaNumeric(Id ,accType ,displayString , mandatory)        //Created By Syed
    {
        var type = new Array();
        type[0] = " _-,.&*:;+#/";   //text        
        type[1] = ".";              //0..9
        type[2] = " -.()";          //phone
        type[3] = " _-.@";          //email
        type[4] = " ._";            //username
        type[5] = " ._()- /.:";     //remark
        type[6] = " #@%!";          //password
        type[7] = "0";				//09
        type[8] = " ";   //textOnly
        type[9] = " #@%!&$*(\")-_+|/?.,;:]}[{'";  //Description	 pageName
        type[10] = " .";  //Name
        type[11] = " .0123456789";  //Name        
        

	    var ValidChars = type[accType];
	    var IsTrue =true;
	    var Char;
	    var txtBox = Trim(document.getElementById(Id).value);
	    
	    if(txtBox!="")
	    {
	        for (i = 0; i < txtBox.length && IsTrue == true; i++) 
	        { 
		        Char = txtBox.charAt(i);
		        if (ValidChars.indexOf(Char) == -1) 
		        {
			        IsTrue = false;
		        }
	        }
        	
        	
        	
	        if(IsTrue == true)
	        {
	        
	            return "Invalid "+ displayString;
                return false;
	        }
	        else
            {     
		        var type1 = new Array();                
                type1[0] = "~!@$%^()|}{\"?><'[]\=`";   //text
                type1[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ~!@#$%^&*()_+|}{:\"?><,/';[]\=-`";             //0..9
                type1[2] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ~!@#$%^&*_+|}{:\"?><,/';[]\=`";                //phone
                type1[3] = "~!#$%^&*()+|}{:\"?><,/';[]\=`";                            //email
                type1[4] = "~!@#$%^&*()+|}{:\"?><,/';[]\=-`";            //username
                type1[5] = "~!@#$%^&*+|}{\"?><,';[]\=`";     //remark
                type1[6] = "~$^&*()_+|}{:\"?><,./';[]\=-`";          //password
                type1[7] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ~!@#$%^&*()_+|}{:\"?><,./';[]\=-`";  //09
                type1[8] = "1234567890~!@#$%^&*()_+|}{:\"?><,/';[]\=-`.";   //textOnly
				type1[9] = "~^><`";             //Description	 pageName			
				type1[10] = "~!@#$%^&*()_+|}{:\"?><,/';[]\=-`0123456789";  //Name
				type1[11] = "~!@#$%^&*()_+|}{:\"?><,/';[]\=-`";  //Name				
               
                var ValidChars = type1[accType];
                var IsTrue = true;               
                var Char;
                var txtBox = Trim(document.getElementById(Id).value);
                
                for (i = 0; i < txtBox.length && IsTrue == true; i++) 
                { 
                    Char = txtBox.charAt(i);
                    if (ValidChars.indexOf(Char) != -1) 
                    {
	                    IsTrue = false;
                    }
                }
            	
                if(IsTrue == false)
                {
                    return "Invalid "+ displayString;
                    return false;
                }
                else
                    return true;
            }
	    }   //end if(txtBox!="")
	    else if(mandatory == 'y')
	    {
			return "Enter "+ displayString; 
	    }
	    else
	    {
			return true;
	    }
    }   //function end

	function udfReplaceAll(str , txt1 , txt2)		//Created by SYED
	{
	
		var strReplaceAll = str;
		var intIndexOfMatch = strReplaceAll.indexOf(txt1);

		while (intIndexOfMatch != -1)
		{
			strReplaceAll = strReplaceAll.replace(txt1, txt2 )
			intIndexOfMatch = strReplaceAll.indexOf(txt1);
		}
		return strReplaceAll;
	}

