function go(link) {
   document.location.href = link;
}
function show_element(id, visible) {
   if (visible) {
      jQuery('#' + id).show();
   } else {
      jQuery('#' + id).hide();
   }
   return false;
}
function previewPrintPage(link) {
   return openPage(link, 600, 600)
}
function printPage() {
   window.print();
   return false;
}
function openPage(link, width, height) {
   if ('undefined' == typeof width) {
      width = 600;
   }
   if ('undefined' == typeof height) {
      height = 600;
   }
   win = window.open(link, 'Page', 'width=' + width + ',height=' + height + ',scrollbars=yes');
   return false;
}
function choosePerson(link) {
   if ('undefined' != typeof opener) {
      opener.location.href = link;
      window.close();
   } else {
      document.location.href = link;
   }
}
function show_hide_element(id) {
   if ('none' == jQuery('#' + id).css('display')) {
      jQuery('#' + id).show();
   } else {
      jQuery('#' + id).hide();
   }
   return false;
}
function toggleDepartament(id) {
   if ('none' == jQuery('#departament-' + id).css('display')) {
      jQuery('#departament-' + id).show();
      jQuery('#top-departament-' + id).show();
      jQuery('#other-persons-departament-' + id).show();
      jQuery('#depimage-' + id).attr('src', base_url + 'images/tree/minus.png');
   } else {
      jQuery('#departament-' + id).hide();
      jQuery('#top-departament-' + id).hide();
      jQuery('#other-persons-departament-' + id).hide();
      jQuery('#depimage-' + id).attr('src', base_url + 'images/tree/plus.png');
   }
   return false;
}

function add_user(title) {
   if ('' != title && 0 == jQuery('input[name=users\\[\\]][value=' + title + ']').size()) {
      el = '<div rel="user">';
      el += '<input type="hidden" name="users[]" value="' + title + '" />';
      el += '<a href="#" onclick="return remove_user(this)" title="Удалить">[X]</a> ' + title;
      el += '</div>';
      jQuery('#users-container').append(el);
   }
   return false;
}
function remove_user(obj) {
   jQuery(obj).parent().remove();
   return false;
}
function toggleCategory(id) {
   if ($('#category-'+id).attr('rel') == 'close') {
      // open
      if ('loaded' != $('#container-products-'+id).attr('rel')) {
         // load products
         var url = base_url + 'eshop/products.html?category=' + id;
         $.get(url, function (data) {
            $('#container-products-'+id).html(data).attr('rel', 'loaded');
         });
      }
      $('#container-'+id).show();
      $('#link-'+id).addClass('active-category');
      $('#indicator-'+id).attr('src', base_url + 'images/tree/minus.png');
      $('#category-'+id).attr('rel', 'open');
   } else {
      // close
      $('#container-'+id).hide();
      $('#link-'+id).removeClass('active-category');
      $('#indicator-'+id).attr('src', base_url + 'images/tree/plus.png');
      $('#category-'+id).attr('rel', 'close');
   }
   return false;
}


function popup (img,sx,sy,num) {
		 var winl = (screen.width-sx)/2;
		 var wint = (screen.height-sy)/2;
    image = "<a href='javascript:self.close()'><img src=" + img + " border=0 alt='Click to Close'></a>";
    popupwin=window.open("","photo"+num,"toolbar=no,location=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
    popupwin.document.write("<HTML><HEAD><TITLE>Autogallery Pop-Up Title</TITLE><BASE HREF=\http://integra-gr.ru/\></HEAD><BODY BGCOLOR=#FFFFFF><CENTER>" + image + "</CENTER></BODY></HTML>");
    popupwin.document.close();
}

function go_menu(menu) {
    choice = menu.selectedIndex;
    if (menu.options[choice].value != "") {
        window.location.href = menu.options[choice].value;
    }
}
jQuery(document).ready(function () {

jQuery('.leftMenuItem').each(function () {
   if (0 < jQuery(this).attr('rel')) {
      jQuery(this).parent().css('display', 'none');
      row = jQuery(this).parent();
      jQuery('#' + jQuery('.active', row).attr('rel')).addClass('active');
      }
   });
   
});
