//CHECK ALL / UNCHECK ALL
function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
     for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
      theForm[z].checked = theElement.checked;
      }
     }
    }
	
//TRIM FUNCTION
function trim(strText) {
  // this will get rid of leading spaces
  while (strText.substring(0,1) == ' ')
   strText = strText.substring(1, strText.length);

  // this will get rid of trailing spaces
  while (strText.substring(strText.length-1,strText.length) == ' ')
   strText = strText.substring(0, strText.length-1);
  var pos=0;
  var tevePos=0;
  while(strText.indexOf("\n",pos)>-1)
  {
   tevePos=strText.indexOf("\n",pos)
   pos=tevePos+1
  }
    return strText;
}

function keyRestrict(e, validchars)
 {
  var key='', keychar='';
  key = getKeyCode(e);
  if (key == null) return true;
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();
  validchars = validchars.toLowerCase();
  if (validchars.indexOf(keychar) != -1)
  { return true;}
  if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
  { return true;}
  //alert("Plese enter a valid character.");
  return false;
 }
 function getKeyCode(e)
 {
  if (window.event)
   return window.event.keyCode;
  else if (e)
   return e.which;
  else
   return null;
 }
