var site_title = $("title").text();

$(function() {

	$("a[rel='colorbox']").colorbox();	
	
	$(".album_tracklisting_toggle").click(function(){
		var albumid = $(this).attr('id').replace('album_tracklisting_toggle_','');
		$("#album_tracklisting_"+albumid).toggle();
		return false;
	});
	
	/* Add item to shopping cart */
	$(".store_addtocart").click(function() {
		
		var item_id = $(this).attr('id');
		
		$.get($(this).attr('href'),function(data)
		{
			$("#"+item_id).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
		
			$(".store_shoppingcart_empty").fadeOut();
			$(".store_shoppingcart_items").html(data);
		});
		return false;
	});
	
	/* Alert before clearing cart */
	$("#store_empty_cart").click(function()
	{
		var ans = confirm("Empty all shopping cart items?");
		
		if(!ans){
			return false;
		}
	});
	
	/* Validate checkout form */
	$("#checkoutSubmit").click(function() {
		var error = false;
		
		$(".error").hide();
		
		if($("#firstname").val().length<2)
		{
			error = true;
			$("#firstnameError").show();
		}
		if($("#lastname").val().length<2)
		{
			error = true;
			$("#lastnameError").show();
		}
		if($("#address").val().length<2)
		{
			error = true;
			$("#addressError").show();
		}
		if($("#city").val().length<2)
		{
			error = true;
			$("#cityError").show();
		}
		if($("#zip").val().length<2)
		{
			error = true;
			$("#zipError").show();
		}
		if($("#phone").val().length<2)
		{
			error = true;
			$("#phoneError").show();
		}
		if($("#email").val().length<2)
		{
			error = true;
			$("#emailError").show();
		}
		
		if(error) return false;
	});	
	
});
