jQuery(function($) {

  if($("#banner-content ul li").length > 1) {
	$("#banner-content ul").innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 6000,
		type: 'random',
		containerheight: '210px'
	});
  }
  
});

//TopUp.host = "http://www.anotherwebsite.com/";
TopUp.players_path = "fileadmin/templates/js/players/";
TopUp.images_path = "fileadmin/templates/js/images/top_up/";

var $j = jQuery.noConflict();
$j(document).ready(function() {

	if (document.referrer.indexOf("skidata") < 0 || window.location.search.indexOf("reCheck") == 1 || window.location.search.indexOf("langPop") == 1) {
		// Browserweiche zur Spracherkennung:
		if (navigator.appName == 'Netscape') {
			var language = navigator.language;
		} else {
			var language = navigator.browserLanguage;
		}
		
		// Sprache erkennen:
		if (language.indexOf('de') > -1) {
			langcode = "de";
		} else if (language.indexOf('en') > -1) {
			langcode = "en";
		} else if (language.indexOf('fr') > -1) {
			langcode = "fr";
		} else if (language.indexOf('it') > -1) {
			langcode = "it";
		} else if (language.indexOf('ja') > -1) {
			langcode = "ja";
		} else if (language.indexOf('ko') > -1) {
			langcode = "ko";
		} else if (language.indexOf('nl') > -1) {
			langcode = "nl";
		} else if (language.indexOf('ru') > -1) {
			langcode = "ru";
		} else if (language.indexOf('sk') > -1) {
			langcode = "sk";
		} else if (language.indexOf('es') > -1) {
			langcode = "es";
		} else {
			langcode = "none";
		}

		// com deutsch
		if (window.location.href == "http://www.skidata.com/" || window.location.href == "http://www.skidata.com" || window.location.href == "http://www.skidata.com/?reCheck=1") {
			// 1 - Cookie Umleitung
			if (readCookie("langalways") != null) {
				location.href = readCookie("langalways") + "?langPop=1";
			} else {
				// 2 - nicht deutschsprachige
				if (langcode != "de") {
					location.href = "http://www.skidata.com/en.html?reCheck=1";
				} else {
					$j.getJSON('index.php?eID=wpgeoip&langcode=' + langcode, function(data) {
						countrycode = data["geoplugin_countryCode"];
						langcode = data["langcode"];
						
						// Usern aus Deutschland die de-Tochter vorschlagen.
						if (countrycode == "DE") {
							var alwaystext = 'Immer automatisch zu der ausgewähl-<br />ten SKIDATA-Website weiterleiten.';
							var infotext = 'Kennen Sie schon unsere lokale SKIDATA Deutschland Website?';
							var infolink = 'http://www.skidata.de';
							var infoclose = 'schließen';
							var infoopen = 'öffnen';
							var infocancel = 'abbrechen';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
					});
				}
			}
		}
		
		// com englisch
		if (window.location == "http://www.skidata.com/en" || window.location == "http://www.skidata.com/en.html" || window.location == "http://www.skidata.com/en.html?reCheck=1") {
			// 1 - Cookie Umleitung
			if (readCookie("langalways") != null) {
				location.href = readCookie("langalways") + "?langPop=1";
			} else {
			
				// 2 - deutschsprachige
				if (langcode == "de") {
					location.href = "http://www.skidata.com/?reCheck=1";
				} else {
					$j.getJSON('index.php?eID=wpgeoip&langcode=' + langcode, function(data) {
						countrycode = data["geoplugin_countryCode"];
						langcode = data["langcode"];
						
						// Usern aus Belgien die be-Tochter vorschlagen.
						if (countrycode == "BE") {
							var alwaystext = 'Toujours accéder directement au site Internet SKIDATA sélectionné.';
							var infotext = 'Connaissez-vous notre site Internet français ? ';
							var infolink = 'http://www.skidata.be';
							var infoclose = 'proches';
							var infoopen = 'ouvrir';
							var infocancel = 'annuler';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Frankreich die fr-Tochter vorschlagen.
						if (countrycode == "FR") {
							var alwaystext = 'Toujours accéder directement au site Internet SKIDATA sélectionné.';
							var infotext = 'Connaissez-vous notre site Internet français ?';
							var infolink = 'http://www.skidata.fr';
							var infoclose = 'proches';
							var infoopen = 'ouvrir';
							var infocancel = 'annuler';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Italien die it-Tochter vorschlagen.
						if (countrycode == "IT") {
							var alwaystext = 'Trasferiscimi sempre al sito SKIDATA selezionato.';
							var infotext = 'Conoscete già il nostro sito locale SKIDATA www.skidata.it?';
							var infolink = 'http://www.skidata.it';
							var infoclose = 'chiudere';
							var infoopen = 'apri';
							var infocancel = 'annulla';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Japan die jp-Tochter vorschlagen.
						if (countrycode == "JP") {
							var alwaystext = '選択した SKIDATA ウェブサイトへ常に自動的に転送する。';
							var infotext = '当社の地域別ウェブサイトSKIDATA www.skidata.co.jp を既にご存知ですか?';
							var infolink = 'http://www.skidata.co.jp';
							var infoclose = '近くに';
							var infoopen = '開く';
							var infocancel = 'キャンセル';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Korea die kr-Tochter vorschlagen.
						if (countrycode == "KR") {
							var alwaystext = '선택한 SKIDATA 홈페이지로 항상 자동으로 이동하기';
							var infotext = 'SKIDATA jp.skidata.com/?L=8 홈페이지를 방문해 보셨습니까? ';
							var infolink = 'http://jp.skidata.com/?L=8';
							var infoclose = '가까운';
							var infoopen = '열기';
							var infocancel = '취소';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus den Niederlanden die nl-Tochter vorschlagen.
						if (countrycode == "NL") {
							var alwaystext = 'Altijd automatisch doorsturen naar de geselecteerde SKIDATA website. ';
							var infotext = 'Kent u al onze lokale SKIDATA www.skidata.nl website? ';
							var infolink = 'http://www.skidata.nl';
							var infoclose = 'dicht';
							var infoopen = 'openen';
							var infocancel = 'annuleren';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Russland die ru-Tochter vorschlagen.
						if (countrycode == "RU") {
							var alwaystext = 'Всегда автоматически перенаправлять на выбранный сайт SKIDATA.';
							var infotext = 'Вы уже знакомы с нашим локальным сайтом SKIDATA www.skidata.ru?';
							var infolink = 'http://www.skidata.ru';
							var infoclose = 'близко';
							var infoopen = 'открыть';
							var infocancel = 'отменить';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus der Slowakei die sk-Tochter vorschlagen.
						if (countrycode == "SK") {
							var alwaystext = 'Vždy automaticky presmerovať na vybranú webovú stránku SKIDATA.';
							var infotext = 'Poznáte už našu lokálnu webovú stránku SKIDATA www.skidata.sk? ';
							var infolink = 'http://www.skidata.sk';
							var infoclose = 'zavrieť';
							var infoopen = 'otvoriť ';
							var infocancel = 'storno';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Spanien die es-Tochter vorschlagen.
						if (countrycode == "ES") {
							var alwaystext = 'Reconducir automáticamente a la página web de SKIDATA seleccionada.';
							var infotext = '¿Conoce ya nuestra página web local de SKIDATA de www.skidata.es?';
							var infolink = 'http://www.skidata.es';
							var infoclose = 'cerca';
							var infoopen = 'abrir';
							var infocancel = 'cancelar';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus Chile die cl-Tochter vorschlagen.
						if (countrycode == "CL") {
							var alwaystext = 'Reconducir automáticamente a la página web de SKIDATA seleccionada.';
							var infotext = '¿Conoce ya nuestra página web local de SKIDATA de www.skidata.cl?';
							var infolink = 'http://www.skidata.cl';
							var infoclose = 'cerca';
							var infoopen = 'abrir ';
							var infocancel = 'cancelar';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
						
						// Usern aus USA die us-Tochter vorschlagen.
						if (countrycode == "US") {
							var alwaystext = 'Always redirect automatically to the selected SKIDATA website. ';
							var infotext = 'Have you visited our local SKIDATA www.skidata.com website?';
							var infolink = 'http://www.skidatausa.com/';
							var infoclose = 'Close';
							var infoopen = 'Open';
							var infocancel = 'Cancel';
							var infoid = 'langopen';
							showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
						}
					});
				}
			}
		}
		
		// sub de
		if (window.location == "http://www.skidata.de" || window.location == "http://www.skidata.de/" || window.location == "http://www.skidata.de/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
				var alwaystext = 'Immer automatisch zur ausgewählten SKIDATA-Website weiterleiten.';
				var infotext = 'Sie wurden soeben  auf www.skidata.de weitergeleitet.';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'schließen';
				var infoopen = 'zurück';
				var infocancel = 'abbrechen';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		 //belgien
		if (window.location == "http://www.skidata.be" || window.location == "http://www.skidata.be/" || window.location == "http://www.skidata.be/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
				var alwaystext = 'Toujours accéder directement au site Internet SKIDATA sélectionné.';
				var infotext = 'Vous avez été redirigé(e) vers skidata.be';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'proches';
				var infoopen = 'retour';
				var infocancel = 'annuler';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		  //frankreich
		if (window.location == "http://www.skidata.fr" || window.location == "http://www.skidata.fr/" || window.location == "http://www.skidata.fr/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
				var alwaystext = 'Toujours accéder directement au site Internet SKIDATA sélectionné.';
				var infotext = 'Vous avez été redirigé(e) vers skidata.fr';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'proches';
				var infoopen = 'retour';
				var infocancel = 'annuler';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		      //italien
		if (window.location == "http://www.skidata.it" || window.location == "http://www.skidata.it/" || window.location == "http://www.skidata.it/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Trasferiscimi sempre al sito SKIDATA selezionato.';
				var infotext = 'Siete appena stati trasferiti su skidata.it.';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'chiudere';
				var infoopen = 'indietro';
				var infocancel = 'annulla';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		     //japan
		if (window.location == "http://jp.skidata.com/?L=5" || window.location == "http://jp.skidata.com/?L=5&langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		    var alwaystext = '選択した SKIDATA ウェブサイトへ常に自動的に転送する。';
				var infotext = '只今 skidata.co.jp に転送中です。';
				var infolink = 'http://www.skidata.com';
				var infoclose = '近くに';
				var infoopen = '戻る';
				var infocancel = 'キャンセル';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		     //korea
		if (window.location == "http://jp.skidata.com/?L=8" || window.location == "http://jp.skidata.com/?L=8&langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		    var alwaystext = '선택한 SKIDATA 홈페이지로 항상 자동으로 이동하기';
					var infotext = 'www.skidata.com/?L=8 으로 이동되었습니다.';
					var infolink = 'http://www.skidata.com';
					var infoclose = '가까운';
					var infoopen = '뒤로';
					var infocancel = '취소';
					var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}            
		}
		//Niederlande
		if (window.location == "http://www.skidata.nl" || window.location == "http://www.skidata.nl/" || window.location == "http://www.skidata.nl/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Altijd automatisch doorsturen naar de geselecteerde SKIDATA website. ';
				var infotext = 'U werd net doorgestuurd naar skidata.nl';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'dicht';
				var infoopen = 'terugkeren';
				var infocancel = 'annuleren';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		
		//Russland
		if (window.location == "http://www.skidata.ru" || window.location == "http://www.skidata.ru/" || window.location == "http://www.skidata.ru/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Всегда автоматически перенаправлять на выбранный сайт SKIDATA.';
				var infotext = 'Вы только что были перенаправлены на сайт skidata.ru.';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'близко';
				var infoopen = 'возвращение';
				var infocancel = 'отменить';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		
		//Slovakei
		if (window.location == "http://www.skidata.sk" || window.location == "http://www.skidata.sk/" || window.location == "http://www.skidata.sk/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Vždy automaticky presmerovať na vybranú webovú stránku SKIDATA.';
				var infotext = 'Práve ste boli presmerovaní na skidata.sk.';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'zavrieť';
				var infoopen = 'návrat ';
				var infocancel = 'storno';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		
		//Spanien
		if (window.location == "http://www.skidata.es" || window.location == "http://www.skidata.es/" || window.location == "http://www.skidata.es/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Reconducir automáticamente a la página web de SKIDATA seleccionada.';
				var infotext = 'Acaba de ser reconducido a skidata.es.';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'cerca';
				var infoopen = 'volver';
				var infocancel = 'cancelar';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		
		//Chile
		if (window.location == "http://www.skidata.cl" || window.location == "http://www.skidata.cl/" || window.location == "http://www.skidata.cl/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Reconducir automáticamente a la página web de SKIDATA seleccionada.';
				var infotext = 'Acaba de ser reconducido a skidata.cl.';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'cerca';
				var infoopen = 'volver';
				var infocancel = 'cancelar';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
		
		//USA
		if (window.location == "http://www.skidata.com" || window.location == "http://www.skidata.com/" || window.location == "http://www.skidata.com/?langPop=1") {
			if (window.location.search.indexOf("langPop") == 1) {
		  	var alwaystext = 'Always redirect automatically to the selected SKIDATA website. ';
				var infotext = 'You have been redirected to skidata.com';
				var infolink = 'http://www.skidata.com';
				var infoclose = 'Close';
				var infoopen = 'return';
				var infocancel = 'Cancel';
				var infoid = 'langreturn';
				showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
			}
		}
							
	}
	
	

/*
	// Sprache abfangen
	//if (window.location.search.indexOf("lang") > -1) { // diese Zeile entfernen wenn es online soll (und unten)
		
		if (window.location.search.indexOf("langPop") > -1) { // Prüfen ob nicht von Skidata kommend oder URL Parameter übergeben
			// Umleiten wenn Cookie gesetzt
			if (readCookie("langalways") == 1) {
				location.href = infolink + "#langpop";
			}
		}
		
		if (document.referrer.indexOf("skidata") < 0) { // Prüfen ob nicht von Skidata kommend oder URL Parameter übergeben
			
			// Land erkennen mit PHP/Ajax
			$j.getJSON('index.php?eID=wpgeoip&langcode=' + langcode, function(data) {
				countrycode = data["geoplugin_countryCode"];
				langcode = data["langcode"];
				
				// Belgien
				if (window.location == "http://www.skidata.be") {
					var alwaystext = 'Immer automatisch zu der ausgewähl-<br />ten SKIDATA-Website weiterleiten.';
					var infotext = 'Sie wurden umgeleitet';
					var infolink = 'http://www.skidata.com/';
					var infoclose = 'schließen';
					var infoopen = 'zurück';
					var infocancel = 'abbrechen';
						var infoid = 'langreturn';
					showlangpop(alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid);
				}

			});
			
		}
*/
	//} // diese Zeile entfernen wenn es online soll (und oben)
	
	// prettyPhoto
	// /fileadmin/templates/images/prettyPhoto/light_rounded/sprite.png
	$j(".youtube").prettyPhoto({
		theme: 'dark_rounded', /* pp_default / light_rounded / dark_rounded / light_square / dark_square / facebook */
		social_tools: ''
	});
	
	// Leere Suche verhindern:
	$j("#searchform").submit(function() {
		if ($j(".searchinput").val() == "") {
			return false;
		}
	});
//////////////////////////////////////////////////////////////////////////////////////

	// Lokale Websites Link deaktivieren
	$j(".toplinklocal DL DT A").click(function() { return false; });

//////////////////////////////////////////////////////////////////////////////////////
// Subsidiary dropdown start //
	//$j(".dropdown img.flag").addClass("flagvisibility");
	
	
	
	$j(".dropdown dt a").click(function() {
		$j(".dropdown dd ul").toggle();
	});
				
	$j(".dropdown dd ul li a").click(function() {
		var text = $j(this).html();
		// do not show selection after click
		//$j(".dropdown dt a span").html(text);
		$j(".dropdown dd ul").hide();
		// $j("#result").html("Selected value is: " + getSelectedValue("sample"));
		// $j("#result").html("Selected value is: " + getSelectedValue("sample"));
	});
				
	// function getSelectedValue(id) {
	// 	return $j("#" + id).find("dt a span.value").html();
	// }
	
	$j(document).bind('click', function(e) {
		var $jclicked = $j(e.target);
		if (! $jclicked.parents().hasClass("dropdown"))
			$j(".dropdown dd ul").hide();
	});
	
	//$j("#flagSwitcher").click(function() {
	//	$j(".dropdown img.flag").toggleClass("flagvisibility");
	//});
// Subsidiary dropdown end //
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
// Megamenue start //
	function addMega(){
		$j(this).addClass("hovering");
	}
	function removeMega(){
		$j(this).removeClass("hovering");
	}
	var megaConfig = {
		interval: 300,
		sensitivity: 4,
		over: addMega,
		timeout: 300,
		out: removeMega
	};
	$j("li.mega").hoverIntent(megaConfig)
// Megamenue end //
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
// Symbol start //
	
	$j(".symbol").click(function() {
		if ($j(this).find("a").attr("target") == "_blank") {
			window.open("/" + $j(this).find("a").attr("href"));
		} else {
			window.location.href = "/" + $j(this).find("a").attr("href");
		}
		return false;
	});
	
	$j(".symbol").hover(
		function () {
			$j(this).addClass("symbol_active");
		},
		function () {
			$j(this).removeClass("symbol_active");
		}
	);

// Symbol end //
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
// Content Tabs generation start //

	// Generate Klickmenu on Top
	tabCount = 0;
	$j(".tab_container").each(function(){
		tabCount ++;
		tabsCount = ($j(this).children().length);
		mylist = "";
		for (i=0; i<tabsCount; i++) {
			target = i+1
			mytext = $j(this).find(".tab_all .tab_header H2").eq(i).text();
			mylist+= '<li><a href="#tab' + target + '">' + mytext + '</a></li>';
		}
		$j(this).before('<ul class="tabs" id="tabNav' + tabCount + '">' + mylist + '</ul>'); // Füge Topnav ein
		$j(this).attr('id', 'tabItem' + tabCount); // Setzte ID
		
		$j(this).find(".tab_all").hide(); //Hide all content
		$j(this).find(".tab_header").hide(); //Hide all headers
		$j("#tabNav" + tabCount + " li:first").addClass("active"); //Activate first tab
		$j(this).find(".tab_all:first").show(); //Show first tab content
	});
	// Click Function
	$j("ul.tabs li").click(function() {
		var activeTab = $j(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		var laenge = activeTab.length;
		var activeTab = activeTab.substr(laenge-1, 1) -1;
		
		$j(this).parent().find("li").removeClass("active"); //Remove any "active" class
		$j(this).addClass("active"); //Add "active" class to selected tab
		$j(this).parent().parent().find(".tab_container .tab_all").hide(); //Hide all tab content
		$j(this).parent().parent().find(".tab_container").find(".tab_all").eq(activeTab).show(); //Fade in the active ID content
		
		//move tab on top of page		
		/*
		var target_offset = $j("ul.tabs").offset();
		var target_top = target_offset.top - 10;	
		$j('html, body').scrollTop(target_top);
		*/
		return false;
	});

/*
	mylist = "";
	tabsCount = $j('.tab_header').length;
	for (i=0; i<tabsCount; i++) {
		target = i+1
		mytext = $j('.tab_header H2').eq(i).text();
		mylist+= '<li><a href="#tab' + target + '">' + mytext + '</a></li>';
	}
	$j(".tab_container").before('<ul class="tabs">' + mylist + '</ul>');
				
// Content Tabs function start //
	$j(".tab_all").hide(); //Hide all content
	$j(".tab_header").hide(); //Hide all headers
	//$j(".tab_container").css("border-top","none"); //Disable Border-Top
	$j("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$j(".tab_all:first").show(); //Show first tab content
	//On Click Event
	$j("ul.tabs li").click(function() {
		$j("ul.tabs li").removeClass("active"); //Remove any "active" class
		$j(this).addClass("active"); //Add "active" class to selected tab
		var activeTab = $j(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		var startpos = activeTab.lastIndexOf("#");
		var laenge = activeTab.length;
		var activeTab = activeTab.substring(startpos, laenge);
		$j(".tab_all").hide(); //Hide all tab content
		//$j(activeTab).fadeIn(); //Fade in the active ID content
		$j(activeTab).show(); //Fade in the active ID content
		//move tab on top of page		
		var target_offset = $j("ul.tabs").offset();
		var target_top = target_offset.top - 10;	
		//$j('html, body').scrollTop(target_top);
		return false;
	});
*/

// Content Tabs end //
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
// Image Slider start  //
	$j('.jcarousel-skin-slider').jcarousel({
		scroll: 1,
		wrap: 'circular',
		auto: 10,
		initCallback: mycarousel_initCallback
	});
	$j('.jcarousel-skin-related').jcarousel({
		scroll: 1,
		wrap: 'circular',
		auto: 10,
		initCallback: mycarousel_initCallback
	});
	
// Home
	var anzahl_hs = $j('.jcarousel-skin-home').children().length;
	for (i=0; i<anzahl_hs; i++) {
		zahl = i+1;
		$j(".paging").append('<a href="javascript:;">' + zahl + '</a>');
	}
	$j(".paging").show();
	
	$j('.jcarousel-skin-home').jcarousel({
		scroll: 1,
		wrap: 'circular',
		auto: 10,
        buttonNextHTML: null,
        buttonPrevHTML: null,
		initCallback: mycarousel_initCallback,
//		itemVisibleInCallback: home_itemVisibleInCallback
		itemVisibleInCallback: {
		  onBeforeAnimation: home_itemVisibleInCallback
//		  onAfterAnimation: home_itemVisibleInCallback
		}
	});

// Image Slider end //
//////////////////////////////////////////////////////////////////////////////////////

});

//////////////////////////////////////////////////////////////////////////////////////
// TopUp click enlarge - Presets start//
TopUp.addPresets({
  ".video": {
    //layout: "quicklook",//
    shaded: 1,
    overlayClose: 1,
    title: "watch movie",
    width: 850,
    height: 450
  },
  /*
    ".youtube": {
    type: "flashvideo",
    layout: "quicklook",
    shaded: 1,
    overlayClose: 1,
    title: "watch movie on youtube",
    width: 850,
    height: 450
  },
  */
    ".showhtml": {
    type: "iframe",
    layout: "quicklook",
    shaded: 1,
    overlayClose: 1,
    title: "open html pages",
    width: 850,
    height: 450
  }
});
// TopUp click enlarge - Presets end//
//////////////////////////////////////////////////////////////////////////////////////


function mycarousel_initCallback(carousel)
{
	
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
	

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
    // Home Scroller
    $j('.paging A').bind('click', function() {
        carousel.scroll($j.jcarousel.intval($j(this).text()));
		//$j(".paging A").removeClass('active'); //Remove all active class
		//$j(this).addClass('active'); //Add active class (the $jactive is declared in the rotateSwitch function)
        return false;
    });
    
};
function home_itemVisibleInCallback(carousel,li,c_index) {
	//Remove all active class
	$j(".paging A").removeClass('active');
	
	//Add active class
	myitems = $j(".paging A").length;
	myindex = (c_index%myitems) -1;
	$j(".paging A").eq(myindex).addClass('active');
}

function showlangpop (alwaystext, infoclose ,infotext ,infolink ,infoopen ,infocancel, infoid) {
	var lang1 = '<div class="langpop"><div class="langalways"><div class="langalwayscheck"><input type="checkbox" id="langalways" checked="checked" /></div><div class="langalwaystext"><label for="langalways">';
	var lang2 = '</label></div></div><div class="langinfo"><a class="langclose" href="#"><img src="fileadmin/templates/img/lang_close.gif" alt="';
	var lang3 = '" width="8" height="8" /></a>';
	var lang4 = ' [ <a href="';
	var lang5 = '" id="'+infoid+'">';
	var lang6 = '</a> ] [ <a href="#" id="langclose">';
	var lang7 = '</a> ]</div></div>';
	var fadespeed = 500;
	$j("#outer").append(lang1 + alwaystext + lang2 + infoclose + lang3 + infotext + lang4 + infolink + lang5 + infoopen + lang6 + infocancel + lang7);
	$j(".langpop").hide();
	$j(".langpop").fadeIn(fadespeed);
	
	$j("#langopen").click(function() {
		if ($j("#langalways").attr("checked")) {
			createCookie("langalways", $j(this).attr("href"), 300);
		}
	});
	
	$j("#langreturn").click(function() {
		if ($j("#langalways").attr("checked") != true) {
			location.href="http://www.skidata.com/fileadmin/templates/delCookie.html";
			return false;
		}
	});
	
	$j("#langclose").click(function() {
		$j(".langpop").hide();
		return false;
	});
	
	$j(".langclose").click(function() {
		$j(".langpop").hide();
		return false;
	});
	
}

function createCookie(name,value,days) {
  if (days > 0) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }  
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

