function makeResize(){
	var offset_c = window.getSize().y.toInt() - $('container').getSize().y.toInt();
	//$('content').setStyle('height', 'auto');
	if(offset_c > 0)$('content').setStyle('height',$('content').getSize().y.toInt()+offset_c);
}
window.addEvent('resize', function(){
	//makeResize();
});
window.addEvent('load', function(){
	makeResize();
	$$('.bs').setStyle('display','block');
	$$('.bs-t-b').each(function(item, index){
		item.setStyle('width', item.getParent().getSize().x.toInt() - 24);
	});
	$$('.bs-l-r').each(function(item, index){
		item.setStyle('height', item.getParent().getSize().y.toInt() - 24);
	});
	
	
});

window.addEvent('domready', function() {
	//makeResize();
	//alert(window.getSize().y+ ' '+$('content').getSize().y);
	//makeResize();
	$$('.reflect').addEvent('click',function(e){
		window.location.href=this.getParent().getParent().getPrevious().get('href');
	});
	
	$$('td.fur-small img').each(function(item, index){
		item.addEvent('click', function(e){
			$$('.fur-big').removeClass('fur-active');
			$$('.fur-big')[index].addClass('fur-active');
		});
	});

	$$('.to-fade').setStyle('opacity',0.3);

	var $chk = function(obj){
		return !!(obj || obj === 0);
	};
	
	var s_value = $('s_value').get('value');
	$('s_value').addEvents({
		'focus':function(e){
			if(this.get('value') == s_value) this.set('value','');
		},
		'blur':function(e){
			if(this.get('value') == '') this.set('value', s_value);
		}
	});

	
	// ---------------------------------------------------------------------------
	
	var subH = new Array();
	var subFx = new Array();
	var menuFx = new Array();
	var subMenuFx = new Array();
	$$('#menu-td a').each(function(item, index){
		if(!item.hasClass('bg-active'))item.setStyle('background-position', '-'+150+'px 0');
		subMenuFx[index] = new Fx.Tween(item,{
			link:'cancel',
			//transition:Fx.Transitions.Expo.easeOut,
			duration:250
		});
		item.getParent().addEvents({
			'mouseenter': function(e){
				if(!item.hasClass('bg-active'))subMenuFx[index].start('background-position', '-10px 0');
			},
			'mouseleave': function(e){
				if(!item.hasClass('bg-active'))subMenuFx[index].start('background-position', '-150px 0');
			}
		});
	});
	
	$$('.bg-fx-a').reverse().each(function(item, index){
		if(!index) item.getParent().setStyle('padding-right',0);
		if($chk(item.getNext('ul'))){
			
			var size = item.getNext('ul').getDimensions();
			subH[index] = size.y.toInt();
			
			item.getNext('ul').setStyle('left', ((item.getParent().getSize().x.toInt()-size.x.toInt())/2).toInt());
			
			subH[index] += 40;
			//alert(subH[index]);
			//alert(item.getNext('ul').getChildren('li')[0].getSize().y);
			item.getNext('ul').setStyles({'height':0,'display':'block'});
			subFx[index] = new Fx.Tween(item.getNext('ul'),{
				link:'cancel',
				duration:250
			})
		};
		
		if(!item.hasClass('bg-active'))item.setStyle('background-position', '-'+150+'px 0');
		menuFx[index] = new Fx.Tween(item,{
			link:'cancel',
			//transition:Fx.Transitions.Expo.easeOut,
			duration:250
		});
		item.getParent().addEvents({
			'mouseenter': function(e){
				if(!item.hasClass('bg-active'))menuFx[index].start('background-position', '-'+(150-item.getSize().x.toInt())+'px 0');
				if($chk(item.getNext('ul')))subFx[index].start('height', subH[index]);
			},
			'mouseleave': function(e){
				if(!item.hasClass('bg-active'))menuFx[index].start('background-position', '-150px 0');
				if($chk(item.getNext('ul'))){
					subFx[index].cancel();
					subFx[index].set('height', 0);
				}
			}
		});
	});
	

	
});

