	function preventDefaultAction(e)	{
		if (e)	{
   			if (typeof e.preventDefault != 'undefined')	{ 
				e.preventDefault(); 
				}               
    		else	{ 
				e.returnValue = false; 
				}                   
  			}
  		// safey for handling DOM Level 0
  		return false;
		}
	function new_proj_id(which) {
		current = $("#projects div.current").attr("id");
		var num = current.substring(current.lastIndexOf('_') + 1, current.length);
		if(which == 'next')
			num++;
		else
			num--;
		var new_id = 'project_' + num;
		return new_id;
		}
	
	function get_last_project_id() {
		return $("#projects div.last").attr("id");
		}
	
	function set_current(id) {
		$("#projects .current").removeClass('current');
		$('#' + id).addClass('current');
		}
						
	function next_project(e) {
		if($('#projects div.current').hasClass('last')) {
			to_project('project_1', 1200);
			}
		else {
			var new_id = new_proj_id('next');
			to_project(new_id, 600);		
			}
		return preventDefaultAction(e);
		}	
	
	function previous_project(e) {
		if($('#projects div.current').hasClass('first')) {
			var last_id = get_last_project_id()
			to_project(last_id, 1200);	
			}
		else {
			var new_id = new_proj_id('previous');	
			to_project(new_id, 600);
			}
		return preventDefaultAction(e);
		}
		
	function to_project(new_id, speed) {
		if(speed) {
			$("#projects").animate({
					left: 70-$('#' + new_id).position().left
					}, speed);
				set_current(new_id);
			}
		else {
			$("#projects").animate({
					left: 70-$('#' + new_id).position().left
					}, 600);
				set_current(new_id);
			}
		}
	
	function init() {
		jQuery.easing.def = "easeOutQuint";
		$('#contact').contactable();
		$("#next_project_btn").click(next_project);
		$("#previous_project_btn").click(previous_project);
		var navTimer = null;
		$('div.project_info').fadeTo(5, 0);
		$('div.project_info').show();
		$('div.project_info').hover(
			function() {$(this).fadeTo('normal', 1); },
			function() {$(this).fadeTo('normal', 0);}
			);
		}
		
	//initiate when the document is ready
	$(document).ready(function(){
		init();	
		
	});
