//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 );
}

function logout(){
	FB.Connect.logout( onLogoutHandler );
}

function share(){
	var template_data = {"post-title":"THE FLASHFORWARD EXPERIENCE","post-url":"http://www.flashforwardexperience.com","comment-text":"What will you see?","images":[{"src":"http://www.flashforwardexperience.com/images/flashforward_mosaic.jpg","href":"http://www.flashforwardexperience.com"}]}
	
	FB.Connect.showFeedDialog(130301454188, template_data);
	
	var axel = Math.random() + "";
	var a = axel * 10000000000000;
	
	var newIFrame=document.createElement('iframe');
	newIFrame.src='http://fls.doubleclick.net/activityi;src=1249573;type=falll959;cat=flash310;ord=1;num=' + a + '?';
	newIFrame.width="1";
	newIFrame.frameborder="0";
	newIFrame.height="1";
	var scriptNode=document.getElementById('DoubleClickFloodlightTag-1');
	scriptNode.parentNode.insertBefore(newIFrame,scriptNode);

}

//Event Handlers
function onLoginHandler(){
	flashCallBack( "onLogIn" );

	var axel = Math.random() + "";
	var a = axel * 10000000000000;
	
	var newIFrame=document.createElement('iframe');
	newIFrame.src='http://fls.doubleclick.net/activityi;src=1249573;type=falll959;cat=flash221;ord=1;num=' + a + '?';
	newIFrame.width="1";
	newIFrame.frameborder="0";
	newIFrame.height="1";
	var scriptNode=document.getElementById('DoubleClickFloodlightTag-1');
	scriptNode.parentNode.insertBefore(newIFrame,scriptNode);
}

function onLogoutHandler(){
	flashCallBack( "onLogOut" );
}

//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]);
	}else{
		document[as_swf_name][func]();
	}
}