//Local Variable with Flash Content id. default = flashcontent
var as_swf_name = "flashContent";

//Initialize Facebook
function fbInit(pAsSwfName, pApi_key, pReceiver){
	as_swf_name = pAsSwfName;
	FB.init(pApi_key, pReceiver);
}

//JavaScript Connect methods
function login(){
	FB.Connect.requireSession( onLoginHandler );
}

//Event Handlers
function onLoginHandler(){
	flashCallBack( "onLogIn" );
}

// Internet Explorer and Mozilla-based browsers refer to the Flash application 
// object differently.
// This function returns the appropriate reference, depending on the browser.
function getMyApp(appName) {
    if (navigator.appName.indexOf ("Microsoft") !=-1) {
        return window[appName];
    } else {
        return document[appName];
    }
}


//Method to dispatch an Event to Flash
function flashCallBack ( func ) {
	if( arguments.length > 1 ){
		//document[as_swf_name][func]( Array.prototype.slice.call(arguments).slice(1)[0]);
		getMyApp(as_swf_name)[func](Array.prototype.slice.call(arguments).slice(1)[0]);
	}else{
		//document[as_swf_name][func]();
		getMyApp(as_swf_name)[func]();
	}
}