jQuery(function ($) {
	
	$('#header-news').bannerRotator({ random: true });
	
	(function() {
		
		var vimeo = ['4181911', '2102934', '2999374', '1005941', '950874', '913053', '942929'];
		
		for (var i = 0; i < vimeo.length; i++) {
			$('#watch-video').append('<div>' + flashembed.getHTML({src: 'http://vimeo.com/moogaloop.swf?clip_id=' + vimeo[i] + '&amp;server=vimeo.com&amp;color=ffffff&amp;show_title=1', height: '100%', width: '100%', allowFullScreen: 'true', allowscriptaccess: 'always', quality: 'high', wmode: 'transparent'}) + '</div>');
			$('#watch-video').children(':eq(' + i + ')').attr('id', vimeo[i]);
		}
		
		var pointer = Math.floor(Math.random() * vimeo.length);
		
		$('#watch-video').children(':not(:eq(' + pointer + '))').hide();
		
		$('#watch').click(function (e) {
			
			var temp = pointer;
			
			if (e.target.id === 'watch-toggle-next') {

				if ((pointer + 1) < vimeo.length) {
			
					pointer += 1;
				}
				else {
					
					pointer = 0;
				}
			}
			else {
				
				if ((pointer - 1) >= 0) {
			
					pointer -= 1;
				}
				else {
					
					pointer = (vimeo.length - 1);
				}
			}
			
			$('#' + vimeo[temp]).hide();
			$('#' + vimeo[pointer]).show();
			
			return false;
		});
		
		$('#watch').show();
	})();
});