function navigateTo(oneurl){
	if(oneurl=='')return;
	if(oneurl.substr(0,1)=="#"){
		window.open(oneurl.substr(1,oneurl.length));
	}else{
		document.location = oneurl;
	}
}

function setCookie(name,value,days) {
  if (days) {
  	var date = new Date();
  	date.setTime(date.getTime()+(days*24*60*60*1000));
  	var expires = "; expires="+date.toGMTString();
  } else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
  	var c = ca[i];
  	while (c.charAt(0)==' ') c = c.substring(1,c.length);
  	if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function delCookie(name) {
  setCookie(name,"",-1);
}

function addEventHandler(anObject, anEvent, aFunction) {
  if (anObject.attachEvent) {
    anObject.attachEvent('on' + anEvent, aFunction);
  }	else {
    anObject.addEventListener(anEvent, aFunction, false);
  }
}

//addEventHandler(document, "mouseover", hidesub);

var currentmenu = -1;

function getOffsetLeft (el) {
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
  ol += el.offsetLeft;
  return ol;
}

function getOffsetTop (el) {
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
  ot += el.offsetTop;
  return ot;
}

function showsub(n, y) {
  var node = document.getElementById("submenu" + n);
  if (node != null) {
    if (currentmenu != -1) hidesub(currentmenu);
    if (n != 6 && node.getElementsByTagName("div").length > 1) {
      currentmenu = n;
      var menu = document.getElementById("menu" + currentmenu);
      node.style.display = "block";
      node.style.left = getOffsetLeft(menu);
      node.style.top  = getOffsetTop(menu);
    }
    return true;
  }
}

function hidesub(e) {
  var t = e.target ? e.target : e.srcElement;
  while (t != null) {
    if ((t.id == "menu" + currentmenu) || (t.id == "submenu" + currentmenu)) return;
    t = t.parentNode;
  }
  var node = document.getElementById("submenu" + currentmenu);
  if (node != null) {
    node.style.display = "none";
  }
  currentmenu = -1;
}

function showhover(node) {
  node.className = "hover";
}

function hidehover(node) {
  node.className = "";
}

function doFilterCompanies() {
  var t = document.getElementById("companies");
  var o = t.getElementsByTagName("TR");
  var n = 0;
  var f = document.getElementsByName("companytypes");
  var d = "none";
  var s;
  for (var i = 0; i < o.length; i++) {
    d = "none";
    s = o[i].getAttribute("subtypes");
    if (typeof(s) == "string") {
      if (s != "||") {
        for (var j = 0; j < f.length; j++) {
          if (f[j].checked && s.indexOf(f[j].value) != -1) {
            d = "";
            n++;
            break;
          }
        }
        o[i].style.display = d;
      } else {
        n++;
      }
    }
  }
  document.getElementById("companies_count").innerHTML = n;
}

function doPost(url, s) {
  var objXML = (typeof XMLHttpRequest != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
  objXML.open("POST", url, false);
  objXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
  var postdata = "", x;
  for (var i=0; i < s.length; i++) {
    if (postdata != "") postdata += "&";
    postdata += s[i][0] + "=" + encodeURI((s[i][1]+"").replace(/&/ig, "%26"));
  }
  objXML.send(postdata);
  return objXML.responseText;
}

    function qsadd(qs, text, value) {
      var q = qs.split("&");
    
      for (var i=0; i < q.length; i++) {
        if (q[i].split("=")[0].toLowerCase() == text.toLowerCase()) {
          q[i] = text + "=" + escape(value);
          text = "";
          break;
        }
      }
      if (q.length == 1 && q[0].length == 0) q.length = 0;
      if (text != "") {
        q[q.length] = text + "=" + escape(value);
      }
      return q.join("&");
    }
    
    function qsget(text) {
      var qs = window.top.location.search.substring(1);
      var q = qs.split("&");
      for (var i=0; i < q.length; i++) {
        var s = q[i].split("=");
        if (s[0].toLowerCase() == text.toLowerCase()) return s[1];
      }
      return "";
    }

    function onRegion(n)
    {
      var s = window.top.location.search.substring(1);
      s = qsadd(s, "region", n.checked ? 2 : 1);
      if (window.location.pathname.toLowerCase() == "/index.aspx") {
        window.location.href = "/bedrijven.aspx?" + s;
      } else {
        window.location.search = s;
      }
    }
    function onSelectCity(value) {
      var s = window.top.location.search.substring(1);
      s = qsadd(s, "zipcode", value.split(",")[0]);
      if (window.location.pathname.toLowerCase() != "/bedrijven.aspx") {
        window.location.href = "/bedrijven.aspx?" + s;
      } else {
        window.location.search = s;
      }
    }

    function onSelectCompanytype(value) {
      if (window.top.location.pathname != "/bedrijven.aspx")
      {
        window.location.href ="/bedrijven.aspx?type=" + value.split(",")[0];
      } else
      {
        var s = window.top.location.search.substring(1);
        s = qsadd(s, "type", value.split(",")[0]);
        window.location.search = s;
      }
    }

