window.addEvent('domready', function(){

	/* generic code to open all links with rel=_blank in new window, to pass validation in xhtml strict. */
	$$('a').each(function(link,i){
		if(link.get('rel')=='_blank') link.setProperty('target','_blank');
		
		if(link.hasClass('friend'))
		{
			link.addEvent('click', function(e){
				
				new MooDialog.Iframe(link.get('rel'), {
						'class': 'MooDialog myDialog'
				});
			});
		}
	});	
	
	/* end link code */

	/* Standard function to give mCCWrapper the remaining window height if avoidElements is defined */
	//autosize_mCCWrapper();

	/* Standard function to mark all last listitems with class=last in the current document - default enabled */
	markLastLis();
	
	/* Standard function to mark left/right sibling on list - enable with .mark_siblings on list */
	markSiblings();

	/* Fix last li width topmenu for font diffrences */
	var totalwidth = 928;
	Array.each($$('ul.menu li'),function(el,i){
		if(!el.hasClass('last'))
			totalwidth = totalwidth - el.getSize().x;
		if(el.hasClass('last'))
			el.setStyle('width',totalwidth+'px');
	});
	
	/* Init tooltips */
	var tooltips = new Tips($$('.dotips'), {
		offset: {'x': 0, 'y': 35},
		fixed: true,
		className: 'tool-tip'
	});

	/* Clear focus search */
	$('q').addEvents({
		'focus': function(e){
			this.value = (this.value == this.get('title') ? '' : this.value);
		},
		'blur': function(e){
			if(this.value=='')
				this.value='S\xF8k i Mestergruppen...';
		}
	});
	
	/* Handle pane heights */
	/* If template: overview_1 */
	if($(document.body).hasClass('tripane')){
	//	makeSameHeight($$('#leftpane,#centerpane,#rightpane'));
	}	
	/* If template: overview_2 */
	if($(document.body).hasClass('overview_2')){
		makeSameHeight($$('#leftpane,#paneCpane'));
	}
		
});

window.addEvent('resize', function(){
	
	/* Standard function to give mCCWrapper the remaining window height if avoidElements is defined */
	//autosize_mCCWrapper();
	
});
