blnOp = false;
blnIe = false;
blnNs = false;

function checkBrowser()
{
	if (window.opera)
	{
		blnOp = true;
	}
	else if (document.layers) 
	{
		blnNs = true;
	}
	else if (document.all)
	{
		blnIe = true;
	}
}
checkBrowser();
//--------------------------------
function open_window(url, name, breite, hoehe, center, scrollbar) {
	var features = 'location=no,menubar=no,resizable=yes,status=no,toolbar=no';
	if (scrollbar == 0) {
		features += ',scrollbars=no'
	} else {
		features += ',scrollbars=yes'
	}
	if (center == 1) {
		var left = (screen.width) ? (screen.width - breite) / 2 : 100;
		var top = (screen.height) ? (screen.height - hoehe) / 2 : 100;
		features += ',left=' + left + ',top=' + top;
	}
	features += ',width=' + breite + ',height=' + hoehe;
	window.open(url, name, features);
}
//--------------------------------
function deubaPopUp(stUrl, stName) {
	open_window(stUrl, stName, 650, 700, 1, 1);
}
//--------------------------------
function openNewWindow(strUrl) {
	var w = (screen.width) ? (screen.width - 100) : 800;
	var h = (screen.height) ? (screen.height - 250) : 600;
	window.open(strUrl, '_blank', 'height=' + h +',width=' + w + ',top=10,left=10,location=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes');
}
//--------------------------------
function changeProductpage(pageid) {
	if (pageid != '') {
		location.href = 'showpage.asp?pageid=' + pageid;
	}
}
//--------------------------------
function changeChart(index, time) {
	document.images['chart'].src = chartLinks[index][time];
	if (index != 'no_index')
	{
		document.getElementById(actual_index).className = '';
		document.getElementById(index).className = 'aktiv';
	}
	document.getElementById(actual_time).className = '';
	document.getElementById(time).className = 'aktiv';
	actual_index = index;
	actual_time = time;
}
//--------------------------------
function changeProductChart(index, time) {
	// unterbinden, dass beim time-wechsel, der index ausgewertet wird
	if (index != actual_index)
	{
		switch(index) 
		{
			case 'product':
				document.getElementById('underlying').className = 'aktiv';
				if (actual_index == 'underlying')
				{
					document.getElementById('product').className = 'aktiv';
					actual_index = 'both';
				}
				else
				{
					document.getElementById('product').className = '';
					actual_index = 'underlying';
				}
				break;
				
			case 'underlying':
				document.getElementById('product').className = 'aktiv';
				if (actual_index == 'product')
				{
					document.getElementById('underlying').className = 'aktiv';
					actual_index = 'both';
				}
				else
				{
					document.getElementById('underlying').className = '';
					actual_index = 'product';
				}
				break;
			default:
				break;
		}
	}
	else if (time == actual_time)
	{
		if (index == 'product')
		{
			actual_index = 'underlying';
		}
		else if(index == 'underlying')
		{
			actual_index = 'product';
			
		}
		document.getElementById(index).className = '';
		document.getElementById(actual_index).className = 'aktiv';
	}
	document.getElementById(actual_time).className = '';
	document.getElementById(time).className = 'emphased';
	document.getElementById(actual_time+'Perf').className = '';
	document.getElementById(time+'Perf').className = 'emphased';
	actual_time = time;
	document.images['chart'].src = chartLinks[actual_index][time];
}
//--------------------------------
function changeIRLayer(currency) {
	document.getElementById(actual_currency + '_link').className = '';
	document.getElementById(currency + '_link').className = 'aktiv';
	document.getElementById(actual_currency + '_layer').style.visibility = 'hidden';
	document.getElementById(currency + '_layer').style.visibility = 'visible';
	actual_currency = currency;
}
//--------------------------------
function showLayer(id)
{
	document.getElementById(id).style.visibility = 'visible';
}
function hideLayer(id)
{
	document.getElementById(id).style.visibility = 'hidden';
}

function showElement(objE)
{
	if (objE) {
		objE.style.visibility = 'visible';
	}
}
function hideElement(objE)
{
	if (objE) {
		objE.style.visibility = 'hidden';
	}
}
//--------------------------------
function setServerDate() {
	var actualClientTime = new Date();
	var elapsedTime = actualClientTime.getTime()-clientTime.getTime();
	actualServerTime = serverTime.getTime()+elapsedTime;
	setTimeout('setServerDate()',1000);
}
//--------------------------------
function clock(city,zone,showAmOrPm) {
	var digital = new Date(actualServerTime);
	var hours 	= digital.getHours() + parseInt(zone) + parseInt(sZone);
	var minutes = digital.getMinutes();
	var seconds = digital.getSeconds();
	var amOrPm 	= "AM";
	if (minutes<0) {
		minutes = 60 + minutes;
		hours	= hours -1;
	}
	if (minutes>=60) {
		minutes = minutes-60;
		hour	= hours+1;
	}
	if (minutes <= 9) minutes = "0" + minutes;
	
	if (hours >= 24) hours = hours-24;
	if (hours < 0) hours = hours+24;
	
	if (showAmOrPm) {
		if (hours == 0) hours = 12;
		if (hours >= 12) amOrPm = " PM"; else amOrPm = " AM";
		if (hours > 12) hours	= hours-12;
	} else {
		if (hours <= 9) hours = "0" + hours;
		amOrPm = "";
	}
	
	if (seconds <= 9) seconds = "0" + seconds;
	
	dispTime = hours + ":" + minutes + amOrPm ;
	document.getElementById(city).innerHTML = dispTime;
	setTimeout("clock('" + city + "'," + zone + "," + showAmOrPm + ")",1000);
}
//--------------------------------
function deleteInput(ref)
{
	if (blnClicked == false)
	{
		ref.value = '';
		blnClicked = true;
	}
}
//--------------------------------
function checkPassword(inputField)
{	
	//Im Quelltext muss arrKonfig als Array definiert werden mit Name der Elemente (Sicher, Mittel, Unsicher, Unbekannt)
	
	var testString = eval("document.frmProfile." + inputField + ".value");
	//Mindestlänge 6 Zeichen; Kleinbuchstaben, Großbuchstaben, Zahlen, Sonderzeichen
	var regExSicher = /^.*(?=.{6,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!§$%&?*+~#@<>]).*$/; 
	//Mindestlänge 6 Zeichen; Buchstaben und Zahlen
	var regExMediumSicher = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z a-z]).*$/;
	var i;
	
	for (i=0; i< arrKonfig.length;i++)
	{
		document.getElementById(arrKonfig[i]).style.display = "none";
	}
	
	// Wenn Passwort sicher ist
	if (regExSicher.test(testString))
	{
		document.getElementById(arrKonfig[0]).style.display = "inline";
	}
	else
	{
		//Wenn Passwort mittelsicher ist 
		if (regExMediumSicher.test(testString))
		{
			document.getElementById(arrKonfig[1]).style.display = "inline";
		}
		//Wenn Passwort unsicher ist
		else
		{
			document.getElementById(arrKonfig[2]).style.display = "inline";
		}
	}
}

//--------------------------------
// Funktionen, um Inhalts eines Divs dynamisch auf bestimmte Zeilenzahl zu beschränken
// und durch einen Link den "mehr"-Text anzuzeigen
//--------------------------------
var objDivElement;
var strOriginalInhalt;
var strKurzerInhalt;

function zeigeKurzenInhalt() {
	objDivElement.innerHTML = strKurzerInhalt;
}
//--------------------------------
function zeigeOriginalInhalt() {
	objDivElement.innerHTML = strOriginalInhalt;
}
//--------------------------------
function reduziereZeilen(strId, intZeilenZahl, intWorteProZeile, strMehrLink, strWenigerLink) {
	var arrMatches;
	var arrWorte;
	var i;
	var intHoehe;
	var intWortAnzahl = intZeilenZahl * intWorteProZeile;
	var intWorteZuviel;
	var intZeilenhoehe;
	var reAlleTags = /<[\s\S]*?>/gim;
	var reEnde = /(<\/p>)$/gim;
	var strInhalt;
	var strSpaces = '';
	var strSpacesBackup = '';
	var strWorte = '';
	var strWorteBackup = '';
	var blnZeigeWeniger = (strWenigerLink == '') ? false : true;

	if (document.layers) {
		objDivElement = document.layers[strId];
	} else {
		objDivElement = document.getElementById(strId);
	}
	// Ursprünglichen Inhalt des DIVs sichern
	strOriginalInhalt = objDivElement.innerHTML;
	strInhalt = strOriginalInhalt;
	// Alle Tags entfernen und Inhalt in einzelne Worte splitten
	arrMatches = strInhalt.match(reAlleTags);
	for (i = 0; i < arrMatches.length; i++) {
		strInhalt = strInhalt.replace(arrMatches[i], arrMatches[i].replace(' ', '###'));
	}
	arrWorte = strInhalt.split(' ');
	// DIV nur mit dem ersten Wort füllen, um die Zeilenhöhe zu ermitteln
	objDivElement.innerHTML = arrWorte[0].replace('###', ' ');
	if (document.layers) {
		intZeilenhoehe = objDivElement.document.height;
	} else {
		intZeilenhoehe = objDivElement.offsetHeight;
	}
	//Etwas weniger als die durchschnittliche Wortzahl und den mehr-Link einfügen.
	// Falls dies noch zu viele Worte sind, um nur drei Zeilen zu erhalten, die Wortzahl in 5er-Schritten verringern
	intWorteZuviel = 5;
	do {
		strWorte = '';
		for (i = 0; i < (intWortAnzahl - intWorteZuviel); i++) {
			strWorte += (i > 0 ? ' ' : '') + arrWorte[i].replace('###', ' ');
		}
		objDivElement.innerHTML = strWorte + '...&nbsp;<a href="javascript:vostrId();">' + strMehrLink + '</a>';
		if (document.layers) {
			intHoehe = objDivElement.document.height;
		} else {
			intHoehe = objDivElement.offsetHeight;
		}
	} while (intHoehe > (intZeilenhoehe * intZeilenZahl))
	// i enthält jetzt den Index des nächsten einzufügenden Wortes
	// Jetzt solange Worte hinzufügen, bis die vierte Zeile begonnen wird. Dabei immer den letzten Inhalt merken.
	do {
		strWorteBackup = strWorte;
		strWorte = strWorte + ' ' + arrWorte[i++].replace('###', ' ');
		objDivElement.innerHTML = strWorte + '...&nbsp;<a href="javascript:vostrId();">' + strMehrLink + '</a>';
		if (document.layers) {
			intHoehe = objDivElement.document.height;
		} else {
			intHoehe = objDivElement.offsetHeight;
		}
	} while (intHoehe < (intZeilenhoehe * (intZeilenZahl + 1)))
	// strWorteBackup enthält jetzt die richtige Anzahl an Worten.
	// Das DIV mit den Worten, dem mehr-Link und so vielen Spaces füllen, dass das Wort "mehr" ganz rechts steht
	do {
		strSpacesBackup = strSpaces;
		strSpaces = strSpaces + '&nbsp;';
		objDivElement.innerHTML = strWorteBackup + '...' + strSpaces + '<a href="javascript:vostrId();">' + strMehrLink + '</a>';
		if (document.layers) {
			intHoehe = objDivElement.document.height;
		} else {
			intHoehe = objDivElement.offsetHeight;
		}
	} while (intHoehe < (intZeilenhoehe * (intZeilenZahl + 1)))
	// p enthält jetzt die richtige Anzahl an Spaces.
	strKurzerInhalt = strWorteBackup + '...' + strSpacesBackup + '<a href="javascript:zeigeOriginalInhalt();">' + strMehrLink + '</a>';
	if (blnZeigeWeniger) {
		if (arrMatches = reEnde.exec(strOriginalInhalt)) {
			strOriginalInhalt = strOriginalInhalt.replace(reEnde, '&nbsp;<a href="javascript:zeigeKurzenInhalt();">' + strWenigerLink + '</a>' + arrMatches[0]);
		} else {
			strOriginalInhalt = strOriginalInhalt + '&nbsp;<a href="javascript:zeigeKurzenInhalt();">' + strWenigerLink + '</a>';
		}
	}
	zeigeKurzenInhalt();
}
//--------------------------------
