//Javascript navigation shit
//Navigation animation
var Nav = {
	links: $$('#left_container h1 a'),
	init: function(){
		this.links.each(function(link, index){
			link.anim = new Fx.Tween(link, {duration: 100});

			link.addEvent('mouseover', function(){
				this.anim.cancel();
				//this.anim.start('margin-top', 50, 0);
				$('nav-tooltip').set('class', this.get('rel'));
				$('nav-tooltip').tween('margin-top', this.getPosition($('container')).y + this.getSize().y/2 - 50);
				//$('nav-tooltip').tween('left', 500);
			});
			link.addEvent('mouseout', function(){
				this.anim.cancel();
				$('nav-tooltip').set('class', 'hello_link');
				$('nav-tooltip').tween('margin-top', 0);
				//this.anim.start('margin-top', 0, 50);
			});
		});
	}
}

function resize(){
	size = Window.getSize();
	$('fakeBody').setStyle('height', size.y - 52);
}

Images = {
	preload: function(){
		var cssImages = new Asset.images(
			[
				'images/background.jpg',
				'images/tooltip/about_me.png',
				'images/tooltip/credits.png',
				'images/tooltip/links.png',
				'images/tooltip/myworks.png',
				'images/tooltip/navigation.png',
				'images/tooltip/sayhello.png',
				'images/tooltip/skillset.png'
			],
		{
	    	onComplete: function(){
	        	$('background').setStyles({
	        		'background-image': 'url(images/background.jpg)',
	        		'background-position': 'top center'
	        	});
	        	$('fakeBody').setStyle('visibility', 'visible');
	        	$('footer').setStyle('visibility', 'visible');
		    }
		});
	}
}

window.addEvents({
	'domready': function(){
		Images.preload();
		resize();
		Nav.init();
		setWelcomeTxt();	
	},
	
	'resize': function(){
		resize();
	}
});

window.addEvent('domready', function() {
	$$('#footer a').each(function(footLink) {
		footLink.addEvent('mouseover', function() {
		  this.tween("background-color", "#FFF", "#ffff00");
		  this.tween("color", "#FFF", "#000");
		});
		footLink.addEvent('mouseout', function() {
		  this.tween("background-color", "#000");
		  this.tween("color", "#FFF", "#555");
		});
	});
	$$('#links_container a').each(function(favLink) {
		favLink.addEvent('mouseover', function() {
		  this.tween("background-color", "#FFF", "#FFFF00");
		  this.tween("color", "#FFF", "#000");
		});
		favLink.addEvent('mouseout', function() {
		  this.tween("background-color","#000");
		  this.tween("color", "#FFF","#555");
		});
	});
	$$('#works_content a').each(function(myLinks) {
		myLinks.addEvent('mouseover', function() {
		  this.tween("background-color", "#FFF", "#FFFF00");
		  this.tween("color", "#FFF", "#000");
		});
		myLinks.addEvent('mouseout', function() {
		  this.tween("background-color","#000");
		  this.tween("color", "#FFF","#555");
		});
	});
	$$('#iam_content a').each(function(myLinks) {
		myLinks.addEvent('mouseover', function() {
		  this.tween("background-color", "#FFF", "#FFFF00");
		  this.tween("color", "#FFF", "#000");
		});
		myLinks.addEvent('mouseout', function() {
		  this.tween("background-color","#000");
		  this.tween("color", "#FFF","#555");
		});
	});
});

var setWelcomeTxt = function(){
	var div = $('welcome_message').setStyles({
		display:'block',
		opacity: 0
	});
	$('welcome_message').fade(0.7);
	$('welcome_message').addEvent('mouseover', function() {
			this.fade(1);
	});
	$('welcome_message').addEvent('mouseout', function() {
			this.fade(0.3);
	});
};
 


/*$('newwin').addEvent('click', function() { 
	$$('#background a').each(function() {
		a
	}
});
$('myImage').setProperty('src', 'mootools.png');*/
