function login (email, password, template, arg)
{
	function successHandler (obj) 
	{
		//alert (obj.responseText);
		if (obj.responseText.indexOf ("SUCCESS") != -1)
		{
			self.location.replace ("?" + arg);
		}
		else if (obj.responseText.indexOf ("USER") != -1)
		{
			alert ('That email ID is not registered with us. Please try again or sign up FREE below.');
			//self.location.replace ("?template=signup");
			loadData ('includes/widgets/login.wid.php', 'WelcomeContainer',arg);
		}
		else if (obj.responseText.indexOf ("PASSWORD") != -1)
		{
			alert ("That is not the correct password for that email ID. Please try again or click the 'Forgot Login' button.");
		}
	}
						
	YAHOO.util.Connect.asyncRequest ("POST", 'includes/ajax/session.ajax.php',
		{
			success:successHandler,
			failure:successHandler
		},
		'form_action=login&email=' + email + '&password=' + password + '&template=' + template);
}

function logout (user_id, template) 
{
	function successHandler (obj) 
	{
		self.location.replace ("?template=splash");
	}
		
	YAHOO.util.Connect.asyncRequest ("POST", 'includes/ajax/session.ajax.php',
		{
			success:successHandler,
			failure:successHandler
		},
		'form_action=logout&user_id=' + user_id + '&template=' + template);
}


