$(document).ready(function(){

	
	// EMAIL OBFUSCATION
	$(".replaceAt").replaceWith("@");
  	$(".obfuscate").each(function () {
  		$(this).attr("href", "mailto:"+$(this).text());
  	});
  	$(".emaillink").each(function () {
  		$(this).attr("href", "mailto:" + $(this).attr("href") + "@" + $(this).attr("rel"));
  	});
  
  
  	// SLIDESHOW
  	jQuery("#fpimageslider").innerfade({
  		animationtype: 'fade',
  		speed: 'normal',
  		timeout: '5000',
  		type: 'sequence',
  		containerheight: 'auto'
  	}); 



	// SUB-MENUS

	var slideTime = 200;

	var artistmenutimer = false;
	$("#dropdown-artist, #nav-artist").hover(function(){
		if (artistmenutimer) clearTimeout(artistmenutimer);
		$("#dropdown-artist").slideDown(slideTime);
		$("#nav-artist").addClass("current");
	}, function() {
		artistmenutimer = setTimeout(function() {
			$("#dropdown-artist").slideUp(slideTime);
			$("#nav-artist").removeClass("current");
		}, slideTime);
	});

	var tourmenutimer = false;
	$("#dropdown-tour, #nav-tour").hover(function(){
		if (tourmenutimer) clearTimeout(tourmenutimer);
		$("#dropdown-tour").slideDown(slideTime);
		$("#nav-tour").addClass("current");
	}, function() {
		tourmenutimer = setTimeout(function() {
			$("#dropdown-tour").slideUp(slideTime);
			$("#nav-tour").removeClass("current");
		}, slideTime);
	});
	
	
	$(".closebiopopup, #TB_window").bind("click", function(e) {
		tb_remove();
		return false;
	});


	// TOUR DATE SEARCH
	$(".runtourdates, #viewalltours").bind("click", function(e) {
		$("#searchtourdate_zip").val("");
		runTourDateSearch();
	});
	$("#searchtourdates").submit(function(e) {
		e.preventDefault();
		runTourDateSearch();
	});


	function runTourDateSearch() {
		$("#tourdatetarget").html($("#waitingdiv").html());
		$.get("/getcalendar.php", { zip: $("#searchtourdate_zip").val() }, function(data) {
			$("#tourdatetarget").html(data);
		});
	}
	
});

