<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="iTunes" description="Questo gadget ti consente di rimanere sempre informato sulle novita` musicali e non solo di iTunes Music Store: i top album, le top canzoni, le ultime novita` e gli ultimi album aggiunti. Inoltre hai la possibilita` di scaricare direttamente i brani che piu` ti interessano e di fare ricerche libere nell'intero catalogo di iTunes" title_url="http://www.facilegadget.it" author="FacileGadget" author_email="info@facilegadget.it" author_location="Italia" author_link="http://www.facilegadget.it" scrolling="true" height="350" screenshot="http://facilegadget.googlecode.com/svn/trunk/iTunes/itunes_screenshot.png" thumbnail="http://facilegadget.googlecode.com/svn/trunk/iTunes/itunes_thumbnail.png" >
<Require feature="analytics"/>
</ModulePrefs>
<UserPref name="TipoURL" display_name="Tipo:" datatype="enum" required="true" default_value="2">
 <EnumValue value="1" display_value="Top canzoni"/>
 <EnumValue value="2" display_value="Top album"/>
</UserPref>
<UserPref name="Numero" display_name="Numero album/brani:" datatype="enum" default_value="10">
 <EnumValue value="5" display_value="5"/>
 <EnumValue value="10" display_value="10"/>
 <EnumValue value="25" display_value="25"/>
</UserPref>
<Content type="html">
<![CDATA[
<link rel="stylesheet" type="text/css" href="http://facilegadget.googlecode.com/svn/trunk/facilegadget.css" />
<script type="text/javascript">
//parametri gadget  
var nomegadget = "iTunes";
var IDgadget = "3";
var piattaforma = "igoogle";
</script>
<script type="text/javascript" src="http://facilegadget.googlecode.com/svn/trunk/facilegadget.js"></script>
<style>
    a {color: #003399; font-weight: bold;}
    a:visited {color: #003099;}
    a:hover {color: red;}

    i {color: #808080; font-weight: bold;}
    form {margin: 0;}
    p {margin: 5 0 10 0;}

    #cd {font-size: 80%; margin: 0 0 5 0; background-color: #FFFFFF; text-align: center;}
    #adv {text-align: center;}
    .tit {text-align: center; color: #707575; font-weight: bold;}
    #content_div {font-size: 85%; background-color: #F0F0F0;}
    table {font-size: 80%; background-color: #bdbdbd; width: 98%; border: outset 5pt; border-spacing: 5pt 5pt;}

    td {vertical-align: top;}
</style>

<script type="text/javascript">
  function displayMenu() {
     var prefs = new _IG_Prefs();
     var numero = prefs.getInt("Numero");
     var TipoURL = prefs.getInt("TipoURL");
     var html, url, DescrizioneURL;
     var title, link, descrizione;
     var i, j, artista, artistalink, album, albumlink, albumprezzo, albumimmagine, datauscita, genere;
     var nodeList, itemList, node;

     if (TipoURL == 1) {
          url = "http://itunes.apple.com/it/rss/topsongs/limit=" + numero + "/xml";
          DescrizioneURL = "TOP " + numero + " canzoni";
     }
     else if (TipoURL == 2) {
          url = "http://itunes.apple.com/it/rss/topalbums/limit=" + numero + "/xml";
          DescrizioneURL = "TOP " + numero + " album";
     }
     else if (TipoURL == 3) {
          url = "http://itunes.apple.com/it/rss/topimixes/limit=" + numero + "/xml";
          DescrizioneURL = "TOP " + numero + " iMix";
     }
     else if (TipoURL == 4) {
          url = "http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/featuredalbums/sf=143450/limit=" + numero + "/rss.xml";
          DescrizioneURL = "ultimi " + numero + " album";
     }
     else if (TipoURL == 5) {
          url = "http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/justadded/sf=143450/limit=" + numero + "/rss.xml";
          DescrizioneURL = numero + " nuove uscite";
     }

     document.write('<table><tr><td class="tit"><img src="http://facilegadget.googlecode.com/svn/trunk/iTunes/iTunes.png" border="0" />: ' + DescrizioneURL + '</td></tr></table>');
     document.write('<div id="content_div"></div>');

     document.write('<form action="' + crealink('http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?1=1') + '" target="_blank" method="POST">');
     document.write('<table><tr><td class="tit"><img src="http://facilegadget.googlecode.com/svn/trunk/iTunes/iTunes.png" border="0" /> <input type="text" name="term" size="8"><input type="submit" value="cerca" name="B1"></td></tr></table>');
     document.write('</form>');

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

           itemList = response.getElementsByTagName("entry");

           html = ""; 
           for (i = 0; i < numero; i++) {
             nodeList = itemList.item(i).childNodes;

             for (j = 0; j < nodeList.length ; j++) {
                node = nodeList.item(j);
                if (node.nodeName == "title") {
                   title = node.firstChild.nodeValue;
                }
                if (node.nodeName == "id") {
                   link = crealink(node.firstChild.nodeValue);
                }
                if (node.nodeName == "im:artist") {
                   artista = node.firstChild.nodeValue;
                }
                if (node.nodeName == "im:price") {
                   albumprezzo = node.firstChild.nodeValue;
                }
                if (node.nodeName == "im:releaseDate") {
                   datauscita = node.firstChild.nodeValue;
                   datauscita = datauscita.substr(8,2) + "/" + datauscita.substr(5,2) + "/" + datauscita.substr(0,4);
                }
                if (node.nodeName == "im:image") {
                   albumimmagine = node.firstChild.nodeValue;
                }
             } 

             html += '<table><tr>';
             html += '<td width="100px"><a target="_blank" href="' + link + '"><img border="0" src="' + albumimmagine + '" width="100" height="100"></a></td>';
             html += '<td><b><a target="_blank" href="' + link + '">' + title + '</a></b><br><br>';
             html += '<b>artista</b>: ' + artista + '<br>';
             html += '<b>data uscita</b>: ' + datauscita + '<br>';
             html += '<b>genere</b>: ' + genere + '<br>';
             html += '<b>prezzo</b>: ' + albumprezzo + '</td>';
             html += '</tr></table>';
         }
     _gel('content_div').innerHTML = html; 
    }); 
  }
</script>
<script>
  displayMenu();
</script>

<script type="text/javascript">
scriviby(IDgadget, nomegadget);
</script>

<div id="adv">  
<script type="text/javascript">
advcross('');
stats(nomegadget, piattaforma);
</script>
</div>

]]></Content></Module>