/* ---- common ---- */
/****************************/
/* Common utility functions */
/****************************/
/* bugfix for IE6 - reloading background images on mouse over */
try
{	document.execCommand('BackgroundImageCache', false, true);
}
catch(ex)
{
}

/*
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}
*/
/* Find the position of a DOM Element */

function findPosition(obj) {
	var curleft = 0;
    var curtop = 0;
    if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft, curtop];      
}

/* Get the scroll offset of the window */

function getScrollXY() {
    var scrOfX = 0, scrOfY = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return [ scrOfX, scrOfY ];
}

function cancelBubbling(e) {
  if (!e) {
    var e = window.event
  }
  e.cancelBubble = true
  if (e.stopPropagation) {
    e.stopPropagation()

  }
}

/************************/
/* Global DOM Functions */
/************************/

/* Search for parents node by tagname */
function findParentNodeByTagName(obj, tagName) {

	do {
		obj = obj.parentNode;
	}  while (obj.nodeName != tagName && obj.nodeName != 'BODY')

	return (obj)
}

/* Search parents for element with specific classname */
function findParentNodeByClassName(obj, className) {

	do {
		obj = obj.parentNode;
	}  while ((obj.className.indexOf(className) == -1) && obj.nodeName != 'BODY')

	return (obj)
}

/* Search children for element(s) with specific classname */
function getElementsByClassName(obj, className, looseSearch) {
    /*
    obj = the object to search from;
    classname = the name of the class to search for;
    looseSearch = (default:true), if true then use indexOf ; if false then strict compare;
    */

    var list = new Array();
    var childrenList = obj.getElementsByTagName('DIV');
    var searchCriterium;

    if(!looseSearch)
        searchCriterium = "childrenList[i].className == className";
    else
        searchCriterium = "childrenList[i].className.indexOf(className) != -1";

    for(var i=0; i < childrenList.length; i++) {
        if(eval(searchCriterium)) {
            list.push(childrenList[i]);
            }
    }
    return (list);
}

/************************/
/* More specific Functions */
/************************/

function mailAuthor(obj) {
	var form = obj.parentNode;
	var msg = "";

	if (form.Leserbrief.value == '' && !form.Leserbrief.value) {
		msg = msg + "<li>Das Feld 'Leserbrief' muss ausgefüllt werden.</li>";
	}
	if (form.Name.value == '' && !form.Name.value) {
		msg = msg + "<li>Das Feld 'Ihre Name' muss ausgefüllt werden.</li>";
	}
	if (form.Absender.value == '' && !form.Absender.value) {
		msg = msg + "<li>Das Feld 'E-Mail Absender' muss ausgefüllt werden.</li>";
	}
	if (form.Website.value == '' && !form.Code.value) {
		msg = msg + "<li>Das Feld 'Code' muss ausgefüllt werden.</li>";
	}
	if (msg != '') {
		var errdiv = document.getElementById("formErrors");
		var ul = document.createElement("ul");
		ul.innerHTML = msg;
		if(errdiv.firstChild) {errdiv.removeChild(errdiv.firstChild)}	// Clean the error div
		errdiv.appendChild(ul);
		alert('false')
		return false;
	}
	form.submit();
	return false;
}

function switchTab (theObj) {
    /* first check if object is already active */
    if(findParentNodeByTagName(theObj, 'LI').className.indexOf('active') != -1) {
        return false;
    }

    /* root element of the tabs container */
    var tabsContainerObj = findParentNodeByClassName(theObj, 'tabbedPanes');
    /* root element of the tabs group */
    var tabsObj = findParentNodeByClassName(theObj, 'tabs');

    /* list of tab buttons */
    var tabItems = findParentNodeByClassName(theObj, 'tabs').getElementsByTagName('A');
    /* list of tab panes */
    var paneList = getElementsByClassName(tabsContainerObj, 'pane', true);

    /* find out the order number of the selected tab */
    var position;

    for (var i=0; i < tabItems.length; i++ ) {
        if (tabItems[i] == theObj) {
            position = i;
            findParentNodeByTagName(tabItems[i], 'LI').className = 'active';
            //theObj.parentNode.className = 'active';
            //alert(theObj.nodeName + "==");
        }
        else {
            findParentNodeByTagName(tabItems[i], 'LI').className = '';
            //alert(theObj.nodeName);
        }
    }

    for (var i=0; i < paneList.length; i++ ) {
        if (i == position) {
            paneList[i].className += ' active';
        }
        else {
            paneList[i].className = paneList[i].className.replace(' active','');
        }
    }
}



/* ---- cookies ---- */
/* STATUS: FINAL */

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var 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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
/* ---- styleswitcher ---- */
/*
STATUS: PENDING
TODO: this code was written in ms-write or something because the eol are not standard. 
*/

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}
function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

/* ---- modules ---- */
/*
STATUS: PENDING
TODO: Test Richmedia (just integrated)
*/

/*
	This file contains all the javascripts that are used by the modules section in the welt online site
*/

/*
	Javascript functions for the poll forum
*/
function ShowHide( id)
{
  try{
	var hideId = "vote-"+id;
	var showId = "voted-"+id;
	var hideElm = document.getElementById( hideId);
	var showElm = document.getElementById( showId);

	if ( hideElm != null && showElm != null) {
		hideElm.style.display = "none";
		showElm.style.display = "block";
	}
	var hideId = "vote-"+id+"-art";
	var showId = "voted-"+id+"-art";

	var hideElm = document.getElementById( hideId);
	var showElm = document.getElementById( showId);

	if ( hideElm != null && showElm != null) {
		hideElm.style.display = "none";
		showElm.style.display = "block";
	}

  }catch (erm){
	//alert("peiling.ShowHide()"+erm);
  }
}
function initialHide( id)
{
  try
  {
	//hide poll Q&A and show Results
	var mentometer = readCookie("mentometer");
	if ( mentometer != null )
	{
	  var mentometer_array = mentometer.split("M");
	  for ( i = 0; i < mentometer_array.length; i++ )
	  {
		if ( mentometer_array[i] != 'null' )
		{
		  if ( mentometer_array[i].match(id) )
		  {
			  ShowHide(""+id);
		  }
		}
	  }
	}
  }
  catch ( erm )
  {
	alert("displayPoll" + erm);
  }
}
/*
	end Javascript functions for the poll forum
*/



/*
 *	Start function for tabs
 */



var TabHash = {};

function showTab(tabgroup, panelid, islasttab)
{	//alert("showTab " + tabgroup + " " + panelid + " " + islasttab);
	/* First check if there's 1 tab selected (the first time its the 1st tab probably) */
	if (TabHash[tabgroup])
	{
		// If the selected tab is the lasttab 
		if (TabHash[tabgroup][2]){
			// Set a different deselect-style 
			TabHash[tabgroup][0].className="unselectedtablast";
		}else{
			// If not, set the default deselect-style
			TabHash[tabgroup][0].className="unselectedtab";
		}
		TabHash[tabgroup][1].style.display= "none";
	}
	/* Then remember the new selected Tab and remember if the tab is the lasttab (islasttab boolean) */
	TabHash[tabgroup] = [document.getElementById(tabgroup + "_" + panelid + "_tab"), document.getElementById(tabgroup + "_" + panelid), islasttab];
	TabHash[tabgroup][0].className="selected"; 
	TabHash[tabgroup][1].style.display = "block";
	/* If select tab is the last tab, show 'padding-line' */
    /* deactivated - not needed in new layout */

/*	if(islasttab){
		document.getElementById('tablastend').style.visibility = 'visible';
	}else{
		document.getElementById('tablastend').style.visibility = 'hidden';
	}
*/
}

/*
 *	End function for tabs
 */

/*
 *	Start function for slideshows
 */


var SlideHash = {};

function slide(slidegroup,delta)
{
	i=0;
	if (SlideHash[slidegroup])
	{
	if (!delta) return true;
		i = SlideHash[slidegroup][0] + (delta>0 ? 1 : -1);
		SlideHash[slidegroup][1].style.display="none";
	}

	//check to see if there if buttons still needs to be displayed
	if (document.getElementById(slidegroup + "_" + (i+1)) != null) document.getElementById(slidegroup + "_forward").style.visibility = "visible";
	else document.getElementById(slidegroup + "_forward").style.visibility = "hidden";

	if (document.getElementById(slidegroup + "_" + (i-1)) != null) document.getElementById(slidegroup + "_back").style.visibility = "visible";
	else document.getElementById(slidegroup + "_back").style.visibility = "hidden";

	SlideHash[slidegroup] = [i,document.getElementById(slidegroup + "_" + i)];
	SlideHash[slidegroup][1].style.display="block";
	return true;
}

/*
 *	End function for slideshows
 */


/*
 *	TabEx used for richmedia box
 */

var LOADED = false;
var hash_tab_ex = {};

function setTabInfo(groupid, nrtabs,cn_notsel, cn_sel, cn_first, cn_last, cn_stop, cn_stop_br)
{
        hash_tab_ex[groupid] = {};
        hash_tab_ex[groupid]["classNotSelected"] = cn_notsel;
        hash_tab_ex[groupid]["classSelected"] = cn_sel;
        hash_tab_ex[groupid]["classFirst"] = cn_first;
        hash_tab_ex[groupid]["classLast"] = cn_last;
        hash_tab_ex[groupid]["classStop"] = cn_stop;
        hash_tab_ex[groupid]["classStopBr"] = cn_stop_br;

        hash_tab_ex[groupid]["nrTabs"] = nrtabs;
        hash_tab_ex[groupid]["currentTabNr"] = -1;
}

function addFirstLast(groupid,sel)
{
        result = "";
        prefix = "";

        if (sel) prefix = hash_tab_ex[groupid]["classSelected"] + "_";
        else prefix = hash_tab_ex[groupid]["classNotSelected"] + "_";

        if (hash_tab_ex[groupid]["currentTabNr"] == 0) return " " + prefix + hash_tab_ex[groupid]["classFirst"];
        if (hash_tab_ex[groupid]["nrTabs"] == hash_tab_ex[groupid]["currentTabNr"]+1) return  " " + prefix + hash_tab_ex[groupid]["classLast"];
        return "";
}

function isLastTab(groupid)
{
        return (hash_tab_ex[groupid]["nrTabs"] == hash_tab_ex[groupid]["currentTabNr"]+1);
}

function showTabEx(groupid, tabid, tabnr)
{
        if (!document.getElementById(groupid+"_"+tabid)) return false;;
        if (!hash_tab_ex[groupid]) return false; // not initialized;

        if (hash_tab_ex[groupid]["currentTabNr"] != -1)
        {
                unsel = hash_tab_ex[groupid]["classNotSelected"] + addFirstLast(groupid,false);
                hash_tab_ex[groupid]["currentTabObj"].className = unsel;
                hash_tab_ex[groupid]["currentDivObj"].style.display = "none";
        }

        tabobj = document.getElementById(groupid + "_" + tabid + "_tab");
        divobj = document.getElementById(groupid + "_" + tabid);

        hash_tab_ex[groupid]["currentTabNr"]  = tabnr;
        hash_tab_ex[groupid]["currentTabObj"] = tabobj;
        hash_tab_ex[groupid]["currentDivObj"] = divobj;

        sel = hash_tab_ex[groupid]["classSelected"] + " " + addFirstLast(groupid,true);

        tabobj.className = sel;
        divobj.style.display = "block";

        stop = document.getElementById(groupid + "_stop_tab");
        if (stop) stop.className = (isLastTab(groupid) ? hash_tab_ex[groupid]["classStopBr"] : hash_tab_ex[groupid]["classStop"]);

        return false;
}

function startupRichmedia(divarray, tabhash)
{
	setTabInfo("rmtab", divarray.length, "tab", "tab_selected","firsttab","lasttab","rest","rest break");
	tabhash = tabhash.substring(1);
	var index = -1;

	//hide all tabs and find the id of the to be selected tab
	for (i=0; i<activeTabs.length; i++)
	{
		document.getElementById("rmtab_" + activeTabs[i]).style.display = "none";
		if (tabhash && (activeTabs[i] == tabhash)) index = i;
	}

	//select a tab
	showTabEx("rmtab",activeTabs[0],0);
	if (index >=0)
	{
		showTabEx("rmtab",tabhash,index);
	}
}

/*
 *	End of TabEx
 */

currElem = null;
currElem2 = null;
function showArticleInteraction(id)
{

        if (currElem != null)
        {
                currElem.style.display = "none";
        }
        if (currElem2 != null)
        {
                currElem2.style.display = "none";
        }

        if (id == "comment")
        {
        	if (document.getElementById("readcomments")) {
                	currElem2 = document.getElementById("readcomments");
                	currElem2.style.display = "block";
                }
        }
        if (!document.getElementById(id)) return true;

		if (captcha = document.getElementById(id + "_captcha_img"))
		{
			captcha.src="/captcha/captcha.jpg?no_cache=" + Math.floor(Math.random() * 9000000 + 1000000);
		}

        currElem = document.getElementById(id);
        currElem.style.display = "block";
        return true;
}

function popupImage(id)
{
        window.open("?service=ImagePopup&id=" + id, "", "scrollbars=no, addressbar=no,statusbar=no, menubar=no");
}


function initByHash()
{	
	if (document && document.location && document.location.hash)
	{	switch (document.location.hash)
		{
			case "#article_mailauthor":
				showArticleInteraction("mailAuthor");
				break;
			case "#article_recommend":
				showArticleInteraction("recommend");
				break;
			case "#article_comment":
				showArticleInteraction("comment");
				break;
			case "#read_comments":
				showArticleInteraction("comment");
				document.location.hash="#article_readcomments";
				break;
			case "#msg_mailAuthor":
				document.getElementById("xmsg_mailAuthor").style.display = "block";
				break;
			case "#msg_comment":
				document.getElementById("xmsg_comment").style.display = "block";
				break;
			case "#msg_recommend":
				document.getElementById("xmsg_recommend").style.display = "block";
				break;
					
			//Recommend
			case "#article_recommend_parameterError":
				showArticleInteraction("recommend");
				addNotification("recommend_form","Falscher Parameter");
				document.location.hash = "#article_recommend";
				break;
			case "#article_recommend_parameterEmpty":
				showArticleInteraction("recommend");
				addNotification("recommend_form","Falscher Parameter");
				document.location.hash = "#article_recommend";
				break;
			case "#article_recommend_captcha_failure":
				showArticleInteraction("recommend");
				addNotification("recommend_form","Bitte geben Sie den Code erneut ein");
				document.location.hash = "#article_recommend";
				break;
			case "#article_recommend_captcha_sessionError":
				showArticleInteraction("recommend");
				addNotification("recommend_form","Zeitlimit abgelaufen");
				document.location.hash = "#article_recommend";
				break;
				
			//MailAuthor
			case "#article_mailauthor_parameterError":
				showArticleInteraction("mailAuthor");
				addNotification("mailAuthor_form","Falscher Parameter");
				document.location.hash = "#article_mailauthor";
				break;
			case "#article_mailauthor_parameterEmpty":
				alert('article_mailauthor_parameterEmpty');
				showArticleInteraction("mailAuthor");
				addNotification("mailAuthor_form","Falscher Parameter");
				document.location.hash = "#article_mailauthor";
				break;
			case "#article_mailauthor_captcha_failure":
				showArticleInteraction("mailAuthor");
				addNotification("mailAuthor_form","Bitte geben Sie den Code erneut ein");
				document.location.hash = "#article_mailauthor";
				break;
			case "#article_mailauthor_captcha_sessionError":
				showArticleInteraction("mailAuthor");
				addNotification("mailAuthor_form","Zeitlimit abgelaufen");
				document.location.hash = "#article_mailauthor";
				break;
					
			//Comment
			case "#article_kommentar_parameterError":
				showArticleInteraction("comment");
				addNotification("com.escenic.forum.struts.presentation.PostingForm","Falscher Parameter");
				document.location.hash = "#article_comment";
				break;
			case "#article_kommentar_captcha_failure":
				showArticleInteraction("comment");
				addNotification("com.escenic.forum.struts.presentation.PostingForm","Bitte geben Sie den Code erneut ein");
				document.location.hash = "#article_comment";
				break;
			case "#article_kommentar_captcha_sessionError":
				showArticleInteraction("comment");
				addNotification("com.escenic.forum.struts.presentation.PostingForm","Zeitlimit abgelaufen");
				document.location.hash = "#article_comment";
				break;
			case "#article_kommentar_forum_succes":
				/* firstPostInformation is not written anymore
				try{
					document.getElementById("firstPostInformation").style.display = "block";
				}catch(err){
					// "firstPostInformation" not found, not the first post on this article
				}
				*/
				//showArticleInteraction("comment");
				showArticleInteraction("comment");
				addNotification("com.escenic.forum.struts.presentation.PostingForm","Vielen Dank für Ihren Kommentar. Er wird in wenigen Minuten unter dem Artikel erscheinen.");
				document.location.hash="#article_readcomments";
				break;
			case "#article_kommentar_forum_error":
				showArticleInteraction("comment");
				addNotification("com.escenic.forum.struts.presentation.PostingForm","Falscher Parameter");
				document.location.hash="#article_comment";
				break;
			case "#article_kommentar_forum_cancel":
				showArticleInteraction("comment");
				addNotification("com.escenic.forum.struts.presentation.PostingForm","Abgebrochen");
				document.location.hash="#article_comment";
				break;


		}
		//this is needed because when this is called the page has already scrolled to the anchor, and if the content after the page is smaller
		//after the anchor then the page it will scroll to the bottom, after which the div is displayed. The div will then not be scrolled
		//into view correctly. This will recall the anchor after the div is displayed, just like the links in the menu do.
		document.location.hash = document.location.hash;
	}

}

/*
 *	Following function is used to underline every element in a mouse over over en exklusiv item
 */



function styleChildren(obj, elem, val)
{
	par = obj;
	for (i=0; i<par.childNodes.length; i++)
	{
		v = "par.childNodes[i].style." + elem + " = \"" + val + "\"";
		try { eval(v); }
		catch (e) {}
	}
}


/*
 *	end underline styleChildren
 */

/* ---- validateForm ---- */
/* STATUS:FINAL */

var forms = {};

/*	
	Add required fields to a form (by formname) and validate before submit
	----------------------------------------------------------------------
	formid -> the id of the form
	fields -> an array containing the ids of the fields that are required
	fieldnames -> an array containing the names of the fields, how they are displayed in the warning

	there should be a %formname%_alert div that can hold the warning list (ul)
	it should be like:
	
	<form name="someform" id="someform" method="post">
		required - Field 1: <input id="req" name="req"/><br/>
		not required - Field 2: <input id="req" name="notreq"/><br/>
	</form>
	<a href="#" onclick="submitForm('someform')">
	<div id="someform_alert"></div>

	<script>
		addLoadEvent(
			function() {
				addForm("someform",
				        new Array("req"),
				        new Array("Field 1")
				);
			}
		);
	</script>
*/

function addForm(formid, fields, fieldnames)
{
  forms[formid] = new Array(fields, fieldnames);
}



function addNotification(formid, notification)
{
	alertDiv = document.getElementById(formid + "_alert");
	if (!alertDiv.firstChild)
	{
		//there is no UL yet
		ul = document.createElement("ul");
		alertDiv.appendChild(ul);
	}
	li = document.createElement("li");
	li.innerHTML = notification;
	alertDiv.firstChild.appendChild(li);
}

function submitForm(formid)
{
	form = document[formid];
	fields = forms[formid][0];
	fieldnames = forms[formid][1];
	
	error = "";
	
	for (i=0; i<fields.length; i++)
	{
		fid   = fields[i];
		fname = fieldnames[i];
	
		field = form[fid];
		
		if (!field || field.value == '')
		{
			error = "Das Feld '" + fname + "' muss ausgefüllt werden.";
			addNotification(formid, error);
		}
	}
	if (error) return false;

	//if (error != '')
	//{
	//	alertdiv = document.getElementById(formid + "_alert");
	//	ul = document.createElement("ul");
	//	ul.innerHTML = error;
	//	if (alertdiv.firstChild) alertdiv.removeChild(alertdiv.firstChild);
	//	alertdiv.appendChild(ul);
	//	return false;
	//}
	form.submit();
	return false;
}

















































































/* Limitz */

/* ---- picturebars ---- */
/*
STATUS: CHECKED
TODO: maybe add some comments
*/


function imageObject() {
    this.htmlContent = "";
	/* htmlContent replaced by: */
    this.imageUrl = "";
    this.imageWidth = "";
    this.imageHeight = "";
    this.articleId = "";

    this.targetUrl = "";
	this.clickAction = "";
}

function setSelectedGallery(galleryID,numberOfImages){
	selectedGalleryID = galleryID
	n=0;
	populateGallery(selectedGalleryID,numberOfImages)
}

function nextFour(articleID,numberOfImages) {
	n+=numberOfImages
	populateGallery(articleID,numberOfImages);
}

function previousFour(articleID,numberOfImages) {
	if(n>0) {
		n-=numberOfImages
		populateGallery(articleID,numberOfImages);
	}
}

function populateGallery(articleID,numberOfImages){
    var imageObjectDOM;
    var compatabilityMode = false;

    for(var i=0;i<numberOfImages;i++){

        if(i == 0){
			if(n == 0){
				document.getElementById("picturebarBack").style.visibility="hidden";
			}else{
				document.getElementById("picturebarBack").style.visibility="visible";

			}
		}else if(i == (numberOfImages-1)){
			if((n+numberOfImages) < foto[articleID].length){
				document.getElementById("picturebarForward").style.visibility="visible";
			}else{
				document.getElementById("picturebarForward").style.visibility="hidden";
			}
		}

		try
		{

            if(foto[articleID][n+i].htmlContent == "false") {
                //Only used for frontpage
                //Get reference to image object inside the foto hyperlink

                imageObjectDOM = document.getElementById("foto" + i).getElementsByTagName("IMG")[0];

                imageObjectDOM.ImageObjectRef = foto[articleID][n+i]; // Copy reference from ImageObject to DOM IMG object
                imageObjectDOM.src = foto[articleID][n+i].imageUrl;
                imageObjectDOM.width = foto[articleID][n+i].imageWidth;
                imageObjectDOM.height = foto[articleID][n+i].imageHeight;

                //attach the mouse-events to the image object
                imageObjectDOM.onmouseover = function () { showTextPopup(this,'top','outside','medium',false,eval(this.ImageObjectRef.articleId)); };
                imageObjectDOM.onmouseout = function () { hideTextPopup(this); }

                compatabilityMode = false;
            }
            else  {
                //Backward compatibility with picturebar in premiumchannel
                document.getElementById("foto" + i).innerHTML = foto[articleID][n+i].htmlContent;
                compatabilityMode = true;
            }

            var clickActionVar = foto[articleID][n+i].clickAction;

			if(foto[articleID][n+i].targetUrl != ""){
				document.getElementById("fotoLink" + i).href = foto[articleID][n+i].targetUrl;
			}

            if(clickActionVar) {
                if (window.attachEvent) {
                     document.getElementById("fotoLink" + i).onclick = function attachedEvent() { eval(clickActionVar); };
                } else {
                    document.getElementById("fotoLink" + i).setAttribute("onClick", foto[articleID][n+i].clickAction);
                }
            }

            document.getElementById("fotoLink" + i).style.visibility = 'visible';

		}
		catch(err)
		{
            document.getElementById("fotoLink" + i).style.visibility = 'hidden';
            document.getElementById("fotoLink" + i).href = "";
            document.getElementById("fotoLink" + i).onclick = "";

            if(compatabilityMode)
                document.getElementById("foto" + i).innerHTML = "";

        }
	}
}

function switchTabsPictureBar(obj) {
	tabsObj = findParentNodeByTagName(obj, "UL");
	checkObj = findParentNodeByTagName(obj, "LI");

	for (i=0; i<tabsObj.childNodes.length; i++) {

		if(checkObj == tabsObj.childNodes[i])
			tabsObj.childNodes[i].className = 'selected';
		else
			tabsObj.childNodes[i].className = '';
	}
}
/* ---- mediabox ---- */
/*********************/
/* Mediabox functions */
/*********************/

/* Mediabox Object */
function MediaBox (DOMObject) {
	this.DOMObject = DOMObject;
	this.tabs = new Array(); // Array of DOM HTML Elements
	this.panes = new Array(); // Array of MediaBoxPane Objects
	this.activePane = 0;
	this.activeSlide = 0;
	this.previousButton = null; //DOM HTML Element
	this.nextButton = null; //DOM HTML Element
	this.initialized = false;
}

/* Pane Object inside Mediabox */
function MediaBoxPane (DOMObject) {
	this.DOMObject = DOMObject;
	this.slides = new Array();
}

/* Slide Object inside pane */
function MediaBoxPaneSlide (DOMObject) {
	this.DOMObject = DOMObject;
}

/* Initialize Mediabox (on page load) */
function mediaBoxInitialize(theObj) {
	/* If Mediabox was already initialized, skip this routine */

    if((theObj.mediaBoxObject != null) || (theObj.nodeName == "BODY"))
        return false;

    /* Make array of panes */
	try {
		// Instantiate new MediaBox object
		var theMediaBox = new MediaBox(theObj);
		theObj.mediaBoxObject = theMediaBox; // Make reference to Mediabox Object from DOMElement

		/* Add attribute "mediaBoxObject" to all child elements of the Mediabox */
		var allChildren = theObj.getElementsByTagName("*");
		for(var i in allChildren)
			allChildren[i].mediaBoxObject = theMediaBox;

		/* Get navigationbuttons (previous, next) */
		theMediaBox.previousButton = getElementsByClassName(theObj, "mediaBoxPaneNavigationPrevious", false)[0];
		theMediaBox.nextButton = getElementsByClassName(theObj, "mediaBoxPaneNavigationNext", false)[0];

		/* Get all the tabs */
		//Get container object of the tabs
		var tabContainer = getElementsByClassName(theObj, "mediaBoxTabStrip", true)[0];
		//Get List of items in that container
		var itemList = getElementsByClassName(tabContainer, "mediaBoxTab", true);
		for(i in itemList)
			theMediaBox.tabs[i] = itemList[i];

		/* Get all panes and slides */
		//Get container object with the picture panes(tabs) and slides
		var paneContainer = getElementsByClassName(theObj, "mediaBoxPaneContainer", true)[0];
		//Get List of items in that container
		var itemList = getElementsByClassName(paneContainer, "mediaBoxPane", true);

		var theMediaBoxPane;
		var theMediaBoxPaneSlide;

		for(i in itemList) {
			switch(itemList[i].className) {
				case "mediaBoxPane":
					theMediaBoxPane = theMediaBox.panes[theMediaBox.panes.length] = new MediaBoxPane(itemList[i]);
					break;

				case "mediaBoxPaneActive":
					theMediaBoxPane =  theMediaBox.panes[theMediaBox.panes.length] = new MediaBoxPane(itemList[i]);
					theMediaBox.activePane = theMediaBox.panes.length - 1;
					break;

				case "mediaBoxPaneSlide":
					theMediaBoxPaneSlide = theMediaBoxPane.slides[theMediaBoxPane.slides.length] = new MediaBoxPaneSlide(itemList[i]);
					break;

				case "mediaBoxPaneSlideActive":
					theMediaBoxPaneSlide = theMediaBoxPane.slides[theMediaBoxPane.slides.length] = new MediaBoxPaneSlide(itemList[i]);
					theMediaBox.activeSlide = theMediaBoxPane.slides.length - 1;
					break;
			}
		}
	}
	catch(error) {
		alert("Error during initialization of Mediabox [initializeMediaBox()]\n\nError Code: " + error);
		return false;
	}

	mediaBoxRefreshNavigation(theMediaBox);

	theMediaBox.initialized = true;
	return true;
}

function mediaBoxRefreshNavigation(mediaBox) {

    var maxActiveSlides = mediaBox.panes[mediaBox.activePane].slides.length;

	if(mediaBox.activeSlide == 0)
		mediaBox.previousButton.style.visibility = "hidden";
	else
		mediaBox.previousButton.style.visibility = "visible";

	if ((mediaBox.activeSlide + 1) == maxActiveSlides)
		mediaBox.nextButton.style.visibility = "hidden";
	else
		mediaBox.nextButton.style.visibility = "visible";

	return true;

}

/* Select the  pane corresponding to the tab  */
function mediaBoxPaneSelect(theObj) {
	var mediaBox;

    /* Instantiate Mediabox Object if needed */
	if(!theObj.mediaBoxObject) {
        // Find the mediaBox Rool element by moving up the DOM Tree
		mediaBox = theObj;
		do {
			mediaBox = findParentNodeByClassName(mediaBox, "mediaBox");
        }  while ((mediaBox.className != "mediaBox") && (mediaBox.className.indexOf("mediaBox ") == -1) && (mediaBox.nodeName != 'BODY')) //Find classnames exactly equal or in combination with other classname (i.e. class="Mediabox Frontpage")

        mediaBoxInitialize(mediaBox);
	}

	mediaBox = theObj.mediaBoxObject; // Use reference of the DOMElement to the Picturbar Object

	/* Find the right tab number */
	for(var i in mediaBox.tabs) {
		if(mediaBox.tabs[i].getElementsByTagName("A")[0] == theObj)
			break;
	}

	if(mediaBox.activePane == i) //If this pane is already active, exit function
		return false;

	/* Set active tab  */
	mediaBox.tabs[mediaBox.activePane].className = "mediaBoxTab";
	mediaBox.tabs[i].className = "mediaBoxTabActive";

	/* Set active pane and slide to normal */
	mediaBox.panes[mediaBox.activePane].DOMObject.className = "mediaBoxPane";
	mediaBox.panes[mediaBox.activePane].slides[mediaBox.activeSlide].DOMObject.className = "mediaBoxPaneSlide";

	/* Display chosen pane  and first slide  */
	mediaBox.panes[i].DOMObject.className = "mediaBoxPaneActive";
	mediaBox.panes[i].slides[0].DOMObject.className = "mediaBoxPaneSlideActive";
	mediaBox.activePane = i;
	mediaBox.activeSlide = 0;

	mediaBoxRefreshNavigation(mediaBox);
	return true;
}

function mediaBoxMoveSlide(theObj, direction) {
	var mediaBox;
	var currentPane;
	var maxpossibleSlides;
	var slideTest;

	/* Instantiate Mediabox Object if needed */
	if(!theObj.mediaBoxObject) {
		// Find the mediaBox Rool element by moving up the DOM Tree
		mediaBox = theObj;
		do {
			mediaBox = findParentNodeByClassName(mediaBox, "mediaBox");
        }  while ((mediaBox.className != "mediaBox") && (mediaBox.className.indexOf("mediaBox ") == -1) && (mediaBox.nodeName != 'BODY')) 
		//Find classnames exactly equal or in combination with other classname (i.e. class="Mediabox Frontpage")

		mediaBoxInitialize(mediaBox);
	}

	mediaBox = theObj.mediaBoxObject; // Use reference of the DOMElement to the Picturbar Object
	currentPane = mediaBox.panes[mediaBox.activePane];
	maxpossibleSlides = currentPane.slides.length;

	/*Test if it is possible to navigate */
	slideTest = mediaBox.activeSlide + direction;
	if((slideTest < 0) || (slideTest == maxpossibleSlides))
		return false;

	/* Hide current slide and show next */
	currentPane.slides[mediaBox.activeSlide].DOMObject.className = "mediaBoxPaneSlide";
	mediaBox.activeSlide += direction;
	currentPane.slides[mediaBox.activeSlide].DOMObject.className = "mediaBoxPaneSlideActive";

	mediaBoxRefreshNavigation(mediaBox)
	return true;
}
/* ---- popups ---- */
/********************************************/
/* Javascript textpopup with shaded corners */
/********************************************/

/* Declare some global variables, that will be persisted across the mouseover events */

var popupWindowObj; /* pointer to textPopupWindow object */
var textPopupActive = false;
var textPopupActiveOject = null;
var textPopupActiveValign;
var textPopupActivePosition;
var textPopupActiveSize;
var textPopupActiveFollow;

/*
    This function inserts the popup div at the end of the document and is then reused
*/

function insertTextPopupIntoDOM (){
    var textPopupHTML = new Array
    (
    '<div id="textPopupWindow" class="textPopup textPopupSizeSmall" onmouseover="showTextPopup(this,\'\',\'\',\'\');" onmouseout="hideTextPopup(this);">',
    '<iframe id="textPopupIframeBackground" scrolling="no" frameborder="0"></iframe>',
    '   <div id="textPopupWindowContent" class="textPopupcontent">',
    '       empty',
    '   </div>',
    '   <div class="dropshadow">',
    '       <div class="top">',
    '           <span class="dropshadowtopleft"></span><span class="dropshadowtopright"></span><span class="dropshadowright"></span>',
    '       </div>',
    '       <div class="bottom">',
    '           <span class="dropshadowbottomleft"></span><span class="dropshadowbottom"></span><span class="dropshadowbottomright"></span>',
    '       </div>',
    '   </div>',
    '</div>'
    );

    for(var i=0; i<textPopupHTML.length; i++) {
        document.writeln(textPopupHTML[i]);
    }

    popupWindowObj = document.getElementById('textPopupWindow');

    var browser = navigator.userAgent;
    if (browser.indexOf("MSIE") >= 0 ){
        document.getElementById("textPopupIframeBackground").style.display = 'block';
    }
}

/*
    Mouseoverhandler for showing the textPopup
*/

function showTextPopup(theObj, valign, position, size, follow, textContent) {
    /* following parameters are possible: */
    /* valign = [top|bottom|], position = [inside|outside], size = [small|medium], follow = [true|false] */
    /* textContent = [String] for dynamic content */
    
    valign = valign.toUpperCase();
    position = position.toUpperCase();
    size = size.toUpperCase();

    //check if the popup-object exists
    if(!popupWindowObj)
        return(false);

    /*
    Execute this code only at the initial mouseover of a new button object that triggers the popup,
    textpopupActive will be set to true this time and will be set to false by the reallyHide function,
    when the popup is actually hidden
    */

    if(!textPopupActive) {   //Execute only at initial mouseover
        // Set the parameters of this mouseover to global variables that can be used by other event handlers
        textPopupActiveValign = valign;
        textPopupActivePosition = position;
        textPopupActiveSize = size;
        textPopupActiveFollow = follow;

        //Changes classname of the popupwindow according to the 'valign' and 'size' parameter
        //Check alignment
        if(valign == 'TOP') {
            popupWindowObj.className = 'textPopupTop';
        }
        else if(valign == 'BOTTOM') {
            popupWindowObj.className = 'textPopupBottom';
        }
        else  {
            popupWindowObj.className = 'textPopup';
        }

        //Check size
        if(size == 'SMALL') {
            popupWindowObj.className += ' textPopupSizeSmall';
        }
        else if(size == 'MEDIUM') {
            popupWindowObj.className += ' textPopupSizeMedium';
        }
        else {
            popupWindowObj.className += ' textPopupSizeMedium';
        }

        //Look for the HTML-content of the popup and copy that into the popupwindow
        if(textContent) {
           document.getElementById('textPopupWindowContent').innerHTML = textContent;
        }

        else {
            var goNext = true;
            var sibling = theObj.nextSibling;

            //First Look for child div with classname 'popupContent'
            for(var i=0; i < theObj.childNodes.length; i++) {

                if(theObj.childNodes[i].className) {
                    if(theObj.childNodes[i].className.indexOf('popupContent') != -1) {
                        document.getElementById('textPopupWindowContent').innerHTML = theObj.childNodes[i].innerHTML;
                        goNext = false;
                    }
                }
            }

            //If that fails:
            //Look for sibling div with classname 'popupContent'

            while(goNext && sibling) {
                if(sibling.className) {
                    if(sibling.className.indexOf('popupContent') != -1) {
                        document.getElementById('textPopupWindowContent').innerHTML = sibling.innerHTML;
                        goNext = false;
                    }
                }

                if(sibling.nextSibling) {
                    sibling = sibling.nextSibling;
                }

                else {
                    goNext = false;
                }
            }
        }

        //reset the popupwindow relative to the calling object
        coords = findPosition(theObj); //find position of popup-caller button
        popupWindowObj.style.left = coords[0] + (theObj.offsetWidth/2) + "px"; //horizontally center the popup over the caller-object
        popupWindowObj.style.top = coords[1] + "px"; //basic vertical realignment

        //Further adjust the vertical coordinate according to 'valign' and 'position' property
        if(valign == 'TOP' && position == 'INSIDE') {
            //popupWindowObj.style.top = ((coords[1] - popupWindowObj.offsetHeight) + (theObj.offsetHeight/1.5)) + "px";
            popupWindowObj.style.top = ((coords[1] - popupWindowObj.offsetHeight) + (theObj.offsetHeight)/2) + "px";
        }
        else if(valign == 'BOTTOM' && position == 'INSIDE') {
            //popupWindowObj.style.top = (coords[1] + (theObj.offsetHeight*2)) + "px";
            popupWindowObj.style.top = (coords[1] + (theObj.offsetHeight*0.5)) + "px";
        }
        else if(valign == 'TOP') {
            popupWindowObj.style.top = (coords[1] - popupWindowObj.offsetHeight) + "px";
        }
        else if(valign == 'BOTTOM') {
            popupWindowObj.style.top = (coords[1] + theObj.offsetHeight) + "px";
        }

        //Find the newly defined coords of the repositioned popupwindow
        coords = findPosition(popupWindowObj);

        //Check if it is positioned outside the TOP of the screen and reposition popup at bottom align
        if((findPosition(popupWindowObj)[1] < getScrollXY()[1]) && valign == 'TOP') {   // only trigger this event when valign == TOP!
            showTextPopup(theObj, 'bottom', position, size, follow); //recursively call this function again with 'valign = bottom'
            return;
        }

        //Check if the 'follow' parameter is set to true
        if(follow) {
            if(!theObj.onmousemove)
                theObj.onmousemove = followTextPopup;  //Set the mouseover eventhandler on the caller object

            if(window.event) //only needed for IE. directly readjust popup-position to the mouse pointer
               followTextPopup(window.event);  //used in IE only for smooth transition
        }

        //Important!
        textPopupActive = true; //this popup is now active and visible
        textPopupActiveOject = theObj; //the object that called the currently activated popupwindow

        //check if there is any valid content in the popup
        if(document.getElementById('textPopupWindowContent').innerHTML.length > 2) { //Content should at least contain more than 2 characters
            //Only show if there is any content
            document.getElementById("textPopupIframeBackground").style.width = (document.getElementById("textPopupWindowContent").offsetWidth - 0) + 'px';
            document.getElementById("textPopupIframeBackground").style.height = (document.getElementById("textPopupWindowContent").offsetHeight - 0) + 'px';

            popupWindowObj.style.visibility='visible'; //Finally display the window
        }
    }

    //Cancel the hide timeout if the popupwindow receives a mouseover again from the caller OR the popupwindow itself
    else if(popupWindowObj.getAttribute("timerId") && textPopupActiveFollow == false )  {  /* if the follow option is active, then don't do this */
        clearTimeout(popupWindowObj.getAttribute("timerId"));
        popupWindowObj.setAttribute ("timerId", null);
    }

    /*
    If a mouseover is generated by another caller, then immediately hide the current popupwindow without delay and
    and recursively call the showTextPop handler with the new caller
    */

    if(textPopupActiveOject != theObj && theObj != popupWindowObj) {
        reallyHideTextPopup(); //immmediately hide the current popup
        showTextPopup(theObj, valign, position, size, follow, textContent); //call a new popup window
    }

    return;
}

/*
    Mouseout handler for delayed hiding of the popup (exeption: follow parameter = true)
*/

function hideTextPopup(theObj) {
    /*
    Try to hide submenu in case of mouseout
    Can be cancelled by a mouseover
    */

    var timerId;
    var timeOutHandler = "reallyHideTextPopup()";
    var timeOut = 500; /* standard delay (milliseconds) of mouseout */

    //check if the popup-object exists
    if(!popupWindowObj)
        return(false);

    //If the follow property of the active popup is set to true, then immediately hide
    if(textPopupActiveFollow) {
        reallyHideTextPopup();
    }
    else {
        timerId = window.setTimeout(timeOutHandler, timeOut);
        popupWindowObj.setAttribute ("timerId", timerId);
    }

    return;
}

/*
    Actually hide the popup window
*/

function reallyHideTextPopup() {
    popupWindowObj.style.visibility='hidden';  //hide the window
    clearTimeout(popupWindowObj.getAttribute("timerId"));
    popupWindowObj.setAttribute ("timerId", null); //set the timer attribute of the popupwindow to null
    textPopupActive = false; //Important! set popupwindow inactive
}

/*
    Mousemove handler in case the 'follow(mouse)' option is selected
*/

function followTextPopup(e) {

    //check if the popup-object exists
    if(!popupWindowObj)
        return(false);

    //Do not execute when there is still a timer running !!!
    if(popupWindowObj.getAttribute("timerId"))  {
        return(false);
    }

    var posx = 0;
	var posy = 0;

    if (!e) var e = window.event;

    if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

    //adjust the horizontal position of the popupwindow
    popupWindowObj.style.left = posx + "px";

    //adjust the vertical position according to the valign property relative to mousepointer
    if(textPopupActiveValign == 'TOP') {
        popupWindowObj.style.top = posy - popupWindowObj.offsetHeight - 10 + "px";
    }
    else if(textPopupActiveValign == 'BOTTOM') {
        popupWindowObj.style.top = posy + 15 + "px";
    }

    //find the newly coords of the repositioned popupwindow
    coords = findPosition(popupWindowObj);

    //check if it is positioned outside the TOP of the screen and reposition popup at bottom align
    if(findPosition(popupWindowObj)[1] < getScrollXY()[1]) {
        reallyHideTextPopup();
        showTextPopup(textPopupActiveOject, 'bottom', textPopupActivePosition, textPopupActiveSize, true);
        return;
    }
}

/*************************************************************/
/* Functions for displaying the ressort menustrip (mainmenu) */
/*************************************************************/

var mainMenu;
var iframeBackground;
var mainMenuActive = false;

function showMainMenu() {
    if(!mainMenuActive){
        mainMenu = document.getElementById('mainMenu');
        iframeBackground = document.getElementById('mainMenuIframeBackground');

        var coords = findPosition(mainMenu);

        iframeBackground.style.left = mainMenu.style.left;
        iframeBackground.style.top = mainMenu.style.right;
        iframeBackground.style.width = mainMenu.offsetWidth + 'px';
        iframeBackground.style.height = mainMenu.offsetHeight + 'px';

        mainMenu.style.visibility = 'visible';
        iframeBackground.style.visibility = 'visible';
        mainMenuActive = true;
    }
    //Cancel the hide timeout if the popupwindow receives a mouseover again from the caller OR the popupwindow itself
    else if(mainMenu.getAttribute("timerId"))  {
        clearTimeout(mainMenu.getAttribute("timerId"));
        mainMenu.setAttribute ("timerId", null);
    }

    return;
}

function hideMainMenu() {
    /*
    Try to hide submenu in case of mouseout
    Can be cancelled by a mouseover
    */

    var timerId;
    var timeOutHandler = "reallyHideMainMenu()";
    var timeOut = 400; /* standard delay (milliseconds) of mouseout */

    timerId = window.setTimeout(timeOutHandler, timeOut);
    mainMenu.setAttribute ("timerId", timerId);

    return;
}

/*
    Actually hide the popup window
*/

function reallyHideMainMenu() {
    mainMenu.style.visibility = 'hidden';
    iframeBackground.style.visibility = 'hidden'; //hide the window

    mainMenu.setAttribute ("timerId", null); //set the timer attribute of the popupwindow to null
    mainMenuActive = false; //Important! set popupwindow inactive
    return;
}
/* ---- sortModules ---- */
/* STATUS: FINAL */

/*
*	GPR Javascript DIV sort 
*
*	Functions for sorting li layers, containing module names, on a page and saving there positions in a Cookie on every move
*
*	This script is used in the personalisation page in access manager 
*
*	USAGE 
*	
*	Create LI items containing a DIV wich contains a checkbox, the module typename and up and down arrows.
*	Thease LI items will ba sortable by the user and checkable to determain how and if the modules should 
*	be displayed on the site.
*
*		<li id="picture_gallery_teaser"><div> ... </div></li>
*	
*	Each DIV sould have two arrows with the CLASS arrowUp and arrowDown.  thease link should be children of the DIV
*
*		<a class="arrowUp" onclick="moveDivUp(this.parentNode.parentNode)"> Up arrow </a>
*		<a class="arrowDown" onclick="moveDivDown(this.parentNode.parentNode)"> Down arrow </a>
*	
*	On load read the sorted list from a Cookie and parse the container DIV in which all LI's that need sorting are available
*
*		readListFromCookie(document.getElementById('Containing_DIV'));
*
*	<ul id="moduleList">
*		<li id="picture_gallery_teaser">
*			<div class="clearfix" style="border: 1px solid #ff0000;">
*				<div style="border: 1px solid #00ff00; float: left;"><input name="chooseModuleGroup" id="picture_gallery_teaser_checkbox" type="checkbox"/>Picture gallery teaser</div>
*				<div style="border: 1px solid #ff00ff; float: right;" class="arrowContainer">
*					Sortieren<a name="arrowUp" class="arrowUp" onclick="moveDivUp(getElementById('picture_gallery_teaser'))"> Up </a>
*					<a name="arrowDown" class="arrowDown" onclick="moveDivDown(getElementById('picture_gallery_teaser'))"> Down </a>
*			</div></div></li>		
*
*
*
*	Structure
*
*		Containing_DIV 
*			LI name="type1"
*				moduleType_DIV
*					checkbox
*					module name
*					arrowUp - arrowDown
*
*			LI name="type2"
*				moduleType_DIV
*					checkbox
*					module name
*					arrowUp - arrowDown
*
*			LI name="type3"
*				moduleType_DIV
*					checkbox
*					module name
*					arrowUp - arrowDown
*
*/

function updateList(){
	removeTextNodesFromDiv(document.getElementById('moduleList'));
	showUpAndDownArrow(document.getElementById('moduleList'));
	hideFirstAndLastArrow(document.getElementById('moduleList'));
}

function moveDivUp(currentDivObject){
	divsContainer = currentDivObject.parentNode
	for (i=0; i <= divsContainer.childNodes.length-1; i++){
		if(divsContainer.childNodes[i].id == currentDivObject.id){
			// IE loses the check status when the div is moved in the tree
			var checkedBox1 = false;
			var checkedBox2 = false;

			var checkBoxObject1 = document.getElementById(divsContainer.childNodes[i].id + "_checkbox");
			var checkBoxObject2 = document.getElementById(divsContainer.childNodes[i-1].id + "_checkbox");

			// if the checkbox of this list item is checked
			if(checkBoxObject1.checked){
				checkedBox1 = true;
			}
			if(checkBoxObject2.checked){
				checkedBox2 = true;
			}
			
			// switch the LI items
			divsContainer.insertBefore(divsContainer.childNodes[i], divsContainer.childNodes[i-1]);
			
			checkBoxObject2.checked = checkedBox2;
			checkBoxObject1.checked = checkedBox1;
			
			updateList();
			break;
		}
	}
}

function moveDivDown(currentDivObject){
	divsContainer = currentDivObject.parentNode
	for (i=0; i < divsContainer.childNodes.length; i++){
		if(divsContainer.childNodes[i].id == currentDivObject.id){
			// IE loses the check status when the div is moved in the tree
			var checkedBox1 = false;
			var checkedBox2 = false;
			
			var checkBoxObject1 = document.getElementById(divsContainer.childNodes[i].id + "_checkbox");
			var checkBoxObject2 = document.getElementById(divsContainer.childNodes[i+1].id + "_checkbox");
			
			// if the checkbox of this list item is checked
			if(checkBoxObject1.checked){
				checkedBox1 = true;
			}
			if(checkBoxObject2.checked){
				checkedBox2 = true;
			}
			
			// switch the LI items
			divsContainer.insertBefore(divsContainer.childNodes[i+1], divsContainer.childNodes[i]);
			
			checkBoxObject2.checked = checkedBox2;
			checkBoxObject1.checked = checkedBox1;
			
			updateList();
			break;
		}
	}
}

function removeTextNodesFromDiv(divModulesContainer){
	var section_prio1_container = divModulesContainer;
	// remove text nodes between modules
	for (k=0; k < section_prio1_container.childNodes.length; k++){
		if(section_prio1_container.childNodes[k].nodeName == "#text"){
			section_prio1_container.removeChild(section_prio1_container.childNodes[k]);
		}
	}
}


function writeListToCookie(divModulesContainer){
	//
	// Depricated cookies for sorting the modules are now set using a paresonalisationpage in the access manager
	//
	alert("writing list to cookie");
	var section_prio1_container = divModulesContainer;
	var galleryList = new Array();
	var divCounter = 0;
	for (i=0; i < section_prio1_container.childNodes.length; i++){
		if(section_prio1_container.childNodes[i].nodeName != null  && section_prio1_container.childNodes[i].nodeName == "LI"){
			galleryList[divCounter] = new Array();
			galleryList[divCounter][0] = section_prio1_container.childNodes[i].id;
			
			//alert(document.getElementById(section_prio1_container.childNodes[i].id + "_checkbox").checked);
			galleryList[divCounter][1] = document.getElementById(section_prio1_container.childNodes[i].id + "_checkbox").checked;
			divCounter++;
		}
	}
	createCookie("sortedGalleryList",galleryList,1000);
}

function readListFromCookie(divModulesContainer){
	updateList();

	var section_prio1_container = divModulesContainer;
	if(readCookie("sortedGalleryList") != null){
		var galleryList = readCookie("sortedGalleryList").substring(1,readCookie("sortedGalleryList").length-1).split(',');

		// for every EVEN item in the galleryList get the node and append it to the container to sort the itmes
		for (i=0; i < galleryList.length; i+=2){
			for (j=0; j < section_prio1_container.childNodes.length; j++){
				if(galleryList[i] == section_prio1_container.childNodes[j].id){
					section_prio1_container.appendChild(section_prio1_container.childNodes[j]);
				}
			}
		}
		
		// for every ODD item in the galleryList get the checked state
		for (i=1; i < galleryList.length; i+=2){
			for (j=0; j < section_prio1_container.childNodes.length; j++){
				if(galleryList[i-1] == section_prio1_container.childNodes[j].id){
					if(galleryList[i] == "true"){
						document.getElementById(galleryList[i-1] + "_checkbox").checked = true;
					}else{
						document.getElementById(galleryList[i-1] + "_checkbox").checked = false;
					}
				}
			}
		}
	}
	
	for (i=0; i < section_prio1_container.childNodes.length; i++){
		if(section_prio1_container.childNodes[i] != null  && section_prio1_container.childNodes[i].nodeName == "DIV"){
			section_prio1_container.childNodes[i].style.display = 'inline';
		}
	}
	updateList();
}

function hideFirstAndLastArrow(divModulesContainer){
	removeTextNodesFromDiv(divModulesContainer);
	
	var listItems = divModulesContainer.childNodes
	
	var firstArrows = listItems[0].getElementsByTagName('A');
	var lastArrows = listItems[listItems.length-1].getElementsByTagName('A');
	
	for (i=0; i < firstArrows.length; i++){
		if(firstArrows[i].name == 'arrowUp'){
			firstArrows[i].style.display = 'none';
		}
	}
	
	for (i=0; i < lastArrows.length; i++){
		if(lastArrows[i].name == 'arrowDown'){
			lastArrows[i].style.display = 'none';
		}
	}
}

function showUpAndDownArrow(divModulesContainer){
	var upArrows = document.getElementsByName('arrowUp');
	var downArrows = document.getElementsByName('arrowDown');
	
	for(i=0; i < upArrows.length; i++){
		upArrows[i].style.display = 'inline';
	}
	
	for(i=0; i < downArrows.length; i++){
		downArrows[i].style.display = 'inline';
	}
}

/*
*	Sort modules on page function
*		
*	This function is used for displaying sorted modules on the webpage. It works by copying modules in the order stored in 
*	a cookie to a temporary div and when done copying the inner html from this Div over the modulebar content.
*
*	usage:
*		
*		sortModulesOnPage(divModulesContainer,debugModuleList)
*
*		divModulesContainer		- Should contain the name of the rightColumn
*		divTempModuleContainer	- The name of the hidden div in the page to copy the modules to		
*
*	debug version
*		
*		sortModulesOnPage(divModulesContainer,divTempModuleContainer,debugModuleList,divMainColumn)
*
*		divModulesContainer		- Should contain the name of the rightColumn
*		divTempModuleContainer	- The name of the hidden div in the page to copy the modules to	
*		debugModuleList			- Default false, when true it displays debug information for this function		
*		divMainColumn			- The name of the output div for debugging information
*
*	requires: the following divs
*			
*		rightColumn 			- This is the div with the modules
*		tempModuleDiv			- A hidden div to copy the modules to
*		mainColumn	(1)			- The main div of the page to copy the debug information to	
*		
*		(1) optional 
*/

// Default version
function sortModulesOnPage(divModulesContainer,divTempModuleContainer){
	sortModulesOnPage(divModulesContainer,divTempModuleContainer,false,null);
}

// Default version and Debug version
function sortModulesOnPage(divModulesContainer,divTempModuleContainer,debugModuleList,divMainColumn){
	var rightModuleContainer = document.getElementById(divModulesContainer);
	var tempModuleContainer = document.getElementById(divTempModuleContainer);
	var mainColumn = document.getElementById(divMainColumn);
	
	if(readCookie("sortedGalleryList") != null){
		var sortLog = readCookie("sortedGalleryList");
	
		var galleryList = readCookie("sortedGalleryList").substring(1,readCookie("sortedGalleryList").length-1).split(',');

		
		
		// remove comments and tekstnodes
		for (j=0; j < rightModuleContainer.childNodes.length; j++){
			if(rightModuleContainer.childNodes[j].nodeName != "DIV"){
				try{
					rightModuleContainer.removeChild(rightModuleContainer.childNodes[j]);
				}catch(err){}
			}
		}

		sortLog += "<h2>Hide and make visible</h2><br>"
		
		// for every ODD item in the galleryList get the checked state
		for (i=1; i < galleryList.length; i+=2){
			for (j=0; j < rightModuleContainer.childNodes.length; j++){
				if(rightModuleContainer.childNodes[j].nodeName == "DIV"){
					moduleType = rightModuleContainer.childNodes[j].id.split('_sep_');
					if(galleryList[i-1] == moduleType[1]){
						if(galleryList[i] == "true"){
							sortLog += rightModuleContainer.childNodes[j].id + " to visible<br>"
							rightModuleContainer.childNodes[j].style.display = "block";
						}else{
							sortLog += rightModuleContainer.childNodes[j].id + " to hidden<br>"
							rightModuleContainer.childNodes[j].style.display = "none";
						}
					}
				}
			}
		}
		sortLog += "<br><h2>Sort modules according to cookie</h2>"

		// for every EVEN item in the galleryList get the node and append it to the container to sort the itmes
		var bannerPositionCounter = 0;
		for (i=0; i < galleryList.length; i+=2){
			sortLog += "<br>Check " + galleryList[i] + "<br>";
			try{
				for (j=0; j < rightModuleContainer.childNodes.length; j++){
					if(rightModuleContainer.childNodes[j].nodeName == "DIV"){
						moduleType = rightModuleContainer.childNodes[j].id.split('_sep_');
						sortLog += "Check " + galleryList[i] + " == " + moduleType[1] + "<br>"
						if(galleryList[i] == moduleType[1]){
							sortLog += "Moving " + rightModuleContainer.childNodes[j].id + "<br>";
							
							// add the first banner 
							// Node needs to be cloned becouse otherwhise the sorting ot the elements will fail because the amount of objects won't be correct.
							
							// put the banner above the right site column for sorting in IE
							if(bannerPositionCounter == 0){
								// alert('printing banner');
								bannerPositionCounter++;
								if(document.getElementById('banner_1')){
									//tempModuleContainer.appendChild(document.getElementById('banner_1').cloneNode(true));
								}	
								
								/*
								if(typeof(adlink_randomnumber)=="undefined") var adlink_randomnumber=Math.floor(Math.random()*1000000000000);
								//var bannerTag = document.write('<'+'script type="text/javascript" src="http://ad.de.doubleclick.net/adj/Welt/home;tile=2;sz=120x600;ord=' + adlink_randomnumber + '?"><'+'/script>');

								var myElement = document.createElement('script'); 
								//myElement.innerHTML = 'http://ad.de.doubleclick.net/adj/Welt/home;tile=2;sz=120x600;ord=' + adlink_randomnumber + '?';

								
								myElement.src = 'http://ad.de.doubleclick.net/adj/Welt/home;tile=2;sz=120x600;ord=' + adlink_randomnumber + '?';
								
								
								tempModuleContainer.appendChild(myElement);
								
								
								myElement.innerHTML = 'http://ad.de.doubleclick.net/adj/Welt/home;tile=2;sz=120x600;ord=' + adlink_randomnumber + '?';
								tempModuleContainer.appendChild(myElement);
								*/
								
							}
							
							
							var	textNode = rightModuleContainer.childNodes[j].cloneNode(true);
							tempModuleContainer.appendChild(textNode);
							
							
							if(rightModuleContainer.childNodes[j]){
								if(rightModuleContainer.childNodes[j].style.display == "block"){
									bannerPositionCounter++;
								}
							}
							
							// add the second banner (Not needed becouse currently only the homepage will be personalised)
							// Node needs to be cloned becouse otherwhise the sorting ot the elements will fail because the amount of objects won't be correct.
							/*
							if(bannerPositionCounter == 2){
								if(document.getElementById('banner_2')){							
									tempModuleContainer.appendChild(document.getElementById('banner_2').cloneNode(true));
								}
							}
							*/
						}
					}
				}
			}catch(err){
				alert("error checking Div: " + err.description);
			}
		}
		
		// Print the remaining modules if they haven't been printed in between the modules, 
		// this might accure when there are only a few modules desked or selected in the personalisation.
		
		// add the second banner (Not needed becouse currently only the homepage will be personalised)
		/*
		if(bannerPositionCounter < 2){
			if(document.getElementById('banner_2')){	
				tempModuleContainer.appendChild(document.getElementById('banner_2'));
			}
		}
		*/

		if(divMainColumn != null && debugModuleList == true){
			mainColumn.innerHTML = "<h1>Javascript module sort debug</h1><br>" + sortLog;
		}
		rightModuleContainer.innerHTML = tempModuleContainer.innerHTML

		// Clear the data in the temp madule container 
		tempModuleContainer.innerHTML = "";		
	}
}


// This is where the flash objects are executed. This function needs to be called after the sorting routine, 
// because executing thease objects before sorting will result in  blank flash objects in IE.
function executePodcastObjectsInModules(podcastList){
	// More then one podcast article can be desked so this loop executes all the corresponing articles
	for(i=0;i < podcastList.length;i++){
		var mp3Player = eval('mp3Player_'+ podcastList[i]);
		mp3Player.addParam("allowScriptAccess", "sameDomain");
		mp3Player.addParam("menu", "false");
		mp3Player.addParam("quality", "high");
		mp3Player.addParam("align", "middle");
		mp3Player.addParam("wmode", "opaque");
		mp3Player.addVariable("beginPlaying", false);
		mp3Player.addVariable("mp3Path", eval('mp3PlayerMediaURL_'+ podcastList[i]));
		mp3Player.write('flashMp3Player_' + podcastList[i]);
	}
}

// This is where the flash objects are executed. This function needs to be called after the sorting routine, 
// because executing thease objects before sorting will result in  blank flash objects in IE.	
function executeVideoObjectInModules(so){
	// there can only be one video module for the time being. 
	so.addParam( "allowScriptAccess", "sameDomain" );
	so.addParam( "menu", "false" );
	so.addParam( "quality", "high" );
	so.addParam( "id", "mediaplayer" );
	so.addParam( "align", "middle" );
	so.addParam( "wmode", "opaque" );

    so.addVariable( "autoPlay", "true" );
    so.addVariable( "startClip", "0" );
    so.addVariable( "libraryPath", soLibraryPath );
	so.addVariable( "defaultMediaAssetPath", soDefaultMediaAssetPath );
	so.addVariable( "bwCheckUrl", soBwCheckUrl );
	so.addVariable( "eaeLoggerPath", soEaeLoggerPath );
	so.addVariable( "eaeLoggerPubId", soEaeLoggerPubId );
	so.addVariable( "eaeLoggerType", "video" );
	so.addVariable( "mediacliplist", soMediacliplist);
	so.addVariable( "ivwStatsFunction", "ivwLogVideo" );
	//so.write( "teaservideo" );
}
/* ---- print ---- */
/* STATUS:CHECKED Todo: should this file be integrated in a global js? */

var display_img_print = false;
function switchDisplayImages()
{
	//go through the domtree of article and set display to none
	divs = document.getElementById("article").getElementsByTagName("div");
	for (i=0; i<divs.length; i++)
	{
		switch (divs[i].className)
		{
			case "imageHeadline":
			case "imageLeft":
			case "imageCenter":
			case "imageRight":
			case "inlineGallery":
                divs[i].style.display = (display_img_print ? "block" : "none");

			default: break;
		}
	}
	display_img_print = !display_img_print;
}

function printArticle()
{
	window.print();
}
/* ---- search ---- */
//TODO: define German alerts
//method cleanSearchExpression: cleans expression in expressoin fields after an search with calendar
//method searchSubmitAdvanced: validates expression for submit. see also search-advanced.jsp
//method searchSubmitTop: validates expression for submit. see also search-simpel.jsp
//method searchSubmitInternal: validates expression for submit . see also search-simple-result.jsp
//method TrimString: does a String.Trim()

//cleanin inputbox from search-expression of calendar
function cleanSearchExpression(){
  try{
  //clean top inputbox
  var formTop = document['searchFormTop'];
  if (formTop==null){

  } else{
     var expression = formTop["lucyExpr"].value;
     expression = TrimString(expression);
      if ((expression=='ei*')||(expression=='de*')){
       formTop["lucyExpr"].value='';
    }
  }
  //clean advanced search inputbox
  var formAdvanced=document['searchForm'];
  if (formAdvanced==null){

  } else{
     var expression = formAdvanced["lucyExpr"].value;
     expression = TrimString(expression);
      if ((expression=='ei*')||(expression=='de*')){
       formAdvanced["lucyExpr"].value='';
    }
  }
  
  var formAdvancedInternal = document['searchFormInternal'];
  if (formAdvancedInternal==null){

  } else{
     var expression = formAdvancedInternal["lucyExpr"].value;
     expression = TrimString(expression);
      if ((expression=='ei*')||(expression=='de*')){
       formAdvancedInternal["lucyExpr"].value='';
    }
  }
    }catch (E){

  }
}
function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}
 //validating  document['searchForm']['lucyExpr']
function searchSubmitAdvanced(searchForm){
   try{
  var expression = searchForm["lucyExpr"].value;
   expression = TrimString(expression);
  
  var valid = true;
   if (expression.length<3){
     valid = false;
   }

  if ((expression.charAt(0)=='*')||(expression.charAt(0)=='?')){
    valid = false;
  }

  if ((expression=='ei*')||(expression=='de*')){
    valid = false;
  }
  if (valid){
    searchForm.submit()
    }else{
    alert('Bitte geben sie einen Suchbegriff ein.')
  }
     }catch (E){

   }
  return valid;
}
 //validating  document['searchFormTop']['lucyExpr']
function searchSubmitSimple(searchForm){
  //alert(searchForm);
   try{
   var expression = searchForm["lucyExpr"].value;
   expression = TrimString(expression);

  var valid = true;
   if (expression.length<3){
     valid = false;
   }

  if ((expression.charAt(0)=='*')||(expression.charAt(0)=='?')){
    valid = false;
  }
  if ((expression=='ei*')||(expression=='de*')){
    valid = false;
  }
  if (valid){
    searchForm.submit()
    }else{
    alert('Bitte geben sie einen Suchbegriff ein.')
  }
     }catch (E){

   }
  return valid;
}
//validating  document['searchFormInternal']['lucyExpr']
function searchSubmitSimpleInternal(searchForm){
  //alert(searchForm);
  try{
   var expression = searchForm["lucyExpr"].value;
   expression = TrimString(expression);

  var valid = true;
   if (expression.length<3){
     valid = false;
   }

  if ((expression.charAt(0)=='*')||(expression.charAt(0)=='?')){
    valid = false;
  }
 if ((expression=='ei*')||(expression=='de*')){
    valid = false;
  }
  if (valid){
    searchForm.submit()
    }else{
    alert('Bitte geben sie einen Suchbegriff ein.')
  }
    }catch (E){
    
  }
  return valid;
}
/* ---- mp3Player ---- */
function startMp3Player(mp3FilePath,divName,startPlaying){
	mp3Player.addParam("allowScriptAccess", "sameDomain");
	mp3Player.addParam("menu", "false");
	mp3Player.addParam("quality", "high");
	mp3Player.addParam("align", "middle");
	mp3Player.addParam("wmode", "opaque");
	mp3Player.addVariable("beginPlaying", startPlaying);
	mp3Player.addVariable("mp3Path", mp3FilePath);
	mp3Player.write(divName);
}
function ivwLogMp3Player(){
	getCounters();
}
/* ---- video ---- */

function showMainPlayerDefer( mediaclip, player ) {
	var popupUrl = mediaclip;
	if ( mediaclip.indexOf( "?" ) > -1 ) {
		popupUrl = mediaclip.substr( 0, mediaclip.indexOf( "?" ) );
	}
	popupUrl += "?service=VideoPopup";
	var videowindow;
	if ( player == "adv" ) {
		popupUrl += "&player=adv";
		videowindow = window.open( popupUrl, "video", "width=492,height=433,location=0,menubar=0,resizable=0,scrollbars=0,toolbar=0,status=0" );
	}
	else {
		videowindow = window.open( popupUrl, "video", "width=748,height=433,location=0,menubar=0,resizable=0,scrollbars=0,toolbar=0,status=0" );
	}
	if ( videowindow.opener ) videowindow.opener = self;
	videowindow.focus();
}


function showMainPlayer( mediaclip, player ) {
	setTimeout( "showMainPlayerDefer( '" + mediaclip + "', '" + player + "' )", 100 );
}


function showMoreVideos() {
	if ( window.opener ) {
		window.opener.location = "/videos/";
		window.opener.focus();
		window.close();
	}
	else {
		window.open( "/videos/" );
		window.close();
	}
}


function ivwLogVideo( parameters ) {
	var ivw = "<img src=\"http://welt.ivwbox.de/cgi-bin/ivw/CP/videoteaser?r=" + escape(document.referrer) + "&d=" + (Math.random()*100000) + "\" width=\"1\" height=\"1\" alt=\"\" class=\"countPixel\"/>";

	videoUrl = parameters.url;
	if ( videoUrl.indexOf( "?" ) >= 0 ) videoUrl = videoUrl.substr( 0, videoUrl.indexOf( "?" ) );
	if ( videoUrl.substr( 0, 7 ) == "http://" ) {
		videoUrl = videoUrl.substr( 7 );
		videoUrl = videoUrl.substr( videoUrl.indexOf( "/" ) );
	}
	ivw += "<img src=\"http://ivw.ullstein-online.de/ivw/CP/welt" + escape(videoUrl) + "/_x_?d=" + (Math.random()*100000) + "\" width=\"1\" height=\"1\" alt=\"\" class=\"countPixel\" id=\"localCountPixel\"/>";

	var ivwElement = document.getElementById( "ivw" );
	if ( ivwElement ) {
		ivwElement.innerHTML = ivw;
	}


	if (typeof s == 'object'){
		s.pageName = "Video "+parameters.id+": "+parameters.title;
		s.prop5 = "Video";
		s.prop7 = parameters.bandwidth;
		s.prop3 = parameters.id;

		var code = s.t();
		if (code){
			document.getElementById("siteCatalystSink").innerHTML = code;
		}
	}

}


/* ---- loadDataToCookies ---- */
var xmlhttp	

function loadXMLDoc(url)
{
	xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}if (xmlhttp!=null){
		xmlhttp.onreadystatechange=state_Change
		xmlhttp.open("GET",url,true)
		xmlhttp.send(null)
	}else{
		alert("Your browser does not support XMLHTTP.")
	}
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
	{
	  // if "OK"
		if (xmlhttp.status==200)
		{
			// xmlhttp.status
			// xmlhttp.statusText
			// xmlhttp.responseText
			try{
				loadDataToCookies(xmlhttp.responseText);
			}
			catch(err){
			}
		}
		else
		{
		}
	}
}

function loadDataToCookies(text){

	// this script is used to make shure that the profile information is directly available as cookie information 
	// without having to do a login.	
	
	// Create a DOM tree from the personalisation information in http://*.welt.de/?service=Login
	
	
	// convert string to an XML doc
	
	// code for IE
	if (window.ActiveXObject)
	{
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(text);
	}
	// code for Mozilla, Firefox, Opera, etc.
	else
	{
		var parser=new DOMParser();
		var doc=parser.parseFromString(text,"text/xml");
	}
	
	// Loop trough the DOM tree to find the information for the cookie
	var root = doc.documentElement;
	 for (var iNode = 0; iNode < root.childNodes.length; iNode++) {
		var node = root.childNodes.item(iNode);
		
		// remove #text nodes in firefox
		if (!window.ActiveXObject)
		{
			for (i = 0; i < node.childNodes.length; i++) {
				if(node.childNodes.item(i).nodeName == "#text"){
					node.removeChild(node.childNodes.item(i));
				}
			}
		}
		
		// loop trough all nodes to find RSSfeeds and sorted gallery list
		for (i = 0; i < node.childNodes.length; i++) {
			//debugString += " " + node.childNodes.item(i).nodeName + "\n";
			try{
				//debugString += " " + node.childNodes.item(i).childNodes[0].nodeValue + "\n";
				if(node.childNodes.item(i).childNodes[0].nodeValue == "RSSfeeds"){
				
					// quotes are there becouse access manager also puts quotes around its session cookie values
					createCookie("RSSfeeds","\"" + node.childNodes.item(i-1).childNodes[0].nodeValue + "\"",365);	
				}
				if(node.childNodes.item(i).childNodes[0].nodeValue == "sortedGalleryList"){

					// quotes are there becouse access manager also puts quotes around its session cookie values
					createCookie("sortedGalleryList","\"" + node.childNodes.item(i-1).childNodes[0].nodeValue + "\"",365);
					
					var browser = navigator.userAgent;
					if ( browser.indexOf("Safari")>=0 || browser.indexOf("Konqueror")>=0 ){
						eraseCookie("sortedGalleryList");
					}
				}
			}catch(err){
			}
		}
	}
}

function logoutButton(){
	if(readCookie('userId') != null)
	{	//document.getElementById('LoginRegister').innerHTML = "<a class=\"arrowLink\" href=\"/action?action=logout\">Abmelden</a>";
		document.getElementById('LoginRegister').innerHTML = "<a href=\"/action?action=logout\">Abmelden</a>";
	}
}
		

if(readCookie("userId") != null){
	loadXMLDoc('/?service=Login');
}else{
	if(readCookie("RSSfeeds") != null){
		eraseCookie("RSSfeeds");
	}
	if(readCookie("sortedGalleryList") != null){
		eraseCookie("sortedGalleryList");
	}
}
/* ---- gallery ---- */
/* STATUS:FINAL */

/*
	This function can be used in two ways.
	Using the a href object.
	or
	Using the image id.
*/

function openImageGalleryPopup(Url) {
    window.open(Url,'picture_gallery','menubar=no, toolbar=no, status=no, width=665, height=565, scrollbars=no, resizable=no');
}

var waitingTimeoutId = null;

function viewImage(linkElement, number) {
	if (number != null) imageId = number;
	else imageId = linkElement.name;
	curr = images[imageId];
		
	imgNode = document.getElementById("fullimage");

    document.getElementById('hourglass').style.visibility = 'hidden';   /* hide hourglass if still visible */
    //Hide & Clear the old image, then change the properties and..
	imgNode.style.visibility = 'hidden';
    imgNode.src = "";
	imgNode.src = curr[0];

    //imgNode.width = (curr[6] > 305 ? (305*curr[5]) / curr[6] : curr[5]);
	//imgNode.height = (curr[6] > 305 ? 305 : curr[6]);
	imgNode.width = curr[5];
	imgNode.height = curr[6];
    imgNode.alt = imgNode.title = curr[4];

	// document.getElementById("fullimage_author").innerHTML = curr[11];
	document.getElementById("fullimage_copy").innerHTML = curr[3];
	// document.getElementById("fullimage_headline").innerHTML = curr[1];
	document.getElementById("fullimage_intro").innerHTML = curr[2];
	document.getElementById("fullimage_index").innerHTML = curr[8];
	document.getElementById("fullimage_back").name= curr[9];
	document.getElementById("fullimage_forward").name = curr[10];
    document.getElementById("fullimage_forward_imagebutton").name = curr[10];
    
    //..then show the new image
	//imgNode.style.visibility = 'visible';
	// DM: moved above instruction to the onload function of the image itself ;)
    //document.getElementById("fullimage").style.marginTop = "" + (305 - curr[6] > 0 ? (305 - curr[6])/2 : 0) + "px";
    waitingTimeoutId = window.setTimeout("document.getElementById('hourglass').style.visibility = 'visible';",900);
}

function drawPicturebar(linkElement,picturebarLength,picturebarPageLength) {
	
	var parent = document.getElementById("filmstrip");
	var nodes = parent.childNodes;
	var from = linkElement.name * picturebarLength;
	
	var curpage = from/picturebarLength;
	
	var backnr = curpage-1;
	var forwnr = curpage+1;
	
	if ( backnr<0 ) { backnr = picturebarPageLength; }
	
	if ( forwnr>picturebarPageLength ) { forwnr = 0; }
	
	for (var i = 0; i < nodes.length; i++) {
		node = nodes[i];
		if (node.className == "pictures") {
			// First remove all the child nodes;
			while (node.childNodes[0]) node.removeChild(node.childNodes[0]);
			for (var j=from; j < images.length && j < (from+picturebarLength); j++) {

				var ahref = document.createElement('a');
				ahref.name = j;
				ahref.href = "#";
		
				var div = document.createElement('div');
				div.className = "picture";

				if (window.attachEvent) {
					ahref.href = "javascript: viewImage('', "+j+");";
				} else {
					ahref.setAttribute("onClick", "viewImage(this);");
				}
					
				var img = document.createElement('img');
				img.src = images[j][12];
				img.height = images[j][14] > 43 ? 43 : images[j][14];
				img.alt = images[j][4];
				img.title = images[j][4];
				
				ahref.appendChild(img);
				div.appendChild(ahref);
				node.appendChild(div);
			}
		}
	}
	document.getElementById("galBack").name=backnr;
	document.getElementById("galForward").name=forwnr;
}


function reloadAdFrame () {
  var adlink_randomnumber=Math.floor(Math.random()*1000000000000);

  // Definition der "Grundhoehen und Breiten der Werbemittel:
  var adProp = new Array();
  adProp['Head'] = new Object();
  adProp['Head']['style'] = "width: 738px; height: 90px";  // 728x90
  adProp['Head']['id'] = "bannerHead";
  adProp['Skyscraper'] = new Object();
  adProp['Skyscraper']['style'] = "width: 160px; height; 600px";  // 120x600
  adProp['Skyscraper']['id'] = "bannerSkyscraper";
  adProp['Rectangle'] = new Object();
  adProp['Rectangle']['style'] = "width: 320px; height: 255px";  // 300x250
  adProp['Rectangle']['id'] = "banner_1";

  // Um ein Neuladen zu erzwingen, haengen wir die Bildnummer in die URL:
  var url = document.location.href;
  var imageNr = 0;
  document.getElementById && document.getElementById('fullimage_index') && (imageNr = document.getElementById('fullimage_index').innerHTML);
  url = url.replace(/\.html/,'_'+imageNr+'.html');


  for (var ad in adProp){

    // Wir maskieren die AD-Position als Satische URL
    // Eine Apache-Rewrite setzt dem Tomcat dann wieder ein ?service=Adframe&Position=ad vor:
    var urlFrame = url + '/AdFrame_' + ad + '.html';

    // Beim ersten Bild hat die Seite keine AD-Frames, sondern direkt eingebaute AD-Codes.
    // Wir suchen den Container ueber die ID und und plazieren dann einen IFrame. Bei den
    // reslichen Bildern gibt es schon einen IFrame - wir aendern dann das Attributr "src":

    var adContainer;
    if (document.getElementById && (adContainer = document.getElementById(adProp[ad]['id']))) {
      if (adContainer.firstChild && adContainer.firstChild.nodeName == 'IFRAME'){
        adContainer.firstChild.src = urlFrame;
      } else {
        adContainer.innerHTML = '<iframe style="' + adProp[ad]['style'] + '" src="' + urlFrame + '" scrolling="no" frameborder="0"></iframe>';
      }
    }
  }
}
/* ---- swfobject ---- */
/* STATUS:FINAL */

/**
 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
try
{ 

if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}

deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b)
{
	if(!document.createElement||!document.getElementById){return;}
	
	this.DETECT_KEY=_b?_b:"detectflash";
	this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params=new Object();
	this.variables=new Object();
	this.attributes=new Array();
	
	if(_1){this.setAttribute("swf",_1);}
	if(id){this.setAttribute("id",id);}
	if(w){this.setAttribute("width",w);}
	if(h){this.setAttribute("height",h);}
	if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}

	this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
	if(c){this.addParam("bgcolor",c);}
	
	var q=_8?_8:"high";
	this.addParam("quality",q);
	this.setAttribute("useExpressInstall",_7);
	this.setAttribute("doExpressInstall",false);
	var _d=(_9)?_9:window.location;
	
	this.setAttribute("xiRedirectUrl",_d);
	this.setAttribute("redirectUrl","");
	if(_a){this.setAttribute("redirectUrl",_a);}
};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){
_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
	var n=(typeof _20=="string")?document.getElementById(_20):_20;
	if (n)
		n.innerHTML=this.getSWFHTML();
	return true;
}else{
if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_25=new deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}
return _25;};
deconcept.PlayerVersion=function(_29){
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;
this.minor=parseInt(_29[1])||0;
this.rev=parseInt(_29[2])||0;};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){
var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){
return q.substring(q.indexOf("=",_2d)+1,_2e);
}}return "";}};
if(Array.prototype.push==null){
Array.prototype.push=function(_2f){
this[this.length]=_2f;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject; // for backwards compatibility
var SWFObject=deconcept.SWFObject;

}
catch(e)
{	
}

