bind_init = 0;

function init_first(cur)
{
  if (!cur)
    cur = new String(document.location.hash);

  if (cur == '#l_regions')
    show_regions();
  else if (cur == '#l_foreign')
    show_foreign();
  else
    show_moscow();
}

function show_moscow(obj)
{
  resetAll();
  $("#l_moscow").addClass('active');
  $('.reg_table').show();
  $('.region_1').show();
  fixSpliters();
}

function show_regions(obj)
{
  resetAll();
  $("#l_regions").addClass('active');
  $('.reg_block').show();
  $('.reg_block A').removeClass('active');
  show_region($("#region_2").eq(0));
}

function show_foreign(obj)
{
  resetAll();
  $("#l_foreign").addClass('active');
  $('.reg_table').show();
  $('.rtype_country').show();
  fixSpliters();
}

function show_region(obj)
{
  $('.reg_table TR.hided_first').hide();
  $('.reg_table').show();
  $('.reg_block A').removeClass('active');
  $(obj).addClass('active');
  var id = $(obj).attr('id');
  $('.'+id).show();
  fixSpliters();
}

function fixSpliters()
{
  $('.reg_table TR:visible:eq(1)').filter('.spliter').hide();
  $('.reg_table TR:visible:last').filter('.spliter').hide();
}

function resetAll()
{
  $(".regions A").removeClass('active');
  $(".hided_first").hide();
}

function partner_projects(obj, cl)
{
  $(".project_sw").removeClass('active');
  $(obj).addClass('active');
  $(".project_list LI").hide();
  if (cl == 'all')
  {
    $(".project_list LI").show();
  }
  else if (cl == '5')
  {
    $(".project_list LI:lt(6)").show();
  }
}

function showme(obj)
{
  $(obj).toggleClass('active');
  $(obj).nextAll('DL').toggle();
  return false;
}

function solutions(obj, cl)
{
  $(obj).parent().siblings().find('A').removeClass('active');
  $(obj).addClass('active');
  $('.useit').hide();
  $('#'+cl).show();
  return false;
}

function solutionssub(obj)
{
  $(obj).toggleClass('active');
  $(obj).nextAll('UL').toggle();
  return false;
}

function afterEnd(i, cssDisp)
{
  var divSize = parseInt($(this).parent().css('width'));
  var countSize = cssDisp;
   $("LI", this).each(function(i){
    var liSize = parseInt($(this).css('width'));
    var middle = countSize + liSize/2;

    if (middle <= divSize/2)
    {
      // left part
      afterEnd_switchPic(this, 'timg-s');
    }
    if (middle > divSize/2) 
    {
      // right part
      afterEnd_switchPic(this, 'timg-f');
    }
    //$("A:last", this).text(countSize+"px");
    countSize = countSize + liSize;

  });
  return;
}

function afterEnd_switchPic(obj, type)
{
    if ($("IMG.timg-s", obj).length > 0 && $("IMG.timg-f", obj).length > 0)
    {
      $("IMG", obj).addClass('hided_first');
      $("IMG."+type, obj).removeClass('hided_first');
      
      var imgSize= $("IMG.timg-s",obj).width();
       $("IMG",obj).css('margin-left', '-'+ Math.round(imgSize/2)+'px');  
       
       $("A.imglink", obj).css('width', imgSize +'px'); 
    }
}


function shwmenu() {
 var heightmenu=$('.green_menu').height();
   $('.outersink').css('min-height',119+heightmenu+'px')
   
  return false; 
}