function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//--------------------------------
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//--------------------------------
function allOff() {
	for (var i=0; i < arrLayer.length; ++i)
	{
		MM_showHideLayers(''+arrLayer[i],'','hide');
	}
}
//--------------------------------
function open_window(url, name, breite, hoehe, center, scrollbar, resizable) {
	var features = 'location=no,menubar=no,status=no,toolbar=no';
	if (scrollbar == 0) {
		features += ',scrollbars=no';
	} else {
		features += ',scrollbars=yes';
	}
	if (resizable == 0) {
		features += ',resizable=no';
	} else {
		features += ',resizable=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;
	popup_window = window.open(url, name, features);
	popup_window.focus();
}
//--------------------------------

function highlight(str) {
	var res = document.getElementById("content");
	var txt = res.innerHTML;
	var arr = txt.split(str);  // Split the search string based on your search term
	txt = arr.join("<font style='BACKGROUND-COLOR: #ffff00'><b>"+str+"</b></font>")  // Rejoin the array adding in the bold tags to form the new string....
	res.innerHTML = txt;
}

arrIndexParam = new Array(4);
arrIndexParam[0] = 'hsi';
arrIndexParam[1] = 'hsce';
arrIndexParam[2] = 'dji';
arrIndexParam[3] = 'ixic';
arrIndexParam[4] = '1';
arrIndexParam[5] = '5';
arrIndexParam[6] = '13';
arrIndexParam[7] = '16';
arrIndexParam[8] = '941';
arrIndexParam[9] = '2388';

arrTimeParam = new Array(4);
arrTimeParam[1] = '1w';
arrTimeParam[2] = '1m';
arrTimeParam[3] = '6m';
arrTimeParam[4] = '1y';

var intIndexAktiv = 0;
var intTimeAktiv = 4;
function changeChart(intIndex, intTime)
{
	if (intIndex > -1)
	{
		if (document.getElementById('links'+intIndexAktiv))
		{
			document.getElementById('links'+intIndexAktiv).style.visibility='hidden';
		}
		if (intIndex != 2 && intIndex != 3) {
			if (document.getElementById('links'+intIndex))
			{
				document.getElementById('links'+intIndex).style.visibility='visible';
			}
		}
		document.getElementById('index'+intIndexAktiv).className='';
		document.getElementById('index'+intIndex).className='aktiv';
		document.images['chart'].src = 'http://203.161.254.141/cgi-bin/chart/chart_' + arrTimeParam[intTimeAktiv]+ '.cgi?code=' + arrIndexParam[intIndex];
		intIndexAktiv = intIndex;
	}
	else
	{
		document.getElementById('time'+intTimeAktiv).className='';
		document.getElementById('time'+intTime).className='aktiv';
		document.images['chart'].src = 'http://203.161.254.141/cgi-bin/chart/chart_' + arrTimeParam[intTime]+ '.cgi?code=' + arrIndexParam[intIndexAktiv];
		intTimeAktiv = intTime;
	}
}
//--------------------------------
function openProductPage(strURL) {
	open_window(strURL,'dbpower_products_popup',1000,770,1,1,1);
}

//--------------------------------
function openBannerPopup(code) {
	open_window('http://203.161.254.141/cgi-bin/dbank/ucode_c.cgi?code=' + code,'dbpower_banner_popup',1000,770,1,1,1);
}

//--------------------------------
function changeDetailChart(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 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);
}
//--------------------------------
//simple Switch-Funktion für die Warrants /CBBC-Tabellen auf der Startseite

function switchTable(active_obj_id, inactive_obj_id, inactive_obj_id2) {
	document.getElementById(inactive_obj_id).style.display = "none";
	if (inactive_obj_id2 != null)
		document.getElementById(inactive_obj_id2).style.display = "none";
	document.getElementById(active_obj_id).style.display = "block";
}
//--------------------------------
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];
}