<!--

window.addEvent('domready', function() 
{
  // center background image
  setBackgroundImg();
  // set sponsor box
  setSponsorBox();
	
  // change position of background and sponsor box when window size changes
  window.addEvent('resize', function() {
    setBackgroundImg();
    setSponsorBox();
  });
	
});


function setBackgroundImg()
{
	// if kalender is selected, show wallpaper3 (because its black and so the calender legend is visible best)
	//var res = document.URL.match(/fizik-team.com\/(.*)/);
	//if (res[1] == 'index.php/kalender')
	var res = document.URL.match(/(fizik|fizik-team\.com)\/(.*)/);
	if (res[2] == 'index.php/kalender')
		wallpaper = '3';
	else  // random image
	{
		var imgNum = Math.random();
		if (imgNum < 0.333333)
			wallpaper = '1';
		else if (imgNum > 0.666666)
			wallpaper = '2';
		else
			wallpaper = '3';
	}
	
	var imgWidth = 2182;
	var imgHeight = 1079

  $('backgroundImage').setProperty('src', '/images/fizik/wallpaper/wallpaper_'+wallpaper+'.jpg');
  
	// center background image horizontally
  var pos = (window.getWidth() - imgWidth) / 2;
  pos = pos - (pos % 1);  // ganze zahl draus machen
  $('backgroundImage').setStyle('left', pos+'px');
}


function setSponsorBox()
{
  pos = window.getWidth() / 2 + (681/2) + 26;
  pos = pos - (pos % 1);  // ganze zahl draus machen
  $('sponsorsContent').setStyle('left', pos+'px');
  
  // check if box is too large to display   
  var elementHeight = $('sponsorsContent').getStyle('height'); 
  var res = elementHeight.match(/([\.0-9]*)\D\D/);  // remove 'px' from result
  elementHeight = res[1];

  if ( window.getHeight() < parseInt(elementHeight)+10 )
    $('sponsorsContent').setStyle('top', '0px');
}

-->
