<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="VW - Gadget Ad" width="336" height="280" thumbnail="" scrolling="false">
  <Require feature="ads"/>
  <Require feature="flash"/>
</ModulePrefs>
<UserPref name="clickurl" datatype="hidden" default_value="DEBUG"/>
<UserPref name="aiturl" datatype="hidden" default_value="DEBUG"/>
<Content type="html"><![CDATA[
  <style>
    /* Don't show default blue borders around images */
    img {
      border-width: 0px;
    }

    #mainTable {
      width: 100%;
      height: 280px;
      background-color: #000;
    }
    
    #linksContainer {
      text-align: center;
      font-size: 13px;
    }
    #linksContainer a {
      text-decoration: none;
      padding: 0px 3px;
      color: #ccf;
    }
    
    #contentContainer {
      height: 240px;
      border-top: 1px solid #676767;
      padding: 5px 5px 2px;
    }
    
    /* Style when displaying feeds */
    .feeds ul {
      margin: 0px;
      padding: 0px 5px;
      list-style-type: none;
      font-size: 11px;
    }
    .feeds ul li {
      margin-bottom: 10px;
    }
    
    /* Style when showing videos */
    .videos {
      text-align: center;
    }
    .videos a {
      font-size: 13px;
      text-decoration: none;
      color: #ccf;
    }
  </style>
  
  <table id="mainTable" border=0 cellspacing=0 cellpadding=1>
    <tr height="30">
      <td id="logoContainer" width=40 align=center></td>
      <td id="linksContainer"></td>
    </tr>
    <tr>
      <td id="contentContainer" colspan=2></td>
    </tr>
  </table>
  
  <script>
    // Global variables
    var prefs = new _IG_Prefs();
    var contentContainer = _gel("contentContainer");
    var videoSources = [
      "cv157ZIInUk",
      "xCIF6JF1O5U",
      "0I0WfnhVs2s",
      "SPQp7HJWVdg",
      "Xnd1BxAo81g",
      "119eSti2n1o",
      "_9Eg-S6aaSw",
      "FvyxCC5XWCg"
    ];
  
  
    // This function is executed after the page loads
    function init() {
      // Create clickable logo
      var html = [
        '<a onclick="javascript:_ADS_ClickDestinationUrl(\'http://www.vw.com\')" href="javascript:void(0);">',
        '<img src="' + _IG_GetImageUrl('http://') + '" alt="logo" width=30 height=30/>',
        '</a>'
      ].join("");
      _gel("logoContainer").innerHTML = html;
    
      // Generate tab links
      var html = [
        '<a href="javascript:void(0);" onclick="_ADS_ReportInteraction(\'tab_1\'); showVideos();">Videos</a>',
        '<a href="javascript:void(0);" onclick="_ADS_ReportInteraction(\'tab_2\'); showFeeds();">Buzz</a>',
        '<a onclick="_ADS_ReportInteractionClick(\'http://www.vw.com/dealerlocator/en/us/\', \'destination_url_1\');" href="javascript:void(0);">Find Dealers</a>',
        '<a onclick="_ADS_ReportInteractionClick(\'http://www.vw.com/specialoffers/en/us/\', \'destination_url_2\');" href="javascript:void(0);">Special Offers</a>'
      ].join(" | ");
      _gel("linksContainer").innerHTML = html;
    
      // Start in feeds mode
      showVideos();
    }
    
    // Creates a target URL using the clickurl userpref.
    function generateClickUrl(url) {
      return prefs.getString("clickurl") + _esc(url);
    }
  
    // Called whenever user clicks on 'VW Buzz'
    // Fetches RSS feed from vw.com and displays them.
    function showFeeds() {
      var url = 'http://www.vw.com/news/browse/en/us/?format=rss';
      _IG_FetchFeedAsJSON(url, showFeedsCallback, 10, true);
    }
  
    function showFeedsCallback(response) {
      var entries = response.Entry;
    
      var html = new Array();
      html.push('<ul>');
      for (var n = 0; n < entries.length; n++) {
        var entry = entries[n];
        html.push('<li>');
        html.push('<a target="_top" href="' + entry.Link + '">' + entry.Title + '</a>');
        html.push('<div>' + entry.Summary + '</div>');
        html.push('</li>');
      }
      html.push('</ul>');
    
      // Show feeds DIV and hide videos
      contentContainer.innerHTML = html.join("");
      contentContainer.className = "feeds";
    }
  
    // Called whenever user clicks 'Video'
    // Play a random GTI video via YouTube
    function showVideos() {
      // Pull random video from our pre-selected list
      var randIndex = Math.floor(Math.random() * 10000 % videoSources.length);
      var html = [
        '<div id="videoContainer"></div>',
        '<a href="javascript:void(0);" onclick="_ADS_ReportInteraction(\'browse\'); showVideos();">&laquo; see more &raquo;</a>'
      ];
      contentContainer.innerHTML = html.join('');
    
      // Show videos DIV and hide feeds
      var videoUrl = 'http://www.youtube.com/v/' + videoSources[randIndex];
      _IG_EmbedFlash(videoUrl, 'videoContainer', {
          width: 270,
          height: 220,
          wmode: 'transparent'
        });
      contentContainer.className = "videos";
    }
  
    _IG_RegisterOnloadHandler(init);
  </script>
]]>
</Content>
</Module>
