/*validation to check and uncheck all the checkboxes*/
 function checkUncheckAll(theElement) 
 {	//documentation for this script at http://www.shawnolson.net/a/693/
    var theForm = theElement.form, z = 0;
	
	for (k=0; k < theForm.elements.length; k++)
	{	if (theForm[k].type == 'checkbox' && theForm[k].name != theElement.name)
		{	if(theElement.checked == true)
			{	theForm[k].checked = true;	
			}
			else
			{	theForm[k].checked = false;	
			}
		}
	}	
  }
/*validation for emailid*/

function check_eid(fld)
        {
        var len_of_fld = fld.value.length;
        var fld_str = fld.value;
        var i;
        var dot_pre = false;
        var atr_pre = false;
        var atr_pos = 0;
        var dot_pos = 0;
		if (!fld.value.match(/^[0-9|@._|A-Za-z]+$/))
		{
		return 0;
		return false;
		}
        for( i = 0 ; i < len_of_fld ;i++)
         {  var ind_ch=fld_str.substring(i,i+1);


            if (ind_ch == '\@')
            {   atr_pre = true;
                atr_pos = i;
                continue;
            }
            if (ind_ch == '.')
            {   dot_pre = true;
                dot_pos = i;
                continue;
            }
         }
				 if (parseFloat(atr_pos) == 0)
                {       return 0;
                }
                if (parseFloat(atr_pos+1) == dot_pos)
                {       return 0;
                }
                if (dot_pos == parseFloat(len_of_fld-1))
                {       return 0;
                }
               if (dot_pre == true && atr_pre == true)
        {   
           return 1;
        }
        else
        {      return 0;
        }
        }
/*validation to check numbers*/
function checkNumber(numberField,fldname){
  var msg = "";
//  if(!numberField.value.match(/^[0-9]+$/||/^[.]+$/||/^[-]+$/)){
	  if(!numberField.value.match(/^[\/\0-9\.-]+$/)){
    if(numberField.value==""){
      alert("Enter value for "+fldname);
    } else {
      alert("Invalid characters for "+fldname);
    }
    numberField.select();
    numberField.focus();
	return false;		
  } 
  return true;
}

function checkAlpha(charfield,fieldname)
{
	if (!charfield.value.match(/^[a-zA-Z\'`\s]+$/))
	{
		alert("Invalid characters for " +fieldname);
			charfield.select();
		charfield.focus();
		return false;
	}
	return true;
}

function confirmdelete()
{
	if (confirm("Do you want to delete this record?"))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function paging(pg,sortorder,sorttype)
{
	  document.form1.cpage.value=pg;
	  document.form1.sort.value=sortorder;
	  document.form1.sorttype.value=sorttype;
	 document.form1.submit();
}