var ww_class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}
ww_fb_graph = ww_class.create();
ww_fb_graph.prototype={
	init:false,
	init_oauth:true,
	init_xfbml:false,
	init_cookie:true,
	init_status:true,
	errflush:'#b73a18',
	errflushok:'#23982b',
	logo:IPATH+'grafiken/logo.jpg',
	//loading_gif:'grafiken/loading.gif',
	loading_gif:'grafiken/ajax-loader-3.gif',
	typ_forum:'9',
	typ_answers:'7',
	typ_gbook:'6',
	typ_video:'4',
	typ_foto:'3',
	typ_blog:'2',
	loginerror:'Vorgang abgebrochen oder Zugangsdaten falsch!',
	perms:'user_birthday',
	fbuser:false,
	wwfbuser:false,
	uid:null,
	sig:null,
	session_key:null,
	secret:null,
	access_token:null,
	birthday:null,
	email:null,
	first_name:null,
	gender:null,
	last_name:null,
	link:null,
	third_party_id:null,
	website:null,
	friend_count:null,
	current_location:null,
	friends:null,
	pic:null,
	about_me:null,
	rec_user:null,
	user_id:null,
	initialize:function(options)
	{
		if(!options) throw 'no options in ww_fb_graph';
		if(options.APPID){this.APPID=options.APPID;}else{throw 'no appid in ww_fb_graph';}
		if(options.DIV){this.DIV=options.DIV;}else{throw 'no div in ww_fb_graph';}
		if(options.OAUTH){if(options.OAUTH=='1'){this.init_oauth=true;}else{this.init_oauth=false;}}else{this.init_oauth=true;}
		if(options.COOKIE){if(options.COOKIE=='1'){this.init_cookie=true;}else{this.init_cookie=false;}}else{this.init_cookie=true;}
		if(options.STATUS){if(options.STATUS=='1'){this.init_status=true;}else{this.init_status=false;}}else{this.init_status=true;}
		if(options.XFBML){if(options.XFBML=='1'){this.init_xfbml=true;}else{this.init_xfbml=false;}}else{this.init_xfbml=false;}
		if(options.LANG){if(options.LANG==''){this.LANG='de_DE';}else{this.LANG=options.LANG;}}else{this.LANG='de_DE';}
		if(options.PUBLISH_LOGIN){if(options.PUBLISH_LOGIN=='1'){this.PUBLISH_LOGIN='1';}else{this.PUBLISH_LOGIN='0';}}else{this.PUBLISH_LOGIN='0';}
		if(options.PUBLISH_REG){if(options.PUBLISH_REG=='1'){this.PUBLISH_REG='1';}else{this.PUBLISH_REG='0';}}else{this.PUBLISH_REG='0';}
		if(options.PUBLISH_CHILD){this.PUBLISH_CHILD=options.PUBLISH_CHILD;}else{this.PUBLISH_CHILD='';}
		if(options.PUBLISH_ASK){if(options.PUBLISH_ASK=='1'){this.PUBLISH_ASK='1';}else{this.PUBLISH_ASK='0';}}else{this.PUBLISH_ASK='0';}
		if(options.PUBLISH_ENABLE){if(options.PUBLISH_ENABLE=='1'){this.PUBLISH_ENABLE='1';}else{this.PUBLISH_ENABLE='0';}}else{this.PUBLISH_ENABLE='0';}
		if(options.REG_INVITE){if(options.REG_INVITE=='1'){this.REG_INVITE='1';}else{this.REG_INVITE='0';}}else{this.REG_INVITE='0';}
		if(options.LOGOUT_ASK){if(options.LOGOUT_ASK=='1'){this.LOGOUT_ASK='1';}else{this.LOGOUT_ASK='0';}}else{this.LOGOUT_ASK='0';}
		if(options.PUBLISH_TYP){this.PUBLISH_TYP=options.PUBLISH_TYP;}else{this.PUBLISH_TYP='';}
		if(options.PUBLISH_SETTINGS){this.PUBLISH_SETTINGS=parseInt(options.PUBLISH_SETTINGS,10);}else{this.PUBLISH_SETTINGS=0;}
		if(options.FBUSER){this.wwfbuser=options.FBUSER;}else{this.wwfbuser='0';}
		if(options.RECOGNIZE_USER){this.rec_user=options.RECOGNIZE_USER;}else{this.rec_user={ENABLE:'0'};}
		if(options.USER){this.user_id=options.USER;}else{this.user_id='0';}
		if(options.PERMS){this.perms=options.PERMS;}else{}
		if(!document.getElementById(this.DIV))
		{
			var body = document.getElementsByTagName('body')[0];
			var div = document.createElement('div');
			div.id=this.DIV;
			body.appendChild(div);
			window.fbAsyncInit = function() 
			{
				FB.init({appId: wwfb.APPID, status: wwfb.init_status, cookie: wwfb.init_cookie, xfbml: wwfb.init_xfbml, oauth:wwfb.init_oauth});
				wwfb.init=true;
				wwfb.status(function(){
					if(wwfb.rec_user.ENABLE=='1' && wwfb.user_id=='0' && wwfb.fbuser==true)
					{
						if(document.getElementById(wwfb.rec_user.TITLEDIV) && document.getElementById(wwfb.rec_user.CONTENTDIV) && document.getElementById(wwfb.rec_user.MAINDIV))
						{
							document.getElementById(wwfb.rec_user.TITLEDIV).innerHTML='Hallo '+wwfb.first_name+'!';
							var html='Nutze jetzt deinen Facebook-Account um dich bei me20 einzuloggen.';
							html+='<div class="fbg_button fbg_recognize_button" id="fbg_recognize_button" onclick="wwfb.login(this,\''+wwfb.rec_user.ERRORDIV+'\',\''+wwfb.perms+'\');" isfixed="true">Anmelden mit Facebook</div>';
							document.getElementById(wwfb.rec_user.CONTENTDIV).innerHTML=html;
							document.getElementById(wwfb.rec_user.MAINDIV).style.display='block';
						}
					}
				});
			};
			(function() {
				var e = document.createElement('script'); e.async = true;
				e.src = document.location.protocol +
				'//connect.facebook.net/'+options.LANG+'/all.js';
				document.getElementById(options.DIV).appendChild(e);
			}());
		}
	},
	isready:function()
	{
		if(this.init && typeof(FB)!='undefined')
		{
			return true;
		}
		else
		{
			return false;
		}
	},
	session_isok:function(r)
	{
		var ok=false;
		if(this.init_oauth==true)
		{
			if(r.status=='connected')
			{
				ok=true;
			}
		}
		else
		{
			if(r.session)
			{
				ok=true;
			}
		}
		return ok;
	},
	send_query:function(q,on)
	{
		var options={
			QUERY:null,
			VARS:null
		}
		for (property in q) options[property] = q[property];
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		var query = FB.Data.query(options.QUERY,options.VARS);
		query.wait(function(rows) {
			onc(rows);
		});
	},
	status:function(on)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		FB.getLoginStatus(function(response)
		{
			if(wwfb.session_isok(response))
			{
				if(wwfb.init_oauth==true)
				{
					wwfb.uid=((response.authResponse)?response.authResponse.userID:null);
					wwfb.access_token=((response.authResponse)?response.authResponse.accessToken:null);
					wwfb.sig=((response.authResponse)?response.authResponse.signedRequest:null);
					wwfb.session_key=null;
					wwfb.secret=null;
					//wwfb.session_key=((response.authResponse)?response.session.session_key:null);
					//wwfb.secret=((response.authResponse)?response.session.secret:null);
				}
				else
				{
					wwfb.uid=((response.session)?response.session.uid:null);
					wwfb.sig=((response.session)?response.session.sig:null);
					wwfb.session_key=((response.session)?response.session.session_key:null);
					wwfb.secret=((response.session)?response.session.secret:null);
					wwfb.access_token=((response.session)?response.session.access_token:null);
				}
				var q={QUERY:'SELECT about_me,current_location,friend_count,website,third_party_id,birthday_date,pic_big,email,first_name,sex,last_name,profile_url FROM user WHERE uid={0}',VARS:wwfb.uid};
				wwfb.send_query(q,function(sresponse){
					wwfb.birthday=((sresponse[0]['birthday_date'])?sresponse[0]['birthday_date']:'');
					wwfb.email=((sresponse[0]['email'])?sresponse[0]['email']:'');
					wwfb.first_name=((sresponse[0]['first_name'])?sresponse[0]['first_name']:'');
					wwfb.gender=((sresponse[0]['sex'])?sresponse[0]['sex']:'');
					wwfb.last_name=((sresponse[0]['last_name'])?sresponse[0]['last_name']:'');
					wwfb.link=((sresponse[0]['profile_url'])?sresponse[0]['profile_url']:'');
					wwfb.current_location=((sresponse[0]['current_location'])?sresponse[0]['current_location']:'');
					wwfb.third_party_id=((sresponse[0]['third_party_id'])?sresponse[0]['third_party_id']:'');
					wwfb.website=((sresponse[0]['website'])?sresponse[0]['website']:'');
					wwfb.friend_count=((sresponse[0]['friend_count'])?sresponse[0]['friend_count']:'');
					wwfb.pic=((sresponse[0]['pic_big'])?sresponse[0]['pic_big']:'');
					wwfb.about_me=((sresponse[0]['about_me'])?sresponse[0]['about_me']:'');
					wwfb.fbuser=true;
					onc(response);	
				});
			}
			else
			{
				wwfb.uid=null;
				wwfb.sig=null;
				wwfb.session_key=null;
				wwfb.secret=null;
				wwfb.access_token=null;
				wwfb.birthday=null;
				wwfb.email=null;
				wwfb.first_name=null;
				wwfb.gender=null;
				wwfb.last_name=null;
				wwfb.link=null;
				wwfb.third_party_id=null;
				wwfb.website=null;
				wwfb.friend_count=null;
				wwfb.current_location=null;
				wwfb.friends=null;
				wwfb.pic=null;
				wwfb.about_me=null;
				wwfb.fbuser=false;
				onc(response);
			}
		});	
	},
	login:function(el,err,permition,on,connect_call)
	{
		if(!this.isready()) {setTimeout(function(){wwfb.login(el,err,permition,on,connect_call);},500);throw 'ww_fb_graph not initialized';}
		var p=permition || 'user_birthday';
		var onc=on || function(){};
		document.getElementById(err).innerHTML='<img src="'+this.loading_gif+'" class="loading_gif" />';
		FB.login(function(response) 
		{
			if(connect_call)
			{
				onc(response);
			}
			else
			{
				wwfb.login_done(response,el,err,p,onc);
			}
		},{scope: p});
	},
	login_done:function(response,el,err,permition,onc)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var func=function(){
			if(wwfb.session_isok(response))
			{
				new ajax(PPATH+'ajax/fb_graph_login.html', {postBody:'FBUID='+wwfb.uid+'&FBSESSION='+wwfb.session_key+'&FBACCESS='+wwfb.access_token,onComplete:function(){
					document.getElementById(err).innerHTML='';
					if(return_fblogin._MO_FB_STATUS=='OK')
					{
						if(return_fblogin._MO_FB_ACCOUNT=='login')
						{
							wwfb.fbuser=true;
							if(wwfb.PUBLISH_LOGIN=='1')
							{
								var m={message:'Ich bin jetzt auf me20 unterwegs Du findest mich dort unter "'+return_fblogin._MO_FB_NAME+'".',link:PPATH,picture:wwfb.logo};
								wwfb.feed(m,function()
								{
									el_flush(el,wwfb.errflushok);
									wwfb.ww_sitereload();
								});
							}
							else
							{
								el_flush(el,wwfb.errflushok);
								wwfb.ww_sitereload();
							}	
						}
						else if(return_fblogin._MO_FB_ACCOUNT=='new')
						{
							wwfb.get_friends(function(){
								var fr='';
								for(var i=0;i<wwfb.friends.length;i++)
								{
									fr+=wwfb.friends[i]['uid2']+',';
								}
								var tl='&FBUID='+wwfb.uid;
								tl+='&FBFRIENDS='+fr;
								tl+='&FBFIRSTNAME='+wwfb.first_name;
								tl+='&FBLASTNAME='+wwfb.last_name;
								tl+='&FBFRIENDCOUNT='+wwfb.friend_count;
								ToolTip.get('fbg_register',el,false,tl);
							});
						}
					}
					else
					{
						document.getElementById(err).innerHTML=return_fblogin._MO_FB_ETXT;
						el_flush(err,wwfb.errflush);
					}
				},evalObj:'return_fblogin'});
			}
			else
			{
				document.getElementById(err).innerHTML=wwfb.loginerror;
				el_flush(err,wwfb.errflush);
			}		
		};
		this.status(function(){
			func();
		});
	},
	logout:function(url)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		if(this.fbuser && this.LOGOUT_ASK=='1')
		{
			ToolTip.get('fbg_logout',this,false,'&URL='+url);
		}
		else
		{
			wwfb.ww_sitereload(url);
		}
		
	},
	logout_do:function(url)
	{
		FB.logout(function(response) 
		{
			wwfb.ww_sitereload(url);
		});	
	},
	get_friends:function(on)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		var q={QUERY:'SELECT uid2 FROM friend WHERE uid1 ={0}',VARS:wwfb.uid};
		wwfb.send_query(q,function(response){
			wwfb.friends=response;
			onc();	
		});
	},
	connect:function(el,err,permition,reload,on)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		var lonc=function(response){
			if(wwfb.session_isok(response))
			{
				var fonc=function(){
					wwfb.get_friends(function(){
						var fr='';
						for(var i=0;i<wwfb.friends.length;i++)
						{
							fr+=wwfb.friends[i]['uid2']+',';
						}
						var tl='&FBUID='+wwfb.encode_url(wwfb.uid);
						tl+='&FBSESSION='+wwfb.encode_url(wwfb.session_key);
						tl+='&FBACCESS='+wwfb.encode_url(wwfb.access_token);
						tl+='&FBFRIENDS='+wwfb.encode_url(fr);
						tl+='&FBBIRTHDAY='+wwfb.encode_url(wwfb.birthday);
						tl+='&FBEMAIL='+wwfb.encode_url(wwfb.email);
						tl+='&FBFIRSTNAME='+wwfb.encode_url(wwfb.first_name);
						tl+='&FBLASTNAME='+wwfb.encode_url(wwfb.last_name);
						tl+='&FBGENDER='+wwfb.encode_url(wwfb.gender);
						tl+='&FBLINK='+wwfb.encode_url(wwfb.link);
						tl+='&FBWEBSITE='+wwfb.encode_url(wwfb.website);
						tl+='&FBTHIRDPARTYID='+wwfb.encode_url(wwfb.third_party_id);
						tl+='&FBFRIENDCOUNT='+wwfb.encode_url(wwfb.friend_count);
						tl+='&FBCOUNTRY='+wwfb.encode_url(wwfb.current_location.country);
						tl+='&FBSTATE='+wwfb.encode_url(wwfb.current_location.state);
						tl+='&FBCITY='+wwfb.encode_url(wwfb.current_location.city);
						tl+='&FBZIP='+wwfb.encode_url(wwfb.current_location.zip);
						tl+='&FBPIC='+wwfb.encode_url(wwfb.pic);
						tl+='&FBABOUTME='+wwfb.encode_url(wwfb.about_me);
						tl+='&REG_CHOICE=true';
						tl+='&PROFIL_CONNECT=true';
						new ajax(PPATH+'ajax/fb_graph_register.html', {postBody:tl,onComplete:function(){
							document.getElementById(err).innerHTML='';
							if(return_fbgconnect._MO_FB_STATUS=='OK')
							{
								if(reload)wwfb.ww_sitereload();
								onc(return_fbgconnect,response);
							}
							else
							{
								document.getElementById(err).innerHTML=return_fbgconnect._MO_FB_ETXT;
							}
						},evalObj:'return_fbgconnect'});
					});
				};
				wwfb.status(fonc);
			}
			else
			{
				document.getElementById(err).innerHTML=wwfb.loginerror;
				el_flush(err,wwfb.errflush);			
			}
		};
		this.login(el,err,permition,lonc,true);
	},
	register:function(op,on)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		var err=op.FBG_REG_ERR;
		document.getElementById(err).innerHTML='<img src="'+this.loading_gif+'" class="loading_gif" />';
		document.getElementById(err).style.color=this.errflush;	
		var fr='';
		for(var i=0;i<wwfb.friends.length;i++)
		{
			fr+=wwfb.friends[i]['uid2']+',';
		}
		var tl='&FBUID='+this.encode_url(wwfb.uid);
		tl+='&FBSESSION='+this.encode_url(wwfb.session_key);
		tl+='&FBACCESS='+this.encode_url(wwfb.access_token);
		tl+='&FBFRIENDS='+this.encode_url(fr);
		tl+='&FBBIRTHDAY='+this.encode_url(wwfb.birthday);
		tl+='&FBEMAIL='+this.encode_url(wwfb.email);
		tl+='&FBFIRSTNAME='+this.encode_url(wwfb.first_name);
		tl+='&FBLASTNAME='+this.encode_url(wwfb.last_name);
		tl+='&FBGENDER='+this.encode_url(wwfb.gender);
		tl+='&FBLINK='+this.encode_url(wwfb.link);
		tl+='&FBWEBSITE='+this.encode_url(wwfb.website);
		tl+='&FBTHIRDPARTYID='+this.encode_url(wwfb.third_party_id);
		tl+='&FBFRIENDCOUNT='+this.encode_url(wwfb.friend_count);
		tl+='&FBCOUNTRY='+this.encode_url(wwfb.current_location.country);
		tl+='&FBSTATE='+this.encode_url(wwfb.current_location.state);
		tl+='&FBCITY='+this.encode_url(wwfb.current_location.city);
		tl+='&FBZIP='+this.encode_url(wwfb.current_location.zip);
		tl+='&FBPIC='+this.encode_url(wwfb.pic);
		tl+='&FBABOUTME='+this.encode_url(wwfb.about_me);
		tl+='&USERNAME='+this.encode_url(document.getElementById(op.FBG_REG_FBUSERNAME).value);
		tl+='&REG_CHOICE='+op.FBG_REG_CHOICE;
		tl+='&REG_PW='+this.encode_url(document.getElementById(op.FBG_REG_PW).value);
		tl+='&REG_USERNAME='+this.encode_url(document.getElementById(op.FBG_REG_USERNAME).value);
		new ajax(PPATH+'ajax/fb_graph_register.html', {postBody:tl,onComplete:function(){
			if(return_fbgregister._MO_FB_STATUS=='OK')
			{
				var fu=function(){
					if(wwfb.REG_INVITE=='1')
					{			
						wwfb.invite(function(){
							document.getElementById(err).innerHTML='';
							wwfb.ww_sitereload();						
						});
					}
					else
					{
						document.getElementById(err).innerHTML='';
						wwfb.ww_sitereload();					
					}
				};
				if(wwfb.PUBLISH_REG=='1')
				{
					var m={message:'Ich habe mich gerade bei me20 registriert. Du findest mich dort unter "'+return_fbgregister._MO_FB_NAME+'".',link:PPATH,picture:wwfb.logo};
					if(return_fbgregister._MO_FB_ACTYPE=='con')
					{
						m={message:'Ich bin jetzt auf me20 unterwegs Du findest mich dort unter "'+return_fbgregister._MO_FB_NAME+'".',link:PPATH,picture:wwfb.logo};
					}
					wwfb.feed(m,function()
					{
						fu();
					});
				}
				else
				{
					fu();
				}
			}
			else
			{
				document.getElementById(err).innerHTML=return_fbgregister._MO_FB_ETXT;
				el_flush(err,wwfb.errflush);
			}
		},evalObj:'return_fbgregister'});
	},
	checkname:function(el,err)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		document.getElementById(err).innerHTML='';
		document.getElementById(err).style.color=this.errflush;
		var tl='';
		tl+='&VAL='+this.encode_url(el.value);
		tl+='&VALTYP=name';
		new ajax(PPATH+'ajax/reg_check_value.html', {postBody:tl,onComplete:function(){
			if(return_fbgcheckname._MO_REG_ETXT=='OK')
			{
				document.getElementById(err).style.color=wwfb.errflushok;
			}
			document.getElementById(err).innerHTML=return_fbgcheckname._MO_REG_STATUS;
		},evalObj:'return_fbgcheckname'});
	},
	invite:function(on)
	{
		if(!this.isready()) {setTimeout(function(){wwfb.invite(on);},500);throw 'ww_fb_graph not initialized';}
		var onc=on || function(){};
		FB.ui({
		          method : 'apprequests',
		          title: 'Herzlich Willkommen bei me20!',
		          message : 'Ein Freund hat Dich zu www.me20.de eingeladen. Stimme der Einladung zu und vernetze Dich auch hier. Viel Spaß wünschen wir auf www.me20.de'
		          //filters : 'app_non_users'
		  }, function(response){
		          onc(response);
		  });		
	},
	feed:function(obj,on)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		if(this.PUBLISH_ENABLE=='1')
		{
			if(this.PUBLISH_ASK=='1')
			{
				var vurl='';
				if(obj.typ==this.typ_video)
				{
					var v=obj.video.split('|');
					var p=v[0];
					var h=v[1];
					var f=v[2];
					vurl=IPATH+'flash/wwplayer.swf?vcontenturl='+this.encode_url(IPATH+'userfiles/')+'&vcontentpath='+this.encode_url(this.encode_b64(p+'/'+h))+'&vcontentimg=_4.jpg&vvolume=33&smoothmode=true';
				}
				var o = {
			          method: 'feed',
			          link: obj.link || PPATH,
			          picture: obj.picture || wwfb.logo,
			          source:vurl || '',
			          name: obj.name || '',
			          caption: obj.title || '',
			          description: obj.message || ''
			        };
			        FB.ui(o, function(response)
				{
					onc();
				});
			}
			else
			{
				//var att = {'media':[{'type':'image','src':obj.picture || wwfb.logo,'href':obj.link || PPATH}]};
				//obj.video='http://images.me20.de/flash/wwplayer.swf?vcontenturl=http%3A%2F%2Fimages.me20.de%2Fuserfiles%2F&amp;vcontentpath=by94L00vTC9oL1h1NkYzUUk3b0pBd3p6UVlqYjNHSTE%3D&amp;vcontentimg=_4.jpg&amp;vvolume=33&amp;smoothmode=true';
				var vurl='';
				if(obj.typ==this.typ_video)
				{
					var v=obj.video.split('|');
					var p=v[0];
					var h=v[1];
					var f=v[2];
					vurl=IPATH+'flash/wwplayer.swf?vcontenturl='+this.encode_url(IPATH+'userfiles/')+'&vcontentpath='+this.encode_url(this.encode_b64(p+'/'+h))+'&vcontentimg=_4.jpg&vvolume=33&smoothmode=true';
				}
				var msg=obj.message;
				if(obj.xid>0)msg=wwfb.first_name+' kommentiert: '+obj.message;
				var o = {
			          link: obj.link || PPATH,
			          picture: obj.picture || wwfb.logo,
			          name: obj.name || '',
			          source:vurl || '',
			          caption: obj.title || '',
			          message: msg || ''
			        };
			        //console.info(o);
				FB.api('/me/feed', 'post',  o , function(response) 
				{
					//console.info(response);
					//return;
					onc();
				});
			}
		}
		else
		{
			onc();
		}
	},
	publish:function(obj,on)
	{
		if(!this.isready()) throw 'ww_fb_graph not initialized';
		var onc=on || function(){};
		if(wwfb.fbuser==false){
			on();
			return;
		}
		var types=wwfb.PUBLISH_TYP.split(',');
		var push=false;
		for(var i=0;i<types.length;i++)
		{
			if(types[i]==obj.typ)
			{
				push=true;
			}
		}
		if(this.wwfbuser=='0')push=false;
		if(push==true)
		{
			if(obj.typ==this.typ_blog)
			{
				if((this.PUBLISH_SETTINGS&1)==1)
				{
					push=false;
				}
			}
			if(obj.typ==this.typ_foto)
			{
				if((this.PUBLISH_SETTINGS&2)==2)
				{
					push=false;
				}
			}
			if(obj.typ==this.typ_video)
			{
				if((this.PUBLISH_SETTINGS&4)==4)
				{
					push=false;
				}
			}
			if(obj.typ==this.typ_forum)
			{
				if((this.PUBLISH_SETTINGS&8)==8)
				{
					push=false;
				}
			}
			if(obj.typ==this.typ_answers)
			{
				if((this.PUBLISH_SETTINGS&16)==16)
				{
					push=false;
				}
			}
			if(obj.typ==this.typ_gbook)
			{
				if((this.PUBLISH_SETTINGS&32)==32)
				{
					push=false;
				}
			}
			if(push==true)
			{
				if(obj.xid>0)
				{
					push=false;
					types=wwfb.PUBLISH_CHILD.split(',');
					for(var i=0;i<types.length;i++)
					{
						if(types[i]==obj.typ)
						{
							push=true;
						}
					}
					if(push==true)
					{
						wwfb.feed(obj,on);
					}
					else
					{
						onc();
					}
				}
				else
				{
					wwfb.feed(obj,on);
				}
			}
			else
			{
				onc();
			}
		}
		else
		{
			onc();
		}
	},
	show_userdetail:function(obj,on)
	{
		if(!this.isready()) {setTimeout(function(){wwfb.show_userdetail(obj,on);},500);throw 'ww_fb_graph not initialized';}
		var onc=on || function(){};
		var options={
			RETRY_UNTIL_READY:true,
			ATTEMPTS:5,
			TRY:0,
			DIV:null,
			PIC:true,
			NAME:true,
			DISCON_BUTTON:true,
			UID:wwfb.uid
		}
		for (property in obj) options[property] = obj[property];
		if(options.DIV!=null)
		{
			document.getElementById(options.DIV).innerHTML='<img src="'+this.loading_gif+'" class="loading_gif">';
			if(options.UID!=null)
			{
				var q={QUERY:'SELECT pic_small_with_logo,first_name,last_name,profile_url FROM user WHERE uid={0}',VARS:options.UID};
				wwfb.send_query(q,function(sresponse){
					var html='<div id="fb_userdetail" class="fb_userdetail">';
					if(options.PIC)html+='<div class="fb_userimg"><a href="'+sresponse[0]['profile_url']+'" target="_blank"><img src="'+sresponse[0]['pic_small_with_logo']+'" /></a></div>';
					if(options.NAME)html+='<div class="fb_username"><a href="'+sresponse[0]['profile_url']+'" target="_blank">'+sresponse[0]['first_name']+' '+sresponse[0]['last_name']+'</a></div>';
					if(options.DISCON_BUTTON)html+='<div class="fb_disconnect"><div class="fbg_button fbg_disconnect_button" onclick="wwfb.profil_disconnect(this);">Verbindung auflösen</div></div>';
					html+='<div class="cl"></div>';
					html+='</div>';
					html+='<div class="cl"></div>';
					document.getElementById(options.DIV).innerHTML=html;
					onc(sresponse);
				});
			}
			else
			{
				options.TRY+=1;
				options.UID=wwfb.uid;
				if((options.ATTEMPTS+1)>options.TRY)setTimeout(function(){wwfb.show_userdetail(options,on);},500);
			}
		}
	},
	profil_disconnect:function(el)
	{
		ToolTip.get('fbg_disconnect',el,false,'');
	},
	profil_disconnect_do:function(el,type,err)
	{
		new ajax(PPATH+'ajax/fb_graph_disconnect.html', {postBody:'FBUID='+wwfb.uid+'&FBSESSION='+wwfb.session_key+'&FBACCESS='+wwfb.access_token,onComplete:function(){
			if(return_fbdisconnect._MO_FB_STATUS=='OK')
			{
				wwfb.ww_sitereload();
			}
			else
			{
				document.getElementById(err).innerHTML=return_fbdisconnect._MO_FB_ETXT;
				el_flush(err,wwfb.errflush);
			}
		},evalObj:'return_fbdisconnect'});
	},
	ww_sitereload:function(url)
	{
		if(url)
		{
			location.href=url;
		}
		else
		{
			location.reload();
			setTimeout(function(){
				location.href=location.href;
			},800);
		}

	},
	encode_url:function(str)
	{
		return encodeURIComponent(str);
	},
	encode_b64:function(inp)
	{
		var key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
		var chr1,chr2,chr3,enc3,enc4,i=0,out="";
		while(i<inp.length)
		{
			chr1=inp.charCodeAt(i++);if(chr1>127) chr1=88;
			chr2=inp.charCodeAt(i++);if(chr2>127) chr2=88;
			chr3=inp.charCodeAt(i++);if(chr3>127) chr3=88;
			if(isNaN(chr3)) {enc4=64;chr3=0;} else enc4=chr3&63
			if(isNaN(chr2)) {enc3=64;chr2=0;} else enc3=((chr2<<2)|(chr3>>6))&63
			out+=key.charAt((chr1>>2)&63)+key.charAt(((chr1<<4)|(chr2>>4))&63)+key.charAt(enc3)+key.charAt(enc4);
		}
		return out;
	}
}



