$(document).ready(function() {

	$('.order_btn, .order-from-right-col').click(function(){
		if ( $(this).hasClass('order_btn_cur') ) return true;
		$(this).addClass('order_btn_cur');
		$('.order_panel').slideDown();
		return false;
	});

	$('#country-sel').bind('change', function(){
		btn = $('.order_btn, .order-from-right-col');
		href = btn.attr('href').replace(/\/[a-z]{2}\/order\/select/i, '/'+$(this).val()+'/order/select');
		
		btn.attr('href', href);
		location.href = href;
	});

	// обработка ссылок в разделе price
	$('#ucNav_rptNavLevel1_ctl01_rptNavLevel2_ctl02_lnkNavLevel2').click(function(){
		
		$('#country-sel').unbind();
		
		var cx = $(this);
		
		$('#country-sel').bind('change', function(){
			href = cx.attr('href').replace(/\/[a-z]{2}\/product\/price_listing/i, '/'+$(this).val()+'/product/price_listing');
			location.href = href;
		});
		
		var pan = $('.order_panel');
		pan.detach();
		
		pan.prependTo('body');
		
		offset = $(this).offset();
		
		offset.left -= 16;
		offset.top -= 8;
		
		$('#price').find('a').css('z-index', '10');
		
		$('.order_panel')
			.css({'position':'absolute', 'z-index':'9990', 'display':'block'})
			.offset(offset);
		
		$(this).css('z-index', '9999');
		
		return false;
	});

	
	// обработка ссылки OrederNow
	$('#Ordernow').click(function(){
		
		$('#country-sel').unbind();
		
		var cx = $(this).parent();
		
		$('#country-sel').bind('change', function(){
			href = cx.attr('href').replace(/\/[a-z]{2}\/order\/select/i, '/'+$(this).val()+'/order/select');
			location.href = href;
		});
		
		var pan = $('.order_panel');
		pan.detach();
		
		pan.prependTo('body');
		
		offset = $(this).offset();
		
		offset.left -= 16;
		offset.top -= 8;
		$('body').css('position', 'relative');
		
		$('.order_panel')
			.css({'position':'absolute', 'z-index':'99', 'display':'block'})
			.offset(offset);
		
		
		$(this).css('display', 'block-inline');
		$(this).css('position', 'relative');
		$(this).css('z-index', '99999');
		
		return false;
	});
	
	// затухание флеш сообщений
	$('.flash-message').fadeOut(3000);

});
