/* shows.js */
$(function(){
});
$(document).ready(function(){
	
	$(".pix img").lazyload({
		placeholder : "images/clear.gif",
		effect      : "fadeIn"
	});
	
	$('.show-entry ul').hide().attr('title', 'double-click to close');
	$('.close-me').dblclick(function(){
		$(this).parent().find(".tip-me").click();
	});
	$('.show-entry .details').before('<div class="tip-me closed" title="click for band bios">');
	$('.show-entry ul').before('</div><div class="tip-mee close-me" title="double-click to close">').after('</div>');
	$(".tip-me").tooltip({
		extraClass: 'simple',
		track	: true,
		top		: 5,
		left	: 5,
		delay	: 1200
	});
	var SPD = 300;
	$(".tip-me").click(function(){
	//	var thiss = $(this).parent();
		var thiss = $(this).parent('.show-entry');
		var id = '#'+ thiss.attr('id');
		$(".open").not(thiss).removeClass('open').find("ul").slideUp(SPD/2);
		thiss.toggleClass('open').find("ul").slideToggle(SPD,function(){
			if ( thiss.hasClass('open')) {
				$.scrollTo(id, SPD);
			}
		});
	});

	$('#primary').find('a').click(function(){
		$(this.hash).find(".closed").click(); // first .tip-me
		return false;
	});
	
	add = ' - click for bigger photo';	
	$('.pix a').each(function(){
		temp = $(this).attr('title') + add;
		$(this).attr('title', temp);
	}).tooltip({
		showURL: false,
		showBody: ' - '
	});

	$('.bandlist .band-name').each(function(){
		var t = $(this).html().replace(' - ',' &mdash; </big><br /><small>');
		$(this).html(t); // fixes long names that have a hyphen
	});

	$('#header').addClass('floater');
	var winH = $(window).height() - 8;
	//alert( 'window= '+ winH +' primary= '+ $('#primary').height() ); // debuggin
	if ( $('#primary').height() >= winH ) {
		$('#primary').addClass('overflow');
	}
	
});
$(window).load(function(){

	/*
	var priOT = $('#primary').offset().top, offst = priOT - 20;
	// the natural position, minus the distance from the top when floating
	$(window).scroll(function() { // Detect if content is scrolling offscreen.
	 	var dbsT  = document.body.scrollTop, ddEsT = document.documentElement.scrollTop;
		var topp  = (dbsT > ddEsT) ? dbsT : ddEsT;
		$('#b_vip a').text(topp + " | " + offst); // Debugging
		if (topp >= offst) {
			$('#primary').addClass('floater');
		} else
		if ((topp || priOT) < offst) {
			$('#primary').removeClass('floater');
		}
	 });
	*/
	/*
	$('.pix a').each(function(){ // to check for broken imgs
		var w = $(this).find('img').height();
		if ((w != "undefined") && (w != "null") && (w > "20")) { // 20 is default // image doesn't exist
			$(this).animate({opacity:1},'fast');
		} else {
			$(this).remove();
		}
	});
	*/

});