// GLOBALE VARIABLEN

var path="./index.php?id=";

var serverpath = "fileadmin/template/main/";
var flashpath = serverpath + "flash/";
var imagepath = serverpath + "img/";

// Spezialfall fuer den Sitemap- und Impressumlink, diese habe keine sprechenden URLs
var impressum = 41;
var sitemap = 90;

var ancudDE = "http://www.ancud.de/de/"
var ancudEN = "http://www.ancud.de/en/"


var flashmovies = new Array(7);
flashmovies[0] = flashpath + "home.swf";
flashmovies[1] = flashpath + "leistungen.swf";
flashmovies[2] = flashpath + "loesungen.swf";
flashmovies[3] = flashpath + "unternehmen.swf";
flashmovies[4] = flashpath + "referenzen.swf";
flashmovies[5] = flashpath + "presse.swf";
flashmovies[6] = flashpath + "kontakt.swf";

var flashmovies_en = new Array(7);
flashmovies_en[0] = flashpath + "home_en.swf";
flashmovies_en[1] = flashpath + "services_en.swf";
flashmovies_en[2] = flashpath + "solutions_en.swf";
flashmovies_en[3] = flashpath + "about_en.swf";
flashmovies_en[4] = flashpath + "customers_en.swf";
flashmovies_en[5] = flashpath + "news_en.swf";
flashmovies_en[6] = flashpath + "contact_en.swf";

var leftImage = new Array(7);
leftImage[0] = imagepath + "mt_0/left_0.jpg";
leftImage[1] = imagepath + "mt_1/left_1.jpg";
leftImage[2] = imagepath + "mt_1/left_2.jpg";
leftImage[3] = imagepath + "mt_1/left_3.jpg";
leftImage[4] = imagepath + "mt_1/left_4.jpg";
leftImage[5] = imagepath + "mt_1/left_5.jpg";
leftImage[6] = imagepath + "mt_1/left_6.jpg";

var leftImage_en = new Array(7);
leftImage_en[0] = imagepath + "mt_0/left_0_en.jpg";
leftImage_en[1] = imagepath + "mt_1/left_1_en.jpg";
leftImage_en[2] = imagepath + "mt_1/left_2_en.jpg";
leftImage_en[3] = imagepath + "mt_1/left_3_en.jpg";
leftImage_en[4] = imagepath + "mt_1/left_4_en.jpg";
leftImage_en[5] = imagepath + "mt_1/left_5_en.jpg";
leftImage_en[6] = imagepath + "mt_1/left_6_en.jpg";

var middleImage = new Array(7);
middleImage[1] = imagepath + "mt_1/middle_1.jpg";
middleImage[2] = imagepath + "mt_1/middle_2.jpg";
middleImage[3] = imagepath + "mt_1/middle_3.jpg";
middleImage[4] = imagepath + "mt_1/middle_4.jpg";
middleImage[5] = imagepath + "mt_1/middle_5.jpg";
middleImage[6] = imagepath + "mt_1/middle_6.jpg";

var rightImage = new Array(7);
rightImage[1] = imagepath + "mt_1/right_1.jpg";
rightImage[2] = imagepath + "mt_1/right_2.jpg";
rightImage[3] = imagepath + "mt_1/right_3.jpg";
rightImage[4] = imagepath + "mt_1/right_4.jpg";
rightImage[5] = imagepath + "mt_1/right_5.jpg";
rightImage[6] = imagepath + "mt_1/right_6.jpg";

var topImage = new Array(7);
topImage[1] = imagepath + "mt_1/top_1.jpg";
topImage[2] = imagepath + "mt_1/top_2.jpg";
topImage[3] = imagepath + "mt_1/top_3.jpg";
topImage[4] = imagepath + "mt_1/top_4.jpg";
topImage[5] = imagepath + "mt_1/top_5.jpg";
topImage[6] = imagepath + "mt_1/top_6.jpg";


function englishPage() {
  var Ausdruck = /\/en\//;
  var Ergebnis = Ausdruck.test(document.URL);
  // Spezialfall fuer Impressum und Sitemap beruecksichtigen
  var Ausdruck2 = /L=1/;
  var Ergebnis2 = Ausdruck2.test(document.URL);
  if (Ergebnis || Ergebnis2) {
    return true;
  } else {
    return false;
  }
}


function homeImage() {
  var myURL = ancudDE;
  if (englishPage()) { 
	myURL = ancudEN;
  }
  return '<a href='+ myURL +' style="text-decoration:none;"><img src="fileadmin/template/main/img/ancud_logo.jpg" border="0" width="164px" height="60px" alt="Ancud IT-Beratung GmbH" /></a>'; 
}



function impressumImage() {
  if (englishPage()) { 
	return '<a href="'+path+impressum+'&L=1" style="text-decoration:none; " class="weiss"><img src="fileadmin/template/main/img/impressum.gif" border="0" width="51px" height="7px" alt="Ancud IT-Beratung GmbH" /></a>'; 
  } else {
    return '<a href="'+path+impressum+'&L=0" style="text-decoration:none; " class="weiss" ><img src="fileadmin/template/main/img/impressum.gif" border="0" width="51px" height="7px" alt="Ancud IT-Beratung GmbH" /></a>'; 
  }
}

function sitemapImage() {
  if (englishPage()) { 
	return '<a href="'+path+sitemap+'&L=1" style="text-decoration:none;" class="weiss"><img src="fileadmin/template/main/img/sitemap.gif" border="0" width="38px" height="7px" alt="Ancud IT-Beratung GmbH" /></a>'; 
  } else {
    return '<a href="'+path+sitemap+'&L=0" style="text-decoration:none;" class="weiss"><img src="fileadmin/template/main/img/sitemap.gif" border="0" width="38px" height="7px" alt="Ancud IT-Beratung GmbH" /></a>'; 
  }
}

function cebitBanner(){
	var banner = '<img src="fileadmin/template/main/img/mt_0/ancud_cebit.png" />';
	if (englishPage()) {
		banner = '<img src="fileadmin/template/main/img/mt_0/ancud_cebit_en.png" />';
	} 
	// return '<div style="position:absolute;top:50px;">' + banner + '</div>';
	return '';
}


/*
 * Berechnet dynamsich die Höhe der letzten Tabellen Spalte für das Maintemplate mt_0.html
 */
function dynamicHeight() {
	if (document.getElementById('content')) {
		var t1 = (document.getElementById('content').offsetHeight);
		//562 ergibt sich aus den Höhen der Reihen 3 (302px), 4 (60px) und 5 (200px) + einen Puffer von 20px
		var t2 = t1 - 501 + 20;
		if(t2 > 20) {
		  t1 = t2+"px";
		} else {
		  t1 = 20+"px";
		}
		document.getElementById('buffer').style.height=(t1);
	}
}


/*
  * Prüft ob der Client über ein Flash-Plugin verfügt
  */
function flashDetection() {
	var required_version = 7;
	var max_version = 9;
	var available_version = 0;
	var result = 0;

	 if(typeof(navigator.plugins["Shockwave Flash"]) == "object") {
		var description = navigator.plugins["Shockwave Flash"].description;
		result = 1;
		//available_version = description.substr(16, (description.indexOf(".", 16) - 16));
	} else  if(typeof(ActiveXObject) == "function") {
		 for(var i = required_version; i < (max_version + 1); i++) {
			try {
				 if(typeof(new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i)) == "object") {
					result = 1;
				}
		   } catch(error) {}
		}
	}
	return result;
}


/*
 * Bei Klick auf eine Referenz soll sowohl eine neue Seite aufgehen, welche Details zu der Referenz
 * angibt, als auch ein Popup mit einem Flashfilm
 */
function popup(flashFile, windowName) {
    if (flashDetection() > 0) {
		var URL = "/fileadmin/documents/flash/" + flashFile;
		var Name = "Ancud IT-Beratung GmbH - " + windowName;
		var Fensteroptionen = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0";
		var Breite = 780;
		var Hoehe = 585;
		var Fenster = window.open('about:blank', 'Name', Fensteroptionen + ',width=' + Breite + ',height=' + Hoehe + ',left=0,top=0');
		
		if (Fenster) {
			Fenster.document.open();
			
			Fenster.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
			Fenster.document.writeln('<html>');
			Fenster.document.writeln('<head>');
			Fenster.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />');
			Fenster.document.writeln('<title>' + Name + '</title>');
			Fenster.document.writeln('</head>');
			Fenster.document.writeln('<body style="background-color:#FFFFFF; margin-top:0px; margin-left:0px; margin-bottom:0px; margin-right:0px;">');
			Fenster.document.writeln('<object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ Breite +'" height="'+ Hoehe +'" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0">');
			Fenster.document.writeln('  <param name="movie" value="'+ URL +'">');
			Fenster.document.writeln('  <param name="quality" value="high">');
			Fenster.document.writeln('  <param name="scale" value="exactfit">');
			//Fenster.document.writeln("  <param name=\"menu\" value=\"true\">");
			Fenster.document.writeln('  <param name="menu" value="true">');
			Fenster.document.writeln('  <param name="bgcolor" value="#FFFFFF">');
			Fenster.document.writeln('  <embed src="'+ URL +'" quality="high" scale="exactfit" menu="false" bgcolor="#FFFFFF" width="'+ Breite +'" height="'+ Hoehe +'" swLiveConnect="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
			Fenster.document.writeln('</object>');
			Fenster.document.writeln('</body>');
			Fenster.document.writeln('</html>');
				
			Fenster.document.close();
			Fenster.focus();
		}
	}
}



/*
 * Spezielles für die Anfahrtsseite
 */
function writeSwapableImage(file, swapfile) {
  document.writeln('<img onclick="swapImage(\'imageToSwap\', \''+ file +'\', \''+ swapfile +'\'); return false" src="'+ file +'" id="imageToSwap" />');
}
 

function swapImage(id, originalfile, swapfile) {
  var image = document.getElementById(id);
  image.setAttribute("src", swapfile); 
  //Netscape, FF, Opera, ...
   if ((!document.all)&&(document.getElementById)){
       image.setAttribute("onClick", "swapImage('"+ id +"', '"+ swapfile +"', '"+ originalfile +"')");
   }    
   //IE
   if ((document.all)&&(document.getElementById)){
       image["onclick"]=new Function("swapImage('"+ id +"', '"+ swapfile +"', '"+ originalfile +"')");
   }
}

function writeFlashObject(file, width, height) {
	document.writeln("<object classid=\"CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000\" width="+ width +" height="+ height +" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\">");
	document.writeln("  <param name=\"movie\" value="+ file +">");
	document.writeln("  <param name=\"quality\" value=\"high\">");
	document.writeln("  <param name=\"scale\" value=\"exactfit\">");
	document.writeln("  <param name=\"menu\" value=\"true\">");
	document.writeln("  <param name=\"menu\" value=\"true\">");
	document.writeln("  <param name=\"bgcolor\" value=\"#FFFFFF\">");
	document.writeln("  <embed src="+ file +" quality=\"high\" scale=\"exactfit\" menu=\"false\" bgcolor=\"#FFFFFF\" width="+ width +" height="+ height +" swLiveConnect=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>");
	document.writeln("</object>");
}




/*
 * Funktion zur dynamischen Bildanzeige
 */
function dynamicImages(id, flash) {
  if (document.getElementById("left")) {
  	var leftNode = document.getElementById("left");
  	if(flash < 1) {
		var imgObject = leftImage[id];
		if (englishPage()) {
			imgObject = leftImage_en[id];
		}
  	  var leftImg = document.createElement("IMG");
	  leftImg.setAttribute("style", "margin-top:0px;");
	  leftImg.setAttribute("border", "0");
	  leftImg.setAttribute("src", imgObject);
	  leftNode.appendChild(leftImg);
	} else {
		var flashObject = flashmovies[id];
		if (englishPage()) {
			flashObject = flashmovies_en[id];
		} 
		
		var flashString = "<object classid=\"CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"405\" height=\"347\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\">\n" +
	        "  <param name=\"movie\" value="+ flashObject +">\n" +
			"  <param name=\"quality\" value=\"high\">\n" +
			"  <param name=\"scale\" value=\"exactfit\">\n" +
			"  <param name=\"menu\" value=\"true\">\n" +
			"  <param name=\"bgcolor\" value=\"#FFFFFF\">\n" +
			"  <embed src="+ flashObject +" quality=\"high\" scale=\"exactfit\" menu=\"false\" bgcolor=\"#FFFFFF\" width=\"405\" height=\"347\" swLiveConnect=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>\n" +
			"</object>";
		leftNode.innerHTML = flashString;
	}

  }
  
  if (document.getElementById("middle")) {
  	var middleNode = document.getElementById("middle");
        middleNode.style.backgroundImage="url("+ middleImage[id] +")";
  	middleNode.style.backgroundRepeat="no-repeat";
  }
  
   if (document.getElementById("right")) {
  	var rightNode = document.getElementById("right");
        rightNode.style.backgroundImage="url("+ rightImage[id] +")";
  	rightNode.style.backgroundRepeat="no-repeat";
  }

  /* Durch das <MARQUEE> TAG in "mt_1.html" wurde es noetig auch diese Grafik an Hintergrundbild einzubauen
  if (document.getElementById("right")) {
    var rightNode = document.getElementById("right");
    var rightImg = document.createElement("IMG");
    rightImg.setAttribute("border", "0");
    rightImg.setAttribute("src", rightImage[id]);
    rightNode.appendChild(rightImg);
  }
  */

  if (document.getElementById("top")) {
  	 var topNode = document.getElementById("top");
  	 topNode.style.backgroundImage="url("+ topImage[id] +")"; 
	 topNode.style.paddingTop="0px";
  	 topNode.style.backgroundRepeat="no-repeat";
  }
}






/*
 * Start der Function für den Scroller auf der Startseite
 */

function safari() {
    var uAgent = navigator.userAgent;
    var Ergebnis = uAgent.search(/Safari.+/);
    if (Ergebnis != -1){
      return true;
    } else {
      return false;
    }
}

var scrollers = new Array();
var scCount = 0;

function Scroller(bound, content) {
	this.Id = ++scCount;
	scrollers[this.Id] = this;
	this.Bound = bound;
	this.Content = content;
	this.StartDelay = 500;
	this.StepSize = 1;
	this.StepDelay = 10;
	this.Position = 0;
	this.DelayPositions = new Array();
}

Scroller.prototype.start = function p_start() {
	this.SecondContent = this.Content.cloneNode(true);
	this.Bound.appendChild(this.SecondContent);
	this.SecondContent.style.top = this.Content.offsetHeight;

	window.setTimeout("_p_next(" + this.Id + ")", this.StartDelay);

	for (var pos = 0; pos < this.Content.childNodes.length; pos++) {
		var node = this.Content.childNodes[pos];
  
		if (node.tagName) {
			var delay = node.getAttribute("scrollDelay");
			if (delay) {
				this.DelayPositions[node.offsetTop] = delay;
			}
		}
	}
}

Scroller.prototype.next = function p_start() {
	if (this.Position == this.Content.offsetHeight) {
		this.Position = 0;
		var c = this.Content;
		this.Content = this.SecondContent;
		this.SecondContent = c;
  
		this.SecondContent.style.clip = "rect(auto auto auto auto)";
		this.Content.style.clip = "rect(auto auto auto auto)";
	} else {
		this.Position += this.StepSize;
	}

	var delay = this.StepDelay;
	if (this.DelayPositions[this.Position]) {
		delay = this.DelayPositions[this.Position];
	}

	if (this.Position > this.Content.offsetHeight) {
		this.Position = this.Content.offsetHeight;
	}

	this.Content.style.clip = "rect(" + this.Position + " auto auto auto)";
	this.Content.style.top = -this.Position;
	this.SecondContent.style.top = this.Content.offsetHeight-this.Position;

	window.setTimeout("_p_next(" + this.Id + ")", delay);
}

function _p_next(id) {
	scrollers[id].next();
}
