
function isBlank(obj,mess)
{	
   var s = obj.value; 
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    alert(mess);
    obj.focus();    
    return true;
}


function isNotBlank(obj)
{	
   var s = obj.value; 
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return true;
    }
    return false;
}


function isNumber(obj,mess)
{
   data = obj.value;
   var num = 0;
   for(var i = 0; i < data.length; i++) {   
   num = parseInt(data.charAt(i));
   if(!(num >= 0) || !(num <= 9))  {
   	 alert(mess);
   	 obj.focus();
     return false;
   } }
   return true;
}

function isFormatedNumber(obj,mess)
{
   data = obj.value;
   for(var i = 0; i < data.length; i++) {   
	    var c = data.charAt(i);	    
    	if((c != ',') && isNaN(c))	{
	   	 alert(mess);
	   	 obj.focus();    	
    	  return false;    	    	    	
    	}
   	}
   	return true;    	    	    	
}

function isDecimal(obj,numPres,decPres,mess)
{   
   data = obj.value;   
   if(isNaN(data)) {
    	alert(mess);
    	obj.focus();
    	return false;	   
   }
   var numPart = 0;
   var decPart = 0;
   if(data.indexOf('.') != -1) {
      numPart = data.substring(0,data.indexOf("."));
      decPart = data.substring(data.indexOf(".")+1,data.length);
    } else
    numPart = data;
   if(numPart.length > (parseInt(numPres) - parseInt(decPres)))   {
    	alert(mess);
    	obj.focus();
    	return false;	
   }   
   return true;                 
}

function checkLimit(obj,leg,mess)
{
  if(obj.value.length >= leg)
  {
     alert(mess);
     obj.focus();
     return false;
  }
  return true;
}


function validateList(obj,def,mess)
{
    if(getSel(obj) == def)
    {
      alert(mess);
  	  obj.focus(); 	
   	  return false;
    }
    return true;
}

function isValidEmail(obj,mess)
{
   if(obj ==null)
    return false;
    var checkString = obj.value;
    var emailFormat = /^[a-zA-Z0-9_\.]+\@{1}([a-zA-Z0-9\-]+\.){1,3}[a-zA-Z]{2,4}$/;
	regExpEmail= new RegExp(emailFormat);
	if(regExpEmail.test(checkString)==false)
	{
	  	alert(mess);
  		obj.focus();	
		return true;
	} else 	
		return false;
}
function isChecked(obj,mess)
{
   if(obj ==null)
   return false;
	var ckct = obj.length;
	var flag = false;
	var isMultiple = true;
	if(ckct == null || ckct == 'undefined')
	{
  	   isMultiple = false;
	   if(obj.checked)
	   flag = true;
	}
	if(isMultiple)
	for(var i=0;i<ckct;i++)
	{
	    if(obj[i].checked)
	    {
	      flag = true;
	      break;
	    }
	}
	if(!flag)
	alert(mess);
	return flag;	
}

function selectObj(optObj,selText)
{ 
  if(optObj != null && selText != null)  {
	  var optCt = optObj.options.length;
	  for(var i=0;i<optCt;i++)  {
		  if(optObj.options[i].value == selText)	  {
			  optObj.selectedIndex = i;
			  return;
		  }
	  }
  }
}
function selectObjTxt(optObj,selText)
{ 
  if(optObj != null && selText != null)  {
	  var optCt = optObj.options.length;
	  for(var i=0;i<optCt;i++)  {
		  if(optObj.options[i].text == selText)	  {
			  optObj.selectedIndex = i;
			  return;
		  }
	  }
  }
}

function getSel(opt)
{
  if(opt.options.selectedIndex != -1)
  return  opt.options[opt.options.selectedIndex].value;
  else
  return  '';
}
function getSelTxt(opt)
{
  if(opt.options.selectedIndex != -1)
  return  opt.options[opt.options.selectedIndex].text;
  else
  return  '';
}
