// TO REMOVE LEADING AND TRAILING SPACES OF A GIVEN STRING
// will return a string after removing trailing and leading spaces from the string.

function rowOverEffect(object) {
  if (object.className == 'dataTableRow') object.className = 'dataTableRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'dataTableRowOver') object.className = 'dataTableRow';
}

function trimSpaces(strValue) 
{
	var intNoOfCharctrs = strValue.length;
	var strLspace = "";	
	var strTrimmed="";
	strLspace=strValue;
	while (strLspace.charAt(0)==" ")
	{
		strLspace=strLspace.substring(1,intNoOfCharctrs);
	}
	strTrimmed=trimTrailingSpaces(strLspace);
	return strTrimmed;
}//end of trimSpaces() method

function trimTrailingSpaces(aValue) 
{
	var bValue=reverse(aValue); //pass the value to Reverse method
	var strValue = "";
	var retValue="";
	var intNoOfCharctrs = bValue.length;
	strValue=bValue;
	while (strValue.charAt(0)==" ")//checks whether the charceter is space
	{
		strValue=strValue.substring(1,intNoOfCharctrs);
	}
	strValue=reverse(strValue);
	return strValue;
}//end of trimTrailingSpaces() method

//Internally called in TrimTrailingSpaces, for reversing the String
function reverse(aValue)
{
	var intIndex;
	var strValue="";
	var intNoOfCharctrs = aValue.length;
	for (intIndex = 0; intIndex <=  intNoOfCharctrs; intIndex++)
	strValue = aValue.substring(intIndex, intIndex+1) + strValue;
	return strValue;//reverse the field value and send to again trailing space method
}//end of reverse() method

// METHOD FOR URLENCODING FOR A GIVEN VALUE
// this will return a urlencoded string for space and ampersand
function urlencode(s)
{
	var result = "";
	for(i=0;i<s.length;i++)
	{
		if(s.charAt(i) == " " )
		{
			result += "+";
		}
        else if(s.charAt(i) == "&")
		{
		    result +="%26"
		}
	    else
		{
			result += s.charAt(i);
		}
	}
	return result;
}
// end of urlencode() method

// METHOD FOR CHECKING THE EXISTANCE OF ANY SPECIAL CHARACTERS IN A STRING
// this will return false if any of the special characters are present in the string else returns true.
function checkSplChar(name){
 var splchar=new Array('/','*','%','-','!','@','#','$','%','^','&','+','|','=','{','}','[',']','<','>','\'','\"','\\','\,','.',';',':','~','`','(',')','?');

       for(i=0;i < name.length;i++)
          {
              for(j=0;j < splchar.length;j++)
                {
                    if(name.charAt(i)==splchar[j])
                       {
                           return false;
                        }
                }
          }
		  return true; 
}
// end of checkSplChar() method.

// METHOD FOR CHECKING THE EXISTANCE OF SELECTED SPECIAL CHARACTERS IN A STRING
// this will return false if any of the special characters are present in the string else returns true.
function checkSplChar_Few(name){
 var splchar=new Array('/','*','!','#','$','&','{','}','[',']','<','>','\'','\"',';',':','(',')','?','`');

       for(i=0;i < name.length;i++)
          {
              for(j=0;j < splchar.length;j++)
                {
                    if(name.charAt(i)==splchar[j])
                       {
                           return false;
                        }
                }
          }
		  return true; 
}
// end of checkSplChar_Few() method.

// METHOD FOR CHECKING THE EXISTANCE OF ANY SPECIAL CHARACTERS AND NUMBERS IN A STRING
// this will return false if any of the special characters and numbers are present in the string else returns true.
function checkSplChar_Num(name){
 var splchar=new Array('0','1','2','3','4','5','6','7','8','9','/','*','%','-','!','@','#','$','%','^','&','+','|','=','{','}','[',']','<','>','\'','\"','\\','\,','.',';',':','~','`','(',')','?');

       for(i=0;i < name.length;i++)
          {
              for(j=0;j < splchar.length;j++)
                {
                    if(name.charAt(i)==splchar[j])
                       {
                           return false;
                        }
                }
          }
		  return true; 
}
// end of checkSplChar_Num() method.

// METHOD FOR CHECKING THE BLANK SPACES IN A GIVEN STRING
// this will return false if any blank space exists else returns true.
function checkBlank(name){
	for(i=0;i < name.length;i++)
	{
		if(name.charAt(i) == " " )
		{
			return false;
		}
	}
	return true;
}
// END OF checkBlank() method.	

//VALIDATE EMAIL ADDRESS.......
function isEmail(email) 
{
  if ((email.indexOf('@', 0) == -1) || email.indexOf('.') == -1) 
  {
    return false;
  }
 else { return true; }
}




// to change the color of a row
function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
} // end of the 'setPointer()' function


// Check the value is in Numeric or not
	function IsNumeric(str)	
	 {
	 	var no=true,i,s1;	
		var Chr = "0123456789._-";
		for (i = 0; i < str.length ; i++)
      	{ 
      		s1= str.charAt(i); 
      		if (Chr.indexOf(s1) == -1) 
         	{
         		no = false;
         	}
      	}
		if(no==false)
		{
			return false;
		}
		else
		{
			return true;
		}
	 }
	 

