Размер файла: 2.48Kb
- //Cuenta atrбs con recarga opcional
- function CuentaAtras(valor,recargar) {
- if(valor!=0) tiempo=valor-1;
- horas=Math.floor(valor/3600);
- valor-=3600*horas;
- min=Math.floor(valor/60);
- valor-=60*min;
- seg=valor;
- horas=(horas<10)? "0"+horas : horas;
- min=(min<10)? "0"+min : min;
- seg=(seg<10)? "0"+seg : seg;
- horas=(horas=="00")? "" : horas+":";
- min=(min=="00" && horas=="")? "" : min+":";
- seg=(seg=="00" && min=="")? "Booommm!!" : seg+"''";
- document.clock.CuentaAtras.value=horas+min+seg;
- if(seg=="Booommm!!" && recargar==1) window.location.reload();
- setTimeout("CuentaAtras(tiempo)",1000);
- }
- //Abre nueva ventana centrada en el centro de la pantalla
- function ventana(theURL,winName,winWidth,winHeight) {
- var w = (screen.width - winWidth)/2;
- var h = (screen.height - winHeight)/2 - 50;
- features = 'directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=no,width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
- window.open(theURL,winName,features);
- }
-
- function submitOnce(theform) {
- if (document.all || document.getElementById) {
- for(i=0 ; i < theform.length ; i++) {
- var tempobj = theform.elements[i];
- if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
- tempobj.disabled=true;
- }
- }
- }
- }
-
- function validate(obj,modo,porDefecto, min) {
- var texto = obj.value;
- do {
- texto = texto.replace(/\|\|/,"|");
- } while(/\|\|/.test(texto));
- if(modo=="url") {
- if(texto.substr(0,7)!="http://" && texto.substr(0,8)!="https://") texto = "http://" + texto;
- texto = texto.replace(/ /,"");
- }
- if(modo=="email") {
- if(!/(.+)@(.+)\.(.+)/.test(texto)) texto = porDefecto;
- if(/[\s]+/.test(texto)) texto = porDefecto;
- if(texto.indexOf('@') != texto.lastIndexOf('@')) texto = porDefecto;
- var dominio = texto.substring(1+texto.lastIndexOf('.'));
- if( dominio.length>3 || dominio.length<2) texto = porDefecto;
- }
- if(modo=="icq") {
- do {
- texto = texto.replace(/[^0-9]/,"");
- } while(/[^0-9]/.test(texto));
- }
- if(modo=="number") {
- do {
- texto = texto.replace(/[^0-9]/,"");
- } while(/[^0-9]/.test(texto));
- if(texto=='') texto = porDefecto;
- }
- if(modo=="numberMin") {
- do {
- texto = texto.replace(/[^0-9]/,"");
- } while(/[^0-9]/.test(texto));
- if(texto=='') texto = porDefecto;
- if(parseInt(texto) < min) texto = porDefecto;
- }
- if(modo=="text") {
- if(texto=='') texto = porDefecto;
- }
- obj.value = texto;
- }