//
//	This class represent the page the user is viewing. It's the controller on
//	the client-side of the view.
//
//
PeopleDetailsPage = function()
{
	Unyk.Web.UI.Page.call(this);
};

YAHOO.lang.extend(PeopleDetailsPage, Unyk.Web.UI.Page,
{

	//*************************************************************************
	//
	//	Fields
	//
	//*************************************************************************


	//*************************************************************************
	//
	//	Events
	//
	//*************************************************************************

	//
	//	Handles the Page Load event.
	//
	Page_Load : function(e, args)
	{
		$("txtLogin").focus();

		if (PageLewt.ProfilMode == 2)
		{
			this.DisplayCoords();
		}
		if (PageLewt.ProfilMode == 1)
		{
			this.DisplayProfile();
		}

		// Damn Opera Fix
		if (PageLewt.IsOpera)
		{
			if (PageLewt.ProfilMode == 2) {
				setTimeout("PeopleDetailsPage.DisplayProfile();", 50);
				setTimeout("PeopleDetailsPage.DisplayCoords();", 50);
			}
			if (PageLewt.ProfilMode = 1) {
				setTimeout("PeopleDetailsPage.DisplayCoords();", 50);
				setTimeout("PeopleDetailsPage.DisplayProfile();", 50);
			}
		}

		Unyk.Tools.AddCtrlToTrack($("txtLoginPassword"), this.loginCapsError);
	},


	//*************************************************************************
	//
	//	Private API
	//
	//*************************************************************************

	//
	//
	//
	ProcessPassword : function()
	{
		if ($("txtLogin").value.indexOf('@') > 0)
		{
			document.location.href = "/MyInfos/LostPassword.asp?AutoSend=1&<%= m_Session.toQS()%>&Email=" + $("txtLogin").value;
		}
		else
		{
			document.location.href = "/MyInfos/LostPassword.asp?<%= m_Session.toQS()%>";
		}
	},


	//
	//
	//
	ProcessLogin : function()
	{
		var erreur = "";

		if (trim($("txtLogin").value) == "")
		{
			erreur = erreur + PageLewt.Texts.ForgotEmail;
		}

		if (trim($("txtLoginPassword").value) == "")
		{
			erreur = erreur + PageLewt.Texts.ForgotPassword;
		}

		if (erreur == "")
		{
			$("frmLogin").submit();
		}
		else
		{
			alert(erreur);
			$("txtLogin").focus();
		}
	},


	//
	//
	//
	loginCapsError : function(tg)
	{
		var txt = $("login-CAPS-warning");
		var tmptg = $("txtLoginPassword");

		if (tg == tmptg && Unyk.Tools.IsCapslockOn())
		{
			txt.style.visibility = "visible";
			txt.style.display = "block";
		}
		else
		{
			txt.style.visibility = "hidden";
			txt.style.display = "none";
		}
	},


	//
	//
	//
	DisplayProfile : function()
	{
		ShowThis("ONGLETPROFILEON");
		ShowThis("ONGLETCOORDSOFF");
		HideThis("ONGLETPROFILEOFF");
		HideThis("ONGLETCOORDSON");

		ShowThis("PROFILEMODE1");
		HideThis("PROFILEMODE2");
		FixFooter();
	},


	//
	//
	//
	DisplayCoords : function()
	{
		ShowThis("ONGLETCOORDSON");
		ShowThis("ONGLETPROFILEOFF");
		HideThis("ONGLETCOORDSOFF");
		HideThis("ONGLETPROFILEON");

		ShowThis("PROFILEMODE2");
		HideThis("PROFILEMODE1");
		FixFooter();
	}

});

// Makes AspPageTemplatePage a singleton.
PeopleDetailsPage = new PeopleDetailsPage();
