/********** fast overwrite   *********/
var loadedOverwriteLists = {};

function loadBlockedArticleList(documentGlobalId, requestContext, id) {
    if (!loadedOverwriteLists[id]) {
		var url = requestContext + '/inc/blocked-articles.ajax';
		new Ajax.Updater(id, url, {
	  		parameters: { globalId:documentGlobalId }
		});
		loadedOverwriteLists[id] = true;
	}
}

function fastOverwriteBlockArticle(documentA, documentB, requestContext, isFastDocument) {
    var typeParams = {};
	if (isFastDocument) {
        typeParams['type'] = 'blocked';
        typeParams['command'] = 'set';
	} else {
	    typeParams['type'] = 'mandatory';
        typeParams['command'] = 'reset';
	}
	var url = requestContext + '/inc/article-relation-state-controller.ajax';
	new Ajax.Request(url, {
  		method: 'get',
  		parameters: $H(typeParams).merge({documentGlobalIdA:documentA,documentGlobalIdB:documentB}),
  		onSuccess: function(transport) {
  			window.location.reload();
		},
		onFailure: function() {
			alert('Beim Blocken des Artikels ist ein Fehler aufgetreten.');
		}
	});
}

function fastOverwriteUnblockArticle(documentA, documentB, requestContext) {
	var url = requestContext + '/inc/article-relation-state-controller.ajax';
	new Ajax.Request(url, {
  		method: 'get',
  		parameters: {type:'blocked',command:'reset',documentGlobalIdA:documentA,documentGlobalIdB:documentB},
  		onSuccess: function(transport) {
  			window.location.reload();
		},
		onFailure: function() {
			alert('Beim Entblocken des Artikels ist ein Fehler aufgetreten.');
		}
	});
}

function submitManualFastoverwrite(form, requestContext) {
    var url = requestContext + '/inc/article-relation-state-controller.ajax';
    new Ajax.Request(url, {
        method: 'get',
        parameters: form.serialize(true),
        onSuccess: function(transport) {
            window.location.reload();
        },
        onFailure: function() {
            alert('Beim Manuellen Hinzufügen/Entfernen eines Artikels ist ein Fehler aufgetreten.');
        }
    });
    
}

/**********  audio-player.js *********/

function embedAudioPlayer (target, options) {
    var flash = Plugin.getInfo("Flash");
    if (flash.isInstalled && parseInt(flash.version) >= 7) {
        var playerUrl = contextPath + "/static/swf/audio-player.swf";
        var audioUrl = options.audioUrl;
        var width = options.width;
        var height = options.height;

        
        var flashOptions = {
            scale: 'noScale',
            src: playerUrl, 
            width: width, 
            height: height, 
            FlashVars: "soundSrc=" + audioUrl
        };
        
        Plugin.embed("Flash", flashOptions, target);
    } else {
        //no flash plug-in
    }
}

/**********  global.js *********/

/* Schriftgroesse aendern */
var newfontSize = 0 ;
function groesse(pixel) {
	pixel= parseFloat(pixel)
	if (!newfontSize==0) {
		var ergebnis = newfontSize + pixel;
	}
	else
	{
		var ergebnis = 12 + pixel;
	}
		
   	document.getElementById("article-detail").style.fontSize = ergebnis+"px";
   	newfontSize = ergebnis;
}


/* Suchergebnisseite alle checken */
var marker_arr = new Array();
function CheckboxenAktivieren(field, fieldname)
{
	if(marker_arr[fieldname]==undefined){
		marker_arr[fieldname]==false;
	}
	
	if(!marker_arr[fieldname])
	{
		for(i=0; i<field.length; i++)
		{
			field[i].checked = true;
		}
		marker_arr[fieldname] = true;
	}
	else
	{
		for(i=0; i<field.length; i++)
		{
			field[i].checked = false;
		}
		marker_arr[fieldname] = false;
	}
}

/* Suchergebnisseite Filter ein und ausblenden */

function einblenden(divId) {
 if(document.getElementById)
   document.getElementById(divId).style.display = "block";
   document.getElementById("einblenden_"+divId).style.display = "none";
   document.getElementById("ausblenden_"+divId).style.display = "inline";
 
}
function ausblenden(divId) {
 if(document.getElementById)
   document.getElementById(divId).style.display = "none";
   document.getElementById("ausblenden_"+divId).style.display = "none";
   document.getElementById("einblenden_"+divId).style.display = "inline";
}

/* Suchergebnisseite Kalender */
function TageBestimmen()
{
	var Tag = document.getElementById("Tag").value;
	var Monat = document.getElementById("Monat").value;
	var Jahr = document.getElementById("Jahr").value;

	var TageImFebruar = 28;

	if((Jahr%4 == 0 && Jahr%100 !=0) || Jahr%400 == 0)
	{
		var TageImFebruar = 29;
	}

	var Tage = new Array(31, TageImFebruar, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	document.getElementById("Tag").options.length = Tage[Monat-1];

	for(i = 0; i < Tage[Monat-1]; i++)
	{
		document.getElementById("Tag").options[i].text = i+1;
		document.getElementById("Tag").options[i].value = i+1;
	}
}


var aktDatum = new (Date);
var aktTag = aktDatum.getDate();
var aktMonat = aktDatum.getMonth();
var aktJahr = aktDatum.getFullYear();

var Monatname = new
Array("Januar","Februar","MÃ¤rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");



function datumAuswaehlen()
{
	for(var i = 0; i < document.kalender.bis.length; i++)
	{
		if(document.kalender.bis.options[i].text==aktTag)
		{
		document.kalender.bis.options[i].selected=true;
		break;
		}
	}
	
	for(var i = 0; i < document.kalender.monat.length; i++)
	{
		if(document.kalender.monat.options[i].text==Monatname[aktMonat])
		{
		document.kalender.monat.options[i].selected=true;
		break;
		}
	}
	
	for(var i = 0; i < document.kalender.jahr.length; i++)
	{
		if(document.kalender.jahr.options[i].text==aktJahr)
		{
		document.kalender.jahr.options[i].selected=true;
		break;
		}
	}
}
/* Suchergebnisseite Kalender Ende */


/* button rollover */
function swapImgRestore() { //v3.0
  var i,x,a=document.Sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.Sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.Sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/* button rollover Ende */


/* open popup for articleDetail inline images */

function openDocumentDetailResourcePopup(theURL,winName,features) {
    window.open(theURL,winName,features);
}

/* Find first parental div of an element */

function firstParentalDiv(el) {
    while (el) {
        if (el.nodeName == "DIV") {
            return el;
        }   
        el = el.parentNode;
    }
    return null;
}

/* switch between the two slideshow teaser tabs in a slideshow popup */
function switchSlideShowsTeasers(myAnchorNode) {
    var divNodeList = myAnchorNode.parentNode.parentNode.parentNode.getElementsByTagName('div');
    var divNodes = $A(divNodeList);
    divNodes.each(
        function(divNode){
            if (divNode == myAnchorNode.parentNode.parentNode) {
                divNode.className = 'hide-slideshow-teaser';
            } else {
                divNode.className = 'display-slideshow-teaser';
            }
        }
    );
}

function gotoNextSlideshowTabPage(tab, newsPage, ressortPage, offset, contextPath, slideshowAjaxGlobalId, slideshowAjaxUrl) {
    var parameters = new Hash({});
    if (tab == 'ressort') {
        ressortPage += offset;
    } else {
        newsPage += offset;
        parameters['newsTabActive'] = 1;
    }
    
    parameters.merge({
        'tab': tab,
        'newsPage': newsPage,
        'ressortPage': ressortPage,
        'globalId' : slideshowAjaxGlobalId
    });
    
    var spinnerHtml = '<span style="width:100%;"><img style="border:none;position:relative;left:95px;" src="' + contextPath + '/static/css/img/spinner.gif" alt="Lade..."/></span>';

    var newsPager    = $('slideshow-teaser-news-pager');
    var ressortPager = $('slideshow-teaser-ressort-pager');
    
    if (newsPager) {
        newsPager.update(spinnerHtml);
    }
    if (ressortPager) {
        ressortPager.update(spinnerHtml);
    }

    new Ajax.Updater('slideshow-teaser', slideshowAjaxUrl, {
        'parameters': parameters
    });
}
/*
 *  Kommentaranzahl per Ajax abrufen
 */
 
var ajaxCommentDocs;
var idsOfGlobalIds = {};

function handleAjaxCommentCount(contextPath) {
    var allDivList = new Array();
    commentNeededId.each(function(divId) {
        var div = $(divId);
        var globalId = div.getAttribute("we:globalId");
        if (!idsOfGlobalIds[globalId]) {
            idsOfGlobalIds[globalId] = [];
         }
         idsOfGlobalIds[globalId].push(div);
           
        var prefixedComma = div.getAttribute("we:prefixedComma");
        allDivList.push({documentId: globalId, prefixedComma: prefixedComma});
    });
    if (allDivList.size() > 0) {
        new Ajax.Request(
                contextPath + '/inc/document-title-details.ajax', {
                method: 'POST',
                parameters: { documents: Object.toJSON(allDivList) },
                onSuccess: function(transport){
                    var startTime = new Date().getTime();
                    ajaxCommentDocs = transport.responseText.evalJSON(true);
                    handleAjaxCommentCountResult();
                }
            });
	}
}


/*
 *  Kommentarzahl die per AJAX abgerufen wurde, in die Seite einbetten.
 */

function handleAjaxCommentCountResult() {
        
        
        if (ajaxCommentDocs.length < 1) {
            return;
        }
            var document = ajaxCommentDocs.pop();
	        
	        var commentBuffer = ""; 
            if (document["prefixedComma"]) {
                commentBuffer += '<span class="comment">,&nbsp;</span>';
            }
            commentBuffer += '<a href="' + document["url"] + '#comments" class="comment">' + document["comments"] + '</a>';

            if (document["trackbacks"] != '') {
                commentBuffer += ', <a href="' + document["url"] + '#trackbacks" class="trackback">' + document["trackbacks"] + '</a>'; 
            }
            
            idsOfGlobalIds[document["globalId"]].each(function(ajaxContainer) {
                    ajaxContainer.update(commentBuffer);
                    ajaxContainer.show();
            });
            setTimeout(handleAjaxCommentCountResult, 10);
}

function disableRightClick(e){  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      return false;
    }
  }
  else
  {
    return false;
  }
}

/********** Content Multimedia Box Sliding ***************/
function multimediaSlideCount(div) {
    if (!div.slideCount) {
	    var i = 0;
	    var tCol = div.down('div.column-left'); 
	    if (tCol) {
	        i++;
	        while (tCol.next('div.column-middle')) {
	            i++;
	            tCol = tCol.next('div.column-middle');
	        }
	    }
	    if (div.down('div.column-left')) {
	        i++;
	    }
	    div.slideCount = i;
    }
    return div.slideCount;
}

function multimediaNext(div, id, contextPath, carouselCall, oneCategoryOnly) {
    if (div.down('div.column-right').next('div.column-hidden')) {
        var old_left=div.down('div.column-left');
        old_left.removeClassName('column-left');
        old_left.addClassName('column-hidden');
        
        var old_middle=div.down('div.column-middle');
        old_middle.removeClassName('column-middle');
        old_middle.addClassName('column-left');
        
        var old_right=div.down('div.column-right');
        old_right.removeClassName('column-right');
        old_right.addClassName('column-middle');
        
        var old_next=old_right.next('div.column-hidden');
        old_next.removeClassName('column-hidden');
        old_next.addClassName('column-right');

        if ('true' == oneCategoryOnly) {
	        old_middle.down('div.quattroCategory').down('a').show();
	        old_left.down('div.quattroCategory').down('a').hide();
        }
        
        updatePagerStates(div, id, contextPath);
        return true;
    } else if (div.carousel && !carouselCall) {
        while (multimediaPrev(div, id, contextPath, true)) {}
        for (var i = 0; i < multimediaSlideCount(div) - 1; i++) {
            multimediaNext(div, id, contextPath, true);
        }
        
    }
    return false;
}

function multimediaPrev(div, id, contextPath, carouselCall, oneCategoryOnly) {
    var old_left=div.down('div.column-left');
    var old_prev = old_left.previous('div.column-hidden');
    if (old_prev) {
        var old_right=div.down('div.column-right');
        old_right.removeClassName('column-right');
        old_right.addClassName('column-hidden');            
    
        var old_middle=div.down('div.column-middle');
        while(old_middle.next('div.column-middle')) {
            old_middle=old_middle.next('div.column-middle');
        }
        old_middle.removeClassName('column-middle');
        old_middle.addClassName('column-right');
        
        old_left.removeClassName('column-left');
        old_left.addClassName('column-middle');
        
        old_prev.removeClassName('column-hidden');
        old_prev.addClassName('column-left');
        
        if ('true' == oneCategoryOnly) {
	        old_prev.down('div.quattroCategory').down('a').show();
	        old_left.down('div.quattroCategory').down('a').hide();
        }
        
        updatePagerStates(div, id, contextPath);
        return true;
    } else if (div.carousel && !carouselCall) {
        while (multimediaNext(div, id, contextPath, true)) {}
        for (var i = 0; i < multimediaSlideCount(div) - 1; i++) {
            multimediaPrev(div, id, contextPath, true);
        }
    }
    return false;
}

function changePrevPagerState(id, enable, contextPath, carousel) {
    if (enable || carousel) {
        $$('img.' + id + '_pager_prev').each(function(el) {
            el.src = contextPath + "/static/css/img/btn_s1_left_mini_aktiv.gif";
        });                    
    } else {
        $$('img.' + id + '_pager_prev').each(function(el) {
           el.src = contextPath + "/static/css/img/btn_s1_left_mini_inaktiv.gif";
        });
    }
}

function changeNextPagerState(id, enable, contextPath, carousel) {
    if (enable || carousel) {
        $$('img.' + id + '_pager_next').each(function(el) {
            el.src = contextPath + "/static/css/img/btn_s1_right_mini_aktiv.gif";
        });                    
    } else {
        $$('img.' + id + '_pager_next').each(function(el) {
            el.src = contextPath + "/static/css/img/btn_s1_right_mini_inaktiv.gif";
        });
    }
}

function updatePagerStates(div, id, contextPath) {
    changePrevPagerState(id, div.down('div.column-left').previous('div.column-hidden'), contextPath, div.carousel);
    changeNextPagerState(id, div.down('div.column-right').next('div.column-hidden'), contextPath, div.carousel);
}

function setPagerCarousel(div, state) {
    div.carousel = state;
}
        


/**********  picturetransfer.js *********/

// ##########################################################################
// bildpartner.de Galerie-Schnittstelle		2004-01-12
// 
// 
// ACHTUNG: diese Schnittstelle darf nur in unveraenderter Form eingesetzt
//          werden. Mehr Informationen dazu entnehmen Sie der 
//          Dokumentation und der Nutzungslizenz fuer den Einsatz der
//          bildpartner.de Galerie-Schnittstelle.
// 
// Mit der Nutzung der bildpartner Galerie-Schnittstelle erkennen Sie die
// Geltung der Nuzuungslizenz Nutzungslizenz der 
// bildpartner.de Galerie-Schnittstelle und der AGBs der adconsys AG an.
//
// Kontakt:
// partner@bildpartner.de
// www.bildpartner.de
// 
// (c) 2002 - 2004 adconsys AG, www.adconsys.de
// ##########################################################################

function picturetransfer(url, format, referenz) {
	if (!format) format = '';
	if (!referenz) referenz = '';
	fotowin=window.open('http://www.bildpartner.de/upload/picup.php?vcode=1101892&pic='+url+'&artnr='+format+'&referenz='+referenz+'','fotowin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=300,height=250');
	fotowin.focus();
}

function preise(liste) {
	// liste = Preisliste

	if (!liste) liste = 'GALERIE';
	
	preiswin=window.open('http://shop.bildpartner.de/preisliste/?vcode=1101892-'+liste+'','preiswin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=380,height=450');
	preiswin.focus();
}

function kalendertransfer(url, format, text) {
	if (!format) format = '';
	if (!text) text = '';
	text=escape(text);
	url=escape(url);
	fotowin=window.open('http://www.bildpartner.de/upload/kalenderup.php?vcode=1101892&pic='+url+'&artnr='+format+'&k_text='+text+'','fotowin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=300,height=320');
	fotowin.focus();
}

/**********  plugin.js *********/



/**

 * PLUGIN FRAMEWORK, Version 0.5

 * For details, see the Knallgrau web site: http://www.knallgrau.code/prototype/plugins_js

 * Copyright (c) 2006 Matthias Platzer <matthias@knallgrau.at>

 * This code is freely distributable under the terms of an MIT-style license.

 * 

 ***********************************************************************************

 *  Copyright (c) 2006 Matthias Platzer <matthias@knallgrau.at>

 *  

 *  Permission is hereby granted, free of charge, to any person obtaining a copy 

 *  of this software and associated documentation files (the "Software"), to deal 

 *  in the Software without restriction, including without limitation the rights 

 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 

 *  copies of the Software, and to permit persons to whom the Software is 

 *  furnished to do so, subject to the following conditions:

 *  

 *  The above copyright notice and this permission notice shall be included in 

 *  all copies or substantial portions of the Software.

 *  

 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 

 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

 *  SOFTWARE.

 *

 ***********************************************************************************

 *

 *  inspired by Prototype JavaScript framework

 *

 *  Provides the following functions

 *    // name accepts: 

 *    // Acrobat, QuickTime, DivX, Director, 

 *    // 'Windows Media', Flash, Java, RealPlayer, VLC

 *    Plugin.isInstalled(String name) 

 *    Plugin.getVersion(String name)

 *    Plugin.getPluginsForMimeType(String mimeType)  // returns Array of Plugin Names

 *    Plugin.getPluginsForFileSuffix(String suffix)  // returns Array of Plugin Names

 *    Plugin.embed(pluginName, options, target)

 *    Plugin.getInfo(String name) 

 *      // Result Object contains informations about the plugin

 *      Boolean isInstalled

 *      String  version

 *      String  description

 *      Array   progID        to be used with new ActiveXObject()

 *      String  classID       for ActiveX

 *      String  pluginsPage   URL to download the plugin

 *      Array   acceptedMimeTypes  provides MimeType info for IE

 *

 * CHANGELOG:

 * 17.12.2005: Version 0.1

 *   initial version

 * 18.12.2005: Version 0.2

 *   added mimetypes for divx & co.

 *   added VLC support (detection for IE is missing)

 *   renamed getPluginsForMimeType, getPluginsForFileSuffix -> returns Array, instead of String

 *   dropped support vor Adobe SVG (IE)

 *   tested and debugged RealPlayer -> still reports a strange version number

 *   fixed bugs where script did break on unknown name attribute

 *   added experimental Plugin.embed

 * 20.12.2005: Version 0.3

 *   added docs

 *   added license

 *   rewrote Plugin.embed -> now it's easier to add new formats

 *   downloadURL became pluginsPage

 *   added mimeType, activeXType and codeBase to Plugin.PLUGINS

 *   Plugin.embed accepts strings as target (id)

 *   Added Plugin.embed support for Flash, RealPlayer and VLC

 * 23.03.2006: Version 0.4

 *   Fixed a few warnings reported by firefox in javascript strict mode (reported by Olav Roth)

 * 13.04.2006: Version 0.5

 *   Improved support for Windows Media Plugin

 *   - use WM6.4 ClassID instead of WM7 (this fixes a lot of bad behaviour, like missing controls)

 *   - detect installed ActiveX support for Mozilla (Firefox)

 *   - added support for forceObjectTag as a sideeffect

 *   Fixed a bug with embeding VLC (src needs to be present in the embed tag)

 *   Updated DivX support to final Version 1.0

 * 

 * you may remove the comments section, but please leave the copyright

/*--------------------------------------------------------------------------*/



var PluginFactory = function() {



  // Returns if plugin with identifier name is installed

  // @see Plugin.getInfo

  this.isInstalled = function(name) {

    return Plugin.getInfo(name).isInstalled;

  }



  // Returns version number of plugin if available

  // @see Plugin.getInfo

  this.getVersion = function(name) {

    return Plugin.getInfo(name).version;

  }



  // Returns an Array of plugin identifier names, 

  // that can handle this mimeType.

  this.getPluginsForMimeType = function(mimeType) {

    var result = [];

    if (supportsNavigatorPlugins()) {

      // navigator.mimeTypes

      for (var i=0; i<navigator.mimeTypes.length; i++) {

        if (navigator.mimeTypes[i].type.indexOf(mimeType) == 0 && navigator.mimeTypes[i].enabledPlugin) {

          var pluginName = (findPluginName(navigator.mimeTypes[i].enabledPlugin.name) || navigator.mimeTypes[i].enabledPlugin.name);

          if (!Array.contains(result, pluginName)) result.push(pluginName);

        }

      }

    } else {

      // Code for IE using ActiveX

      for (var pluginName in Plugin.PLUGINS) {

        var mimeTypes = Plugin.PLUGINS[pluginName].acceptedMimeTypes;

        if (!mimeTypes) continue;

        for (var j=0; j<mimeTypes.length; j++) {

          if (mimeTypes[j].type.indexOf(mimeType) == 0 && Plugin.isInstalled(pluginName)) {

            if (!Array.contains(result, pluginName)) result.push(pluginName);

          }

        }

      }    

    }

    return result;

  }



  // Returns an Array of plugin identifier names, 

  // that can handle a file with this suffix.

  this.getPluginsForFileSuffix = function(suffix) {

    var result = [];

    if (supportsNavigatorPlugins()) {

      // navigator.mimeTypes

      for (var i=0; i<navigator.mimeTypes.length; i++) {

        if ((","+navigator.mimeTypes[i].suffixes+",").indexOf(","+suffix+",") != -1 && navigator.mimeTypes[i].enabledPlugin) {

          var pluginName = (findPluginName(navigator.mimeTypes[i].enabledPlugin.name) || navigator.mimeTypes[i].enabledPlugin.name);

          if (!Array.contains(result, pluginName)) result.push(pluginName);

        }

      }

    } else {

      // Code for IE using ActiveX

      for (var pluginName in Plugin.PLUGINS) {

        var mimeTypes = Plugin.PLUGINS[pluginName].acceptedMimeTypes;

        if (!mimeTypes) continue;

        for (var j=0; j<mimeTypes.length; j++) {

          if ((","+mimeTypes[j].suffixes+",").indexOf(","+suffix+",") != -1 && Plugin.isInstalled(pluginName)) {

            if (!Array.contains(result, pluginName)) result.push(pluginName);

          }

        }

      }    

    }

    return result;

  }



  // Returns general information about a plugin.

  // accepts: Acrobat, QuickTime, DivX, Director, 'Windows Media', 

  //          Flash, Java, RealPlayer, VLC

  this.getInfo = function(name) {



    var info = Plugin.PLUGINS[name];

    var isInstalled = false;

    var version = null;



    if (supportsNavigatorPlugins()) {

      // navigator.plugins

      var plugin = findNavigatorPluginByName((name == "RealPlayer") ? "RealPlayer Version Plugin" : name);

      if (plugin) {

        isInstalled = true;

        version = getVersionFromPlugin(plugin);

      }



    } else {

      // Code for IE using ActiveX

      isInstalled = hasActiveXObject(Plugin.PLUGINS[name] && Plugin.PLUGINS[name].progID);

      if (isInstalled) {

        if (Plugin.PLUGINS[name].getActiveXVersionInfo) {

          version = Plugin.PLUGINS[name].getActiveXVersionInfo();

        } else {

          // assume that the progID contains the version number

          // this is not always correct

          var progID = getProgIdForActiveXObject(Plugin.PLUGINS[name].progID);

          version = getVersionFromPlugin(progID);

        }

      } else {

        version = getActiveXPluginByClassId(Plugin.PLUGINS[name] && Plugin.PLUGINS[name].classID);

        if (version) version = version.replace(/,/g, ".");

        isInstalled = (version!=undefined);

      }



    }



    var result = {};

    for (var i in info) {

      result[i] = info[i];

    }

    result["isInstalled"] = isInstalled;

    result["version"] = version;

    result["name"] = name;



    return result;

  }



/**

 * writes an embed or object tag to document.write or target.

 * @param plugin   name of the plugin to be used

 * @param options  options for embed respectivly object tag.

 *   .src,.width,.height,.type,.activeXType will get a special treatment

 *   all other properties of options will be added to the 

 *   embed tag as attributes resp. to the object tag as param(eters).

 *   option names should be lower case!

 * @param target   optional (id of) container element for the embed/object tag

 */

  this.embed = function(plugin, options, target) {

    options = options || {};



    var embedOptions = Object.extend({}, options);

    var src = embedOptions.src;

    delete embedOptions.src;

    var id = embedOptions.id;

    delete embedOptions.id;

    var name = embedOptions.name || id;

    delete embedOptions.name;

    var width = embedOptions.width;

    delete embedOptions.width;

    var height = embedOptions.height;

    delete embedOptions.height;

    var type = embedOptions.type || (Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].mimeType) || "";

    delete embedOptions.type;

    var activeXType = embedOptions.activeXType || (Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].activeXType) || type;

    delete embedOptions.activeXType;

    var forceEmbedTag = (Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].forceEmbedTag === true) ? true : false;

    var forceObjectTag = (Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].forceObjectdTag === true) ? true : false;



    var embedOptions = Object.extend(((Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].standardEmbedAttributes) || {}), embedOptions);



    switch (plugin) {

      case "QuickTime":

        // get space for controlls

        if (embedOptions.controller == "true" && (height+"").indexOf("%") == -1) {

          height += 16;

        }

        if (!options.activeXType) {

          activeXType = null;

        }

        break;



      case "DivX":

        // get space for controlls

        if ((height+"").indexOf("%") == -1) {

          if (embedOptions.mode == "mini") height += 20;

          else if (embedOptions.mode == "large") height += 65;

          else if (embedOptions.mode == "full") height += 90;

        }

        break;



      case "Windows Media":

        // check if ActiveX for Firefox is installed

        // http://help.yahoo.com/help/us/launch/videos/videos-07.html

        if (!supportsNavigatorPlugins() || window.GeckoActiveXObject) {

           forceObjectTag = true;

        }

        // get space for controlls

        if ((window.ActiveXObject || window.GeckoActiveXObject || window.opera) &&

            (height+"").indexOf("%") == -1) {

          height += 45;

        }

        break;



      case "Flash":

        // flash wants the src to be named "movie" if passed as object param

        if (!supportsNavigatorPlugins()) {

          embedOptions.movie = src;

          src = null;

        }

        break;



      case "VLC":

        // VLC wants the src to be named "target"

        // update: that's actualy wrong, even it's documented like that!

        if (supportsNavigatorPlugins()) {

          embedOptions.target = src;

        }

        break;



      case "RealPlayer":

        break;        



      default: 

        // do nothing

        break;

    }



    // prepare html code

    var html = "";

    if ((supportsNavigatorPlugins() && ! forceObjectTag) || forceEmbedTag) {

      // Netscape Plugin embed Tag

      html += '<embed' + getAttributeHtml("src", src)  + getAttributeHtml("id", id) + getAttributeHtml("name", name) + getAttributeHtml("width", width) + getAttributeHtml("height", height) + getAttributeHtml("pluginspage", Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].pluginsPage) + getAttributeHtml("type", type);

      for (var i in embedOptions) {

        html += ' '+i+'="'+embedOptions[i]+'"';

      }

      html += '></embed>\n';

    } else {

      // ActiveX object tag

      html += '<object classid="clsid:'+(Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].classID)+'"';

      html += getAttributeHtml("id", id) + getAttributeHtml("name", name) + getAttributeHtml("width", width) + getAttributeHtml("height", height) + getAttributeHtml("codebase", (Plugin.PLUGINS[plugin] && Plugin.PLUGINS[plugin].codeBase)) + getAttributeHtml("type", activeXType) + '>\n';

      html += (src) ? '  <param name="src" value="'+src+'">\n' : '';

      for (var i in embedOptions) {

        html += '  <param name="'+i+'" value="'+embedOptions[i]+'" />';

      }

      html += '</object>\n';

    }



    if (target) {

      if (typeof target == "string") target = document.getElementById(target);

      target.innerHTML = html;

    } else {

      document.write(html);

    }

  }



  var getAttributeHtml = function(name, value) {

    return (value) ? (" " + name + "=\"" + value + "\"") : "";

  }



  // Info about known plugins

  this.PLUGINS = {

    "Acrobat": {

      description: "Adobe Acrobat Plugin",

      progID: ["PDF.PdfCtrl.7", "PDF.PdfCtrl.6", "PDF.PdfCtrl.5", "PDF.PdfCtrl.4", "PDF.PdfCtrl.3", "AcroPDF.PDF.1"],

      classID: "CA8A9780-280D-11CF-A24D-444553540000",

      pluginsPage: "http://www.adobe.com/products/acrobat/readstep2.html",

      acceptedMimeTypes: [

        { type: "application/pdf", suffixes: "pdf" },

        { type: "application/vnd.fdf", suffixes: "fdf" },

        { type: "application/vnd.adobe.xfdf", suffixes: "xfdf" },

        { type: "application/vnd.adobe.xdp+xml", suffixes: "xdp" },

        { type: "application/vnd.adobe.xfd+xml", suffixes: "xfd" }

      ]

    },

    "QuickTime": {

      description: "QuickTime Plug-in",

      progID: ["QuickTimeCheckObject.QuickTimeCheck.1", "QuickTime.QuickTime"],

      classID: "02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",

      pluginsPage: "http://www.apple.com/quicktime/download/",

      codeBase: "http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0",

      mimeType: "video/quicktime",

      standardEmbedAttributes: {

        autoplay: "false"

      },

      // embedInfo: http://www.apple.com/quicktime/tutorials/embed.html 

      //            http://developer.apple.com/quicktime/compatibility.html

      getActiveXVersionInfo: function() { 

        var progID = getProgIdForActiveXObject(Plugin.PLUGINS["QuickTime"].progID); 

        var obj = new ActiveXObject(progID);

        var version = (obj && obj.QuickTimeVersion) ? obj.QuickTimeVersion.toString(16) : "";

        return version.substring(0,1) + '.' + version.substring(1,2) + '.' + version.substring(2,3);

      },

      acceptedMimeTypes: [

        { type: "image/tiff", suffixes: "tif,tiff" },

        { type: "image/x-tiff", suffixes: "tif,tiff" },

        { type: "video/x-m4v", suffixes: "m4v" },

        { type: "image/x-macpaint", suffixes: "pntg,pnt,mac" },

        { type: "image/pict", suffixes: "pict,pic,pct" },

        { type: "image/x-pict", suffixes: "pict,pic,pct" },

        { type: "image/x-quicktime", suffixes: "qtif,qti" },

        { type: "image/x-sgi", suffixes: "sgi,rgb" },

        { type: "image/x-targa", suffixes: "targa,tga" },

        { type: "audio/3gpp", suffixes: "3gp,3gpp" },

        { type: "video/3gpp2", suffixes: "3g2,3gp2" },

        { type: "audio/3gpp2", suffixes: "3g2,3gp2" },

        { type: "video/sd-video", suffixes: "sdv" },

        { type: "application/x-mpeg", suffixes: "amc" },

        { type: "video/mp4", suffixes: "mp4" },

        { type: "audio/mp4", suffixes: "mp4" },

        { type: "audio/x-m4a", suffixes: "m4a" },

        { type: "audio/x-m4p", suffixes: "m4p" },

        { type: "audio/x-m4b", suffixes: "m4b" },

        { type: "video/mpeg", suffixes: "mpeg,mpg,m1s,m1v,m1a,m75,m15,mp2,mpm,mpv,mpa" },

        { type: "audio/mpeg", suffixes: "mpeg,mpg,m1s,m1a,mp2,mpm,mpa,m2a" },

        { type: "audio/x-mpeg", suffixes: "mpeg,mpg,m1s,m1a,mp2,mpm,mpa,m2a" },

        { type: "video/3gpp", suffixes: "3gp,3gpp" },

        { type: "audio/x-gsm", suffixes: "gsm" },

        { type: "audio/AMR", suffixes: "AMR" },

        { type: "audio/aac", suffixes: "aac,adts" },

        { type: "audio/x-aac", suffixes: "aac,adts" },

        { type: "audio/x-caf", suffixes: "caf" },

        { type: "video/x-mpeg", suffixes: "mpeg,mpg,m1s,m1v,m1a,m75,m15,mp2,mpm,mpv,mpa" },

        { type: "audio/aiff", suffixes: "aiff,aif,aifc,cdda" },

        { type: "audio/x-aiff", suffixes: "aiff,aif,aifc,cdda" },

        { type: "audio/basic", suffixes: "au,snd,ulw" },

        { type: "audio/mid", suffixes: "mid,midi,smf,kar" },

        { type: "audio/x-midi", suffixes: "mid,midi,smf,kar" },

        { type: "audio/midi", suffixes: "mid,midi,smf,kar" },

        { type: "audio/vnd.qcelp", suffixes: "qcp" },

        { type: "application/sdp", suffixes: "sdp" },

        { type: "application/x-sdp", suffixes: "sdp" },

        { type: "application/x-rtsp", suffixes: "rtsp,rts" },

        { type: "video/quicktime", suffixes: "mov,qt,mqv" },

        { type: "video/flc", suffixes: "flc,fli,cel" },

        { type: "audio/x-wav", suffixes: "wav,bwf" },

        { type: "audio/wav", suffixes: "wav,bwf" }

      ]

    },

    "DivX": {

      description: "DivX Browser Plugin",

      progID: ["npdivx.DivXBrowserPlugin.1", "npdivx.DivXBrowserPlugin"],

      classID: "67DABFBF-D0AB-41fa-9C46-CC0F21721616",

      codeBase: "http://go.divx.com/plugin/DivXBrowserPlugin.cab",

      pluginsPage: "http://go.divx.com/plugin/download/",

      mimeType: "video/divx",

      standardEmbedAttributes: {

        mode: "mini",

        minversion: "1.0.0"

      },

      // embedInfo: Beta1: http://labs.divx.com/archives/000072.html

      //            SDK&Doc: http://download.divx.com/labs/Webmaster_SDK.zip

      getActiveXVersionInfo2: function() {

        var progID = getProgIdForActiveXObject(Plugin.PLUGINS["DivX"].progID); 

        return "1.0.0"; // that's the only currently available

      },

      acceptedMimeTypes: [

        { type: "video/divx", suffixes: "dvx,divx" }

      ]

    },

    "Director": {

      description: "Macromedia Director",

      progID: ["SWCtl.SWCtl.11","SWCtl.SWCtl.10","SWCtl.SWCtl.9","SWCtl.SWCtl.8","SWCtl.SWCtl.7","SWCtl.SWCtl.6","SWCtl.SWCtl.5","SWCtl.SWCtl.4"],

      classID: "166B1BCA-3F9C-11CF-8075-444553540000",

      pluginsPage: "http://www.macromedia.com/shockwave/download/",

      codeBase: "http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0",

      mimeType: "application/x-director"

    },         

    "Flash": {

      description: "Macromedia Shockwave Flash",

      progID: ["ShockwaveFlash.ShockwaveFlash.9", "ShockwaveFlash.ShockwaveFlash.8.5", "ShockwaveFlash.ShockwaveFlash.8", "ShockwaveFlash.ShockwaveFlash.7", "ShockwaveFlash.ShockwaveFlash.6", "ShockwaveFlash.ShockwaveFlash.5", "ShockwaveFlash.ShockwaveFlash.4"],

      classID: "D27CDB6E-AE6D-11CF-96B8-444553540000",

      pluginsPage: "http://www.macromedia.com/go/getflashplayer",

      codeBase: "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0",

      mimeType: "application/x-shockwave-flash",

      standardEmbedAttributes: {

        quality: "high"

      },

      // embedInfo: http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_4150

      //            http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701

      acceptedMimeTypes: [

        { type: "application/x-shockwave-flash", suffixes: "swf" },

        { type: "application/futuresplash", suffixes: "spl" }

      ]

    }, 

    "VLC": {

      description: "VLC multimedia plugin",

      progID: [],

      classID: "",

      pluginsPage: "http://www.videolan.org/doc/play-howto/en/ch02.html#id287569",

      codeBase: "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0",

      mimeType: "application/x-vlc-plugin",

      standardEmbedAttributes: {

        quality: "high",

        autoplay: "no"

      },

      // embedInfo: http://www.videolan.org/doc/vlc-user-guide/en/ch07.html

      //            http://www.videolan.org/doc/play-howto/en/ch04.html#id293251

      acceptedMimeTypes: [

        { type: "audio/mpeg", suffixes: "mp2,mp3,mpga,mpega" },

        { type: "audio/x-mpeg", suffixes: "mp2,mp3,mpga,mpega" },

        { type: "video/mpeg", suffixes: "mpg,mpeg,mpe" },

        { type: "video/x-mpeg", suffixes: "mpg,mpeg,mpe" },

        { type: "video/mpeg-system", suffixes: "mpg,mpeg,vob" },

        { type: "video/x-mpeg-system", suffixes: "mpg,mpeg,vob" },

        { type: "video/mpeg4", suffixes: "mp4,mpg4" },

        { type: "audio/mpeg4", suffixes: "mp4,mpg4" },

        { type: "application/mpeg4-iod", suffixes: "mp4,mpg4" },

        { type: "application/mpeg4-muxcodetable", suffixes: "mp4,mpg4" },

        { type: "video/x-msvideo", suffixes: "avi" },

        { type: "video/quicktime", suffixes: "mov,qt" },

        { type: "application/x-ogg", suffixes: "ogg" },

        { type: "application/x-vlc-plugin", suffixes: "*" },

        { type: "video/x-ms-asf-plugin", suffixes: "asf,asx,*" },

        { type: "video/x-ms-asf", suffixes: "asf,asx,*" },

        { type: "application/x-mplayer2", suffixes: "dvx,divx,ivx,xvid,ivf,*" },

        { type: "video/x-ms-wmv", suffixes: "wmv,*" },

        { type: "application/x-google-vlc-plugin", suffixes: "*" }      

      ]

    },

    "Windows Media": {

      description: "Windows Media Player Plug-in Dynamic Link Library",

      progID: ["WMPlayer.OCX", "MediaPlayer.MediaPlayer.1"],

      classID: "22D6f312-B0F6-11D0-94AB-0080C74C7E95", // WMP6 -> semms to work a lot better, don't know why

      // classID: "6BF52A52-394A-11D3-B153-00C04F79FAA6", // WMP7+ -> doesn't work for me

      pluginsPage: "http://www.microsoft.com/windows/windowsmedia/",

      codeBase: "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902",

      mimeType: "application/x-mplayer2",

      activeXType: "application/x-oleobject",

      standardEmbedAttributes: {

        autoplay: "false"

      },

      // embedInfo: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/imedia/netshow/crossbrowserembed/default.asp

      getActiveXVersionInfo: function() { 

        var progID = getProgIdForActiveXObject(Plugin.PLUGINS["Windows Media"].progID); 

        var obj = new ActiveXObject(progID);

        return (obj && obj.versionInfo) ? obj.versionInfo : "";

      },

      acceptedMimeTypes: [

        { type: "application/asx", suffixes: "*" },

        { type: "video/x-msvideo", suffixes: "avi" },

        { type: "video/x-ms-asf-plugin", suffixes: "*" },

        { type: "application/x-mplayer2", suffixes: "dvx,divx,ivx,xvid,ivf,*" },

        { type: "video/x-ms-asf", suffixes: "asf,asx,*" },

        { type: "video/x-ms-wm", suffixes: "wm,*" },

        { type: "audio/x-ms-wma", suffixes: "wma,*" },

        { type: "audio/x-ms-wax", suffixes: "wax,*" },

        { type: "video/x-ms-wmv", suffixes: "wmv,*" },

        { type: "video/x-ms-wvx", suffixes: "wvx,*" }

      ]

    },

    "Java": {

      description: "Java Virtual Machine",

      progID: [],

      classID: "08B0E5C0-4FCB-11CF-AAA5-00401C608500",

      pluginsPage: "http://www.java.com/de/download/manual.jsp",

      acceptedMimeTypes: [

        { type: "application/x-java-applet", suffixes: "" },

        { type: "application/x-java-bean", suffixes: "" },

        { type: "application/x-java-vm", suffixes: " " }

      ]

    },          

    "RealPlayer": {

      description: "RealPlayer Version Plugin",

      progID: ["RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)", "RealVideo.RealVideo(tm) ActiveX Control (32-bit)", "rmocx.RealPlayer G2 Control"],

      classID: "CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA",

      mimeType: "audio/x-pn-realaudio-plugin",

      pluginsPage: "http://www.real.com/freeplayer/?rppr=rnwk",

      forceEmbedTag: true,

      standardEmbedAttributes: {

        controls: "ControlPanel",

        nojava: "true",

        autostart: "false"

      },

      // embedInfo: http://service.real.com/help/library/guides/realone/ProductionGuide/HTML/realpgd.htm?page=htmfiles/embed.htm

      // couldn't find any info about the object tag!

      getActiveXVersionInfo: function() { 

        var progID = getProgIdForActiveXObject(Plugin.PLUGINS["RealPlayer"].progID); 

        var obj = new ActiveXObject(progID);

        var version = (obj) ? obj.GetVersionInfo() : "";

        return version;

      },

      acceptedMimeTypes: [

        { type: "audio/x-pn-realaudio-plugin", suffixes: "rpm" },

        { type: "application/vnd.rn-realplayer-javascript", suffixes: "rpj" }

      ]

    }

  }



  var supportsNavigatorPlugins = function() {

    return (navigator.plugins && (navigator.plugins.length > 0));

  }



  var supportsActiveX = function() {

    return ((typeof 'ActiveXObject' != 'undefined') && (navigator.userAgent.indexOf('Win') != -1));

  }



  var findNavigatorPluginByName = function(name) {

    if (supportsNavigatorPlugins()) {

      for(var i=0;i<navigator.plugins.length;++i) {

        var plugin = navigator.plugins[i];

        if (plugin.name.indexOf(name) != -1) {

          return plugin;

        }

      }

    }

    return null;

  }



  var findPluginName = function(str) {

    for (var pluginName in Plugin.PLUGINS) {

      if (str.indexOf(pluginName) != -1) {

        return pluginName;

      }

    }

    return null;

  }



  var getIEClientCaps = function() {

    var clientcaps = document.getElementById("__Plugin_ClientCaps");

    if (!clientcaps) {

      var clientcaps = document.createElement("DIV");

      clientcaps.id = "__Plugin_ClientCaps";

      if (clientcaps.addBehavior) {

        clientcaps.addBehavior("#default#clientCaps");

        document.body.appendChild(clientcaps);

      }

      clientcaps = document.getElementById("__Plugin_ClientCaps");

    }

    return clientcaps;    

  }



  var getActiveXPluginByClassId = function(classID) {

    if (!classID) return null;

    if (!classID.match(/{[^}]+}/)) classID = "{" + classID + "}";

    var clientcaps = getIEClientCaps();

    try {

      var result = clientcaps.getComponentVersion(classID, "ComponentID")

      return result || null;

    } catch (err) { }

    return null;

  }



  var hasActiveXObject = function(progID) {

    progID = getProgIdForActiveXObject(progID);

    return (progID != null);

  }



  var getProgIdForActiveXObject = function(progID) {

    if (!progID) return null;

    for (var i=0; i<progID.length; i++) {

      try {

        var obj = new ActiveXObject(progID[i]);

        return progID[i] || null;

      }

      catch(e) { }

    }

    return null;

  }



  // accepts plugin or string

  var getVersionFromPlugin = function(plugin) {

    if (!plugin.name) plugin = { name: plugin, description: name };

    var matches = /[\d][\d\.]*/.exec(plugin.name);

    if (matches && plugin.name.indexOf("Java") == -1) return matches[0];

    matches = /[\d\.]+/.exec(plugin.description);

    return matches ? matches[0] : "";

  }

  

};



// helper functions

// for usage without prototype.js

if (!Object.extend) {

  Object.extend = function(destination, source) {

    for (property in source) {

      destination[property] = source[property];

    }

    return destination;

  }

}

// Array functions
Array.contains = function(arr, el) {
  return Array.indexOf(arr, el) != -1;
}

Array.indexOf = function(arr, el) {
  for (var i=0; i<arr.length; i++) {
    if (arr[i] == el) return i;
  }
  return -1;
}

String.encode = String.prototype.encode = function() {
  var str = this;
  str = str.replace("&", "&amp;");
  str = str.replace("<", "&lt;");
  str = str.replace(">", "&gt;");
  str = str.replace("\"", "&quot;");
  str = str.replace("\n", "");
  return str;

}

if (!window.Plugin) {

  var Plugin = new Object();

}

Object.extend(Plugin, (new PluginFactory()));

/**********  search.js *********/

function resetModifiersAndSubmit(key, value, formId, typeModifierName) {
	removeLastModifiers();
	submitWithValue(key, value, formId, typeModifierName);
}

function submitWithValue(key, value, formId, typeModifierName) {
	var form = document.getElementById(formId);
	var el = document.createElement("input");
    el.type = "hidden";
    el.name = key;
    el.value = value;
    form.appendChild(el);
    
	var el2 = document.createElement("input");
    el2.type = "hidden";
    el2.name = "chosenTypeNavigatorName";    
    el2.value = typeModifierName;
    form.appendChild(el2);
    form.submit();
    return false;
}

function appendChosenTypeModifierAsHiddenField(formId, typeModifierName) {
	$A($$('chosenTypeNavigatorName')).each(function (modifier) {
		Element.remove(modifier);	
	});

	var form = document.getElementById(formId);
	var el = document.createElement("input");
    el.type = "hidden";
    el.name = 'chosenTypeNavigatorName';
    el.value = typeModifierName;
    form.appendChild(el);
    
    form.action += generateSearchUrl(form);
    
    form.submit();
    return false;	
}


function removeLastModifiers() {
	$A($$('input.last-modifier')).each(function (modifier) {
		Element.remove(modifier);	
	});
	var el = $('chosenTypeNavigatorName');
	if (el != null) {
		Element.remove(el);
	}	
}


function checkAll(el, clazz) {
    $$("div." + clazz + " input").each(function (input) {
        if (input.type == 'checkbox') { 
            input.checked = el.checked;
        }
    });
}
    

function expandSearchFilterSublist(id) {
    var sublist = $(id);
    var span = $(id + '-span');
    if (sublist.style.display == 'none') {
        span.className = span.getAttribute('we:expanded-class');
    } else {
        span.className = span.getAttribute('we:collapsed-class');
    }
    
    Effect.toggle(sublist, 'appear', {duration : 0.3});
}

function generateSearchUrl(form) {
    form = Element.extend(form);
    
    if (form.searchphrase[0].value.replace(/^\s+$/,'').length > 0) {
	    
	    var sorting = 'sortiert-nach-neuestem';
	    $A(form.sortBy).each(function(el) {
	        if (el.checked) {
	            if (el.value == 'date_asc') {
	                sorting = 'sortiert-nach-aeltestem';
	            } else if (el.value == 'relevance') {
	                sorting = 'sortiert-nach-relevanz';
	            }
	         }
	    });
	    
	    return'/suche/' + form.typeForLink.value + '/' + sorting + '/' + 
	            form.searchphrase[0].value.escapeHTML() + '.html';
    } else {
        return '/suche.html';
    }
}

/**********  slideshow.js *********/
var slideshowCallbacks = [];

function loadSlideImage(slideImg) {
    if (slideImg) {
	    var reloadableSrc = slideImg.readAttribute('we:reloadablesrc');
	    if (reloadableSrc && slideImg.src != reloadableSrc) {
	        slideImg.src = reloadableSrc;
	    }
    }
}

function slideshowSet(id, offset, slides) {
    var resourceId = 'undefined';
    var slideshow = $(id);
    var position = parseInt(slideshow.getAttribute('slideshow:position'));
    var size = parseInt(slideshow.getAttribute('slideshow:size'));
    
    position += offset;
    
    var lastPosition = 0;
    if ((position + size) > slides.length) {
        position = size - 1;   
    }
    if (position < 0) {
        position = slides.length - ((size - 1) * (size > 1 ? 2 : 1) + 1);    
    }
    if (id == 'single_slideshow') {
        if(position + 1 == slides.length) {
            slideshow.setAttribute('slideshow:islast', 'true');
        } else {
            slideshow.setAttribute('slideshow:islast', 'false');
        }
    }
    for (i=0; i < slides.length; i++) {
        var slide = slides[i];
        if (position <= i && (position + size) > i) {
            loadSlideImage($(slide.id + "_img"));
            slide.style.display = 'block';
            lastPosition = i + size - (size > 1 ? 1 : 0);
            if (slide.getAttribute('slideshow:resource')) {
                resourceId = slide.getAttribute('slideshow:resource');
            }
        } else {
            slide.style.display = 'none';
        }
    }
    slideshow.setAttribute('slideshow:position', position);

    loadSlideImage($((lastPosition + (offset > 0 ? 1 : -1)) + "_" + id + "_img"));
    if (slideshowCallbacks[id]) {
        var actualPosition = position;
        if (actualPosition < (size - 1)) {
            actualPosition = size - (size - 1 - actualPosition);
        }
        if (actualPosition > slides.length - size) {
            actualPosition = actualPosition - (slides.length - size);
        }
        slideshowCallbacks[id].call(null, position, actualPosition + 1); 
    }
    if (!(resourceId == 'undefined')) {
       updateForm(resourceId);
    }
}

function slideshowSetup(id, callback) {
    var slides = $$("#" + id + " .canvas .slide");
    if (callback) {
        slideshowCallbacks[id] = callback;
    }
    slideshowSet(id, 0, slides);
    if (arguments.length == 3 && arguments[2].length > 0) {
        var resources = arguments[2].split(',');
        for (i=0; i < slides.length; i++) {
            slides[i].setAttribute('slideshow:resource', resources[i]);
        }
    }
    return slides;
}

function slideshowForeward(id, slides) {
    slideshowSet(id, 1, slides);
}

function slideshowBack(id, slides) {
    slideshowSet(id, -1, slides);
}


/**********  swfobject.js *********/



/**********  video-player.js *********/

function embedVideoPlayer (target, options, teaserPlayer) {
    var controllerHeight = 38;
    var flash = Plugin.getInfo("Flash");
    if (flash.isInstalled && parseInt(flash.version) >= 9) {
        if (!teaserPlayer) {
            var playerUrl = contextPath + "/static/swf/video-player.swf";
        } else {
            var playerUrl = contextPath + "/static/swf/sidebar-video-player.swf";
        }
        var videoUrl = options.videoUrl;
        var thumbUrl = options.thumbUrl;
        var width = options.width;
        var height = options.height + controllerHeight;
        var bgcolor="#AFAFAF";
        
        var flashOptions = {
            src: playerUrl, 
            width: width, 
            height: height, 
            bgcolor: bgcolor, 
            allowFullScreen: true,
            FlashVars: "videoUrl=" + videoUrl + "&a=1&previewUrl=" + thumbUrl
        };
        
        Plugin.embed("Flash", flashOptions, target);

    } else {
        //no flash plug-in
    }
    
}


function embedTeaserVideoPlayer (target, options) {
     var controllerHeight = 22;
	 var videoUrl = options.videoUrl;
	 var thumbUrl = options.thumbUrl;
	 var width = options.width;
	 var height = options.height + controllerHeight;
	 var so = new SWFObject(contextPath + "/static/swf/sidebar-video-player.swf", "teaser_video_player", width, height, "9.0.28.0");
	
	so.addParam("quality", "high");
	so.addParam("wmode", "window");
	so.addParam("devicefont", "false");
	so.addParam("menu", "false");
	so.addParam("allowFullScreen", "true");
	so.addParam("allowScriptAccess", "sameDomain");
	//FlashVars
	so.addVariable("videoUrl",videoUrl);
	so.addVariable("previewUrl", thumbUrl);
	so.addVariable("autoLoad", "true");
	
	so.useExpressInstall(contextPath + "/static/swf/expressinstall.swf");
	
	so.write(target);
}

function selectVideo(myAnchorNode) {
    
    var anchorNodeList = myAnchorNode.parentNode.getElementsByTagName('a');
    var displayNodeList = myAnchorNode.parentNode.getElementsByTagName('span');
    var anchorNodes = $A(anchorNodeList);
    var displayNodes = $A(displayNodeList);
    
    anchorNodes.each(
        function(anchorNode){
            if (anchorNode == myAnchorNode) {
                options = Object.extend(
                    options, {
                        videoUrl: anchorNode.getAttribute('we:videoUrl')
                    });
                    
                embedVideoPlayer($("video-"+anchorNode.getAttribute('we:videoId')), options);
                
                var myDisplayNode = anchorNode.firstChild;
                
                displayNodes.each(
                    function(displayNode) {
                        if (displayNode == myDisplayNode) {
                            displayNode.className = 'selected';
                        } else {
                            displayNode.className = 'default';
                        }
                    }
                )
            }
        }
    );
}

