// JavaScript Document

function trim (str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}

function begin(){
	document.getElementById('maquina').value = trim(window.opener.document.getElementById('machine').innerHTML);
}

function validateContact(form){
	if(form.nombres.value == ""){
		alert("You must fill in the name field !!!");
		form.nombres.focus();
		return false;
	}
	if(form.correo.value== ""){
		alert("You must fill in the email field !!!");
		form.correo.focus();
		return false;
	} else {
		correo = validateEmail(form.correo.value);
		if(correo==false){
			form.correo.focus();
			return correo;	
		}
	}
	if(form.telefono.value== ""){
		alert("You must fill in the phone field !!!");
		form.telefono.focus();
		return false;
	}
	if(form.mensaje.value== ""){
		alert("You must fill in the message field !!!");
		form.mensaje.focus();
		return false;
	}	
	return true;
}

function validateEmail(email){
	var m = unescape(email);
	var i = 1;
	var mLength = m.length;
	while ((i < mLength) && (m.charAt(i) != "@")){
		i++
	}
	if ((i >= mLength) || (m.charAt(i) != "@")){
		alert("Mail invalid");
		return false;
	} else {
		i += 2;
	}
	while ((i < mLength) && (m.charAt(i) != ".")){
		i++
	}
	if ((i >= mLength - 1) || (m.charAt(i) != ".")){
		alert("Mail invalid");
		return false;
	}	
}








//###############################################



/**
* Funcion que valida la longitud de las contrase?as
*
*/
function validate_pass(txt_box)
{
passwd=txt_box.value;

if (passwd.length < 6)
 {
    alert("La contraseņa debe tener 8 o mas caracteres!");
    return false;
 }
else
 {
 return true;
 }
}


/**
*
*Funcion que confirma si se desea borrar un item
*/
//
/*function if_borrar(confirm_txt, location)
{
  if (confirm(confirm_txt))
  {
    window.location=location;
  }else{
  	
  }
}*/

