	var firstslide = 1;
	var seen = new Array();
	var cyclewait = 1;
	var totalslides;
	var fading=0;
    jQuery(function() {
		$(".hero > .feature .feature").css('padding','20px 0 0 5px');
		$('.hero -> .feature').css('z-index','10');
		totalslides = $("span#totalslides").html();
		if(totalslides < 6){
			$(".hero .pagination .sequential .next").hide();
		}
		$('.hero #leftarrow').attr('rel',totalslides);
		$('.hero #rightarrow').attr('rel',1);

		var isusa = $('.slide-1').html();
		if( ! isusa){
			$(".hero > .feature:visible").hide();
			$(".hero #bigslide1").show();
		}
		$(".slidearrow").hover(
			function(){
				$(this).fadeTo('fast',1.0);
			},
			function(){
				$(this).fadeTo('fast',0.6);
			});

		jQuery(".hero .navigation ul li").bind('mouseenter',function(){
			clearTimeout(cyclewait);
			if(fading){
	//			return; // Commented out so quickly moving the mouse across them doesnt let it get behind.  Not sure why  this was included in the first place
			}
			$(this).siblings().removeClass("selected");
			$(this).addClass("selected");
			slideid = this.id;
			sliden = slideid.substring(5,6);
			setarrows(sliden);
			fading=1;
			$(".hero > .feature:visible").fadeOut('slow',function(){
				$(".hero #big"+slideid).fadeIn('slow');
				fading=0;
			});
			var myid = $(this).find('span.holder').text();
			for (i in seen){
				if( seen[i] == myid ){
				    return;
				}
			}
			seen.push(myid);
			$.get("/_include/ajax/adshown.php", {
				id: myid,
				c: 'index' });

		});
		jQuery(".hero .navigation ul li").click(function(e){
			e.preventDefault();
		});

		$(".hero .pagination .sequential .previous").hide();

		jQuery(".hero #leftarrow").click(function(e){
			clearTimeout(cyclewait);
			e.preventDefault();
			if(fading){
				return;
			}
			var nextn = $(this).attr('rel');
			fading=1;
			$('.hero > .feature:visible').fadeOut('slow',function(){
				$(".hero #bigslide"+nextn).fadeIn('slow');
				fading=0;
			});
			arrowsleft();
			var myid = $('.hero #bigslide'+nextn).find('span.holder').text();
			for (i in seen){
				if( seen[i] == myid ){
				    return;
				}
			}
			seen.push(myid);
			$.get("/_include/ajax/adshown.php", {
				id: myid,
				c: 'index' });
		});
		jQuery(".hero #rightarrow").click(function(e){
			clearTimeout(cyclewait);
			e.preventDefault();
			if(fading){
				return;
			}
			var nextn = $(this).attr('rel');
			fading=1;
			$('.hero > .feature:visible').fadeOut('slow',function(){
				$(".hero #bigslide"+nextn).fadeIn('slow');
				fading=0;
			});
			arrowsright();
			var myid = $('.hero #bigslide'+nextn).find('span.holder').text();
			for (i in seen){
				if( seen[i] == myid ){
				    return;
				}
			}
			seen.push(myid);
			$.get("/_include/ajax/adshown.php", {
				id: myid,
				c: 'index' });
		});

		jQuery(".hero .pagination .sequential .next").click(function(e){
			clearTimeout(cyclewait);
			e.preventDefault();
			firstslide += 5;
			$(".hero .navigation ul li:visible").fadeOut('slow',function(){
				$(".hero .navigation ul li#slide" + firstslide).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+1)).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+2)).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+3)).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+4)).fadeIn('slow');
			});
			if(firstslide > 1){
				$(".hero .pagination .sequential .previous").show();
			}
			if(firstslide > totalslides - 5){
				$(".hero .pagination .sequential .next").hide();
			}
			$("#leftslide").html(firstslide);
			var rightslide = firstslide + 4;
			if(rightslide > totalslides){
				rightslide = totalslides;
			}
			$("#rightslide").html(rightslide);
		});

		jQuery(".hero .pagination .sequential .previous").click(function(e){
			clearTimeout(cyclewait);
			e.preventDefault();
			firstslide -= 5;
			$(".hero .navigation ul li:visible").fadeOut('slow',function(){
				$(".hero .navigation ul li#slide" + firstslide).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+1)).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+2)).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+3)).fadeIn('slow');
				$(".hero .navigation ul li#slide" + (firstslide+4)).fadeIn('slow');
			});
			if(firstslide < 2){
				$(".hero .pagination .sequential .previous").hide();
			}
			if(firstslide < totalslides - 4){
				$(".hero .pagination .sequential .next").show();
			}
			$("#leftslide").html(firstslide);
			var rightslide = firstslide + 4;
			if(rightslide > totalslides){
				rightslide = totalslides;
			}
			$("#rightslide").html(rightslide);
		});
		if( isusa ){
		cyclewait = setTimeout(cycleslides,5000);
		}
    });

function arrowsleft(){
	var ln = $('.hero #leftarrow').attr('rel');
	ln--;
	if( ln < 1){
		ln = totalslides;
	}
	$('.hero #leftarrow').attr('rel',ln);
	var rn = +ln + 2;
	if( rn > totalslides ){
		rn -= totalslides;
	}
	$('.hero #rightarrow').attr('rel',rn);
}

function arrowsright(){
	var rn = $('.hero #rightarrow').attr('rel');
	rn++;
	if( rn > totalslides){
		rn = 1;
	}
	$('.hero #rightarrow').attr('rel',rn);
	var ln = rn - 2;
	if( ln < 1 ){
		ln = totalslides;
	}
	$('.hero #leftarrow').attr('rel',ln);
}

function setarrows(n){
	var ln = +n - 1;
	var rn = +n + 1;
	if( n == totalslides ){
		rn = 1;
	}
	if( n == 1 ){
		ln = totalslides;
	}
	$('.hero #leftarrow').attr('rel',ln);
	$('.hero #rightarrow').attr('rel',rn);
}


function cycleslides(){
	if(! cyclewait){
		return;
	} else {
	    $(".hero > .feature:visible").fadeOut('slow',function(){
			var thisn = this.id.substring(8,10);
			if(thisn == totalslides){
				$(".hero #bigslidea").fadeIn('slow');
			} else {
				var nextone = $(this).next();
				nextone.fadeIn('slow');
			}
        });
		cyclewait = setTimeout(cycleslides,5000);
	}
}

