String.prototype.Trim = function(){ return this.replace(/^\s+|\s+$/g,'') }

function isFloat(iNumber){
  var isOK = true;
  var iMinus = 0;
  var iComma = 0;
  if ((iNumber == null) ||(iNumber == "")){
    isOK = false;
    return isOK; 
  }
  for (j=0; j<iNumber.length; j++) {
    if ((iNumber.substring(j,j+1) != "0") &&
        (iNumber.substring(j,j+1) != "1") &&
        (iNumber.substring(j,j+1) != "2") &&
        (iNumber.substring(j,j+1) != "3") &&
        (iNumber.substring(j,j+1) != "4") &&
        (iNumber.substring(j,j+1) != "5") && 
        (iNumber.substring(j,j+1) != "6") &&
        (iNumber.substring(j,j+1) != "7") &&
        (iNumber.substring(j,j+1) != "8") &&
        (iNumber.substring(j,j+1) != "9") &&
        (iNumber.substring(j,j+1) != ".") &&
        (iNumber.substring(j,j+1) != "-")) {
       isOK = false
     }
     if (iNumber.substring(j,j+1) == "-" ) iMinus += 1;
     if (iNumber.substring(j,j+1) == "." ) iComma += 1;
  }
  if (iMinus>1) isOK = false;
  if (iComma>1) isOK = false;
  return isOK;
}

function isEmail(sValue){
  var isOK = true;
  var iLength = sValue.length;
  var iArr = 0;
  var iDot = 0;
  if (iLength < 6){
     isOK = false;
     return isOK;
  }
  for (j=0; j<iLength; j++){
    if((sValue.substring(j,j+1) == "'") ||
       (sValue.substring(j,j+1) == "*") ||
       (sValue.substring(j,j+1) == "%") ||
       (sValue.substring(j,j+1) == ",") ||
       (sValue.substring(j,j+1) == "&") ||
       (sValue.substring(j,j+1) == "/") ||
       (sValue.substring(j,j+1) == "$") ||
       (sValue.substring(j,j+1) == "=") ||
       (sValue.substring(j,j+1) == "#") ||
       (sValue.substring(j,j+1) == "?") ||
       (sValue.substring(j,j+1) == "¿") ||
       (sValue.substring(j,j+1) == "<") ||
       (sValue.substring(j,j+1) == ">") ||
       (sValue.substring(j,j+1) == "\"")) {
      isOK = false;
     }
     if (sValue.substring(j,j+1) == "@") iArr += 1;
     if (sValue.substring(j,j+1) == ".") iDot += 1;
  }
  if (iArr != 1) isOK = false;
  if (iDot < 1) isOK = false;
  return isOK;
}

function isInteger(iNumber, iSW){
  var isOK = true;
  var iMinus = 0;
  if ((iNumber == null) ||(iNumber == "")){
    isOK = false;
    return isOK; 
  }
  for (j=0; j<iNumber.length; j++) {
    if ((iNumber.substring(j,j+1) != "0") &&
        (iNumber.substring(j,j+1) != "1") &&
        (iNumber.substring(j,j+1) != "2") &&
        (iNumber.substring(j,j+1) != "3") &&
        (iNumber.substring(j,j+1) != "4") &&
        (iNumber.substring(j,j+1) != "5") && 
        (iNumber.substring(j,j+1) != "6") &&
        (iNumber.substring(j,j+1) != "7") &&
        (iNumber.substring(j,j+1) != "8") &&
        (iNumber.substring(j,j+1) != "9") &&
        (iNumber.substring(j,j+1) != "-")) {
       isOK = false
     }
     if (iNumber.substring(j,j+1) == "-" ) iMinus += 1;
  }
  if (iNumber.substring(0,1) == "0") isOK = false
  if (iMinus>1) { 
      isOK = false;   
  }else{
    if (iMinus == 1) {
       if (iNumber.substring(0,1) != "-") { 
            isOK = false;
       }else{
         if (!iSW) isOK = false;
       }
    }
  } 
  return isOK;
}

function MoveSelToSel(s1,s2) {
  obj=document.getElementById(s1);
  if (obj.selectedIndex==-1) return;	
  for (i=0; opt=obj.options[i]; i++)
    if (opt.selected) {
    	valor=opt.value; // almacenar value
    	txt=obj.options[i].text; // almacenar el texto
    	obj.options[i]=null; // borrar el item si está seleccionado    
    	obj2=document.getElementById(s2);             		
    	opc = new Option(txt,valor);
    	eval(obj2.options[obj2.options.length]=opc);    	    	
     }	
}

function MoveSelToSelALL(s1,s2) {
  obj=document.getElementById(s1);
  var xALL = obj.length;
  for (i=0; i<xALL; i++){
        valor=obj.options[0].value; // almacenar value
    	txt=obj.options[0].text; // almacenar el texto
    	obj.options[0]=null; // borrar el item si está seleccionado    
    	obj2=document.getElementById(s2);             		
    	opc = new Option(txt,valor);
    	eval(obj2.options[obj2.options.length]=opc);    	    	
   }
}
