$(function(){
	var actBodyOpen = false;
	$('body').addClass('body');
	function zindex10(zindex){		
		$(zindex).addClass('zindex');		
		if(!$(zindex).parent().hasClass('body')){
			zindex = $(zindex).parent()
			zindex10(zindex)
		}
	}
	
	$("body").click(function(){			
		if(actBodyOpen){
			actBodyOpen.children('ul').css('display','none');
			actBodyOpen.removeClass('OpenSelect');			
		};
	});
	$(".select_form ul li").click(function(){
		$(this).parent().prev().html('<span>'+$(this).text()+'</span>')
		$(this).parent().prev().css('color','#5d61aa')
	}).mouseover(function(){
		$(this).css({'color':'#313eac'})
	}).mouseout(function(){
		$(this).css({'color':'#5d61aa'})		
	});

	
	$(".select_form").click(function(){
		if($(this).hasClass('select_form_top')){
			$(this).children('ul').css({'top':'auto', 'bottom':'17px'})
		};
		$(this).children('ul').css('width',$(this).innerWidth());
		$(this).children('div').css('width',$(this).children('div').innerWidth());
		if(!$(this).hasClass('OpenSelect')){			
			$('.zindex').removeClass('zindex');
			actBodyOpen = $('.OpenSelect');
			$(this).addClass('OpenSelect');
			$(this).css('backgroundPosition','100% 1px');
			zindex10(this);
			$(this).children('ul').css('display','block');
			$(this).addClass('lastopen');			
		}else{
			$(this).removeClass('OpenSelect');
			$(this).children('ul').css('display','none');			
		};		
	}).mouseover(function(){
		if(!$(this).hasClass('OpenSelect')){
			$(this).css('backgroundPosition','100% -16px')
		};
	}).mouseout(function(){
		if(!$(this).hasClass('OpenSelect')){
			$(this).css('backgroundPosition','100% 1px')			
		};
		actBodyOpen = $(this);
	});
	
	$(".F_checkbox").click(function(){
		if($(this).hasClass('F_checkbox_act')){
			$(this).removeClass('F_checkbox_act');
		}else{
			$(this).addClass('F_checkbox_act');
		}
	});
	
	$(".submitBlock input").mouseover(function(){
		$(this).parent().css('backgroundPosition','0 -123px');
	}).mouseout(function(){		
		$(this).parent().css('backgroundPosition','0 0');
	});
	$(".LftMarki td").mouseover(function(){
		$(this).parent().addClass('textDec');
    }).mouseout(function(){		
		$(this).parent().removeClass('textDec');
	});
	
});