
function IGMenu(relPath,staticRelPath,subcat){this.relPath=relPath;this.staticRelPath=staticRelPath;this.subCat=subcat;this.dataLoaded=true;this.subMenuRequest='';this.timer=null;this.timerDisplay=null;this.catRequested=false;this.currentOver=null;this.divId='menu__root__root';this.timeOutRoot=500;this.timeOutChildren=40;this.openedChildren=0;this.activeChild=null;this.activeTempo=this.timeOutRoot;this.categoriesNode={};this.init();}
IGMenu.prototype={init:function()
{var self=this;$('.menuitem').hover(function(){this.className='menuitem-hl';self.currentOver=this.id;self.requestSubMenu(this.id);},function(){self.cancelSubMenuRequest();this.className='menuitem';});},loadData:function()
{if(this.dataLoaded)return;var element=document.createElement("script");element.src=this.staticRelPath+"de-de/js/Partenaires.js";document.body.appendChild(element);this.dataLoaded=true;},requestSubMenu:function(catId)
{var self=this;if(this.timer)clearTimeout(this.timer);var tempo=this.activeTempo;this.catRequested=catId.replace(/^.*__([^_]+)$/,'$1');this.timer=setTimeout(function(){self.processSubMenu();},tempo);},processSubMenu:function()
{var self=this;var catName=self.catRequested;if(!self.dataLoaded)
{self.loadData();self.timer=setTimeout(function(){self.processSubMenu();},self.timeOutRoot);return;}
if(this.categoriesNode[catName])
{this.categoriesNode[catName].show();}
else
{this.categoriesNode[catName]=new IGMenuCat(this,catName,this);}
this.activeTempo=this.timeOutChildren;self.cancelHide();prevActiveChild=self.activeChild;self.activeChild=self.categoriesNode[catName];if(prevActiveChild&&prevActiveChild.catId!=self.categoriesNode[catName].catId)
{prevActiveChild.requestHide();}},cancelSubMenuRequest:function()
{var self=this;var catName=this.catRequested;if(this.timer)clearTimeout(this.timer);if(this.categoriesNode[catName])
{this.categoriesNode[catName].requestHide();}},hide:function()
{if(this.mouseOver)
{return;}
if(this.activeChild&&this.activeChild.mouseOver)
{return;}
this.activeTempo=this.timeOutRoot;},cancelHide:function()
{if(this.timerDisplay)clearTimeout(this.timerDisplay);},requestHide:function()
{var self=this;if(this.timerDisplay)clearTimeout(this.timerDisplay);this.timerDisplay=setTimeout(function(){self.hide();},this.timeOutRoot);}};function IGMenuCat(parent,catName,menu){this.parent=parent;this.catName=catName;this.menu=menu;this.html='';this.div=null;this.divId=parent.divId+'__'+this.catName;this.timer=null;this.timerDisplay=null;this.catRequested=null;this.currentOver=null;this.mouseOver=false;this.openedChildren=0;this.activeChild=null;this.nbElem=0;var self=this;self.init();}
IGMenuCat.prototype={init:function()
{var self=this;this.html='<div id="'+this.divId+'" class="menupopup" style="display: none;">';var subCat=IGMenuData['tree'][this.catName];this.nbElem=0;if(subCat)
{for(var i=0;i<subCat.length;i++)
{this.html+='<dd class="menuitem" id="menu__'+this.catName+'__'+subCat[i]+'" onclick="window.location = \''+menu.relPath+menu.subCat+'/'+subCat[i]+'\';">';this.html+='<div style="max-width: 210px; overflow: hidden; float: left; white-space: nowrap; vertical-align: top;">';this.html+='<img class="icon_category" src="'+menu.staticRelPath+'de-de/images/www/categories/site/'+subCat[i]+'.png" style="margin-top: -1px;" alt="" />';this.html+=IGMenuData.categories[subCat[i]];this.html+='</div>';this.html+='<div class="dropmarker">&gt;</div>';this.html+='</dd>';this.nbElem++;}}
var merchantsId=IGMenuData['merchant-category'][this.catName];if(merchantsId)
{for(var i=0;i<merchantsId.length;i++)
{var merchant=IGMenuData.merchants[merchantsId[i]];var linkAppendVoucher='';if(menu.subCat=='gutscheincodes')
{linkAppendVoucher='/'+merchant['voucherUrl'];}
this.html+='<dd class="menuitem" id="merchant__'+this.catName+'__'+merchant['urlName']+'" onclick="window.location = \''+menu.relPath+menu.subCat+'/'+merchant['urlName']+linkAppendVoucher+'\'">';this.html+='<div style="max-width: 130px; overflow: hidden; float: left; white-space: nowrap; vertical-align: top;">';this.html+='  <img class="icon_partner" src="'+menu.staticRelPath+'de-de/images/partners/favicon/'+merchant['urlName']+'.gif" />';this.html+=merchant['name'];this.html+='</div>';if(merchant['specials'])
this.html+='<img class="icon_partner_details" style="float: right;" src="'+menu.staticRelPath+'common/images/www/toolkit/arbo/specials.png" alt="BA" />';if(merchant['coupons'])
this.html+='<img class="icon_partner_details" style="float: right;" src="'+menu.staticRelPath+'common/images/www/toolkit/arbo/promos.png" alt="P" />';this.html+='<div style="float: right">'+merchant['cashback']+'</div>';this.html+='</dd>';this.nbElem++;}}
if(this.nbElem==0)
{this.html+='<dd class="menuitem" id="menu__'+this.catName+'__'+subCat[i]+'" onclick="window.location = \''+menu.relPath+menu.subCat+'/'+subCat[i]+'\';">';this.html+='<div style="max-width: 210px; overflow: hidden; float: left; white-space: nowrap; vertical-align: top;">';this.html+='Leere Kategorie';this.html+='</div>';this.html+='</dd>';this.nbElem=1;}
this.html+='</div>';$('body').append(this.html);this.div=$('#'+this.divId);$('#'+this.divId+' .menuitem').hover(function()
{this.className='menuitem-hl';},function()
{this.className='menuitem';});this.show();this.div.hover(function(){self.mouseOver=true;self.cancelHide();},function(){self.mouseOver=false;self.requestHide();});$('#'+this.divId+' .menuitem').hover(function(){if(this.id.indexOf('merchant__')==-1)
{self.currentOver=this.id;self.requestSubMenu(this.id);}
else
{self.activeChild=null;}},function()
{self.cancelSubMenuRequest();});},show:function()
{var overElem=$('#'+this.parent.currentOver);var position=overElem.offset();position.left+=overElem.outerWidth();this.parent.openedChildren++;var zindex=overElem.css('z-index');if(zindex=='auto')zindex=100;var xOffset=1;var heightDisplay=document.documentElement.clientHeight;var bottomMenu=position.top-xOffset+20*this.nbElem;var bottomMargin=heightDisplay+document.documentElement.scrollTop-bottomMenu;if(bottomMargin<0)
{xOffset+=-bottomMargin+5;}
var topMenu=position.top-xOffset;if(topMenu<0)
{xOffset+=topMenu-5;}
this.div.css({'top':position.top-xOffset,'left':position.left,'z-index':zindex+1});this.div.show();},hide:function()
{if(this.mouseOver)
{return;}
if(this.parent.mouseOver&&this.parent.activeChild&&this.parent.activeChild.divId==this.divId)
{return;}
if(this.activeChild&&this.activeChild.mouseOver)
{return;}
this.div.hide();this.parent.requestHide();if(this.activeChild)
{var prevActiveChild=this.activeChild;this.activeChild=null;prevActiveChild.requestHide();}},cancelHide:function()
{var self=this;if(this.timerDisplay)clearTimeout(this.timerDisplay);},requestHide:function()
{var self=this;if(this.timerDisplay)clearTimeout(this.timerDisplay);this.timerDisplay=setTimeout(function(){self.hide();},this.menu.timeOutChildren);},requestSubMenu:function(catId)
{var self=this;if(this.timer)clearTimeout(this.timer);var tempo=0;tempo=this.menu.timeOutChildren;this.catRequested=catId.replace(/^.*__([^_]+)$/,'$1');this.timer=setTimeout(function(){self.processSubMenu();},tempo);},processSubMenu:function()
{var self=this;var catName=self.catRequested;if(self.menu.categoriesNode[catName])
{self.menu.categoriesNode[catName].show();}
else
{self.menu.categoriesNode[catName]=new IGMenuCat(this,catName,self.menu);}
prevActiveChild=self.activeChild;self.activeChild=self.menu.categoriesNode[catName];if(prevActiveChild)prevActiveChild.requestHide();},cancelSubMenuRequest:function()
{var catName=this.catRequested;if(this.timer)clearTimeout(this.timer);if(this.menu.categoriesNode[catName])
{this.menu.categoriesNode[catName].requestHide();}}};