/*

	This script places a Facebook Like Box by getting a code from singlerow only visible in live edit

*/

function insertFacebook() {
		
	if(typeof(isInEditMode) == 'undefined'){
		isInEditMode = false;
	}
	
	if(isInEditMode){
		$('#fbcode').css('display', 'block');
	}
	
	var code = $('#fbcode span').html();
	var codecache = code;
	doInsert();
	
	function doInsert() {
		$('#fbframe').html("");
		$('#fbframe').append('<iframe src="http://www.facebook.com/plugins/likebox.php?id='+code+'&amp;width=250&amp;connections=8&amp;stream=true&amp;header=true&amp;height=587" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:587px;" allowTransparency="true"></iframe>');
	}
	
	/*
		Check live edit code change
	*/
	function timedCount() {
		if(isInEditMode){
			setTimeout(timedCount, 1000);
			code = $('#fbcode span').html();
		
			if (codecache != code) {
				codecache = code;
				doInsert();
			}
		}
	}
	timedCount();

	$('.boka.drop').click(function(){
		
		$('#dropdown .dropbg').show();
		
		return false;		
	});
	
	$('#dropdown').mouseleave(function(){
		if(!isInEditMode){
			$('.dropbg').fadeOut();
		}
	});
	
	if(isInEditMode){
		$('#dropdown .dropbg').show();
		$('#dropdown .dropbg').css('position', 'static');
		$('#dropdown .dropbg').css('margin-bottom', '15px');
	}
	
}
