jQuery(document).ready(function($) {
	
	$.fn.fadeToggle = function(speed, easing, callback) {
		return this.animate({opacity: "toggle"}, speed, easing, callback); 
	}; 	
	
	$("a.gigpress-links-toggle").click(function() {
		var target = $(this).attr("href");
		$(target).fadeToggle("fast");
		$(this).toggleClass("gigpress-link-active");
		return false;
	});
	
	$("select.gigpress_menu").change(function()
	{
		window.location = $(this).val();
	});
	
	// ADD THE ARTIST NAMES
	$.post("wp-content/plugins/gigpress/output/gigpress_ajax.php", 
		function(data) {
			var html = $("table.upcoming").html();
			var name = ""; var link = ""; var reg = "";
			
			$.each(data, function(i,elem) {
					link = elem.link;
				
				if (link != "") {
					name = elem.name;
					reg = new RegExp(name, 'g');
					if (html.match(reg)) { html = html.replace(reg, "<a href='" + link + "'>" + name + "</a> "); }
				}
			});
			$("table.upcoming:first").html(html);
		}, "json");
});