// JavaScript Document
function getNumber(){
   var id = document.getElementById('ej_id').value;
   document.getElementById('ej').value = id;
   document.getElementById('forma1').submit();
}

function getArticle(cat){
   forma = document.getElementById('forma1');
   forma.action = '../'+cat+'/index.php';
   forma.submit();
}

function submitAction(acti,loc){
   var widt = (document.body.clientWidth > 950)? document.body.clientWidth : 950;

   if (acti == 'LOGIN')
     openInternal('','internalWindow',loc+'login.php?action2='+acti+'&loc='+loc,widt,300);
   else if (acti == 'LOGOUT')
     openInternal('','internalWindow',loc+'logout.php',widt,300);
}

function registro(loc){
  var widt = (document.body.clientWidth > 950)? document.body.clientWidth : 950;
  openInternal('','internalWindow',loc+'register.php?loc='+loc,widt,500);
}

function forgot(loc){
  var widt = (document.body.clientWidth > 950)? document.body.clientWidth : 950;
  openInternal('','internalWindow',loc+'forgot.php?loc='+loc,widt,300);
}

function sendRegistration(loc){
   if (!validate('name,ap_pat,mail,user,pass,cpass')){
       alert('Los campos marcados en rojo \nson obligatorios.');
	   return;
   }
   
   var mail = document.getElementById('mail').value;
   var pass = document.getElementById('pass').value;
   var cpass = document.getElementById('cpass').value;
   var error = "";
   if (!valMail(mail))
       error += 'La direccion de correo parece esta mal escrita. \n';
   if (pass != cpass)
       error += 'La confimacion de la clave no es correcta.';

   if (error == ""){
      sendContactForm('internalWindow',loc+'register.php?loc='+loc,'name,ap_pat,ap_mat,mail,user,pass,cpass,action');
      return;
   }
   alert(error);
}

function sendForgot(loc){   
   var mail = document.getElementById('mail').value;
   var error = "";

   if (!valMail(mail))
       error += 'La direccion de correo parece esta mal escrita. \n';

   if (error == ""){
      sendContactForm('internalWindow',loc+'forgot.php?loc='+loc,'mail,action');
      return;
   }
   alert(error);
}

function getCommentPage(id_not,val){
  getPageHTML('comments','../showComments.php?id_not='+id_not+'&pag='+val);
}

function addComment(id_not){
  var widt = (document.body.clientWidth > 950)? document.body.clientWidth : 950;
  openInternal('','internalWindow','../commentForm.php?id_not='+id_not,widt,600);
}

function submitComment(id_not){
  var coment = '';
  coment = document.getElementById('com').value;
  if (coment == '')
      alert('Debe introducir algo en el cuadro anterior');
  else{
      sendContactForm('comments','../showComments.php?id_not='+id_not+'&action=INSERT_COMMENT','com');
      closeInternal('internalWindow');
  }
}