function createXMLHttpRequest() {
  var xmlReq = false;
  // branch for native XMLHttpRequest object
  if(window.XMLHttpRequest) {
    try {
      xmlReq = new XMLHttpRequest();
    } catch(e) {
      xmlReq = false;
    }
  // branch for IE/Windows ActiveX version
  } else if(window.ActiveXObject) {
    try {
      xmlReq = new  ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xmlReq = new  ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xmlReq = false;
      }
    }
  }
  return xmlReq;
}
function callServer(method, url, data, dataType, func, arg) {
  if (!method) method='GET';
  var xmlReq = createXMLHttpRequest();
  if(xmlReq) {
    xmlReq.onreadystatechange = function() {
      // only if xmlReq shows "loaded"
      if (xmlReq.readyState == 4) {
        func(arg, xmlReq.responseText,  xmlReq.responseXML,
             xmlReq.status, xmlReq.statusText);
      }
    };
    xmlReq.open(method, url, true);
    if (data) {
      if (!dataType) dataType='application/xml';
      if (typeof(data)!="string" && dataType.indexOf("charset=")<0
           && userAgent.isMozilla) dataType=dataType+';charset=utf-8';
           // in Mozilla XML always serialized as UTF-8
      xmlReq.setRequestHeader('Content-Type', dataType);
    }
    xmlReq.send(data);
    return false;
  }
  return true;
}
function showHTML(element, responseText, responseXML, statusCode, statusText) {
  if (typeof(element)=="string")
    element=document.getElementById(element);
  if (statusCode==200 || statusCode==201) {
    element.innerHTML=responseText;
  }
  else {
    //alert("Загрузить информацию не  удалось: "          +statusText);
          return ;
  }
}

function getData( f ) {

   var tmp = [], el;
    alert(f) ;
   for(i=0; el = f.elements[i]; i++)
      if ( el.value != "" ) tmp.push(el.name + '=' + el.value);
   var str = tmp.join("&");
   alert(str);
  return str;
}

function displayImg( prodgroup_id ) {
  this.document.getElementById( 'img_prodgroup' ).src='/userfiles/prodgroup/'+prodgroup_id+'.jpg';
}
function hideImg( prodgroup_id ) {
  this.document.getElementById( 'img_prodgroup' ).src = '';
}
function addBookmark(a) {
   title=document.title;
   url=document.location;
   try {
     // Internet Explorer
     //window.external.AddFavorite(url, title);
      eval("window.external.AddFa-vorite(url, title)".replace(/-/g,''));
   }
   catch (e) {
     try {
       // Mozilla
       window.sidebar.addPanel(title, url, "");
     }
     catch (e) {
       // Opera
       if (typeof(opera)=="object") {
         a.rel="sidebar";
         a.title=title;
         a.url=url;
         return true;
       }
       else {
         // Unknown
         alert('Нажмите Ctrl-D чтобы добавить страницу в закладки');
       }
     }
   }
   return false;
 }
function showSubmenu(id,parent_id) {
  if ( document.getElementById(id) == null ) return ;
  if (document.getElementById(id).style.display == 'none' || document.getElementById(id).style.display == '' ) {
    document.getElementById(id).style.display = 'block';
    document.getElementById(parent_id).style.listStyleImage="url('/images/li_leftmenu_selected.gif')";
  }
  else {
    document.getElementById(id).style.display = 'none';
    document.getElementById(parent_id).style.listStyleImage="url('/images/li_leftmenu.jpg')";
  }
  return;
}


function sortBy() {

}

function ShowBlock(objId, bHeight)
{
   var obj = document.getElementById(objId);
   if (obj.offsetHeight < bHeight)
   {
      obj.style.height = (obj.offsetHeight + 210) + "px";
      setTimeout (function(){Show(objId, bHeight)}, 5);
   }
}

