Event.observe(window,'load',function(){
									 
	$$('#header li a').each(function(it){
		if(it.up().hasClassName('act'))window.curSel = $(it.up());
		
		Event.observe(it,'mouseover',function(){
			$$('#header li a').each(function(it){
				if(it.up().hasClassName('act'))it.up().removeClassName('act');
			});
		});
		
		Event.observe(it,'mouseout',function(){
			$$('#header li a').each(function(it){
				window.curSel.addClassName('act');
			});
		});
	});
	checkPosition();
	
	Event.observe(window,'resize',function(){
		checkPosition();
	});
	
	$$('.item a.download').each(function(lnk){
		Event.observe(lnk,'mouseover',function(ev){
			var el = Event.element(ev);
			if(!el.hasClassName('download'))el = Event.element(ev).up();

			el.up().style.zIndex = '101';
			el.next().style.bottom = (Position.cumulativeOffset(el)[1]-Event.pointerY(ev) + 10) + 'px';
			el.next().style.left = (Event.pointerX(ev)-Position.cumulativeOffset(el)[0] + 50) + 'px';
			
			el.next().show();
		});
		
		Event.observe(lnk,'mousemove',function(ev){
			var el = Event.element(ev);
			if(!el.hasClassName('download'))el = Event.element(ev).up();

			el.next().style.bottom = (Position.cumulativeOffset(el)[1]-Event.pointerY(ev) + 30) + 'px';
			el.next().style.left = (Event.pointerX(ev)-Position.cumulativeOffset(el)[0] + 70) + 'px';
		});
		
		Event.observe(lnk,'mouseout',function(ev){
			var el = Event.element(ev);
			if(!el.hasClassName('download'))el = Event.element(ev).up();
			el.up().style.zIndex = '100';
			el.next().hide();
		});
	});
});

function getAvailSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth,myHeight];
}

function checkPosition()
{
	document.getElementById("content").style.height = $('data').getHeight() +'px';
	
	if($('decor_big'))
	{
		if(getAvailSize()[0] > 1305)
		{
			$('decor_big').show();
			$('decor').hide();
		}
		else
		{
			$('decor').show();
			$('decor_big').hide();
		}
	}
	
	if(getAvailSize()[0] < 880)
	{
		document.getElementById("wrap").style.width = '880px';
	}
	else
	{
		document.getElementById("wrap").style.width = '100%';
	}
	
	if(getAvailSize()[1] < ($('data').getHeight()+240))
	{
		document.getElementById("wrap").style.height = ($('data').getHeight()+240)+'px';
		document.getElementById("content").style.top = '120px';
		document.getElementById("content").style.marginTop = '0px';
	}
	else
	{
		document.getElementById("wrap").style.height = '100%';
		document.getElementById("content").style.top = '50%';
		document.getElementById("content").style.marginTop = '-'+($('data').getHeight()/2)+'px';
	}
}
