jQuery.noConflict();

Event.observe(window, 'load', hideSkills);
Event.observe(window, 'load', fadeImages);
Event.observe(window, "load", blendProjects);

function blendProjects() {
	var gallery = [  
		{ img: "myguestlist.jpg" },      
		{ img: "tfuapp.jpg" },  
	    { img: "bandtshirts.jpg" },  
	    { img: "bandtshirtsaccounts.jpg" },  
	    { img: "essen.jpg" },  
	    { img: "thq.jpg" },  
	    { img: "timetable.jpg" }
	];  

	new Blender("project-image-blender", gallery.pluck("img"), { dir: "splash/", startIndex: 0 });	
}

function hideSkills() {
	var skills = $$('.skill-blurb');
	skills.each(function(skill) {
		new Effect.toggle(skill, 'blind', { duration: 0.5 });
	});
}

function toggleSkill(id) {
	new Effect.toggle(id, 'blind', { duration: 0.5 });
	return false;	
}

function fadeImages() {
	$('project-image').setStyle({ opacity: 0.5 });
	$('project-image').observe('mouseover', highlightImage);
	
	var screenshots = $$('.screenshot');
	screenshots.each(function(screenshot) {
		$(screenshot).setStyle({
			opacity: 0.5
		});
		
		$(screenshot).observe('mouseover', highlightImage);
		
	});

	var videos = $$('.video');
	videos.each(function(video) {
		$(video).setStyle({
			opacity: 0.5
		});
		
		$(video).observe('mouseover', highlightImage);
		
	});

}

function highlightImage() {
	if (this.getOpacity() != 0.5) { return; }
	new Effect.Opacity(this, {duration: 0.2, from: 0.5, to: 1.0});	
}

function fadeImage() {
	if (this.getOpacity() != 1) { return; }
	new Effect.Opacity(this, {duration: 0.2, from: 1.0, to: 0.5});
}


function showProjects() {
	new Effect.Parallel([new Effect.Fade($('index-content'), { duration: 0.5, sync: true })], { duration: 0.5 });
	new Effect.Parallel([new Effect.Appear($('project-content'), { duration: 0.5, sync: true })], { duration: 0.5, delay: 0.5 });					
}

function hideProjects() {
	new Effect.Parallel([new Effect.Fade($('project-content'), { duration: 0.5, sync: true })], { duration: 0.5 });
	new Effect.Parallel([new Effect.Appear($('index-content'), { duration: 0.5, sync: true })], { duration: 0.5, delay: 0.5 });
}

jQuery(document).ready(function($) {

	$("a.fancybox").fancybox({
		'padding': 				5,
		'zoomSpeedIn':			300, 
		'zoomSpeedOut':			300,
		'zoomOpacity':  		true,
		'hideOnContentClick': 	true,
		'overlayShow':			true,
		'overlayOpacity':		0.6,
		'frameWidth': 			486,
		'frameHeight': 			472
	});

	$("#project-showreel").scrollable({ size: 1, clickable: false, keyboard: false });

	$('#photo').blend({ top: false, speed: 300 });

});

