//////////////////////////////////////////////////////////////////////////////
//
//  general.js
//
//  written by Christian Daehn (c) Germany 2000-2001
//
//  This script needs some variables of main.js!
//  Be sure to bind in main.js BEFORE this script!
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////
// function init()
//
// -> init document
//
function init()
{
  // if no frameset, reload the frameset
  window.defaultStatus = statusText;		// set default status text
}

function openMenu(page, menu_index) {
  parent.frames[3].location.href=page;
  if (menu_index > 0) parent.frames[2].location.href='layout/top'+menu_index+'.html';
  else parent.frames[2].location.href='layout/top.html';
}

////////////////////////////
// function getUpdateStr()
//
// -> show date of last update
//
function getUpdateStr()
  { ogetUpdateStr(window); }

function ogetUpdateStr(object)
  { object.document.writeln('\n' + updateStr + '\n');}

///////////////////////
// function swapPic()
//
// -> swap images of current document
//
function swapPic(picnum, imgname)
{
  // window.alert('picnum = '+picnum);
  window.document.images[picnum].src = imgname;
}

//////////////////////////
// function selectMenu()
//
// -> select menu entry and show it highlighted
//
function selectMenu(picnum)
{
  if (selectedMenu != picnum)
    swapPic((picnum+existingImages), menu_img[picnum]+'s.gif');
  else
    swapPic((picnum+existingImages), menu_img[picnum]+'a.gif');
}

////////////////////////////
// function unselectMenu()
//
// -> unselect Menu and show it 'normal'
//
function unselectMenu(picnum)
{
  if (picnum != selectedMenu) {
    swapPic((picnum+existingImages), menu_img[picnum]+'.gif');
  }
}

////////////////////////////
// function activateMenu()
//
// -> select given Menu and display menu item highlighted
//
function activateMenu(picnum)
{
  selectedMenu=picnum;
  for (i=0; i < maxMenuEntries; i++) {
    unselectMenu(i);
  }
  selectMenu(selectedMenu);
}


///////////////////////
// function setGoTo()
//
// -> set link inside document
//
function setGoTo(gotoStr)
  { osetGoTo(window, gotoStr); }

function osetGoTo(object, gotoStr)
{
  object.document.write('\n<a name=\"' + gotoStr + '\"></a>\n');
}

/////////////////////////
// function showGoTop()
//
// -> set link to top of page
//
function showGoTop(topStr)
  {
 oshowGoTop(window, topStr); }

function oshowGoTop(object, topStr)
{
  object.document.write('<br>\n<div align=right>\n\t<a href=\"#top\"><b>' + ((topStr) ? topStr : 'Top') + '</b></a>\n</div>\n<p>\n');
}

/////////////////////////
// function showTitle()
//
// -> show titlebar
//
function showTitle(titleStr,tcolor,tbgcolor,framecolor)
  {
 oshowTitle(window, titleStr,tcolor,tbgcolor,framecolor); }

function oshowTitle(object, titleStr,tcolor,tbgcolor,framecolor)
{
  var Str = '<p>\n<table cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">\n<tr>\n\t' + '<td valign=\"center\" align=center bgcolor=\"' + 
		 ((framecolor) ? framecolor : table_bgcolor) + '\">\n\t\t' + '<table cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">\n\t\t<tr>\n\t\t\t<td valign=\"center\" align=center bgcolor=\"' + 
		 ((tbgcolor) ? tbgcolor : table_bgcolor) + '\">\n\t\t\t\t' + '<font face=\"Arial,Helvetica,Verdana\" size=\"3\" color=\"' + ((tcolor) ? tcolor : table_color) + '\"><b>' + titleStr + 
		 '</b></font><br>\n\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t</td>\n</tr>\n</table>\n<p>\n';
  object.document.write(Str);
}



//////////////////////////
// function buildTable()
//
// -> build a table with given text array
//
function buildTable(tableTitle, tableTxt, enableList)
  {
 obuildTable(window, tableTitle, tableTxt, enableList)
; }

function obuildTable(object, tableTitle, tableTxt, enableList)
{
  var Str1 = '\n<table bgcolor=\"' + table_bgcolor + '\" cellspacing=\"0\" border=\"0\">\n<tr>\n\t' +
             '<td align=center>\n\t\t<font face=\"Arial,Helvetica\" color=\"' + table_color + '\" size=\"3\">' + 
             tableTitle + '</font>\n\t</td>\n</tr>\n<tr>\n\t<td>\n\t\t<table bgcolor=\"' + table_bgcolor + 
             '\" cellspacing=\"1\" cellpadding=\"5\" border=\"0\" width=\"100%\">\n\t\t<tr>\n\t\t\t<td bgcolor=\"' + 
             tabletext_bgcolor + '\">\n\t\t\t\t<font face=\"Arial,Helvetica\" size=\"2\">\n\t\t\t\t';
  var Str2 = '';
  var Str3 = '</font>\n\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t</td>\n</tr>\n</table>\n';

  for (i=0; i < tableTxt.length; i++) {
    if (enableList)  Str2 += '- ' + tableTxt[i] + '&nbsp;\n\t\t\t\t<p>\n\t\t\t\t';
    else  Str2 += tableTxt[i] + '<br>\n\t\t\t\t';
  }
  object.document.write(Str1+Str2+Str3);
}


//////////////////////////////
// function buildWideTable()
//
// -> build a table with given text array
//
function buildMultiTable(tableTitle, columnTitle, columnTxt, alignRight)
  {
 obuildMultiTable(window, tableTitle, columnTitle, columnTxt, alignRight); }

function obuildMultiTable(object, tableTitle, columnTitle, columnTxt, alignRight)
{
  if (columnTitle.length != columnTxt.length) 
    alert("Warning: buildMultiTable() detected wrong params!");

  var Str1 = '\n<table bgcolor=\"' + table_bgcolor + '\" cellspacing=\"0\" cellpadding=\"1\" border=\"0\">\n<tr>\n\t' +
             '<td align=center>\n\t\t<font face=\"Arial,Helvetica\" color=\"' + table_color + '\" size=\"3\">' + tableTitle +
             '</b></font>\n\t</td>\n</tr>\n<tr>\n\t<td>\n\t\t<table bgcolor=\"' + table_bgcolor + '\" cellspacing=\"1\" cellpadding=\"5\" border=\"0\" width=\"100%\">\n\t\t<tr>\n\t\t\t';
  var Str2 = '';
  var Str3 = '</tr>\n\t\t</table>\n\t</td>\n</tr>\n</table>\n';

  for (i=0; i < columnTxt.length; i++) {
    Str2 += '<td bgcolor=\"' + tabletext_bgcolor + '\" align=' + ((alignRight) ? 'right' : 'center') + '>\n\t\t\t\t<font face=\"Arial,Helvetica\" size=\"2\" color=\"' + 
            tabletext_color + '\"><b>' + columnTitle[i] + '</b>\n\t\t\t\t<p>\n\t\t\t\t' + columnTxt[i] + '<br>\n\t\t\t\t</font>\n\t\t\t</td>\n\t\t';
  }
  object.document.write(Str1+Str2+Str3);
}


//////////////////////////////
// function buildLinkTable()
//
// -> build a table of links with given text array
//
function buildLinkTable(tableTitle, tableTxt, disableList)
  { obuildLinkTable(window,tableTitle, tableTxt, disableList); }

function obuildLinkTable(object,tableTitle, tableTxt, disableList)
{
  var Str1 = '\n<table bgcolor=\"' + table_bgcolor + '\" cellspacing=\"0\" border=\"0\">\n<tr>\n\t<td align=center>\n\t\t' +
             '<font face=\"Arial,Helvetica\" color=\"' + table_color + '\" size=\"3\">' + tableTitle + '</font>\n\t</td>\n</tr>\n<tr>\n\t<td>\n\t\t' +
             '<table bgcolor=\"' + table_bgcolor + '\" cellspacing=\"1\" cellpadding=\"5\" border=\"0\" width=\"100%\">\n\t\t<tr>\n\t\t\t<td bgcolor=\"' + 
             tabletext_bgcolor + '\">\n\t\t\t\t<font face=\"Arial,Helvetica\" size=\"2\" color=\"' + tabletext_color + '\">';
  var Str2 = '';
  var Str3 = '</font>\n\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t</td>\n</tr>\n</table>\n';

  for (i=0; i < tableTxt.length; i+=2) {
    if (!disableList)  Str2 += '<font color=\"' + tabletext_color + '\"><b>-</b> <a href=\"' + tableTxt[i] + '\">' + tableTxt[i] + '</a> &nbsp; ' + tableTxt[i+1]+ '</font></a><br>\n\t\t\t\t';
    else  Str2 += '- <a href=\"' + tableTxt[i] +'\"><font color=\"' + tabletext_color + '\">' + tableTxt[i+1] + '</font></a><br>\n\t\t\t\t';
  }
  object.document.write(Str1+Str2+Str3);
}


//////////////////////////////////////////////////////////////////////////////
// (c) Chris.D:)  -  typingTicker && scrollingTicker
//
// -> start ticker   !!! needs <form name="TickerForm"><input name="TickerField"></form>!!!
//
var arrayPos=0, arraySize=tickerText.length, textPos=0;

//////////////////////////////////////////
// function typingTicker()
//
// -> simple typewriter ticker
//
function typingTicker()
{
  textPos++;
  if (textPos > tickerText[arrayPos].length) {
    arrayPos++;
    if (arrayPos >= arraySize) arrayPos=0;		
    textPos=1;
  }
  document.TickerForm.TickerField.value = tickerText[arrayPos].substring(0, textPos);
	
  if (textPos == tickerText[arrayPos].length)  window.setTimeout("typingTicker();", 500);
  else  window.setTimeout("typingTicker();", tickerDelay);
}


//////////////////////////////////////////////
// function scrollingTicker()
//
// -> simple text scrolling ticker
//
function scrollingTicker()
{
  textPos++;
  if (textPos > tickerText[arrayPos].length) {
    arrayPos++;
    if (arrayPos >= arraySize) arrayPos=0;		
    textPos=1;
  }
  var visText = tickerText[arrayPos].substring(textPos, tickerText[arrayPos].length);
  var nextArrayPos=0;

  if (visText.length > tickerFieldWidth)
    visText = tickerText[arrayPos].substring(textPos, tickerFieldWidth);
  if (visText.length < tickerFieldWidth) {
    nextArrayPos = arrayPos+1;
    if (nextArrayPos >= arraySize) 
      nextArrayPos=0;
    var len = tickerFieldWidth - visText.length;
    if (len > tickerText[nextArrayPos].length)  
      len=tickerText[nextArrayPos].length;
    visText = visText + tickerText[nextArrayPos].substring(0, len);
  }
  if (visText.length < tickerFieldWidth && (nextArrayPos+1 < arraySize || nextArrayPos > 0) ) {
    if (nextArrayPos+1 < arraySize) nextArrayPos++;
    else nextArrayPos=0;
    var len = tickerFieldWidth - visText.length;
    if (len > tickerText[nextArrayPos].length)
      len=tickerText[nextArrayPos].length;
    visText = visText + tickerText[nextArrayPos].substring(0, len);
  }
  document.TickerForm.TickerField.value = visText;
  window.setTimeout("scrollingTicker();", tickerDelay);
}




//////////////////////////////////////////////////////////////////////////////
// !!! FOLLOWING code is under copyright 
//     of the listed author(s)
//

//---------------------------------
// LOGIN SCRIPT BY ALEX KEENE 1997
// INFO@FIRSTSOUND.COM
//---------------------------------

// -> check password and login
function Getstats() 
{
	window.status=('Versuche Anmeldung im User-Bereich.')
  
  	var AccId;
  	var iName;
  	AccId = document.iAccInput.iAccID.value;
  	iName = document.iAccInput.iName.value;
		 
     	if (AccId == "" || iName == "") { 			// check, if correct input given
           		alert('\nERROR\n\nSie muessen schon Name und Passwort angeben,\num zu Ihren Seiten zu kommen.');
           		window.status=('Falsche oder ungueltige Eingabe. Ueberpruefen Sie die Schreibweise.'); 
	} else{
         	 	var location=(iName + AccId + ".htm");
         		this.location.href = location;
         		window.status=('   Verifying:  ' + iName + '-' + AccId + '  Please wait........');
	}
}

// -> get user name and password
function Verifyacc2() 
{
	window.status=('Bitte geben Sie Ihren Usernamen und das Passwort ein...');
        	var oName = prompt("Bitte geben Sie Ihren Usernamen ein: \n(Case Sensitive)\n", "");
         	window.status=('   UserName = ' + oName);  

        	var oAccID = prompt("Bitte geben Sie Ihr Passwort ein: \n(Case Sensitive)\n", "");
          	window.status=('   Account ID = ' + oAccID); 
           	
	if (oAccID == "" || oName == "" || oAccID == "null" || oName == "null")  {
		alert('\nERROR\n\nSie muessen schon Usernamen und Passwort angeben,\num zu Ihren Seiten zu kommen.');
                 	window.status=('Falsche oder ungueltige Eingabe. Ueberpruefen Sie die Schreibweise.'); 
	} else {
		window.status=('   Pruefe:  ' + oName + '-' + oAccID + ' Bitte warten........');
		var location=(oName + oAccID + ".html");
                 	this.location.href = location;			// log into other webpage
	}
}

