//This JS-File is loaded for all pages. It contains functions that are
//always or at least in 2 of the special JS-Files necessary. 
//LAST CHANGE: 16.02.2004
//BY: JF

//---------------------------------------------------------------------------------------------------------
// BEGINN determine browser
//---------------------------------------------------------------------------------------------------------
// recognize browser using DYNAPI function
function Browser() {
	var b=navigator.appName;
	if (b.indexOf('Netscape')!=-1) this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser.\nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6.0')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is=new Browser();
// --------------------------------------------------------
// End Determine Browser
// --------------------------------------------------------

// -------------------------------------------------------------------
// begin function reloadFrameset
// -------------------------------------------------------------------
// function is called to reload the frameset, 
// important on sites with frames and bookmarking on those sites
function reloadFrameset(){

var st_url='';
var st_parm='';
var i_pos;

if((top==self)&&(location.protocol!="file:")){
	st_url=location.href;
	
	i_pos=st_url.indexOf("&");
	if(i_pos<0){
		location.href="../fo-cms-web-framesetdefault?OpenForm&weblink="+webLinkName;
	}
	else {
		st_parm=st_url.substr(i_pos,st_url.length-i_pos);
		location.href="../fo-cms-web-framesetdefault?OpenForm&weblink=" + webLinkName + st_parm;
	}
}
};
// -------------------------------------------------------------------
// end function reloadFrameset
// -------------------------------------------------------------------

//---------------------------------------------------------------------------------
// BEGINN writeDynamicContent()
//---------------------------------------------------------------------------------
// similar to the writeNavCode-Function
// function to write the HTML Code of the navigation in the respective layer
// special writeNav for the 2nd navigation of Sparkasse Krefeld
// attributes:
// st_dynamicContent = HTML Code to write in the layer
// obj_layer = layer object to write in
function writeDynamicContent(st_dynamicContent, obj_layer)
{
	
	// fill the layer dependent on the browser type the website is surfed from
	if(is.ns){

		// Netscape 4.x
		if (is.ns4){
			
			obj_layer.document.clear();
			obj_layer.document.write(st_dynamicContent);
			obj_layer.document.close();
			
		}
		// Netscape 6
		else
		{
			// write html in Netscape 6 in an element (in this case a layer)
			// Netscape 6 doesn't know "innerHTML"
			// create range
		       	var range = document.createRange();
    			range.selectNode(obj_layer);
    			// create the html to paste into the corresponding element
    			var docFrag = range.createContextualFragment(st_dynamicContent);
    			obj_layer.appendChild(docFrag);

		}
		
	}
	// Internet Explorer
	else
	{
		obj_layer.innerHTML = st_dynamicContent;
	}

}

//---------------------------------------------------------------------------------
// END writeDynamicContent
//---------------------------------------------------------------------------------

// --------------------------------------------------------
// Begin Function URLAction
// --------------------------------------------------------
// function determins the urlaction dependent on the shortcut
// Attribute:
// shortcut = shortcut of the urlaction
// return value: urlaction
function getURLAction(shortcut){
	
	var urlAction;
	// lowercase urlAction
	shortcut = shortcut.toLowerCase();
	
	switch(shortcut)
	{
		case "ed":
		urlAction = "EditDocument";
		break;
		case "of":
		urlAction = "OpenForm";
		break;
		case "ov":
		urlAction = "OpenView";
		break;
		case "oa":
		urlAction = "OpenAgent";
		break;
		case "ld":
		urlAction = "LinkDocument";
		break;
		default:
		urlAction = "OpenDocument";
		break;
		}
	
	return urlAction;
};
// --------------------------------------------------------
// 							  End Function URLAction
// --------------------------------------------------------

// --------------------------------------------------------
// Begin Function switchPic
// --------------------------------------------------------
// function to switch the picture on special events
// for example onMouseover used with links
// attributes:
// Name = name of the picture
// divID = name of the layer
function switchPic(Name, divID){
	var modeOld;
	var parts;
	var modeNew;
	var extension;
	var path = '';
	var filename;
	var objImage;
					
	
	// determine objImage dependent on the browser
	// case Netscape
	if(is.ns)
	{
		if(is.ns4)
		{
			// Netscape 4
			objImage = eval('document.'+divID+'.document._Fo_TopNavi.bild_'+Name);
		}
		else
		{
			// Netscape 6
			objImage = eval('document.bild_'+Name);

		}
		
	}
	// Internet Explorer
	else
	{
		//objImage = eval('document.'+divID+'.document.bild_'+Name);
		objImage = eval('document.bild_'+Name);
	}
	
	
   	
	// parse source to determine name of graphic file and attachment 
	// ... and compose new name
	modeOld = objImage.src;
	parts = modeOld.split('.');
	extension = parts[parts.length - 1];	
	parts = parts[parts.length - 2].split('_');
	path = parts[0];
		
	for(i = 1; i < parts.length - 1; i++)
	{
		path = path + '_' + parts[i];
        };

	modeOld = parts[parts.length - 1];
	
	switch(modeOld)
	{
  		case "ou":
			modeNew = "ov";
   			break;
   		case "ov":
   			// do not switch top navigation picture for selected main category
			/*if (leaveHighlighted(Name)){
	   			modeNew = "ov";   			
   			}
   			else {
   				modeNew = "ou";
   			}*/
   			
   			modeNew="ou";
   			break;
   	};
   	
	if (modeOld != modeNew)
		{
   		parts = path.split('/');
   		filename =  parts[parts.length - 1] + '_' + modeNew + '.' + extension;
   		path = 'vwweb/' + filename + '/$file/' + filename;
		
		// put new value for path in image object
		objImage.src=path;
	}
};
// --------------------------------------------------------
// 				     End Function switchPic
// --------------------------------------------------------

//---------------------------------------------------------------------------------
// BEGINN getLayer(st_layername, st_framename)
//---------------------------------------------------------------------------------
// function to define the layerobject dependent on the browser
// Attributes:
// st_layername = the layername of the layer that you want the object from
// st_framename = the framename in which the layer is positioned
// return value: layer object
function getLayer(st_layername, st_framename)
{
	var obj_layer;
	
	// get the layer to use it everytime, it is needed
	if(is.ns)
	{
		// case: browser = Netscape 4.x
		if(is.ns4)
		{
			obj_layer = parent.frames[st_framename].document.layers[st_layername];
		}
		// case: browser = Netscape 6.x
		else
		{
			obj_layer = eval('document.getElementById("'+ st_layername + '")');
			//obj_layer = eval('document.getElementsByName("'+ st_layername + '")[0]');
		}
		
		
	}
	// case: browser = Internet Explorer and Opera at the moment
	else
	{
		obj_layer = eval("parent.frames['" + st_framename + "'].document.all." + st_layername);
	}
	
	return obj_layer;

}
//---------------------------------------------------------------------------------
// 									END getLayer(st_layername, st_framename)
//---------------------------------------------------------------------------------

//---------------------------------------------------------------------------------
// BEGINN getLayerPosition(st_layername, st_framename)
//---------------------------------------------------------------------------------
// function to get the position 'st_layerposition' of the layer 'st_layername'
// in the frame 'st_framename'
// Attributes:
// st_layername = the layer that you want to define the position from
// st_framename = the frame where the layer is defined in
// return value: position as integer
function getLayerPosition(st_layername, st_framename)
{
	var i_layerTopPositionValue;
	var i_layerBottomPositionValue;
	var i_layerHeight;
	// variable for layer object
	var obj_layer;
	
	// get layer object
	obj_layer = getLayer(st_layername, st_framename);
	
	// case Browser = Netscape
	if(is.ns)
	{
		// Netscape 4
		if(is.ns4)
		{
			// gets the top postition --> bottom not valid
			i_layerTopPositionValue = obj_layer.top;
			
			// get the actual height of the layer	
			i_layerHeight = obj_layer.document.height;
		}
		// Netscape 6
		else
		{
			// gets the top postition --> bottom not valid
			i_layerTopPositionValue = obj_layer.style.top;
			
			// get the actual height of the layer	
			i_layerHeight = obj_layer.offsetHeight;
			
			// change string into number
			i_layerTopPositionValue = parseInt(i_layerTopPositionValue);
		}
		
		
	}
	// case Browser = Internet Explorer
	else
	{
		// gets the top postition --> bottom not valid
		i_layerTopPositionValue = obj_layer.style.top;
		
		// change string into number
		i_layerTopPositionValue = parseInt(i_layerTopPositionValue);
		
		// get the actual height of the layer	
		i_layerHeight = obj_layer.offsetHeight;
		
	}
	
	// calculate bottom value of the layer
	i_layerBottomPositionValue = i_layerTopPositionValue + i_layerHeight;
	
	return i_layerBottomPositionValue;


}
//---------------------------------------------------------------------------------
// END getLayerPosition
//---------------------------------------------------------------------------------

//---------------------------------------------------------------------------------
// BEGINN setLayerPosition(st_layername, st_framename, i_positionToSet)
//---------------------------------------------------------------------------------
// function to set the position 'st_layerposition' of the layer 'st_layername'
// in the frame 'st_framename' with the value of 'i_positionToSet'
// Attributes:
// st_layername = the layer that you want to define the position from
// st_framename = the frame where the layer is defined in
// i_positionToSet = the value 'st_layerPosition' should get
// return value: position as integer
function setLayerPosition(st_layername, st_framename, i_positionToSet)
{
	// variable for layer object
	var obj_layer;
	
	// get layer object
	obj_layer = getLayer(st_layername, st_framename);
	i_positionToSet = i_positionToSet + 5;	
	
	
	// case Browser = Netscape
	if(is.ns)
	{
		// Netscape 4
		if(is.ns4)
		{
			// sets the top postition
			obj_layer.top = i_positionToSet;
		}
		// Netscape 6
		else
		{
			
			// sets the top postition
			obj_layer.style.top = i_positionToSet;
		}
		
		
	}
	// case Browser = Internet Explorer
	else
	{
		// get String of the position variable
		i_positionToSet = String(i_positionToSet);		

		// sets the top postition
		obj_layer.style.top = i_positionToSet;
	}

}
//---------------------------------------------------------------------------------
// END setLayerPosition
//---------------------------------------------------------------------------------

// NEED TO BE CHECKED FOR THE LAST PARAMETER
//---------------------------------------------------------------------------------
// Beginn Function buildLink()
//---------------------------------------------------------------------------------
// function that builds the following parts of the link: href, target
// attributes:
// st_link = link that should be referenced (unique name of the document in the cms)
// st_linkExt = external link for linkdocuments only, defines which url or document in the
//		   	 cms is referenced by the linkdocument
// st_navCat = category of the current document
// st_urlAction = shortcut that determines with which urlcommand the document 
//			   has to be opened
// st_target = target that defines in which frame/window the link has to be opened
// st_discl = "1" or "0", defines whether a disclaimer should appear before an
//		    external link is opened or not
// st_sourceOfCall = defines the source from which this function was called 
//				 (possibilities are: side_navi, fork)
// st_isForkDocument = "1" or "0", defines if the current document is a fork document
//				   or not 
//				   --> probably not necessary anymore (navCat is for forkpages 
//			        and other document types that are shown at the same level the same 
//				   --> because navCat of forkpage is shorten by 1 element), must be checked, 
//				   after the problem with documents in more than one category is solved
// return value: html-code for the link
function buildLink(st_link, st_linkExt, st_navCat, st_urlAction, st_target, st_discl, st_sourceOfCall, st_isForkDocument)
{
	var ast_categoryArray;
	var i_documentLevel;
	var st_linkHTMLCode = "";
	
	// switch urlAction to lower case
	st_urlAction = st_urlAction.toLowerCase();
	
	//-----------------------------------------------------------------------------------
	// determine the level of the current document based on the variables "st_navCat" and
	// "st_isForkDocument" as forkdocuments that appear on the same level as other documents
	// have one "*" more in their category
	//-----------------------------------------------------------------------------------
	// split the category based on "*" to determine on this basis the level
	ast_categoryArray = st_navCat.split("*");
	
	if(st_isForkDocument=="1")
	{
		i_documentLevel = ast_categoryArray.length-1;
	}
	else
	{
		i_documentLevel = ast_categoryArray.length;
	}
	
	// if the function was called by the navigation, the level cannot be greater than 4
	// if level is greater than 4 (possible for forkdocuments on the 4th level) set the
	// level back to 4
	if(i_documentLevel>4 && st_sourceOfCall == "side_navi")
	{
		i_documentLevel = 4;
	}
	//-----------------------------------------------------------------------------------
	//													den determine level
	//-----------------------------------------------------------------------------------
	
	
	//-----------------------------------------------------------------------------------
	// write links in the case a disclaimer should appear before opening the link
	// can only be for linkdocuments with external links
	//-----------------------------------------------------------------------------------
	if(st_discl=="1")
	{
		// write frameset new for all entries that aren't deeper than 4th level
		// so that the navigation is actual
		if(i_documentLevel<=4)
		{
	//......................Change 18.2.2004 Coop Finkbeiner & Reulen
	//		st_linkHTMLCode += 'href="../fo-cms-web-framesetdefault?OpenForm';
	//		st_linkHTMLCode += '&weblink=' + st_link + '&cat=' + st_navCat;
	//		st_linkHTMLCode += '&ua=' + st_urlAction + '&discl=' + st_discl;
	//		st_linkHTMLCode += '&extlink=' + st_linkExt;
	//		st_linkHTMLCode += '" target="_top"';
	//.....................neu
			st_linkHTMLCode += 'href="' + st_linkExt;
			st_linkHTMLCode += '" target="content"';
			st_linkHTMLCode += '" onClick="hinweis();"';


		}
		// for all levels below level 4 open the disclaimer in the contentframe of
		// the current window, navigation doesn't change
		else
		{
			st_linkHTMLCode += 'href="../vwweb/' + st_link;
			st_linkHTMLCode += '" target="content"';
		}
		
	}
	//-----------------------------------------------------------------------------------
	// 											....end write disclaimer links
	//-----------------------------------------------------------------------------------
	//-----------------------------------------------------------------------------------
	// write "normal" links in the case no disclaimer should appear
	//-----------------------------------------------------------------------------------
	else
	{
		// differentiate the writing of the link based on the target that was chosen
		// by the author of the document
		switch(st_target)
		{
			//--------------------------------------------------------------------
			// case loading frameset new to make the navigation actual
			//--------------------------------------------------------------------
			case "center":
			
			// check the level of the document to ensure that no documents below level 4
			// are loaded in the frameset as navigation doesn't change below this level;
			// and documents below level 4 should only be opened in the content frame
			if(i_documentLevel<=4)
			{
				
				// st_linkHTMLCode += 'href="../fo-cms-web-framesetdefault?OpenForm';  ...... changed CR 12.3.2004
				st_linkHTMLCode += 'href="../fo-cms-web-FSMain?OpenForm';
				st_linkHTMLCode += '&weblink=' + st_link + '&cat=' + st_navCat;
				st_linkHTMLCode += '&ua=' + st_urlAction + '&discl=' + st_discl;
				st_linkHTMLCode += '&extlink=' + st_linkExt;
				st_linkHTMLCode += '" target="center"';
			}
			// the document is a document deeper than level 4 and should only be loaded
			// in the contentframe; the author chose a wrong target
			else
			{
				
				// differ between link and non link documents
				if(st_urlAction=="ld")
				{
					st_linkHTMLCode += 'href="' + st_link;
					st_linkHTMLCode += '" target="content"';
				}
				else
				{
					st_linkHTMLCode += 'href="../vwweb/' + st_link;
					st_linkHTMLCode += '?' + getURLAction(st_urlAction);
					st_linkHTMLCode += '" target="content"';
				}
				
			}
			break;
			//--------------------------------------------------------------------
			
			//--------------------------------------------------------------------
			// case opening the link in the contentframe
			// navigation doesn't change
			//--------------------------------------------------------------------
			case "content":

			// differ between link and non link documents
			if(st_urlAction=="ld")
			{
				st_linkHTMLCode += 'href="' + st_link;
				st_linkHTMLCode += '" target="content"';
			}
			else
			{
				st_linkHTMLCode += 'href="../vwweb/' + st_link;
				st_linkHTMLCode += '?' + getURLAction(st_urlAction);
				st_linkHTMLCode += '" target="content"';
			}

			break;
			//--------------------------------------------------------------------
			
			//--------------------------------------------------------------------
			// all other cases, should only apply for external targets which means
			// that a new window is opened with the link
			//--------------------------------------------------------------------
			default:

			// differ between link and non link documents
			if(st_urlAction=="ld")
			{
				st_linkHTMLCode += 'href="' + st_link;
				st_linkHTMLCode += '" target="' + st_target + '"';
			}
			else
			{
				st_linkHTMLCode += 'href="../vwweb/' + st_link;
				st_linkHTMLCode += '?' + getURLAction(st_urlAction);
				st_linkHTMLCode += '" target="' + st_target + '"';
			}

			break;
			//--------------------------------------------------------------------
		}
		
	}
	//-----------------------------------------------------------------------------------
	// 											....end write "normal" links
	//-----------------------------------------------------------------------------------
	
	return st_linkHTMLCode;
	
}
//---------------------------------------------------------------------------------
// 											END Function buildLink()
//---------------------------------------------------------------------------------


// --------------------------------------------------------
// OLD: new function = writeDynamicContent
// begin Function writeNavcode
// --------------------------------------------------------
/*function writeNavcode(navCode, divID){
	eval('document.all.' + divID + '.innerHTML = navCode');
};*/
// --------------------------------------------------------
// 				  		    ...end Function writeNavcode
// --------------------------------------------------------


// --------------------------------------------------------
// begin Function ske_print()
// --------------------------------------------------------
function ske_print() 
{
	if (document.all) 
	{
		var OLECMDID_PRINT = 6; 
		var OLECMDEXECOPT_DONTPROMPTUSER = 2; 
		var OLECMDEXECOPT_PROMPTUSER = 1; 
		var WebBrowser = "<object id='WebBrowser1' width=0 height=0 classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"; 
		document.body.insertAdjacentHTML("beforeEnd", WebBrowser); 
	        WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER); WebBrowser1.outerHTML 
        	= "";
     }
     else
     {
    		self.print();
     }
     
}
// ----------------------------------------------------------
//   				  		    ...end Function ske_print()
// ----------------------------------------------------------

// --------------------------------------------------------
// begin Function popup()
// --------------------------------------------------------
function popup(src,width,height,features){
	var xwidth='width='+width;
	var xheight=',height='+height+',';
	var myfeatures=xwidth+xheight+features+',top=280,left=175';
	var myXtrawin=open(src,"myXtrawin",myfeatures);
	myXtrawin.focus();
	return false;
}
// ----------------------------------------------------------
// 				  		    ...end Function popup()
// ----------------------------------------------------------


// --------------------------------------------------------
// begin Function hinweis()
// --------------------------------------------------------

function hinweis ()
{
alert ("Durch Anklicken dieses Links verlassen Sie das Angebot der Sparkasse Krefeld . Fuer den Inhalt aller folgenden Seiten ist der jeweilige Anbieter verantwortlich. Die Sparkasse Krefeld uebernimmt insoweit keine Haftung. Die Bereitstellung der Verlinkungen ist ein Service der Sparkasse Krefeld.")
}
// ----------------------------------------------------------
// 				  		    ...end Function hinweis()
// ----------------------------------------------------------

// --------------------------------------------------------
// begin Function golinkhinweis()
// --------------------------------------------------------

function golinkhinweis (st_src,st_width,st_height)
{
	alert ("Durch Anklicken dieses Links verlassen Sie das Angebot der Sparkasse Krefeld . Fuer den Inhalt aller folgenden Seiten ist der jeweilige Anbieter verantwortlich. Die Sparkasse Krefeld uebernimmt insoweit keine Haftung. Die Bereitstellung der Verlinkungen ist ein Service der Sparkasse Krefeld.")
	var xwidth='width='+st_width;
	var xheight=',height='+st_height+',';
	var myfeatures=xwidth+xheight+',resizable=yes,scrollbars=yes';
	var myXtrawin=open(st_src,"myXtrawin",myfeatures);
	myXtrawin.focus();
	return false;
}
// ----------------------------------------------------------
// 				  		    ...end Function golinkhinweis()
// ----------------------------------------------------------

// --------------------------------------------------------
// begin Function dynwin()
// --------------------------------------------------------

function dynwin (st_src,st_width,st_height)
{
	var xwidth='width='+st_width;
	var xheight=',height='+st_height+',';
	var myfeatures=xwidth+xheight+',resizable=yes,scrollbars=yes';
	var myXtrawin=open(st_src,"myXtrawin",myfeatures);
	myXtrawin.focus();
	return false;
}
// ----------------------------------------------------------
// ...end Function dynwin()
// ----------------------------------------------------------
// ------------------------------------------------------------
// Ausklappbarer-Text-Funktion
// -----------------------------------------------------------
// --------------------------------------------------------
// begin Function doAusklappen(ausklapp,einklapp,text)
// ausklapp 
// --------------------------------------------------------
function doAusklappen(ausklapp,einklapp,text) {
var x_ausklapp = ausklapp;
var x_einklapp = einklapp;
var x_text = text;
if(document.getElementById) document.getElementById(x_einklapp).style.display = "inline"; // " Schaltfläche Ausklappen - SICHTBAR
if(document.getElementById) document.getElementById(x_ausklapp).style.display = "none";  // " Schaltfläche einklappen # unsichtbar
if(document.getElementById) document.getElementById(x_text).style.display = "inline";   // " Text - SICHTBAR
}
// --------------------------------------------------------
// begin Function doEinklappen(ausklapp,einklapp,text)
// --------------------------------------------------------
function doEinklappen(ausklapp,einklapp,text) {
var x_ausklapp = ausklapp;
var x_einklapp = einklapp;
var x_text = text;
if(document.getElementById) document.getElementById(x_einklapp).style.display = "none";     // " Schaltfläche Ausklappen # unsichtbar
if(document.getElementById) document.getElementById(x_ausklapp).style.display = "inline";  // " Schaltfläche einklappen # unsichtbar
if(document.getElementById) document.getElementById(x_text).style.display = "none";       // " Text - unsichtbar
}
// ------------------------------------------------------------
//                                                ....END Ausklappbarer-Text-Funktion
// -----------------------------------------------------------


