//---------KNOB
var finde_text_start='';

$(document).ready(function(){
    $("[knob]").live('mouseover', function()
    {
        $(this).css("backgroundPosition","center");
    });
});

$(document).ready(function(){
    $("[knob]").live('mouseout', function()
    {
        $(this).css("backgroundPosition","top");
    });
});

$(document).ready(function(){
    $("[knob]").live('mousedown',function()
    {
       $(this).css("backgroundPosition","bottom");
    });
});

$(document).ready(function(){
    $("[knob]").live('mouseup',function()
    {
       $(this).css("backgroundPosition","center");
    });
});

//---------KNOB2
$(document).ready(function(){
    $("[alink]").live('mouseover', function()
    {
     if($(this).css("cursor")=="pointer")
     {
       $(this).css("textDecoration","none");
     }
    });
});

$(document).ready(function(){
    $("[alink]").live('mouseout', function()
    {
      if($(this).css("cursor")=="pointer")
     {
        $(this).css("textDecoration","underline");
     }
    });
});

$(document).ready(function(){
    $("[blink]").mouseover(function()
    {
     if($(this).css("cursor")=="pointer")
     {
       $(this).css("textDecoration","underline");
     }
    });
});

$(document).ready(function(){
    $("[blink]").mouseout(function()
    {
      if($(this).css("cursor")=="pointer")
     {
        $(this).css("textDecoration","none");
     }
    });
});

//---------KNOB3
$(document).ready(function()
{
    $("[slink]").mouseover(function()
    {
     if($(this).css("cursor")=="pointer")
     {
       $(this).css("borderWidth","0px");
     }
    });
});


$(document).ready(function(){
    $("#input_on_page").blur(function()
    {
       $(this).stopTime();
       $(this).oneTime(1000,function()
       {
         $('#onpageok').css('display','none');
       });
    });

    $("#input_on_page2").blur(function()
    {
       $(this).stopTime();
       $(this).oneTime(1000,function()
       {
         $('#onpageok2').css('display','none');
       });
    });
});

$(document).ready(function(){
    $("#input_on_page").focus(function()
    {
       $(this).stopTime();
       $('#onpageok').css('display','block');
    });

    $("#input_on_page2").focus(function()
    {
       $(this).stopTime();
       $('#onpageok2').css('display','block');
    });
});

$(document).ready(function(){
    $("#enterhere").focus(function()
    {

      if(!$.browser.opera)
      {
        if($(this).attr("value")=="что ищем?")
        {
           $(this).animate({"textIndent":"-100"},"slow",0,function()
           {
                $(this).attr("value","");
                $(this).css("textIndent","0");
           });
        }
      }
      else
      {
        if($(this).attr("value")=="что ищем?")
        {
         $(this).animate({"left":"-100"},"slow",0,function()
           {
                $(this).attr("value","");
                $(this).css("left","0");
           });
         }
      }
    });
});

$(document).ready(function()
{
   $("#enterhere").focus();
});


$(document).ready(function(){
    $("#enterhere").blur(function()
    {
      if(!$.browser.opera && !$.browser.msie)
      {
        if($(this).attr("value")=="")
        {
           $(this).css("textIndent","-100");
           $(this).attr("value","что ищем?");
           $(this).animate({"textIndent":"100"},"100");
           $(this).animate({"textIndent":"0"},"100");
           $(this).animate({"textIndent":"20"},"100");

           if($.browser.msie)
                $(this).animate({"textIndent":"10"},"slow");
           else
                $(this).animate({"textIndent":"0"},"slow");
        }
      }
      else
      {
        if($(this).attr("value")=="")
        {
           $(this).css("left","-100");
           $(this).attr("value","что ищем?");
           $(this).animate({"left":"100"},"100");
           $(this).animate({"left":"0"},"100");
           $(this).animate({"left":"20"},"100");
           $(this).animate({"left":"0"},"slow");
        }
      }
    });
});

$(document).ready(function(){
    $("#enter_form").submit(function()
    {
       if($("form#enter_form #login_enter").attr("value")=="" || $("form#enter_form #password_enter").attr("value")=="")
        return false;
    });

});

$(document).ready(function(){
    $("#recover_form").submit(function()
    {
       if($("form#recover_form #recover_email").attr("value")=="")
        return false;
    });
});


$(document).ready(function(){
    $("#asho").click(function()
    {
        blok=$("#ashobl");
        if(blok.css('display')=='none')
        {
            blok.slideDown('slow',function(){blok.css("display","block");});
            blok.click(function()
            {
                $("#asho").click();
            });
        }
        else
        {
            if($.browser.msie)
            {
              blok.animate({"height":"0","opacity":"0"},"slow",0,function()
              {
                blok.css("display","none");
                blok.css("opacity","1");
              });
            }
            else
              blok.slideUp("slow",function()
              {
                blok.css("display","none");
              });
        }
    });
});

$(document).ready(function(){
    $("#mysearch").mouseover(function()
    {
       if($("#mysearchblock").css('display')=='none')
        $(this).css("backgroundPosition","center");
    });
});

$(document).ready(function(){
    $("#mysearch").mouseout(function()
    {
       if($("#mysearchblock").css('display')=='none')
        $(this).css("backgroundPosition","top");
    });
});

$(document).ready(function(){
    $("#mysearch").click(function()
    {
        blok=$("#mysearchblock");
        if(blok.css('display')=='none')
        {
            $(this).css("backgroundPosition","bottom");
            blok.slideDown('slow',function(){blok.css("display","block");});
        }
        else
        {
            if($.browser.msie)
            {
              blok.animate({"height":"0","opacity":"0"},"slow",0,function()
              {
                blok.css("display","none");
                blok.css("opacity","1");
              });
            }
            else
              blok.slideUp("slow",function()
              {
                blok.css("display","none");
              });
        }
    });
});

$(document).ready(function(){
    $("#tipa_enter").click(function()
    {
       $("#enter").click();
       $("#mysearch").click();
    });
});

$(document).ready(function(){
    $("#tipa_enter2").live('click',function()
    {
       $("#enter").click();
       $("#login_enter").focus();
    });
});

$(document).ready(function(){
    $("#enter").click(function()
    {
        blok=$("#enterblock");
        blok.animate({"top":"0"},'slow');
    });
});

$(document).ready(function(){
    $("#close").click(function()
    {
        blok=$("#enterblock");
        blok.animate({"top":"-100"},'slow');
    });
});

$(document).ready(function(){
    $("#close1").click(function()
    {
        blok=$("#enterblock");
        $("#enter_show").animate({"left":"0"},'slow');
        $("#recover_show").animate({"left":"227"},'slow',0,function()
        {
            blok.animate({"top":"-100"},'slow');
        });
    });
});

$(document).ready(function(){
    $("#lostpass").click(function()
    {
        $("#enter_show").animate({"left":"-227"},'slow');
        $("#recover_show").animate({"left":"0"},'slow');
    });
});

$(document).ready(function(){
    $("#entersystem").click(function()
    {
        $("#enter_show").animate({"left":"0"},'slow');
        $("#recover_show").animate({"left":"227"},'slow');
    });
});

$(document).ready(function(){
    $("#fsel1").click(function()
    {

        blok=$("#sellist1");

        if(blok.css("display")=="none")
        {

           if($.browser.msie)
           {
             blok.css("height","300");
             blok.css("display","block");

             $('#selcitytip').css("display","block");
           }
           else
           {
             $('#selcitytip').css("opacity","0");
             $('#selcitytip').css("display","block");

             $('#selcitytip').animate({"opacity":"1"},'slow');

             blok.slideDown('slow');
           }

        }
        else
        {
            if($("#fsel2").html()!='Во всех магазинах')
            {
                $("form#main_finde #finde_shop_name").attr("value","Во всех магазинах");
                $("form#main_finde #finde_shop_id").attr("value",0);
                $("#fsel2").html('Во всех магазинах');

                $("#fsel2").animate({"opacity":"0"},"slow");
                $("#fsel2").animate({"opacity":"1"},"slow");
                $("#fsel2").animate({"opacity":"0"},"slow");
                $("#fsel2").animate({"opacity":"1"},"slow");
            }

            if($("#checkbox_mmf").attr('checked'))
            {
               $("#checkbox_mmf").attr('checked',false);
               $("#checkbox_mmf").click();
            }

            if($.browser.msie)
            {
              $('#selcitytip').css("display","none");
            }
            else
            {
              $('#selcitytip').animate({"opacity":"0"},'slow',0,
                  function()
                  {
                      $('#selcitytip').css("display","none");
                  }
              );
            }

            form_name=$("form#main_finde #finde_city_name").attr("value");
            $(this).html(form_name);

            if($.browser.msie)
            {
              blok.animate({"height":"0","opacity":"0"},"slow",0,function()
              {
                blok.css("display","none");
                blok.css("opacity","1");
              });
            }
            else
              blok.slideUp("slow",function()
              {
                blok.css("display","none");
              });
        }
    });
});

$(document).ready(function(){
    $(".sellist1a").click(function()
    {
        $("form#main_finde #finde_city_name").attr("value",$(this).html());
        $("form#main_finde #finde_city_id").attr("value",$(this).attr("parcity_id"));
        $("#fsel1").click();
    });
});

$(document).ready(function(){
    $("#fsel2").click(function(evt)
    {
      if($('#selshoptip2').css("display")=="block")
         $('#selshoptip2').css("display","none");

      if($('#selshoptip').css("display")=="none")
        $('#selshoptip').css("display","block");
      else
        $('#selshoptip').css("display","none");

      var elem = $(evt.target);

      if($("#example2").length==0 )
      {
         form_name=$("form#main_finde #finde_shop_name").attr("value");
         input_element=$("<input class='fselin' id='example2' value='"+form_name+"' />");
         $(this).html("");
         input_element.appendTo($(this));

         $("#example2").autocomplete("/ajax/shop_avtocomplit",
         {
              delay:10,
              minChars:2,
              matchSubset:1,
              autoFill:false,
              matchContains:1,
              cacheLength:10,
              selectFirst:true,
              maxItemsToShow:10,
              width:212,
              onItemSelect:selectItem,
              plusleft:30
         });

         $("#example2").attr("value","");
         $("#example2").focus();
      }
      else
      {
          if(elem.attr("id")=="fsel2")
          {
            form_name=$("form#main_finde #finde_shop_name").attr("value");
            $(this).html(form_name);
          }
      }
    });
});


function selectItem(li)
{
    $('#selshoptip').css("display","none");

    if($("#checkbox_mmf").attr('checked'))
    {
        $("#checkbox_mmf").attr('checked',false);
        $("#checkbox_mmf").click();
    }

    if(li == null )
    {
        $("form#main_finde #finde_shop_name").attr("value","Во всех магазинах");
        $("form#main_finde #finde_shop_id").attr("value",0);

        if($("#example2").length==1)
        {
           $("#fsel2").oneTime("0.2s","fsel2hide",function()
           {
            $("#fsel2").html("Во всех магазинах");
           });
        }
        return;
    }

    if(!!li.extra )
        var sValue = li.extra[0];
	else
        var sValue = li.selectValue;

    $("form#main_finde #finde_shop_name").attr("value",li.selectValue);
    $("form#main_finde #finde_shop_id").attr("value",sValue);

    $("#fsel2").html(li.selectValue);

    if($("#fsel1").html()!='По всей Украине')
    {
        $("form#main_finde #finde_city_name").attr("value",'По всей Украине');
        $("form#main_finde #finde_city_id").attr("value",0);

        $("#fsel1").animate({"opacity":"0"},"slow");
        $("#fsel1").animate({"opacity":"1"},"slow");
        $("#fsel1").animate({"opacity":"0"},"slow");
        $("#fsel1").animate({"opacity":"1"},"slow");

        form_name=$("form#main_finde #finde_city_name").attr("value");
        $("#fsel1").html(form_name);
    }
}

$(document).ready(function()
{
    $("#enterhere").autocomplete("/ajax/tovar_avtocomplit",
    {
        delay:10,
        minChars:2,
        matchSubset:1,
        autoFill:false,
        matchContains:1,
        cacheLength:10,
        selectFirst:false,
        maxItemsToShow:10,
        inputClass:'f_input',
        resultsClass:'f_results',
        loadingClass:'f_loading',
        width_minus: 102,
        overClass:'f_over'
    });
});

$(document).ready(function(){
    $("#checkbox_mmf").click(function()
    {
      if($(this).attr("checked")==true)
      {
         if($("#fsel1").html()!='По всей Украине')
         {
            $("form#main_finde #finde_city_name").attr("value",'По всей Украине');
            $("form#main_finde #finde_city_id").attr("value",0);
            $("#fsel1").html('По всей Украине');

            $("#fsel1").animate({"opacity":"0"},"slow");
            $("#fsel1").animate({"opacity":"1"},"slow");
            $("#fsel1").animate({"opacity":"0"},"slow");
            $("#fsel1").animate({"opacity":"1"},"slow");
         }

         $("form#main_finde #finde_shop_name").attr("value","Во всех магазинах");
         $("form#main_finde #finde_shop_id").attr("value",0);
         $("#fsel2").html('В Моих Магазинах');

         $("#fsel2").animate({"opacity":"0"},"slow");
         $("#fsel2").animate({"opacity":"1"},"slow");
         $("#fsel2").animate({"opacity":"0"},"slow");
         $("#fsel2").animate({"opacity":"1"},"slow");

      }
      else
      {
         if($("#fsel2").html()=='В Моих Магазинах')
         {
            $("form#main_finde #finde_shop_name").attr("value","Во всех магазинах");
            $("form#main_finde #finde_shop_id").attr("value",0);
            $("#fsel2").html('Во всех магазинах');
         }
      }

    });
});

$(document).ready(function()
{
  finde_text_start=$("#enterhere").attr("value");
});


$(document).ready(function(){
    $("#main_finde").submit(function()
    {
      var reg=/^.+\:\@\:.+$/i;

      result=reg.test($("#enterhere").attr("value"));

      if(result==true && ($("form#main_finde #finde_shop_id").attr("value")==0 || $("form#main_finde #finde_city_id").attr("value")!=0))
        $("#enterhere").attr("value",'');

      finde_text=$("#enterhere").attr("value");

      if(finde_text.length<3 || finde_text.toLowerCase()=='что ищем?')
      {
        $("#enterhere").attr("value",'');
        $("#enterhere").focus();
        return false;
      }

      var reg=/^.+\:\@\:.+$/i;

      result=reg.test(finde_text_start);

      if(result==true && finde_text_start!=finde_text && $("form#main_finde #finde_shop_id").attr("value")!=0)
      {
        win=$("<div id='z_explorer2'  class='enter1'><span>Внимание!</span><p>Предыдущий поиск осуществлялся по магазину &laquo;"+$("form#main_finde #finde_shop_name").attr("value")+"&raquo;. Вы можете продолжить поиск товара только в этом магазине, или во всех доступных магазинах.<br><br><b>Укажите, пожалуйста, где Вы хотите искать</b>:</p><input id='search_yes' type='button' value='Во всех магазинах'><input id='search_no' type='button' value='Только в магазине &laquo;"+$("form#main_finde #finde_shop_name").attr("value")+"&raquo;'></div>");
        err=$("<div id='overlay' ></div>");

        win.appendTo("body");
        err.appendTo("body");

        if(!$.browser.msie)
            $("#overlay").css("opacity",0);

        if($.browser.opera)
        {
            if($.browser.version>=9.5)
                $("#overlay").animate({opacity:"1"},100);
        }

        if($.browser.mozilla || $.browser.safari)
            $("#overlay").animate({opacity:"1"},70);

        if($.browser.msie)
        {
          $("select").css("visibility","hidden");
          scrll=$("body").scrollTop();
          center=($(window).height()/2)+scrll;
          $("#z_explorer2").css("top",center-100);
        }

        $("#search_yes").live('click',function()
        {
            $('#z_explorer2').remove();
            $("#overlay").remove();

            if($.browser.msie)
                $("select").css("visibility","visible");

            $("form#main_finde #finde_shop_name").attr("value","Во всех магазинах");
            $("form#main_finde #finde_shop_id").attr("value",0);

            finde_text_start='';
            $("#main_finde").submit();
        });

        $("#search_no").live('click',function()
        {
            $('#z_explorer2').remove();
            $("#overlay").remove();

            if($.browser.msie)
                $("select").css("visibility","visible");

            finde_text_start='';
            $("#main_finde").submit();
        });

        $("#z_explorer2").animate({height:"190"},500);

        return false;
      }

    });
});


$(document).ready(function(){
    $("div.navigator a").mouseover(function()
    {
      if($(this).attr("outtext") && $("#arrtext").html()=="навигатор")
        $("div.navigator #arrtext").html($(this).attr("outtext"));
        $(this).css("backgroundPosition","bottom");
    });
});

$(document).ready(function(){
    $("div.navigator a").mouseout(function()
    {
      if($("#arrtext").html()!="навигатор")
        $("div.navigator #arrtext").html("навигатор");
        $(this).css("backgroundPosition","top");
    });
});

$(document).ready(function(){
    $("div[id^=help2parent]").mouseover(function(e)
    {
        var window=$("#window_titles");

        if(window.length==0)
        {
            $("<div id='window_titles' class='helpwindow2'>"+$(this).attr("window")+"</div>").insertAfter("#wrapper");

            div_blok=$("#window_titles");
            div_blok.css("left",e.pageX+20);
            div_blok.css("top",e.pageY);
        }

    });
});

$(document).ready(function(){
    $("div[id^=help2parent]").mouseout(function()
    {
       var window=$("#window_titles");

       if(window.length>0)
        window.remove();
    });
});

$(document).ready(function(){
    $("#input_on_page").keyup(function(event)
    {
        if(event.keyCode==13 && parseInt($(this).attr("value"))>0)
        {
            url=location.href.replace(/\/limit\/[0-9]{1,2}/,"");
            url=url.replace(/\/scroll\/[0-9]/,"");
            location.href=url+"/limit/"+$(this).attr("value");

        }
    });

    $("#onpageok").click(function()
    {
      if(parseInt($('#input_on_page').attr("value"))>0)
      {
        url=location.href.replace(/\/limit\/[0-9]{1,2}/,"");
        url=url.replace(/\/scroll\/[0-9]/,"");
        location.href=url+"/limit/"+$('#input_on_page').attr("value");
      }
    });

    $("#input_on_page2").keyup(function(event)
    {
        if(event.keyCode==13 && parseInt($(this).attr("value"))>0)
        {
            url=location.href.replace(/\/limit\/[0-9]{1,2}/,"");
            url=url.replace(/\/scroll\/[0-9]/,"");
            location.href=url+"/limit/"+$(this).attr("value");

        }
    });

    $("#onpageok2").click(function()
    {
      if(parseInt($('#input_on_page2').attr("value"))>0)
      {
        url=location.href.replace(/\/limit\/[0-9]{1,2}/,"");
        url=url.replace(/\/scroll\/[0-9]/,"");
        location.href=url+"/limit/"+$('#input_on_page2').attr("value");
      }
    });
});

$(document).ready(function(){
    $("#input_on_page2").keyup(function(event)
    {
        if(event.keyCode==13)
        {
            url=location.href.replace(/\/limit\/[0-9]{1,2}/,"");
            url=url.replace(/\/scroll\/[0-9]/,"");
            location.href=url+"/limit/"+$(this).attr("value");
        }
    });
});

$(document).ready(function(){
    $("#delivery_option").click(function()
    {
        blok=$('#delivery_option_window');

        if(blok.css("display")=='none')
        {
            blok.slideDown('fast',function(){blok.css("display","block");});
        }
        else
        {
            if($.browser.msie)
            {
              blok.animate({"height":"0","opacity":"0"},"fast",0,function()
              {
                blok.css("display","none");
                blok.css("opacity","1");
              });
            }
            else
              blok.slideUp("fast",function()
              {
                blok.css("display","none");
              });
        }
    });
});

$(document).ready(function(){
    $("#kat_option").click(function()
    {
        blok=$('#kat_option_window');

        if(blok.css("display")=='none')
        {
            blok.slideDown('fast',function(){blok.css("display","block");});
        }
        else
        {
            if($.browser.msie)
            {
              blok.animate({"height":"0","opacity":"0"},"fast",0,function()
              {
                blok.css("display","none");
                blok.css("opacity","1");
              });
            }
            else
              blok.slideUp("fast",function()
              {
                blok.css("display","none");
              });
        }
    });
});

$(document).ready(function(){
    $("#delivery_option").hover(
      function()
      {
        $(this).addClass("filtrselhover");
      },
      function()
      {
         $(this).removeClass("filtrselhover");
      }
    );
});

$(document).ready(function(){
    $("#kat_option").hover(
      function()
      {
        $(this).addClass("filtrselhover");
      },
      function()
      {
         $(this).removeClass("filtrselhover");
      }
    );
});

$(document).ready(function(){
    $("div[id^=fsel]").hover(
      function()
      {
        $(this).removeClass("fs");
        $(this).addClass("fsover");
      },
      function()
      {
        $(this).removeClass("fsover");
        $(this).addClass("fs");
      }
    );
});

$(document).ready(function(){
    $(".rightlink").click(function()
    {
        blok=$(this).prev(".tovcontediv");

        if(blok.attr("status_open")=='close')
        {
          blok.css("display","none");
          blok.css("height","auto");
          blok.slideUp("1",function()
          {
            blok.slideDown("slow",function(){blok.attr("status_open","open");});
          });
        }
        else
        {
          if(!$.browser.msie)
          {
            blok.slideUp("slow",function()
            {
              blok.css("height","0");
              blok.animate({"height":"116"},'slow',0,function(){blok.attr("status_open","close");});
            });
          }
          else
          {
            blok.animate({"height":"10"},"slow",0,function()
            {
              blok.animate({"height":"116"},'slow',0,function(){blok.attr("status_open","close");});
            });
          }
        }
    });
});

$(window).load(function(){
    $("#mainpane span").mouseover(function()
    {
       register=$(this).children("div .regbar");

       if(register.length>0 && register.css("display")=='none')
       {
        register.css("display","block");

        if($("#tip"+$(this).attr("id")).css('display')=='none')
            $("#tip"+$(this).attr("id")).css('display','block');
       }
    });
});

$(window).load(function(){
    $("#mainpane span").mouseleave(function()
    {
       register=$(this).children("div .regbar");

       if(register.length>0 && register.css("display")=='block')
       {
        register.css("display","none");
        if($("#tip"+$(this).attr("id")).css('display')=='block')
            $("#tip"+$(this).attr("id")).css('display','none');

       }
    });
});

$(window).load(function(){
    $("#mainpane span").click(function()
    {
       register=$(this).children("div .regbar");

       if(register.length>0)
       {
         location.href="/registration";
       }
    });
});

$(document).ready(function(){
    $("#mainpane span").hover(
      function()
      {
        $(this).addClass($(this).attr("id")+"_hover");
      },
      function()
      {
        $(this).removeClass($(this).attr("id")+"_hover");
      }
    );
});

$(document).ready(function(){
    $("span[id^=add_click]").mouseenter(function()
    {
       register=$(this).children("div");

       if(register.length>0 && register.css('display')=='none')
        register.css("display","block");
    });
});

$(document).ready(function(){
    $("span[id^=add_click]").mouseleave(function()
    {
       register=$(this).children("div");

       if(register.length>0 && register.css('display')=='block')
        register.css("display","none");
    });
});


$(document).ready(function(){
    $("input[id^=radio_rate]").live('click', function()
    {
        $("#btn_"+$(this).attr("offer_num")).css("display","block");
    });
});

var last_click=0;

$(window).load(function(){
    $("#mainpane span").click(function()
    {
       register=$(this).children("div .regbar");


       if(register.length==0 && $("#window_modal_container").length==0)
       {
            if($.browser.msie)
            {
                $('body').css("overflow-x","hidden");
                $('body').css("overflow-y","hidden");
            }
            else
                $('body').css("overflow","hidden");

            win=$("<div  id='window_modal_container' class='windowcontainer'><div id='modal_window' class='windowme'><div class='windowloader'>загрузка...</div></div>");

            $('body').prepend(win);
            var id_window=$(this).attr("id");

              $.ajax(
              {
                url: '/ajax/'+$(this).attr("id"),
                async: false,
                cache: false,
                dataType: "html",
                type: 'POST',
                success: function (data)
                {
                   $("#modal_window").html(data);

                   if(!$.browser.msie)
                   {
                    $("#modal_window").css("opacity","0");
                    $("#modal_window").css("width","0");
                    $("#modal_window").css("height","0");

                    $("#modal_window").animate({"opacity":"1","width":"718","height":"400"},"slow","swing");
                   }
                   else
                   {
                     $("select:not(#pf_city,#pf_day_life,#pf_month_life,#pf_year_life)").css("visibility","hidden");
                   }

                   if(data=="&nbsp;")
                      location.reload(true);

                   if(id_window=="private_user" && $("#pf_city").length>0)
                   {
                    if($("#pf_city").attr("value")==0)
                        $("#div_pf_other_city").css("display","block");
                    else
                        $("#div_pf_other_city").css("display","none");
                   }

                   $("div #note_content div[id^=help3parent]").live('mouseover',function(evt)
                   {
                        div_blok=$("#window_title");

                        if(div_blok.length==0)
                        {
                          $("<div id='window_title' class='helpwindow3'>"+$(this).attr("window")+"</div>").insertAfter("#wrapper");

                          div_blok=$("#window_title");
                          div_blok.css("left",evt.clientX+20);
                          div_blok.css("top",evt.clientY);
                        }
                   });

                   $("div #note_content div[id^=help3parent]").live('mousemove',function(evt)
                   {
                        div_blok=$("#window_title");

                        if(div_blok.length>0)
                        {
                          div_blok.css("left",evt.clientX+20);
                          div_blok.css("top",evt.clientY);
                        }
                   });

                   $("div #note_content div[id^=help3parent]").live('mouseout',function()
                   {
                        div_blok=$("#window_title");

                        if(div_blok.length>0)
                        {
                          div_blok.remove();
                        }
                   });

                   $("#modal_window").bind('click',function(evt)
                   {
                      var obj = $(evt.target);

                      if(obj.attr("ajax_action")!="" && obj.attr("ajax_action")+obj.attr("ajax_param")!=last_click)
                      {
                         last_click=obj.attr("ajax_action")+obj.attr("ajax_param");
                         switch (obj.attr("ajax_action"))
                         {
                            case "location":
                            {
                               if(!$.browser.msie)
                               {
                                 $("#modal_window").animate({"opacity":"0","width":"0","height":"0"},"slow","swing",function()
                                 {
                                      last_click=0;
                                      $("#window_modal_container").remove();
                                      window.location.href=obj.attr("ajax_param");
                                 });
                               }
                               else
                               {
                                  last_click=0;
                                  $("#window_modal_container").remove();
                                  window.location.href=obj.attr("ajax_param");
                               }

                               break;
                            }
                            case "finde":
                            {
                               last_click=0;

                               if(!$.browser.msie)
                               {
                                 $("#modal_window").animate({"opacity":"0","width":"0","height":"0"},"slow","swing",function()
                                 {

                                      $("#window_modal_container").remove();

                                      if($("#fsel2").html()!=obj.attr("ajax_param"))
                                      {
                                        $("#fsel2").html(obj.attr("ajax_param"));
                                        $("#finde_shop_name").attr("value",obj.attr("ajax_param"));
                                        $("#finde_shop_id").attr("value",obj.attr("ajax_param2"));

                                        $("#fsel2").animate({"opacity":"0"},"slow");
                                        $("#fsel2").animate({"opacity":"1"},"slow");
                                        $("#fsel2").animate({"opacity":"0"},"slow");
                                        $("#fsel2").animate({"opacity":"1"},"slow");
                                      }

                                      $('body').scrollTop("0");

                                      $('#selshoptip2').css("display","block");

                                      if($("#fsel1").html()!='По всей Украине')
                                      {
                                          $("form#main_finde #finde_city_name").attr("value",'По всей Украине');
                                          $("form#main_finde #finde_city_id").attr("value",0);

                                          form_name=$("form#main_finde #finde_city_name").attr("value");
                                          $("#fsel1").html(form_name);

                                          $("#fsel1").animate({"opacity":"0"},"slow");
                                          $("#fsel1").animate({"opacity":"1"},"slow");
                                          $("#fsel1").animate({"opacity":"0"},"slow");
                                          $("#fsel1").animate({"opacity":"1"},"slow");
                                      }

                                       if($("#checkbox_mmf").attr('checked'))
                                       {
                                             $("#checkbox_mmf").attr('checked',false);
                                             $("#checkbox_mmf").click();
                                       }

                                      $('body').css("overflow","scroll");
                                 });
                               }
                               else
                               {
                                  $("#window_modal_container").remove();

                                  if($("#fsel2").html()!=obj.attr("ajax_param"))
                                  {
                                    $("#fsel2").html(obj.attr("ajax_param"));
                                    $("#finde_shop_name").attr("value",obj.attr("ajax_param"));
                                    $("#finde_shop_id").attr("value",obj.attr("ajax_param2"));

                                    $("#fsel2").animate({"opacity":"0"},"slow");
                                    $("#fsel2").animate({"opacity":"1"},"slow");
                                    $("#fsel2").animate({"opacity":"0"},"slow");
                                    $("#fsel2").animate({"opacity":"1"},"slow");
                                  }

                                  $('body').scrollTop("0");

                                  $('#selshoptip2').css("display","block");

                                  if($("#fsel1").html()!='По всей Украине')
                                  {
                                    $("form#main_finde #finde_city_name").attr("value",'По всей Украине');
                                    $("form#main_finde #finde_city_id").attr("value",0);

                                    form_name=$("form#main_finde #finde_city_name").attr("value");
                                    $("#fsel1").html(form_name);

                                    $("#fsel1").animate({"opacity":"0"},"slow");
                                    $("#fsel1").animate({"opacity":"1"},"slow");
                                    $("#fsel1").animate({"opacity":"0"},"slow");
                                    $("#fsel1").animate({"opacity":"1"},"slow");
                                  }

                                  if($("#checkbox_mmf").attr('checked'))
                                  {
                                    $("#checkbox_mmf").attr('checked',false);
                                    $("#checkbox_mmf").click();
                                  }

                                  $('body').css("overflow-y","scroll");
                               }
                               break;
                            }

                            case "delete":
                            {
                              $.ajax(
                              {
                                url: '/ajax/'+id_window+"_delete",
                                async: true,
                                cache: false,
                                dataType: "json",
                                type: 'POST',
                                data: {"note":obj.attr("ajax_param")},
                                beforeSend: function()
                                {
                                    $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                },
                                success: function(data)
                                {
                                    if(data['content']=="&nbsp;")
                                        location.reload(true);
                                    else
                                    {

                                       $("#note_content").html(data['content']);
                                       $("#note_scroll").html(data['scroll']);
                                       note_c=$("#note_count").html();
                                       $("#note_count").html(parseInt(note_c)-1);

                                       if($("#no_item_note").css('display')=='block' && id_window=="shops")
                                         $("#mmf").css("display",'none');

                                    }
                                }
                              });
                              break;
                            }

                            case "delete_all":
                            {
                              $.ajax(
                              {
                                url: '/ajax/'+id_window+"_delete_all",
                                async: true,
                                cache: false,
                                dataType: "html",
                                type: 'POST'
                              });

                              note_not_content=$("#no_item_note");

                              $("#note_content").html("");
                              $("#note_scroll").html("");

                              note_not_content.appendTo("#note_content");

                              $("#no_item_note").css("display","block");

                              break;
                            }

                            case "sort":
                            {
                              $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                              $.ajax(
                              {
                                    url: '/ajax/'+id_window+"_sort",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"note":obj.attr("ajax_param")},
                                    beforeSend: function()
                                    {
                                        $("#note_content").css("opacity","1");
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {

                                        $("#note_content").html(data['content']);
                                        $("#note_scroll").html(data['scroll']);

                                        if(id_window!="offers")
                                        {
                                            old_active=$(".filtritem-active");
                                            old_active.removeClass();
                                            old_active.addClass("filtritem");
                                            obj.addClass("filtritem-active");
                                        }
                                        else
                                        {
                                            old_active=$(".filtritemall-active");
                                            old_active.removeClass();
                                            old_active.addClass("filtritemall");
                                            obj.addClass("filtritemall-active");
                                        }

                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "offer_cancel":
                            {

                            $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                            $.ajax(
                            {
                                    url: '/ajax/'+id_window+"_cancel",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"note":obj.attr("ajax_param")},
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {
                                        $("#note_content").html(data['content']);
                                        $("#note_scroll").html(data['scroll']);
                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "offer_rate":
                            {

                                var offer_rate=0
                                for(i=1;i<=4;i++)
                                {
                                    if($("#radio_rate"+i+"_"+obj.attr("ajax_param")).attr("checked"))
                                        offer_rate=i;
                                }

                                var old_html=$("#note_content").html();

                                $.ajax(
                                {
                                    url: '/ajax/'+id_window+"_rate",
                                    async: false,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"note":obj.attr("ajax_param"),"rate":offer_rate},
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    error: function(data)
                                    {
                                      location.reload(true);
                                    },
                                    success: function(data)
                                    {

                                      if(data['re']!=false)
                                      {
                                          $("#note_content").html(old_html);
                                          show_mess=$("#offer_rate_send").html();
                                          $("#offer_"+obj.attr("ajax_param")).html(show_mess);
                                          $("btn_"+obj.attr("ajax_param")).css('display','none');
                                      }
                                      else
                                        location.reload(true);
                                    }
                                  });

                              break;
                            }

                            case "open":
                            {

                              $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                              $.ajax(
                              {
                                    url: '/ajax/'+id_window+"_open",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"item":obj.attr("ajax_param")},
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {
                                        $("#hide_output").css("display","none");
                                        $("div.windowc").attr("id","message_output");
                                        $("#note_content").html(data['content']);
                                        $("#note_scroll").html(data['scroll']);

                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "send_form":
                            {

                              $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                              $.ajax(
                              {
                                    url: '/ajax/'+id_window+"_send_form",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"item":obj.attr("ajax_param")},
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {

                                      if(data['content']!="&nbsp;")
                                      {
                                        $("#hide_output").css("display","none");
                                        $("div.windowc").attr("id","message_output");

                                        $("#note_content").html(data['content']);
                                        $("#note_scroll").html(data['scroll']);

                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "send":
                            {
                               var subject=$("#subject").attr("value");
                               var message=$("#message").attr("value");

                               var reg=/^.{3,50}$/;
                               result=reg.test(subject);

                               if(result==false)
                               {
                                 $("#error_div").html("<b>Отправка невозможна. Минимальная длина темы &mdash; 3, максимальная - 50 символов.</b>");
                                 return;
                               }

                              if(message.length<10 || message.length>2000)
                                result=false;
                              else
                                result=true;

                               if(result==false)
                               {
                                 $("#error_div").html("<b>Отправка невозможна. Минимальная длина сообщения &mdash; 10, максимальная - 2000 символов.</b>");
                                 return;
                               }

                                send={"subject":subject,
                                      "message":message
                                     };


                               $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                               $.ajax(
                               {
                                    url: '/ajax/'+id_window+"_send",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: send,
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    error: function()
                                    {
                                      $("#note_content").html("<div class='message_fool_div'>Извините, Вы исчерпали лимит сообщений на сегодня.<br><br>Если Вам необходимо срочно связаться с нами, перейдите на страницу <a href='/page/contacts'>Контактная информация</a>, и сделайте это любым удобным для Вас способом.<div class='backmess' ajax_action='back' >&laquo; <u ajax_action='back'>Вернуться к списку сообщений</u></div></div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {
                                        if(data['re']==true)
                                            $("#bm2").click();
                                        else
                                            $("#note_content").html("<div class='message_fool_div'>Извините, Вы исчерпали лимит сообщений на сегодня.<br><br>Если Вам необходимо срочно связаться с нами, перейдите на страницу <a href='/page/contacts'>Контактная информация</a>, и сделайте это любым удобным для Вас способом.<div class='backmess' ajax_action='back' >&laquo; <u ajax_action='back'>Вернуться к списку сообщений</u></div></div>");
                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "send_tip":
                            {
                               var tip=$("#tip").attr("value");

                               if($("#radio_tip1").attr("checked"))
                                tip_type=0;
                               else
                                tip_type=1;

                               if(tip.length<10 || tip.length>2000)
                                result=false;
                               else
                                result=true;

                               if(result==false)
                               {
                                 $("#error_div").html("Отправка невозможна. Минимальная длина отзыва - 10 символов, максимальная - 2000.");
                                 return;
                               }


                               $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                               $.ajax(
                               {
                                    url: '/ajax/'+id_window+"_send",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"tip":tip,"tip_type":tip_type,"shop":obj.attr("ajax_param")},
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {
                                        if(data['re']==true)
                                            $("#note_content").html("<div class='message_fool_div'>Ваш отзыв отправлен и поставлен в очередь на модерацию.<div class='backmess' ajax_action='back' >&laquo; <u ajax_action='back'>Вернуться к списку заказов</u></div></div>");
                                        else
                                            $("#note_content").html("<div class='message_fool_div'>Извините, Вы исчерпали лимит отзывов на сегодня.<div class='backmess' ajax_action='back' >&laquo; <u ajax_action='back'>Вернуться к списку заказов</u></div></div>");
                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "back":
                            {
                              $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                              $.ajax(
                              {
                                    url: '/ajax/'+id_window+"_back",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {

                                        if($("#bm1").attr("class")=='bmactive' && ($("#bm1").attr("ajax_param")=='proces' || $("#bm1").attr("ajax_param")=='input'))
                                        {
                                         if($("#hide_output").length>0)
                                         {
                                           $("#hide_output").css("display","block");
                                           $("div.windowc").attr("id","message_input");
                                         }
                                        }
                                        else
                                        {
                                            if($("#hide_output").length>0)
                                            {
                                                $("#hide_output").css("display","none");
                                                $("div.windowc").attr("id","message_output");
                                            }
                                        }

                                        $("#note_content").html(data['content']);
                                        $("#note_scroll").html(data['scroll']);

                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "type":
                            {
                              $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                              $.ajax(
                              {
                                  url: '/ajax/'+id_window+"_type",
                                  async: true,
                                  cache: false,
                                  dataType: "json",
                                  type: 'POST',
                                  data: {"note":obj.attr("ajax_param")},
                                  beforeSend: function()
                                  {
                                    $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                  },
                                  success: function(data)
                                  {
                                    if(data['content']!="&nbsp;")
                                    {
                                      if(obj.attr("ajax_param")=='input' || obj.attr("ajax_param")=='proces')
                                      {
                                         if($("#hide_output").length>0)
                                         {
                                           $("#hide_output").css("display","block");
                                           $("div.windowc").attr("id","message_input");
                                         }
                                      }
                                      else
                                      {
                                        if($("#hide_output").length>0)
                                        {
                                           $("#hide_output").css("display","none");
                                           $("div.windowc").attr("id","message_output");
                                        }
                                      }

                                      $("#note_content").html(data['content']);
                                      $("#note_scroll").html(data['scroll']);
                                      old_active=$(".bmactive");
                                      old_active.removeClass();

                                      obj.addClass("bmactive");

                                      if($("#pf_city").length>0)
                                      {
                                        if($("#pf_city").attr("value")==0)
                                            $("#div_pf_other_city").css("display","block");
                                        else
                                            $("#div_pf_other_city").css("display","none");
                                      }

                                    }
                                    else
                                      location.reload(true);
                                  }
                               });
                              break;
                            }

                            case "kat_open":
                            {
                              kat=obj.next("div .catenotes");

                              if(kat.css("display")=='none')
                              {
                                kat.css("display","block");
                                obj.removeClass();
                                obj.addClass("categorynotescata");
                              }
                              else
                              {
                                obj.removeClass();
                                obj.addClass("categorynotescat");
                                kat.css("display","none");
                              }

                              last_click=0;

                              break;
                            }

                            case "shop_open":
                            {
                              kat=obj.next("div div[id^=shop_kat]");

                              if(kat.css("display")=='none')
                              {
                                 kat.css("display","block");
                                obj.removeClass();
                                obj.addClass("categoryshcata");
                              }
                              else
                              {
                                obj.removeClass();
                                obj.addClass("categoryshcat");
                                kat.css("display","none");
                              }

                              last_click=0;

                              break;
                            }

                            case "scroll":
                            {
                               $("#note_content").html("<div class='windowloader'>загрузка...</div>");

                               $.ajax(
                               {
                                    url: '/ajax/'+id_window+"_scroll",
                                    async: true,
                                    cache: false,
                                    dataType: "json",
                                    type: 'POST',
                                    data: {"note":obj.attr("ajax_param")},
                                    beforeSend: function()
                                    {
                                        $("#note_content").html("<div class='windowloader'>загрузка...</div>");
                                    },
                                    success: function(data)
                                    {
                                      if(data['content']!="&nbsp;")
                                      {
                                        $("#note_content").html(data['content']);
                                        $("#note_scroll").html(data['scroll']);
                                      }
                                      else
                                        location.reload(true);
                                    }
                              });
                              break;
                            }

                            case "close":
                            {
                               if(!$.browser.msie)
                               {
                                 $("#modal_window").animate({"opacity":"0","width":"0","height":"0"},"slow","swing",function()
                                 {
                                      $("#window_modal_container").remove();
                                      last_click=0;
                                      $('body').css("overflow","scroll");
                                 });
                               }
                               else
                               {
                                    $("select").css("visibility","visible");
                                    $("#window_modal_container").remove();
                                    $('body').css("overflow-y","scroll");
                                    last_click=0;
                               }
                               break;
                            }
                         }
                      }
                   });

                }
              });
       }
    });
});

$(document).ready(function()
{
    $("#send_tip_go").click(function()
    {
        tip=$("#b_tip").attr("value");

        if($("#b_tip1").attr("checked"))
            tip_type=0;
        else
            tip_type=1;

        if(tip.length<10 || tip.length>2000)
            result=false;
        else
            result=true;

        if(result==false)
        {
            $("#error_div").html("Отправка невозможна. Минимальная длина отзыва - 10 символов, максимальная - 2000.");
            return;
        }

        $.ajax(
        {
            url: '/ajax/offers_send',
            async: true,
            cache: false,
            dataType: "json",
            type: 'POST',
            data: {"tip":tip,"tip_type":tip_type,"shop":$(this).attr("id_shop")},
            beforeSend: function()
            {
                $("#tip_content_form").html("<div class='windowloader'>отправка...</div>");
            },

            success: function(data)
            {
                if(data['re']==true)
                    $("#tip_content_form").html("<div class='message_fool_div'>Ваш отзыв отправлен и поставлен в очередь на модерацию.</div>");

                if(data['re']==false )
                    $("#tip_content_form").html("<div class='message_fool_div'>Извините, Вы исчерпали лимит отзывов на сегодня.</div>");

                if(data['re']=='reload')
                    $("#tip_content_form").html("<div class='message_fool_div'>Авторизируйтесь на сайте, чтобы оставить отзыв.</div>");

            }
        });
    });
});


$(document).ready(function(){
    $("span[id^=help_show]").click(function()
    {
       answer=$("#"+$(this).attr("id")+"_a");

       if (answer.css("display")=='none')
       {
        answer.slideDown('fast');
        $(this).css("borderColor", "#ffffff");
         $(this).css("color", "#666666");
       }
       else
       {
        answer.slideUp('fast');
        $(this).css("borderColor", "#999999");
         $(this).css("color", "#0098c2");
       }
    });
});

$(document).ready(function()
{
    $("#finde_this_shop").click(function()
    {
        if($("#fsel2").html()!=$(this).attr("from_name"))
        {
            $("#fsel2").html($(this).attr("from_name"));
            $("#finde_shop_name").attr("value",$(this).attr("from_name"));
            $("#finde_shop_id").attr("value",$(this).attr("from_id"));

            $("#fsel2").animate({"opacity":"0"},"slow");
            $("#fsel2").animate({"opacity":"1"},"slow");
            $("#fsel2").animate({"opacity":"0"},"slow");
            $("#fsel2").animate({"opacity":"1"},"slow");
        }

        $('body').scrollTop("0");

        $('#selshoptip2').css("display","block");

        if($("#fsel1").html()!='По всей Украине')
        {
            $("form#main_finde #finde_city_name").attr("value",'По всей Украине');
            $("form#main_finde #finde_city_id").attr("value",0);

            form_name=$("form#main_finde #finde_city_name").attr("value");
            $("#fsel1").html(form_name);

            $("#fsel1").animate({"opacity":"0"},"slow");
            $("#fsel1").animate({"opacity":"1"},"slow");
            $("#fsel1").animate({"opacity":"0"},"slow");
            $("#fsel1").animate({"opacity":"1"},"slow");
        }

         if($("#checkbox_mmf").attr('checked'))
         {
               $("#checkbox_mmf").attr('checked',false);
               $("#checkbox_mmf").click();
         }
    });
});

$(window).load(function(){
    $("span[id^=add_click]").click(function()
    {
       if($(this).attr("ajax_note_tovar"))
       {

        tovar_number=$(this).attr("ajax_note_tovar");
        shop_number=$(this).attr("ajax_note_shop");

        var element=$(this);

        $.ajax(
        {
            url: '/ajax/note_add',
            async: true,
            cache: true,
            dataType: "html",
            type: 'POST',
            data: {"note":tovar_number,"shop":shop_number},
            success: function(data)
            {
                parent_div=element.next();
                parent_div.stopTime("hidden_status");

                if(data=='ok')
                    parent_div.html("<div class='toadd'><span>Предложение&nbsp;добавлено&nbsp;в&nbsp;Блокнот</span><div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='not_uni' || data=='max_count_not_uni')
                    parent_div.html("<div class='toadd'>Это&nbsp;предложение&nbsp;уже&nbsp;есть&nbsp;в&nbsp;Блокноте<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='max_count')
                    parent_div.html("<div class='toadd'>Блокнот&nbsp;переполнен,&nbsp;удалите&nbsp;старые записи<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='not_add')
                    parent_div.html("<div class='toadd'>Добавление&nbsp;невозможно:&nbsp;войдите&nbsp;в&nbsp;Вашу&nbsp;учетную&nbsp;запись<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='ban_or_delete')
                    parent_div.html("<div class='toadd'>Добавление&nbsp;невозможно:&nbsp;Ваша&nbsp;учетная&nbsp;запись&nbsp;заблокирована<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                parent_div.oneTime("3s","hidden_status",function()
                {
                    $(this).html("");
                });
            }
        });
       }

       if($(this).attr("ajax_best_shop"))
       {

       shop_number=$(this).attr("ajax_best_shop");
       var element=$(this);

        $.ajax(
        {
            url: '/ajax/shops_add',
            async: true,
            cache: false,
            dataType: "html",
            type: 'POST',
            data: {"shop":shop_number},
            success: function(data)
            {
                parent_div=element.next();
                parent_div.stopTime("hidden_status");

                if(data=='ok')
                {
                    if($('#mmf').css('display')=='none')
                       $('#mmf').css('display','block');

                    parent_div.html("<div class='toadd'><span>Магазин&nbsp;добавлен&nbsp;в&nbsp;Мои&nbsp;Магазины</span><div class='ltoadd'></div><div class='rtoadd'></div></div>");
                }

                if(data=='not_uni')
                    parent_div.html("<div class='toadd'>Этот&nbsp;магазин&nbsp;уже&nbsp;есть&nbsp;в&nbsp;Моих&nbsp;Магазинах<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='not_shop' || data=='not_shop_not_uni')
                    parent_div.html("<div class='toadd'>Ошибка&nbsp;добавления<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='not_add')
                    parent_div.html("<div class='toadd'>Добавление&nbsp;невозможно:&nbsp;войдите&nbsp;в&nbsp;Вашу&nbsp;учетную&nbsp;запись<div class='ltoadd'></div><div class='rtoadd'></div></div>");

                if(data=='ban_or_delete')
                    parent_div.html("<div class='toadd'>Добавление&nbsp;невозможно:&nbsp;Ваша&nbsp;учетная&nbsp;запись&nbsp;заблокирована<div class='ltoadd'></div><div class='rtoadd'></div></div>");


                parent_div.oneTime("3s","hidden_status",function()
                {
                    $(this).html("");
                });
            }
        });
       }
    });
});

$(document).ready(function(){
    $("#tovar_count").change(function()
    {
       count=parseInt($(this).attr("value"));
       price=parseInt($("#tovar_price").html());
       dprice=parseInt($("#delivery_price").html());
       max_dprice=parseInt($("#max_price_delivery").attr("value"));

       $("#delivery_price").stopTime('tovar_sum_price');
       $("#delivery_price").stopTime('tovar_all_price');
       $("#delivery_price").stopTime('delivery_price');

       if(count>0)
       {
        sum_price=count*price;

        if(max_dprice>0 && sum_price>=max_dprice)
        {
          if($("#delivery [text='Бесплатная']").length==0 && $("#default_delivery").attr("value")!="Доставка по Украине")
          {
            $("#delivery").append("<option value='0' send_id='5'>Бесплатная</option>");
            $('#delivery option:last').attr('selected', 'yes');
            dprice=0;
          }
          else
          {
            $("#delivery [text='Бесплатная']").attr('selected', 'yes');
            dprice=0;
          }

          $("#id_delivery").attr('value',$("#delivery option:selected").attr("send_id"));
        }
        else
        {
           if($("#delivery [text='Бесплатная']").length>0)
           {
            $("#delivery [text='Бесплатная']").remove();
            $("#delivery [text='"+$("#default_delivery").attr("value")+"']").attr('selected','yes');
            $("#id_delivery").attr('value',$("#delivery option:selected").attr("send_id"));
            dprice=parseInt($("#delivery [text='"+$("#default_delivery").attr("value")+"']").attr("value"));
           }
        }

        all_price=count*price+dprice;

        if(parseInt($("#delivery_price").html())<dprice)
        {
            $("#delivery_price").everyTime(10,'delivery_price',function()
            {

                if(parseInt($("#delivery_price").html())<dprice)
                    $("#delivery_price").html(parseInt($("#delivery_price").html())+50);
                else
                {
                   $("#delivery_price").html(dprice);
                   $("#delivery_price").stopTime('delivery_price');
                }
            });
       }
       else
       {
            $("#delivery_price").everyTime(10,'delivery_price',function()
            {

                if(parseInt($("#delivery_price").html())>dprice)
                    $("#delivery_price").html(parseInt($("#delivery_price").html())-50);
                else
                {
                   $("#delivery_price").html(dprice);
                   $("#delivery_price").stopTime('delivery_price');
                }
            });
       }

        if(parseInt($("#tovar_sum_price").html())<sum_price)
        {
            $("#tovar_sum_price").everyTime(10,'tovar_sum_price',function()
            {
               s_plus=0

               if(sum_price-parseInt($("#tovar_sum_price").html())<500)
                s_plus=100;

               if(sum_price-parseInt($("#tovar_sum_price").html())>500 && sum_price-parseInt($("#tovar_sum_price").html())<5000)
                s_plus=500;

               if(sum_price-parseInt($("#tovar_sum_price").html())>5000 && sum_price-parseInt($("#tovar_sum_price").html())<10000 )
                s_plus=1000;

               if(sum_price-parseInt($("#tovar_sum_price").html())>10000)
                s_plus=5000;

               if(parseInt($("#tovar_sum_price").html())<sum_price)
                    $("#tovar_sum_price").html(parseInt($("#tovar_sum_price").html())+s_plus);
               else
               {
                   $("#tovar_sum_price").html(sum_price);
                   $("#tovar_sum_price").stopTime('tovar_sum_price');
               }
            });
        }
        else
        {
            $("#tovar_sum_price").everyTime(10,'tovar_sum_price',function()
            {
               s_plus=0

               if(parseInt($("#tovar_sum_price").html())-sum_price<500)
                s_plus=100;

               if(parseInt($("#tovar_sum_price").html())-sum_price>500 && parseInt($("#tovar_sum_price").html())-sum_price<5000)
                s_plus=500;

               if(parseInt($("#tovar_sum_price").html())-sum_price>5000 && parseInt($("#tovar_sum_price").html())-sum_price<10000 )
                s_plus=1000;

               if(parseInt($("#tovar_sum_price").html())-sum_price>10000)
                s_plus=5000;


               if(parseInt($("#tovar_sum_price").html())>sum_price)
                    $("#tovar_sum_price").html(parseInt($("#tovar_sum_price").html())-s_plus);
               else
               {
                   $("#tovar_sum_price").html(sum_price);
                   $("#tovar_sum_price").stopTime('tovar_sum_price');
               }
            });
        }

        if(parseInt($("#tovar_all_price").html())<all_price)
        {
            $("#tovar_all_price").everyTime(10,'tovar_all_price',function()
            {
               a_plus=0

               if(all_price-parseInt($("#tovar_all_price").html())<500)
                a_plus=100;

               if(all_price-parseInt($("#tovar_all_price").html())>500 && all_price-parseInt($("#tovar_all_price").html())<5000)
                a_plus=500;

               if(all_price-parseInt($("#tovar_all_price").html())>5000 && all_price-parseInt($("#tovar_all_price").html())<10000 )
                a_plus=1000;

               if(all_price-parseInt($("#tovar_all_price").html())>10000)
                a_plus=5000;

                if(parseInt($("#tovar_all_price").html())<all_price)
                    $("#tovar_all_price").html(parseInt($("#tovar_all_price").html())+a_plus);
                else
                {
                   $("#tovar_all_price").html(all_price);
                   $("#tovar_all_price").stopTime('tovar_all_price');
                }
            });
        }
        else
        {
            $("#tovar_all_price").everyTime(10,'tovar_all_price',function()
            {
               a_plus=0

               if(parseInt($("#tovar_all_price").html())-all_price<500)
                a_plus=100;

               if(parseInt($("#tovar_all_price").html())-all_price>500 && parseInt($("#tovar_all_price").html())-all_price<5000)
                a_plus=500;

               if(parseInt($("#tovar_all_price").html())-all_price>5000 && parseInt($("#tovar_all_price").html())-all_price<10000 )
                a_plus=1000;

               if(parseInt($("#tovar_all_price").html())-all_price>10000)
                a_plus=5000;

                if(parseInt($("#tovar_all_price").html())>all_price)
                    $("#tovar_all_price").html(parseInt($("#tovar_all_price").html())-a_plus);
                else
                {
                   $("#tovar_all_price").html(all_price);
                   $("#tovar_all_price").stopTime('tovar_all_price');
                }
            });
        }

       }
       else
       {
        $(this).attr("value","1");

        sum_price=1*price;

        if(max_dprice>0  && sum_price>=max_dprice)
        {
          if($("#delivery [text='Бесплатная']").length==0 && $("#default_delivery").attr("value")!="Доставка по Украине")
          {
            $("#delivery").append("<option value='0' send_id='5'>Бесплатная</option>");
            $('#delivery option:last').attr('selected', 'yes');
            dprice=0;
          }
          else
          {
            $("#delivery [text='Бесплатная']").attr('selected', 'yes');
            dprice=0;
          }
          $("#id_delivery").attr('value',$("#delivery option:selected").attr("send_id"));
        }
        else
        {
           if($("#delivery [text='Бесплатная']").length>0)
           {
            $("#delivery [text='Бесплатная']").remove();
            $("#delivery [text='"+$("#default_delivery").attr("value")+"']").attr('selected','yes');
            dprice=parseInt($("#delivery [text='"+$("#default_delivery").attr("value")+"']").attr("value"));
           }
           $("#id_delivery").attr('value',$("#delivery option:selected").attr("send_id"));
        }

        all_price=1*price+dprice;

        if(parseInt($("#delivery_price").html())<dprice)
        {
            $("#delivery_price").everyTime(10,'delivery_price',function()
            {
                if(parseInt($("#delivery_price").html())<dprice)
                    $("#delivery_price").html(parseInt($("#delivery_price").html())+50);
                else
                {
                   $("#delivery_price").html(dprice);
                   $("#delivery_price").stopTime('delivery_price');
                }
            });
       }
       else
       {
            $("#delivery_price").everyTime(10,'delivery_price',function()
            {
                if(parseInt($("#delivery_price").html())>dprice)
                    $("#delivery_price").html(parseInt($("#delivery_price").html())-50);
                else
                {
                   $("#delivery_price").html(dprice);
                   $("#delivery_price").stopTime('delivery_price');
                }
            });
       }


        if(parseInt($("#tovar_sum_price").html())<sum_price)
        {
            $("#tovar_sum_price").everyTime(10,'tovar_sum_price',function()
            {
               s_plus=0

               if(sum_price-parseInt($("#tovar_sum_price").html())<500)
                s_plus=100;

               if(sum_price-parseInt($("#tovar_sum_price").html())>500 && sum_price-parseInt($("#tovar_sum_price").html())<5000)
                s_plus=500;

               if(sum_price-parseInt($("#tovar_sum_price").html())>5000 && sum_price-parseInt($("#tovar_sum_price").html())<10000 )
                s_plus=1000;

               if(sum_price-parseInt($("#tovar_sum_price").html())>10000)
                s_plus=5000;

               if(parseInt($("#tovar_sum_price").html())<sum_price)
                    $("#tovar_sum_price").html(parseInt($("#tovar_sum_price").html())+s_plus);
               else
               {
                   $("#tovar_sum_price").html(sum_price);
                   $("#tovar_sum_price").stopTime('tovar_sum_price');
               }
            });
        }
        else
        {
            $("#tovar_sum_price").everyTime(10,'tovar_sum_price',function()
            {
               s_plus=0

               if(parseInt($("#tovar_sum_price").html())-sum_price<500)
                s_plus=100;

               if(parseInt($("#tovar_sum_price").html())-sum_price>500 && parseInt($("#tovar_sum_price").html())-sum_price<5000)
                s_plus=500;

               if(parseInt($("#tovar_sum_price").html())-sum_price>5000 && parseInt($("#tovar_sum_price").html())-sum_price<10000 )
                s_plus=1000;

               if(parseInt($("#tovar_sum_price").html())-sum_price>10000)
                s_plus=5000;


               if(parseInt($("#tovar_sum_price").html())>sum_price)
                    $("#tovar_sum_price").html(parseInt($("#tovar_sum_price").html())-s_plus);
               else
               {
                   $("#tovar_sum_price").html(sum_price);
                   $("#tovar_sum_price").stopTime('tovar_sum_price');
               }
            });
        }

        if(parseInt($("#tovar_all_price").html())<all_price)
        {
            $("#tovar_all_price").everyTime(10,'tovar_all_price',function()
            {
               a_plus=0

               if(all_price-parseInt($("#tovar_all_price").html())<500)
                a_plus=100;

               if(all_price-parseInt($("#tovar_all_price").html())>500 && all_price-parseInt($("#tovar_all_price").html())<5000)
                a_plus=500;

               if(all_price-parseInt($("#tovar_all_price").html())>5000 && all_price-parseInt($("#tovar_all_price").html())<10000 )
                a_plus=1000;

               if(all_price-parseInt($("#tovar_all_price").html())>10000)
                a_plus=5000;

                if(parseInt($("#tovar_all_price").html())<all_price)
                    $("#tovar_all_price").html(parseInt($("#tovar_all_price").html())+a_plus);
                else
                {
                   $("#tovar_all_price").html(all_price);
                   $("#tovar_all_price").stopTime('tovar_all_price');
                }
            });
        }
        else
        {
            $("#tovar_all_price").everyTime(10,'tovar_all_price',function()
            {
               a_plus=0

               if(parseInt($("#tovar_all_price").html())-all_price<500)
                a_plus=100;

               if(parseInt($("#tovar_all_price").html())-all_price>500 && parseInt($("#tovar_all_price").html())-all_price<5000)
                a_plus=500;

               if(parseInt($("#tovar_all_price").html())-all_price>5000 && parseInt($("#tovar_all_price").html())-all_price<10000 )
                a_plus=1000;

               if(parseInt($("#tovar_all_price").html())-all_price>10000)
                a_plus=5000;

                if(parseInt($("#tovar_all_price").html())>all_price)
                    $("#tovar_all_price").html(parseInt($("#tovar_all_price").html())-a_plus);
                else
                {
                   $("#tovar_all_price").html(all_price);
                   $("#tovar_all_price").stopTime('tovar_all_price');
                }
            });
        }

       }

       if($("#delivery").attr("value")!=0)
         $('#div_warning1').css("display",'block');
       else
         $('#div_warning1').css("display",'none');
    });
});

$(document).ready(function(){
    $("#delivery").change(function()
    {
       count=parseInt($("#tovar_count").attr("value"));
       price=parseInt($("#tovar_price").html());
       dprice=parseInt($(this).attr("value"));
       all_price=count*price+dprice;

       $("#id_delivery").attr('value',$("#delivery option:selected").attr("send_id"));

       $("#delivery_price").stopTime('delivery_price');
       $("#delivery_price").stopTime('tovar_all_price');

       if($("#delivery").attr("value")!=0)
         $('#div_warning1').css("display",'block');
       else
         $('#div_warning1').css("display",'none');

       if(parseInt($("#delivery_price").html())<dprice)
       {
            $("#delivery_price").everyTime(10,'delivery_price',function()
            {
                if(parseInt($("#delivery_price").html())<dprice)
                    $("#delivery_price").html(parseInt($("#delivery_price").html())+50);
                else
                {
                   $("#delivery_price").html(dprice);
                   $("#delivery_price").stopTime('delivery_price');
                }
            });
       }
       else
       {
            $("#delivery_price").everyTime(10,'delivery_price',function()
            {
                if(parseInt($("#delivery_price").html())>dprice)
                    $("#delivery_price").html(parseInt($("#delivery_price").html())-50);
                else
                {
                   $("#delivery_price").html(dprice);
                   $("#delivery_price").stopTime('delivery_price');
                }
            });
       }

       if(parseInt($("#tovar_all_price").html())<all_price)
       {
            $("#tovar_all_price").everyTime(10,'tovar_all_price',function()
            {
                if(parseInt($("#tovar_all_price").html())<all_price)
                    $("#tovar_all_price").html(parseInt($("#tovar_all_price").html())+50);
                else
                {
                   $("#tovar_all_price").html(all_price);
                   $("#tovar_all_price").stopTime('tovar_all_price');
                }
            });
       }
       else
       {
            $("#tovar_all_price").everyTime(10,'tovar_all_price',function()
            {
                if(parseInt($("#tovar_all_price").html())>all_price)
                    $("#tovar_all_price").html(parseInt($("#tovar_all_price").html())-50);
                else
                {
                   $("#tovar_all_price").html(all_price);
                   $("#tovar_all_price").stopTime('tovar_all_price');
                }
            });
       }


    });
});


$(document).ready(function(){
  $("#add_best").click(function()
  {
    addBookMarkMI('http://www.pomagazinam.net','"По Магазинам" - поиск товаров в интернет-магазинах');
  });
});

$(document).ready(function(){
  $("#add_start_page").click(function()
  {
    this.setHomePage("http://www.pomagazinam.net");
    return false;
  });
});


  addBookMarkMI = function(url,title) {
    if (jQuery.browser.mozilla) {
      window.sidebar.addPanel (title,url,"");
    } else if (jQuery.browser.msie) {
      window.external.AddFavorite(url,title);
    } else return false;
    return true;
  }

$(window).load(function(){
    $("div[id^=rate_go]").click(function()
    {
        var user_id=parseInt($(this).attr("par"));

        var element=$(this);

        element.css('visibility','hidden');

        $.ajax(
        {
            url: '/ajax/go_rate',
            async: false,
            cache: false,
            dataType: "json",
            type: 'POST',
            data: {"user_id":user_id},
            success: function(data)
            {
               if(data['re']=='ok')
               {
                 $('#info_div'+user_id).html("Ваш голос учтен. Спасибо за участие.");
                 $('#info_div'+user_id).css('display','block');
                 $('#rate'+user_id).html(parseInt($('#rate'+user_id).html())+1);
               }

               if(data['re']=='ip')
               {
                 $('#info_div'+user_id).html("Извините но с вашего IP адреса голос уже учтен");
                 $('#info_div'+user_id).css('display','block');
               }

               if(data['re']=='error')
               {
                 $('#info_div'+user_id).html('Голосование доступно только для <span id="tipa_enter2" class="vakk">авторизированных</span> пользователей');
                 $('#info_div'+user_id).css('display','block');
               }
            }
        });
    });
});


