/*	copyright: Eric Di Filippo - big boss (studio) 2009 / http://www.bigbossstudio.com/
//	technical issues: Eric Di Filippo  : support@big-boss-studio.com
*/
if(!seesmic) var seesmic = {}
if(!seesmic.recorder) seesmic.recorder = {}
 
 var _video_token = "";
 var _auth_token;
 
seesmic.recorder.login = function()
{
	//console.log(username + "/"+password);
	$.post( BASEHREF+'seesmic/login/', {},this.onLogin);
	var fl = swfobject.getObjectById(cible+"_fl");
	/*fl.width = 1;
	fl.height = 1;*/
}
/**
* this function will invoke when authentication is done
**/
seesmic.recorder.onLogin = function(auth_token)
{
 	_auth_token = auth_token 
	//alert('auth_token'+auth_token);
	var fl = swfobject.getObjectById(cible+"_fl");	
	fl.retourLogin(auth_token);		
	/*fl.width ='100%';		
	fl.height = '100%';*/	
}
seesmic.recorder.videoReady = function(currentToken)
{
    //alert('video with token ' + currentToken + ' is ready');
   _video_token = currentToken;
    //this.doSaveVideo(currentToken);
   	var fl2 = swfobject.getObjectById("menu_fl");	
	console.log(fl2);
	fl2.statutRetour(1,currentToken);	
   
    //document.getElementById('saveVideo').disabled = false
    //document.getElementById('video_id').value = currentToken;
}
seesmic.recorder.goBackToSite = function(videoToken)
{
	window.opener.seesmic.recorder.setVideoToken(videoToken,_auth_token);
	self.close();
}
seesmic.recorder.cancelVideo = function(currentToken)
{
	var fl2 = swfobject.getObjectById("menu_fl");	
	console.log(fl2);
	fl2.statutRetour(0,currentToken);	
   // alert('video is cancel ' + currentToken);
   // document.getElementById('saveVideo').disabled = true
}
seesmic.recorder.doSaveVideo = function(title,desc)
{
	$.post( BASEHREF+'seesmic/postvideo/', {auth_token:_auth_token, video_token:_video_token , title:title, description:desc}, this.onVideoSave)
	//alert('saving video :' + _video_token + " / _auth_token "+_auth_token);
}
seesmic.recorder.onVideoSave = function(e)
{
	//alert('video has been saved <a href="http://see.fm/'+e+'">' + e + '</a>');
}
seesmic.recorder.setVideoToken = function(videoToken,authToken)
{ 	
	_video_token = videoToken;
	_auth_token = authToken;
	var fl = swfobject.getObjectById(cible+"_fl");	
	fl.activeSite(_video_token);		
	//alert(_video_token+"/"+_auth_token);
}
seesmic.recorder.getCurrentToken = function()
{
	return _video_token;
}
   