﻿$.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) {
	strippos += inc;
	if (strippos < 0 || strippos > stripmax) {strippos -= inc; return;}
	$('#cities').animate({left: '+='+(inc * -220)}, 1000, 'swing');
	if (strippos == 0) {$('#scarr-left').fadeOut(500);}
	if (strippos == 1 && inc > 0) {$('#scarr-left').fadeIn(500);}
	if (strippos == stripmax - 1 && inc < 0) {$('#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(-1);}).hide();
		$('#scarr-right').click(function() {stripmove(+1);}).hide().wait(500).fadeIn(500);
	}
}
var strippos = 0;
var stripmax = 0;
window.onload = startup;

