var resizeW = function(){
	
    var h = window.getSize().y;
	var w = window.getSize().x;
	if(w<1100) w =1100;
	if(w>1700)w = 1700;
	var imgw = w-30;
	var imgh = ((imgw/1700)*963)+50;
	
	//var top = (-(w*913/1700)+715);
	var marginTOP = ((imgh-585)/2-20 > 30) ? Math.round((imgh-585)/2-20) : 30;
	//var marginTOPwide = ((h-imgh)-100)/3 > 0 ? ((h-imgh)-100)/3 : 0;
	//var marginTOPnoW = (h-680)/3 > 20 ? (h-680)/3 : 20;

	//var margin = w-840 < 0? 0: Math.round(w-840);

	//center in the x-axis

	
	if($defined($('background').getElement('img'))){
		$('background').getElement('img').setProperties({'height':imgh,'width':imgw});
	}
	$('background').setStyles({'width':imgw,'height':imgh});
	$('wrapper').setStyles({'width':imgw,'height':imgh});
	$('site').setStyles({'margin-top':marginTOP});
	
	/*if(h>(imgh)){
	$('site').setStyles({'margin-top':marginTOPnoW});
	}*/
	
	//
	
	
};
window.addEvent('domready', function() {
	resizeW();

	//------ loading background --------
	var link2 = $('background').getProperty('title');
	//alert(link2);
	var image2 = new Asset.image(link2, { 'id': 'test',
										onload: function(){
    										 		 //$('background').empty();
    												 this.inject($('background'));
    												 resizeW(true);		
    												 }
    									});

	

	
	//------ morphing --------
	$('menu').getElements('li:not([class$=page])').each(function(li){
	var limorph = new Fx.Morph(li.getElement('span'), {duration: 300, transition: 'expo:out'});
	li.addEvent('mouseenter', function(){
		limorph.pause().start({'margin-left':15});
		});
	li.addEvent('mouseleave', function(){
		limorph.pause().start({'margin-left':0});
		});
	});
	//------ menu deroulant -------
	$('menu').getElements('li[class=sectionheader])').each(function(e){
		var el = e.getElement('a');
		var height = 22;//$('menu').getElement('li[class!=sectionheader]').getSize().y;
		var heightF = (e.getElements('li').length+1)*23;//e.getSize().y;
		e.setStyle('height', height);
		var open = new Fx.Morph(e, {duration: 500, transition: 'expo:out'});
		var n = height;
		el.addEvent('click', function(i){
		i.stop();
		n = (n == height) ? heightF : height;
		open.pause().start({'height':n});
		});
	});

});
var timer;
window.addEvent('resize', function(){
	$clear(timer);
	 timer = (function(){
	   resizeW();
	 }).delay(50);
	
});
