$(document).ready( function() {

	//	video btn
	$('#vid').hover(
		function() {	$('a',this).animate({width:44, height:44}, 100)	},
		function() {	$('a',this).stop(1,1).animate({width:32, height:32}, 100)	}
	);
	$('#vid').click( function() {
		Shadowbox.open({
			content:    'http://cdn-static.viddler.com/flash/simple_publisher.swf?key=bf10905a',
			player:     "swf",
			title:      "",
			height:     342,
			width:      520,
			autostart: true,
			autoplay: true
		});
	});

	//	menu for IE6
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('#menu li').hover(
			function() {
				$('span',this).show();
			}, 
			function() {
				$('span',this).hide();
			} 
		);
	}

	//	"how-slider"
	//	calculates the index of the link being clicked and then shows the image with the same index
	$('.how .section, .how #left-side hr').hide();
	$('#alt .section').eq(0).show();
	$('#slider-nav li a').eq(0).addClass('active');
	$('#slider-nav li a').click( function() {
		$('#alt .section').hide();
		$('#slider-nav li a').removeClass();
		$(this).addClass('active');
		$('#alt .section').eq($('#slider-nav li a').index(this)).show();
		return false
	});

	//	howNavCount keeps track of the position of "how-nav"
	//	0 = first set of links
	var howNavCount = 0;
	//	if nav isn't full, disable next arrow
	if(howNavCount==Math.floor($('#slider-nav li').size()/5)) { $('#slider-nav #next').addClass('dead') }
	
	$('#slider-nav .arrow').click( function() {
		//	if next
		if($(this).is('#next')) {
			//	total # of links / 5 links per set = # of sets
			//	if the current count isn't the last set, proceed
			if(howNavCount!=Math.floor($('#slider-nav li').size()-5)) {
				$('#slider-nav div.inside').animate({marginLeft:'-=148'}, 100)
				$('#slider-nav #prev').removeClass('dead')
				++howNavCount;
				if(howNavCount==Math.floor($('#slider-nav li').size()-5)) {
					$('#slider-nav #next').addClass('dead')
				}
			}
		}

		else {
			//	if this isn't the first set, proceed
			if(howNavCount!=0) {
				$('#slider-nav div.inside').animate({marginLeft:'+=148'}, 100)
				$('#slider-nav #next').removeClass('dead')
				--howNavCount;
				if(howNavCount==0) {
					$('#slider-nav #prev').addClass('dead')
				}
			}
		}
		//	prevent the page from jumping to the top
		return false;
	});

	//	menu click - move slider
	//	gettraffic (3rd link)
	$('#menu a').eq(2).click( function() {
		$('#slider-nav div.inside').animate({marginLeft:'-888'}, 200);
		howNavCount=5;
		$('#slider-nav #prev, #slider-nav #next').removeClass('dead')
		$('#how-img').attr('src','img/how-header.png')
	});
	//	earnmoney (4th link)
	$('#menu a').eq(3).click( function() {
		$('#slider-nav div.inside').animate({marginLeft:'-1487'}, 200);
		howNavCount=10;
		$('#slider-nav #prev').removeClass('dead')
		$('#slider-nav #next').addClass('dead')
		$('#how-img').attr('src','img/earn-header.png')
	});
	//	gettraffic (3rd link)
	$('#sub-menu a').eq(2).click( function() {
		$('#slider-nav div.inside').animate({marginLeft:'-888'}, 200);
		howNavCount=5;
		$('#slider-nav #prev, #slider-nav #next').removeClass('dead');
		$('#how-img').attr('src','img/how-header.png')
	});
	//	earnmoney (4th link)
	$('#sub-menu a').eq(3).click( function() {
		$('#slider-nav div.inside').animate({marginLeft:'-1487'}, 200);
		howNavCount=10;
		$('#slider-nav #prev').removeClass('dead')
		$('#slider-nav #next').addClass('dead')
		$('#how-img').attr('src','img/earn-header.png')
	});

	//	move slider to appropriate section based off of URL hash
	var page = location.hash;
	switch(page)
	{
	case "#traffic":
		$('#slider-nav div.inside').animate({marginLeft:'-888'}, 200);
		howNavCount=5;
		$('#slider-nav #prev, #slider-nav #next').removeClass('dead')
	break;
	case "#earn":
		$('#slider-nav div.inside').animate({marginLeft:'-1487'}, 200);
		howNavCount=10;
		$('#slider-nav #prev').removeClass('dead')
		$('#slider-nav #next').addClass('dead')
	break;
	}

});