<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs
    title="ALDI informiert..."
    title_url="http://www.aldi-sued.de"
    author="ALDI SÜD"
    description="Holen
Sie sich die aktuellen Aktionsangebote von ALDI SÜD auf Ihre iGoogle
Startseite und bleiben Sie immer auf dem neuesten Stand. Mehr
Informationen unter http://www.aldi-sued.de/de/html/service/igoogle_startseite.htm"
    thumbnail="http://www.aldi-sued.de/de/media/igoogle-gadget-de/img/aldi_sued.png"
    screenshot="http://www.aldi-sued.de/de/media/igoogle-gadget-de/img/screenshot_de.png"
    height="320"
    width="350"
    scrolling="false">
   <Require feature="tabs" />
   <Require feature="dynamic-height"/>
  </ModulePrefs>
  <Content type="html">
  <![CDATA[
  <style type="text/css">

  div#content_div{
    font-size: 90%;
  }
    
  div#headline_wrapper{
    width: 100%;
    display: block;
    height: 27px;
    overflow: hidden;
  }
    
  div#headline{
    
  }
    
  h1{
    color: #FFF;
    font-size: 12px;
    font-family: Arial, sans-serif;
    margin: 7px 0 5px 5px; padding: 0;
  }

  ul.offers, ul.offers li{
    list-style: none;
    padding: 0;
    margin: 0;
  }

  ul.offers li{
  	position: relative;
  	padding: 5px 0;
    border-bottom: 1px solid red;
    width: 100%;
  }
    
  ul.offers li:last-child{
    border: none;
  }
  
 ul.offers li a{
		text-decoration: none;
		color: #00158a;
		color: #000;
	}

  ul.offers li div.name{
  	font-weight: bold;
    font-size: 80%;
    margin-bottom: 3px;
  }
  
  ul.offers li div.product_img{
  	width: 115px;
  	height: 67px;
  }
  
  ul.offers li div.product_img img{
  	width: 110px;
  	height: 67px;
  	border: 0;
  }
  
  ul.offers li div.product_info{
  	position: absolute;
  	left: 120px;
  	bottom: 10px;
  }
  
  ul.offers li div.product_info div.amount{
  	font-size: .75em;
  }

  ul.offers li div.product_info div.price{
  	font-weight: bold;
  }
  
  ul.offers li div.product_info div.basicprice{
  	font-size: .75em;
  }

  div#info{
    border-top: 1px solid #00158a;
    padding-top: 3px;
    font-size: 90%;
  }

  div#info a{
    margin-top: -1px;
    color: #00158a;
    font-size: 10px;
  }

  </style>

  <div id="content_div"></div>
  <div id="info" style="display: none">
    <a href="http://aldi-sued.de/de/html/service/begrenzt_verfuegbare_aktionsartikel.htm" target="_blank">
    * Kunden-Information über begrenzt verfügbare Aktionsartikel
    </a>
    <img src="http://stat.aldi.com/dcsfq2jxwixy5f1mioa8p9lnl_5x1d/njs.gif?dcssip=www.aldi-sued.de&dcsuri=/iGoogle&WT.mc_pa=AldiiGoogle&WT.mc_id=google&WT.ti=iGoogle&WT.mc_ev=googleOpen&WT.js=No" alt="tp" />
  </div>
  <script src="http://www.aldi-sued.de/de/html/js/jquery-1.4.2.min.js"></script>
  <script src="http://hosting.gmodules.com/ig/gadgets/file/118193940270262322206/swfobject.js"></script>
  <script src="http://hosting.gmodules.com/ig/gadgets/file/118193940270262322206/gebcn.js"></script>
  <script type="text/javascript">
    
  var url = "http://aldi-sued.de/de/all-current-offers.xml?" + (1 + Math.floor(Math.random() * Math.pow(10, 6)));
  
  var scroll = 0;
  var i =0;
  var x = null;
  var activeTab = 0;
  $(document).ready(function(){  	
  	x = setInterval(autoscroll, 3000);
  	  	
  	$('#content_div').mouseout(function(){
  		x = setInterval(autoscroll, 3000);		
  	});
  	$('#content_div').mouseover(function(){
  		clearInterval(x);
  	});
});
	function autoscroll(){
		var liste = $("#offers" + activeTab + " LI");
		var offset = liste.eq(0).position().top;	

		if(liste.length <= i){
			activeTab++;
			var tabObjs = tabs.getTabs();
			if(tabObjs.length <= activeTab){				
				activeTab = 0;
			}
			$('.content_wrapper').hide();
			$('.content_wrapper').scrollTop();
			$('.content_wrapper').show();
			tabs.setSelectedTab(activeTab);
 			i = 0;
		}else{
			var pos = liste.eq(i).position().top;
			var add = liste.eq(i).outerHeight();
			var m = Math.ceil(pos+add-offset+1);
			$('.content_wrapper').animate({scrollTop:m},{duration:1000,ease:'easeIn'});
			i++;
		}
	}	
	
	function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}//end function var_dump

  function adjust_height(){    
    if(-1 != navigator.userAgent.toLowerCase().indexOf('iphone')){
      _IG_AdjustIFrameHeight();
    }else{
      var content_wrappers = getElementsByClassName("content_wrapper", "div", _gel("content_div"));
      for(var i = 0; i < content_wrappers.length; i++){
        var content_wrapper = content_wrappers[i];
        if(content_wrapper != null){
          content_wrapper.style.overflow = "auto";
          content_wrapper.style.height = "240px";
        }
      }
    }
    active_tab = _gel("tabId");
  }

  _IG_FetchXmlContent(url, function(response){
    if(response == null || typeof(response) != "object" || response.firstChild == null){
      _gel("content_div").innerHTML = "<i>Invalid data.</i>";
      return;
    }

    htmlContent = "";
    
    var htmlContent = "";
    var productData = [];
    var boxNodes = response.getElementsByTagName("box");
    for(var i = 0; i < boxNodes.length; i++){
      var boxNode = boxNodes[i];
      var box = new Object();
      box.headlineShort = boxNode.getElementsByTagName("headlineshort")[0].firstChild.nodeValue;
      box.headline = boxNode.getElementsByTagName("headline")[0].firstChild.nodeValue;
      box.headlineImg = boxNode.getElementsByTagName("headlineimage")[0].firstChild.nodeValue;
      box.headlinebackgroundcolor = boxNode.getElementsByTagName("headlinebackgroundcolor")[0].firstChild.nodeValue;
      box.firstboxbackgroundcolor = boxNode.getElementsByTagName("firstboxbackgroundcolor")[0].firstChild.nodeValue;
      box.firstboxtextcolor = boxNode.getElementsByTagName("firstboxtextcolor")[0].firstChild.nodeValue;
      box.offers = [];
      
      var boxOfferNodes = boxNode.getElementsByTagName("offer");
      for(var j = 0; j < boxOfferNodes.length; j++){
        var boxOfferNode = boxOfferNodes[j];
        var boxOffer = new Object();

        boxOffer.name = boxOfferNode.getElementsByTagName("name")[0].firstChild.nodeValue;
        
        boxOffer.price = (undefined == boxOfferNode.getElementsByTagName("price_no_amount")[0].firstChild) ? "" : boxOfferNode.getElementsByTagName("price_no_amount")[0].firstChild.nodeValue;
        boxOffer.amount = (undefined == boxOfferNode.getElementsByTagName("amount")[0].firstChild) ? "" : boxOfferNode.getElementsByTagName("amount")[0].firstChild.nodeValue;
        boxOffer.basicprice = (undefined == boxOfferNode.getElementsByTagName("basicprice")[0].firstChild) ? "" : boxOfferNode.getElementsByTagName("basicprice")[0].firstChild.nodeValue;
        
        boxOffer.img = boxOfferNode.getElementsByTagName("image")[0].firstChild.nodeValue;
        boxOffer.link = boxOfferNode.getElementsByTagName("link")[0].firstChild.nodeValue;
        boxOffer.regional = "true" == boxOfferNode.getAttribute("regional");
 
 		box.offers.push(boxOffer);
      }
      productData.push(box);
    }
    
    tabs = new _IG_Tabs(__MODULE_ID__, null, _gel('content_div'));
    tabs.displayTabs(false);
    tabs.alignTabs("left");
    for(var i = 0; i < productData.length; i++){
      var box = productData[i];
      var tabContentId = tabs.addTab(box.headlineShort, {callback: adjust_height});
           
      var tabContent = "";
      
      tabContent += "<div id=\"headline_wrapper\" style=\"background-color:" + box.headlinebackgroundcolor + ";\">" +
                    "<div id=\"headline_" + i + "\">" +
                    "<h1>" + box.headline + "</h1>" +
                    "</div>" +
                    "</div>";
          
      tabContent += "<div class=\"content_wrapper\"><ul class=\"offers\" id=\"offers" + i + "\">";
    
      
      var displayedRegionalTitle = false;  
    
      for(var j = 0; j < box.offers.length; j++){
      
        var bgColor = "#FFF";
        var textColor = "#00158a";

        var offer = box.offers[j];

        if(offer.regional && !displayedRegionalTitle){
          tabContent += "<li class=\"regional\" style=\"display:block; width:100%; height: 20px; background: " + box.headlinebackgroundcolor + " url(http://hosting.gmodules.com/ig/gadgets/file/118193940270262322206/regional_" + box.headlinebackgroundcolor.replace("#", "") + ".png) no-repeat 1px 0; text-indent: -9000px; overflow: hidden; border: none; margin-top: -1px; \">&nbsp;</li>";
          displayedRegionalTitle = true;
        }

        tabContent += "<li id=\"offer" + i + "_" + j + "\">"

        + "<div class=\"name\">"
        + "<a target=\"_blank\" href=\"" + offer.link + "?WT.z_src=google&WT.mc_id=google\" >"
        + offer.name
        + "</a>"
        + "</div>"
        
        + "<div class=\"product_img\">"
        
        + "<a target=\"_blank\" href=\"" + offer.link + "?WT.z_src=google&WT.mc_id=google\">"
        + "<img src=\"" + offer.img + "\" />"
        + "</a>"
        
        + "</div>"
        
        + "<div class=\"product_info\">"
        
        + "<div class=\"amount\">"
        + "<a target=\"_blank\" href=\"" + offer.link + "?WT.z_src=google&WT.mc_id=google\">"
        + offer.amount
        + "</a>"
        + "</div>"

        + "<div class=\"price\">"
        + "<a target=\"_blank\" href=\"" + offer.link + "?WT.z_src=google&WT.mc_id=google\">"
        + offer.price
        + "</a>"
        + "</div>"

        + "<div class=\"basicprice\">"
        + "<a target=\"_blank\" href=\"" + offer.link + "?WT.z_src=google&WT.mc_id=google\">"
        + offer.basicprice
        + "</a>"
        + "</div>"
        
        + "</div>"

        + "</li>";

      }
      
      tabContent += "</ul></div>";
      _gel(tabContentId).innerHTML = tabContent;
      
      adjust_height();
      var flashvars = {};
      flashvars.headline = box.headline;
      var params = { wmode: "transparent" };
      var attributes = {};
      attributes.id = "aldi_headline_" + i;
      swfobject.embedSWF("http://hosting.gmodules.com/ig/gadgets/file/118193940270262322206/aldi-headline.swf", "headline_" + i, "320", "27", "8.0.0", "http://hosting.gmodules.com/ig/gadgets/file/118193940270262322206/expressInstall.swf", flashvars, params, attributes);
    }
    var tabObjs = tabs.getTabs();
    for(var i = 0; i < tabObjs.length; i++){
      var tabElement = tabObjs[i].getNameContainer();
      
      tabElement.style.backgroundColor = productData[i].headlinebackgroundcolor;
      tabElement.style.color = "#FFFFFF";
    
    }
    tabs.displayTabs(true);
    _gel("info").style.display = "block";
  });
  
  </script>
  ]]>
  </Content>
</Module>
