	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: 44-$('#' + new_id).position().left
					}, speed);
				set_current(new_id);
			}
		else {
			$("#projects").animate({
					left: 44-$('#' + new_id).position().left
					}, 600);
				set_current(new_id);
			}
		}
	
	function init() {
		jQuery.easing.def = "easeOutQuint";		
		$("#next_project_btn").click(next_project);
		$("#previous_project_btn").click(previous_project);
		var navTimer = null;
		$('div.panelAction, div.panel_bg, div.panel_hit, div.panelActionMid, div.panel_bgMid, div.panel_hitMid, div.panelActionRt, div.panel_bgRt, div.panel_hitRt').fadeTo(6, 0);
		$('div.panelAction, div.panel_bg, div.panelActionMid, div.panel_bgMid, div.panelActionRt, div.panel_bgRt').show();
		$('div.panelAction, div.panelActionMid, div.panelActionRt').hover(
			function() {$(this).fadeTo('normal', 1); $(this).siblings('div.panel_bg, div.panel_bgMid, div.panel_bgRt').fadeTo('normal', .90);},
			function() {$(this).fadeTo('normal', 0); $(this).siblings('div.panel_bg, div.panel_bgMid, div.panel_bgRt').fadeTo('normal', 0);}
			);
		}
		
		
	//initiate when the document is ready
	$(document).ready(function(){
		init();	 
	});
	
	function SimpleSwap(el,which){
  	el.src=el.getAttribute(which || "origsrc");
	}
function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var onmouseover = x[i].getAttribute("onmouseover");
    if (!onmouseover) continue;
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].onmouseover_img = new Image();
    x[i].onmouseover_img.src=onmouseover;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'onmouseover');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}
var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}
