$(function () {

	$('.clickable').click(function() {
		location.href = $('a', this).attr('href');
	}).css('cursor', 'pointer');

	$('#flash').flash({
	    src: '/stoweb/flash/splash.swf',
	    width: 980,
	    height: 412
	});
	
	$('.scrollregion').each(function() {
		if ($('> ul > li', this).length > 1) {
			$(this).vTicker({
				speed: 12000,
				pause: 12200,
				showItems: 2,
				mousePause: true,
				isPaused: false,
				direction: 'up',
				height: 600		
			});
		}
	});
	
	var hdslideshow = {
			
			slides: $('ul.headerimages li'),
			quotes: $('#quotes div.quote'),
			numslides: $('ul.headerimages li').length,
			currentslide: 0,
				
			init: function () {
				if (hdslideshow.numslides > 1) {
					hdslideshow.slides.css({'opacity':0, 'z-index':1});
					hdslideshow.quotes.css({'opacity':0, 'z-index':4});
					hdslideshow.quotes.each(function() {
						var randleft=868 - $(this).width() - Math.floor(Math.random()*200) - 50;
						var randtop=Math.floor(Math.random()*180)+20;
						$(this).css({'margin-left':randleft, 'margin-top':randtop});
					});
					hdslideshow.next(false); 
					setInterval(function() { hdslideshow.next(true); },	9000);				
				}
			},
			
			next: function(crossfade) {
				var csn = hdslideshow.currentslide;
				var nsn = (csn == hdslideshow.numslides ? 1 : csn + 1);
				var cs = hdslideshow.slides.eq(csn-1);
				var ns = hdslideshow.slides.eq(nsn-1);
				var cq = hdslideshow.quotes.eq(csn-1);
				var nq = hdslideshow.quotes.eq(nsn-1);
				cs.css({'z-index':1});
				ns.css({'z-index':2});
				if (crossfade) {
					ns.animate({'opacity':1, left:-19}, 1000, function() {
						cs.css({'opacity':0});	
					});
				} else {
					ns.css({'opacity':1});
					cs.css({'opacity':0});
				}
				cq.animate({'opacity':0}, 500, function() {
					nq.animate({'opacity':0.6}, 3000);
				});
				ns.animate({'left':-212}, 10000, 'linear', function() {
					ns.css({'left':0});
				});
				hdslideshow.currentslide = nsn;
			}
				
		}
			
		hdslideshow.init();	
	
});

function gocalendar() {
	window.open('calendar/', 'calendar', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=1024,height=768,left=0,top=0');
}

function gowelcomevideo() {
	window.open('welcomevideo/', 'media', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=1024,height=768,left=0,top=0');
}
