// DHTML Cross Objects Library
// Version 2.2d
// Updated: 2001-03-30
// copyright oestreicher & wagner
// ###################


if (document.location.href.indexOf("review") == -1) var rootvar = "//www.iii-investments.de/";
else var rootvar = "/iii/";

var ready = false;

function detectBrowser() {
	var agent	=	navigator.userAgent.toLowerCase();
	this.major	=	parseInt(navigator.appVersion);
	this.minor	=	parseFloat(navigator.appVersion);
	this.ns		=	((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns2	=	(this.ns && (this.major == 2));
	this.ns3	=	(this.ns && (this.major == 3));
	this.ns4	=	(this.ns && (this.major == 4));
	this.ns45	=	(this.ns && (this.minor >= 4.5));
	this.ns6	=	(this.ns && (this.major == 5));
	this.ns60	=	(this.ns && (this.major == 5) && (agent.indexOf("netscape6/6.0") != -1));
	this.ns61	=	(this.ns && (this.major == 5) && (agent.indexOf("netscape6/6.1") != -1));
	this.ie		=	(agent.indexOf("msie") != -1);
	this.ie3	=	(this.ie && (this.major == 2));
	this.ie4	=	(this.ie && (this.major >= 4));
	this.ie40	=	(agent.indexOf("msie4.0")!=-1 || agent.indexOf("msie 4.0")!=-1);
	this.ie401	=	(agent.indexOf("msie4.01")!=-1 || agent.indexOf("msie 4.01")!=-1);
	this.ie45	=	(agent.indexOf("msie4.5")!=-1 || agent.indexOf("msie 4.5")!=-1);
	this.ie5	=	(agent.indexOf("msie5")!=-1 || agent.indexOf("msie 5")!=-1);
	this.ie55	=	(agent.indexOf("msie5.5")!=-1 || agent.indexOf("msie 5.5")!=-1);
	this.ie6	=	(agent.indexOf("msie6")!=-1 || agent.indexOf("msie 6")!=-1);
	this.op3	=	(agent.indexOf("opera") != -1);
	this.win	=	(agent.indexOf("win")!=-1);
	this.win95	=	(agent.indexOf("windows95")!=-1 || agent.indexOf("windows 95")!=-1 || agent.indexOf("win95")!=-1);
	this.win98	=	(agent.indexOf("windows98")!=-1 || agent.indexOf("windows 98")!=-1 || agent.indexOf("win98")!=-1);
	this.winnt	=	(agent.indexOf("windows nt")!=-1 || agent.indexOf("winnt")!=-1);
	this.win2k	=	(agent.indexOf("windows nt 5")!=-1 || agent.indexOf("winnt 5")!=-1 || agent.indexOf("winnt5")!=-1);
	this.mac	=	(agent.indexOf("mac")!=-1);
	this.unix	=	(agent.indexOf("x11")!=-1);
	this.w3c	=	document.documentElement;

	return this;
}

// initialize browser object
var is = new detectBrowser();

// setting variable "typo" for css
// needs document.write command in HTML document and a folder with .css files
// otherwise netscape will crash!!

var csspath = "";
var visible		= (is.ns4) ? "show" : "visible";
var hidden		= (is.ns4) ? "hide" : "hidden";
preload = new Image();
preload.src = rootvar+"images/formbgmain.gif"	// for NS-MAC table background


function setCSS() {
	if (document.location.href.indexOf("review") == -1) csspath = rootvar;
	else {
		csspath = "";
		var temp = document.location.href.substr(document.location.href.indexOf(rootvar)+rootvar.length-1);
		while (temp.indexOf("/") != -1) {
			temp = temp.substr(temp.indexOf("/")+1);
			csspath += "../";
		}
		csspath = csspath+rootvar;
	}
	if (is.ns) {
		if (is.mac) var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/mac_ns.css" TITLE="style">';
		else if (is.unix) var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/unix_ns.css" TITLE="style">';
		else if (is.win && is.ns6) var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/ie.css" TITLE="style">';
		else var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/ns.css" TITLE="style">';
	} else if (is.ie) {
		if (is.mac) var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/mac_ie.css" TITLE="style">';
		else var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/ie.css" TITLE="style">';
	} else if (is.op3) {
		var typo = '<LINK REL=stylesheet TYPE="text/css" HREF="'+csspath+'css/op.css" TITLE="style">';
	}
	return typo;
}



function openDIV(id,left,top,width,height,zindex,visibility,cursor,mover,mout) {
	var propCursor	= (cursor != null)  ? ' cursor:'+cursor+';' 	: '';
	var propMOver	= (mover != null) ? ((is.ns4) ? ' onmouseover="'+mover+'"'	: ' onmouseover="'+mover+'"') 	: '';
	var propMOut	= (mout != null)  ? ((is.ns4) ? ' onmouseout="'+mout+'"'	: ' onmouseout="'+mout+'"') 	: '';

	if (is.ns4) var layer = '<layer name="'+id + '" position=absolute left='+left+' top='+top+' width='+width+' height='+height+' z-index='+zindex+' visibility='+visibility + propMOver+propMOut+'>\n';
	else var layer = '<div id="'+id+'" style="position:absolute; left:'+left+'px; top:'+top+'px; width:'+width+'px; height:'+height+'px; z-index:'+zindex+'; visibility:'+visibility+';'+propCursor+'"' + propMOver+propMOut+'>\n';

	return layer;
}

function closeDIV() {
	return (is.ns4) ? "</LAYER>\n" : "</DIV>\n";
}

function printpage() {
	if (!is.ie40 && !(is.ie && is.mac)) timer = setTimeout("self.print()",100);
	else alert("Ihr Browser unterstuetzt die gewaehlte Druckfunktion nicht. \nBitte waehlen Sie die Druckfunktion in Ihrer Menueleiste.");
}







// ###################
function makeEventObj() {
   	this.mCursor = eCursor;
}

function eCursor(e,cursor) {
	if (document.layers)	// NS4
	{
		if (cursor.toLowerCase() == 'x') return e.pageX;
		if (cursor.toLowerCase() == 'y') return e.pageY;
	}
	else if (document.all)	// IE 4+5
	{
		if (cursor.toLowerCase() == 'x') return window.event.clientX;
		if (cursor.toLowerCase() == 'y') return window.event.clientY;
	}
	else if ((document.getElementById)&&(is.ns6))	// only NS6
	{
		if (cursor.toLowerCase() == 'x') return e.pageX;
		if (cursor.toLowerCase() == 'y') return e.pageY;
	}
}
// initialize event object
//var oEvent = new makeEventObj();

// ###################
function makeLayerObj(param) {
	this.oArgLayerObj	=	new makeParamObj(makeLayerObj.arguments);
	this.totalpar		=	this.oArgLayerObj.mGetTotal();
	this.id				=	this.oArgLayerObj.mGetParam(0);
	this.mObject		=	cssObject;
	this.mObjStyle		=	cssObjStyle;
	this.mVisible		=	cssVisible;
	this.mGetVisible	=	cssGetVisible;
	this.mWriteText		=	cssWriteText;
	this.mLeft			=	cssLeft;
	this.mGetLeft		=	cssGetLeft;
	this.mTop			=	cssTop;
	this.mGetTop		=	cssGetTop;
	this.mMoveToXY		=	cssMoveToXY;
	this.mWidth			=	cssWidth;
	this.mGetWidth		=	cssGetWidth;
	this.mHeight		=	cssHeight;
	this.mGetHeight		=	cssGetHeight;
	this.mResizeXY		=	cssResizeXY;
	this.mAlignRight	=	cssAlignRight;
	this.mAlignBottom	=	cssAlignBottom;
	this.mZIndex		=	cssZIndex;
	this.mGetZIndex		=	cssGetZIndex;
	this.mBgColor		=	cssBgColor;
	this.mBgImage		=	cssBgImage;
	this.mLettSpace		=	cssLettSpace;
	this.mTextAlign		=	cssTextAlign;
	this.mToolTip		=	cssToolTip;
	this.mClipping		=	cssClipping;
	this.mGetClip		=	cssGetClip;
	return this;
}

// object containing entire root to layer
function cssObject() {
	if (document.layers) {
		if (this.totalpar > 1) {	// ==> NS4 nested structure
			var str = '';
			for (i=1;i<this.totalpar;i++) {
				str = str + "document['" + this.oArgLayerObj.mGetParam(i) + "'].";
			}
			return eval(str+'document[this.id]');
		} else
			return document.layers[this.id];
	}
	else if (document.all)
		return document.all(this.id)
	else if (document.getElementById)
		return document.getElementById(this.id)
	else
		return null;
}

// pure object with style property
function cssObjStyle() {
	elem = this.mObject();

	if (document.layers)	// NS 4
		styledLayer = elem;
	else if (document.all)	// IE 4+5
		styledLayer = elem.style;
	else if (document.getElementById)	// NS6, IE5
		styledLayer = elem.style;

	return styledLayer;
}

// hide or show a layer
function cssVisible(mode) {
	if (mode == 1)
		option = 'visible'
	else if (mode == 0)
		option = 'hidden'
	else
		option = 'inherit';

	this.mObjStyle().visibility = option;
}

// get visibility status
function cssGetVisible() {
	if (this.mObjStyle().visibility == 'visible')
		return true
	else
		return false;
}

// alter text within a layer
function cssWriteText(text) {
	if (document.layers)
	{
		this.mObject().document.open("text/html");		// open("text/html");
		this.mObject().document.write(text);
		this.mObject().document.close();
	}
	else if (document.all)
	{
		this.mObject().innerHTML = text;
	}
	else if (document.getElementById)
	{
		// no DOM but supported in NS6 though!
		// this.mObject().innerHTML = text;

		// with DOM
		range = document.createRange();
		elem = this.mObject();
		range.setStartBefore(elem);
		htmlFrag = range.createContextualFragment(text);
		while (elem.hasChildNodes())
			elem.removeChild(elem.lastChild);
			elem.appendChild(htmlFrag);
	}
}

// move layer xpos pixels from left
function cssLeft(xpos) {
	if ((is.mac) && (is.ie4)) xpos += "px";
	this.mObjStyle().left = xpos;
}

// get layer's left position
function cssGetLeft()
{
	return parseInt(this.mObjStyle().left);
}

// move layer ypos pixels from top
function cssTop(ypos) {
	if ((is.mac) && (is.ie4)) ypos += "px";
	this.mObjStyle().top = ypos;
}

// get layer's top position
function cssGetTop() {
	return parseInt(this.mObjStyle().top);
}

// move layer to (xpos,ypos)
function cssMoveToXY(xpos,ypos) {
	this.mLeft(xpos);
	this.mTop(ypos);
}

// set layer width
function cssWidth(width) {
	this.mObjStyle().width = width + 'px';
}

// get layer's width
function cssGetWidth() {
	return parseInt(this.mObjStyle().width);
}

// set layer height
function cssHeight(height) {
	this.mObjStyle().height = height + 'px';
}

// get layer's height
function cssGetHeight() {
	return parseInt(this.mObjStyle().height);
}

// resize layer
function cssResizeXY(width,height) {
	this.mWidth(width);
	this.mHeight(height);
}

// align layer on the right
function cssAlignRight(nsLayerWidth) {
	if (is.ns4)
		this.mLeft(size.mGetInnerWidth() - nsLayerWidth + 4);	// nsLayerWidth because NS4 does not deliver width after first load
	else if (is.ns6)
		this.mLeft(size.mGetInnerWidth() - this.mGetWidth() - 14);
	else
		this.mLeft(size.mGetInnerWidth() - this.mGetWidth());
}

// align layer on the bottom
function cssAlignBottom(nsLayerHeight) {
	if (is.ns4)
		this.mTop(size.mGetInnerHeight() - nsLayerHeight);	// nsLayerWidth because NS4 does not deliver width after first load
	else
		this.mTop(size.mGetInnerHeight() - this.mGetHeight());
}

// set the z-index of a layer
function cssZIndex(zindex) {
	this.mObjStyle().zIndex = zindex;
}

// get the z-index of a layer
function cssGetZIndex() {
	return 	this.mObjStyle().zIndex;
}

// layer's background color
function cssBgColor(bgcolor) {
	if ((document.all)||(document.getElementById))	// other but NOT NS4
	{
		this.mObjStyle().backgroundColor = bgcolor;
	}
	else if (document.layers)
	{
		this.mObjStyle().bgColor = bgcolor;	// bgColor is deprecated and only for NS4!!!
	}
}

// layer's background iamge
function cssBgImage(bgimage) {
	if ((document.all)||(document.getElementById))	// other but NOT NS4
	{
		this.mObjStyle().background = 'url('+bgimage+')';
	}
	else if (document.layers)
	{
		this.mObjStyle().background.src = bgimage;
	}
}

// space between a text's letters in a layer
function cssLettSpace(spacing) {
	this.mObjStyle().letterSpacing = spacing + 'px';
}

// align text in a layer
function cssTextAlign(direction) {
	this.mObjStyle().textAlign = direction.toLowerCase();
}

// make a tooltip out of a layer
function cssToolTip(text,e,x,y) {
	if ( (arguments.length == 2) || (arguments.length == 4) )
	{
		if (arguments.length == 2)
		{
			theBgColor   = 'background-color:#FFFF80; layer-background-color:#FFFF80; ';
			theFontColor = 'color:#000000';
		}
		if (arguments.length == 4)
		{
			theBgColor   = ' ';
			theFontColor = 'color:#FFFF80';
		}
		theStyle = 'border:10px; '+ theBgColor + theFontColor;
		theText = '<DIV STYLE="'+theStyle+'"><FONT FACE="verdana,arial" SIZE=1>&nbsp;'+text+'&nbsp;</FONT></DIV>';

		this.mWriteText(theText);
		//eval(root).eval("this.mWriteText(theText)");	// NS6 has problems with root

		if (arguments.length == 2)
		{
			this.mLeft(oEvent.mCursor(e,'X')+10);
			this.mTop(oEvent.mCursor(e,'Y')+10);
		}

		if (arguments.length == 4)
		{
			this.mLeft(x);
			this.mTop(y);
		}

		this.mObjStyle().visibility = 'visible';
		//var root = "top.window";
		//eval(root).eval("this.mObjStyle()").visibility = "visible";	// NS6 has problems with root
	}
	else if (arguments.length == 0)
	{
		this.mObjStyle().visibility = 'hidden';	// NS6 has problems with root
	}
	else
	{
		alert('Invalid arguments amount!\nShow tooltip: 5 arguments\nHide tooltip: 1 argument');
	}
}

// sets the clipping rectangle
function cssClipping(cliptop,clipright,clipbottom,clipleft) {
	if ((document.all)||(document.getElementById))	// other but NOT NS4
	{
		this.mObjStyle().clip = 'rect('+cliptop+'px '+clipright+'px '+clipbottom+'px '+clipleft+'px)';
	}
	else if (document.layers)
	{
		this.mObjStyle().clip.top    = cliptop;
		this.mObjStyle().clip.right  = clipright;
		this.mObjStyle().clip.bottom = clipbottom;
		this.mObjStyle().clip.left   = clipleft;
	}
}

// gets one of the 4 coordinates of a clipping rectangle
function cssGetClip(pos) {
	if (document.all)
	{
		if (pos.toLowerCase()=='top')
			return parseInt(this.mObject().currentStyle.clipTop)
		else if (pos.toLowerCase()=='right')
			return parseInt(this.mObject().currentStyle.clipRight)
		else if (pos.toLowerCase()=='bottom')
			return parseInt(this.mObject().currentStyle.clipBottom)
		else if (pos.toLowerCase()=='left')
			return parseInt(this.mObject().currentStyle.clipLeft);
	}
	else if ((document.getElementById)&&(is.ns6))
	{
		// NS6 return the whole rect as a string...
		var clipStr = this.mObjStyle().clip;
		// ...so I had to split up before returning a position
		clipStr		= clipStr.substring(clipStr.indexOf("(") + 1);
		top_pos		= parseInt(clipStr);
		clipStr		= clipStr.substring(clipStr.indexOf(" ") + 1);
		right_pos	= parseInt(clipStr);
		clipStr		= clipStr.substring(clipStr.indexOf(" ") + 1);
		bottom_pos	= parseInt(clipStr);
		clipStr		= clipStr.substring(clipStr.indexOf(" ") + 1);
		left_pos	= parseInt(clipStr);

		if (pos.toLowerCase()=='top')
			return parseInt(top_pos)
		else if (pos.toLowerCase()=='right')
			return parseInt(right_pos)
		else if (pos.toLowerCase()=='bottom')
			return parseInt(bottom_pos)
		else if (pos.toLowerCase()=='left')
			return parseInt(left_pos);
	}
	else if (document.layers)
	{
		if (pos.toLowerCase()=='top')
			return parseInt(this.mObject().clip.top)
		else if (pos.toLowerCase()=='right')
			return parseInt(this.mObject().clip.right)
		else if (pos.toLowerCase()=='bottom')
			return parseInt(this.mObject().clip.bottom)
		else if (pos.toLowerCase()=='left')
			return parseInt(this.mObject().clip.left);
	}
}


// ###################
function makeScreenObj() {
   	this.mGetScreenWidth	=	bwGetScreenWidth;
   	this.mGetScreenHeight	=	bwGetScreenHeight;
   	this.mGetInnerWidth		=	bwGetInnerWidth;
   	this.mGetInnerHeight	=	bwGetInnerHeight;
	return this;
}

function bwGetScreenWidth() {
	return eval(screen.availWidth);
}


function bwGetScreenHeight() {
	return eval(screen.availHeight);
}

function bwGetInnerWidth() {
	if (document.all)
		return document.body.clientWidth
	else
		return window.innerWidth;
}

function bwGetInnerHeight() {
	if (document.all)
		return document.body.clientHeight
	else
		return window.innerHeight;
}


// ###################
function makeFormObj(param)
{
	this.oArgFormObj = new makeParamObj(makeFormObj.arguments);
	this.totalpar		=	this.oArgFormObj.mGetTotal();					// read:  total parameters
	this.id				=	this.oArgFormObj.mGetParam(0);
	this.mFormObject	=	cssFormObject;
	this.mProp			=	cssProp;
	this.mReset			=	cssReset;
	this.mSubmit		=	cssSubmit;
	this.mValue			=	cssValue;
	this.mGetValue		=	cssGetValue;
	return this;
}

// object containing entire root to Form element
// when nested in a layer
function cssFormObject()
{
	if (document.layers)
	{
		if (this.totalpar > 1)	// ==> NS4 nested structure
		{
			var str = '';
			for (i=1;i<this.totalpar;i++)
			{
				str = str + "document['" + this.oArgFormObj.mGetParam(i) + "'].";
			}
			return eval(str+'document[this.id]');
		}
		else
			return document[this.id]
	}
	else if ( (document.all) || (document.getElementById) )
			return document[this.id]
	else
		return null;
}

// set or get the properties of a HTML element inside or outside a layer
function cssProp(htmlElem,arridx)
{
	// NS4:			document.divForm.document.formInside.fieldName.value
	// IE5/NS6:		document.formInside.fieldName.value

	//alert(   eval(this.mFormObject()['display'][0]).value   )
	if (arridx != null)
		return eval(this.mFormObject()[htmlElem][arridx])
	else
		return eval(this.mFormObject()[htmlElem])
}

// clear the form
function cssReset()
{
	this.mFormObject().reset();
}

// submit the form
function cssSubmit()
{
	this.mFormObject().submit();
}

// internal method to set value of an element
function cssValue(field,val)
{
	elem = this.mFormObject();
	eval(elem[field]).value = val;
}

// internal method to get value of an element
function cssGetValue(field)
{
	elem = this.mFormObject();
	return eval(elem[field]).value;
}



// ###################
function makeParamObj(param)
{
	this.paramrow	=	param;
	this.mGetTotal	=	argGetTotal;
	this.mGetParam	=	argGetParam;
	return this;
}

function argGetTotal()
{
	return this.paramrow.length;
}


function argGetParam(par_nr)
{
	return this.paramrow[par_nr];
}

// ###################
function makeURLObj(url_string)
{
	this.mGetURL			=	url_string;
	this.mGetSearchPos		=	this.mGetURL.indexOf('?');
	this.mGetURLLength		=	this.mGetURL.length;
	this.mGetSearchString	=	this.mGetURL.substring(this.mGetSearchPos + 1, this.mGetURLLength);
	this.mGetPair			=	uGetPair;
	this.mGetPairsCount		=	uGetPairsCount;
	this.mGetValue			=	uGetValue;
	return this;
}

// get the amount of pairs
function uGetPairsCount()
{
	return this.mGetSearchString.split('&').length;
}

// get a pair (key and value)
function uGetPair(pair_nr)
{
	return this.mGetSearchString.split('&')[pair_nr];
}

// get a value for a certain key
function uGetValue(keyname)
{
	var valuename = '';
	for (i=0;i<this.mGetPairsCount();i++)
	{
		if (keyname == this.mGetPair(i).split('=')[0])
			valuename = this.mGetPair(i).split('=')[1];
	}
	return valuename;
}


// ###################
function makeRootObj(aObjPath)
{
	this.path		=	aObjPath;	// array of layers
	this.mGetPath	=	pGetPath;
}

function pGetPath()
{
	if (document.layers)
	{
		var first = '';
		for (i=0;i<this.path.length;i++)
		{
			first = first + 'document.' + this.path[i] + '.';
		}
		var second = 'document';
		var fullpath = first + second;
		return eval(fullpath);
	}
	else
		return document;
}



// ###################
function toHex(dec) {
	hexChars = "0123456789ABCDEF";
	if (dec > 255) return null

	var dd = dec % 16;
	var cc = (dec -dd) / 16;
	var result = hexChars.charAt(cc);
	result += hexChars.charAt(dd);
	return result
}

function umlaute(arg) {
	arg = arg.replace(/ /g,'&nbsp;');
	return arg;
}

function makeUmlaute(arg) {
	return arg;
}


function umlaute2(arg) {
	arg = arg.replace(/ /g,'');
	return arg;
}
function umlToASCII(arg) {
	arg = arg.replace(/\&auml\;/g,'ae');
	arg = arg.replace(/\&Auml\;/g,'Ae');
	arg = arg.replace(/\&ouml\;/g,'oe');
	arg = arg.replace(/\&Ouml\;/g,'Oe');
	arg = arg.replace(/\&uuml\;/g,'ue');
	arg = arg.replace(/\&Uuml\;/g,'Ue');
	arg = arg.replace(/\&szlig\;/g,'ss');
	return arg;
}


function touml(arg) {
	return arg;
}

