$(document).ready(function(){	
	function toggleArticle(element) {
		element.toggleClass('selected').parent().find('div.articles_htmlContent').slideToggle('fast')
	}
	
    $('#boxBriefing').find('span.articles_title').wrap('<a href=\'#\'></a>').parent().click(function(){
    	if($(this).attr('class')=='selected') {
    		toggleArticle($(this));
    	}
    	else {
    		toggleArticle($('a.selected'));
    		toggleArticle($(this));
    	}
    	return false;
	});

	
	$('.tabs').tabs();
	
	var d = $('iframe#dialog');
	
	if (d.length > 0) {
		var horizontalPadding = 30;
		var verticalPadding = 30;
		
		$('iframe#dialog').dialog({
           			title: '',
                    autoOpen: false,
                    width: 530,
                    height: 450,
                    modal: true,
                    resizable: false,
        			autoResize: true,
                    overlay: {
                        opacity: 0.5,
                        background: "black"
                    }
        }).width(500 - horizontalPadding).height(450 - verticalPadding);
		$("span.ui-icon-closethick").html('Sulje');
	}
	
	$('a.openDialog').click(function(e) {
		
		e.preventDefault();
		d.dialog('open');
		d.width(470).height(420);
	});
	
});

function closeCommentDialog(){
	$('iframe#dialog').dialog('close');
	window.location.href = window.location.href + '#commentList';
}