jQuery(function( $ ){
				
	var currentimg = 0;
	
	$(".lightbox").lightbox();
	
	if(($('#images li').length)>8) {
		document.getElementById('images').style.width = ($('#images li').length*115)+'px';
		//borrowed from jQuery easing plugin
		//http://gsgd.co.uk/sandbox/jquery.easing.php
		$.easing.easeOutExpo = function (x, t, b, c, d) {
			return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
		};
		
		$('#screen').scrollShow({
			view:'#view',
			content:'#images',
			easing:'easeOutExpo',
			//navigators:'a[id]',
			navigationMode:'sr',
			circular:false
		});
		
		$('#view').scrollTo('40px', 0, {axis:'x'});
		
		np = function(i) {
			if(currentimg < ($('#images li').length-8)) {		
				currentimg++;
				$('#view').scrollTo((currentimg*115+40)+'px', 300, {axis:'x', onAfter:function() {if(i>0) {cp(currentimg);} } });
			}
			if(currentimg >= ($('#images li').length-8)) {
				document.getElementById('rightlink').style.display = 'none';
				document.getElementById('rightarrow').style.display = 'none';				
			}
			if(currentimg>0) {
				document.getElementById('leftlink').style.display = 'inline';
				document.getElementById('leftarrow').style.display = 'inline';				
			}
		}
		
		ns = function(i) {
			if(currentimg < ($('#images li').length-8)) {		
				currentimg+=8;
				if(currentimg > ($('#images li').length-8)) { 
					currentimg = ($('#images li').length-8);
				}
				$('#view').scrollTo((currentimg*115+40)+'px', 800, {axis:'x', onAfter:function() {if(i>0) {cp(currentimg);} } });
			}
			if(currentimg >= ($('#images li').length-8)) {
				document.getElementById('rightlink').style.display = 'none';
				document.getElementById('rightarrow').style.display = 'none';				
			}
			if(currentimg>0) {
				document.getElementById('leftlink').style.display = 'inline';
				document.getElementById('leftarrow').style.display = 'inline';				
			}
		}
		
		ns2 = function(i) {
			if(currentimg < ($('#images li').length-12)) {		
				currentimg+=12;
				if(currentimg > ($('#images li').length-12)) { 
					currentimg = ($('#images li').length-12);
				}
				$('#view').scrollTo((currentimg*81+40)+'px', 800, {axis:'x'});
			}
			if(currentimg >= ($('#images li').length-12)) {
				document.getElementById('rightarrow').style.display = 'none';				
			}
			if(currentimg>0) {
				document.getElementById('leftarrow').style.display = 'inline';				
			}
		}
		
		pp = function(i) {
			if(currentimg > 0) {
				currentimg--;	
				$('#view').scrollTo((currentimg*115+40)+'px', 300, {axis:'x', onAfter:function() {if(i>0) {cp(currentimg);} } });
			}
			if(currentimg == 0) {
				document.getElementById('leftlink').style.display = 'none';
				document.getElementById('leftarrow').style.display = 'none';				
			}
			if(currentimg < ($('#images li').length-8)) {
				document.getElementById('rightlink').style.display = 'inline';
				document.getElementById('rightarrow').style.display = 'inline';				
			}
		}
		
		ps = function(i) {
			if(currentimg > 0) {
				currentimg-=8;	
				if(currentimg < 0) currentimg = 0;
				$('#view').scrollTo((currentimg*115+40)+'px', 800, {axis:'x', onAfter:function() {if(i>0) {cp(currentimg);} } });
			}
			if(currentimg == 0) {
				document.getElementById('leftlink').style.display = 'none';
				document.getElementById('leftarrow').style.display = 'none';				
			}
			if(currentimg < ($('#images li').length-8)) {
				document.getElementById('rightlink').style.display = 'inline';
				document.getElementById('rightarrow').style.display = 'inline';				
			}
		}
		ps2 = function(i) {
			if(currentimg > 0) {
				currentimg-=12;	
				if(currentimg < 0) currentimg = 0;
				$('#view').scrollTo((currentimg*81+40)+'px', 800, {axis:'x'});
			}
			if(currentimg == 0) {
				document.getElementById('leftarrow').style.display = 'none';				
			}
			if(currentimg < ($('#images li').length-12)) {
				document.getElementById('rightarrow').style.display = 'inline';				
			}
		}
	} else {
		document.getElementById('view').style.width = '1010px'; 
		document.getElementById('view').style.left = '-26px';	
		document.getElementById('rightlink').style.display = 'none';	
		document.getElementById('leftlink').style.display = 'none';		
		document.getElementById('leftarrow').style.display = 'none';		
		document.getElementById('rightarrow').style.display = 'none';	
	}


});
	cp = function(i) {
		var obj = document.getElementById('img'+i);
		if(obj!=null) {
			var f = obj.src.replace('/k/','/l/');
			var f2 = obj.src.replace('/k/','/o/');
			document.getElementById('galimg').src = f;
			document.getElementById('gallink').href = f2;
			document.getElementById('gallink').title = titles[i];
			document.getElementById('p_title').innerHTML = titles[i];
			document.getElementById('p_desc').innerHTML = desc[i];
			//if(dimensions[i]=='landscape') {
				document.getElementById('content').style.left = (parseInt(imgwidths[i])-396+430)+'px';
				document.getElementById('content').style.width = 520-(parseInt(imgwidths[i])-396)+'px';
			//} else {
			//	document.getElementById('content').style.left = '430px';
			//	document.getElementById('content').style.width = '520px';
			//}
		}
	}


