function setSelRange(inputEl, selStart, selEnd) { 
	if (inputEl.setSelectionRange) { 
		inputEl.focus(); 
		inputEl.setSelectionRange(selStart, selEnd); 
	} else if (inputEl.createTextRange) { 
		var range = inputEl.createTextRange(); 
		range.collapse(true); 
		range.moveEnd('character', selEnd); 
		range.moveStart('character', selStart); 
		range.select(); 
	}
}

function displayLikes(post_id) {

	$.get('/ajax/likes.php?action=display&post_id='+post_id,function(html) {
	
		$('#p'+post_id+' .postlikes').html(html).fadeIn();
	
	});

}

function Like(post_id,status) {

	$('#p'+post_id+' .postlikes').html('').hide();

	$.get('/ajax/likes.php?action=like&post_id='+post_id+'&status='+status,function(html) {
	
		$('#p'+post_id+' .postlikes').html(html).fadeIn();
	
	});

}

function getSelectedText() {
    if (window.getSelection) {
        return window.getSelection();
    } else if (document.selection) {
        return document.selection.createRange().text;
    }
    return '';
}

function spoilerToggle(elem) {

	div = $(elem).parent().parent();

	if ($(div).find('.content').css('display') == 'none') {
		$(div).find('.content').css('display','block');
		$(div).find('a:first').html('Masquer');
	} else {
		$(div).find('.content').css('display','none');
		$(div).find('a:first').html('Afficher');
	}

}
