
linux_font_debug();


function startJPKScripts(){

	// Nur starten, wenn Argument übergeben wurde
	for (var i = 0; i < startJPKScripts.arguments.length; ++i){
		if(startJPKScripts.arguments[i] == 'ticker'){
			if (typeof(startJPKTicker)!="undefined"){
				window.setTimeout("startTicker()", 13000);				
			}
		}
	}
	
	// Grundsätzlich starten
	if(typeof(swapDivs)!="undefined"){
		initJpkSwapDivs();
	}
	
	// geo decoding starten
	geo();
}

function test_platform(testOS){
	os = navigator.platform;
	if (os.indexOf(testOS)!= -1){
		return true;	
	}
	return false;
}


// Linux Debug Schriftgrösse
function linux_font_debug(){
	if (test_platform("Linux")){
		document.write('<style type="text/css"><!-- body { font-size: 70%; }  --></style>');	
	}
}


// GEO Decoding ////////////////////////////////

function geo() {
	if (!document.getElementsByTagName) // Check for browser support
			return false;
	if (rot13) // Initiate ROT13 only if needed
		var map = rot13init(); 

	var links = document.getElementsByTagName('a'); // Get all anchors
	function geo_decode(anchor) { // function to recompose the orginal address
		var href = anchor.getAttribute('href');
		var address = href.replace(/.*sendToJPK\/([a-z0-9._%-]+)\+([a-z0-9._%-]+)\+([a-z.]+)/i, '$1' + '@' + '$2' + '.' + '$3');
		var linktext = anchor.innerHTML; // IE Fix
		if (href != address) {
			anchor.setAttribute('href','mailto:' + (rot13 ? str_rot13(address,map) : address)); // Add mailto link	
			anchor.innerHTML = linktext; // IE Fix
		  pageTracker._trackPageview('/mailto/' + (rot13 ? str_rot13(address,map) : address)); // Track in Google Analytics
		}
	}
	for (var l = 0 ; l < links.length ; l++) { // Loop through the anchors
		links[l].onclick = function() { // Encode links when clicked
			geo_decode(this);
		}
	}
}

var rot13 = 'mijsflkerewr';

function rot13init() {
	var map = new Array();
	var s = "abcdefghijklmnopqrstuvwxyz";
	for (var i = 0 ; i < s.length ; i++)
		map[s.charAt(i)] = s.charAt((i+13)%26);
	for (var i = 0 ; i < s.length ; i++)
		map[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase();
	return map;
}

function str_rot13(a,map) {
	var s = "";
	for (var i = 0 ; i < a.length ; i++) {
		var b = a.charAt(i);
		s += (b>='A' && b<='Z' || b>='a' && b<='z' ? map[b] : b);
	}
	return s;
} 



// SubNavigation bei Hover ///////////////////////////
actSubNav=0;
function showSubNav(elem, nr){
	hideActSubNav(elem);
	element = document.getElementById(elem+nr);
	if(element) element.style.display='block';
	actSubNav=nr;
}

function hideActSubNav(elem){
	element = document.getElementById(elem+actSubNav); 
	if(element) element.style.display='none';
}



// Filter
function callFilter(formName){
//	href = href + '?' + filterName + mySelect.options[mySelect.selectedIndex].value;
	document.getElementById(formName).submit();
}

// Contact Adresses Worldwide


function showAdresseWorldwide(){
	sel = document.getElementById('adresses_worldwide'); 
	newAdresse = sel.options[sel.selectedIndex].value;
	// Alte Adresse ausblenden
	if(actAdresse != 'none'){
		document.getElementById(actAdresse).style.display = 'none';
	}
	// Neue Adress einblenden
	document.getElementById(newAdresse).style.display = 'block';
	actAdresse = newAdresse;

}

function showGlobalOffice(country){
	// Alte Adresse ausblenden
	if(actAdresse != 'none'){
		document.getElementById(actAdresse).style.display = 'none';
	}
	// Neue Adress einblenden
	document.getElementById(country).style.display = 'block';
	actAdresse = country;

}

function initJpkSwapDivs(divObj){
	jpkSwapDivsInterval = window.setInterval("jpkSwapDivs()", 5000);
}

function jpkSwapDivs(){
	for(i=0; i<swapDivsArray.length ; i++){
		// aktuelle Box ausblenden
		actBoxNr = swapDivsArray[i]['actBox'];
		actBox = 'box_' + swapDivsArray[i]['id'] + '_' + actBoxNr;
		document.getElementById(actBox).style.display = 'none';
		// Neue Box einblenden
		swapDivsArray[i]['actBox'] = (swapDivsArray[i]['actBox'] == swapDivsArray[i]['boxes'].length) ? 1 : swapDivsArray[i]['actBox'] + 1;
		newBox = 'box_' + swapDivsArray[i]['id'] + '_' + swapDivsArray[i]['actBox'];
		document.getElementById(newBox).style.display = 'block';
	}
	
	

}



//LoadEvent
// funktioniert nicht im FF
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


// Noch ein LoadEvent
// funktioniert auch nicht im FF
// addEvent(window, 'load', foo);
function addJPKEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}


// Steuerung der Register Tabs
var activeRegister = '';

jpkRegister = function() {
	var jpkReg = document.getElementById("jpk_register");
	var regLabels = jpkReg.getElementsByTagName("LI");
	for (var i=0; i<regLabels.length; i++) {
		regLabels[i].onmouseover=function() {
			if(this.className!='active'){
				this.className+="over";
			}
		}
		regLabels[i].onmouseout=function() {
			this.className = this.className.replace(new RegExp("over\\b"), "");
		}
		regLabels[i].onclick=function() {
			if(this.className!='active'){
				// Label Active setzen
				this.className="active";
				document.getElementById(activeRegister+'_label').className = '';
				// Div umblenden
				var activeItem = document.getElementById(activeRegister);
				var newItem = document.getElementById(this.title)  ;
				activeItem.className = activeItem.className.replace(new RegExp(" active\\b"), "");
				newItem.className += ' active';
				activeRegister = this.title;
			}
		}
	}
}


