function ShowSubMenu()
{
	document.getElementById(window.event.srcElement.id + "Menu").style.visibility = "visible";
}

function getCookiesEmail()
{
	    var i;
	    var aNamesValues = document.cookie.split("; ");
    	
	    for(i = 0; i < aNamesValues.length; i++)
	    {
		    var name = aNamesValues[i].split("=")[0];
		    var value = aNamesValues[i].split("=")[1];

		    if(name == "EMail" && document.getElementById("txtEMail").disabled == false)
		    {
			    document.getElementById("txtEMail").value = value;
		        cambiaCampoEMail();
		    }
	    }
}

function LoginOnload()
{
    if (document.getElementById("txtEMail")) 
    {
	    getCookiesEmail();
	    if(document.location.search.toUpperCase().indexOf("VE=S") < 0)
	    {
//	      window.setTimeout("Master_LanzaBocadillo()", 10000, "javascript");
	    }
	}
}

function Master_LanzaBocadillo()
{
  //Miramos si el FRAME general del login mide 0
//  if(document.getElementsByName("Login")[0].height > 0 && document.getElementById("IframeLogin").style.display == "inline")
//  {
//	  if(document.getElementById("txtEMail").value == "")
//	  {
//		  muestraBocadillo(145, 10, "Debe introducir aqu&iacute; su direcci&oacute;n de e-mail y su clave de acceso para acceder a la parte privada de la web.", "");
//	  }
//	  else
//	  {
//	    if(document.getElementById("txtPassword").value == "")
//	    {
//   		  setTimeout(Master_LanzaBocadilloRecPass, 10000, "javascript");
//	    }
//	  }
//	}
}

function Master_bocadilloError(title, message)
{
//  var x, y;

//  if(title == "El usuario no existe")
//  {
//    message = "Verifique que la direcci&oacute;n de e-mail escrita es correcta. Si a&uacute;n no se ha dado de alta, pulse el bot&oacute;n \"alta\".";
//    x = 152;
//    y = 7;
//  }
//  else
//  {
//    if(title == "La clave de acceso es incorrecta")
//    {
//      title = "La clave es incorrecta";
//      message = "Si no recuerda su clave pulse \"recuperar clave de acceso\" para recibir en breve una nueva clave por e-mail.";
//      x = 152;
//      y = 69;
//    }
//    else
//    {
//      if(title == "El usuario no dispone de aplicaciones contratadas")
//      {
//        title = "Sin aplicaciones";
//        message = "Puede ser que este usuario haya sido dado de alta con un c&oacute;digo de cliente desactualizado.";
//        x = 152;
//        y = 7;
//      }
//    }
//  }
//  Master_muestraBocadilloError(x, y, title, message, "", "SO");
}

function Master_LanzaBocadilloRecPass()
{
//  //Miramos si el FRAME general del login mide 0
//  if(document.getElementsByName("Login")[0].height > 0 && document.getElementById("IframeLogin").style.display == "inline")
//  {
//    if(document.all.tags('IFRAME')[1].currentStyle.display != 'none')
//    {
////		var mainframe = buscaFrame("principal");
////		if (mainframe != undefined)
////		{
////			if (mainframe.parent != undefined)
//		      parent.muestraBocadillo(125, 89, "Si ha olvidado su clave de acceso, puede solicitar una nueva pulsando este bot&oacute;n.", "");
////		}
//    }
//  }
}

function buscaFrame(sNom)
{
	var miWin = window;
	while(miWin.frames[sNom] == null && miWin != miWin.parent)
	{
		miWin = miWin.parent;
	}
	return(miWin.frames[sNom]);
}

function paginaPrincipal(s1)
{
	buscaFrame("WorkArea").document.location.replace(s1);
}

function recargaMarcar()
{
	var f1 = buscaFrame("Arriba");
	if(f1.document.frames[0] != null)
	{
		f1.document.frames[0].document.location.replace(f1.document.frames[0].document.location.href);
		//recargaFav();
	}
	else
	{
		window.setTimeout("recargaMarcar()", 50, "javascript");
	}
}

function recargaFav()
{
	var f1 = buscaFrame("Arriba");
	if(f1 != null)
	{
		f1.document.frames["iFrameTitulo"].document.frames["Favoritos"].document.location.replace("WebFavoritos.aspx");
	}
	else
	{
		window.setTimeout("recargaFav()", 50, "javascript");
	}
}

function pulsaAceptar()
{
	if(event.keyCode == "13")
	{
        document.getElementById("inpAceptar").focus();
	    document.getElementById("inpAceptar").click();
	}
}

function muestraAltaNuevoUsuario()
{
  var aP = new Array(1);
  aP[0] = "Alta de nuevo usuario";
  aP[1] = "../CondicionesRegistro.html?alta";
  
  showModalDialog("A3SupportPages/A3Modal.html", aP, "status: no; center: yes; dialogWidth: 600px; dialogHeight: 600px;");
}

function muestraRecuperarClaveAcceso()
{
  var aP = new Array(1);
  aP[0] = "Recuperar clave de acceso";
  aP[1] = "../WebRecuperarPassword.aspx?M=" + document.getElementById("txtEMail").value;
  //alert(aP[1]);
 //JSGO top.showModalDialog("A3SupportPages/A3Modal.html", aP, "status: no; center: yes; dialogWidth: 530px; dialogHeight: 240px;");
  showModalDialog("A3SupportPages/A3Modal.html", aP, "status: no; center: yes; dialogWidth: 530px; dialogHeight: 260px;");
}

function cambiaCampoEMail()
{
    document.getElementById("txtFakeEMail").style.display = "none";
    document.getElementById("txtEMail").style.display = "inline";
    document.getElementById("txtEMail").select();
}

function cambiaCampoEMail2()
{
  if(document.getElementById("txtEMail").value == "")
  {
    document.getElementById("txtEMail").style.display = "none";
    document.getElementById("txtFakeEMail").style.display = "inline";
  }
}

function cambiaCampoPass()
{
  document.getElementById("txtFakePass").style.display = "none";
  document.getElementById("txtPassword").style.display = "inline";
  document.getElementById("txtPassword").select();
}

function cambiaCampoPass2()
{
  if(document.getElementById("txtPassword").value == "")
  {
    document.getElementById("txtPassword").style.display = "none";
    document.getElementById("txtFakePass").style.display = "inline";
  }
}

function preValidar()
{
  var retValue = true;

  if(trim(document.getElementById("txtEMail").value) == "")
  {
    retValue = false;
    alerta("El e-Mail no ha sido introducido.");
  }
  return(retValue);
}
