// JavaScript Document

jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
	jQuery("<img>").attr("src", arguments[i]);
	}
} 

$.preloadImages("images/play_button_82_on.jpg");



$(document).ready(function() 
{
	
// anchorTitles are used for rollovers on the bottomBar
	$('body').append('<div id="anchorTitle" class="anchorTitle1"></div>');
	$('a.anchortitle[title!=""]').each(function() 
		{
		var a = $(this);
		a.hover(
			function() 
			{
			showAnchorTitle(a, a.data('title'));
			},
			function() 
			{
			hideAnchorTitle();
			})
		.data('title', a.attr('title'))
		.removeAttr('title');
		});
/* $('input[name=styleSwitcher]').change(function() 
		{
		$('#anchorTitle').toggleClass('anchorTitle1').toggleClass('anchorTitle2');
		return false;
		});
*/
// thumbTitles are a repeat of the anchortitle code, but control the display of titles for the photo gallery thumbnail.
	$('body').append('<div id="thumbTitle" class="thumbTitle1"></div>');
	$('a.thumbtitle[title!=""]').each(function() 
		{
		var a = $(this);
		a.hover(
			function() 
			{
			showThumbTitle(a, a.data('title'));
			},
			function() 
			{
			hideThumbTitle();
			})
		.data('title', a.attr('title'))
		.removeAttr('title');
		});
/*	$('input[name=styleSwitcher]').change(function() 
		{
		$('#thumbTitle').toggleClass('thumbTitle1').toggleClass('thumbTitle2');
		return false;
		});


// set up rollover ** not used, but useful. Set class to rollover and create an _on and _off version of the img
	$("img.rollover").hover(
		function()
		{
		this.src = this.src.replace('_off','_on');
		},
		function()
		{
		this.src = this.src.replace('_on','_off');
		}
		);
		
		*/
		
// animate #playbutton
	// OPACITY OF BUTTON SET TO 100%
	$("#playbutton").css("opacity","1.0");
 
	// ON MOUSE OVER
	$("#playbutton").hover(
		function () 
		{
 			// SET OPACITY TO 50%
			$(this).stop().animate({opacity: 0.5}, "slow");
		},
		// ON MOUSE OUT
		function () 
		{
 		// SET OPACITY BACK TO 100%
			$(this).stop().animate({opacity: 1.0}, "slow");
		});		


// animate .galleryThumbs
	// OPACITY OF BUTTON SET TO 100%
	$(".galleryThumbnail").css("opacity","1.0");
 
	// ON MOUSE OVER
	$(".galleryThumbnail").hover(
		function () 
		{
 			// SET OPACITY TO 50%
			$(this).stop().animate({opacity: 0.5}, "slow");
		},
		// ON MOUSE OUT
		function () 
		{
 		// SET OPACITY BACK TO 100%
			$(this).stop().animate({opacity: 1.0}, "slow");
		});	


});
function showAnchorTitle(element, text) 
{
	var offset = element.offset();
	$('#anchorTitle')
	.css({
		'top' : (offset.top + element.outerHeight() + 4) + 'px',
		'left' : offset.left + 'px'
		})
	.html(text)
	.fadeIn("slow");
}

function hideAnchorTitle() 
{
	$('#anchorTitle').hide();
} 


// functions to control thumbTitles
function showThumbTitle(element, text) 
{
	var offset = element.offset();
	$('#thumbTitle')
	.css({
		'top' : (offset.top + element.outerHeight() + 4) + 'px',
		'left' : offset.left + 'px'
		})
	.html(text)
	.fadeIn("slow");
}

function hideThumbTitle() 
{
	$('#thumbTitle').hide();
} 



