var as_swf_name ='icovia';

function fbInit(swfName, apiKey,receiverName){

try
{

	FB.init(apiKey,receiverName);

 }
 catch(e)
 {
 alert(e.message);
 }
  
}

function showPermissionDialog(){
FB.Connect.showPermissionDialog("publish_stream", onPermissionHandler, false);

}
function onPermissionHandler(response){
	flashCallBack("onShowPermissionDialog");
}
function login(){

    FB.Connect.ifUserConnected(onLoginHandler, requireSession); 
	
}
function requireSession()
{
    FB.Connect.requireSession( onLoginHandler, true );
}
function killLogin()
{
    FB.Connect.logout(onLoginHandler);
}
function onLoginHandler(){

  flashCallBack( "onConnected" );
 
}
function streamPublish(message, attachment, action_links, target_id)
{
	FB.Connect.streamPublish(message, attachment, action_links, null, null, onStreamPublishHandler, true);

}
function onStreamPublishHandler(postid, fbevent)
{
	//debugger;
	flashCallBack("onStreamPublish",postid,  fbevent);
	//alert(fbevent);

}
function flashCallBack ( func ) {
 
  try
  {
		var arguments = flashCallBack.arguments
		if( arguments.length > 1 ){
			try
			{
			  
			  document[as_swf_name][func]( arguments[1], arguments[2]);
			}
			catch(e)
			{
				document.getElementById(as_swf_name)[func]( arguments[1], arguments[2]);
		  
			}
			  
  }	  else{
		var flash = document[as_swf_name];
		try
		{
			flash[func]();
		}
		catch(e)
		{
			var embed = document.getElementById(as_swf_name);
			embed[func]();
		}
			
	  }
  }
  catch(e)
  {
	 alert (e.message);
  }
}
