// DOM готов
$(document).ready(function(){


$('.fullblog_c').click(function(){
num = $('.fullblog_c').index(this);
$('.fulltext_blog').eq(num).hide(300);
$('.newsText.insider').eq(num).show();

return false;
});


$('.fullblog1').click(function(){
$('.fulltext_blog').hide();
$('.newsText.insider').show();

num = $('.fullblog1').index(this);

$('.fulltext_blog').eq(num).show(300);

$('.newsText.insider').eq(num).hide();

return false;
});

$('.fullblog2').click(function(){
$('.fulltext_blog').hide();
$('.newsText.insider').show();
num = $('.fullblog2').index(this);

$('.fulltext_blog').eq(num).show(300);

$('.newsText.insider').eq(num).hide();

return false;
});

$('.fullblog3').click(function(){
$('.fulltext_blog').hide();
$('.newsText.insider').show();
num = $('.fullblog3').index(this);

$('.fulltext_blog').eq(num).show(300);

$('.newsText.insider').eq(num).hide();

return false;
});


jQuery('.bottom_texts_content,.bottom_texts_content2,.bottom_texts_content3').hide();


jQuery('.button_grey#b_closed').live('click', function(){

srcimg = jQuery('.button_grey#b_opened img').attr('src');

jQuery('.bottom_texts_content,.bottom_texts_content2,.bottom_texts_content3').show();
jQuery('.button_grey').attr('id','b_opened');
jQuery('.button_grey#b_opened img').attr('src',srcimg);

});

jQuery('.button_grey#b_opened').live('click', function(){
srcimg = jQuery('.button_grey#b_opened img').attr('src');
jQuery('.bottom_texts_content,.bottom_texts_content2,.bottom_texts_content3').hide();
jQuery('.button_grey').attr('id','b_closed');
jQuery('.button_grey#b_closed img').attr('src',srcimg);
});





function getcookie(check_name)
{
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = decodeURIComponent( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}




/*
 
cwindow = $(window).width();
left = (cwindow-747)/2;
left = Math.ceil(left);


$("#rass").css("left", left);
$("#vopros").css("left", left);
$("#inst").css("left", left);
$("#cat").css("left", left);
$("#pre").css("left", left);
$("#pricer").css("left", left);
*/

//Расстановка классов first и .last для ячеек и строк в таблицах, а также для элементов списка
jQuery('table').find('tr:first').addClass('first');
jQuery('table').find('tr:last').addClass('last');
jQuery('table tr').find('td:first').addClass('first');
jQuery('table tr').find('td:last').addClass('last');
jQuery('ul').find('li:first').addClass('first');
jQuery('ul').find('li:last').addClass('last');

//Фикс ie6
if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
	jQuery('#mainMenu li').hover(function(){
		jQuery(this).addClass('hover');
	}, function(){
		jQuery(this).removeClass('hover');
	});
}
jQuery('#mainMenu li').mouseenter(function(){
	jQuery(this).find('.wrap').show();
}).mouseleave(function(){
	jQuery(this).find('.wrap').hide();
});

jQuery('.searchQuery').blur(function(){
	if (this.value == '') {this.value = 'KOMANDOR в вашем городе';jQuery(this).removeClass('alt');}
}).focus(function(){
	if (this.value == 'KOMANDOR в вашем городе') {jQuery(this).addClass('alt'); this.value = '';}
});

		//scrollpane parts
		var scrollPane = jQuery( ".scroll-pane" ),
			scrollContent = jQuery( ".scroll-content" );
		
		//build slider
		var scrollbar = jQuery( ".scroll-bar" ).slider({
			slide: function( event, ui ) {
				if ( scrollContent.width() > scrollPane.width() ) {
					scrollContent.css( "margin-left", Math.round(
						ui.value / 100 * ( scrollPane.width() - scrollContent.width() )
					) + "px" );
				} else {
					scrollContent.css( "margin-left", 0 );
				}
			}
		});
		
		//append icon to handle
		var handleHelper = scrollbar.find( ".ui-slider-handle" )
		.mousedown(function() {
			scrollbar.width( handleHelper.width() );
		})
		.mouseup(function() {
			scrollbar.width( "100%" );
		})
		.append( "<span class='ui-icon ui-icon-grip-dotted-vertical'></span>" )
		.wrap( "<div class='ui-handle-helper-parent'></div>" ).parent();
		
		//change overflow to hidden now that slider handles the scrolling
		scrollPane.css( "overflow", "hidden" );
		
		//size scrollbar and handle proportionally to scroll distance
		function sizeScrollbar() {
			var remainder = scrollContent.width() - scrollPane.width();
			var proportion = remainder / scrollContent.width();
			var handleSize = scrollPane.width() - ( proportion * scrollPane.width() );
			scrollbar.find( ".ui-slider-handle" ).css({
				width: handleSize,
				"margin-left": -handleSize / 2
			});
			handleHelper.width( "" ).width( scrollbar.width() - handleSize );
		}
		
		//reset slider value based on scroll content position
		function resetValue() {
			var remainder = scrollPane.width() - scrollContent.width();
			var leftVal = scrollContent.css( "margin-left" ) === "auto" ? 0 :
				parseInt( scrollContent.css( "margin-left" ) );
			var percentage = Math.round( leftVal / remainder * 100 );
			scrollbar.slider( "value", percentage );
		}
		
		//if the slider is 100% and window gets larger, reveal content
		function reflowContent() {
				var showing = scrollContent.width() + parseInt( scrollContent.css( "margin-left" ), 10 );
				var gap = scrollPane.width() - showing;
				if ( gap > 0 ) {
					scrollContent.css( "margin-left", parseInt( scrollContent.css( "margin-left" ), 10 ) + gap );
				}
		}
		
		//change handle position on window resize
		jQuery( window ).resize(function() {
			resetValue();
			sizeScrollbar();
			reflowContent();
		});
		//init scrollbar size
		setTimeout( sizeScrollbar, 10 );//safari wants a timeout
		
		
//Скрытие/показ вакансий
jQuery('.toggleVacancyVision').click(function(){
	if (jQuery(this).prev('div').is(':visible')) {
		jQuery(this).prev('div').slideUp('fast');
		jQuery(this).parent().find('.sendResume').addClass('unactive');
		jQuery(this).text('Раскрыть информацию о вакансии');
	}
	else {
		jQuery(this).prev('div').slideDown('fast');
		jQuery(this).parent().find('.sendResume').removeClass('unactive');
		jQuery(this).text('Скрыть информацию о вакансии');
	}
	return false;
});

//Форма отправки резюме
jQuery('.sendResume').click(function(){
	jQuery('#overlay .wrap').removeClass('visible');
	jQuery('#overlay .sendResumeForm').addClass('visible');
	jQuery('#overlay').animate({
		opacity:'show'
	}, 'fast');
	return false;
});

//Выпадающий список в резюме
jQuery('.selectLikeMenu li:first').click(function(){
	jQuery(this).parent().find('li:not(:first)').slideToggle('fast');
});

jQuery('.selectLikeMenu li:not(:first)').click(function(){
	var newText = jQuery(this).text();
	var oldText = jQuery(this).parent().find('li:first span').text();
	jQuery(this).text(oldText);
	jQuery(this).parent().find('li:first span').text(newText);
	jQuery(this).parent().find('input[type=hidden]').val(newText);
	jQuery(this).parent().find('li:not(:first)').slideUp('fast');
});

if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
	jQuery('.selectLikeMenu li:not(:first)').hover(function(){
		jQuery(this).addClass('hover');
	}, function(){
		jQuery(this).removeClass('hover');
	});
}
jQuery('#overlay').click(function(event){
	if (event.target.tagName.toLowerCase() == 'div' || event.target.tagName.toLowerCase() == 'form' || event.target.tagName.toLowerCase() == 'input' || event.target.tagName.toLowerCase() == 'p') {
		jQuery('.selectLikeMenu li:not(:first)').slideUp('fast');
	}
	if (event.target.id == 'overlay') {
		jQuery('#overlay').animate({opacity:'hide'},'fast');
		jQuery('.customs #vopros').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #cat').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #pre').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #inst').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #pricer').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #rass').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #document').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #study').animate({opacity:'hide'},'fast').removeAttr('act');
		jQuery('.customs #barCode').animate({opacity:'hide'},'fast').removeAttr('act');
	}
});


/*
jQuery('#overlayFormClose').click(function(){
	jQuery('#overlay').animate({opacity:'hide'},'fast', function(){
		jQuery('#overlay .sendCompleteContainer').removeClass('visible');
		jQuery('#overlay .wrap').not('.sendCompleteContainer').addClass('visible');
	});
	return false;
});
*/



jQuery('#overlay .linkClose').click(function(){
	jQuery('#overlay').animate({opacity:'hide'},'fast', function(){
		jQuery('#overlay .sendCompleteContainer').removeClass('visible');
		jQuery('#overlay .wrap').not('.sendCompleteContainer').addClass('visible');
	});
	return false;
});

jQuery('.siteMapSection:odd').filter(':odd').css('margin-right','0');

jQuery('.imgContainer').hover(function(){
	var height = jQuery(this).find('img').height();
	jQuery(this).append("<table style='height:"+height+"px;'><tbody><tr><td><img src='/verstka/images/imageInFocus.png' alt='' /></td></tr></tbody></table>");
}, function(){
	jQuery(this).find('table').remove();
});

jQuery('a.getDelivery').click(function(){
	jQuery('#overlay .wrap').removeClass('visible');
	jQuery('#overlay .getDelivery').addClass('visible');
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	return false;
});





jQuery('#overlayFormClose').live('click', function() {

jQuery('#overlay').animate({opacity:'hide'},'fast');
jQuery('.customs #vopros').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #pre').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #cat').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #inst').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #pricer').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #rass').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #document').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #study').animate({opacity:'hide'},'fast').removeAttr('act');
jQuery('.customs #barCode').animate({opacity:'hide'},'fast').removeAttr('act');
	return false;
});


cwind = $(window).width();
lefter = (cwind-747)/2;
lefter= Math.ceil(lefter);

 if (jQuery.browser.msie && jQuery.browser.version == '6.0') {

 lefter = 0;
}



jQuery('.rassilka').live('click', function() {
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #rass').animate({opacity:'show'}, 'normal').css("left", lefter);

return false;
   
});

jQuery('.pricer').live('click', function() {
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #pricer').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false;
});




jQuery('.mailTous').click(function(){	
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #vopros').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false; 
});

//----------------------------------------------------------------------------------------
jQuery('.podlinost').click(function(){	
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #barCode').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false; 
});
//----------------------------------------------------------------------------------------

jQuery('.inst').live('click', function() {
	rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #inst').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false;
});

jQuery('.cat').live('click', function() {
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #cat').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false;
});


jQuery('.pre').live('click', function() {
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #pre').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false;
});


jQuery('.docUs').live('click', function() {
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #document').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false;
});

jQuery('.studyUs').live('click', function() {
rander = Math.floor( Math.random( ) * (10 - 1 + 1) ) + 1
	jQuery('.cap-div-im').html('<img class="cap-img" src="/cap/cap'+rander+'.gif">'); 
	jQuery('#overlay').animate({opacity:'show'}, 'fast');
	jQuery('.customs #study').animate({opacity:'show'}, 'normal').css("left", lefter);

	return false;
});


//Проверка на Валидность капчи
	/*
	$('input[name=captcha_code]').keyup(function () {
	
	numb = $('input[name=captcha_code]').index(this);
	
	cap = $('.submitter').eq(numb).find("input[name=captcha_code]").val();
	
	//Пока так=)
	
	if (cap=="GLXNY"||cap=="YSFWN"||cap=="FDPFB"||cap=="MMPSU"||cap=="OYNXN"||cap=="BKHWD"||cap=="UPYHC"||cap=="LCZWT"||cap=="OBVKP"||cap=="glxny"||cap=="ysfwn"||cap=="fdpfb"||cap=="mmpsu"||cap=="oynxn"||cap=="bkhwd"||cap=="upyhc"||cap=="lczwt"||cap=="obvkp"||cap=="zrybd"||cap=="ZRYBD")
	{
	$('.submitter').eq(numb).find(".error-cap").css('display','none');
	return true
	}
	else
	{
	$('.submitter').eq(numb).find(".error-cap").css('display','block');
	return false;
	}
	});
	
*/
//Проверка полей форм на заполненность
	
	 $("input[class=text]").blur(function () { 
	 
    numbs = $("input[class=text]").index(this);
	v = $("input[class=text]").eq(numbs).val();
	if (v=='')
	{
   $(".error").eq(numbs).css('display','block');
   }
   else
   {
   $(".error").eq(numbs).css('display','none');
   }

});

 //Проверка select
   
	 $("#idSelect").blur(function () { 
	 
	myv = $("#idSelect").val();
	if (myv=='')
	{
   $(".error-select").css('display','block');
   }
   else
   {
   $(".error-select").css('display','none');
   }   

});
 //Проверка одного textarea на заполненность
	
	 $("textarea[class=text]").blur(function () { 
	 
	v = $("textarea[class=text]").val();
	if (v=='')
	{
   $(".error-area").css('display','block');
   }
   else
   {
   $(".error-area").css('display','none');
   }

});



var options = {
	target: "#rass #mailform2 .rassUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы

   cod1 = $("#mailform2 input[name=icaptcha]").val();

index = 0;
$('#mailform2 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#rass #mailform2 .rassUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#rass #mailform2 .rassUs").html("<span class='formtitle'>Вы успешно подписались на рассылку.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Вы успешно подписались на рассылку!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}

	 
	};
		
	/////
	
	var options2 = {
	target: "#pricer #mailform6 .priceUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы

	
   cod1 = $("#mailform6 input[name=icaptcha]").val();

index = 0;
$('#mailform6 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#pricer #mailform6 .priceUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#pricer #mailform6 .priceUs").html("<span class='formtitle'>Ваша заявка отправлена.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваша заявка на прайс лист успешно отправлена!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}
	 
	};
	
	
	
	/////
	
	var options3 = {
	target: "#vopros #mailform1 .voprosUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы

  cod1 = $("#mailform1 input[name=icaptcha]").val();

index = 0;
$('#mailform1 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#vopros #mailform1 .voprosUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#vopros #mailform1 .voprosUs").html("<span class='formtitle'>Ваше письмо успешно отправлено.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваше письмо успешно отправлено нам.</span></div>");
	}
	

	
	setTimeout(function () {
	//Обнновляем страницу
	//location="http://td-komandor.ru/thankyou/";
	location.reload();
	}, 0);

	}

	 
	};
	

	/////
	
	
		var options4 = {
	target: "#inst #mailform3 .instUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы

   cod1 = $("#mailform3 input[name=icaptcha]").val();

index = 0;
$('#mailform3 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#inst #mailform3 .instUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#inst #mailform3 .instUs").html("<span class='formtitle'>Ваша заявка отправлена.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваша заявка на инструкцию успешно отправлена!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}
	 
	};
	
	
	
	/////
	
	
	
	var options5 = {
	target: "#cat #mailform4 .catUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы

   cod1 = $("#mailform4 input[name=icaptcha]").val();
	cod2= $("#mailform4 .error").css('display');
	
	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#cat #mailform4 .catUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#cat #mailform4 .catUs").html("<span class='formtitle'>Ваша заявка отправлена.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваша заявка на каталог успешно отправлена!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}
	 
	};
	
	
	
	
	/////
	

	var options6 = {
	target: "#pre #mailform5 .preUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы	

  cod1 = $("#mailform5 input[name=icaptcha]").val();

index = 0;
$('#mailform5 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#pre #mailform5 .preUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#pre #mailform5 .preUs").html("<span class='formtitle'>Ваша заявка отправлена.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваша заявка на презентацию успешно отправлена!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}

	 
	};
	
	
	
	
	
	
	
	
		
	/////
	

	var options7 = {
	target: "#document #mailform7 .docUs", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы	

	
	 cod1 = $("#mailform7 input[name=icaptcha]").val();

index = 0;
$('#mailform7 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#document #mailform7 .docUs").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#document #mailform7 .docUs").html("<span class='formtitle'>Ваша заявка отправлена.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваша заявка на документы успешно отправлена!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}

	 
	};
	
	
	
	/////
	

	var options8 = {
	target: "#study #mailform8 .study", //Целевой элемент, в который выводим ответ от запроса
	url: "/mailto.php", //PHP скрипт для отправки формы через функцию mail
	beforeSubmit:function() {	 //Функция выполняемая до отправки формы
		
	  cod1 = $("#mailform8 input[name=icaptcha]").val();

index = 0;
$('#mailform8 input[class=text]').each(function() {
numb = $('input[class=text]').index(this);
value = $('input[class=text]').eq(numb).val();

if (value=='')
{
index++;
}

});

if (index>0)
{
cod2='block';
}
else
{
cod2='none';
}

	if (cod2=='block')
	{
	return false;
	}
	else if (cod1=='0')
	{
	return false;
	}
	else if (cod1=='1'&&cod2=='block')
	{
	return false;
	}
	else
	{
	return true;
	}
	
	},
	success: function() { //Функция выполняемая при успехе	
	res = $("#result-form").html();
	if (res=="no")
	{	
	$("#study #mailform8 .study").html("<span class='formtitle'>Неверен код с картинки.</span><br><br><div class='reqtext'><span class='b1'>Извините, вы неправильно ввели код с картинки!</span><br><span class='b2'>Введите правильный код повторно.</span></div>");
	}
	else if(res=="yes")
	{
	$("#study #mailform8 .study").html("<span class='formtitle'>Ваша заявка отправлена.</span><br><br><div class='reqtext'><span class='b1'>Спасибо за проявленный интерес!</span><br><span class='b2'>Ваша заявка на обучение успешно отправлена!</span></div>");
	}
	setTimeout(function () {
	//Обнновляем страницу
	location.reload();
	}, 700);
	}

	 
	};
	
	
// При нажатии на элемент с class='.send' отправляем форму





jQuery('#send-myform').live('click', function() {


//Обходим все элементы текущей формы и проверяем на заполненность

$('#mailform2 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
});

//Отправка если все ок

$("#mailform2").ajaxSubmit(options);
return false;	

});


jQuery('#send-myform2').live('click', function() {

$('#mailform6 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
   

   
   
});
   valuear = $('#idSelect').val();
   if (valuear=='')
   {
   $(".error-select").css('display','block');
   return false;
   }   
$("#mailform6").ajaxSubmit(options2);
	
	return false;
});



jQuery('#send-myform3').live('click', function() {


$('#mailform1 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();



	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
   
   valuearea = $('textarea[class=text]').val();
   if (valuearea=='')
   {
   $(".error-area").css('display','block');
   }
});

$("#mailform1").ajaxSubmit(options3);
	
	return false;
});



jQuery('#send-myform4').live('click', function() {


$('#mailform3 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
});


$("#mailform3").ajaxSubmit(options4);
	
	return false;
});

//----------------------------------------------------------------
jQuery('#send-myform-podlinost').live('click', function() {
	var code = $(".text").val();
	cod1 = $("#mailform-podl input[name=icaptcha]").val();
	if (cod1==1)
	{
	//alert(code);
	$.post('/netCatCrash/barcode.php', { code: code } ,function(data) {
		//$("#mailform-podl").height(280);		
		$("#mailform-podl").html(data+'<span id="overlayFormClose" onclick="location.href=location.href"></span>');
		//var hh = $(".barcodeContent").height()-40;
		//$("#mailform-podl").height(hh);
		//alert($(".barcodeContent").height());
	});
	}
	
});
//----------------------------------------------------------------


jQuery('#send-myform5').live('click', function() {

$('#mailform4 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
});

$("#mailform4").ajaxSubmit(options5);
	
	return false;
});


jQuery('#send-myform6').live('click', function() {

$('#mailform5 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
});

$("#mailform5").ajaxSubmit(options6);
	
	return false;
});



jQuery('#send-myform7').live('click', function() {

$('#mailform7 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
});

$("#mailform7").ajaxSubmit(options7);
	
	return false;
});




jQuery('#send-myform8').live('click', function() {

$('#mailform8 input[class=text]').each(function() {

numb = $('input[class=text]').index(this);

value = $('input[class=text]').eq(numb).val();

	if (value=='')
	{
   $(".error").eq(numb).css('display','block');
   return false;
   }
   else
   {
   $(".error").eq(numb).css('display','none');
   }	
});

$("#mailform8").ajaxSubmit(options8);
	
	return false;
});


   

}); 

function showHelp(name,qq){
            $("#"+name).fadeIn('fast');
            $("#"+qq).removeClass('qq');
            $("#"+qq).addClass('qq_active');
        }
        function hideHelp(name,qq){
             $("#"+name).fadeOut('fast');
             $("#"+qq).removeClass('qq_active');
             $("#"+qq).addClass('qq');           
        }
	
   

