			

function OnFocus()//for text box on foucs
{onfocus="javascript:this.style.backgroundColor='#F3F6FA'";}

function OnBlur()//for text box if focus is lost
{onblur="javascript:this.style.backgroundColor=''";}




//verifying the input whether it is ''
function TxtEntered(obj)
 {
	if(document.getElementById(obj) != null)
	{
		 if (document.getElementById(obj).value.replace(/^\s+|\s+$/,'')=='')
			{
				return false;
			}
		else
			{
				 return true;
			}
	}
	else
	{
		return false;
	}
     
 }
 
 
 
 
 function ComboSelected(obj)
 {
    
  if (parseInt(document.getElementById(obj).value.replace(/^\s+|\s+$/, ''))==-1)
     {return false}
  else return true   
     
 }

 //if check box is checked
 function ChkChecked(obj)
 {
  if (document.getElementById(obj).checked)
     {return true}
  else return false   
     
 }


function CheckDateFormat(obj_Id,Field_Name)
{
    if(document.getElementById(obj_Id).value)
		{
			
			//validating for format
			var strDate = document.getElementById(obj_Id).value;
			var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4})[ ]*$/;
			var match=strDate.match(dateregex);	
			
			if (match)
				{
					var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
					if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10))
						{return "";}//true
					else
						{return  Field_Name +" ex: 01/01/2000" + ",";} 
				}
			else{return Field_Name +" ex: 01/01/2000" + ","; } 	
					 		                            
		}



}

function IsNumeric(strString)
   //  check for valid numeric strings 
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


	var chkDot = true;
   var usEmail = true;
   function validEmail(eAddr) 
   { 
      var lenSuffix = (usEmail) ? 4 : 3;
      var result = false;
      var ndxAt = ndxDot =  0;
          
      ndxAt  = eAddr.indexOf("@");
      ndxDot = eAddr.indexOf(".") ;
      ndxDot2 = eAddr.lastIndexOf(".") ;
          
      if (ndxAt < 0)   //Removed criteria for .    ||  ndxDot < 0
         return result;
      /** Commented out....  . should be allowed.  **      
      else if (chkDot && (ndxDot < ndxAt) )
         return result;
      */
      else 
           result=true;           
      return result; 
   }
   	
function Trim(TRIM_VALUE)
    {
       
        if(TRIM_VALUE.length < 1)
            {
                return"";
            }
        TRIM_VALUE = RTrim(TRIM_VALUE);
        TRIM_VALUE = LTrim(TRIM_VALUE);
        if(TRIM_VALUE=="")
            {
                return "";
            }
        else{
                return TRIM_VALUE;
            }
    } //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function Focus(obj)
		{
			if(document.getElementById(obj)!=null)
				{document.getElementById(obj).focus();}
}
