//methods for handling the authentication and registration aspects of the site

var authentication =
{  
	invokedFrom : null,
	loginSuccessCalls: null,
	showLogin : function(control, successCalls)
	{
	    //alert("show login");

		this.invokedFrom = control;
		this.loginSuccessCalls = successCalls;
		var iframe = modalWindow.buildIFrame(350,350, gyzorkBaseUrl + "login.html");
		modalWindow.show(iframe,"#000000",350,350);
	},
	loginSuccesssful : function()
	{
	    authenticated = true;
	    
		if(this.loginSuccessCalls!=null)
		{
			modalWindow.close();
			window.authenticated = true;
			if(window.parent && (typeof window.parent.authenticated !="undefined"))
				window.parent.authenticated =true;
			eval(this.loginSuccessCalls);
		}
		else{
			window.parent.location.href = window.parent.location.href;
		}
	},
	showForgotPassword : function()
	{
		var iframe = modalWindow.buildIFrame(350,350, gyzorkBaseUrl +  "forgotPassword.html");
		modalWindow.show(iframe,"#000000",350,350);
	},
	
	
	logout : function( control)
	{
            new XHR( {method: 'post', onSuccess: authentication.goHome, async: false } ).send("login.html", "logout=true");
            window.location.href=CTXT_ID+'/home.html';
	},

	goHome: function()
	{
		window.parent.location.reload( false );
	},

	
	showRegistration : function (control)
	{
		if(control!=null)
			this.invokedFrom = control;
		var iframe = modalWindow.buildIFrame(500,400, gyzorkBaseUrl + "signup.html");
		modalWindow.show(iframe,"#000000",500,400);
	
	},

	showAccountSettings : function(control){
		var iframe = modalWindow.buildIFrame(500,400, gyzorkBaseUrl + "changeAccountSettings.html");
		modalWindow.show(iframe,"#000000",500,400);
	}
}














