function randomizeCovers(){
	$('#randomButton').attr("src", '../images/storeui/arrow_white_animated.gif');
	$.ajax({
		type: "GET",
		url: "/includes/ajax_functions.php",
		data: "func_name=randomizeCovers",
		success: function(html){
			
			setTimeout(function(){
				$("#randomPickHolder").fadeOut('fast',
				function(){
					$("#randomPickHolder").html(html);
					setTimeout(function(){
						$('#randomButton').attr("src", '../images/storeui/arrow_white_static.gif');
						$("#randomPickHolder").fadeIn('fast');
					},1000);
				});					
			},50); 
			
		}
	});	
}

function addToCart(targetx,product_id,option_name,size){

	
	//	alert(description);
	$.ajax({
		type: "GET",
		url: "/includes/ajax_functions.php",
		data: "func_name=addToCart&product_id="+product_id+"&mediaType="+option_name+"&description="+"&size="+size,
		success: function(html){
			if(html=='freeDownload'){
				window.location="/store/checkout/index.php?section=my_downloads";
			}else{
				if(option_name=='MP3' || option_name=='FLAC'){
					
					$(targetx).html('<a href="#" class="menu_item added" onclick="return false;"><span class=\"menu_item_addtocart2\">IN</span><span class="menu_item_addtocart">CART</span></a>');	
					
				}else{
					
					$(targetx).html('<a href="#" class="menu_item added" onclick="return false;"><span class=\"menu_item_format\">'+option_name+'</span><span class="menu_item_addtocart">IN CART</span></a>');
					
				}
				//$(targetx).animate({ color: "yellow" }, 1000);
				updateCart();
			}
		}
	 });
}

function updateCart(){
	$.ajax({
		type: "GET",
		url: "/includes/ajax_functions.php",
		data: "func_name=updateCart",
		success: function(html){
			$("#topcart").html(html);
			$("#colorcart").animate({ color : "#FFFF00" }, 50).animate({ color: "#FFFFFF" }, 1000);
			hashizeLinks();
		}
	});
}



function showBuy(){
	
	$(this).children('div.buybutton').fadeIn('fast');
	
}

function hideBuy(){
	
	$(this).children('div.buybutton').fadeOut('fast');
	
}

function storeSetup(){
	updateCart();
	$('div.buybutton').hide();
	$('.showSearch').click(function(){
		 $('#advancedSearch').fadeIn();
	});
	
	$('.hideSearch').click(function(){
		 $('#advancedSearch').fadeOut();
	});
/*
	$('#featureContainer').cycle({
		fx: 'fade',
		pause:5,
		speed: 500
	});
*/
//	$('#categoryContainer > ul').tabs({ fx: {opacity: 'toggle', duration: 180 } });
	$('div.buybuttons').hoverIntent( showBuy, hideBuy );
	
	$('.leftCategoryItem').hover(function() {
		$(this).addClass('frontItemHover');
	}, function() {
		$(this).removeClass('frontItemHover');
	});

	$("#browse_by").change(function () {
		//window.location="http://<?php echo $_SERVER['HTTP_HOST']; ?>" + $("#browse_by").val();
		//window.location="http://www.truepanthersounds.com/#" + $("#browse_by").val();
		loadPage($("#browse_by").val());
	});
	
	$("#searchTerm").click(function(){
		if($("#searchTerm").val()=='Enter Search Here...'){	
			$("#searchTerm").val('');
		}
	});


	$("#tracktable tr:even").addClass('trackEven');
	$("#tracktable tr:odd").addClass('trackOdd');
	
	$(".baskettable tr:odd").addClass('trackOdd');

	$(".trackPreview").children('img').attr("border", '0');
	
	$(".trackPreview").hover(
		function () {
			$(this).children('img').attr("src", '../images/storeui/previewOver.gif');
		}, 
		function () {
			$(this).children('img').attr("src", '../images/storeui/previewOff.gif');
		}
    );
		
	
	
	
	
}


$(window).ready(function() { 
	$('#featureContainer').fadeIn('fast'); 
});

$(document).ready(function(){
	storeSetup();
	
});

