﻿var lang="en"
var ak=0

function addHMEl(elpar, mid, mhref, mtext, mtitle) {
	var elli=document.createElement("li");
	var ela=document.createElement("a");
	var elt=document.createTextNode(mtext);
	ela.className="hmu";
	ela.id="hm_"+mid;
	ela.href=mhref;
	ela.setAttribute("title", mtitle);
	ela.setAttribute("accesskey", "0123456789abcdefghijk".charAt(ak));
	ak++;
	if (mid=="index") {
		ela.setAttribute("style", "display:none");
	}
	ela.appendChild(elt);
	elli.appendChild(ela);
	elpar.appendChild(elli);
	return elli;
}

function createHM() {
	var suf="_"+lang+".html";
	document.getElementById("hlogo").setAttribute("onclick", "window.location.href='index"+suf+"'");
	var mis;
	if (lang=="de") {
		//"jobs;Jobs;Stellenangebote", "imprint;Impressum;Impressum, Adresse"
		mis=new Array("index;Moving Data. Fast.;Start", "intro;Lösungen;Überblick", "*", "tixstream;File Transfer;TIXstream", "tixway;FTP Beschleunigung;TIXway", "#", "products;Produkte;Produktserie", "*", "ps_tixstream;TIXstream;TIXstream", "ps_tixway;TIXway;TIXway", "#", "cases;Fallstudien;Anwendungsbeispiele", "technology;Technologie;Technologie", "news;News;Nachrichten, Pressemitteilungen", "about;Über uns;Kontakt, über TIXEL", "*", "imprint;Impressum;Impressum", "location;Standort;Wegbeschreibung - wie Sie uns finden", "#");
	} else {
		//"jobs;Job Opportunities;Jobs", "imprint;Imprint, Address;Imprint"
		mis=new Array("index;Moving Data. Fast.;Start", "intro;Solutions;Introduction", "*", "tixstream;File Transfer;TIXstream", "tixway;FTP Acceleration;TIXway", "#","products;Products;Products", "*", "ps_tixstream;TIXstream;TIXstream", "ps_tixway;TIXway;TIXway", "#", "cases;Case Studies;Case Studies", "technology;Technology;Technology", "news;News;News, Events, Press Releases", "about;About;Contact, About us", "*", "imprint;Imprint;Imprint", "location;Location;How to reach us", "#");
	}
	var elul=document.createElement ("ul");
	var curul=elul;
	var upelli;
	var lastelli;
	for (var i=0; i<mis.length; i++) {
		if(mis[i]=='*') {
			upelli=lastelli;
			curul=document.createElement ("ul");
		} else if(mis[i]=='#') {
			upelli.appendChild(curul);
			curul=elul;
		} else {
			ti=mis[i].split(';');
			lastelli=addHMEl(curul, ti[0], ti[0]+suf, ti[1], ti[2]);
		}
	}
	document.getElementById("hmenu").appendChild(elul);
}

function hiliteHM() {
	var tit="TIXEL: "
	var top=document.getElementById('hmtop').firstChild.nodeValue;
	var tel=document.getElementById('hm_'+top);
	if (tel) tel.className="hms";
	var hone=document.getElementsByTagName("h1");
	if (hone[0]) {
		document.title=tit+hone[0].firstChild.nodeValue;
	} else {
		if (top) document.title=tit+tel.firstChild.data;
	}
}

function showLS() {
	var otherlang="deutsch";
	var otherlid="de";
	var url=this.document.URL;
	if ((url.indexOf("_de")>0) || (url.indexOf("_en")>0)) {
		if (lang=="de") {
			otherlang="english";
			otherlid="en";
			url=url.replace(/_de./g, "_en.");
		} else {
			otherlang="deutsch";
			otherlid="de";
			url=url.replace(/_en./g, "_de.");
		}		
		var eld=document.createElement("div");
		eld.id="langsel";
		var ela=document.createElement ("a");
		ela.setAttribute ("href", url);
		ela.setAttribute ("accesskey", "l");
		//var elt=document.createTextNode(otherlang);
		var eli=document.createElement("img");
		eli.setAttribute ("src", "lang_"+otherlid+".png");
		eli.setAttribute ("alt", otherlang);
		eli.setAttribute ("title", otherlang);
		ela.appendChild (eli);
		eld.appendChild (ela);
		document.getElementById ("hcont").appendChild (eld);
	}
}

function filladr(elid, name) {
	var cnt="info";
	if (name) cnt=name;
	var ac=unescape('%40');
	var ael=document.getElementById(elid);
	if (ael) {
		cnt+=(ac+"tixeltec."+"com");
		ael.firstChild.nodeValue=cnt;
	}
}


function fixIE() {
if (navigator.userAgent.indexOf("Opera")>=0) {
	document.getElementById('hmenu').setAttribute('style', 'left:180px');
}
if (navigator.userAgent.indexOf("MSIE 6")>=0) {
		var ello=document.getElementById('hlogo');
		if (ello) {
			ello.className='hlogoie';
			//ello.setAttribute('style','background-image: url(./tixel.jpg);');
		}
	}
}

function switchlang() {
	var navlang="en";
	var url=this.document.URL;
	if (navigator.language) navlang=navigator.language;
	else if (navigator.userLanguage) navlang=navigator.userLanguage;
	//if (navlang=="de") url=url.replace(/\.html/, "_de.html");
	//else url=url.replace(/\.html/, "_en.html");
	if (navlang.indexOf("de")==0) url="index_de.html";
	else url="index_en.html";
	window.location.href=url;
}


var pels=new Array();
var pidx=0;
var prorun=1;
var slpre;
var slnext;
var slop;
var sldelay=4000;
var slccnt=0;

function showText() {
}

function fadeSlide() {
	sty="z-index:88; opacity: "+slop+";";
	slnext.setAttribute("style", sty);
	slop=slop+0.05;
	if (slop>1) {
		slop=0.0;
		var at="";
		if (slnext.firstChild.nodeName=="IMG") {
			//IE
			at=slnext.firstChild.getAttribute("title");
		} else {
			at=slnext.firstChild.nextSibling.getAttribute("title");
		}
		document.getElementById("protext").firstChild.nodeValue=at;
		slpre.setAttribute("style", "z-index:84; opacity: 0.0;");
		slnext.setAttribute("style", "z-index:86; opacity: 1.0;");
		setTimeout('changeSlide()', sldelay);	
	} else {
		setTimeout('fadeSlide()', 40);
	}
}

function changeSlide() {
	if (prorun==0) return;
	slccnt=slccnt+1;
	if (slccnt==12) sldelay=10000;
	if (slccnt==120) sldelay=30000;
	slpre=pels[pidx];
	pidx=pidx+1;
	if (pidx==pels.length) pidx=0;
	slnext=pels[pidx];
	slop=0.0;
	fadeSlide();
}

function startPro() {
	pidx=0;
	setTimeout('changeSlide()', 4000);
}

function checkPro() {
	var dels=document.getElementsByTagName("div");
	var t="";
	for (var i=0; i<dels.length; i++) {
		if (dels[i].className.indexOf("proslide")==0) pels.push(dels[i]);
		t=t+dels[i].className+" ";
	}
	if (pels.length>1) startPro();
}

function init() {
	if (this.document.URL.indexOf('_de.html')>0) lang='de';
	createHM();
	hiliteHM();
	fixIE();
	showLS();
	checkPro();
	//alert(document.getElementsByTagName('meta')[0].content);
}

/* (c) 2009-2011 einhorn-net.de */

