

obj = {
  activeid : false
}

$(document).ready(function(){

  var tabContainers = $('div.infos > div');

  var id = document.body.id;
  if(id == 'potreb' || id == 'medic')
    id = 'shop';

  document.getElementById('menu_'+id).className = 'active';
  
  

  $('input#tab').each(function(){
    obj.activeid= $(this).val();
    //скрываем все элементы
    $('#info_link li').each(function(){
      if($(this).attr('id') == obj.activeid){
        $(this).addClass('selected');
      } else {
        $(this).removeClass('selected');
      }
    });
    $('div.infos div').each(function(){
      if($(this).attr('id') == 'id'+obj.activeid){
        $(this).show();
      } else {
        $(this).hide();
      }
    });
  });
  /**
   */
  if(!obj.activeid){
    tabContainers.hide().filter(':first').show();
    $('ul#info_link li a').click(function(){
      tabContainers.hide();
      tabContainers.filter(this.hash).show();
      $('ul#info_link li').removeClass('selected');
      $(this).parent('li').addClass('selected');
      return false;
    }).filter(':first').click();
    
  }

  $('ul#info_link li a').click(function(){
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('ul#info_link li').removeClass('selected');
    $(this).parent('li').addClass('selected');
  });

  $('.tab').cornerz({
    radius:5,
    corners:"tl tr"
  });
  $('div.infos').cornerz({
    radius:20,
    corners:"bl tr br"
  });

  $("div.photocatalog a").fancybox({
    overlayShow: true,
    overlayOpacity: 0.5,
    zoomSpeedIn: 1500,
    zoomSpeedOut:600
  });

  ns = false;
  $('div.group li.head').click(function(){
    $(this).next('ul').toggle();
    $(this).find('div#tog').toggleClass('tog');
  /*
           if(ns){
               $(this).find('img.tog').attr('src','http://'+location.host+'/public/skins/img/tog.png');
               ns = false;
           }else{
               $(this).find('img.tog').attr('src','http://'+location.host+'/public/skins/img/tog2.png');
               ns = true;
           }
             */
           
  });

  $('div.group ul:not(:first)').hide();
  $('div.group div.infos ul').show();
  
  	if( document.location.hash && document.location.hash == '#id4' )
	{
		tabContainers.hide();
		$( 'div#id4' ).show();
		$( 'ul#info_link li' ).removeClass( 'selected' );
		$( 'a[href=#id4]' ).parent( 'li' ).addClass( 'selected' );
	}
  
});


function getBrowserInfo() {
  var t,v = undefined;
  if (window.opera) t = 'Opera';
  else if (document.all) {
    t = 'IE';
    var nv = navigator.appVersion;
    var s = nv.indexOf('MSIE')+5;
    v = nv.substring(s,s+1);
  }
  else if (navigator.appName) t = 'Netscape';
  return {
    type:t,
    version:v
  };
}

function bookmark(a){
  var url = window.document.location;
  var title = window.document.title;
  var b = getBrowserInfo();
  if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
  else if (b.type == 'Opera') {
    a.href = url;
    a.rel = "sidebar";
    a.title = url+','+title;
    return true;
  }
  else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
  else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
  return false;
}

