var headid = 'headslider';
var photoid = 'gallery_photos';
var videoid = 'gallery_videos';
var mysliderXpos = 0;
function slideTheHead( direction ) 
{
	if( changeState != true )
		return;
	if( direction == 'photos' && mysliderXpos == 300 )
	{
		slideNow( 0 , 1, 0);
	}
	else if( direction == 'videos' && mysliderXpos == 0 )
	{
		slideNow( 300, 0, 1);
	}
}
var first, second;
function slideNow( x )
{
	if(changeState != true){
		return;
	}else{
		changeState = false;
	}
	mysliderXpos = x;
	if( x == 300 ){
		first = photoid;
		second = videoid;
		
	}else{
		first = videoid;
		second = photoid;
	}
	document.getElementById(first).style.zIndex = 1;
	document.getElementById(second).style.zIndex = 10;
	var myEffect = new Fx.Morph( document.getElementById(headid), {duration: '2000', transition: 'circ:out', onComplete: setMyHeadState});
		myEffect.start({
			'left': x
		});	

	var myNextEffect = new Fx.Morph( document.getElementById(first), {duration: '1000', transition: 'linear',onComplete: timetofade });
		myNextEffect.start({
			'opacity': [1,0]
		});	

}

function timetofade()
{
	var myAfterNextEffect = new Fx.Morph( document.getElementById(second), {duration: '1000', transition: 'circ:in'});
		myAfterNextEffect.start({
			'opacity': [0,1]
		});		
}

function setMyHeadState()
{
	changeState = true
}
/*
function onmouseoverMyBild( el )
{
	el.style.border = '5px solid #2bd8ff';
} 

function onmouseoutMyBild( el )
{
	el.style.border = '5px solid #cccccc';
}*/

window.addEvent('domready', function() {

	var myEffect = new Fx.Morph( document.getElementById('gallery_videos'), {duration: '0', transition: 'circ:in'});
		myEffect.start({
			'opacity': [0,0]
		});
	$$('div.gallery_text').addEvents({
    		'mouseover': function(){
			if( this.offsetWidth >= 195 ){
      			 	this.set('tween', {duration: 500});
				this.tween('left', 195-this.offsetWidth);
			}
   	 	},
    		'mouseout': function(){
       	 	//e.stop();
			this.set('tween', {duration: 0});
			this.tween('left', 0);
    		}
	})

	$$('#gallery_photos div.gallery_element').addEvents({
    		'mouseover': function(){
      			 	this.setStyle('border-color', '#2bd8ff');
   	 	},
    		'mouseleave': function(){
       	 	//e.stop();
			this.set('tween', {duration: 500});
			this.tween('border-color', '#2bd8ff', '#cccccc');
    		}
	})

	$$('#gallery_videos div.gallery_element').addEvents({
    		'mouseover': function(){
      			 	this.setStyle('border-color', '#BB9144');
   	 	},
    		'mouseleave': function(){
       	 	//e.stop();
			this.set('tween', {duration: 500});
			this.tween('border-color', '#BB9144', '#cccccc');
    		}
	})
})
