
/*
function isEmpty(field,label)
Author VP Singh
Dated 07-06-2k1.
Parameters : field-> The name of the field whose value is to be checked
			 label-> The label with that field to give the appropiate error message
Purpose : To check if the value of field is null or not.
Return Value : False if value is empty else True
*/			 

function isEmpty(field,label)
{
	if(Trim(field.value) == "")
	{
		 label = label +   "  cannot be left blank."
	     alert(label)
	     field.focus()
	     return false;
	}
	else
    {
       return true;
    }
	       
}

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function Trim(str)
Author Sandeep Bassi
Dated 27-08-2k1.
Parameters : str -> String which is to be trimmed
Purpose : To trim the spaces of string.
Return Value : Trimmed string
*/			 

function Trim(str)
{
	
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function TrimLeft(str)
Author Sandeep Bassi
Dated 27-08-2k1.
Parameters : str -> String which is to be trimmed
Purpose : To trim the spaces on the left of string.
Return Value : String with spaces trimmed from left
*/			 

function TrimLeft( str ) 
{
	var resultStr = "";
	var i = len = 0;

	if (str+"" == "undefined" || str == null)	
		return null;

	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

//-------------------------------------------------------------------------------------------------------------------------------

/* 
function TrimRight(str)
Author Sandeep Bassi
Dated 27-08-2k1.
Parameters : str -> String which is to be trimmed
Purpose : To trim the spaces on the right of string.
Return Value : String with spaces trimmed from right
*/			 


function TrimRight( str ) 
{
	var resultStr = "";
	var i = 0;
	if (str+"" == "undefined" || str == null)	
		return null;

	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
  		resultStr = str.substring(0, i + 1);
  	}
  	
  	return resultStr;  	
}
//======================================================================
