$(document).ready(function(){
	// hilighting valittu
	$('.valittu').each(function(){
		$(this).css('background-position', '0 -' + $(this).css('height'));
	});
	
	$(".hilight:not(.valittu)").hover(
		function(){
			$(this).css("background-position", "0 -" + $(this).css('height'));
		},
		function(){
			$(this).css("background-position", "0 0");
		}
		
	);
		
});

function checkRequired()
{
	var valid;
	valid = false;

	$(".required").each(function(){
		if(this.value == undefined || this.value == ''){
			valid = false;
			alert("Arvo puuttuu: " + $(this).attr('rel'));
			return false;
		}

		valid = true;
		return true;
	});

	return valid;
}

function gal_animate(idx, img, idxOut, imgOut) {
	if (idxOut == undefined)
	{
		if(!img.alt)
			return;
		// starting single image phase, put up caption
		$('div.caption').text(img.alt).animate({
			opacity: 1.0
		});
	}
	else
	{
		// starting cross-fade phase, take out caption
		$('div.caption').animate({opacity: 0});
	}
}
