function detallePopUp(id) {
	mywindow = window.open ("detalle.php?id="+id,
							"Detalle"+id,
							"location=0,status=0,scrollbars=1,toolbar=0,width=600,height=550");
} 
function submitSearch() {
  var query = document.forms['searchform'].query.value;

  if(query.length < 3) {
    inlineMsg('query','Ingrese una b&uacute;squeda de al menos 3 caracteres',2);
  } else {
  	document.forms['searchform'].submit();
  }
}
function submitPoll() {
  document.forms['pollform'].submit();
}

function submitRecommend() {
  var tunombre = document.forms['recommendform'].tunombre.value;
  var sunombre = document.forms['recommendform'].sunombre.value;
  var suemail = document.forms['recommendform'].suemail.value;
  
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  
  if(tunombre == "") {
    inlineMsg('recommendtunombre','Ingresa tu nombre',2);
  } else if(!tunombre.match(nameRegex)) {
    inlineMsg('recommendtunombre','Ingresa tu nombre',2);
  } else if(sunombre == "") {
    inlineMsg('recommendsunombre','Ingresa su nombre',2);
  } else if(!sunombre.match(nameRegex)) {
    inlineMsg('recommendsunombre','Ingresa su nombre',2);
  } else if(suemail == "") {
    inlineMsg('recommendsuemail','Ingresa el email de destino',2);
  } else if(!suemail.match(emailRegex)) {
    inlineMsg('recommendsuemail','Ingresa el email de destino',2);
  }  else if(tuemail == "") {
    inlineMsg('recommendtuemail','Ingresa tu email',2);
  } else if(!tuemail.match(emailRegex)) {
    inlineMsg('recommendtuemail','Ingresa tu email',2);
  } else { 
  	document.forms['recommendform'].submit();
  }
}
function submitInvitation() {
  var tunombre = document.forms['inviteform'].tunombre.value;
  var sunombre = document.forms['inviteform'].sunombre.value;
  var suemail = document.forms['inviteform'].suemail.value;
  var tuemail = document.forms['inviteform'].tuemail.value;
  
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  
  if(tunombre == "") {
    inlineMsg('invitetunombre','Ingresa tu nombre',2);
  } else if(!tunombre.match(nameRegex)) {
    inlineMsg('invitetunombre','Ingresa tu nombre',2);
  } else if(sunombre == "") {
    inlineMsg('invitesunombre','Ingresa su nombre',2);
  } else if(!sunombre.match(nameRegex)) {
    inlineMsg('invitesunombre','Ingresa su nombre',2);
  } else if(suemail == "") {
    inlineMsg('invitesuemail','Ingresa el email de destino',2);
  } else if(!suemail.match(emailRegex)) {
    inlineMsg('invitesuemail','Ingresa el email de destino',2);
  }  else if(tuemail == "") {
    inlineMsg('invitetuemail','Ingresa tu email',2);
  } else if(!tuemail.match(emailRegex)) {
    inlineMsg('invitetuemail','Ingresa tu email',2);
  } else { 
  	document.forms['inviteform'].submit();
  }
}


function checkContactForm(form) {
  var query = form.name.value;
  var email = form.email.value;
  var message = form.mailmessage.value;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  
  if(name == "") {
    inlineMsg('name','<?=LANG_ENTER_A_NAME?>',2);
    return false;
  }
  if(!name.match(nameRegex)) {
    inlineMsg('name','<?=LANG_ENTER_A_NAME?>',2);
    return false;
  }
  if(email == "") {
    inlineMsg('email','<?=LANG_ENTER_MAIL?>',2);
    return false;
  }
  if(!email.match(emailRegex)) {
    inlineMsg('email','<?=LANG_ENTER_MAIL?>',2);
    return false;
  }
  if(message == "") {
    inlineMsg('mailmessage','<?=LANG_ENTER_INFO?>');
    return false;
  }
  if(message.match(messageRegex)) {
    inlineMsg('mailmessage','<?=LANG_ENTER_INFO?>');
    return false;
  }
  return true;
}
function showElement(id) {
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = '';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}
