window.onload = function() {
  $(document).ready(function(){
    //$(".cb_bg").corner("br 5px").corner("tl 5px");
  });
  if(document.getElementById('center_banner')){
    setInterval('gogo()', 5000) ;
    $(document).ready(function(){
      $('#center_banner').hover(function(){
        document.getElementById('center_banner').className='ban_off';
      }, function() {
        document.getElementById('center_banner').className='ban_on';
      });
    });
  }
  if (document.getElementById('tovars')){

    var tov_divs=document.getElementById('tovars').getElementsByTagName('div').length;
    for (td=0; td<tov_divs; td++){
      if ((td)%2==1){document.getElementById('tovars').getElementsByTagName('div')[td].style.paddingRight='0';}
      else {}
    }
  }
}
function turn_pic(pic){
  if (pic==6){pic=0}
  $(document).ready(function(){
    var pos_pic=-(pic*430);
    $('#cbanner_4 ul').stop().animate({left: pos_pic+"px"},{queue:false,duration:1000});
    $(".cbanner_act").removeClass ('cbanner_act');
    $(document.getElementById('cbanner_1').getElementsByTagName('a')[pic]).toggleClass ('cbanner_act');
    document.getElementById('cbanner_1').className='banner_pos_'+pic;
  });
}
function gogo(){
  if(document.getElementById('center_banner').className=='ban_on'){
    $(document).ready(function(){
      var ul_pos=document.getElementById('cbanner_1').className;
      ul_pos=ul_pos.replace(/banner_pos_/, "");
      ul_pos=ul_pos-0;
      ul_pos=ul_pos+1;
      turn_pic(ul_pos);
    });
  }

}


function topmenu(){
  pic1 = new Image();
  pic1.src="/images/menu_bg_6.gif";
  pic2 = new Image();
  pic2.src="/images/pic_16.png";
  pic3 = new Image();
  pic3.src="/images/pic_17.png";
  pic4 = new Image();
  pic4.src="/images/menu_bg_5.gif";
  pic5 = new Image();
  pic5.src="/images/pic_16.gif";
  pic6 = new Image();
  pic6.src="/images/pic_17.gif";
  pic7 = new Image();
  pic7.src="/images/menu_bg_7.gif";
  $(document).ready(function(){
    var vdg=$("#head_menu li:first-child a:first-child").css("paddingLeft");
    vdg1=vdg.replace(/px/, "");
    vdg1 = vdg1 - 0; 
    vdg1 = vdg1 + 8;
    vdg3 = vdg1 - 10;
    vdg11 = vdg1 + 'px'; 
    vdg3 = vdg3 + 'px 7px';
    
    //$("#head_menu li:first-child a:first-child").css({"paddingLeft" : vdg11});
    //$("#head_menu li:first-child a:first-child").css({"backgroundPosition" : vdg3});
    
    var dota = document.getElementById('head_menu').getElementsByTagName('ul')[0].getElementsByTagName('ul').length;
    dota=dota-1;
    var nwidth=0;
    for (dds=0; dds<dota; dds++){
      var width=$('#head_menu ul:first-child ul')[dds].parentNode.scrollWidth;
      //$("#head_menu li:last-child").css({"width" : width + "px"});
      //$('#head_menu ul:first-child ul')[dds].parentNode.style.width=width+'px';
      nwidth=nwidth+width;
      newwidth=374-nwidth;
      //$('#head_menu ul:first-child ul')[dota].parentNode.style.width=newwidth+'px'
    }
  });    
  var uls=$("#head_menu ul:first-child ul");
  var ul_lenght=uls.length; 
  
  for (i=0; i<ul_lenght; i++) {
    var uls_li=uls[i].getElementsByTagName('li').length; 
    uls_li = uls_li - 0; 
    uls_li = uls_li - 1;
    uls[i].getElementsByTagName('li')[uls_li].className='last_li';
  }
  
  $(document).ready(function(){
    $('#head_menu li').hover(function(){
      var ul = this.getElementsByTagName('ul')[0];
      var width= ul.parentNode.scrollWidth;
      $(ul).css({"display" : "block", "width" : width });
      $(this).css({"background" : "url(/images/menu_bg_7.gif) right 11px no-repeat"}); 
    }, function() {
      var ul=this.getElementsByTagName('ul')[0];
      $(ul).css({"display" : "none"});
      $(this).css({"background" : "url(/images/menu_bg_2.gif) 20px 7px no-repeat"}); 
    });
  });    
}


function Zoom(perc)
{



  //  if (document.body && document.body.style && typeof document.body.style.zoom != 'undefined') {
  //    if (document.body.style.zoom == perc + '%') {
  //      document.body.style.zoom = '100%';
  //    } else {
  //      document.body.style.zoom = perc + '%';
  //    }
  //  }
}


function switchFontSize(val){

  var bd = $("BODY");
  switch (val) {
    case 'inc':
    if (CurrentFontSize+1 < 7) {
      bd.removeClass('fs'+CurrentFontSize);
      CurrentFontSize++;
      bd.addClass('fs'+CurrentFontSize);
    }
    break;
    case 'dec':
    if (CurrentFontSize-1 > 0) {
      bd.removeClass('fs'+CurrentFontSize);
      CurrentFontSize--;
      bd.addClass('fs'+CurrentFontSize);
    }
    break;
    default:
      bd.removeClass('fs'+CurrentFontSize);
      CurrentFontSize = val;
      bd.addClass('fs'+CurrentFontSize);
  }
}

