$(function(){
	
	/**
	 * Tabs.
	 * convert all tap-markup into jquery-ui
	 * tabs
	 */
	$('.tabs').tabs();
	
	/**
	 * Global function for delete buttons.  
	 * It locks itself to the class delete on the a tags when the click event is fired.  
	 * It then displays a modal dialog box with two buttons, getting a conformation if 
	 * the user wants to delete the record or not.
	 * 
	 * @author Hilmar Kari Hallbjornsson <hilmar@is-project.org>
	 */
	$('.delete').click(function(event){
		event.preventDefault();
		$('<div class="modal-background"><h2>Ertu viss um að þú viljir eyða þessari færslu?</h2> ' +
				'<p>Það gæti verið að fleiri færslur myndu eyðast, þannig að þú þarft að vera alveg ' +
				'viss um hvað þú ert að gera.  Ef þú velur já, er aðgerðin óafturkræf.' +
			'</div>').appendTo('body').dialog({
			modal: true,
			title: $(event.target).attr('title'),
			buttons: {
				Nei: function(){ $(this).dialog('destroy'); },
				Já: function(){window.location = $(event.target).attr('href');}				
			}
		});	
	});
});
