jQuery.noConflict();

jQuery(document).ready(function($)
{
	// Hide content
	$('.ujs_hide').hide();
	
	// Tabbed box navigation
	//$('ul#product_tab_nav').tabs();
	$('ul.folded_content_menu').tabs();
	
	// Stripe
	$('.ujs_stripe li:nth-child(even)').addClass('even');
	$('.ujs_stripe tbody tr:nth-child(odd)').addClass('odd');
	
	// Hover
	$('.ujs_hover li').hover( function() {$(this).addClass('selected');}, function() {$(this).removeClass('selected');} );
	
	// Out of use
	$('.ujs_out_of_use').click( function(e) { alert('Tämä ominaisuus ei ole vielä käytössä.'); e.preventDefault(); } );
	
	$("form.yhteydenottolomake").validate(
	{
		rules:
		{
			name: "required",
			message: "required"
			// email: { required: true, email: true }
		},
		messages:
		{
			name: " is required",
			message: " is required"
			// email: { required: "Annathan myös sähköpostiosoitteesi", email: "Sähköpostiosoitteen muoto on virheellinen"}
		},
		errorPlacement: function(error, element)
		{
			error.appendTo( element.prev() );
		}
	});
	
	// Links within page - animated scrolling
	// http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links
	$('p a[href*=#]').each(function()
	{
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
		&& location.hostname == this.hostname
		&& this.hash.replace(/#/,'') )
		{
			var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
			var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
			if ($target)
			{
				var targetOffset = $target.offset().top;
				$(this).click(function()
				{
					$('html, body').animate({scrollTop: targetOffset}, 200);
					return false;
				});
			}
		}
	});
});


/* Thanks to Peter-Paul Koch: http://www.quirksmode.org/js/select.html */
function navigationGo(navElement)
{
	nav = document.getElementById(navElement);
	dest = nav.options[nav.selectedIndex].value;
	if (dest)
	{
		location.href = dest;
	}
}