function verifyFields(obj,lg){
  
  var cont = 0;
  
  var objele = obj.elements;
  
  for(i = 0; i < objele.length; i++){
    
    if(objele[i].value == '')
      cont++;
  }
  
  if(document.getElementById('email1')){
  if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email1').value))){
      if(lg=='pt'){
          alert("Campo de e-mail incorrecto!")
        } else {
          alert("Invalid e-mail!")
        }
      document.getElementById('email1').focus()
      return false;
  }
  }
  
  if(document.getElementById('email2')){
  if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email2').value))){
      if(lg=='pt'){
          alert("Campo de e-mail incorrecto!")
        } else {
          alert("Invalid e-mail!")
        }
      document.getElementById('email2').focus()
      return false;
  }
  }
  
  if(cont > 0){
    if(lg=='pt'){
      alert('Os campos do formulário tem de ser todos preenchidos!');
    } else {
      alert('All the fields must be filled!');
    }
    return false;
  } else {
    return true;
  }
  
  
}

function verifyRegFields(obj,lg){
  
  var cont = 0;
  
  var cont2 = 0;
  
  var objele = obj.elements;
  
  for(i = 0; i < objele.length; i++){
    
    var xs = objele[i].name.substring(0,1);
    
    if(objele[i].value == '' && xs == 'R')
      cont++;
      
    if(objele[i].name == 'R[password][2]' && document.getElementById('pass2').value != document.getElementById('pass1').value)
      cont2++;
    
  }
  
  if(document.getElementById('email1')){
    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email1').value))){
        if(lg=='pt'){
          alert("Campo de e-mail incorrecto!")
        } else {
          alert("Invalid e-mail!")
        }
        document.getElementById('email1').focus()
        return false;
    }
  }
  
  if(cont2 > 0){
    if(lg=='pt'){
      alert('As passwords não são iguais, confirme novamente!');
    } else {
      alert('The passwords do not confirm, please try again!');
    }
    return false;
  }
  
  if(cont > 0){
    if(lg=='pt'){
      alert('Tem de preencher todos os campos de preenchimento obrigatório!');
    } else {
      alert('You need to fill the requested fields!');
    }
    return false;
  } else {
    return true;
  }
}

function check(sid){

  var state = document.getElementById(sid).checked;
  
  if(state == true){
    document.getElementById('submit2').style.display = 'block';
  } else {
    document.getElementById('submit2').style.display = 'none';    
  }  

}

function openApp(URL) {
 
  var _top    = parseInt((screen.width/2) - (1024/2));
  var _left   = parseInt((screen.height/2) - (768/2)); 
    		  	     
  var _scroll = (screen.height > 800)? 0 : 'yes'; 
  
  window.open(URL, 'SempreID', 'toolbar=0, scrollbars=' + _scroll + ', location=0, statusbar=0, menubar=0, resizable=yes, width=1020, height=750, top=' + _top + ', left=' + _left);

}

function change_menu(obj, imgnormal, imghover, cont){

  var intobj = document.getElementById('menu' + obj);
  var imgobj = document.getElementById('img' + obj);
  
  if(!YAHOO.util.Dom.hasClass(intobj, 'selected') && !YAHOO.util.Dom.hasClass(intobj, 'selected_ini')){
  
    if(YAHOO.util.Dom.hasClass(intobj, 'hover') || YAHOO.util.Dom.hasClass(intobj, 'hover_ini')){
      if(cont == 1){ YAHOO.util.Dom.removeClass(intobj, 'hover_ini'); } else { YAHOO.util.Dom.removeClass(intobj, 'hover'); }
      imgobj.src = imgnormal;
      YAHOO.util.Dom.setStyle(intobj, 'cursor', 'normal');
    } else {
      if(cont == 1){ YAHOO.util.Dom.addClass(intobj, 'hover_ini'); } else { YAHOO.util.Dom.addClass(intobj, 'hover'); }
      imgobj.src = imghover;
      YAHOO.util.Dom.setStyle(intobj, 'cursor', 'pointer');
    }
  
  }

}
