$(document).ready(function(){
//подсветка строки в сравнении
	$('.search-submit').hover(
		function(){ $(this).addClass('search_sact2'); },
		function(){ $(this).removeClass('search_sact2'); }
	);

	$('.auth-submit').hover(
		function(){ $(this).addClass('auth-s2'); },
		function(){ $(this).removeClass('auth-s2'); }
	);

	$('.feature-title-open').hover(
		function(){ $(this).addClass('ftitleco'); },
		function(){ $(this).removeClass('ftitleco'); }
	);
	
	$('.feature-title-close').hover(
		function(){ $(this).addClass('ftitleco'); },
		function(){ $(this).removeClass('ftitleco'); }
	);	





	$('.tbl_srv').hover(
		function(){ $(this).addClass('hover'); },
		function(){ $(this).removeClass('hover'); }
	);
// открыть
 $(".footer-inner2").click(function(){
   $(".footer").hide()
   $(".head").hide()
   $(".main-inner").hide()
   $(".footer2z").show()
 });
 $(".footer-inner2a").click(function(){
   $(".footer2z").hide()
   $(".footer").show()
   $(".head").show()
   $(".main-inner").show()
 });

 $(".feature-title-close").click(function(){
 if($(this).hasClass("feature-title-open")){
  $(this).removeClass("feature-title-open")
  $(this).addClass("feature-title-close")
  $(this).next(".feature-text-close").hide()
 } 
 else{
  $(this).removeClass("feature-title-close")
  $(this).addClass("feature-title-open")
  $(this).next(".feature-text-close").show()
 }
 });
// мелкие картинки
 $(".td_img_small").click(function(){
  $(".td_img_small").removeClass("td_active")
  $(this).addClass("td_active")
  x="#"+this.id+"_div"
  $(".c-photo").addClass("close_img")
  $(x).removeClass("close_img")
 });

});
function f_compare(e){
  $.post('/js/ajax.php',{cod_g:e,cod_ses:$("#cod_ses").val()},onAjaxSuccess_ng);
}
function onAjaxSuccess_ng(dta){
 $("#tdsrli_0").append(dta);
 $(".add-to-compare").hide()
 $("#div_list_compare").removeClass("close_img")
 $("#srli_0").removeClass("close_img")
 $("#srli_0").show()
}

function func_dost(e){
   document.getElementById("p_dostavka").value=e
   if (e==2){
      $(".b_style").hide()
   }
   else{
      $(".b_style").show()   
   }
}

function f_basket(e){
 fl1=document.getElementById('korz_all_hidd').value
 if (fl1==0){
    $("#korz_all").show()
    document.getElementById('korz_all_hidd').value=1
 }
 else{
  e2=document.getElementById('sel_color').value
  e3=document.getElementById('sel_razm').value
  e5=document.getElementById('sel_tipraz').value      
  if ((e2==0)||(e3=="")){
   dta='---';
   onAjaxSuccess_ng2(dta)
  }
  else{
   $.post('/js/ajax2.php',{cod_g:e,cod_ses:$("#cod_ses2").val(),cod_c:e2,cod_r:e3,cod_tr:e5},onAjaxSuccess_ng2);
  }
 }
}


function f_basket2(e){
 fl1=document.getElementById('korz_all_hidd').value
 if (fl1==0){
    $("#korz_all").show()
    document.getElementById('korz_all_hidd').value=1
 }
 else{
  e2=document.getElementById('sel_color').value
  e3=document.getElementById('sel_razm').value  
  e4=document.getElementById('sel_moln').value  

  e5=document.getElementById('sel_tipraz').value  
  if ((e2==0)||(e3=="")){
   dta='---';
   onAjaxSuccess_ng2(dta)
  }
  else{
   $.post('/js/ajax3.php',{cod_g:e,cod_ses:$("#cod_ses2").val(),cod_c:e2,cod_r:e3,cod_m:e4,cod_tr:e5},onAjaxSuccess_ng2);
  }
 }
}

function f_basket3(e){
 fl1=document.getElementById('korz_all_hidd').value
 if (fl1==0){
    $("#korz_all").show()
    document.getElementById('korz_all_hidd').value=1
 }
 else{
  e2=document.getElementById('sel_color').value
  e5=document.getElementById('sel_tipraz').value  
  if (e2==0){
   dta='---';
   onAjaxSuccess_ng2(dta)
  }
  else{
   $.post('/js/ajax4.php',{cod_g:e,cod_ses:$("#cod_ses2").val(),cod_c:e2,cod_tr:e5},onAjaxSuccess_ng2);
  }
 }
}



function onAjaxSuccess_ng2(dta){
  if (dta!="---"){
   document.getElementById('mess_div').innerHTML="<br /><b style=\"color:green\">Товар добавлен в корзину</b><br /><br />"
   mas_s=dta.split(",")
   document.getElementById('b_tov').innerHTML=mas_s[0]
   document.getElementById('b_sum').innerHTML=mas_s[1]
  }
  else{
     document.getElementById('mess_div').innerHTML="<br /><b style=\"color:red\">Ошибка. Необходимо заполнить все поля выбора</b><br /><br />"
  }
  $("#mess_div").show()
  setTimeout('f_hd_mess()',2000);
}

function f_hd_mess(){
  document.getElementById('mess_div').innerHTML=""
  $("#mess_div").hide()
}


function f_view_post(){
		document.getElementById("all_pg").style.display=""
		document.getElementById("cod_link2").style.display=""
		document.getElementById("cod_link1").style.display="none"
}
function f_hide_post(){
		document.getElementById("cod_link1").style.display=""
		document.getElementById("cod_link2").style.display="none"
		document.getElementById("all_pg").style.display="none"
}

function f_sbm_kom(){
        if (document.getElementById("zagol_komm").value=="") {alert("Не введен заголовок"); return false;}
        if (document.getElementById("dopinf").value=="") {alert("Не введен текст комментария"); return false;}
        if (document.getElementById("intgg").value=="") {alert("Не введен код подтверждения"); return false;}
		document.getElementById("nm").submit()
}

function f_sbm_kom2(){
        if (document.getElementById("message_m").value=="") {alert("Не введен текст комментария"); return false;}
		document.getElementById("nm").submit()
}

function f_opt_pok(e){
 if (e==1){
  document.getElementById("hid_oppok").value=1
  for (i=1;i<22;i++){
    $("#tr_dop"+i).show()
  }
 }
 else{
  document.getElementById("hid_oppok").value=0
  for (i=1;i<22;i++){
    $("#tr_dop"+i).hide()  
  } 
 }
}


function testFormR(){
        if (document.getElementById("login_aut").value=="") {alert("Не заполнено поле Логин"); return false;}
        if (document.getElementById("email_aut").value=="") {alert("Не заполнено поле  Email"); return false;}
        if (document.getElementById("pass1_aut").value=="") {alert("Не заполнено поле  Пароль"); return false;}
        if (document.getElementById("pass2_aut").value=="") {alert("Не заполнено поле  Повтор пароля"); return false;}
        if (document.getElementById("pass1_aut").value!=document.getElementById("pass2_aut").value) {alert("Пароль и повтор пароля не совпадают"); return false;}
        if (document.getElementById("pudop01").checked){
          if (document.getElementById("pudop1").value=="") {alert("Не заполнено поле Компания"); return false;}
          if (document.getElementById("pudop2").value=="") {alert("Не заполнено поле Должность"); return false;}
          if (document.getElementById("pudop3").value=="") {alert("Не заполнено поле Кого Вы представляете (магазин, сеть магазинов, дистрибьютера и т.д.)"); return false;}
          if (document.getElementById("pudop4").value=="") {alert("Не заполнено поле Адреса Ваших магазинов (города и количество)"); return false;}
          if (document.getElementById("pudop5").value=="") {alert("Не заполнено поле Специализация магазина"); return false;}
          if (document.getElementById("pudop6").value=="") {alert("Не заполнено поле Представленные товарные группы в магазине"); return false;}
          if (document.getElementById("pudop7").value=="") {alert("Не заполнено поле Ценовой уровень представленной одежды OUTDOOR"); return false;}
          if (document.getElementById("pudop8").value=="") {alert("Не заполнено поле Представленные торговые марки OUTDOOR"); return false;}
          if (document.getElementById("pudop9").value=="") {alert("Не заполнено поле Вы арендуете помещения или магазины в Вашей собственности"); return false;}
          if (document.getElementById("pudop10").value=="") {alert("Не заполнено поле Площадь Вашего магазина"); return false;}
          if (document.getElementById("pudop11").value=="") {alert("Не заполнено поле Объем продаж за год по одежде OUTDOOR"); return false;}
          if (document.getElementById("pudop12").value=="") {alert("Не заполнено поле Разделены ли торговые марки в магазине"); return false;}
          if (document.getElementById("pudop13").value=="") {alert("Не заполнено поле Представлена ли реклама торговых марок в магазине"); return false;}
          if (document.getElementById("pudop14").value=="") {alert("Не заполнено поле Бюджет рекламы магазина"); return false;}
          if (document.getElementById("pudop15").value=="") {alert("Не заполнено поле Ваши конкуренты"); return false;}
          if (document.getElementById("pudop16").value=="") {alert("Не заполнено поле Почему Вы лучше своих конкурентов"); return false;}
          if (document.getElementById("pudop17").value=="") {alert("Не заполнено поле Какие выставки посещаете для выбора одежды OUTDOOR"); return false;}
          if (document.getElementById("pudop18").value=="") {alert("Не заполнено поле Вы делаете заказы или покупаете в сезон"); return false;}
          if (document.getElementById("pudop19").value=="") {alert("Не заполнено поле Чем привлекает наш бренд"); return false;}
          if (document.getElementById("pudop20").value=="") {alert("Не заполнено поле Готовы ли Вы делать заказ и предоплату"); return false;}
          if (document.getElementById("pudop21").value=="") {alert("Не заполнено поле Готовы ли Вы для заказа приехать в наш офис или сделаете заказ по каталогу"); return false;}
		}
        return true;
}

function testFormU(){
        if (document.getElementById("login_aut").value=="") {alert("Не введен логин"); return false;}
        if (document.getElementById("email_aut").value=="") {alert("Не введен email"); return false;}
        if (document.getElementById("tpas_aut").value=="") {alert("Не введен текущий пароль"); return false;}
        if (document.getElementById("pass1_aut").value!="") {
          if (document.getElementById("pass1_aut").value!=document.getElementById("pass2_aut").value) {alert("Пароль и повтор пароля не совпадают"); return false;}		 
		}
        if (document.getElementById("pudop01").checked){
          if (document.getElementById("pudop1").value=="") {alert("Не заполнено поле Компания"); return false;}
          if (document.getElementById("pudop2").value=="") {alert("Не заполнено поле Должность"); return false;}
          if (document.getElementById("pudop3").value=="") {alert("Не заполнено поле Кого Вы представляете (магазин, сеть магазинов, дистрибьютера и т.д.)"); return false;}
          if (document.getElementById("pudop4").value=="") {alert("Не заполнено поле Адреса Ваших магазинов (города и количество)"); return false;}
          if (document.getElementById("pudop5").value=="") {alert("Не заполнено поле Специализация магазина"); return false;}
          if (document.getElementById("pudop6").value=="") {alert("Не заполнено поле Представленные товарные группы в магазине"); return false;}
          if (document.getElementById("pudop7").value=="") {alert("Не заполнено поле Ценовой уровень представленной одежды OUTDOOR"); return false;}
          if (document.getElementById("pudop8").value=="") {alert("Не заполнено поле Представленные торговые марки OUTDOOR"); return false;}
          if (document.getElementById("pudop9").value=="") {alert("Не заполнено поле Вы арендуете помещения или магазины в Вашей собственности"); return false;}
          if (document.getElementById("pudop10").value=="") {alert("Не заполнено поле Площадь Вашего магазина"); return false;}
          if (document.getElementById("pudop11").value=="") {alert("Не заполнено поле Объем продаж за год по одежде OUTDOOR"); return false;}
          if (document.getElementById("pudop12").value=="") {alert("Не заполнено поле Разделены ли торговые марки в магазине"); return false;}
          if (document.getElementById("pudop13").value=="") {alert("Не заполнено поле Представлена ли реклама торговых марок в магазине"); return false;}
          if (document.getElementById("pudop14").value=="") {alert("Не заполнено поле Бюджет рекламы магазина"); return false;}
          if (document.getElementById("pudop15").value=="") {alert("Не заполнено поле Ваши конкуренты"); return false;}
          if (document.getElementById("pudop16").value=="") {alert("Не заполнено поле Почему Вы лучше своих конкурентов"); return false;}
          if (document.getElementById("pudop17").value=="") {alert("Не заполнено поле Какие выставки посещаете для выбора одежды OUTDOOR"); return false;}
          if (document.getElementById("pudop18").value=="") {alert("Не заполнено поле Вы делаете заказы или покупаете в сезон"); return false;}
          if (document.getElementById("pudop19").value=="") {alert("Не заполнено поле Чем привлекает наш бренд"); return false;}
          if (document.getElementById("pudop20").value=="") {alert("Не заполнено поле Готовы ли Вы делать заказ и предоплату"); return false;}
          if (document.getElementById("pudop21").value=="") {alert("Не заполнено поле Готовы ли Вы для заказа приехать в наш офис или сделаете заказ по каталогу"); return false;}
		}		
        return true;
}

function testFormPg(){
   if (document.getElementById("login_mail").value=="") {alert("Не введен email"); return false;}
   return true;
}

function f_find_cl1(e){
  if (e==1){
     if (document.getElementById("login_aut2").value=='Логин') document.getElementById("login_aut2").value='';
  }
  if (e==2){
     if (document.getElementById("login_aut2").value=='') document.getElementById("login_aut2").value='Логин';
  }
}


function f_find_cl2(e){
  if (e==1){
     if (document.getElementById("f_search").value=='Искать') document.getElementById("f_search").value='';
  }
  if (e==2){
     if (document.getElementById("f_search").value=='') document.getElementById("f_search").value='Искать';
  }
}

function f_fpp(){
 document.getElementById('s_div1').style.display="none";
 document.getElementById('s_div2').style.display="";
 document.getElementById('pass_aut').focus()
}
function f_fp(){
   if(document.getElementById('pass_aut').value==""){
      document.getElementById('s_div2').style.display="none";
      document.getElementById('s_div1').style.display="";
   }
}

function f_sel_sbm(e){
  document.getElementById("f_type_model").value=e
  document.getElementById("form_sel").submit()
}
function f_comment_bl(e){
 x1=document.getElementById('kod_bokid').value
 document.getElementById('kod_bokid').value=e
 x2=document.getElementById('redaktor'+x1).innerHTML
 document.getElementById('zagol_kom').innerHTML='Написать комментарий';
 document.getElementById('redaktor'+x1).innerHTML='';
 document.getElementById('redaktor'+e).innerHTML=x2;
 document.getElementById('type_bokid').value="add"
 if (e!=0) document.getElementById('red_0hid').style.display="";
 else  document.getElementById('red_0hid').style.display="none";
}
function edit_kom(e) {
  f_comment_bl(e)
  document.getElementById('zagol_kom').innerHTML='Редактировать комментарий';
  document.getElementById('type_bokid').value="upd"
  $.post('/js/ajax_kom.php',{cod_g:e},onAjaxSuccess_kod_im);
}
function onAjaxSuccess_kod_im(ddd){
  document.getElementById('message_m').value=ddd
}

function edit_blog(e){
  document.getElementById('id_edit_kom').value=e
  document.getElementById("form_edit_kom").submit()  
}

function del_blog(e){
  document.getElementById('id_del_kom').value=e
  document.getElementById("form_del_kom").submit()  
}



function f_izm_price() {
  e1=document.getElementById('cod_tov_tek').value
  e2=document.getElementById('sel_color').value
  e3=document.getElementById('sel_razm').value
  if (e2!=0) $.post('/js/ajax_n_price.php',{cod_t:e1,cod_c:e2,cod_r:e3},onAjaxSuccess_kod_price);
}

function f_izm_price2() {
  e=document.getElementById('sel_color').value
  $.post('/js/ajax_n_priceap.php',{cod_t:e},onAjaxSuccess_kod_price);
}
function onAjaxSuccess_kod_price(ddd){
  document.getElementById('rek_price').innerHTML=ddd
}

function f_ch_sezon(e){
 document.getElementById('sez_sl').value=e
 document.getElementById('f_sezon').submit()
}

function f_sel_tr(e1,e2){
 $.post('/js/ajax5.php',{cod_g:e1,cod_t:e2},f_traz);
}

cod_iraz=0
cod_ivt=""
function f_sel_tr2(e1,e2,e3,e4){
 cod_iraz=e3
 cod_ivt=e4
 $.post('/js/ajax5.php',{cod_g:e1,cod_t:e2},f_traz2);
}

function f_traz(data){
   var sel = $("#sel_razm");
   sel.empty()
   $(data).appendTo(sel);
   f_izm_price()
}

function f_traz2(data){
   var sel = $("#sel_razm"+cod_iraz);
   sel.empty()
   $(data).appendTo(sel);
   if (cod_ivt=="") f_izm_tvr(cod_iraz)
   else f_izm_tvr2(cod_iraz)
   cod_iraz=0
   
}


