function fctGetObjectById(id) {
  if (document.all) {
    var obj = document.all[id];
    if (obj.length) {
      return obj[0];
    } else {
      return obj;
    }
  } else {
   return document.getElementById(id);
  }
}

function fctSetTitleClick() {
initFontSize();
}



function fctGetElementsByClassName(cssClass,tag,element) {
 var elements;
 var returnElements=new Array();
 if (typeof element != "object") element = document;
 if (tag) { 
   if (document.all) {
     elements = element.all.tags(tag);
   } else if (document.getElementsByTagName) {
     elements = element.getElementsByTagName(tag);
   }
 } else {
    if (document.all) {
      elements = element.all;
    } else if (document.childNodes) {
      elements = element.childNodes
    }
 }

 for (var i=0;i<elements.length;i++) {
  if (elements[i].className == cssClass) {
   returnElements[returnElements.length] = elements[i];
  }
 }
 return  returnElements;
}

function fctSetTitle() {
  for (var j = 0;j < setTitle.length; j++) {
    if (document.all) {		
      var element = fctGetElementsByClassName("rahmen", "div", fctGetObjectById(setTitle[j]));
      if (element.length > 0) {
           fctShowDiv(element[0]);
      }
    }
  }
}
/****************************************************** NAVIGATION **************************************************************************************/




function fctPhotogalerie(actID,nextID) {

 var obj = false;
 var nextObj = false;

 if (document.all)  {
      obj =  document.all["image"+actID];
      nextObj =   document.all["image"+nextID];
 } else if (document.getElementById) {
        obj = document.getElementById("image"+actID)
        nextObj = document.getElementById("image"+nextID)
 }

 if (obj) obj.className="nodisplay";
 if (nextObj) nextObj.className="showdisplay";
 }

/************************************* Backbutton bei Bedarf anzeigen *****************************************/

function fctBackButton(text) {

 if (!text || text=="") return "";

// if (document.referrer.indexOf(location.hostname) > -1) {
   return '<a href="#" onclick="history.back();return false;" class="zurueckAlt rechts">'+text+'</a>'

// }

 return "";

}


/**** open Popup ****/
function fctOpenWin(resource,height,width,top,left,blnScrollbar,blnResizable,blnMenubar,targetname) 
{
   if(targetname=="_blank") {
     F = window.open(resource,targetname);
     if (F.focus) F.focus();
   } else {

     if( targetname=="") targetname = "MyWindow";

    if (typeof blnScrollbar == "boolean") {
       if (blnScrollbar) blnScrollbar='yes'; else  blnScrollbar='no';
     }
     if (typeof blnScrollbar == "boolean"){
       if (blnResizable) blnResizable='yes'; else blnResizable='no';
     }
     if (typeof blnScrollbar == "boolean"){
       if (blnMenubar) blnMenubar='yes'; else blnMenubar='no';
     }

   if (blnScrollbar == "true" || blnScrollbar == "1") blnScrollbar='yes';
   if (blnResizable == "true"|| blnResizable == "1") blnResizable='yes';
   if (blnMenubar == "true" || blnMenubar == "1") blnMenubar='yes';

/**** Stream-Zwischenloesung Anfang ****/
   stream = new Array();
   stream[0] = "http://q8i91.kiel01.telekom.de/livdoc01/";
   stream[1] = "http://q8i34.kiel01.telekom.de/livdoc01/";

   if  ((resource.indexOf("=")!=-1) && (resource.indexOf(".wmv")!=-1)) {
      resource=resource.split("/");
      resource=stream[Math.floor(Math.random()* 2)]+ 'random_neu.html?'+ resource[resource.length-1];
      }
/**** Stream-Zwischenloesung Ende ****/   

     F = window.open(resource,targetname,"height="+height+",width="+width+",menubar="+blnMenubar+",resizable="+blnResizable+",scrollbars="+blnScrollbar+",left="+left+",top="+top);
     if (F.focus) F.focus();
  }
return F;
}

function selektierterText () {
  if (window.getSelection) {
    return(window.getSelection());
  } else if (document.getSelection) {
    return(document.getSelection());
  } else if (document.selection) {
    return(document.selection.createRange().text);
  }
}


//myHelper = new helper();
/**
 * checks if browser is mf**** ie6
 */
function isIE6() {
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	if((is_major == 4) && (agt.indexOf("msie 6.")!=-1)) {
		return true;
	}
	return false;
}

/**
 * @description: modul: who is who -> show and hide user details
 * @autor: mme
 */
function switchPersonDetails(el){
	var cn;
	var node = el.parentNode.parentNode.nextSibling;
	while (node.nodeType != 1) {
		node = node.nextSibling;
	}
	if (document.all) {
		cn = "className";
	}
	else if(document.getElementById) {
		cn = "class";
	}
	if (node.getAttribute(cn) == "details_hidden") {
		node.setAttribute(cn, "details_visible");
		el.setAttribute(cn, "minus");
	}
	else if (node.getAttribute(cn) == "details_visible") {
		node.setAttribute(cn, "details_hidden");
		el.setAttribute(cn, "plus");
	}
}
/**
 * @description: modul: linkliste
 * @autor: mme
 */
function showList(el){
	var cn;
	var node = el.parentNode.nextSibling;
	while (node.nodeType != 1) {
		node = node.nextSibling;
	}
	if (document.all) {
		cn = "className";
	}
	else if(document.getElementById) {
		cn = "class";
	}
	if (node.getAttribute(cn) == "hidden") {
		node.setAttribute(cn, "visible");
		el.setAttribute(cn, "minus");
	}
	else if (node.getAttribute(cn) == "visible") {
		node.setAttribute(cn, "hidden");
		el.setAttribute(cn, "plus");
	}
}
/**
 * @description: modul: fontsize switcher
 * @autor: mme
 * @param: string plus or minus
 * @ToDo: img styles 
 */
function switchFontSize(what){
	var fu = "px";
	var oldfs = null;
	var newfs;
	var min = 11;
	var max = 15;
	//ie
	if (document.all) {
		var fs = parseFloat(document.body.currentStyle.fontSize);
		if(isIE6()) oldfs =  Math.round(fs*0.16);
		else oldfs = fs;
		if (what == "minus") {
			if(oldfs <= min) return false;
			newfs = oldfs - 1;
		}
		if (what == "plus") {
			if(oldfs >= max) return false;
			newfs = oldfs + 1;
		}
		if (isIE6()) {
			document.getElementsByTagName('body')[0].style.fontSize = newfs * 6.25 + "%";
		}
		else {
			document.getElementsByTagName('body')[0].style.fontSize = newfs  + fu;
		}
	}
	//browser
	else if(document.getElementById) {
		oldfs = parseFloat(window.getComputedStyle(document.body, null).fontSize);
		if (what == "minus") {
			if(oldfs <= min) return false;
			newfs = oldfs - 1;
		}
                     		if (what == "plus") {
			if(oldfs >= max) return false;
			newfs = oldfs + 1;
		}
		document.getElementsByTagName('body')[0].style.fontSize = newfs + fu;
	}
	moveFader(newfs);
	setFontSizeCookie(newfs);
}
/**
 * @autor: mme
 * @description: move the fader left or right
 */
function moveFader(newfs) {
	var cs = fctGetObjectById('fontsize_scale_img');
	switch(parseInt(newfs)) {
		case 11:
			cs.style.marginLeft = "0px";
			// document.all.area1.coords = "0, 30, 350, 80";
			// document.getElementById("area2").coords = 0, 0, 0, 0";
			// document.getElementById("area3").coords = 0, 0, 0, 0";
			// document.getElementById("area4").coords = 0, 0, 0, 0";
			// document.getElementById("area5").coords = 0, 0, 0, 0";
			
		break;
		case 12:
			cs.style.marginLeft = "20px";
			// document.all.area2.coords = "0, 30, 400, 100";
			// document.getElementById("area1").coords = "0, 0, 0, 0";
			// document.getElementById("area3").coords = "0, 0, 0, 0";
			// document.getElementById("area4").coords = "0, 0, 0, 0";
			// document.getElementById("area5").coords = "0, 0, 0, 0";
			
		break;
		case 13:
			cs.style.marginLeft = "45px";
			// document.all.area3.coords = "0, 30, 450, 120";
			// document.getElementById("area1").coords = "0, 0, 0, 0";
			// document.getElementById("area2").coords = "0, 0, 0, 0";
			// document.getElementById("area4").coords = "0, 0, 0, 0";
			// document.getElementById("area5").coords = "0, 0, 0, 0";
		break;
		case 14:
			cs.style.marginLeft = "80px";
			// document.all.area4.coords = "0, 30, 500, 140";
			// document.getElementById("area1").coords = "0, 0, 0, 0";
			// document.getElementById("area2").coords = "0, 0, 0, 0";
			// document.getElementById("area3").coords = "0, 0, 0, 0";
			// document.getElementById("area5").coords = "0, 0, 0, 0";
		break;
		case 15:
			cs.style.marginLeft = "95px";
			// document.all.area5.coords = "0, 30, 550, 160";
			// document.getElementById("area1").coords = "0, 0, 0, 0";
			// document.getElementById("area2").coords = "0, 0, 0, 0";
			// document.getElementById("area3").coords = "0, 0, 0, 0";
			// document.getElementById("area4").coords = "0, 0, 0, 0";
		break;
	}
}
/**
 * @autor: mme
 * @param: {Object} nfs 
 * @description: create a cookie with current fontsize 
 */
function setFontSizeCookie(newfs) {
	var days = new Date();
	var tmp = days.getTime() + (1 * 24 * 60 * 60 * 1000); //1 day
	days.setTime(tmp);
	document.cookie = "fontsize="+newfs+"; expires=" + days.toGMTString()+ ";path=/";
}
/**
 * @autor: mme
 * @description: read cookie and init fontsize - execute this at document ready
 */
function initFontSize() {
	var nameEQ = "fontsize=";
	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) {
			var newfs = c.substring(nameEQ.length, c.length);
			if (isIE6()) {
				document.getElementsByTagName('body')[0].style.fontSize = newfs*6.25 + "%"; 
			}
			else if (document.getElementById) {
				document.getElementsByTagName('body')[0].style.fontSize = newfs + "px";  
			}
			moveFader(newfs);
		}
	}
	return null;
}
function showTooltip(id){
	var element = fctGetObjectById(id);
	//element.style.visibility = "visible";
	element.style.display = "block";
}
function hideTooltip(id){
	var element = fctGetObjectById(id);
	//element.style.visibility = "hidden";
	element.style.display = "none";
}

function setFormCookie(id) {
	var days = new Date();
	var tmp = days.getTime() + (1 * 24 * 60 * 60 * 1000); //1 day
	days.setTime(tmp);
	document.cookie = "form"+id+"=true; expires=" + days.toGMTString()+";path=/dtag/cms/;";

}

function getFormCookie(id) {

var mein_cookie = document.cookie; 
  if (mein_cookie.indexOf('form'+id) == -1) { 
    return false;
  } else {
    return true;
  }
}

/* Startseite, Einstieg nach Zielgruppen */
/*
 function fctSelectList(value) {
if (!value || value=="") return;
value = value.split("|");
if (value.length>1) {
var modify = value[1].split(",");
switch (modify[0]) {
case "blank": window.open(value[0],"_blank");break;
case "top": top.location.href=value[0];break;
case "parent": parent.location.href=value[0];break;
default:
if (isNaN(modify[0]) && top.frames[modify[0]])
top.frames[modify[0]].location.href=value[0];
else if (!isNaN(modify[0])) {
//600,500,0,0,1,0,1,printversion
if (modify.length<8) { if (top.frames["mainframe"])
top.frames["mainframe"].location.href=value[0];
else self.location.href=value[0];
}  else {

fctOpenWin(value[0],modify[0],modify[1],modify[2],modify[3],modify[4],modify[5],modify[6],modify[7])
}

} else if (!top.frames[modify[0]]) self.location.href=value[0];
}

} else if (top.frames["mainframe"])
top.frames["mainframe"].location.href=value[0];
else self.location.href=value[0];

}
*/
function fctSelectList(url) {
    //window.open(url);
self.location.href=url;

}