function ce_borrar(url){if(confirm('¿ Está seguro que desea borrar este elemento ?')){document.location=url;}}
function ce_addnews(url){if(confirm('¿ Está seguro que desea agregar este elemento ?')){document.location=url;}}
function ce_trim(strTxt){var pos1=0;var pos2=strTxt.length-1;var i;for(i=0;i<strTxt.length;i++){if(strTxt.charAt(i)==' ')pos1=pos1+1;else break;}if(pos1!=(pos2+1))for(i=strTxt.length-1;i>0;i--){if(strTxt.charAt(i)==' '){pos2=pos2-1;}else{break;}}return strTxt.substring(pos1,pos2+1);}
function ce_vacio(dato,msg){var valor=ce_trim(eval("document."+dato+".value"));if(valor==""){alert("Debe escribir un valor para el dato '"+msg+"'.");eval("document."+dato+".focus();");return true;}return false;}
function ce_muycorto(dato,msg,minimo){var valor=ce_trim(eval("document."+dato+".value"));if(valor.length<minimo){alert("'"+msg+"' debe tener al menos "+minimo+" caracteres.");eval("document."+dato+".value='';");eval("document."+dato+".focus();");return true;}return false;}
function ce_limite(dato,msg,minimo,maximo){var valor=eval("document."+dato+".value");if(valor<minimo||valor>maximo){alert("'"+msg+"' debe ser un valor entero entre "+minimo+" y "+maximo);eval("document."+dato+".focus();");return false;}return true;}
function ce_valid_entero(dato,msg){var strOk="0123456789";var strValor=eval('document.'+dato+'.value');if(ce_validar(strValor,strOk)){return true;}else{alert("Sólo se aceptan dígitos para el dato '"+msg+"'.");eval('document.'+dato+'.value="";');eval('document.'+dato+'.focus();');return false;}}
function ce_validar(dato,strOk){var strValor=dato;var todobien=true;strValor.toUpperCase();strOk.toUpperCase();var i=0;for(i=0;i<strValor.length;i++){if(strOk.indexOf(strValor.charAt(i))==-1){todobien=false;break;}}return(todobien);}
function ce_iguales(dato1,dato2,msg){if(eval("document."+dato1+".value==document."+dato2+".value")==false){alert("'"+msg+"' don't match each to other. Please make sure you write them correctly.");eval("document."+dato1+".value=''");eval("document."+dato2+".value=''");eval("document."+dato1+".focus()");return false;}else{return true;}}
function ce_email_invalido(dato,msg){var strValor=eval('document.'+dato+'.value');if(!ce_valid_email(strValor)){alert("'"+msg+"' must be a valid email address.");eval("document."+dato+".focus();");return true;}else{return false;}}
function ce_valid_email(s){var strOk="@_.ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";var strValor=s.toUpperCase();var i=0;var arrobas=0;for(i=0;i<strValor.length;i++){if(strOk.indexOf(strValor.charAt(i))==-1){return false;break;}if(strValor.charAt(i)=="@"){if(i<1||i==strValor.length-1){return false;}if(strValor.charAt(i-1)=="."){return false;}arrobas++;}if(strValor.charAt(i)=="."){if(i<1||i==strValor.length-1){return false;}if(strValor.charAt(i-1)=="."||strValor.charAt(i-1)=="@"){return false}}}if(arrobas!=1){return false;}return true;}

function ce_confirmar(url){if(confirm('¿ Está seguro que desea confirmar este elemento ?')){document.location=url;}}
