var x = 0;
var gap = (isIE6()) ? -757 : -742;
var item = 0;

// Capture key pressed (fuck IE)
onkeydown = function(e){
	var evt = new Event(e);	
	if (evt.key == 'right' || evt.key == 'left')
			slideFolio(evt.key);
}

function slideFolio(side){
	if (side=='right')
	{
		if (item < (nb_pages-1))
		{
			if (item == 0)
			{
				$('img_prev').src = url_prev;
				$('href_prev').href = 'javascript:slideFolio(\'left\');';
				$('img_prev2').src = url_prev;
				$('href_prev2').href = 'javascript:slideFolio(\'left\');';
			}
			item += 1;
			x = (item*gap);
			if (item == (nb_pages-1))
			{
				$('img_next').src = url_next_d;
				$('href_next').href = '#';
				$('img_next2').src = url_next_d;
				$('href_next2').href = '#';
			}
		}
	}
	else
	{
		if (item > 0)
		{
			if (item == (nb_pages-1))
			{
				$('img_next').src = url_next;
				$('href_next').href = 'javascript:slideFolio(\'right\');';
				$('img_next2').src = url_next;
				$('href_next2').href = 'javascript:slideFolio(\'right\');';
			}
			item -= 1;
			x = (item*gap);
			if (item == 0)
			{
				$('img_prev').src = url_prev_d;
				$('href_prev').href = '#';
				$('img_prev2').src = url_prev_d;
				$('href_prev2').href = '#';
			}
		}
	}
	var folioChange = new Fx.Style('projects_full', 'left', {duration:700});
	folioChange.start(x);				
}

function isIE6()
{	
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	if(strChMid.indexOf("MSIE 6") != -1) 
		return true;
	else
		return false;
}
