function validaNumeroEnter(evento){codigoTecla=(document.all)?evento.keyCode:evento.which;if((codigoTecla<48||codigoTecla>57)&&(codigoTecla!=8)&&(codigoTecla!=13)&&(codigoTecla!=0)&&(codigoTecla!=45))return false;}
function validaNumeroEnter2(evento,inpt){codigoTecla=(document.all)?evento.keyCode:evento.which;var virgul=inpt.value;virgul=(virgul.indexOf('.')>=0?true:false);if((codigoTecla<48||codigoTecla>57)&&(codigoTecla!=8)&&(codigoTecla!=13)&&(codigoTecla!=0)&&(codigoTecla!=46||(codigoTecla==46&&virgul))&&(codigoTecla!=45||(codigoTecla==45&&inpt.value!="")))return false;}
function validaEmail(email, msg){email='%'+email+'%';var re=/\%[a-z\-\_0-9]+(\.[a-z\-\_0-9]+)*@[a-z\-\_0-9]+(\.[a-z\-\_0-9]+)+\%/i;if(!email.match(re)){ alert(msg);return false;}return true;}
function clearSelectBox(obj){ while(obj.options.length>1){ obj.options[1]=null;}}
function checkDate(obj){ if(obj.value){ if(obj.value!=''){ var dats=new String(obj.value);var dats2=dats.split("/");if(parseInt(dats2[0])>1900&&parseInt(dats2[1])>0&&parseInt(dats2[1])<13&&parseInt(dats2[2])>0&&parseInt(dats2[2])<32){ return true;}else{ obj.value='0000/00/00';}}else{ obj.value='0000/00/00';}}return false;}
function inArray(needle, stack){ for(i=0;i<stack.length;i++){ if (needle==stack[i]) return true;}return false;}
function getAllSelected(obj){ var res='';for(i=0;i < obj.options.length;i++){ if (obj.options[i].selected) res=res+(res!=''?',':'')+obj.options[i].value;}return res;}
function checkVal(obj,val,msg){ if(obj.value==val){ return true;}else{ alert(msg);obj.focus();}return false;}
function isEmpty(obj,msg){ if(obj.value!=''){ return false;}else{ alert(msg);obj.focus();}return true;}
function selectIsValid(obj,minIdx,msg){ if(obj.selectedIndex>=minIdx){ return true;}else{ alert(msg);obj.focus();}return false;}
function valida_nif(nif){if (nif.length!=9){ return false;}var str=new String(nif);var sum=0;var c='';var r=0;for(r=0;r<8;r++){ c=str.substr(r,1);if (isNaN(parseInt(c))){ return false;}c=parseInt(c);sum+=c*(10-r-1);}r=sum%11;r=(r<2?0:11-r);return (parseInt(str.charAt(8))==r);}
