// Copyright IT-Inspiration ApS, All rights reserved Worldwide
// Any change or copying of the below code without written concent from IT-Inspiration ApS is strictly forbidden. 
// Contact mail@it-inspiration.dk for details.
var strDatabasePath = "/webcm/pestikomv2.nsf/";
/**
 * 
 */
function showPrinterFriendly() {
	// compute the url for the printer friendly version
	var url = document.location.href;
	
	// cut out the view
	var start = url.indexOf("/0/");
	if (start > -1) {
		var url_first_part = url.substring(0, start);
		var url_second_part = url.substring(start+3);
		
		// create new url
		url = url_first_part + "/1/" + url_second_part;
		// call presenting function
		displayPrinterFriendly(url);
	} else {
		// call presenting function
		displayPrinterFriendly(url);
	}
}
/**
 * 
 */
function showEmailFriend() {
	// compute the url for the printer friendly version
	var url = document.location.href;
	
	// cut out the view
	var start = url.indexOf("/0/");
	if (start > -1) {
		var url_first_part = url.substring(0, start);
		var url_second_part = url.substring(start+3);
		
		// create new url
		url = url_first_part + "/2/" + url_second_part;
		// call presenting function
		displayEmailFriend(url);
	} else {
		// call presenting function
		displayEmailFriend(url);
	}
}
function showSitemapEntry(index) {
	try {
		var o = webcm_sitemap[index];
		primary = getLink(o);
		secondary = traverse(o, true);
		displaySitemapEntry(primary, secondary, o);
	} catch (exception) {
		// couldn't find the index - ignore
	}
}
var level = 0;
function traverse(m, ignore_first) {
	var html = "";
	
	if (!ignore_first) {
		level++;
		for (var i=1; i<level; i++) {
			html += "&nbsp;&nbsp;&nbsp;";
		}
		html += getLink(m) + "<br>";
	} else {
		ignore_first = false;
	}
	var child = m.getFirstChild();
	while (null != child) {
		html += traverse(child, ignore_first);
		child = m.getNextChild();
	}
	if (level > 0) {
		level--;
	}
	return html;
}
function getLink(m) {
	return "<a href=\"" + m.getURL() + "\" target=\"" + m.getTarget() + "\">" + m.getName() + "</a>";
}
function replaceCharacter(strSource, strSearchFor, strReplaceWith) {
	var strTarget = "";
	for (var i=0; i < strSource.length; i++) {
		if (strSource.substring(i, i+1) == strSearchFor) {
			strTarget = strTarget + strReplaceWith;
		} else {
			strTarget = strTarget + strSource.substring(i, i+1);
		}
	}
	return strTarget;
}
function showView() {
	try {
		// show view division
		var view = document.getElementById('$$ViewBody');
		view.style.visibility = 'visible';
		
		// hide no documents found message division
		var empty_view = document.getElementById('$$ViewBody_EmptyView');
		empty_view.style.visibility = 'hidden';
	} catch (exception) {
		
	}
}
function getObj(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	} else {
		return false;
	}
}
function mouseOverMenuItem(obj) {
	obj.style.cursor = 'hand';
}
function mouseOutMenuItem(obj) {
	obj.style.cursor = '';
}
function showMenuItems(divid) {
	// get the division to show/hide
	var div = getObj(divid + "_DIV");
	// get the image to change
	var img = getObj(divid + "_IMG");
	
	// did we get the objects ?
	if (!div) return;
	if (!img) return;
	// is the division current hidden to shown ?
	if (div.style.display == "block") {
		// it is shown so hide it
		div.style.display = "none";
		img.innerHTML = "<IMG SRC=\"" + strDatabasePath + "menu-plus.gif\" BORDER=0>";
	} else {
		// it is hidden so show it
		div.style.display = "block";
		img.innerHTML = "<IMG SRC=\"" + strDatabasePath + "menu-minus.gif\" BORDER=0>";
	}
}
