//JAVASCRIPT FOR homepage.php Version 1.2 beta

var ol_width = 275; //set the tooltip width for overlib

function getShowDetail(evt) {
	var theShowCode = this.src.split('images/')[1];
	theShowCode = theShowCode.split('_')[0];
	var d = loadJSONDoc('ajaxshow.php?show='+theShowCode);
	var gotMetaData = function(meta) {
		var theHTML = '<h3>' + meta.title + '<\/h3>' + meta.description;
		return overlib(theHTML, VAUTO);
	}
	d.addCallback(gotMetaData);
}

function getSpecialDetail(evt) {
	var specialOfferTitle = this.parentNode.parentNode.parentNode.getElementsByTagName('strong').item(0).innerHTML;
	var specialOfferTxt = this.parentNode.parentNode.parentNode.getElementsByTagName('span').item(0).innerHTML;
	var theHTML = '<h3>' + specialOfferTitle + '<\/h3><p>' + specialOfferTxt + '<\/p>';
	return overlib(theHTML, VAUTO);
}

addLoadEvent(function () {
	document.body.onmouseout = function() {
		return nd();
	}
	var topShowsLinks = getElementsByTagAndClassName('img',null,$('Topshows'));
	for (i=0; i<topShowsLinks.length; i++) {
		topShowsLinks[i].onmouseover = getShowDetail;
		topShowsLinks[i].onmouseout = function() {
			return nd();
		}
	}
});

addLoadEvent(function () {
	if ($('Specials')) {
		var specialsLinks = getElementsByTagAndClassName('img',null,$('Specials'));
		for (i=0; i<specialsLinks.length; i++) {
			specialsLinks[i].onmouseover = getSpecialDetail;
			specialsLinks[i].onmouseout = function() {
				return nd();
			}
		}
	}
});

//ADVERT ANIMATION
function rotate() {
	var effect = new fx.Opacity($('Fabshow').getElementsByTagName('img').item(0),{duration:2000});
	$('Fabshow').getElementsByTagName('p').item(0).style.background = 'url(' + adImages[thisAd] + ')';
	if (!$('Fabshow').getElementsByTagName('img')) return false;
	if ($('Fabshow').getElementsByTagName('img').item(0).complete) {
		thisAd++;
		if (thisAd == imgCt) {
			thisAd = 0;
		}
		effect.custom(0,1); // start effect
		setTimeout ("$('Fabshow').getElementsByTagName('img').item(0).src = adImages[thisAd]",100); //slow loading of image to stop flashing
		$('Fabshow').getElementsByTagName('a').item(0).href = adUrl[thisAd];
	}
	setTimeout("rotate()", 6 * 1000);
}
addLoadEvent(function () {
	if ($('Fabshow')) { rotate(); }
});
