window.addEvent('domready', function()
{
	if($('search'))
	{
		var searchInput = $('search').getElement('input');
		var placeholder = searchInput.getProperty('value');
		
		searchInput.addEvents({
			'focus': function()
			{
				if(this.getProperty('value') == placeholder)
				{
					this.setProperty('value', '');
				}
			},
			'blur': function()
			{
				if(this.getProperty('value').length < 1) 
				{
					this.setProperty('value', placeholder);
				}
			}
		});
	}
	
	if($('movies'))
	{
		$$('.movie').each(function(movie) 
		{
			var h3 = movie.getElement('h3');
			var stars = h3.getPrevious();
			
			h3.fade(0);
			stars.fade(0);
			
			movie.addEvents({
				'mouseover': function()
				{
					h3.fade(.6);
					stars.fade(1);
				},
				'mouseout': function()
				{
					h3.fade(0);
					stars.fade(0);
				}
			});
		});
	}
});

var changingThumbs = new Array();

function changeThumb(index, i, numThumbs, path)
{
	if(changingThumbs[index])
	{
		hiddenImageID = (i + 1) % numThumbs;

		$(index).src = path + i + ".jpg";
		$("pixel").src = path + hiddenImageID + ".jpg";
		
		i = i % numThumbs;
		i++;
		
		setTimeout("changeThumb('" + index + "'," + i + ", " + numThumbs + ", '" + path + "')", 1000);
	}
}	

function startThumbChange(index, numThumbs, path)
{
	changingThumbs[index] = true;
	changeThumb(index, 1, numThumbs, path);
}

function endThumbChange(index, path)
{
	changingThumbs[index] = false;
	document.getElementById(index).src = path + "1.jpg";
}
