function x(o){
  if(typeof(o)!='object')return alert('~'+o+'~');
  var s='';
  for(var i in o)try{
    s+='\n--['+i+']='+o[i];
  }catch(e){
    s+='\n--['+i+']=~ERROR~';
  }
  alert('~'+(typeof(o))+'~'+s);
}
function changeSize(obj){
  $(".select").val(obj);
  $(".list-select div.select").slideUp("fast");	
}
function catalogRibbon(){
  var timer;
  var forward=true;
  var wraper=$('#catalog-ribbon div.wraper:eq(0)');
  var after=0;
  var timeout=1800;
  var slide=function(){
    // if(after==wraper.scrollLeft())forward=!forward;
    $('#catalog-ribbon img.'+(forward ? 'right' : 'left')).click();
    // after=wraper.scrollLeft();
  }
  $('#catalog-ribbon').hover(function(){clearTimeout(timer)},function(){timer=setInterval(slide,timeout)});
  timer=setInterval(slide,timeout);
}
$(document).ready(function(){
  setTimeout(function(){window.status='Loading done.'},1);
  setTimeout(function(){window.status=''},1500);

  $('.tabs ul li').hover(function(){
    var p = $(this).find('a').attr('rel');
    var h = $('.lights ul').find('#'+p);
    h.fadeIn(300);
  },function(){
    $('.lights ul li').fadeOut(300);
  });
 
  $('.bottom-head-block .tabs ul li').hover(function(){
    $(this).find('ul').css('display','block');
  },function(){
    $('.bottom-head-block .tabs ul li ul').css('display','none');
  });
 
  $('.list-select img').click(function(){
    if($(this).next('.select').css('display')=='none') {
      $(this).next('.select').fadeIn(300);
    }
    else {
      $(this).next('.select').fadeOut(300);
    }
  });
  $('span.show_map').click(function(){
    if ($('#map-block').css('display') == 'none') 
      $('#map-block').fadeIn(300);
    else
      $('#map-block').fadeOut(300);
  });

  var params = {
    changedEl: "#size_select, #atribut",
    scrollArrows: false
  }
  cuSel(params);
  var catalogRibbonWidth=165;
  var catalogRibbonCount=5;
  $('#catalog-ribbon div.wraper div:eq(0)').children().each(function(){$(this).parent().append($(this).clone())});
  $('#catalog-ribbon img.left').click(function(event){
    event.preventDefault();
    $(this).unbind('click');
    if(!$('#catalog-ribbon div.wraper:eq(0)').scrollLeft())
      $('#catalog-ribbon div.wraper:eq(0)').scrollLeft(catalogRibbonWidth*$('#catalog-ribbon div.wraper div:eq(0)').children().size()/2);
    $('#catalog-ribbon div.wraper:eq(0)').animate({scrollLeft: $('#catalog-ribbon div.wraper:eq(0)').scrollLeft()-catalogRibbonWidth}, 'slow');
    //$('#catalog-ribbon div.wraper:eq(0)').scrollLeft($('#catalog-ribbon div.wraper:eq(0)').scrollLeft()-catalogRibbonWidth);
    var func=arguments.callee;
    setTimeout(function(){$('#catalog-ribbon img.left').click(func)},1000);
  });
  $('#catalog-ribbon img.right').click(function(event){
    event.preventDefault();
    $(this).unbind('click');
    if(($('#catalog-ribbon div.wraper div:eq(0)').children().size()-catalogRibbonCount)*catalogRibbonWidth<=$('#catalog-ribbon div.wraper:eq(0)').scrollLeft())
    $('#catalog-ribbon div.wraper:eq(0)').scrollLeft(0);
    $('#catalog-ribbon div.wraper:eq(0)').animate({scrollLeft: $('#catalog-ribbon div.wraper:eq(0)').scrollLeft()+catalogRibbonWidth}, 'slow');
    //$('#catalog-ribbon div.wraper:eq(0)').scrollLeft($('#catalog-ribbon div.wraper:eq(0)').scrollLeft()+catalogRibbonWidth);
    var func=arguments.callee;
    setTimeout(function(){$('#catalog-ribbon img.right').click(func)},1000);
  });
  catalogRibbon();
});

