//Load Facebook JS-SDK  library
//Load Facebook JS-SDK  library

		$(function(){
					var fbroot = document.createElement('div');
					fbroot.id = 'fb-root';
					window.document.body.appendChild(fbroot);	
					
					
					var e = document.createElement('script'); e.async = true;
			 		e.src = document.location.protocol +
					'//connect.facebook.net/en_US/all.js';
    				var fbs = document.getElementsByTagName('script')[0]; fbs.parentNode.insertBefore(e, fbs);		
		
					
					window.fbAsyncInit = function() {
						FB.init({appId: _appVars.appId, status: true, cookie: true, xfbml: true});
						FB.Event.subscribe('edge.create', function(){_appVars.liked = '1'; ga_trackLiked('new');});
						FB.Canvas.setAutoResize();
						//FB.Canvas.setSize({width:520,height:1000});
					};	
		
		});

		
		


//Load Google analytics

var _gaq = _gaq || [];

$(function() {
    var ga = document.createElement('script');     ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:'   == document.location.protocol ? 'https://ssl'   : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 

try{
		if(BrowserDetect.browser == 'saf' && $('.facebook').length < 0){
				var fbga = document.createElement('img');
				fbga.src = _appVars.baseURL+'lib/fbga/fbga.php?googlecode='+_appVars.gaId+'&googledomain=facebook.com&pagelink='+ _appVars.locale+'/'+_appVars.template+'/start&pagetitle='+_appVars.title;
				window.document.body.appendChild(fbga);
		}else{
			_gaq.push(['_setAccount', _appVars.gaId]);	
			_gaq.push(['_setCampNameKey', 'cam']);    // name
			_gaq.push(['_setCampMediumKey', 'med']);    // medium
			_gaq.push(['_setCampSourceKey', 'src']);    // source
			_gaq.push(['_trackPageview', _appVars.locale+'/'+_appVars.template+'/start']);	
		
		}
}catch (err) {consile.log(err)}

});

