/* UNCE http://paulirish.com/2009/avoiding-the-fouc-v3/ */
(function (h) {
    h.className = h.className.replace(/\bno-js\b/, 'js')
}(document.documentElement))

/* Use Object Detection to detect IE6 */
var ie6 = document.uniqueID      /*IE*/
       && document.compatMode    /*>=IE6*/ 
       && !window.XMLHttpRequest /*<=IE6*/
       && document.execCommand;
try {
  if(!!ie6) {
    ie6("BackgroundImageCache", false, true) /* = IE6 only */
  }
} catch(e) {};

// First active history item: Default text
var activeHistoryItem = 'history-default';
// Active item in continent list
var activeContinent = null;
var activeContinentHotspot = null;
if (loginGuid == "") {
    // Load ULI on every page
    window.onload = function() { showLine() };
}
/**
 * IE save function to get all nodes with a given name
 *
 * @param name, String, value of the name attribute to be found
 * @param tagName, String, tagName of the used element
 *
 * @return Array, found elements
 *
 */
function getElementsByName(name, tagName)
{
  var a = new Array();
  for(i = 0; i < document.getElementsByTagName(tagName).length; i++)
  {
    if(document.getElementsByTagName(tagName)[i].getAttribute('name') == name)
      a.push(document.getElementsByTagName(tagName)[i]);
  }
  return a;
}
function openPrintView(fileName)
{
  window.open(fileName,'Printview');
}
function openPrintDialog()
{
  window.print();
}
/**
 * toggles visibility of metaNavigation elements, also changes headline to
 * display an open/close arrow
 *
 * @param index, int, # of the element to toggle
 * @param name, String, name attribute value of all elements to toggle
 * @param tag, String, tagName of all elements to toggle
 * @param classOpen, String, name of the class for open state
 * @param classClosed, String, name of the class for closed state
 *
 */
function toggle(index, name, tag, classOpen, classClosed)
{
  var elements = getElementsByName(name,tag);
  if(elements[index].className == classClosed)
  {
    //close all elements of given type
    for(var i=0; i<elements.length; i++)
    {
        elements[i].className = classClosed;
    }
    //open the selected element
    elements[index].className = classOpen;
  } else {
    //close only the selected element
    elements[index].className = classClosed;
  }
  
if(loginGuid == "") {
  saveSetting(name,index);
} 
  return false;
}
/**
 * Returns the value of a GET parameter
 * Example: bar = getUrlParameter('foo')
 *
 * @author  http://www.netlobo.com
 */
function getUrlParameter(name)
{
  var regexS  = "[\\?&]"+name+"=([^&#]*)";
  var regex   = new RegExp( regexS );
  var tmpURL  = (arguments.length == 2) ? arguments[1] : window.location.href;
  var results = regex.exec( tmpURL );
  return (results == null) ? '' : results[1];
}
/**
 * Open a URL in a PopUp Window
 *
 * @author Markus Küfner
 */
function openWindow(url, width, height, windowName)
{
   w = window.open(url, windowName, "width="+width+",height="+height+",status=no,scrollbars=no,resizable=yes");
   w.focus();
}

/**
 * Attaches the name of the active continent to the 'Back to Overview' link
 *
 * @param  activeContinent  Name of the currently active continent DIV
 */
function setBackLink(activeContinent)
{
  if (document.getElementById('back2OverviewBarTop') == null) return;
  var backLink = document.getElementById('back2OverviewBarTop').href;
  if (getUrlParameter('continent', backLink) != null)
  {
    backLink = backLink.replace(/continent=([^&#]*)/, 'continent=' + activeContinent);
  } else {
    backLink += (backLink.lastIndexOf('?') == -1) ? '?' : '&amp;';
    backLink += 'continent=' + activeContinent;
  }
}       

/**
 * Toggles visibility for address overview
 *
 * @param  continentId  Id of the DIV to be toggled
 */
function showContinent(continentId, continentHotspot)
{
  if (activeContinent != null) document.getElementById(activeContinent).style.display = 'none';
  if (activeContinentHotspot != null) activeContinentHotspot.className = '';
  document.getElementById(continentId).style.display = 'block';
  continentHotspot.className = 'activeHotspot';
  // setBackLink(continentId);
  activeContinent = continentId;
  activeContinentHotspot = continentHotspot;
}

/**
 * Shows a history page item and hides any previously visible history item
 * 
 * @param itemId  Id of the history item container (e.g. history1)
 */   
function showHistoryItem(itemId)
{
  if (document.getElementById(itemId))
  {
    // hide current history item if item is set
    if (activeHistoryItem != null)
    {
      if (document.getElementById(activeHistoryItem)) document.getElementById(activeHistoryItem).display = 'none';
    }
    // show new history item
    document.getElementById(itemId).display = 'block';
    activeHistoryItem = itemId;
  }
}
/**
 * Jumps to an url passed though a dropdown
 *
 * Example: <select onchange="jumpToDropdownLink(this)">
 * @param dropdownItem  referrer to the select-object
 */
function jumpToDropdownLink(dropdownItem)
{
  var url = dropdownItem.options[dropdownItem.options.selectedIndex].value;
  if (url != '#' && url != undefined) window.location.href = url;
}
/**
 * Set the form action url to an url passed though a dropdown
 *
 * Example: <select onchange="changeFormActionToDropdownLink(this)">
 * @param dropdownItem  referrer to the select-object
 */
function changeFormActionToDropdownLink(dropdownItem)
{
  var url = dropdownItem.options[dropdownItem.options.selectedIndex].value;
  if (url != '#' && url != undefined)
  {
    dropdownItem.form.action = url;
  }
}

/**
 * PROTOTYPE: Removes white spaces at the beginnning and end of a string
 */
String.prototype.trim = function () {
  return (this.replace(/\s+$/,"").replace(/^\s+/,""));
};
    
/**
 * PROTOTYPE: Removes duplicates in an array
 */
Array.prototype.unique = function()
{
  for (var i = 0; i < this.length; i++)
  {
    for (var j = (i + 1); j <= this.length; j++) if (this[i] === this[j]) this.splice(j, 1);
  }
};

/**
 * Extracts filter categories from a string
 * i.e. REDDOT_PAGE_GUID.category1.subcategory1;REDDOT_PAGE_GUID.category1.subcategory2; ...
 *
 * @param  categoryString      string containing category information
 * @return array               category names
 */  
function getCategories(categoryString) 
{
  categoryString = categoryString.trim();
  
  // Replace multiple occasions of divider chars (just to be sure)
  categoryString.replace(/;+/g, ';');
  categoryString.replace(/\.+/g, '.');
  
  categoryString = categoryString.slice(0, categoryString.length-1);
  var tmpCategoryArray = categoryString.split(';');
  var categoryArray = new Array();
    
  for (var i=0; i<tmpCategoryArray.length; i++)
  {
    var tmpSubcategoryArray = tmpCategoryArray[i].split('.');
        
    // Ignore the first part of the string, it's the RedDot page GUID.            
    if (tmpSubcategoryArray.length > 1) categoryArray.push(tmpSubcategoryArray[1]);
  }
  categoryArray.sort();
  categoryArray.unique();
  return categoryArray;
}

/**
 * Fills the category dropdown. Only for use in RedDot SmartEdit!
 *
 * @param  dropdownId      Id of the html select-tag to be filled
 * @param  categoryString  String containing the category information
 */
function fillReddotCategoryDropdown(dropdownId, categoryString)
{
  var categories = new Array();
  categories = getCategories(categoryString);
  categories.unique();
  // Only start the filling if select-tag was found
  if (document.getElementById(dropdownId))
  {
    for (var i=0; i<categories.length; i++)
    {
      var newDropdownOption = new Option(categories[i], '', false, false);
      document.getElementById(dropdownId).options[document.getElementById(dropdownId).length] = newDropdownOption;
    }
  }
}

/**
 * Add and remove classnames
 *
 * @author www.hesido.com
 */
function changeClass(elem, addClass, remClass)
{
  if (!elem.className) elem.className = '';
  var clsnm = elem.className;
  if (addClass && !clsnm.match(RegExp("\\b"+addClass+"\\b"))) clsnm = clsnm.replace(/(\S$)/,'$1 ')+addClass;
  if (remClass) clsnm = clsnm.replace(RegExp("(\\s*\\b"+remClass+"\\b(\\s*))*","g"),'$2');
  elem.className=clsnm;
}

/**
 * Returns all elements with a certain class name
 *
 * @param  tagName    Tag names to search (use '*' as wildcard)
 * @param  className  Class name to seach
 * @return Array with elements or NULL
 */
function getElementsByClassName(tagName, className)
{
  var allElements = document.getElementsByTagName(tagName);
  var returnElements = new Array();
  var searchTerm = new RegExp("\\b" + className + "\\b");
    
  for (var i=0; i<allElements.length; i++)
  {
    if (allElements[i].className.match(searchTerm)) returnElements.push(allElements[i]);
  }
    
  return (returnElements.length > 0) ? returnElements : null;
}

/**
 * RBO: this jQuery snippet replaces function initTeaserNavigation
 */
jQuery(document).ready(function($) {
    $('.teaserNavigation th, .teaserNavigation td')
        .bind('mouseenter', function() {
            var $this = $(this);
                
            $this
                .closest('table')
                .find('tr > :nth-child(' + ($this.index() + 1) + ')')
                .addClass('hover');
        })
        .bind('mouseleave', function() {
            $(this)
                .closest('table')
                .find('th, td')
                .removeClass('hover');
        })
});
/**
 * RBO: deprecated, see jQuery snippet just above this function
 * Inits the mouseover effect for teaser navigation elements
 */
/*function initTeaserNavigation()
{
  var teaserNav = getElementsByClassName('td', 'teaserText');
  if (teaserNav != null)
  {
    for (var i=0; i<teaserNav.length; i++)
    {
      teaserNav[i].onmouseover = function () { 
    //  changeClass(this, 'teaserTextHover', 'teaserText'); alert(this.className); return false;  
            switch (this.className) {
              case "teaserText textLeft":
                this.className ="teaserText teaserTextLeftHover";
                break;
              case "teaserText textRight":
                this.className = 'teaserText teaserTextRightHover';
                break;
              case "teaserText text":
                this.className = 'teaserText teaserTextHover';
                break;
            }
      }
      teaserNav[i].onmouseout  = function () {
    // changeClass(this, 'teaserText', 'teaserTextHover'); return false;
            switch (this.className) {
              case "teaserText teaserTextLeftHover":
                this.className ="teaserText textLeft";
                break;
              case "teaserText teaserTextRightHover":
                this.className = 'teaserText textRight';
                break;
              case "teaserText teaserTextHover":
                this.className = 'teaserText text';
                break;
            }
      }
   }
}
}*/
/**
 * Removes href attribute from empty 72dpi/300dpi image links
 *
 * @param  imageLink  a-tag of the image link
 */
function removeEmptyImageLink(imageLink)
{
  if (imageLink.href && imageLink.href.lastIndexOf('/') == imageLink.href.length-1) imageLink.removeAttribute('href');
}

/**
 * Returns all elements with a certain class name
 *
 * @param  className  Class name to seach
 * @param  tagName    Tag names to search (use '*' as wildcard)
 * @return Array with elements or NULL
 */
document.getElementsByClassName = function (className, tagName)
{
  var allElements = document.getElementsByTagName(tagName);
  var returnElements = new Array();
  var searchTerm = new RegExp("\\b" + className + "\\b");
    
  for (var i=0; i<allElements.length; i++)
  {
    if (allElements[i].className.match(searchTerm)) returnElements.push(allElements[i]);
  }
    
  return (returnElements.length > 0) ? returnElements : null;
}

/**
 * Displays the ULI between the top level navigation and subnavigation
 */
/**
 * RBO: this jQuery snippet replaces function showLine
 */
jQuery(document).ready(function($) {
    var $activeMainItem = $('#mainNavigation li.active'),
        $leftItem = $('#leftNavigation h1');
    if ($activeMainItem.length && $leftItem.length) {
        _naviLineTop = $activeMainItem.position().top + $activeMainItem.height();
        $('<div/>')
            .attr('id', 'navigationLine')
            .css({
                'top': _naviLineTop,
                'height': $leftItem.position().top - _naviLineTop
            })
            .prependTo($('#navigation'));
    }
    // GECA Navigation Bottom Line correction
    $('#leftNavigation h3:last-child,#leftNavigation h4:last-child').css('border-bottom','1px solid #D8DEE4');
    // GECA Hybirs Navigation Highlight correction
    $('#leftNavigation h5.active').prevAll('h4.active').removeClass('active').find('a').addClass('active hasChildren');    
    $('#leftNavigation h4.active').prevAll('h3.active').removeClass('active').find('a').addClass('active hasChildren');  
    $('#leftNavigation h3.active').prevAll('h2.active').removeClass('active').find('a').addClass('active hasChildren'); 
    // GECA Hybirs Navigation Highlight correction
    $('#leftNavigation h2').each(function(index) {
        if($(this).next('h3').size() == 0) $(this).find('a').removeClass('hasChildren');    
        if($(this).next('h3').size() == 1) $(this).find('a').addClass('active hasChildren');
    });
    $('#leftNavigation h3').each(function(index) {
        if($(this).next('h4').size() == 0) $(this).find('a').removeClass('hasChildren');    
        if($(this).next('h4').size() == 1) $(this).find('a').addClass('active hasChildren')
    });
    $('#leftNavigation h4').each(function(index) {
        if($(this).next('h5').size() == 0) $(this).find('a').removeClass('hasChildren');    
        if($(this).next('h5').size() == 1) $(this).find('a').addClass('active hasChildren')
    }); 
    $('#leftNavigation h5').each(function(index) {
        if($(this).next('h6').size() == 0) $(this).find('a').removeClass('hasChildren');    
        if($(this).next('h6').size() == 1) $(this).find('a').addClass('active hasChildren')
    });  
});
/**
 * RBO: deprecated, see jQuery snippet just above this function
 */
function showLine()
{
  return;
  
  var header = document.getElementById("header");
  var mainNav = document.getElementById("mainNavigation");
  var leftNav = document.getElementById("leftNavigation");
  // Exit if the left navigation is empty
  if (leftNav.getElementsByTagName("a").length == 0) return false;
  // Calculate the height of the upper part
  try
  {
    for(i = 0; (mainNav.getElementsByTagName("li")[i].className != "active") && (i < mainNav.getElementsByTagName("li").length);i++) {}
  } catch(e) {
    return false;
  }
  var curNav = mainNav.getElementsByTagName("li")[i];
  var topLineHeight = header.offsetHeight - curNav.parentNode.offsetTop - curNav.offsetTop - (curNav.offsetHeight/2);
  var topLine = document.createElement("div");
  topLine.id = 'navigationLine';
  topLine.style.height = topLineHeight + 'px'; //document.getElementById("header").clientHeight;
  header.appendChild(topLine);
  // Create the upper part
  var bottomLine = document.createElement("div");
  bottomLine.id = 'navigationLineBottom';
  bottomLine.style.top = header.offsetHeight + 'px';
  // Create the lower part
  var leftNavHeadline = leftNav.getElementsByTagName("h1")[0];
  bottomLineHeight = leftNav.offsetTop - header.offsetHeight + (leftNavHeadline.offsetHeight/2);
  bottomLine.style.height = bottomLineHeight + 'px'; //document.getElementById("header").clientHeight;
  document.body.appendChild(bottomLine);
}
  

/**
 * if #metaNavigation > 609px set a min-height to #mainContainer (no ie6 support)
 * @author UNCE
 */
function syncingHeight(){ 
    var heightMetaNavigation = $('#metaNavigation').outerHeight(true);
    if( heightMetaNavigation > 609) {    
        $('#mainContainer').css('min-height',heightMetaNavigation);  
    }
}
$(window).load(function(){
    syncingHeight(); 
});
  
/* UNCE */
jQuery(document).ready(function($) {
    
    /* table add class odd even  */
    $('div.texteditortable table').attr({
      cellspacing: '0',
      cellpadding: '0',
      border: '0'
    });
      
    /* WPC Paging change font-size  */
    $('div.n *').css('font-size','12px');    
   
});

  
/**
 * Inits the selection information for the country selection in Form Editor
 * @author  EuKr
 */
function showInformation(infoId, countryDescription, selectedEntry) {
  document.getElementById(infoId).style.display = (countryDescription == selectedEntry) ? 'block' : 'none';
}

/**
 * Fill dropdowns of FastTrack Navigation with content of hidden DIVs
 */
function fillFasttrackDropdowns() {
  var linkArrayProduct = document.getElementById("LinkArrayProduct");
  var dropdownProduct  = document.getElementById("ProductBrandDropdown");    
  if (linkArrayProduct && dropdownProduct) 
  {
    for (var i=0; i < linkArrayProduct.childNodes.length; i++)
    {
      dropdownProduct.options[i+1] = new Option(linkArrayProduct.childNodes[i].innerHTML.replace(/&amp;/g, "&"), linkArrayProduct.childNodes[i].getAttribute('href'), false, false);
    }
    dropdownProduct.selectedIndex = 0;
  }    
    
  var linkArrayTopic = document.getElementById("LinkArrayTopic");
  var dropdownTopic  = document.getElementById("TopicDropdown");  
  if (linkArrayTopic && dropdownTopic)
  {
    for (var i=0; i < linkArrayTopic.childNodes.length; i++)
    {
      dropdownTopic.options[i+1] = new Option(linkArrayTopic.childNodes[i].innerHTML, linkArrayTopic.childNodes[i].getAttribute('href'), false, false);
    }
    dropdownTopic.selectedIndex = 0;
  }
  var linkArrayWebsiteSelector = document.getElementById("LinkArrayWebsiteSelector");
  var dropdownWebsiteSelector  = document.getElementById("WebsiteSelectorDropdown");    
  if (linkArrayWebsiteSelector && dropdownWebsiteSelector) 
  {
    for (var i=0; i < linkArrayWebsiteSelector.childNodes.length; i++)
    {
      dropdownWebsiteSelector.options[i+1] = new Option(linkArrayWebsiteSelector.childNodes[i].innerHTML, linkArrayWebsiteSelector.childNodes[i].getAttribute('href'), false, false);
    }
    dropdownWebsiteSelector.selectedIndex = 0;
  }
}
 
/**
 * eTracker WPC Implementation
 * @author  GeCa
 */
function removeMultipleSpacesAndTrim(str) {
    return str.replace(/\s+/g, " ").replace (/^\s+/, '').replace (/\s+$/, '');
}
var WPC_Information = false;
function edorasGetWebsitemainContent()
{
    var mainContent = "";
    try {
      mainContent = $("#mainContent h1:first").text();
      mainContent = "_Hybris_" + removeMultipleSpacesAndTrim(mainContent);
    } catch(e) { }
    return mainContent;
}
/*
 * VideoPlayer 
 * @author MaRi
 */        
$.buildPlayer = function(options) {
    //#### Variablen
    this.set = jQuery.extend({
            id:"videoplayerli",
            height: 226,
            width: 367,
            allowfullscreen: "true",
            allowscriptaccess: "always",
            file: "",
            player: '/lvl/content_data/player.swf'
    }, options);
    this.object = $("#"+this.set.id);
    this.fallbackcontent = this.object.html();
    
    //Create the Player in Container
    this.createPlayer = function() {
        var player = new SWFObject(this.set.player,'ply'+this.set.id,this.set.width,this.set.height,'9');
        player.addParam('allowfullscreen',this.set.allowfullscreen);
        player.addParam('allowscriptaccess',this.set.allowscriptaccess);
        player.addParam('flashvars','file='+this.set.file);
        player.write(this.set.id);
    };
    
    //Remove any Player in Container
    this.removePlayer = function() {
        if(this.object != null) {
            this.object.empty();
            this.object.append(this.fallbackcontent);
        }
    };
    //Clear Container
    this.removePlayer();
    //Create Player
    this.createPlayer();
};
 
/* PHMU temporary industrial popup */
function openindustrialpopup(url) {
 fenster = window.open(url, "fenster1", "width=450,height=400,status=yes,scrollbars=yes,resizable=yes");
 fenster.focus();
}
 
/**
 * @projectDescription
 * 
 * jCookie provides an convenient api for CRUD-related cookie handling.
 * 
 * @example:
 *  Create,update:
 *  jQuery.jCookie('cookie','value');
 *  Delete:
 *  jQuery.jCookie('cookie',null);
 *  Read:
 *  jQuery.jCookie('cookie');
 * 
 * Copyright (c) 2008-2010 Martin Krause (jquery.public.mkrause.info)
 * Dual licensed under the MIT and GPL licenses.
 *
 * @author Martin Krause public@mkrause.info
 * @copyright Martin Krause (jquery.public.mkrause.info)
 * @license MIT http://www.opensource.org/licenses/mit-license.php
 * @license GNU http://www.gnu.org/licenses/gpl-3.0.html
 * 
 */
// start plugin closure
/**
 * 
 * @param {String} sCookieName_, the cookie name
 * @param {Object} [oValue_], the cokie value
 * @param {String, Number} [oExpires_], the expire date as string ('session') or number 
 * @param {Object} [oOptions_], additionale cookie options { path: {String}, domain: {String}, secure {Bool} } 
 */
jQuery.jCookie = function(sCookieName_, oValue_, oExpires_, oOptions_) {
    
    // cookies disabled
    if (!navigator.cookieEnabled) { return false; }
    
    // enfoce params, even if just an object has been passed
    var oOptions_ = oOptions_ || {};
    if (typeof(arguments[0]) !== 'string' && arguments.length === 1) {
        oOptions_ = arguments[0];
        sCookieName_ = oOptions_.name;
        oValue_ = oOptions_.value;
        oExpires_ = oOptions_.expires;
    }
    
    // escape characters
    sCookieName_ = encodeURI(sCookieName_);
    
    // basic error handling 
    if (oValue_ && (typeof(oValue_) !== 'number' && typeof(oValue_) !== 'string' && oValue_ !== null)) { return false; }
    
    // force values 
    var _sPath = oOptions_.path ? "; path=" + oOptions_.path : "";
    var _sDomain = oOptions_.domain ? "; domain=" + oOptions_.domain : "";
    var _sSecure = oOptions_.secure ? "; secure" : "";
    var sExpires_ = "";
    
    // write ('n delete ) cookie even in case the value === null 
    if (oValue_ || (oValue_ === null && arguments.length == 2)) {
    
        // set preceding expire date in case: expires === null, or the arguments have been (STRING,NULL)  
        oExpires_ = (oExpires_ === null || (oValue_ === null && arguments.length == 2)) ? -1 : oExpires_;
        
        // calculate date in case it's no session cookie (expires missing or expires equals 'session' )
        if (typeof(oExpires_) === 'number' && oExpires_ != 'session' && oExpires_ !== undefined) {
            var _date = new Date();
            _date.setTime(_date.getTime() + (oExpires_ * 24 * 60 * 60 * 1000));
            sExpires_ = ["; expires=", _date.toGMTString()].join("");
        }
        // write cookie
        document.cookie = [sCookieName_, "=", encodeURI(oValue_), sExpires_, _sDomain, _sPath, _sSecure].join("");
        
        return true;
    }
    
    // read cookie 
    if (!oValue_ && typeof(arguments[0]) === 'string' && arguments.length == 1 && document.cookie && document.cookie.length) {
        // get the single cookies 
        var _aCookies = document.cookie.split(';');
        var _iLenght = _aCookies.length;
        // parse cookies
        while (_iLenght--) {
            var _aCurrrent = _aCookies[_iLenght].split("=");
            // find the requested one 
            if (jQuery.trim(_aCurrrent[0]) === sCookieName_) { return decodeURI(_aCurrrent[1]); }
        }
    }
    
    return false;
};
/**
GECA Needed Vertical Align for Fishnet Logo 
**/
(function ($) {
$.fn.vAlign = function() {
    return this.each(function(i){
    var ah = $(this).height();
    var ph = $(this).parent().height();
    var mh = (ph - ah) / 2;
    $(this).css('margin-top', mh);
    });
};
})(jQuery);
jQuery(document).ready(function($) {
 $('.fishnetLogo img').vAlign();
});



/**
* Download Center 
 */   
 
/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie = function (key, value, options) {
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);
        if (value === null || value === undefined) {
            options.expires = -1;
        }
        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        value = String(value);
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }
    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
/**
* Download Center 
*/
    var downloadCockieA = 'HenkelDownloadFolderIdLVL';
    var downloadCockieB = 'HenkelDownloadFolderSizeLVL';
    var henkelDownloadCartDomain = "http://" + window.location.hostname;
    
    function getSession()
    {
        if ($.cookie(downloadCockieA) == null)
        {
            var sessionid = '';
            var now = new Date();
            year = now.getFullYear();
            day = now.getDate(); if(day < 10) day = '0' + day;
            month = now.getMonth(); if((month+1) < 10) month = '0' + (month + 1);
            if($.cookie('session-id') != null)
            {
            sessionid = $.cookie('session-id').slice(13,23) + '-' + year + month + day;
            $.cookie(downloadCockieA, sessionid, { expires: 1, path: '/',domain: document.domain }); 
            }
        } else {
            sessionid = $.cookie(downloadCockieA);
        }
        //console.log(sessionid);
        return sessionid;
    }  
    /*createHenkelCartSaveLink*/
    function createHenkelCartSaveLink(data, href) {
        data.href = henkelDownloadCartDomain + "/cps/rde/WebletController?operation=download&sessionid=" + getSession() + "&href=" + href;
        return true;
    }
    /*createHenkelCartDeleteLink*/
    function createHenkelCartDeleteLink(data, href, title) {        
        $.ajax({
                url: henkelDownloadCartDomain + "/cps/rde/WebletController?operation=delete&sessionid=" + getSession() + "&href=" + href,
                async:false,
                success: function() {
                    var uncheckItems = $("table.downloadCenterList tbody tr input[type='checkbox']:not(:checked)").length;
                    
                    $(data).parent().parent().remove();                
                    
                    $('div.downloadCenterContent div.error').css('visibility','hidden');
                    if(uncheckItems == 0) {
                       $('input#downloadCenterListSelectAll').attr('checked', false); 
                   }
                
                   $.cookie(downloadCockieB, null, { expires: 1, path: '/',domain: document.domain });
                     
                    var itemslength = $("table.downloadCenterList tbody tr.active").length;
                    console.log(itemslength);
                    if (itemslength == 0) {
                        $.cookie(downloadCockieA, null, { expires: 1, path: '/',domain: document.domain });
                        setBasketSizeToZero();
                    } else {
                        getSize();
                    }
                                
                }          
        }); 
        return false;
    }
    
    function readdb() {
        $.ajax({
        url: henkelDownloadCartDomain + "/cps/rde/WebletController?operation=readdb&sessionid="+ getSession(),
        async:false,
            success: function(data) {
                //alert('readdb: ' + data);
                data = unescape(data);
                $('#henkelDownloadCenterResultOutput').html(data);                               
            }            
        });       
    }        
    function getSize() {                              
        if ($.cookie(downloadCockieB) == null)
        {                             
            $.ajax({
            url: henkelDownloadCartDomain + "/cps/rde/WebletController?operation=getSize&sessionid=" + getSession(),
            async:false,
            success: function(data) {
                $('#basketCounter').remove();
                $('a.sbasket').append('<span id="basketCounter">(' + data + ')</span>');
                $('html[dir=rtl] a.sbasket').prepend('<span id="basketCounter">(' + data + ')&nbsp;</span>');                                                                                                                  
                $('#basketCounter').show();     
                $.cookie(downloadCockieB, escape(data), { expires: 1, path: '/',domain: document.domain });                  
            }                            
            });  
        } else {
            data = unescape($.cookie(downloadCockieB)); 
            $('#basketCounter').remove();
            $('a.sbasket').append('<span id="basketCounter">(' + data + ')</span>');
            $('html[dir=rtl] a.sbasket').prepend('<span id="basketCounter">(' + data + ')&nbsp;</span>');                                                                                                                  
            $('#basketCounter').show();              
       }              
    }        
            
    function clearBasket() {
        $('#henkelDownloadCenterResultOutput').html('');
    }        
    function setBasketSizeToZero() {                              
        $('#basketCounter').remove();
        $('a.sbasket').append('<span id="basketCounter">(0)</span>');
        $('html[dir=rtl] a.sbasket').prepend('<span id="basketCounter">(0)&nbsp;</span>');                                   
        $('#basketCounter').show();              
    }
    
    function getFileName(url) {
        url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#"));
        url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?"));
        url = url.substring(url.lastIndexOf("/") + 1, url.length);
        return url;
    }
    $(document).ready(function(){
    
        IE7 = (navigator.appVersion.indexOf('MSIE 7.')==-1) ? false : true;        
        if(!window.console) {  
            window.console = {  
                log : function(str) {  
                  
                }  
            }; 
        }
        
        if ($.cookie(downloadCockieA) == null)
        {
            // Cockie NOT SET            
        } else {
            // Cockie SET         
            getSize();     
            readdb();
        }
       $('#basketCounter').css('display','inline');
        
    /*Layer*/
        /*Colorbox settings + Layer add class downloadCenter */
        $('a.downloadCenterMenuBasketShow,a.sbasket').colorbox({scrolling:false, slideshow:false, inline:true, href:"div#downloadCenterLayer"});

        $('a.downloadCenterMenuBasketShow,a.sbasket').click(function(){ 
            $('table.downloadCenterList tbody tr.active td').css('background-color','#ebeef1');
            $('div.downloadCenterContent div.error').css('visibility','hidden');
            $('div#cboxContent').addClass('downloadCenter');

            /*Hide colorbox title*/
            $('div#cboxContent.downloadCenter #cboxTitle').remove();
        });

        /*Cut long filenames*/            
        $(document).bind({
          cbox_complete: function() {    
            var maxwidth = $('.downloadCenterList col:eq(2)').attr('width');  
            $('#henkelDownloadCenterResultOutput h2').each(function (index) {
                $(this).css('display','inline').after('<br />');                
                var itemwidth = $(this).width();
                var maxchar = 50;
                if (itemwidth > maxwidth) {        
                    $(this).text($(this).text().substring(0, maxchar-4));
                    $(this).html($(this).html() + ' ...');
                }
            });
          },
          cbox_closed: function() {
            $('#henkelDownloadCenterResultOutput br').remove();    
          }
        });  
                   
    /*Download List*/
        /*Change title from save and delete icon*/
        var downloadCenterIconSave = "Save";
        var downloadCenterIconDelete = "Delete";    
        $("a.downloadCenterIcon.save", this).live("hover", function(){
             $(this).attr('title', downloadCenterIconSave);
        });
        $("a.downloadCenterIcon.delete", this).live("hover", function(){
             $(this).attr('title', downloadCenterIconDelete);
        });
        /*Uncheck+check checkboxes*/    
        $('input#downloadCenterListSelectAll').live('click', function() {
            $('table.downloadCenterList tbody tr.active td').css('background-color','#ebeef1');
            $('div.downloadCenterContent div.error').css('visibility','hidden');
            $("table.downloadCenterList tbody tr input[type='checkbox']").attr('checked', $('input#downloadCenterListSelectAll').is(':checked'));
             
        });    
            $("table.downloadCenterList tbody tr input[type='checkbox'],a.downloadCenterMenuBasketShow,a.sbasket").live('click', function() {
            $('table.downloadCenterList tbody tr.active td').css('background-color','#ebeef1');
            $('div.downloadCenterContent div.error').css('visibility','hidden');
            var uncheckItems = $("table.downloadCenterList tbody tr input[type='checkbox']:not(:checked)").length;
            if(uncheckItems > 0){
                $('input#downloadCenterListSelectAll').attr('checked', false); 
            }
        });          
      
        $('form.downloadCenterList #DownloadCenterdeleteAllButton').live('click', function() {
            $.get(henkelDownloadCartDomain + "/cps/rde/WebletController?operation=delete&sessionid="+ getSession()); 
            $('table.downloadCenterList tbody tr').removeClass('active').hide();
            $('input#downloadCenterListSelectAll').attr('checked', false);                
            $('div.downloadCenterContent div.error').css('visibility','hidden');
            var uncheckItems = $("table.downloadCenterList tbody tr input[type='checkbox']:not(:checked)").length;
            $(this).colorbox.resize({width: "650px",height: "353px"});
            $.cookie(downloadCockieA, null, { expires: 1, path: '/',domain: document.domain });
            $.cookie(downloadCockieB, null, { expires: 1, path: '/',domain: document.domain });
            clearBasket(); setBasketSizeToZero();  
        });    
        
        /*List of the hrefs for download zip*/
        $('form.downloadCenterList #zipButton').live('click', function() {
            var arraydownloadCenterList = [];
            $('form.downloadCenterList').append('<div id="downloadCenterDataHrefs"></div>');
            $('table.downloadCenterList tbody tr.active input').each(function(index) {
                if($('table.downloadCenterList tbody tr.active input:eq('+index+')').attr("checked") == true) {
                    var downloadCenterDataHrefs = $(this).val();    
                    arraydownloadCenterList.push(downloadCenterDataHrefs);
                    $("div#downloadCenterDataHrefs").text(arraydownloadCenterList.join(","));
                }
            });    
            var downloadCenterDataListHrefs = $("div#downloadCenterDataHrefs").html();
            $('div#downloadCenterDataHrefs').remove();
            
            //alert("Download ZIP: " +downloadCenterDataListHrefs);
            
            var henkelCartZipSelectedItems = "";
            var henkelCartZipSelectedItemsError = "";
            
            if(downloadCenterDataListHrefs==""){
                $('div.downloadCenterContent div.error').html('<p>Lūdzu, atzīmējiet vismaz vienu failu</p>');
                $('table.downloadCenterList tbody tr.active td').css('background-color','#ffdddd');
                $('div.downloadCenterContent div.error').css('visibility','visible');
                $(this).attr('href', '#'); 
            }        
            else { 
                if(downloadCenterDataListHrefs.length < 2000)
                {                                                             
                    $.ajax({
                        type: "GET",
                        url: henkelDownloadCartDomain + "/cps/rde/WebletController?operation=checkFileSize&sessionid="+ getSession() +"&hrefList="+downloadCenterDataListHrefs,
                        async:false,
                        success: function(data){
                            if (data == "Maximum entry size of 250MB exceeded!") {
                               $('div.downloadCenterContent div.error').html('<p>Maksimālais izmērs 250 MB pārsniedza [Error Code #2]</p>');
                               $('div.downloadCenterContent div.error').css('visibility','visible');
                               henkelCartZipSelectedItemsError = "error";
                               return false;
                            } 
                            else {
                                $(this).attr('href', "#");
                                henkelCartZipSelectedItems = data;
                            }
                         }                    
                    });
                    $(this).attr('href', "#");
                    if (henkelCartZipSelectedItems == "success" && henkelCartZipSelectedItemsError != 'error') {
                       window.location = henkelDownloadCartDomain + "/cps/rde/WebletController?operation=zip&sessionid="+ getSession() +"&hrefList="+downloadCenterDataListHrefs;            
                    }
                } else {
                    $('div.downloadCenterContent div.error').html('<p>Maksimālais izmērs 250 MB pārsniedza [Error Code #2]</p>');
                    $('div.downloadCenterContent div.error').css('visibility','visible');
                    henkelCartZipSelectedItemsError = "error";
                }
            }
        });
        
        /*DownloadCenterMenu*/          
        /*Open downloadCenterMenu*/        
        $('.downloadCenterLink').hover(
            function () {
                
                if (IE7) {
                downloadCenterLinkHeight = Math.round($(this).height())-5;
                } else {
                downloadCenterLinkHeight = Math.round($(this).height());
                }
                  
                //alert("downloadCenterLinkHeight: " +downloadCenterLinkHeight);
                MenuTop = Math.round($(this).offset().top);
                MenuHeight = Math.round($(this).children('div.downloadCenterMenu').height());
                ScrollTop = Math.round($(window).scrollTop());
                WindowHeight = Math.round($(window).height());
                //console.log('Menu Top ' + MenuTop);
                //console.log('Menu Height ' + MenuHeight);
                //console.log('Menu Max Height ' + (MenuHeight + MenuTop) );
                WindowHeight = (WindowHeight + ScrollTop - downloadCenterLinkHeight);
                //console.log('ScrollTop ' + ScrollTop);
                //console.log('WindowHeight ' + WindowHeight);
                //console.log("CSS TOP " +$(this).children('div.downloadCenterMenu').css('top'));
                if( (MenuTop + MenuHeight) > WindowHeight )
                {                
                    $(this).children('div.downloadCenterMenu').css('top','-'+MenuHeight +'px');
                } else {
                    $(this).children('div.downloadCenterMenu').css('top',+downloadCenterLinkHeight+'px');
                }
                $('.downloadCenterLink div.downloadCenterMenu').hide();
                // Bad for orginal Links DE3 $('.downloadCenterLink a.downloadLanguage').removeAttr('href').removeAttr('target');
                $(this).css('z-index','1001');
                $(this).children('div.downloadCenterMenu').css('z-index','1000').show();
            },
            function () {
                $(this).css('z-index','0');
                $(this).children('div.downloadCenterMenu').css('top',+downloadCenterLinkHeight+'px');
                $(this).children('div.downloadCenterMenu').css('z-index','0').hide();
            }
        );
        
        /*Add download to basket / downloadCenterMenuBasketIn*/
        $('li a.downloadCenterMenuBasketIn').live('click', function() {  
            $('div.downloadCenterMenu').hide();
            var downloadCenterDataTitle = $(this).parent().parent().find('li.downloadCenterDataTitle').text();
            // LYAT: encoding fix
            downloadCenterDataTitle = encodeURIComponent(escape(downloadCenterDataTitle));
            var downloadCenterDataHref = '../mediaweb' + $(this).parent().parent().find('a.downloadCenterMenuOpen').attr('href');        
            //UNCE
            //alert("downloadCenterDataTitle :"+ downloadCenterDataTitle + " # downloadCenterDataHref :"+downloadCenterDataHref);
                            
            $.ajax({
                    url: henkelDownloadCartDomain + "/cps/rde/WebletController?operation=update&sessionid="+ getSession() +"&href="+ downloadCenterDataHref +"&fileName="+downloadCenterDataTitle,
                    success: function(data) {
                        //alert('Add download to basket: ' + data);
                        $('#henkelDownloadCenterResultOutput').html(data);
                        //alert('Load was performed.');
   
                $.cookie(downloadCockieB, null, { expires: 1, path: '/',domain: document.domain });
                        readdb(); getSize();
                    }
                });
            return false;
            
        });    
            
        /*Save download / downloadCenterMenuSave*/
        $('li a.downloadCenterMenuSave').click(function(){  
            var downloadCenterDataHref = '../mediaweb' + $(this).parent().parent().find('a.downloadCenterMenuOpen').attr('href');
            $(this).attr('href',henkelDownloadCartDomain + '/cps/rde/WebletController?operation=download&sessionid='+ getSession() +'&href='+ downloadCenterDataHref);    
        }); 
           
    }); // End of DOM Ready
  


 
/**
* RSS Reader 
* 
* @param {String} template
* @param {String} urlExternal
* @param {Number} maxItems
* @param {String} modeCols
* @param {String} idPage
* @param {Boolean} altContent
* @param {String} linktarget
* @param {String} textMorelink
* @param {Number} limitDescription
* @returns {void}
*/
function rssReader(template, urlExternal, maxItems, modeCols, idPage, altContent, linktarget, textMorelink, limitDescription)
{    
    var urlExternalBase = urlExternal.substring(0, urlExternal.indexOf("/", 8));                                                                                                        
    var markupRSS = "";
    var timeoutLoad = 8000;
    var timeoutExpired = false;
    var timeout;
    var countTeaserItems = 0;
    var maxTeaserItems = maxItems;
    var countCols;
                        
    var countResizeImages = 0;
    var intervalResize = null;
    
    var msgError = "<div style=\"color:#e3000f; font-weight:bold; text-align:center;\">An error occured loading the RSS feed - content.</div>";
    
    var styleWrapTextItem = { "withImage" : "" , "withoutImage" : "teaserListText clearFix" };
    var styleWrapImage = "";
    var sizeImages = 60;
    
    if(urlExternal != "")
    {
        switch(template)
        {    
            case "te6":
                styleWrapTextItem["withImage"] = "teaserListTextwI";
                break;
            case "te1-60":
                styleWrapTextItem["withImage"] = "teaserListTextwI";
                styleWrapImage = "style=\"width:" + sizeImages + "px;\"";
                break;
            case "te1-93":
                styleWrapTextItem["withImage"] = "teaserListTextwithImage";
                sizeImages = 93;
                styleWrapImage = "style=\"width:" + sizeImages + "px;\"";
                break;
            case "mp-teaserlist":
                styleWrapTextItem["withImage"] = "teaserListTextwithImage";
                sizeImages = 93;
                break;
        }
        
        if(modeCols.indexOf("2") != -1)
            countCols = 2;
        else
            countCols = 1;
        
        requestCD(
            urlExternal, 
            function(resultRSS)
            {   
                if(!timeoutExpired)
                {
                    window.clearTimeout(timeout);
                    processResult(resultRSS);
                }
                else
                    handleError("timeout (manual)");
                    
            }
        );
    }
    else
        handleError("no rss-url");
    
    
    /**
     * Feed - Inhalte abfragen
     * 
     * @param {String} url
     * @param {String} callback
     */
    function requestCD(url, callback)
    {
        var yql = "http://query.yahooapis.com/v1/public/yql?q=" + encodeURIComponent("select * from xml where url ='" + url + "'") + "&format=xml&callback=?";
    
        timeout = window.setTimeout(handleTimeout, timeoutLoad);
        $.getJSON(
            yql, 
            function(data)
            {
                if(data.results[0])
                {
                    data = data.results[0];
                    
                    if(typeof callback === "function")
                        callback(data);
                }
                else
                    handleError("Antwort enthält keine Daten");
            }
        );
    }
    
    
    /**
     * Auf Timeout reagieren
     * 
     * @returns {void}
     */ 
    function handleTimeout()
    {
        timeoutExpired = true;
        window.clearTimeout(timeout);
    }
    
    
    /**
     * Ergebnis verarbeiten
     * 
     * @param {String} resultRSS
     * @returns {void}
     */
    function processResult(resultRSS)
    {
        //Title - Tags ersetzen, da diese falsch verarbeitet werden
        resultRSS = resultRSS.replace(/\<link\>/g,"<linkitem>").replace(/\<\/link\>/g,"</linkitem>");
        if(window.DOMParser)
            $result = $(resultRSS);
        else
        {
            var xmlObject = new ActiveXObject( "Microsoft.XMLDOM" );
            xmlObject.async = false;
            xmlObject.loadXML(resultRSS);
            $result = $(xmlObject);
        }
        
        //Antwort auf Fehler überprüfen
        if($result.find("errorFeed").length > 0)
        {
            if($result.find("errorFeed").text() == "noURL")    //Es wurde keine URL für das Feed angegeben
                handleError("feed-url fehlt");
        }
        else
        {
            //XML - Code durchlaufen und Markup - String generieren                                   
            $result.find("item").each(
                function()
                {
                    if(countTeaserItems < maxTeaserItems)
                    {
                        countTeaserItems ++;
                                                                     
                        var $item = $(this);
                        var date = $item.find("pubDate").text();
                        var title = $item.find("title").text();
                        var description = $item.find("description").text();
                        var link = $item.find("linkitem").text(); 
                                                                      
                        //Prüfen, ob Description - Element Image - Tag enthält und ggf. Bild von Rest der Beschreibung trennen
                        var image = "";
                        var imgStart = description.indexOf("<img") != -1;
                        if(imgStart != -1)
                        {
                            var imgEnd = description.indexOf(">");
                                                                          
                            if(imgEnd != -1)
                            {
                                image = description.substr(0, imgEnd + 1);
                                description = description.substr(imgEnd + 1);
                            }
                        }
                                            
                        //Datum aus der Description entfernen, da dieses schon am Anfang ausgegeben wird
                        if(date != "")
                        {
                            description = description.replace(/^\d{2}\.\d{2}\.\d{4} - /, "");
                            description = description.replace(/^\d{2}\/\d{2}\/\d{4} - /, "");
                        }
                        
                        //ggf. Zeichenanzahl des "description" - Textes begrenzen
                        if(limitDescription != false)
                            description = shortenDescription(description, limitDescription);
                        
                        if(countCols == 1)
                            markupRSS += "<div class=\"teaserListNew1Column clearFix\">";    //1 - spaltig
                        else if(countCols == 2)
                        {
                            if(countTeaserItems % 2 == 0)
                                markupRSS += "<div class=\"teaserListRightNew clearFix\">";    //2 - spaltig - rechts
                            else
                                markupRSS += "<div class=\"teaserListNew clearFix\">";    //2 - spaltig - links
                        }
                                                                        
                        if(image != "")
                        {
                            markupRSS += "<div class=\"teaserListImage\" " + styleWrapImage + " >";
                            markupRSS += "<a href=\"" + link + "\" target=\"_" + linktarget + "\">" + image + "</a>";
                            markupRSS += "</div>";
                            markupRSS += "<div class=\"" + styleWrapTextItem["withImage"] + "\">";
                        }
                        else
                            markupRSS += "<div class=\"" + styleWrapTextItem["withoutImage"] + "\">";
                                                           
                            markupRSS += date + "<br />";
                                                        
                            markupRSS += "<a class=\"arrowRedBoldInline\" href=\"" + link + "\" target=\"_" + linktarget + "\">" + title + "</a><br />";
                            markupRSS += description;
                            markupRSS += "<a class=\"underline inline morelinkRSSReader\" href=\"" + link + "\" target=\"_" + linktarget + "\">" + textMorelink + "</a>";                                    
                                                                 
                            markupRSS += "</div></div>";
                            
                            if(countCols == 2 && countTeaserItems % 2 == 0)
                                markupRSS += "<br style=\"clear:both;\" />";
                    }
                    else
                        return false;
                }
            );
                                                      
            $markupRSSObject = $(markupRSS);
                                                      
            //Relative Bilder - URLs anpassen
            $markupRSSObject.find("img").each(
                function()
                {
                    var src = $(this).attr("src");
                    var srcNew = "";
                                        
                    if(src.indexOf("http") != -1)
                    {
                        src = src.replace(/http\:\/\//, "").replace(/https\:\/\//, "");
                        src = src.substr(src.indexOf("/"));
                    }
                    srcNew = urlExternalBase + src;    
                                            
                    $(this).attr("src", srcNew);
                }
            );
                            
            $markupRSSObject.find("div p:first").each(
                function()
                {
                     $(this).css({"display" : "block", "margin" : "0px"});
                }
            );
                            
            //Größe der Bilder ermitteln und ggf. anpassen
            if($.browser.msie == undefined || $.browser.version >= 9)
            {
                $markupRSSObject.find("img").load(
                    function()
                    {
                        if(($(this).height() >= $(this).width()) && $(this).height() > sizeImages)
                            $(this).height(sizeImages);
                                                                            
                        else if(($(this).width() > $(this).height()) && $(this).width() > sizeImages)
                            $(this).width(sizeImages);
                    }                                                                            
                );
            }                                                     
            else
                intervalResize = window.setInterval(resizeImages, 100);
            
            $("#feed-" + idPage).empty();
            $("#feed-" + idPage).append($markupRSSObject);
            $("#preloader-" + idPage).hide();
            
            
            //"more" - Links durchlaufen und prüfen, ob sie unter dem Text oder daneben angeordent sind - 
            //ist Letzteres der Fall, Abstand einfügen
            
            $("#feed-" + idPage + " .morelinkRSSReader").each(
                function()
                  {    
                    var $element = $(this);
                        
                    if($element.prev().css("display") === "inline")
                        $element.before("&nbsp;&nbsp;");
                  }
            );
            
            
            $("#feed-" + idPage).show();
        }
    }
    
 
    /**
     * Zeichenanzahl des "description" - Textes begrenzen
     * 
     * @param {String} description
     * @param {String} limit
     * @returns {String} description
     */
    function shortenDescription(description, limit)
    {    
        var cntFoundStart = 0;
        var cntFoundEnd = 0;
        var posFound = -1;
        var tagEnd = "";
        var tags = [ 
            ["<P" , "</P>"], ["<LI" , "</LI>"], ["<UL" , "</UL>"], ["<SPAN" , "</SPAN>"], ["<STRONG" , "</STRONG>"], ["<EM" , "</EM>"], ["<I" , "</I>"], ["<DIV" , "</DIV>"],
            ["<p" , "</p>"], ["<li" , "</li>"], ["<ul" , "</ul>"], ["<span" , "</span>"], ["<strong" , "</strong>"], ["<em" , "</em>"], ["<i" , "</i>"], ["<div" , "</div>"]
        ];
        var i = 0;
    
        //Übergebene Zeichenkette ab dem letzten Zeichen vor der Obergrenze abschneiden
        description = description.substr(0, limit);
        description = description.substr(0, description.lastIndexOf(" "));
        
        //Zeichenkette auf nicht geschlossene HTML-Tags überprüfen
        for(; i < tags.length; i ++)
        {
            while(true)
            {
                posFound = description.indexOf(tags[i][0], posFound + 1);
                if(posFound == -1)
                    break;
                else
                {
                    //Prüfen ob nach dem öffnenden Tag noch weitere Zeichen kommen - wenn nicht, Tag entfernen und abbrechen
                    if(description.substr(0, posFound + tags[i][0].length + 1).length == $.trim(description).length)
                    {
                        description = description.substr(0, posFound);
                        break;
                    }
                    else
                    {    
                        cntFoundStart ++;
                    }
                }
                    
            }
            posFound = -1;
            
            while(true)
            {
                posFound = description.indexOf(tags[i][1], posFound + 1);
                if(posFound == -1)
                    break;
                else
                    cntFoundEnd ++;
            }
            
            if(cntFoundStart != cntFoundEnd)
            {
                tagEnd = tags[i][1];
                if(tagEnd == "</LI>")
                    tagEnd += "</UL>";
                else if(tagEnd == "</li>")
                    tagEnd += "</ul>";
                break;
            }
        }
        
        description += "..." + tagEnd;
        return description;
    }
    
    
    /**
     * Fehler verarbeiten
     * 
     * @param {String} type Fehlerbeschreibung
     * @returns {void}
     */
    function handleError(type)
    {   
        if(altContent == false)
            $("#feed-" + idPage).append(msgError);
        $("#preloader-" + idPage).hide();
        $("#feed-" + idPage).show();
    }
    
    
    /**
     * Nachträglich die Größe der Bilder anpassen (nur für IE < 9)
     * 
     * @returns {void}
     */
    function resizeImages()
    {    
        if(countResizeImages < 10)
        {
            $("#feed-" + idPage).find("img").each(
                function()
                {
                    if(($(this).height() >= $(this).width()) && $(this).height() > sizeImages)
                        $(this).height(sizeImages);
                    else if(($(this).width() > $(this).height()) && $(this).width() > sizeImages)
                        $(this).width(sizeImages);
                }
            );
            countResizeImages ++;
        }
        else
            window.clearInterval(intervalResize);
    }
}
