// ======================================================================
// Scripte für Übersichtsseiten/Tabellen mit Banner
//	(c) by www.Traducer.de
// ======================================================================

// ----------------------------------------------------------------------
// VARIABLEN 
// ----------------------------------------------------------------------

// Vordefinitionen im Html-File
// = QC_Num

// Chart-Quick-View-Fenster
var WinSize = new Array(0,0);
var Win_qc = 0;
var WIN_QC = "left="+String(screen.width-310-50)+",top=23,location=no,menubar=no,resizable=yes,scrollbars=no,toolbar=no,status=no";
var QC_PICSIZE = new Array(2);
	QC_PICSIZE[0] = new Array(260,210);
	QC_PICSIZE[1] = new Array(260,210);
	QC_PICSIZE[2] = new Array(310,350);
var QC_WINOFFS = new Array(2);
	QC_WINOFFS[0] = 8;
	QC_WINOFFS[1] = 75;

// Hilfe-Fenster
var Win_h = 0;
var WIN_H = "width=350,left=5,height=430,top=23,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,status=no";


// ----------------------------------------------------------------------
// FUNKTIONEN
// ----------------------------------------------------------------------

function winparam_()
{
	var Par = new Array(2);
	
	Par[0] = QC_PICSIZE[parseInt(QC_Num)-1][0]+25;
	Par[1] = QC_PICSIZE[parseInt(QC_Num)-1][1]+120;
	
	return Par;
}


function winopen_(WinPar)
{
	var Win, WinPar2;
	
	WinPar2 = "width="+String(WinPar[0])+",height="+String(WinPar[1]);
	WinPar2 = WinPar2+","+WIN_QC;
	
	Win= window.open("","",WinPar2);
	
	return Win;
}


function qcwrite_(Win_qc,Title,Mode)
{
	with(Win_qc)
	{
		focus();
		document.open("text/html; charset=iso-8859-1");
		
		document.write("	<html><head>	");
		if (Mode == 0) {
			document.write("	<title>TRADUCER.de - Quick-Chart</title>	");
		} else {
			document.write("	<title>TRADUCER.de - ***Kopie***</title>	");
		}
		document.write("	</head>	");
		document.write("	<body style=\"background-image:url(../bg.gif); background-attachment:fixed;\"	");
		document.write("	bgcolor=\"#C8C8D7\" text=\"#06061C\" link=\"#042779\" vlink=\"#042779\" alink=\"#042779\">	");
		document.write("	<script language=\"JavaScript\" src=\"i/chart_1.js\" type=\"text/javascript\"></script>	");
		document.write("	<script language=\"JavaScript\" type=\"text/javascript\">var QC_Num= \""+QC_Num+"\";</script>	");
		document.write("	<p><a name=\"top\"></a></p>	");
		document.write("	<div align=\"left\">	");
		document.write("	<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"230\">	");
		document.write("		<tr>	");
		document.write("			<td style=\"background-image:url(../hs.gif)\"><font size=\"1\"	");
		document.write("			face=\"Times New Roman\">&nbsp;&nbsp;&nbsp;</font></td>	");
		document.write("		</tr>	");
		document.write("		<tr>	");
		document.write("			<td bgcolor=\"#C8C8D7\"><div align=\"center\"><center><table	");
		document.write("			border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">	");
		document.write("				<tr>	");
		document.write("					<td valign=\"bottom\" nowrap><font size=\"4\"	");
		document.write("					face=\"Arial\">&nbsp;&nbsp;</font></td>	");
		document.write("					<td align=\"right\" valign=\"bottom\"><font size=\"4\"	");
		document.write("					face=\"Arial\">&nbsp;&nbsp;</font></td>	");
		document.write("				</tr>	");
		document.write("				<tr>	");
		document.write("					<td align=\"center\" colspan=\"2\" width=\"100%\"><p	");
		document.write("					align=\"center\"><font face=\"Arial\"><img id=\"qchart\"	");
		if (Mode == 0) {
			// document.write("					onclick=\"window.close();\" src=\"../include/"+Title+"_c" +QC_Num+".gif\"	");
			document.write("					onclick=\"javascript:qchart2('"+Title+"');\" src=\"../include/"+Title+"_c" +QC_Num+".gif\"	");
			document.write("					align=\"top\" width=\""+QC_PICSIZE[parseInt(QC_Num)-1][0]+"\" height=\""+QC_PICSIZE[parseInt(QC_Num)-1][1]+"\"	");
			//~ document.write("					title=\"Zum Schließen auf den Chart klicken.\">	");
			document.write("					title=\"F&uuml;r eine Kopie des Fensters auf den Chart klicken.\">	");
		} else {
			document.write("					title=\"Quick-Chart-Kopie.\"	");
			document.write("					src=\"../include/"+Title+"_c" +QC_Num+".gif\">	");
		}
		document.write("					&nbsp;</font></p>	");
		document.write("					</td>	");
		document.write("				</tr>	");
		document.write("			</table>	");
		document.write("			</center></div></td>	");
		document.write("		</tr>	");
		document.write("		<tr>	");
		document.write("			<td style=\"background-image:url(../hs.gif)\"><font size=\"1\"	");
		document.write("			face=\"Times New Roman\"><code>&nbsp;&nbsp;&nbsp;</code></font></td>	");
		document.write("		</tr>	");
		document.write("		<tr>	");
		document.write("			<td style=\"font-size:0.7em;color:#042779;font-family:'Arial'\"><a href=\"http://www.traducer.de\" target=\"_blank\">www.Traducer.de</a>	");
		document.write("			<br>&copy; Harun Gebhardt Innovative Finanzmarktanalysen</td>	");
		document.write("		</tr>	");
		document.write("	</table>	");
		document.write("	</div>	");
		document.write("</body></html>");
		
		document.close();
	}
}


function info_()
{
	var Text = "";
	Text = Text+"Klicken Sie die Tabelle einfach anhand der Icons durch.\n\n";
	Text = Text+"Lassen Sie dabei das neue Quick-Chart-Fenster offen!\n\n";
	Text = Text+"Mit den Ziffern 1-2-3 können Sie jeweils den Kurs-Zeitraum wählen.\n\n";
	Text = Text+"Sie erhalten so schnell eine Uebersicht\noder können eine interessante Aktie herausfiltern.";
	alert(Text)
}


function qchart(Title)
{
	var WinPar;

	WinPar = winparam_();

	if (Win_qc == 0)
	{
		//~ info_();
		Win_qc = winopen_(WinPar);
		qcwrite_(Win_qc,Title,0);
	}
	else//if (Win_qc != 0)
	{
		if (Win_qc.closed)
		{
			Win_qc = winopen_(WinPar);
			qcwrite_(Win_qc,Title,0);
		}
		else//if (!Win_qc.closed)
		{
			qcwrite_(Win_qc,Title,0);
		}
	}
	return false;
}


function qchart2(Title)
{
	qcwrite_(winopen_(winparam_()),Title,1);

	return false;
}


function qchart_n(Num)
{
	var WinPar, Title;
	var ix = new Array(2);

	document.getElementById("qchart_n"+QC_Num).style.fontWeight="normal";
	QC_Num = Num;
	document.getElementById("qchart_n"+QC_Num).style.fontWeight="bold";
	
	if (Win_qc != 0)
	{
		if (!Win_qc.closed)
		{
			WinPar = winparam_();
			Win_qc.resizeTo(WinPar[0]+QC_WINOFFS[0],WinPar[1]+QC_WINOFFS[1]);
			
			Title = Win_qc.document.images[0].src;
			ix[0] = Title.lastIndexOf("/")+1;
			ix[1] = Title.search(/_c\d+\.gif/i);
			
			if (ix[0] != -1  &&  ix[1] != -1)
			{
				qchart(Title.slice(ix[0],ix[1]));
			}
		}
	}
}


function qcclose_()
{
	if (Win_qc && !Win_qc.closed) Win_qc.close();
}


function openhlp(Doku)
{
	Doku = "../misc/"+Doku+".htm";
	Win_h = window.open(Doku,'Hinweise',WIN_H);
	Win_h.focus();

	x_relbanner();
	
	if (Win_h) return false;
    else return true;
}


function x_relbanner()
{
	for(var ii = 0; ii <= document.images.length - 1; ii++)
	{
		if (document.images[ii].name.substr(0,6) == "banner")
		{
			document.images[ii].src = document.images[ii].src;
		}
	}
}


window.onunload = qcclose_;