
function initElement(){	
	var selDiv = document.getElementById("content");
	var postId = selDiv.className;
}

function debug(){

}

function goBig(e){
var aggiunta = "&big=true";
var veraUrl = document.getElementById("embeddato").name;
enlarge(veraUrl+aggiunta);
//scrollo in giu la pagina dopo 1 secondo
scrolldelay = setTimeout('pageScroll()',1000)	
}

function pageScroll() {
    	window.scrollBy(0,500); // horizontal and vertical scroll increments
    	clearInterval(scrolldelay);
}


function checkStatus(msg,author,immagine,variabilebuleanadaflash,_permalink) {
			var seconda=variabilebuleanadaflash;
		    var comment=msg;
		    
		    var permalink = _permalink
        	var attachment;
        	var posso=true;
        	var datiUtente;
        	var utente;
        	var lamail;
        	
        	//me li deve passare ale
        	var autore=author;
        	var tmb=immagine;
        	
        	var api_key='cffed75e41e4315fce4a82861d31f648';
        	var channel_path = 'http://tododiacriativo.com/fbApp/xd_receiver.htm'; 
    		
    		var a = document.getElementById("sb-content");
			var b = document.getElementById("sb-body");
    		
    		
if(seconda!=true){
	FB.init(api_key, channel_path,{"ifUserConnected":onConnected,"ifUserNotConnected":onNotConnected});
}
else{
FB.Connect.get_status().waitUntilReady(function(status) {
   switch(status) {
   case FB.ConnectState.connected:
   		var connesso = FB.Connect.get_loggedInUser();
   		if(connesso !="undefined"){
     		onConnected(connesso);
     	}
     break;
   case FB.ConnectState.userNotLoggedIn:
     	onNotConnected();
     break;
   }
 });	
}
	 function small(){
	   	//controllo sistema operativo
	   	var os=navigator.appVersion;
	   	var win=os.indexOf("Windows",0);
	   		if(win>0){
	 			//se è windows controllo browser
	   			var str=window.navigator.userAgent;
	   			var moz=str.indexOf("Firefox",0);
	   			if(moz>0){
	   				//se è firefox rimpicciolisco
					a.width=1;   
					a.height=1;
				}else{
				a.style.width="1";
				a.style.height="1";
				} 
	   		}
	   	}
		
		function aggiungiListener(){
			window.onclick=null
			document.onclick=null
		 	var os=navigator.appVersion;
	   		var win=os.indexOf("Windows",0);
	   		if(win>0){
				b.onmousemove=check;
			}
		}
		
		function check(){
			bigAgain();
			b.onmousemove=null;
		}
		
		function bigAgain(){
			var str=window.navigator.userAgent;
	   		var moz=str.indexOf("Firefox",0);
	   			if(moz>0){
	   				//se è firefox rimpicciolisco
					a.width=900;   
					a.height=500;
				}else{
					a.style.width="900";
					a.style.height="500";
				} 
		}
		
		
			//1 - Se connesso
		function onConnected(user_id) {
			if(posso){
				small();
				utente=user_id;
				FB.Connect.forceSessionRefresh(function (){FB.Facebook.apiClient.users_getInfo([user_id], ['name','pic','pic_small','pic_square','profile_url','contact_email'], datiRicevuti); })			
	       		}
			}
       		// 2 - Se NON connesso
			function onNotConnected() {
				//posso=false;
				small();
				FB.Connect.requireSession(onConnected,onCancelCallback, isUserActionHint=false);			
			}
			
			function onCancelCallback(){
				FB.Connect.logout()
				bigAgain();
				
				thisMovie("sb-content").sendToAs(null,null);
			}
			
			function datiRicevuti(oggetto) {
				small();
				datiUtente=oggetto;
				
				attachment = {'media': [{'type':'image','src':tmb,'href':permalink}]};
				FB.Connect.streamPublish('Seja um fã do projeto de '+autore+' e deixe seu comentário: '+comment+' '+permalink, attachment, null, null,'Sou um fã do projeto de: '+autore,stream_callback);
				
			 	//LA PROXIED_EMAIL
				lamail=oggetto[0]['proxied_email'];				
			}
	       	//se il commento è finito su facebook...
	       	function stream_callback (post_id, exception) {
  				if (post_id) {
  					FB.Connect.showPermissionDialog('email', 
  				function(result) 
				{
					//FUNZIONE DA RICHIAMARE QUANDO L'UTENTE HA ACCETTATO DI
					//LASCIARE IL PERMESSO ALL'APPLICATIVO DI USARE LA MAIL 
			 		//alert(result)
			 		bigAgain();
  					callback(comment);
			  	});
  				
  				
  					
  				}
  				if(exception){
  					bigAgain();
  				}
			}	
			
			function callback(oggetto){
				sendToAs(datiUtente,oggetto);
			}
				//invia a as
			function sendToAs(values,post) {
				thisMovie("sb-content").sendToAs(values,post);
			}	
				//estrapola il riferimento all'swf
			function thisMovie(movieName) {
	   		     if (navigator.appName.indexOf("Microsoft") != -1) {
	   		     	return window[movieName]
	   		     }
	   		     else {
	   		     	return document[movieName]
	   		     }
	       	}
        }