/* Open help pages into pop-up window. Settings of pop-up window are defined in settings.js file. */
function OpenHelp(sLang, sContentUrl) {
	var url = "";

	var lang = getLang(sLang);
	var contentUrl = getUrlPart(sContentUrl);

	if (contentUrl != '') {
		url = '/help/' + lang + '/index.html?' + contentUrl;
	} else {
		url = '/help/' + lang + '/index.html';
	}

	var help = window.open(url, 'help', 'width=' + HelpWindowWidth + ',height=' + HelpWindowHeight + ',left=' + getLeftCoordinate(HelpWindowWidth) + ', top=' + getTopCoordinate(HelpWindowHeight) + 'menubar=no, resizable=1');
	help.top.focus();
}

/* Get content url path.
 Examples: index.html?options/access -> options/access.htm */
function getContentUrl() {
	var content = HelpDefaultContent;
	if (location.href.lastIndexOf("?") > 0) content = location.href.substring(location.href.lastIndexOf("?") + 1, location.href.length).replace(/:/g, "");
	return content + '.htm';
}

/* Get language. When lang paramatr is "cs" or "sk" function returns "cs", in other cases returns "en".
 Currently known languages: bg ; cs ; en ; fr ; de ; nl ; pt ; ro ; sk ; sl */
function getLang(lang) {
	if (lang && lang != '' && (lang == CS_LANG || lang == SK_LANG)) {
		return CS_LANG;
	} else {
		return OTHERS_LANG;
	}
}

/* Get part of content url.
 Examples: summary -> summary or client -> options/client */
function getUrlPart(sContent) {
	if (sContent && sContent != "") {
		for (var i = 0; i < HelpContents.length; i++) {
			if (sContent == HelpContents[i][0]) {
				return HelpContents[i][1];
			}
		}
	}
	return "";
}

/* Get left coordinate for open centered pop-up window. */
function getLeftCoordinate(iWidth) {
	return (screen.width) ? (screen.width - iWidth) / 2 : 0;
}

/* Get top coordinate for open centered pop-up window. */
function getTopCoordinate(iHeight) {
	return (screen.height) ? (screen.height - iHeight) / 2 : 0;
}

