﻿$.fn.wait = function(time, type) {
	time = time || 1000; type = type || "fx";
	return this.queue(type, function() {
		var self = this; setTimeout(function() {$(self).dequeue();},time);
	});
};
function stripmove(inc) {
	var target = strippos + inc;
	var place = 'm';
	if (target < 0) {
		inc = -strippos;
		place = 'b';
	}
	if (target > stripmax) {
		inc = stripmax - strippos;
		place = 'e';
	}
	strippos += inc;
	$('#cities').animate({left: '+='+(inc * -220)}, 1500, 'swing');
	if (strippos == 0) {$('#scarr-left').fadeOut(500);}
	if (strippos > 0) {$('#scarr-left').fadeIn(500);}
	if (strippos < stripmax - 1) {$('#scarr-right').fadeIn(500);}
	if (strippos == stripmax) {$('#scarr-right').fadeOut(500);}
}
function startup() {
	stripmax = ($('#filmstrip li').size()) - 4;
	if (stripmax > 0) {
		$('#filmstrip').before('<img src="/i/v03/scarr-left.png" id="scarr-left"><img src="/i/v03/scarr-right.png" id="scarr-right">');
		$('#scarr-left').click(function() {stripmove(-3);}).hide();
		$('#scarr-right').click(function() {stripmove(+3);}).hide().wait(250).fadeIn(500);
	}
}
var strippos = 0;
var stripmax = 0;
window.onload = startup;

