// ---
function reloadKursListe() {
	if (document.indizes.index.value == 'dax') { 
		window.location.href = '/index.html?section=Realtimekurse&index=mdax&land=deutschland';
	} else if (document.indizes.index.value == 'mdax') { 
		window.location.href = '/index.html?section=Realtimekurse&index=sdax&land=deutschland';
	} else if (document.indizes.index.value == 'sdax') { 
		window.location.href = '/index.html?section=Realtimekurse&index=tecdax&land=deutschland';
	} else if (document.indizes.index.value == 'tecdax') { 
		window.location.href = '/index.html?section=Realtimekurse&index=dax&land=deutschland';
	}
	
	/*--- Entry Standard ---*/
	if (document.indizes.index.value == 'lsentry') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsprime&land=deutschland';
	}
	
	if (document.indizes.index.value == 'lsprime') { 
		var pfad	=	'/index.html?section=Realtimekurse&index=lsprime&land=lsprime&letter=';
		var buchstabe;
		if (document.indizes.letter.value == 'a') {
			buchstabe	=	'b';	
		} else if (document.indizes.letter.value == 'b') {
			buchstabe	=	'c';	
		} else if (document.indizes.letter.value == 'c') {
			buchstabe	=	'd';	
		} else if (document.indizes.letter.value == 'd') {
			buchstabe	=	'e';	
		} else if (document.indizes.letter.value == 'e') {
			buchstabe	=	'f';	
		} else if (document.indizes.letter.value == 'f') {
			buchstabe	=	'g';	
		} else if (document.indizes.letter.value == 'g') {
			buchstabe	=	'h';	
		} else if (document.indizes.letter.value == 'h') {
			buchstabe	=	'i';	
		} else if (document.indizes.letter.value == 'i') {
			buchstabe	=	'j';	
		} else if (document.indizes.letter.value == 'j') {
			buchstabe	=	'k';	
		} else if (document.indizes.letter.value == 'k') {
			buchstabe	=	'l';	
		} else if (document.indizes.letter.value == 'l') {
			buchstabe	=	'm';	
		} else if (document.indizes.letter.value == 'm') {
			buchstabe	=	'n';	
		} else if (document.indizes.letter.value == 'n') {
			buchstabe	=	'o';	
		} else if (document.indizes.letter.value == 'o') {
			buchstabe	=	'p';	
		} else if (document.indizes.letter.value == 'p') {
			buchstabe	=	'q';	
		} else if (document.indizes.letter.value == 'q') {
			buchstabe	=	'r';	
		} else if (document.indizes.letter.value == 'r') {
			buchstabe	=	's';	
		} else if (document.indizes.letter.value == 's') {
			buchstabe	=	't';	
		} else if (document.indizes.letter.value == 't') {
			buchstabe	=	'u';	
		} else if (document.indizes.letter.value == 'u') {
			buchstabe	=	'v';	
		} else if (document.indizes.letter.value == 'v') {
			buchstabe	=	'w';	
		} else if (document.indizes.letter.value == 'w') {
			buchstabe	=	'x';	
		} else if (document.indizes.letter.value == 'x') {
			buchstabe	=	'y';	
		} else if (document.indizes.letter.value == 'y') {
			buchstabe	=	'z';	
		} else if (document.indizes.letter.value == 'z') {
			buchstabe	=	'a';	
		}
		window.location.href = pfad+buchstabe;
	}
	
	/*--- USA --- */
	if (document.indizes.index.value == 'lsdji') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsnasdaq&land=usa';
	}
	if (document.indizes.index.value == 'lsnasdaq') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsusgix&land=usa';
	}
	if (document.indizes.index.value == 'lsusgix') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsdji&land=usa';
	}
	
	/*--- EUROPA --- */
	if (document.indizes.index.value == 'lseosaeu') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsbritainselect&land=europa';
	}
	if (document.indizes.index.value == 'lsbritainselect') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsschweiz&land=europa';
	}
	if (document.indizes.index.value == 'lsschweiz') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lseosaeu&land=europa';
	}
	
	/*--- ASIEN ---*/
	if (document.indizes.index.value == 'lsjpselect') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsasnselect&land=asien';
	}
	if (document.indizes.index.value == 'lsasnselect') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsaustralienselect&land=asien';
	}
	if (document.indizes.index.value == 'lsaustralienselect') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lsjpselect&land=asien';
	}
	
	/*--- AFRIKA ---*/
	if (document.indizes.index.value == 'lssuedafrika') { 
		window.location.href = '/index.html?section=Realtimekurse&index=lssuedafrika&land=afrika';
	}
	/*--- Hot Stocks ---*/
	if (document.indizes.index.value == 'hotstocks') { 
		window.location.href = '/index.html?section=Realtimekurse&index=hotstocks';
	}
	
}

function makeRequestStock(uri, fCall) {
	var http_request = false;
	
	if (window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
          http_request.overrideMimeType('text/xml');
      }
  } else if (window.ActiveXObject) {
      try {
          http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
          try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e) {}
      }
  }

  if (!http_request) {
      return false;
  }
	
	http_request.onreadystatechange = function() {
		alertContentsStockResetColor(http_request);
	}
  http_request.open('GET', uri, true);
  http_request.send(null);
}


function alertContentsStockResetColor(http_request) {
	if (http_request.readyState == 4) {
  	if (http_request.status == 200) {
  		var htmltext = new String;
  		htmltext = http_request.responseText;

  		if ( htmltext != "" ) {
  			aIsin = htmltext.split(";");
				for (i=0; i < aIsin.length; i++) {
					var aContent = aIsin[i].split("|");
					// --- vortag
	  			//document.getElementById('vortag' + aContent[0]).innerHTML = aContent[2];
	  			//document.getElementById('debug').innerHTML = 'DEBUG: ' + aContent[0] + ' [' + aContent[6] + ']';
	  			
	  			// --- Timestamp setzen
	  			if ( aContent[26] > 0 ) {
	  				$('millisec').innerHTML = aContent[26];
	  			} else {
	  				var jetzt = new Date();
						var meTime = Math.round(Math.abs(jetzt.getTime() / 1000));
	  				$('millisec').innerHTML = meTime;
	  			}
	  			
	  			// --- aktuell
	  			if ($('aktuell' + aContent[0]).innerHTML != aContent[3] ) {
	  				$('aktuell' + aContent[0]).setStyle({backgroundColor: aContent[17],   color: aContent[18]});
	  				$('aktuell' + aContent[0]).innerHTML = aContent[3];
				  }
	  			
	    		// --- bid
	    		if ($('bid' + aContent[0]).innerHTML != aContent[4] ) {
		  			$('bid' + aContent[0]).setStyle({backgroundColor: aContent[13],   color: aContent[14]});
	  				$('bid' + aContent[0]).innerHTML = aContent[4];
					}
		  		
		  		// --- aks
		  		if ($('ask' + aContent[0]).innerHTML != aContent[5] ) {
		  			$('ask' + aContent[0]).setStyle({backgroundColor: aContent[15],   color: aContent[16]});
	  				$('ask' + aContent[0]).innerHTML = aContent[5];
					}
					
		  		// --- change
		  		if ($('change' + aContent[0]).innerHTML != aContent[6] ) {
		  			$('change' + aContent[0]).setStyle({backgroundColor: aContent[19],   color: aContent[20]});
	  				$('change' + aContent[0]).innerHTML = aContent[6];
				  }
		  		
		  		// --- percent
		  		if ($('percent' + aContent[0]).innerHTML != aContent[7] ) {
		  			$('percent' + aContent[0]).setStyle({backgroundColor: aContent[21],   color: aContent[22]});
	  				$('percent' + aContent[0]).innerHTML = aContent[7];
	  			}
	  				  			
	  			if ($('pfeil' + aContent[0])) {
	  				$('pfeil' + aContent[0]).innerHTML = '<img src=\"http://www.ad-hoc-news.de/images/pf_' + aContent[9] + '.gif\" alt=\"pfeil\" border=\"0\">';
	  			}
	  			$('milliseconds' + aContent[0]).innerHTML = aContent[23];
	  			$('zeitstempel' + aContent[0]).innerHTML = aContent[27];
	  			if ($('prozentbalken' + aContent[0])) {
						breite	=	(aContent[6] / $('maxpercent').innerHTML * 100) / 2;
						/*
						if (breite > 0) {
							$('prozentbalken' + aContent[0]).removeClassName('prozentbalken_pos'); 
							$('prozentbalken' + aContent[0]).addClassName('prozentbalken_neg');
	  				} else {
	  					$('prozentbalken' + aContent[0]).removeClassName('prozentbalken_neg'); 
							$('prozentbalken' + aContent[0]).addClassName('prozentbalken_pos');
	  				}
	  				
	  				if (breite < 0) {
	  					breite	=	Math.abs(breite);
	  				}
	  				$('prozentbalken' + aContent[0]).style.width = breite;
	  				*/
	  			}
	  			
	  		}
      }
    }
  }
}

function countDownStock(link) {
		makeRequestStock(link + '&milliseconds=' + document.getElementById('millisec').innerHTML, 'stock');
    window.setTimeout("countDownStock('"+link+"');", 5000);
}

function countDownStockResetColor() {
		var isin = new Array();
		isin = document.getElementById('isinarray').value.split(";");
		for (i=0; i < isin.length; i++) {
			diff = Math.abs(document.getElementById('millisec').innerHTML  - document.getElementById('milliseconds' + isin[i]).innerHTML);
			if ( diff != 0 && (document.getElementById('percent' + isin[i]).style.backgroundColor != '' || document.getElementById('change' + isin[i]).style.backgroundColor != '') ) {
				$('ask' + isin[i]).setStyle({backgroundColor: '',   color: ''}); 
				$('aktuell' + isin[i]).setStyle({backgroundColor: '',   color: ''});
				$('change' + isin[i]).setStyle({backgroundColor: '',   color: ''});
				$('percent' + isin[i]).setStyle({backgroundColor: '',   color: ''});
				$('bid' + isin[i]).setStyle({backgroundColor: '',   color: ''});
		  }
		}
}

function resetAllColor() {
		var isin = new Array();
		isin = document.getElementById('isinarray').value.split(";");
		for (i=0; i < isin.length; i++) {
			$('aktuell' + isin[i]).setStyle({backgroundColor: '',   color: ''});
		}
}
