jQuery(document).ready(function(){
	
	// mp3 addtocart
	$('table.product-list a.addtocart').click(function(){
		var xurl = $(this).attr('href');
		var xlink = this;
		 $.ajax({
		   type: "GET",
		   url: xurl,
		   dataType: 'html',
		   success: function(msg){
			$(xlink).css('background-image', 'url(/usr/tpl/default/img/tick.png)');
		   }
		 });
		 return false;
	});
	
	// navigation
	$("#navlist").html( $("#left li:first ul").html() );
	$("#left a").click(function(){
		if ($("li:first a", $(this).parent()).attr('href'))
			window.location.href = $("li:first a", $(this).parent()).attr('href');
		else
			return true;
		/*var xhtml = $("ul", $(this).parent()).html();
		$("#left .active").removeClass('active');
		$(this).parent().addClass('active');
		$("#navlist").hide();
		$("#navlist").html(xhtml);
		$("#navlist").effect('blind', { direction: "horizontal", mode: "show" }, 1000);
		$(this).blur();*/
		return false;
	});
	$("#left li li.active").each(function(){
		var xhtml = $(this).parent().html();
		$("#navlist").html(xhtml);
		$("#left .active").removeClass('active');
		$(this).parent().parent().addClass('active');
		return false;
	});
	
	if ($('#splash').length) {
		//colorbox({ href:'/usr/tpl/default/img/splash.jpg', photo:true, open:true }); 
		//setTimeout("tb_remove()", 5000);
	}
	
	// unobtrusive youtube
	$('a[href^="http://youtube."], a[href^="http://www.youtube."]').youtubin();
	
	// stupid IE doesn't support last/first selectors so...
	$(":first-child").addClass("first");
	$(":last-child").addClass("last");
	
	// autoclear
	$(".autoclear").each(function(){
		$(this).attr("title", $(this).attr("value"));
	});
	$(".autoclear").focus(function(){
		if ($(this).attr("title") == $(this).attr("value"))
			$(this).attr("value", "");
	});
	$(".autoclear").blur(function(){
		if (!$(this).attr("value") || $(this).attr("value") == "")
			$(this).attr("value", $(this).attr("title"));
		else
			$(this).removeClass("autoclear");
	});
	
	// zebra stripes
	$(
		"table.zebra tbody tr:odd, "
		+ "table#cart tbody tr:odd"
	).addClass('zebra1');
	
	// add input classes since IE can't do attribute selectors
	$("input[@type=text]").addClass("text");
	$("input[@type=password]").addClass("password");
	
	// self clearers
	$("#container").append("<div style=\"clear:both;height:1px;overflow:hidden;\">&nbsp;</div>");

});
