$(document).ready(function(){
	dropdown_menu();

	$(".delete-notification a").live('click', function(){
		var handler = $(this);
		$.ajax({
			url: "/php/ajax/delete_notification.php",
		  	data: "notificationid="+handler.attr('notificationid'),
		  	type: "POST",
		  	success: function(){
		  		$("#notification-id-"+handler.attr('notificationid')).fadeOut();
		  		
		  		//handler.parent().parent().fadeOut();
		  		//$(this).parent().hide();
		  	}
		});
		
		return false;
	});
});

function dropdown_menu() {
	$("#openlangpicker").click(function() { //When trigger is clicked...
		$.get('/template/sub-template/langpicker.php', function(data) {
			$("#langpicker").html(data).toggle();
			//$("#langpicker").css('display', 'block');
		});
	});		
}


/*
 * JavaScript Pretty Date
 * Copyright (c) 2011 John Resig (ejohn.org)
 * Licensed under the MIT and GPL licenses.
 */

// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time){
	var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
		diff = (((new Date()).getTime() - date.getTime()) / 1000),
		day_diff = Math.floor(diff / 86400);
			
	if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
		return;
			
	return day_diff == 0 && (
			diff < 60 && diff+"s" ||
			diff < 120 && "1m" ||
			diff < 3600 && Math.floor( diff / 60 ) + "m" ||
			diff < 7200 && "1h" ||
			diff < 86400 && Math.floor( diff / 3600 ) + "h") ||
		day_diff == 1 && "y" ||
		day_diff < 7 && day_diff + " days ago" ||
		day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
}
