/**
 * This is purely used to interact between JS and the SWF, there should be no
 * product specific cases in here, nor should there be anything that isn't generic
 * 
 * with this class you will need teh 'swfobject' class, jQuery, 
 **/
var TwitterAPI = {
		bIsReady : false,				//whether or not the SWF is ready to go!
		bSWFExists: false,
		SWF_ID: "TwitterLibraryApp",	//name of the app
		SWF_SRC: sImgPath+"/twitter/WebfettiTwitter.swf", 
//		SWF_SRC: "http://imgfarm.com/images/fwp/wf/twitter/WebfettiTwitter.swf", 
		oConfig: {},					//config file that will be requested from the SWF
		callBackObj: {},				//object to hold callbacks
		oIsReadyCallBack: function(){} ,
		//Generic error function, we can set it up later if we need
		genericErrorFunc:function(a_jsonObj){alert("There is an error with Twitter. Please try again later.");},
		createContainerElement: function (a_swfID){var dd = document.createElement('div');	dd.id = a_swfID;document.body.appendChild(dd); $("#"+a_swfID).css({position:"absolute", top:"-3200px", left:"-2000px"});return {element:dd, height:'100', width:'100',extraParams:{}}},
		/**
		 * The init function, this function will check to see if the swf exists
		 * and if it doesn't create a new SWF
		 **/
		init: function(a_configObj, a_callback, a_swfID, a_swfSrc, a_createContainerOverride){
			if($("#"+this.SWF_ID).length > 0){
				if(!TwitterAPI.bIsReady){
					TwitterAPI.bIsReady = true;		
				}
				if(typeof(a_callback) == "function") TwitterAPI.oIsReadyCallBack = a_callback;
				TwitterAPI.oIsReadyCallBack();
				return;
			}
			
			if(a_swfID != 'undefined' && a_swfID != null) TwitterAPI.SWF_ID = a_swfID;
			if(a_swfSrc != 'undefined' && a_swfSrc != null) TwitterAPI.SWF_SRC = a_swfSrc;
			if(typeof(a_callback) == "function") TwitterAPI.oIsReadyCallBack = a_callback;
			if(typeof(a_createContainerOverride) == "function" && a_createContainerOverride != null) TwitterAPI.createContainerElement = a_createContainerOverride;
			 	
			TwitterAPI.setConfig(a_configObj);
			TwitterAPI.createTwitterLib(TwitterAPI.SWF_ID);
		},		
		/**
		 * Set config
		 **/
		setConfig:function(a_val){
			TwitterAPI.callBackObj.ErrorCB = TwitterAPI.genericErrorFunc;
			if(a_val != null)
				TwitterAPI.oConfig = a_val;
			else
				alert("Improper Config Passed to Twitter API");
		},
		/**
		 * This should create a new SWF
		 **/
		createTwitterLib: function(a_swfID){
			if($("#"+this.SWF_ID).length > 0)
				return;
			var obj = TwitterAPI.createContainerElement(a_swfID);
			swfobject.embedSWF(this.SWF_SRC, a_swfID, obj.width, obj.height, "9.0.0", false, false,{allowscriptaccess:'always'});//, wmode:'transparent'} ); //this dosn't work in FF, it seems that the 'getconfig' func is never called from flash, not sure whats going on but it can't be good :(
		},
		
		/**
		 * Gets the SWF, be it in FF or IE
		 **/
		getSWF: function(a_id){
			if (navigator.appName.indexOf("Microsoft") != -1) {
	             return window[a_id];
	         } else {
	             return document[a_id];
	         }
				
			return document.getElementById(a_id);
		},
		/** 
		 * get the config, called from flash.  we set a Timeout for 200ms so that
		 * by the time the callback is called, the config will have been loaded.
		 **/
		getConfig: function(){
			TwitterAPI.bIsReady = true;
			setTimeout(function(){TwitterAPI.oIsReadyCallBack()},200);
			return TwitterAPI.oConfig;
		},
		checkForErrors: function(a_obj){
			try{
				if(a_obj.error_code){
					return true;
				}
			}catch(e){}
			return false;
		},
		/** 
		 * All the receive functions that need to be accomplished
		 **/
		recieve_getPublicTimeline: function(a_json){ 
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getPublicTimelineCB(unescape(a_json));
		},
		recieve_getHomeTimeline: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getHomeTimelineCB(unescape(a_json));
		},
		recieve_getMentions: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getMentionsCB(unescape(a_json));
		},
		recieve_getSpecificStatus: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getSpecificStatusCB(unescape(a_json));
		},
		recieve_setStatusUpdate: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.setStatusCB(unescape(a_json));
		},
		recieve_deleteStatus: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.deleteStatusCB(unescape(a_json));
		},
		recieve_getDirectMessages: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getDirectMessagesCB(unescape(a_json));
		},
		recieve_getDirectMessagesSent: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getDirectMessagesSentCB(unescape(a_json));
		},
		recieve_sendNewDirectMessage: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')')))) 
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.sendNewDirectMessageCB(unescape(a_json));
		},
		recieve_deleteFavoriteStatus: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.deleteFavoriteStatusCB(unescape(a_json));
		},
		recieve_setNewFavoriteStatus: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.setNewFavoriteStatusCB(unescape(a_json));
		},
		recieve_getFavoriteStatuses: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getFavoriteStatusesCB(unescape(a_json));
		},
		recieve_deleteDirectMessage: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.deleteDirectMessageCB(unescape(a_json));
		},
		recieve_endSession: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.endSessionCB(unescape(a_json));
		},
		recieve_getUserShow: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.getUserShowCB(unescape(a_json));
		},
		recieve_setProfileImage: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.setProfileImageCB(unescape(a_json));
		},
		recieve_setBackgroundImage: function(a_json){
			if(TwitterAPI.checkForErrors(eval(unescape('('+a_json+')'))))
				TwitterAPI.callBackObj.ErrorCB(eval(unescape('('+a_json+')')));
			TwitterAPI.callBackObj.setBackgroundImageCB(unescape(a_json));
		},
		/**************************************************************************************
		***************************************************************************************
		********************  This is the block that you won't change, it  ********************  
		********************  should always be the same.  If you need to   ********************
		********************  change your SWF name, change it above.	   ********************
		***************************************************************************************
		**************************************************************************************/
		/**
		 * Returns the 20 most recent statuses from non-protected users who have 
		 * set a custom user icon. The public timeline is cached for 60 seconds 
		 * so requesting it more often than that is a waste of resources.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-public_timeline
		 */	
		getPublicTimeline: function(a_callBackFunc){
			TwitterAPI.callBackObj.getPublicTimelineCB = a_callBackFunc;
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getPublicTimeline();
		},
		
		/**
		 * Returns the 20 most recent statuses posted by the authenticating user 
		 * and that user's friends. This is the equivalent of /timeline/home on 
		 * the Web.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline
		 * 
		 * @param a_startingID		[optional] an ID to start at, used to find 'new' tweets
		 * @param a_maxID			[optional] Finds statuses that are < than this.  used for finding old tweets
		 * @param a_count			[optional] Number of tweets you want to retrieve
		 * @param a_page			[optional] the page of results to retrieve
		 */	
		getHomeTimeline: function(a_callBackFunc, a_startingID, a_maxID, a_count, a_page){
			TwitterAPI.callBackObj.getHomeTimelineCB = a_callBackFunc;
			if(a_startingID == "undefined" || a_startingID == null) a_startingID = null; 
			if(a_maxID == "undefined" || a_maxID == null) 			a_maxID = null; 
			if(a_count == "undefined" || a_count == null) 			a_count = 20; 
			if(a_page == "undefined" || a_page == null) 			a_page = null; 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getHomeTimeline(a_startingID, a_maxID, a_count, a_page);
		},
		
		/**
		 * Returns the 20 most recent mentions (status containing @username) for 
		 * the authenticating user. 
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-mentions
		 * 
		 * @param a_startingID		[optional] an ID to start at, used to find 'new' tweets
		 * @param a_maxID			[optional] Finds statuses that are < than this.  used for finding old tweets
		 * @param a_count			[optional] Number of tweets you want to retrieve
		 * @param a_page			[optional] the page of results to retrieve
		 */		
		getMentions: function(a_callBackFunc, a_startingID, a_maxID, a_count, a_page){
			TwitterAPI.callBackObj.getMentionsCB = a_callBackFunc;
			if(a_startingID == "undefined" || a_startingID == null) a_startingID = null; 
			if(a_maxID == "undefined" || a_maxID == null) 			a_maxID = null; 
			if(a_count == "undefined" || a_count == null) 			a_count = 20; 
			if(a_page == "undefined" || a_page == null) 			a_page = null; 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getMentions(a_startingID, a_maxID, a_count, a_page);
		},
		
		/**
		 * Returns a single status, specified by the id parameter below.  The 
		 * status's author will be returned inline.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0show
		 * 
		 * @param a_id				an ID to show
		 */
		getSpecificStatus: function(a_callBackFunc, a_statusID){
			TwitterAPI.callBackObj.getSpecificStatusCB = a_callBackFunc;
			if(a_statusID == "undefined" || a_statusID == null){		alert("You need a statusID");		return;} 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getSpecificStatus(a_statusID);
		},
		
		/**
		 * Updates the authenticating user's status.  Requires the status 
		 * parameter specified below.  Request must be a POST.  A status 
		 * update with text identical to the authenticating user's current 
		 * status will be ignored to prevent duplicates.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0update
		 *  
		 * @param a_status			your status that you would like to update with
		 * @param a_replyStatusID	[optional] the ID of an existing status that the update is in reply to.  This only works if the users name is  in the status update
		 * @param a_latitude		[optional] Lat for geo tagging
		 * @param a_longitude		[optional] Long for geo tagging
		 */		
		setStatus: function(a_callBackFunc, a_status, a_replyStatusID, a_lat, a_long){
			TwitterAPI.callBackObj.setStatusCB = a_callBackFunc;
			if(a_status == "undefined" || a_status == null){				alert("You need a Status");		return;} 
			if(a_replyStatusID == "undefined" || a_replyStatusID == null) 	a_replyStatusID = null; 
			if(a_lat == "undefined" || a_lat == null) 			a_lat = null; 
			if(a_long == "undefined" || a_long == null) 			a_long = null; 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).setStatusUpdate(a_status, a_replyStatusID, a_lat, a_long);
		},
		
		/**
		 * Destroys the status specified by the required ID parameter.  The 
		 * authenticating user must be the author of the specified status.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0destroy
		 *  
		 * @param a_id				an ID to delete
		 */		
		deleteStatus: function(a_callBackFunc, a_id){
			TwitterAPI.callBackObj.deleteStatusCB = a_callBackFunc;
			if(a_id == "undefined" || a_id == null){				alert("You need a ID to delete");		return;} 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).deleteStatus(a_id);
		},
		
		/**
		 * Returns a list of the 20 most recent direct messages sent __to__ the 
		 * authenticating user.  The XML and JSON versions include detailed 
		 * information about the sending and recipient users.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages
		 * 
		 * @param a_startingID		[optional] an ID to start at, used to find 'new' tweets
		 * @param a_maxID			[optional] Finds statuses that are < than this.  used for finding old tweets
		 * @param a_count			[optional] Number of tweets you want to retrieve
		 * @param a_page			[optional] the page of results to retrieve
		 */		
		getDirectMessages: function(a_callBackFunc, a_startingID, a_maxID, a_count, a_page){
			TwitterAPI.callBackObj.getDirectMessagesCB = a_callBackFunc;
			if(a_startingID == "undefined" || a_startingID == null) a_startingID = null; 
			if(a_maxID == "undefined" || a_maxID == null) 			a_maxID = null; 
			if(a_count == "undefined" || a_count == null) 			a_count = 20; 
			if(a_page == "undefined" || a_page == null) 			a_page = null; 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getDirectMessages(a_startingID, a_maxID, a_count, a_page);
		},
		
		/**
		 * Returns a list of the 20 most recent direct messages sent __by__ the 
		 * authenticating user.  The XML and JSON versions include detailed 
		 * information about the sending and recipient users.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages%C2%A0sent
		 * 
		 * @param a_startingID		[optional] an ID to start at, used to find 'new' tweets
		 * @param a_maxID			[optional] Finds statuses that are < than this.  used for finding old tweets
		 * @param a_count			[optional] Number of tweets you want to retrieve
		 * @param a_page			[optional] the page of results to retrieve
		 */	
		getDirectMessagesSent: function(a_callBackFunc, a_startingID, a_maxID, a_count, a_page){
			TwitterAPI.callBackObj.getDirectMessagesSentCB = a_callBackFunc;
			if(a_startingID == "undefined" || a_startingID == null) a_startingID = null; 
			if(a_maxID == "undefined" || a_maxID == null) 			a_maxID = null; 
			if(a_count == "undefined" || a_count == null) 			a_count = 20; 
			if(a_page == "undefined" || a_page == null) 			a_page = null; 
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getDirectMessagesSent(a_startingID, a_maxID, a_count, a_page);
		},
		
		/**
		 * Sends a new direct message to the specified user from the 
		 * authenticating user. Requires both the user and text parameters. 
		 * Request must be a POST. Returns the sent message in the requested 
		 * format when successful.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages%C2%A0new
		 *  
		 * @param a_user			a user ID or screen name
		 * @param a_text			the text you want to send the user
		 */	
		sendNewDirectMessage: function(a_callBackFunc, a_user, a_text){
			TwitterAPI.callBackObj.sendNewDirectMessageCB = a_callBackFunc;
			if(a_user == "undefined" || a_user == null){	alert("You need a user");		return;}
			if(a_text == "undefined" || a_text == null){	alert("You need a textID");		return;}
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).sendNewDirectMessage(a_user, a_text);
		},
		
		/**
		 * Un-favorites the status specified in the ID parameter as the 
		 * authenticating user. Returns the un-favorited status in the 
		 * requested format when successful.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-favorites%C2%A0destroy
		 * 
		 * @param a_id				a id of the status to un-favorite
		 */			
		deleteFavoriteStatus: function(a_callBackFunc, a_id){
			TwitterAPI.callBackObj.deleteFavoriteStatusCB = a_callBackFunc;
			if(a_id == "undefined" || a_id == null){	alert("You need an ID to delete");		return;}
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).deleteFavoriteStatus(a_id);
		},
		
		/**
		 * Returns the 20 most recent favorite statuses for the authenticating 
		 * user or user specified by the ID parameter in the requested format.	
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-favorites
		 * 
		 * @param a_id				[optional] a id or screen name of the user for whom to request a list of favoirtes
		 * @param a_page			[optional] a page to return
		 */		
		getFavoriteStatuses: function(a_callBackFunc, a_id, a_page){
			TwitterAPI.callBackObj.getFavoriteStatusesCB = a_callBackFunc;
			if(a_id == "undefined" || a_id == null) 	a_id = null; 
			if(a_page == "undefined" || a_page == null) a_page = null;
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getFavoriteStatuses(a_id, a_page);
		},
		
		/**
		 * Favorites the status specified in the ID parameter as the 
		 * authenticating user. Returns the favorite status when successful.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-favorites%C2%A0create
		 * 
		 * @param a_id				a id of the status to favorite
		 */	
		setNewFavoriteStatus: function(a_callBackFunc, a_id){
			TwitterAPI.callBackObj.setNewFavoriteStatusCB = a_callBackFunc;
			if(a_id == "undefined" || a_id == null){	alert("You need an ID");		return;}
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).setNewFavoriteStatus(a_id);
		},
		
		/**
		 * Destroys the direct message specified in the required ID parameter.  
		 * The authenticating user must be the recipient of the specified direct 
		 * message.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages%C2%A0destroy 
		 * 
		 * @param a_id				a id of the DM to delete
		 */	
		deleteDirectMessage: function(a_callBackFunc, a_id){
			TwitterAPI.callBackObj.deleteDirectMessageCB = a_callBackFunc;
			if(a_id == "undefined" || a_id == null){	alert("You need an ID");		return;}
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).deleteDirectMessage(a_id);
		},
		
		/**
		 * Ends the session of the authenticating user, returning a null cookie.  
		 * Use this method to sign users out of client-facing applications like widgets
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-account%C2%A0end_session
		 * 
		 * @param a_responseFormat	[optional] format for requests
		 * 
		 */		
		endSession: function(a_callBackFunc){
			TwitterAPI.callBackObj.endSessionCB = a_callBackFunc;
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).endSession();
		},
		
		/**
		 * Returns extended information of a given user, specified by ID or 
		 * screen name as per the required id parameter.  The author's most 
		 * recent status will be returned inline.
		 * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
		 * 
		 * @param a_username		an ID or a username to be called 
		 * @param a_responseFormat	[optional] format for requests
		 * 
		 */		
		getUserShow: function(a_callBackFunc, a_username){
			TwitterAPI.callBackObj.getUserShowCB = a_callBackFunc;
			if(a_username == "undefined" || a_username == null){	alert("You need a uername");		return;}
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).getUserShow(a_username);
		},
		
		
		/**
		 * call this if you want to change the current users profile picture
		 * to something totally different
		 **/
		setProfileImage:function(a_callBackFunc, a_url){
			if(a_url == "undefined" || a_url == null){	alert("You need a url");		return;}
			TwitterAPI.callBackObj.setProfileImageCB = a_callBackFunc;
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).setProfileImage(a_url);
		},
		
		/**
		 * call this if you want to change the current users Background image
		 * to something totally different
		 **/
		setBackgroundImage:function(a_callBackFunc, a_url){
			if(a_url == "undefined" || a_url == null){	alert("You need a url");		return;}
			TwitterAPI.callBackObj.setBackgroundImageCB = a_callBackFunc;
			TwitterAPI.getSWF(TwitterAPI.SWF_ID).setBackgroundImage(a_url);
		},
		
		
		/**
		 * these are calls that would require multiple actions on teh SWF side
		 * they are seperated to not pollute the pure twitter calls.
		 */
		MultiStepActions: {
			overlayURL: "",
			
			/**
			 * call this to start adding an overlay
			 **/
			addProfileOverlay: function(a_callBackFunc, a_overlayImage, a_secondCallback){
				TwitterAPI.callBackObj.setProfileImageCB = a_callBackFunc;
				if(a_overlayImage == "undefined" || a_overlayImage == null){	alert("You need an overlay url");		return;}
				TwitterAPI.MultiStepActions.overlayURL = a_overlayImage;
				TwitterAPI.getUserShow(
					function(a_json){
						a_secondCallback(a_json);
						TwitterAPI.MultiStepActions.addProfileOverlay_mergeImages(a_json);
					}, 
					TwitterAPI.oConfig.user.usersSN);
			},
			
			/**
			 * add an overlay to an image 
			 **/
			addBackgroundOverlay:function(a_callBackFunc,a_image, a_overlayImage){
				if(a_image == "undefined" || a_image == null){	alert("You need an image url");		return;}
				if(a_overlayImage == "undefined" || a_ua_overlayImagerl == null){	alert("You need an overlay url");		return;}
				TwitterAPI.callBackObj.setBackgroundImageCB = a_callBackFunc;
				TwitterAPI.MultiStepActions.overlayURL = a_overlayImage
				TwitterAPI.setOverlayOnBackground(a_image, TwitterAPI.MultiStepActions.addOverlay_mergeImages);
			},
			
			/**
			 * actually makes the call to merge the 2 images together
			 **/
			addProfileOverlay_mergeImages:function(a_json){
				var response = eval(unescape('('+a_json+')'));
				var imageURL = response.profile_image_url;
				TwitterAPI.getSWF(TwitterAPI.SWF_ID).setOverlayOnProfileImage(imageURL, TwitterAPI.MultiStepActions.overlayURL);
			}
		}
	}