var Theme =
{
	ResizeBody: function()
	{
		var leftHeight = $('links').offsetHeight;
		var rightHeight = $('rechts').offsetHeight;
		
		if( $('links').hasClass('special') )
		{
			leftHeight = leftHeight-58;
		}
		
		if( rightHeight < leftHeight )
		{
			$('pbrw').setStyle('height', (leftHeight-rightHeight)+1);
		}
		
		if( rightHeight > leftHeight )
		{
			$('pblw').setStyle('height', (rightHeight-leftHeight)+1);
		}
	},
	
	hoverRow: function(el, state)
	{
		var items = $(el).getChildren();

		for (var i=0; i<items.length; i++)
		{
			if (items[i].nodeName.toLowerCase() == 'ul')
			{
				items[i].setStyle('background-color', (state ? '#ebfdd7' : ''));
			}
		}
	},

	hoverDiv: function(el, state)
	{
		$(el).setStyle('background-color', (state ? '#ebfdd7' : ''));
	}
};


function getTips()
{
	//store titles and text
	$$('a.tipz').each(function(element,index) 
	{
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	});
	
	//create the tooltips
	var tipz = new Tips('.tipz',{
		className: 'tipz',
		fixed: true,
		hideDelay: 50,
		showDelay: 50
	});
}

/**
 * Topheader füllen
 */
function getStandardAd()
{
	window.setTimeout( function() {
		$("ContentSpecialHeader").addClass('bgAdd');;
		window.clearInterval();
	}, 3000);
}

var RequestCalendar =
{
	/**
	 * Kalendersteuerung
	 */
	changeMonth: function( monat )
	{
		// Kalender ausblenden
		var overlay = $('loadbox');

		if (!overlay)
		{
			overlay = new Element('div').setProperty('id', 'loadbox').injectInside($('ajax_calendar'));
		}
		
		overlay.setStyle('display', 'block');
//		$('loadbox').addClass('loading');
		$('calendar_rechts').fade(0);
		
		window.setTimeout( function()
		{
			new Request(
			{
				url: 'ajax.php?action=fmd&id=7&g=1&month='+monat,
				onComplete: function(txt, xml)
				{
					$('calendar_rechts').innerHTML = txt;
					getTips();
//					$('loadbox').removeClass('loading');
					overlay.setStyle('display', 'none');
					$('calendar_rechts').fade(1);
				}
			}).send();
		
		}, 600);
	}	
}


/**
 * Funktion zum Ligawechsel
 * ModuleMatchDayShort
 */
function changeLeague( id, el )
{
	$$("#MatchDayShort ul").removeClass('active');
	$$("#MatchDayShort a").removeClass('active');
	$('league_'+id).addClass('active');
	el.addClass('active');
}

/**
 * Open a new window (used by file trees and the help wizard)
 * @param object
 * @param integer
 * @param integer
 */
function openWindow(el, width, height)
{
	el.blur();
	width = Browser.Engine.trident ? (width + 40) : (width + 17);
	height = Browser.Engine.trident ? (height + 30) : (height + 17);

	window.open(el.href, '', 'width='+width+',height='+height+',modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}
