function tourDateDisplayInfo(el){
	var infoEl=el.parent().parent().next().children("td").children(".bg");
	var showMe=true;
	if(infoEl.hasClass("active")){
		var showMe=false;
	}
	//hide all
	$('.tourDatesTable .moreInfoDisplay .bg').removeClass("active");
	$('.tourDatesTable .moreInfoDisplay .bg').slideUp("slow");
	if(showMe){
		infoEl.addClass("active");
		infoEl.slideDown("slow");
	}
}

function scrollToAnchor(anchorHash){
	//anchorHash = '#anchorName'
	var $target = $(anchorHash);
	$target = $target.length && $target || $('[name=' + anchorHash.slice(1) +']');
	if ($target.length) {
		var targetOffset = $target.offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 1000);
		return false;
	}
}

$(document).ready(function(){
	//add class to body if IE6 because it's a toolshed
	if(jQuery.browser.msie && (jQuery.browser.version < 7)){
		$("body").addClass("IE6");
	}
	
	//scroll to <a name>
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
	
	//popup links
	$(".popuplink").click(function(e){
		var url=$(this).attr("href");
		var newwindow=window.open(url,'name');
		if (window.focus) {
			newwindow.focus()
		}
		return false;
	});
	
	//confirm link
	$(".confirmlink").click(function(e){
		var msg=$(this).attr("title");
		if(msg==''){
			msg='Permanently Delete?';
		}
		var url=$(this).attr("href");
		var confirmDelete=confirm(msg);
		if(confirmDelete==true){
			window.location=url;
		}
		return false;
	});
	
	//tour dates more info
	$(".tourDatesTable tr .date .moreInfo").click(function(e){
		tourDateDisplayInfo($(this));
		return false;
	});
	
	//newsletter submit
	$("#newsletterSignup .nlInputText").click(function(e){
		var emailAddy=$(this).val();
		if(emailAddy=='email@address.com'){
			$(this).val('');
		}
	});
	$("#newsletterSignup form").submit(function(){
		var emailAddy=$("#newsletterSignup .nlInputText").val();
		if(emailAddy=='email@address.com'){
			$("#newsletterSignup .nlInputText").val('');
		}
		return true;
	});
});
