var shi = new Array();
sh = function(id, t, n){this.init(id, t, n);};
$.extend(sh.prototype, {
	init: function(id, t, n) {
		this.id = id;
		shi[this.id.substr(3)] = this;
		this.t = t;
		this.m = '#'+this.id;
		$(this.m).css({position: 'relative', overflow: 'hidden'});
		this.h = $(this.m).height();
		$(this.m+'>li').css({position: 'absolute', top: this.h, left:0, width:'100%'})

		this.c = $(this.m+'>li').size();
		this.n = n%this.c;
		this.o = this.n;
		$(this.m+'>li:eq('+this.n+')').css('top','0px');
		if(this.c>1)this.s();
	},
	s: function() {
		var ix=this.id.substr(3);
		this.i = setInterval(function(){shi[ix].r(shi[ix])},this.t);
		$(this.m).hover(function() {clearInterval(shi[this.id.substr(3)].i);}, function() {var ix=this.id.substr(3);
			shi[ix].i = setInterval(function(){shi[ix].r(shi[ix])},shi[ix].t);
			});
	},
	r: function(obj) {
		obj.n = (obj.o + 1) % obj.c; 
		$(obj.m+'>li:eq(' + obj.o + ')').animate({top: -obj.h-10},"slow", function() {
			$(this).css('top',obj.h);
		});
		$(obj.m+'>li:eq(' + obj.n + ')').show().animate({top: 0},"slow");  
		obj.o = obj.n;
	}
});
function updateBookmarks(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			if(this.hash=='#top'){
				$('html,body').animate({scrollTop: 0}, 700);
				return false;			
			}
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 700);
				return false;
			}
		}
	});
}
function updateMenu(){	
	$("ul.topnav li").hover(function() {
		$(this).find("ul.subnav").stop().slideDown('fast').show('slow', function(){
			$(this).height("auto");
		});
 
	$(this).hover(function() {
		}, function(){	
			$(this).find("ul.subnav").stop().slideUp('slow');
		});
 		}).hover(function() { 
			$(this).addClass("subhover");
		}, function(){
			$(this).removeClass("subhover");
	});
}
