﻿
/**
* 
* Flash : Common Methods
* 
*/
function getSwf(swfName)
{
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		return window[swfName];
	} 
	else {
		return document[swfName];
	}
}

/**
* 
* Flash : Login Methods
* 
*/

function loginRequest(user, pass)
{
	
	var response;
	if (user == null || pass == null)
	{
		response = getFormatedResponse("error", "Error: Login attempt failed.");
		getSwf("americanCrew").loginResponse(response);
		return;
	}

	//call login method
	var retMessage = FlashLogin(user,pass);
	if (retMessage==""){
		response = getFormatedResponse("success", "Login successful.");
		getSwf("americanCrew").loginResponse(response);
	}else{
		response = getFormatedResponse("error", retMessage);
		getSwf("americanCrew").loginResponse(response);
	}
	
}


function getFormatedResponse(type, message)
{
	var response = '<response type="'+type+'">';
			response += '<message>'+message+'</message>';
		response += '</response>';
	return response;
}

function checkLoginStatus()
{
	getSwf("americanCrew").loginStatus(checkFlashLoggedIn());
}