/*
Añadir en el form despues del accion 
 onSubmit="return Validar(document['form1'])"

 Valido que mail tenga forma de mail y que telefono sean 9 numeros
 Tambien que los campos obligatorios (nombre, empresa, telefono y email) no queden vacios
 Valido que numero pcs sea numero
*/
   function Validar(form){
        empresa=form.empresa.value;		// empresa es obligatorio
        if (empresa == "")  { alert("Necesitamos un empresa para contactar");
                form.empresa.focus(); return false;}

        nombre=form.nombre.value;
        if (nombre == "")  { alert("Necesitamos un nombre para contactar");
                form.nombre.focus(); return false;}

        invalidChars = " /:,;"
        email=form.email.value;
        telefono=form.telefono.value;
        if (email == "") {                                              // cannot be empty
                alert("Necesitamos un correo donde contactar");
                form.email.focus();
                return false;
        }

        for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters?
                badChar = invalidChars.charAt(i)
                if (email.indexOf(badChar,0) > -1) {
                        alert("Por favor, complete su email correctamente.");
                        form.email.focus();
                        return false;
                }
        }
        atPos = email.indexOf("@",1)                    // there must be one "@" symbol
        if (atPos == -1) {
                alert("Por favor, complete su email correctamente.");
                form.email.focus();
                return false;
        }
        if (email.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
                alert("Por favor, complete su email correctamente.");
                form.email.focus();
                return false;
        }
        periodPos = email.indexOf(".",atPos)
        if (periodPos == -1) {                                  // and at least one "." after the "@"
                alert("Por favor, complete su email correctamente.");
                form.email.focus();
                return false;
        }
        if (periodPos+3 > email.length) {               // must be at least 2 characters after the "."
                alert("Por favor, complete su email correctamente.");
               form.email.focus();
                return false;
        }

        invalidChars="qazwsxedcrfvtgbyhnujmik,ol.pñ-´`+!·$%&/()=?¿Ç;:_"
        for (i=0; i< invalidChars.length; i++) {        // does it contain any invalid characters?
                badChar =  invalidChars.charAt(i)
                if (telefono.indexOf(badChar,0) > -1) {
                        alert("Caracteres invalidos.");
                        form.telefono.focus();
                        return false;
                }
        }

                if (telefono.length < "6") {
                        alert("Por favor, complete el telf. (sin espacios).");
                        form.telefono.focus();
                        return false;
                }
                if (telefono.length > "11") {
                        alert("Por favor, complete el telf. (sin espacios).");
                        form.telefono.focus();
                        return false;
                }

	numero_pcs=form.numero_pcs.value;
	if(numero_pcs.length > 0){
	    invalidChars="qazwsxedcrfvtgbyhnujmik,ol.pñ-´`+!·$%&/()=?¿Ç;:_"
		  for (i=0; i< invalidChars.length; i++) {        // does it contain any invalid characters?
			badChar =  invalidChars.charAt(i)
			if (numero_pcs.indexOf(badChar,0) > -1) {
		         alert("No entiendo cuantos PCs");
			     form.numero_pcs.focus();
				 return false;
           }
		}
	}

    form.submit();
    return true;
   }

function checklogin()
{
	if(document.frmlogin.username.value == "")
	{
		alert("Necesitamos un nombre para usuario");
		document.frmlogin.username.focus();
		return false;
	}
	if(document.frmlogin.password.value == "")
	{
		alert("Necesitamos un nombre para password");
		document.frmlogin.password.focus();
		return false;
	}
	if(document.frmlogin.username.value == "ofiwex" && document.frmlogin.password.value == "ofiwex")
	{
		window.open("privado.html");
	}
	else
	{
		alert("Error, vuelva a intentarlo");
		return false;
	}
	
	return true;
}