function dirDepth(uri) {
	var strRoot = "/";
	var start = uri.indexOf(strRoot) + strRoot.length + 1;
	uri = uri.substr(start);
	var tmp = new Array();
	
	tmp = uri.split("/");
	return tmp.length;
}

function PathToRoot(){
	var depth = dirDepth(location.pathname)-1;
	var path ="";
	var i=0;
	for (i=0;i<depth;i++) {
		path = path + "../"
	}
	return path;
}

function showContactForm(code){
  
	/*create form-element */
	var form = document.createElement('form');
	form.setAttribute('action', PathToRoot() + 'contact/index.php');
	form.setAttribute('method', 'post');
	form.setAttribute('name', 'contactformulier');
	
	/*create hidden inputfield */
	var fldInput = document.createElement('input');
	fldInput.setAttribute('type', 'hidden');
	fldInput.setAttribute('name', 'code');
	fldInput.setAttribute('value', code);
	
	/*append inputfield to form */
	form.appendChild(fldInput);
	
	/*append form to body tag (hidden form so no layout issues) */
	document.body.appendChild(form);
	/*submit the form */
	form.submit();
}

function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}

function displayResult(xmldoc,xsldoc,elementid)
{
xml=loadXMLDoc(xmldoc);
xsl=loadXMLDoc(xsldoc);
// code for IE
if (window.ActiveXObject)
  {
  ex=xml.transformNode(xsl);
  document.getElementById(elementid).innerHTML=ex;
  }
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
  {
  xsltProcessor=new XSLTProcessor();
  xsltProcessor.importStylesheet(xsl);
  resultDocument = xsltProcessor.transformToFragment(xml,document);
  elm=document.getElementById(elementid);
  elm.parentNode.replaceChild(resultDocument,elm);
  }
}
