// JQUERY 4 LIFE

function searchAlert () {
	$(".search-alert").html("Skriv in n&aring;gra tecken och tryck p&aring; \"enter\"");
	$(".search-alert").fadeIn("slow");
}
function searchAlertHide () {
	$(".search-alert").fadeOut("slow");	
}
function readMore () {
	$("#sub-1").fadeOut("slow", function() {
		$("#sub-2").fadeIn("slow");
	});	
}
function readLess () {
	$("#sub-2").fadeOut("slow", function() {
		$("#sub-1").fadeIn("slow");
	});	
}


function goUrl(strTitle) {
	messureImg('http://impse.tradedoubler.com/imp?type(inv)g(16153296)a(1565697)');
	var sUrl = 'http://clk.tradedoubler.com/click?p=46&a=1565697&url=http://cdon.se/search?q=' + encodeURIComponent(strTitle);
	pageTracker._trackPageview('/outgoing/'+encodeURIComponent(strTitle)+'/');

	window.open(sUrl)
}


function messureImg(sUrl) {
    var oImg = document.createElement("img");
    oImg.setAttribute('src', sUrl);
    oImg.setAttribute('height', '1px');
    oImg.setAttribute('width', '1px');
    document.body.appendChild(oImg);
}

function insertFaceBookLike() {
	
	if($(".single-page").length > 0) {
	
	
		$("div.imdbinfo a").attr({
		    target: "_blank", 
		    title: "Opens in a new window"
		  });

 
		$(".tBanner").before('<div id="fb-root"></div>');
		
	
			var htmlString =  '<fb:like href="' + encodeURIComponent(location.href) + '" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" />';
			$("#fb-root").append('<div id="facebook-like">' +htmlString + '</div>');	
			
			setTimeout(function(){ 

			  window.fbAsyncInit = function() {
				FB.init({appId: '3207886a03b6ed3e42683d6f128d13fc', status: true, cookie: true,
						 xfbml: true});
			  };
			  (function() {
				var e = document.createElement('script'); e.async = true;
				e.src = document.location.protocol +
				  '//connect.facebook.net/sv_SE/all.js';
				document.getElementById('fb-root').appendChild(e);
					
			  }());
			  
			}, 10);
		
	}
}

  
$(document).ready(function() {
 insertFaceBookLike();
});