
function set_wins()
{
var height=0; var width=0;
if (self.screen) {
width = screen.width
height = screen.height
}
else if (self.java) {
var jkit = java.awt.Toolkit.getDefaultToolkit();
var scrsize = jkit.getScreenSize();
width = scrsize.width;
height = scrsize.height;
}

$.cookie("s", width+"-"+height,{ expires: 1 }); 
 }
 
 
function get_scrollTop()
{
    return (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function get_scrollLeft()
{
    return (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function get_clientWidth()
{
    return (document.documentElement && document.documentElement.clientWidth) || (document.body && document.body.clientWidth);
}

function get_clientHeight()
{
    return (document.documentElement && document.documentElement.clientHeight) || (document.body && document.body.clientHeight);
}

function get_visibility(id)
{
    visibility = ( document.getElementById(id).style.display == 'none' ) ? 0 : 1;

    return visibility;
}

function set_visibility(id, value)
{
    visibility = (value == 1) ? 'inline' : 'none';
    // document.getElementById(id).fadeIn('1000');
    document.getElementById(id).style.display = visibility;
    
    return;
}

function show_preloader()
{    //  alert('sdfsdf');
   // var preloader_html = "<div class='preloader'><p>Пожалуйста, подождите &hellip;</p><p><img src='/img/preloader.gif' border='0'></p></div>";
   // var preloader_html = '<div class="popup"><div class="popup-top">&nbsp;</div><div class="bg-popup"><p>Пожалуйста, подождите &hellip;</p><p><img src="http://nbplaza.ru/images/preloader.gif" border="0"></p></div><div class="popup-bottom">&nbsp;</div></div>';
    var preloader_html = '<img src="http://nbplaza.ru/images/preloader.gif" width="64" height="64">';

    var width = 70;
    var height = 375;

    var preloader = document.getElementById("preloader_box");
    var left = get_scrollLeft() + ( get_clientWidth() / 2 ) - ( width / 2 );
    var top = get_scrollTop() + ( get_clientHeight() / 2 ) - ( height / 2 );
   // alert(top);
    left = Math.round(left) + 'px';
    top = Math.round(top) + 'px';
    
    preloader.innerHTML = preloader_html;
    preloader.style.top = top;
    preloader.style.left = left;
    set_visibility('preloader_box', 1);

    return;
}

function hide_preloader()
{
    //set_visibility('preloader_box', 0);
    setTimeout("set_visibility('preloader_box', 0);", 750);
    
    return;
}


function put_in_basket(idtov)
{
   // in_basket = in_basket || 0;

    show_preloader();

                  $.ajax({   
    url: "cart_a.php?new="+idtov+"&z=1",   
    cache: false,   
    success: function(data){ 
   // alert('fghfgh');  
        show_popup_box(data,400,250,'basket');
        
    }   
});  
                 // alert('sdfsdf');
               // hide_preloader();
              //  document.getElementById('basket_class').className = 'bag full';
              //  document.getElementById('basket_link').style.display = 'block';
             //   set_html('basket_status', response.basket_items + ' ' + response.basket_items_string + '<br />на сумму ' + response.basket_price + ' р.');
             //   show_popup_box(response.popup, 400, 300);
                setTimeout("show_basket_items()",2000);
                
 
    
  
    
    
    return;
}

function fast_order()
{
   // in_basket = in_basket || 0;

    show_preloader();

                  $.ajax({   
    url: "cart_a_fast.php?z=1",   
    cache: false,   
    success: function(data){ 
   // alert('fghfgh');  
        show_popup_box(data,342,300,'basket_fast');
        
    }   
});  
   
    return;
}

 function submit_fast_order()
{
   // in_basket = in_basket || 0;

    

                  $.ajax({ 
                  type: "POST",   
                      
                     
                
                data: "name="+$("#f_name").val()+"&phone="+$("#f_phone").val()+"&komm="+$("#f_komm").val()+"&z=2", 
                  
    url: "cart_a_fast.php?z=2",   
    cache: false,   
    success: function(html){ 
   // alert('fghfgh');  
        $("#basket_fast").html(html);
        
    }   
});  
   
    return;
}


function show_basket_items()

{
                        $.ajax({   
    url: "cart_a.php?z=2",   
    cache: false,   
    success: function(html){   
                    $("#cart1").html(html);  
        
        
    }   
});    
            $.ajax({   
    url: "cart_a.php?z=3",   
    cache: false,   
    success: function(html){   
                    $("#cart2").html(html);  
        
        
    }   
});

      
}



function show_popup_box(text, width, height,object)
{
    var popup_box = document.getElementById(object);
    var left = get_scrollLeft() + ( get_clientWidth() / 2 ) - ( width / 2 );
    var top = get_scrollTop() + ( get_clientHeight() / 2 ) - ( height / 2 );
    var top = get_scrollTop() + 200;
    left = Math.round(left) + 'px';
    top = Math.round(top) + 'px';
    
    popup_box.innerHTML = text;
    popup_box.style.left = left; 
    popup_box.style.top = top;
    set_visibility(object, 1);
    
    //alert(left);
    //alert(top);
    hide_preloader();  
    return;
}


function hide_popup(id)
{
    set_visibility(id, 0);

    return;
}


 function display_street(street)   
        {   // alert(street);
            $.ajax({
             type: "POST",   
                      
                     
                url: "adress.php",
                data: "street="+street+"&action=1",     
                cache: false,   
                success: function(data){   
                    set_str(data);    
                }   
            });   
        }  
        
         function set_str(data)
{
document.getElementById('str').value=data;
document.getElementById('str').setSelectionRange(0,2).select();
//document.getElementById('str').select(); 

}


function show_call_back(text)
{
    var popup_box = document.getElementById('call_back');

    popup_box.innerHTML = text;
    popup_box.style.right = 220; 
    popup_box.style.top = 150;
    set_visibility('call_back', 1);
    

    
    return;
}



function call_back(idtov)
{
   

                  $.ajax({   
    url: "call_back.php?z=1&idtov="+idtov,   
    cache: false,   
    success: function(data){ 

        show_call_back(data);
        
    }   
});  
   
    return;
}

function call_back_sub(idtov)
{
   

   if(document.getElementById('call_zad1').checked===true) a=1;         
  else if(document.getElementById('call_zad2').checked===true) a=2;
  else if(document.getElementById('call_zad3').checked===true) a=3;  
     
    

                  $.ajax({
      type: "POST",               
    url: "call_back.php",
    data:"z=2"+"&name="+$("#call_name").val()+"&tel="+$("#call_tel").val()+"&zad="+a+"&idtov="+idtov,   
    cache: false,   
    success: function(data){ 

        show_call_back(data);
        
    }   
});  
     setTimeout("hide_popup('call_back')",8000);  
    return;
}



/*$('f_kommasd')
    .focus(function() { 
        $(this).css("background", "none"); 
    })
    .blur(function() { 
        if ($(this)[0].value == '') { 
            $(this).css("background", "url(images/dot.gif) center center no-repeat"); 
        } 
    });  */
   

   
   function ch_o(id)
   {
         if(id==1)
       {
       $("#har_t1").css("background", "url(../images/SO_obz1.jpg)  no-repeat");     
       $("#har_t2").css("background", "url(../images/SO_spec.jpg)  no-repeat"); 
       $("#har_t3").css("background", "url(../images/SO_otz.jpg)  no-repeat");
       $("#har_t4").css("background", "url(../images/SO_aks.jpg)  no-repeat");
       $("#har_t1").css("width", "72");
       $("#har_t2").css("width", "106");
       $("#har_t3").css("width", "72");
       $("#har_t4").css("width", "91");

        $("#obz").fadeIn('fast',function(){
                   $("#obz").css("display","block");});  
       $("#spec").css("display", "none"); 
       $("#otz").css("display", "none"); 
       $("#aks").css("display", "none");
       }
       
       
       
       if(id==2)
       {
       $("#har_t1").css("background", "url(../images/SO_obz.jpg)  no-repeat");     
       $("#har_t2").css("background", "url(../images/SO_spec1.jpg)  no-repeat"); 
       $("#har_t3").css("background", "url(../images/SO_otz.jpg)  no-repeat");
       $("#har_t4").css("background", "url(../images/SO_aks.jpg)  no-repeat");
       $("#har_t1").css("width", "62");
       $("#har_t2").css("width", "122");
       $("#har_t3").css("width", "72");
       $("#har_t4").css("width", "91");
       
       $("#obz").css("display", "none"); 
       $("#spec").fadeIn('fast',function(){
                   $("#spec").css("display","block");
       });  
       $("#otz").css("display", "none"); 
       $("#aks").css("display", "none"); 

       }
       if(id==3)
       {
       $("#har_t1").css("background", "url(../images/SO_obz.jpg)  no-repeat");     
       $("#har_t2").css("background", "url(../images/SO_spec.jpg)  no-repeat"); 
       $("#har_t3").css("background", "url(../images/SO_otz1.jpg)  no-repeat");
       $("#har_t4").css("background", "url(../images/SO_aks.jpg)  no-repeat");
       $("#har_t1").css("width", "62");
       $("#har_t2").css("width", "106");
       $("#har_t3").css("width", "85");
       $("#har_t4").css("width", "91");
       
        $("#obz").css("display", "none"); 
       $("#spec").css("display", "none"); 
       $("#otz").fadeIn('fast',function(){
                   $("#otz").css("display","block");}); 
       $("#aks").css("display", "none");
       
       }
       if(id==4)
       {
       $("#har_t1").css("background", "url(../images/SO_obz.jpg)  no-repeat");     
       $("#har_t2").css("background", "url(../images/SO_spec.jpg)  no-repeat"); 
       $("#har_t3").css("background", "url(../images/SO_otz.jpg)  no-repeat");
       $("#har_t4").css("background", "url(../images/SO_aks1.jpg)  no-repeat");
       $("#har_t1").css("width", "62");
       $("#har_t2").css("width", "106");
       $("#har_t3").css("width", "72");
       $("#har_t4").css("width", "108");

        $("#obz").css("display", "none"); 
       $("#spec").css("display", "none"); 
       $("#otz").css("display", "none"); 
       $("#aks").fadeIn('fast',function(){
                   $("#aks").css("display","block");}); 
       }
       
       
   }
    
$(document).ready(function(){  
$("#iwbit").click(function()
{       
 var a = document.getElementById('iwbit2');

    
     
    call_back(a.innerHTML);
});

});   

function kont(id)
{
  if(id==2)
  {
   $("#kart").css("display", "none"); 
   $("#kart2").css("display", "block"); 
   $("#adr2").css("display", "block"); 
      
   $("#kart1").css("display", "none"); 
   $("#adr1").css("display", "none");   
      
  } 
   else if(id==1)
  {
   $("#kart").css("display", "none"); 
   $("#kart1").css("display", "block"); 
   $("#adr1").css("display", "block"); 
      
   $("#kart2").css("display", "none"); 
   $("#adr2").css("display", "none");   
      
  } 
   else if(id==3)
  {
   $("#kart").css("display", "block"); 
   $("#kart1").css("display", "none"); 
   $("#adr1").css("display", "none"); 
      
   $("#kart2").css("display", "none"); 
   $("#adr2").css("display", "none");   
      
  }
}

function hd(id)

{   
    var b=document.getElementById("gfoto2_0").style.cursor; 
      if(b!="default")   
       {
     document.getElementById("gfoto2_0").style.cursor="default"; 
    
       
           
       
    
    for(var c=0;c<=4;c++){ 
          //alert(c);
         m="gfoto2_"+c;
         if(document.getElementById(m))
    document.getElementById(m).style.border="1px solid white";}
    
                   document.getElementById("gfoto2_"+id).style.border="1px solid #b0c2b1"; 
         
       for(var c=0;c<=4;c++)
       {
           
                         
              if(document.getElementById("gfoto_"+c))  
         var a=document.getElementById("gfoto_"+c).style.display; 
         
          if(a=="block")
          {
           $("#gfoto_"+c).fadeOut('fast',function(){
               
   
               $("#gfoto_"+id).fadeIn('slow',function(){
                   $("#gfoto_"+id).css("display","block");
                   
                  
               
               }
                   )}
                   ); 
            
          } 
          
          
       } 
       setTimeout('a1()', 700);
       }
   
}
function a1()
{
    

 document.getElementById("gfoto2_0").style.cursor="pointer"; 
  
           
}

 


function show_gifts(cenad)
{
                  
                      $.ajax({   
    url: "gifts.php?z=1&cenad="+cenad,   
    cache: false,   
    success: function(data){ 

        var popup_box = document.getElementById('gifts_d');
        var top = get_scrollTop() + 200;   
      
    popup_box.innerHTML = data;
    popup_box.style.left = 300; 
    popup_box.style.top = top; 
    $("#gifts_d").fadeIn('slow',function(){
                   $("#gifts_d").css("display","block");
                       
                      });
         }   
});
    return; 
}  


function sel_cat_item(c,z)
{
    if(z==1)
    {

   document.getElementById('cat_item_'+c).style.borderColor='red';
    document.getElementById('cat_item_har_'+c).style.backgroundColor='#f2f6fe'
     document.getElementById('idt_'+c).style.display='block' 
       
    }
    else if(z==2)
    {
     document.getElementById('cat_item_'+c).style.borderColor='#cacaca';

    document.getElementById('cat_item_har_'+c).style.backgroundColor='white';
    
    document.getElementById('idt_'+c).style.display='none'    
         
    }
    else if(z==11)
    {
     document.getElementById('cat_item_'+c).style.backgroundImage='url(../images/polos.jpg)';   
         
    }
    else if(z==22)
    {
     document.getElementById('cat_item_'+c).style.backgroundImage='url(../images/polosg.jpg)';    
         
    }
    
    
}


function ch_gift(c,id)
{
   



                  $.ajax({   
    url: "aja.php?idtov="+id+"&z=1&c="+c,   
    cache: false,   
    success: function(data){ 
   // alert(data);  
      
        
    }   
});  
                 
                
 
    
  
    
    
    return;
}

function get_fast_podb(id)
{   
      document.getElementById('slider_prod_cols_info').innerHTML = '<img src="images/timer20.gif">';
                           $.ajax({   
    url: 'opc.php',
    type: "POST",
    data: 'action=5&id='+id,                                  
    cache: false,   
    success: function(data){
    document.getElementById('catIz').innerHTML=data;   
     document.getElementById('dr_bar').innerHTML="";
     var cm=document.getElementById('cm').innerHTML;
     var cma=document.getElementById('cma').innerHTML;  
   
    }   
});     
  
    return;
 
     
}



function get_blok(fine)
{
    
    
    document.getElementById('slider_prod_cols_info').innerHTML = '<img src="images/timer20.gif">';
                           $.ajax({   
    url: 'opc.php',
    type: "POST",
    data: 'action=6&fine='+fine,                                  
    cache: false,   
    success: function(data){
    document.getElementById('catIz').innerHTML=data;   
     document.getElementById('dr_bar').innerHTML="";
     var cm=document.getElementById('cm').innerHTML;
     var cma=document.getElementById('cma').innerHTML;  
   
    }   
});     
  
    return;
}









