function NewWindow(mypage, w, h) {
var winl = (screen.width - w) / 2;
var wint=0;

//var param='width='+w+',height='+h+',scrollbars=yes';
PopUp(mypage,'popupLink','width='+w+',height='+h+',scrollbars=yes',1,2,2);
return document.MM_returnValue;

//winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes';
//win = window.open(mypage, winprops);
//if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function PopUp(){
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;
v11=new Array("width,left,"+v4,"height,top,"+v5);
for (i=0;i<v11.length;i++){
	v12=v11[i].split(",");
	l_iTarget=parseInt(v12[2]);
	if (l_iTarget>1||v1[2].indexOf("%")>-1){
		v13=eval("screen."+v12[0]);
		for (v6=0;v6<v2.length;v6++){
			v10=v2[v6].split("=");
			if (v10[0]==v12[0]){
				v14=parseInt(v10[1]);
				if (v10[1].indexOf("%")>-1){
					v14=(v14/100)*v13;v2[v6]=v12[0]+"="+v14;
				}
			}
			if (v10[0]==v12[1]){
				v16=parseInt(v10[1]);v15=v6;
			}
		}
		if (l_iTarget==2){
			v7=(v13-v14)/2;
			v15=v2.length;
		} else if (l_iTarget==3){
			v7=v13-v14-v16;
		}
		v2[v15]=v12[1]+"="+v7;
	}
}
v8=v2.join(",");
v9=window.open(v1[0],v1[1],v8);
if (v3){
	v9.focus();
}
document.MM_returnValue=false;
return v9;
}


function SuperaMaximoPalabras(frase,nummax) {
	var supera=false;
	
	numpalab = frase.length;
		
	if (numpalab > nummax) {
		supera=true;
	}
	
	return supera;		
}

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 (mes>12) {
			bOk=false;
		}
		if ((dia>31) || (dia>finMes(mes))) {			
			bOk=false;
		}
		
	}
	
	return bOk;			  
}

function finMes(mes) {
	var nMes=parseInt(mes,10);
	var nRes = 0;
	
	switch (nMes) {
		case 1: nRes = 31; break;
		case 2: nRes = 28; break;
		case 3: nRes = 31; break;
		case 4: nRes = 30; break;
		case 5: nRes = 31; break;
		case 6: nRes = 30; break;
		case 7: nRes = 31; break;
		case 8: nRes = 31; break;
		case 9: nRes = 30; break;
		case 10: nRes = 31; break;
		case 11: nRes = 30; break;
		case 12: nRes = 31; break;
	}
	
	return nRes;
}

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;
    }
}

