function slideSwitch() {
    	var $active = $('#slideshow IMG.active');
	    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    	var $next =  $active.next().length ? $active.next()
        	: $('#slideshow IMG:first');
	    $active.addClass('last-active');
    	$next.fadeOut(1, function() { $(this).addClass('active').fadeIn(800, function() { $active.removeClass('active last-active'); });
    	});
}
	
	
	
	
	
$(function() {
		// slideshow
    	setInterval( "slideSwitch()", 3300 );
    	
    	$('.partners_description').hide();
		$('.partner_item').click(function() {
			var cn = $(this).find('.partner_all_descr').html();
			$('.partner_item').removeClass('active');
			$(this).addClass('active');
			$('.partners_description').fadeOut(0,function(){			$('.partners_description').html(cn);});
			$('.partners_description').fadeIn('fast');
			//	return false;
		});
		
		
		// # + base href FIX
		$("a[ href ^= '#' ]").each(function() {
        	var href = window.location + $(this).attr('href').replace('/#.*/i','');
        	$(this).attr('href',href);
    });
    
	// validate signup form on keyup and submit
	jQuery.validator.messages.required = "";
	var validator = $("#order").validate({
			invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'Вы не заполнили 1 поле. Оно отмечено ниже'
					: 'Вы не заполнили ' + errors + ' полей. Они отмечены ниже';
				$("div.errors_list span").html(message);
				$("div.errors_list").show();
			} else {
//				$("div.errors_list").hide();
			}
		},
		onkeyup: false


	});
	validator;
	$('#dest_my').focus(function(){ $(this).parent().parent().find(".f_radio input[type=radio]").attr("checked","") });
	
	
	// weather 
	$('.w_os, .w_ob').hover(
		function()
		{
			var weather_txt = $(this).attr('title');
			if(weather_txt!="")
			{
				$(this).append("<div class='w_alttitle'>"+weather_txt+"</div>");
				$(this).find('.w_alttitle').hide().fadeIn(300);
			}
		},
		function()
		{
			$(this).find('.w_alttitle').fadeOut(300, function() {$(this).remove();});
		}
	);
	
	
});
	
	
	

