	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 = jQuery("#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 jQuery("#projects div.last").attr("id");
		}
	
	function set_current(id) {
		//alert("sandy"+id);
		jQuery("#projects .current").removeClass('current');
		jQuery('#' + id).addClass('current');
		}
						
	function next_project(e) {
		if(jQuery('#projects div.current').hasClass('last')) {
			to_project('project_1', 1780);
			}
		else {
			var new_id = new_proj_id('next');

			to_project(new_id, 890);		
			}
		return preventDefaultAction(e);
		}	
	
	function previous_project(e) {
		if(jQuery('#projects div.current').hasClass('first')) {
			var last_id = get_last_project_id()

			to_project(last_id, 1780);	
			}
		else {
			var new_id = new_proj_id('previous');	
			to_project(new_id, 890);
			}
		return preventDefaultAction(e);
		}
		
	function to_project(new_id, speed) {
		if(speed) {
			jQuery("#projects").animate({
					left: 0-jQuery('#' + new_id).position().left
					}, speed);
				set_current(new_id);
			}
		else {
			jQuery("#projects").animate({
					left: 0-jQuery('#' + new_id).position().left
					}, 890);
				set_current(new_id);
			}
		}
	
	function init_q() {
		jQuery.easing.def = "easeOutQuint";
		
		jQuery("#next_project_btn").click(next_project);
		jQuery("#previous_project_btn").click(previous_project);
		

		
		jQuery('#project_list a').click(function() 
		{
			to_project(jQuery(this).attr('title'), 890)
			return preventDefaultAction();
			});
	
		}
		
	//initiate when the document is ready
	jQuery(document).ready(function(){
		init_q();	 
	});