jQuery.noConflict();

jQuery(document).ready(function($)
{
	// Nostot
	$('div#nosto_content ul').cycle(
	{
		fx: 'fade',
		timeout: 0,
		speed: 500
	});
	
	$('div#nosto_navigation ul.navigation li:first-child span').addClass('active');
	$('div#nosto_navigation ul.navigation').children().each(function(i)
	{
		$(this).mouseover(function()
		{
			$('div#nosto_navigation ul.navigation li span.active').removeClass('active');
			$('div#nosto_navigation ul.navigation li:nth-child(' + (i + 1) + ') span').addClass('active');
			$('div#nosto_content ul').cycle(i);
		});
	});
	
	// Haku label
	var hakulabel = $('label#search_label').html();
	$('label#search_label').hide();
	$('input#keywords').val(hakulabel);
	$('input#keywords').focus(function()
	{
		if ($(this).val() == hakulabel)
		{$(this).val('');}
	});
	
	$('input#keywords').blur(function()
	{
		if ($(this).val() == '' || $(this).val() == ' ')
		{$(this).val(hakulabel);}
	});
	
	// Form validation
	$("form.tarjouspyynto").validate(
	{
		errorElement: "span",
		rules:
		{
			name: { required: true, minlength: 3 },
			phone: { required: true, minlength: 3 },
			email: { required: true, email: true },
			quote: { required: true, minlength: 10 }
		},
		messages:
		{
			name: " puuttuu",
			phone: " puuttuu",
			email: { required: " puuttuu", email: " on virheellinen" },
			quote: " puuttuu"
		},
		errorPlacement: function(error, element)
		{
			error.appendTo( element.prev() );
		}
	});
});