var myScroll,media;
window.addEvent('domready', function(){
	if($$('article menu ul li').length>0){
		$$('article menu ul li')[0].destroy();
		$$('article menu ul li a').addEvent('click', function(e){
			e.stop();
		})
		var acc = new Fx.Accordion($$('article menu ul li a'), $$('article div.tab'), {
			'onActive': function(a){
				a.getParent('ul').getElements('a').removeClass('active');
				a.addClass('active');
			}
		});
	}	
	
	resizeGrid();
	
	if(Browser.Device.ipad ||Browser.Device.iphone){
		myScroll = new iScroll(document.getElement('section'));
	}
	if($('resizeCenter')){
		$('resizeCenter').addEvent('click', function(event){

		});
	}
	if(false){
		media = new Element.Media('background', {
			//autoBuffer:true,
			//autoPlay:true,
			onEnded: function(){this.play()},
			element: {
				create: true,
				type: 'video',
				properties: {
					id: 'cinemoo',
					loop: 'loop'
				},
				sources: [
					{ url: '/images/Comp.ogg', type: 'video/ogg' },
					{ url: '/images/Comp.mp4', type: 'video/mp4' }
				],
			}   
		});
		document.getElement('section').addEvent('touchstart', function(){
			media.play();
		});
	}
});
function resizeGrid(){
	var items = $$('.projects li');
	if(items.length>0){
		var w = document.getElement('.projects ul').getSize().x-1;
		var c = Math.ceil(w/320);
		items.setStyles({
			'width': w/c-1
		});
	}}
window.addEvent('resize', function(){
	resizeGrid();
	if(myScroll){
		myScroll.refresh();
	}
});
window.addEvent('load', function(){
	if(myScroll){
		myScroll.refresh();
	}
});
