<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Video del momento su YouTube" description="Video su YouTube: se vuoi veramente divertirti guarda i video del momento su YouTube e ricerca in tutto You Tube" 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="445" screenshot="http://facilegadget.googlecode.com/svn/trunk/youtube/youtube_screenshot.png" thumbnail="http://facilegadget.googlecode.com/svn/trunk/youtube/youtube_thumbnail.png" >
<Require feature="analytics" />
  <Require feature="dynamic-height" />
<Require feature="setprefs" />
</ModulePrefs>
<UserPref name="counter" default_value="0" datatype="hidden" />
<UserPref name="TipoVideo" datatype="hidden" default_value="1"/>
<UserPref name="Dimensione" display_name="Dimensione video:" datatype="enum" default_value="2">
  <EnumValue value="1" display_value="Piccolo"/>
  <EnumValue value="2" display_value="Medio"/>
  <EnumValue value="3" display_value="Grande"/>
</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 = "youtube";
var IDgadget = "1";
var piattaforma = "igoogle";
</script>
<script type="text/javascript" src="http://facilegadget.googlecode.com/svn/trunk/facilegadget.js"></script>
<script src="http://facilegadget.googlecode.com/svn/trunk/swfobject.js"></script>
<style>
    a {color: #003399; font-weight: bold;}
    a:visited {color: #003099;}
    a:hover {color: red;}
    #content_div {text-align: center;}
    #inte_div a {font-size: 35px; line-height: 25px; text-decoration: none;}

    i {color: #808080; font-weight: bold;}
    form {margin: 0;}
    p {margin: 5 0 5 0;}
    table {font-size: 80%; background-color: #ffffff; width: 99%; border: outset 5pt; border-spacing: 5pt 5pt;}
    td {vertical-align: top; font-size: 85%;}
  
    .tit {text-align: center; color: #000000; font-weight: bold; font-size: 110%;}
    .titolo {font-weight: bold; font-size: 120%;}

    #cambiavideo {font-size: 75%; width: 180px;}
    #inte_div {font-size: 20px; margin-top: 5px;}
    #cd {font-size: 80%; margin: 0 0 5 0; background-color: #FFFFFF;}
</style>
   
<script type="text/javascript">
var prefs = new _IG_Prefs();
var primoavvio = 1;

function cambia() {
  var selIndex = cambiavideo.selectedIndex;
  prefs.set("TipoVideo", cambiavideo.options[selIndex].value);
  displayMenu(0);
}

function intestazione(tipo) {
  var htmlinte = "";
  htmlinte += '<table><tr><td class="tit"><a title="video precedente" href="javascript:displayMenu(2)">&laquo;&nbsp;</a>';
  htmlinte += '<select name="cambiavideo" id="cambiavideo" onChange="cambia()">';
  htmlinte += '<option value="1">Video recenti</option>';
  htmlinte += '<option value="2">Video preferiti</option>';
  htmlinte += '<option value="3">Più votati</option>';
  htmlinte += '<option value="4">Più visti di oggi</option>';
  htmlinte += '<option value="5">Più visti settimana</option>';
  htmlinte += '<option value="6">Più visti del mese</option>';
  htmlinte += '<option value="7">Più visti in assoluto</option>';
  htmlinte += '<option value="8">Recenti in primo piano</option>';
  htmlinte += '</select>';
  htmlinte += '<a title="video successivo" href="javascript:displayMenu(1)">&nbsp;&raquo;</a></td></tr></table>';
  _gel("inte_div").innerHTML = htmlinte;
}

function displayMenu(param) {
     var dimensione = prefs.getInt("Dimensione");
     var numero, html, htmltit, so;
     var id, title, link, inizio, fine;
     var i, j, dimAltezza, dimLarghezza;
     var nodeList, itemList, node;
     var url;

     var TipoURL = prefs.getInt("TipoVideo");
     if (TipoURL == 1) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/most_recent";
     }
     else if (TipoURL == 2) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/top_favorites";
     }
     else if (TipoURL == 3) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/top_rated";
     }
     else if (TipoURL == 4) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/most_viewed?time=today";
     }
     else if (TipoURL == 5) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/most_viewed?time=this_week";
     }
     else if (TipoURL == 6) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/most_viewed?time=this_month";
     }
     else if (TipoURL == 7) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/most_viewed";
     }
     else if (TipoURL == 8) {
        url = "https://gdata.youtube.com/feeds/api/standardfeeds/IT/recently_featured";
     }
          
     if (param == 0) {
       numero = 0;
       prefs.set("counter", numero);
     }
     else if (param == 1) {
       numero = prefs.getInt("counter") + 1;
       if (numero > 14) {numero = 0;}
       prefs.set("counter", numero);
     }
     else if (param == 2) {
       numero = prefs.getInt("counter") - 1;
       if (numero < 0) {numero = 14;}
       prefs.set("counter", numero);
     }
    
     if (dimensione == 1) {
       dimLarghezza = 145;
       dimAltezza = 105;
     }
     else if (dimensione == 2) {
       dimLarghezza = 285;
       dimAltezza = 215;
     }
     else if (dimensione == 3) {
       dimLarghezza = 425;
       dimAltezza = 319;
     }

    _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");
 
           for (i = numero; i < numero+1; i++) {
             html = "";
             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") {
                   id = node.firstChild.nodeValue;
                   id = id.replace("http://gdata.youtube.com/feeds/api/videos/", "");
                   link = "http://www.youtube.com/watch?v=" + id;
                }
             }

             html += "<p><a target='_blank' href='" + link + "'>" + title + "</a></p>";
             html += "<object style='height: " + dimAltezza + "px; width: " + dimLarghezza + "px'><param name='movie' value='http://www.youtube.com/v/" + id + "?version=3'>"
             html += "<param name='allowFullScreen' value='true'><param name='allowScriptAccess' value='always'>"
             html += "<embed src='http://www.youtube.com/v/" + id + "?version=3' type='application/x-shockwave-flash' allowfullscreen='true' allowScriptAccess='always' width='" + dimLarghezza + "' height='" + dimAltezza + "'></object>"

             _gel("content_div").innerHTML = html;
             if (primoavvio == 1) {
                 primoavvio = 0;
             }
             else {
                 simply250();
             }

             setTimeout('_IG_AdjustIFrameHeight()', 500); 
             _IG_AdjustIFrameHeight();
         } 
    });
  cambiavideo.selectedIndex = TipoURL-1;
  }
</script>
<div id="inte_div"></div>
  
<div id="content_div"></div>
<div id="fine_div">
<br />
<form action="http://it.youtube.com/results" target="_blank" method="GET">
<table><tr><td class="tit"><img src="http://facilegadget.googlecode.com/svn/trunk/youtube/youtube.png" border="0" /> <input type="text" name="search_query" size="12"/> <input type="submit" value="cerca"/></td></tr></table>
</form></div> 

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

<div id="adv">
<script type='text/javascript'>
   document.MAX_ct0 ='';
   var m3_u = (location.protocol=='https:'?'https://cas.criteo.com/delivery/ajs.php?':'http://cas.criteo.com/delivery/ajs.php?');
   var m3_r = Math.floor(Math.random()*99999999999);
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("zoneid=32419");document.write("&amp;nodis=1");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) {
       document.write ("&amp;ct0=" + escape(document.MAX_ct0));
   }
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'></scr"+"ipt>");
</script>
</div>

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

intestazione();
displayMenu(0);
</script>
]]></Content></Module>