var dbpath,basepath,basepathmedien,basepathformulare,imgpath,intLangpos,nopermissionpath, notacceptedpath;
try
{
	var loc = new String(window.parent.document.location);
}catch (e)
{
	var loc = "";
}


dbpath = '/gkb/';
hostname= location.hostname;
basepath = '/gkb/home.nsf/';
basepathmedien = '/gkb/medien.nsf/';
basepathformulare = '/gkb/form.nsf/';
imgpath = '/gkb/medien.nsf/img/';
nopermissionspath = '/web/private';
notacceptedpath = '/web/ueberuns';
if (loc.indexOf("https://")!= -1)
{ 
	prefix         = "https://"; 
	imgpath        = prefix+hostname+imgpath;
	basepathmedien = prefix+hostname+basepathmedien;
}
 
// Remove outline around active links
// Needs to be called from body onLoad event
function buttonBlur() { 
	var lnks = document.links, i; 
	for (i = 0; i < lnks.length; ++i) { 
		//lnks[i].onclick = "this.blur()"; // non-DOM2 browsers like IE 
		lnks[i].onfocus = "this.blur()"; // non-DOM2 browsers like IE 
		//lnks[i].setAttribute("onclick", "this.blur()"); // DOM2 browser like NN7 
		lnks[i].setAttribute("onfocus", "this.blur()"); // DOM2 browser like NN7 
	}
} 
var windowopen = false;

function open_window(url,width,height,scroll)
{
if (windowopen) {
if (hwin.closed) {
hwin = window.open(url,"popup","alwaysRaised=yes,resizable=yes,scrollbars=no,width=" + width + ",height=" + height +","+ scroll);
} else {
hwin.location.href = url;
hwin.resizeTo(width,height);
hwin.focus();
}
} else {
hwin = window.open(url,"popup","alwaysRaised=yes,resizable=yes,scrollbars=no,width=" + width + ",height=" + height +","+ scroll);
windowopen = true;
}
}

function close_window()
{
if (windowopen) {
if (!hwin.closed)
hwin.close();
}
}
// create img tag
function writeimage(picturename)
{
document.write('<img src="' + imgpath + picturename + '" alt="" border="">')
}
// form image submit button
function writesubmitimage(picturename)
{
   var onclickaction = 'submit()';
   writesubmitimage2(picturename, onclickaction);
}
// form image submit button, with possibility to define onclick action
function writesubmitimage2(picturename, onclickaction)
{
   document.write('<input type="image" src="' + imgpath + picturename + '" alt="" border="" OnClick="' + onclickaction +'">')
}
// ceate a link to a mediendb document
function writemediendblink(file, linktext)
{
document.write('<a href="' + imgpath + file + '" alt="" target="_top">' + linktext + '</a>')
}
// ceate a link to a mediendb document - open link in a new window
function writemediendblink_newwindow(file, linktext, titleattributetext)
{
document.write('<a href="' + imgpath + file + '" title="' + titleattributetext + '" target="_blank">' + linktext + '</a>');
}
// get link from string ANYLINK#LANGUAGE
function getlinkfromstr(strText)
{
intLangpos = strText.indexOf("#");
if (intLangpos > 0) {
return strText.substr(0,intLangpos);
} else {
return strText;
}
}
// get language from string ANYSTRING#LANGUAGE
function getlangfromstr(strText)
{
intLangpos = strText.indexOf("#");
if (intLangpos > 0) {
return strText.substr(intLangpos + 1,2);
} else {
return "DE";
}
}
// create text link
function writelink(linkid,linktext)
{
document.write('<a class="contentlink" href="' + basepath + 'PageID/' + linkid + '"  target="_top">' + linktext + '</a>')
}
// create image link
function writeimagelink(linkid,imagename)
{
document.write('<a class="contentlink" href="' + basepath + 'PageID/' + linkid + '"  target="_top"><img src="' + imgpath + picturename + '" alt="" border=""></a>')
}
// create text link
function writefilelink(linkid,linktext,titleattributetext)
{
   var titleattribute = '';
   // add title attribute if the titleattribute text is set
   if (titleattributetext != undefined && titleattributetext != '') {
	titleattribute = ' title="' + titleattributetext + '" ';
   } 
document.write('<a class="contentlink" href="/gkb/medien.nsf/img' + '/' + linkid + '" target="_blank"' + titleattribute + ' >' + linktext + '</a>');
}
// create form link
function writeformlink(formid,linktext)
{
var strFormLink;
var strFormLanguage;
strFormLink = getlinkfromstr(formid);
strFormLanguage = getlangfromstr(formid);
document.write('<a class="contentlink" href="' + basepathformulare + strFormLink + '?ReadForm' + '&language=' + strFormLanguage + '"  target="_top">' + linktext + '</a>')
}
//---- Cookiefunction Bibliothek -----
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value) {
    document.cookie = name + "=" +escape(value) + ";path=/;";
}
// ------ zoom --------
function zoom(quelle, links, oben, bildbreite, bildhoehe, scrollen)
{
filelaenge = quelle.length;
pos = filelaenge - 1;
pos1 = quelle.charAt(filelaenge - 1);
pos2 = quelle.charAt(filelaenge - 2);
pos3 = quelle.charAt(filelaenge - 3);
endung = pos3 + pos2 + pos1;
if(endung == "jpg"  || endung == "jpeg" || endung == "gif"){
 eigenschaften = "left=" + links + ",top=" + oben + ",width=" + bildbreite + ",height=" + bildhoehe + ",resizable";
 inhalt = "<html><head><title>Zoom</title></head><body bgcolor='white' marginwidth='0' marginheight='0' topmargin='0' leftmargin='0'";
 inhalt += "><center><img id='bild' src='" + imgpath + quelle + "'>";
 inhalt += "</center></body></html>";
 fenster = window.open("", "", eigenschaften);
 fenster.document.open();
 fenster.document.write(inhalt);
 fenster.document.close();
 }
else
 {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(quelle, '" + id + "', 'resizable,scrollbars=" + scrollen + ",width=" + bildbreite + ",height=" +  bildhoehe + ",left=" + links + ",top=" + oben + "');");
 }
}
function mail(n,c,nolink) {
	var pre = "&#64;&#103;&#107;&#98;&#46;&#99;&#104;";
	if(n == "") {
		n = "info";
	}  
	if(c != "") {
		c = "class=\"" + c + "\" ";
	}
	if(nolink){
		document.write(n+pre);
	} else {
		document.write('<a '+c+'href=\"mailto:'+n+pre+'\" onFocus=\"if(this.blur)this.blur();\">'+n+pre+'</a>');
	}
}
function clearSearch(field){
var defaultString = "Suche";
	if(field.value == defaultString){
		field.value="";
		field.style.color="#000000";
	}
}
function submitSearch(){
var f = document.forms["searchForm"];
if (f.SearchString.value==""){ 
	return false;
}else{
	f.submit();
}
}
function removeMicrositeLinkTargets()
{
	var allHrefs = document.getElementsByTagName('A');
	var counter = 0;
	for (var i=0;i<=allHrefs.length-1;i++){
		if(allHrefs[i].id == "Microsite"){
			allHrefs[i].target = "_top"
		}
	}
} 
// Define bookmarks 
function bookmark() { 
	//***---This text will be shown to the visitor if it has Netscape. 
	netscape="Bitte drücken Sie in Ihrem Browser [Ctrl] + [D], um die Seite zu bookmarken." 
	if (navigator.appName=='Microsoft Internet Explorer') { 
		window.external.AddFavorite(location.href, document.title); 
 	} else if (window.sidebar) { // firefox
              window.sidebar.addPanel(document.title, location.href,"");
        }
 	else if (navigator.appName=='Netscape') 
 	{ 
 		alert(netscape); 
 	} 
} 
// ------------------------------------------------------------------
// scrollStart
// This function scrolls the page to the anchor named "contentStart"
// Call it with the scroll speed in milliseconds.
// Call it with the scroll speed speedms=0, then the default speed is
//  used.
// ------------------------------------------------------------------
function scrollStart(speedms)
{
		//scroll to anchor
		var defaultms = 500;
		if (speedms == 0) speedms = defaultms;
		var contentStart = $('#contentStart');
		$('html,body').animate({
		scrollTop: contentStart.offset().top
		}, speedms);
}

