//document ready function
$(document).ready( function() {

	// Handle content rotation in the bottom left ad area
	$("#rotate1").css("display","none");
	$("#forwardback").css("visibility","visible");
	var currentRotateImage = Math.floor(Math.random()*6) + 1;
	$("#rotate"+currentRotateImage).css("display","block");

	$("#rotatelast").click(function() {
		$("#rotate"+currentRotateImage).css("display","none");
		currentRotateImage--;
		if (currentRotateImage == 0) {
			currentRotateImage = 6;
		}
		$("#rotate"+currentRotateImage).css("display","block");
		$(".onofflight:last").after($(".onofflight:first"));
	});
	
	$("#rotatenext").click(function() {
		$("#rotate"+currentRotateImage).css("display","none");
		currentRotateImage++;
		if (currentRotateImage == 7) {
			currentRotateImage = 1;
		}
		$("#rotate"+currentRotateImage).css("display","block");
		$(".onofflight:first").before($(".onofflight:last"));
	});
	
	//product rollover on default page
	
	$("#lineuplink").hover(
		function () {
			//alert("yo");
			$(this).css("background-image",$(this).css("background-image").replace("_off", "_on"));
			if (($.browser.msie) && (parseInt(jQuery.browser.version) < 7)) {
				$(this).css('filter',$(this).css('filter').replace(/_off/, "_on"));
			}
		}, 
		function () {
			$(this).css("background-image",$(this).css("background-image").replace("_on", "_off"));
			if (($.browser.msie) && (parseInt(jQuery.browser.version) < 7)) {
				$(this).css('filter',$(this).css('filter').replace(/_on/, "_off"));
			}
		}
	);
	
	//popup info for lineup page
	$(".prodpop").append("<span>[ x ]</span>");
	$(".prodpop span").click(function() {
		$(this).parent().css("display","none");
	});
	$(".prodlink").click(function() {
		var popid = $(this).attr("id") + "_pop";
		$(".prodpop").css("display","none");
		$("#" + popid).css("display","block");
		return(false);
	});
	//lineup page hover effect
	$(".prodlink").hover(
		function () {
			$(this).children("img:not(#sgImage)").attr("src",$(this).children("img").attr("src").replace("_off", "_on"));
			if (($.browser.msie) && (parseInt(jQuery.browser.version) < 7)) {
				$(this).children("img:not(#sgImage)").css('filter',$(this).children("img").css('filter').replace(/_off/, "_on"));
			}
		}, 
		function () {
			$(this).children("img:not(#sgImage)").attr("src",$(this).children("img").attr("src").replace("_on", "_off"));
			if (($.browser.msie) && (parseInt(jQuery.browser.version) < 7)) {
				$(this).children("img:not(#sgImage)").css('filter',$(this).children("img").css('filter').replace(/_on/, "_off"));
			}
		}
	);

	//determine which person's info to view on testimonial page
	//alert($(".userinfo").length);
	if(location.search.search("user") != -1) {
		var	userName = location.search.replace("?user=","");
		if ($("#"+userName+".userinfo").length == 1) {
			$(".userinfo").removeClass("youcantseeme").addClass("youcantseeme");
			$("#"+userName).removeClass("youcantseeme");
		}
	}
	
	//IE6 png fix
	if (($.browser.msie) && (parseInt(jQuery.browser.version) < 7)) {
		$("img[src$=.png], #lineuplink").css("behavior","url(js/iepngfix.htc)");
		$(".prodpop").wrapInner($("<div></div>"));
	}
	//IE6 png rollover fix


});

