﻿function trim(objTxtValue) {

	txtValue	= new String();
	txtValue1	= new String();
	var i		= 0;
		
	txtValue	= objTxtValue;
	
	if (txtValue.length == 0) {
		return txtValue;
	} else {
		while (((txtValue.lastIndexOf(' ') + 1) == txtValue.length) && (txtValue.lastIndexOf(' ') != 0)) {
			txtValue1	= (txtValue.slice(0,txtValue.lastIndexOf(' ')));
			txtValue	= txtValue1;
		}
		while (txtValue.indexOf(' ') == 0) {
			txtValue1	= (txtValue.slice(1,txtValue.length));
			txtValue	= txtValue1;
		}
		return txtValue;
	}
}

function TrimString(str)
{  
    while(str.charAt(0) == (" ") )
      {  str = str.substring(1);
      }
    while(str.charAt(str.length-1) == " " )
      {  str = str.substring(0,str.length-1);
      }
      return str;
}

function isValidEmail(oEMailField)
{
   var AEM = TrimString(oEMailField.value);
   
    oEMailField.value = AEM;
    var aemailadd = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;

    if(!AEM.toLowerCase().match(aemailadd))
    {
        oEMailField.focus();
        alert("Enter proper Email Id");
        return false;
    }
    else
    {
        return true;
    } 
}
function allowNumbersOnly() 
{
   if (!((event.keyCode > 47  && event.keyCode < 58 ) || event.keyCode == 8 ) && event.keyCode != 13 && event.keyCode != 27)
   {
		event.keyCode =0;
   }
}