//For E-Mail Validation
function isMail(emField)
{ 

var fieldValue = emField.value 
	if(fieldValue != "")
	{ 
	var atSymbol = 0
		for(var a = 0; a < fieldValue.length; a++)
		{ 
			if(fieldValue.charAt(a) == "@")
			{ 
			atSymbol++
			}
		}
		if(atSymbol > 1)
		{ 
		alert("Please enter a valid email ID") 
		emField.focus();
		return false;
		}
	
		if(atSymbol == 1 && fieldValue.charAt(0) != "@")
		{ 
		var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) 
		var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false 
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)==".")
			{
			alert("Please enter a valid email ID") 
			emField.focus();
			return false;
			}
		}
		else
		{ 
		alert("Please enter a valid email ID")
		emField.focus();
		return false ;
		}
	}
	else
	{ 
	alert("Please enter Email Address")
	emField.focus();
	return false; 
	}
return true;
}

//Check Blank
function LTrim(str) 
{
	for (var i=0; str.charAt(i)==" "; i++);
	return str.substring(i,str.length);
	
}

function RTrim(str) 
{
	for (var i=str.length-1; str.charAt(i)==" "; i--);
	return str.substring(0,i+1);
}

function Trim(str) 
{
return LTrim(RTrim(str));
}

//For Blank
function checkBlank(controlname,msg)
{
	if(Trim(controlname.value)=="")
	{
		alert(msg);
		controlname.value="";
		controlname.focus();
		return false;
	}
}

//For Numeric only
function onlyNumeric_Press($char, $mozChar) 
{ 
 if($mozChar != null) 
    { 
        if(($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $char ==  8 || $mozChar == 13)
            {
         $RetVal = true; 
            }
           else
         { 
            $RetVal = false; 
             //alert('Please enter a numeric value.'); 
          } 
 } 
 else 
 { 
 if(($char >= 48 && $char <= 57) || $char == 13) 
    {
    $RetVal = true; 
    }
 else
     { 
    $RetVal = false; 
    //alert('Please enter a numeric value.'); 
    } 
 } 
 return $RetVal; 
 } 

function onlyNumeric(val)
{
	if (isNaN(val.value)==true)
	{
		alert("Please enter only Numeric")
		val.focus();
		return false;
	}
}
