function likeAjax(id,likes) {
	$.ajax({
	   type: "POST",
	   url: "http://www.8p.ro/like.php",
	   data: "id="+id,
	   success: function(msg){
		if(msg=='ok')
			$("#l"+id).html(likes+1);
		else
			alert('Ai votat deja acest post.');
		}
	});				
}

function dislikeAjax(id,dislikes) {
	$.ajax({
	   type: "POST",
	   url: "http://www.8p.ro/dislike.php",
	   data: "id="+id,
	   success: function(msg){
			if(msg=='ok')
				$("#d"+id).html(dislikes+1);
			else
				alert('Ai votat deja acest post.');
		}
	});				
}

function show_facebook_popin(){
	
	if (readCookie("facebook_popin") != 1){
	
		$("#facebook_popin").fancybox({
			'width'				: 760,
			'height'			: 330,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});
	
		$('#facebook_popin').trigger('click');
		
		createCookie("facebook_popin","1",1);
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
