// JavaScript Document created by i-Concept innovators
var _imgPad = 'img/';

function $(e) { return document.getElementById(e); }

function createPDF(loc) {
	// function to open a popup window that will create a pdf document in functions.cfm.
}

function printDocument(e) {
	// function to print the current frame
	e.window.print();
}

function toggleItem(el,elImg)
{
	if ($(el).className == 'open') { 
		$(el).className = 'hidden';
		$(elImg).src = _imgPad + 'folder_closed.gif';
	}
	else {
		$(el).className = 'open';
		$(elImg).src = _imgPad + 'folder_open.gif';
	}
}

function createAjaxObj(){
var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	}
	else if (window.ActiveXObject){ // if IE
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
		try{
			httprequest=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){}
		}
	}
	return httprequest
}

var ajaxpack=new Object()
ajaxpack.basedomain="http://"+window.location.hostname
ajaxpack.ajaxobj=createAjaxObj()
ajaxpack.filetype="txt"
ajaxpack.addrandomnumber=0 //Set to 1 or 0. See documentation.

ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if (ajaxpack.addrandomnumber==1) //Further defeat caching problem in IE?
		var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange=callbackfunc
		this.ajaxobj.open('GET', url+"?"+parameters, true)
		this.ajaxobj.send(null)
	}
}

ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange = callbackfunc;
		this.ajaxobj.open('POST', url, true);
		this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.ajaxobj.setRequestHeader("Content-length", parameters.length);
		this.ajaxobj.setRequestHeader("Connection", "close");
		this.ajaxobj.send(parameters);
	}
}

/*function zoek(_F) {
	top.neocontent.dhfContent.location.href = 'dhf_search.cfm?keywords='+GetE('dhfSearchvalue').value+'&pageEvent=activity.search';
	_F.pageEvent.value="tree.search";
	_F.action=document.location.href;
	_F.submit();
}*/

function loadPage(loc) {
	ajaxpack.getAjaxRequest(loc, "", loadContent, "txt");
	return false;
}

function loadContent() {
	var myajax=ajaxpack.ajaxobj
	var myfiletype=ajaxpack.filetype
	var thisPath = getPageName(window.location.href);
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
			if (myfiletype=="txt") { // het XML object
				$('contentsBox').innerHTML = myajax.responseText;
			}
		}
	}
}

function setFocus() {
	document.fZoekFormulier.dhfSearchvalue.focus();
}

function setTekst(obj, tekst) {
	var naam = obj.value;
	if (naam == tekst) {
		obj.value = '';
	} else if (naam == '') {
		obj.value = tekst;
	}
}

function getPath(){
	var path = new String(document.location);
	var start = path.lastIndexOf("/");
	return path.substring(start+1,path.length);
}
