function popup(file,width,height)
{
  window.open(file,"site_path","height="+height+",width="+width+",status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,menubar=no,top=10,left=10");
}

function test_(){
alert('111');
}

function makeSiteLink(name) {
  if (!window.js_base_url) {
    str = document.location.toString();
    js_base_url = str.replace("/javascript/editor/scripts/hyperlink.htm","");
    js_base_url = js_base_url.replace("/javascript/editor/scripts/moz/hyperlink.htm","");
  }
  popup(js_base_url+'/admin/index.php?mod=tree&action=mini_browser&returnname='+name,'600','400');
}

function retBack(obj, str) {
  window.close();
  obj.value = str;
}

function insertIntoWYSIWYG(str) {
  doc = "window.opener";
  for ( property in eval(doc) ) {
    fullPropertyName = "document."+property;

    if (fullPropertyName.indexOf("document.myStyle")!=-1) {
      objName = fullPropertyName.replace("document.myStyle", "");
      break;
    }
  }
  objName = eval(doc+".window."+objName);
  objName.insertCustomTag(str);
}

function check4compare(obj) {
  for(i=0; i<obj.elements.length; i++) if (obj.elements[i].type=="checkbox" && obj.elements[i].checked) return true;
  
  alert('Не выделено ни одного продукта для сравнения');
  return false;
}

function switch_loading_box (box_id) {
  
  if(document.getElementById(box_id).style.display!="none") {
    document.getElementById(box_id).style.display="none";
  }
  else {
    document.getElementById(box_id).style.display="";
    
    var ie=document.all;
    iebody=document.body;
    var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
    var docwidth=(ie)? iebody.clientWidth : window.innerWidth;
    docheight=(ie)? iebody.clientHeight: window.innerHeight;
    var objwidth=document.getElementById(box_id).offsetWidth;
    objheight=document.getElementById(box_id).offsetHeight;
    var test=docwidth/2-objwidth/2+"px";

    document.getElementById(box_id).style.left=docwidth/2-objwidth/2+"px";
    document.getElementById(box_id).style.top=scroll_top+docheight/2-objheight/2+"px";
  }
  
  return false;
  
}

function show_div(name) {
  
  if(document.getElementById(name).style.display!="none") {
    document.getElementById(name).style.display="none";
  }
  else {
    document.getElementById(name).style.display="";
  }
  
  return false;
}

function insert()
{
  var sel_ind = document.filter.metro_all.options.selectedIndex;
  if ( sel_ind >= 0 )
  {
    all_opt = document.filter.metro_all.options;
    new_opt = document.filter.metro_new.options;
    text = all_opt[sel_ind].innerText;
    val = all_opt[sel_ind].value;

      exist = 0;
      new_index = document.filter.metro_new.length;
      for ( i=0; i<new_index; i++ )
        if ( new_opt[i].value == val ) exist = true;
      if ( !exist ) new_opt[new_index] = new Option(text,val); 
    
  }
}

function erase () {
  if (document.filter.metro_new.options.selectedIndex!=-1)document.filter.metro_new.options[document.filter.metro_new.options.selectedIndex]=null;
}

function clear_all ()
 {
  var mn
  var n
  n=0
  mn = document.filter.metro_new.length;
  while (document.filter.metro_new.options[n] != null)
  {
    document.filter.metro_new.options[n] = null;
      n++;
    if (n=mn){n=0;}
  }
  document.filter.metro_new.selectedIndex = 0;
}

function form_metro_list() {
  
  mn = document.filter.metro_new.length;
  if (mn==0){
    
    document.filter.metro.value ="";
    return true;
  } else {
    document.filter.metro.value ="";
  
  for ( n=0; n<mn; n++ ) {
    document.filter.metro.value += document.filter.metro_new.options[n].value + "-";
  }
  
  if ( document.filter.metro.value != '' ) {
    document.filter.metro.value = document.filter.metro.value.substring(0, document.filter.metro.value.length-1);
  }
  document.filter.metro_all.value='';
  document.filter.metro_new.value='';

  document.filter.submit();
  }
}

function switch_div(action, id) {
  if (obj=document.getElementById("menu_"+id)) {
    if (action=="show")
      obj.className="";
    else
      obj.className="hidd";
  }
  
  return false;
}



