window.addEvent('domready', function() {
	var Scroll = new Fx.Morph('scroller',{duration: 1600,link: 'chain',transition: Fx.Transitions.Quad.easeInOut});
	$$('#portfolio').each(function(el) {
		el.addEvents({
			'click': function(e) {
				Scroll.start({'margin-left':'0px;'});
				e.stop();
			}
		});
	});
	$$('#about').each(function(el) {
		el.addEvents({
			'click': function(e) {
				var margin = $('aboutCo').getSize().x;
				Scroll.start({'margin-left':'-'+margin+'px;'});
				e.stop();
			}
		});
	});
	$$('#contact').each(function(el) {
		el.addEvents({
			'click': function(e) {
				var margin = $('contactCo').getSize().x*2;
				Scroll.start({'margin-left':'-'+margin+'px;'});
				e.stop();
			}
		});
	});
	
	var Logo = new Fx.Morph('logo',{duration: 200,link: 'chain',transition: Fx.Transitions.Quad.easeOut});
	$$('#logo').each(function(el) {
		el.addEvents({
			'mouseenter': function(e) {
				Logo.start({'background-position':'0px -39px;'});
				e.stop();
			},
			'mouseleave': function(e) {
				Logo.start({'background-position':'0px 0px;'});
				e.stop();
			}
		});
	});
	
	if ((navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1)) {
		$('container').setStyle('background-image','none');
	}
	
	/* scroller portfolio */
	var CurrentPage = 0;
	var PageCount = Math.ceil($$('#pScroller div.video').length/3);
	
	var pScroll = new Fx.Morph('pScroller',{duration: 400,link: 'ignore',transition: Fx.Transitions.Quad.easeInOut,
		onComplete: function(){
			if (CurrentPage == 0) { $('up').addClass('disable'); } else { $('up').removeClass('disable'); }
			if (PageCount == CurrentPage+1) { $('down').addClass('disable'); } else { $('down').removeClass('disable'); }
		}
	});
	
	$('up').addClass('disable');
	if (PageCount == 1) { $('down').addClass('disable'); }
	
	$$('#up').each(function(el) {
		el.addEvents({
			'click': function(e) {
				if (CurrentPage > 0) {
					CurrentPage --;
					pScroll.start({'margin-top':(CurrentPage*199)*-1+'px;'});
				}
			}
		});
	});
	$$('#down').each(function(el) {
		el.addEvents({
			'click': function(e) {
				if (CurrentPage+1 < PageCount) {
					CurrentPage ++;
					pScroll.start({'margin-top':(CurrentPage*199)*-1+'px;'});
				}
			}
		});
	});
	/* fine scroller portfolio */
	
	$$('div.video a').each(function(el) { 
		var fx = new Fx.Tween(el,{duration: 300,link: 'chain',transition: Fx.Transitions.Quad.easeInOut}); 
		el.setStyle('background-position','-298px 0px').addEvents({ 
			'mouseenter': function(e) {
				el.setStyle('background-position','0px -177px');
				e.stop();
				fx.start('background-position','0px 0px'); 
			},
			'mouseleave': function(e) {
				e.stop();
				fx.start('background-position','0px 177px');
			}
		}); 
	}); 
	
});
