
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
//var wint = (screen.height - h) / 2;
var wint=0;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',menubar=yes';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function NewWindow2(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
//var wint = (screen.height - h) / 2;
var wint=0;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll;
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function formatoimporte(imp) {
var pos = imp.indexOf(",");
var result;
if (pos>-1) {
   result = imp.substring(0,pos)+"."+imp.substring(pos+1,imp.length);
} else {
   result=imp;
}
return result;
}

function longitudcampo(campo,longitud) {
    if (campo.length<longitud) {
        return false;
    }
    else {
        return true;
    }
}
function validaremail(ema) {
    /* Validamos el formato de correo electrónico*/

    /* Verificamos si email tiene formato usuario@dominio. */
    var emailPat=/^(.+)@(.+)$/; 

    /* Verificamos la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; 

    /* Verificamos los caracteres que son válidos en un email */
    var validChars="\[^\\s" + specialChars + "\]"; 
    var quotedUser="(\"[^\"]*\")"; 

    /* Verificamos si el e-mail está representado con una IP vàlida */ 
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

    /* Verificamos caracteres inválidos */ 
    var atom=validChars + '+';
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

    var matchArray=ema.value.match(emailPat);
    if (matchArray==null) {
        return false;
    }
    var user=matchArray[1];
    var domain=matchArray[2];

    /* Validamos si la parte "usuario" es correcta */
    if (user.match(userPat)==null) {
    // Si no
        return false;
    }

    /* Si la dirección IP es válida */
    var IPArray=domain.match(ipDomainPat);
    if (IPArray!=null) {
        for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
                return false;
            }
        }
        return true;
    }
    var domainArray=domain.match(domainPat);
    if (domainArray==null) {
        return false;
    }
    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) { 
        return false;
    }
    if (len<2) {
        return false;
    }
    else {
        return true;
    }
}

function FechaCorrecta(dia,mes,ano) {
	var bOk=true;
	
	if ((dia=="") || (mes=="") || (ano=="")) {
		if ((dia=="") && (mes=="") && (ano=="")) {
			bOk=true;
		} else {
			bOk=false;
		}
	} else {
		if ((isNaN(dia)) || (isNaN(mes)) || (isNaN(ano))) {
			bOk=false;
		}
		if ((dia>31) || (mes>12))   {
			bOk=false;
		}
		
	}
	
	if (bOk==false) {
		alert("Incorrect date");
	}
		
	return bOk;			  
}

//Función para mostrar fecha completa
function MostrarFecha() {
	dows = new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
	months = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	now = new Date();
	dow = now.getDay();
	d = now.getDate();
	m = now.getMonth();
	y = now.getFullYear();
	document.write(dows[dow]+", "+d+" de "+months[m]+" de "+y);
}

function SuperaMaximoPalabras(frase,nummax,ilim) {
	var supera=false;
	
	vector = frase.split(" ");
	numpalab = vector.length + 1;
	
	if (ilim==false) {
		if (numpalab > nummax) {
			supera=true;
		}
	}
	return supera;		
}
function mostrar_correo(){
   usuario="info"; 
   dominio="canaldental.com"; 
   conector="@";  
   correo = usuario + conector + dominio; 
   document.write("<a class='textobuscador' href='mailto:" + correo + "'>" + correo + "</a>");
} 
