function windowpop(url,width,height,scroll,resize) {
	sealWin = window.open(url,"win",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable='+resize+',width='+width+',height='+height+'');
}

$(document).ready( function() {
	
	// Brand dropdown.
	$("#topNav ul li").hover( function() {
		if ( $(this).children("ul").length ) {
			$(this).addClass("active");
			var menuContents = $(this).children(".menu").html();
			$(this).append("<ul class='superDropdown'><li><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr bgcolor='#ffffff'><td class='border4_5'><img src='media/images/1pxTrans.gif' border='0'></td><td class='dropdownContents'><ul>"+menuContents+"</ul></td><td class='border2_5'><img src='media/images/1pxTrans.gif' border='0'></td></tr><tr><td width='10'><img src='media/images/dropdown4.gif' width='10' height='10' border='0'></td><td class='border3_5' bgcolor='#ffffff'><img src='media/images/1pxTrans.gif' border='0'></td><td width='10'><img src='media/images/dropdown3.gif' width='10' height='10' border='0'></td></tr></table></li></ul>");
			$(".dropdownContents li:last-child a").css({"border":"none"});
		}
	}, function() {
		$(this).removeClass("active");
		$(this).children(".superDropdown").remove();
	});
	
	// Top sellers
	$("#rotate").jCarouselLite({
        btnNext: "#btnNext",
        btnPrev: "#btnPrevious",
		visible: 4,
		easing: "easeinout",
		speed: 1000,
		scroll: 4
    });
	
	// Highlight subproduct rows
	$("#productOptionsTable tbody tr").hover( function() {
		$(this).addClass("rowHover");
	}, function() {
		$(this).removeClass("rowHover");
	});
	
	// Tabs
	$("#tabNav li:first").addClass("active");
	$("#tabContent div[id^='tab']:gt(0)").hide();
	$("#tabNav li").click( function() {
		$("#tabNav li").removeClass("active");
		$("#tabContent div[id^='tab']").hide();
		$(this).addClass("active");
		var selectedTab = $(this).children("a").attr("href");
		$(selectedTab).show();
		return false;
	});
	
	// Images
	$(".colorbox").colorbox({
		"photo" : true
	});
	
	$("a[rel='colorboxExtraViews']").colorbox({
		"photo" : true
	});
	
	$("#extraViewsLink").click( function() {
		$.scrollTo("#tabs",1000);
		$("#tabNav li").removeClass("active");
		$("#tabContent div[id^='tab']").hide();
		$("#extraViewsTab").addClass("active");
		$("#tab2").show();
		return false;
	});
	
	// Product Info
	$("#itemNum").change( function() {
		
		var recordNumber = $(this).val();
		
		if ( productInfo[recordNumber] ) {
			
			var stockStatus = productInfo[recordNumber][0];
			var savings = productInfo[recordNumber][1];
			var price = productInfo[recordNumber][2];
			var saleAmount = productInfo[recordNumber][3];
			var sku = productInfo[recordNumber][4];
			
			if ( savings != "" ) {
				$("#savings").html(savings).show();
			} else {
				$("#savings").hide();
			}
			
			$("#sku").html("Product SKU: <span>"+sku+"</span>").show();
			
			if ( saleAmount < price && saleAmount ) {
				$(".was").html("MSRP: <span>$"+price+"</span>").show();
				$(".price").html("Price: <span>$"+saleAmount+"</span>").show();
			} else if ( saleAmount > 0 && price == 0 ) {
				$(".was").hide();
				$(".price").html("Price: <span>$"+saleAmount+"</span>").show();
			} else if ( saleAmount == 0 && price > 0 ) {
				$(".was").hide();
				$(".price").html("Price: <span>$"+price+"</span>").show();
			}
			
			$("#stockStatus").html(stockStatus).show();
		
		} else {
			
			$("#savings").empty().hide();
			$("#sku").empty().hide();
			$(".was").empty().hide();
			$(".price").empty().hide();
			$("#stockStatus").empty().hide();

		}
		
	});
	
});