var picPath = '../Nav/';
var index = 0;
var maxindex = 0;
var idioma;
var scrollVal = 40;
var suffix;

if (idioma == "english")
  { 
  var destinationsDisp = new Array("About Archimedes", "Technical Concept", "Scientific Payload", "Mission Profile", "Configuration", "Preliminary Studies", "Zero G Flight Tests", "The Flight Test Team", "Rocket Science", "Sponsors &amp; Partners", "Support Archimedes", "Contact Information");
  var destinations = new Array("intro", "concept", "payload", "profile", "configuration", "cstudies", "zeroG", "zeroG2", "rocketScience", "sponsors", "donations", "contact");
  var langsuffix = "EN";
  }
  
else if (idioma =="deutsch")
  {
  var destinationsDisp = new Array("Einf&uuml;hrung", "Forschungsballons", "Instrumente", "Konstruktion", "Daten&uuml;bertragung", "Energieversorgung", "Probleme", "Konzept", "Aufblasen im Weltraum", "Technische Herausforderungen", "Missionsgestaltung", "Konfiguration", "Faltungs- und Aufblastests", "Flugtests bei Zero-G", "Erster Weltraumtest", "Geplante Tests", "ARCHYFLOW", "ARCHiMATTER", "CLEOPATRA", "Sponsoren", "Unterst&uuml;tzen Sie uns", "Kontakt");
  var destinations = new Array("intro", "forschungsballons", "instrumente", "konstruktion", "datenuebertragung", "energieversorgung", "probleme", "konzepte", "aufblasen", "herausforderungen", "missionsgestaltung", "konfiguration", "aufblastests", "parabelflug", "parabelflug2", "regina", "planung", "archyflow", "archimatter", "cleopatra", "sponsoren", "spenden", "kontakt");
  var langsuffix = "DE";
  }  


goup = new Image();
goup.src = picPath + 'fourwayUP.PNG';
down = new Image();
down.src = picPath + 'fourwayDOWN.PNG';
fourway = new Image();
fourway.src = picPath + 'fourway.PNG';
goleft = new Image();
goleft.src = picPath + 'fourwayLEFT.PNG';
goright = new Image();
goright.src = picPath + 'fourwayRIGHT.PNG';

upreg = new Image();
downreg = new Image();
leftreg = new Image();
rightreg = new Image();

uphover = new Image();
downhover = new Image();
lefthover = new Image();
righthover = new Image();

uppressed = new Image();
downpressed = new Image();
leftpressed = new Image();
rightpressed = new Image();

upreg.src = picPath + 'arrow2hoch.PNG';
downreg.src = picPath + 'arrow2unten.PNG';
leftreg.src = picPath + 'arrow2links.PNG';
rightreg.src = picPath + 'arrow2rechts.PNG';

uphover.src = picPath + 'arrow3hoch.PNG';
downhover.src = picPath + 'arrow3unten.PNG';
lefthover.src = picPath + 'arrow3links.PNG';
righthover.src = picPath + 'arrow3rechts.PNG';

uppressed.src = picPath + 'arrow6hoch.PNG';
downpressed.src = picPath + 'arrow6unten.PNG';
leftpressed.src = picPath + 'arrow6links.PNG';
rightpressed.src = picPath + 'arrow6rechts.PNG';
   
 function arrow(arrow)
{
   switch (arrow) {
	 case 'upreg': 
		 document.images['arrowUp'].src = upreg.src; 
		 document.images['fourway'].src = fourway.src; 
		 break;
	 case 'uphover': 
	     document.images['arrowUp'].src = uphover.src; 
	     document.images['fourway'].src = goup.src; 
	     break;
	 case 'uppressed': 
	     document.images['arrowUp'].src = uppressed.src; 
		 scrollUp();
	     break;
		 
	 case 'leftreg': 
	     document.images['arrowLeft'].src = leftreg.src; 
	     document.images['fourway'].src = fourway.src; 
	     break;
	 case 'lefthover': 
	     document.images['arrowLeft'].src = lefthover.src; 
	     document.images['fourway'].src = goleft.src; 
	     break;
	 case 'leftpressed': 
	     document.images['arrowLeft'].src = leftpressed.src; 
	     if (index > 0) index--;
	     document.getElementsByName("pfeilLinks")[0].href = 'javascript:mylinks("left")';
	     break;
		 
	 case 'rightreg': 
	     document.images['arrowRight'].src = rightreg.src; 
	     document.images['fourway'].src = fourway.src; 
	     break;
	 case 'righthover': 
	     document.images['arrowRight'].src = righthover.src; 
	     document.images['fourway'].src = goright.src; 
	     break;
	 case 'rightpressed': 
	     document.images['arrowRight'].src = rightpressed.src; 
	     if (index < destinations.length) index++;
	     document.getElementsByName("pfeilRechts")[0].href = 'javascript:mylinks("right")';
		 break;
		 
	 case 'downreg': 
		 document.images['arrowDown'].src = downreg.src; 
		 document.images['fourway'].src = fourway.src; 
		 break;
	 case 'downhover': 
	     document.images['arrowDown'].src = downhover.src; 
	     document.images['fourway'].src = down.src; 
	     break;
	 case 'downpressed': 
	     document.images['arrowDown'].src = downpressed.src; 
		 scrollDown();
	}
}

function mylinks(direction) {
	if (window.location.pathname == "/nobs.html") {		//falls alte Browser bedient werden
		if (destinations[index].indexOf(".php") > 0) suffix = "";
		else suffix = ".xml"; 
		window.open("nobsText.php5?lg=" + langsuffix + "&fl=" + destinations[index] + suffix + "#principio", "archiText");	
		}
	else {
		if (document.body.clientWidth) {
			offset = eval(document.body.clientWidth - 298); }
		if (window.innerWidth) {
			offset = eval(window.innerWidth - 344);	}
		if (destinations[index] == "news") 
		{
	//		showInfo("xmldata" + langsuffix + "/" + destinations[index] + ".php");
	//		window.open("archiText" + langsuffix + "/" + destinations[index] + ".php#principio", "archiText");
		}
		else 
		{
			alpha = offset*index;
			  if (alpha < 0) alpha = 1 ;
	
		if (direction == "right")
			{
				top.archiText.document.getElementsByTagName("div")[0].style.width="40000px";
				if (index > maxindex && index < destinations.length) { 
				  maxindex = index;
		//		  alert (index);
				  showInfo("xmldata" + langsuffix + "/" + destinations[index] + ".xml", "ajaxfeed");
				}
				if (index < destinations.length)
		//		alert ("alpha: " + alpha + " Index: " + index);
				scrollRight(alpha);
				if (index == destinations.length) {
				  index = destinations.length-1; }
			}
			if (direction == "left")
			{
				scrollLeft(alpha);
			}
		}
	}
}

function dispMenu () {
   for (i = 1; i < destinationsDisp.length; i++) {
      document.write("<tr><td><a class='roller' href='nobsText.php5?lg=" + langsuffix + "&fl=" + destinations[i] + ".xml' target='archiText' onmousedown=setIndex(i)>" + destinationsDisp[i] + "</a></td></tr>");
   }
}

function setIndex(x) {
   index = x;
}

function scrollLeft (y) {
	if (top.archiText.pageXOffset >= 0) {
	  x = top.archiText.pageXOffset; }
	else if (top.archiText.document.body.scrollLeft >= 0) {
      x = top.archiText.document.body.scrollLeft;}
	if (x > y) {
		if (window.pageYOffset > 0) window.scrollBy(0,-100);
		if (window.document.body.scrollTop >= 0) window.scrollBy(0,-100);
		if ((x-scrollVal) > 0) {
	top.archiText.scrollBy(-scrollVal, 0);
    setTimeout("scrollLeft(" + y + ")", 1);	}
	}
}

function scrollRight (y) {
	if (top.archiText.pageXOffset >= 0) {
	  x = top.archiText.pageXOffset; }
	else if (top.archiText.document.body.scrollLeft >= 0) { 
      x = top.archiText.document.body.scrollLeft; }
	if (x < y) {
		if (window.pageYOffset > 0) window.scrollBy(0,-100);
		if (window.document.body.scrollTop >= 0) window.scrollBy(0,-100);
	    top.archiText.scrollBy(scrollVal, -100);
    	setTimeout("scrollRight(" + y + ")", 0);
  }
}

function scrollDown () {
	if (window.pageYOffset > 0) window.scrollBy(0,30);
	if (window.document.body.scrollTop >= 0) window.scrollBy(0,30);
	if (document.images['arrowDown'].src == downpressed.src)
	setTimeout("scrollDown()", 0);
}

function scrollUp () {
	if (window.pageYOffset > 0) window.scrollBy(0,-30);
	if (window.document.body.scrollTop >= 0) window.scrollBy(0,-30);
	if (document.images['arrowUp'].src == uppressed.src)
	setTimeout("scrollUp()", 0);
}
