<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="Bollywood Celebrity Gadget" height="320" width="300"
             author="Jinu George"
             author_email="jgeorge.feedback+bollywood@googlemail.com"
             author_link="http://raakshaseeyam.blogspot.com" 
             description="Shows Photos, videos and news from bollywood"
             screenshot="http://jinuvgeorge.googlepages.com/srk_b.png"
             thumbnail="http://jinuvgeorge.googlepages.com/srk_s.png"> 
  <Require feature="analytics" />
  <Require feature="tabs" />
</ModulePrefs>
<UserPref name="photo_str" display_name="Photos of (e.g.: shahrukh,khan):"  default_value="shahrukh,khan"/>
<UserPref name="video_str" display_name="Videos of (e.g.: shahrukh+khan):"  default_value="shahrukh+khan"/>
<UserPref name="news_str" display_name="News about (e.g.: shahrukh+khan):"  default_value="shahrukh+khan"/>
<Content type="html"><![CDATA[ 

<script>
  _IG_Analytics("UA-2560293-8", "/Bollywood");
</script>
 
 <script type="text/javascript">

var entries = 10;

var prefs = new _IG_Prefs();
     var picsof = prefs.getString("photo_str");
     var vidsof = prefs.getString("video_str");
     var newsabt = prefs.getString("news_str");


    // Initialize tabs, designate the tab named "Two" as
    // the tab selected by default.
    var tabs = new _IG_Tabs(__MODULE_ID__, "");

    function init() {
    
     tabs.addTab("Photos", "photo", getPics);

    tabs.addTab("Videos", "video", getVid);
    tabs.addTab("News", "news", getNews);

}

function getVid () {
_IG_FetchFeedAsJSON("http://www.youtube.com/rss/tag/"+vidsof+".rss",
             
            function(feed) { 
              if (feed == null){ 
                 alert("There is no data.");
                 return;
              }

  
         var ran_number=Math.floor(Math.random()*10);

         // Start building HTML string that will be displayed in gadget.
         var html = "";

     
         // Access the data for a given entry
         if (feed.Entry) {
  
             if (feed.Entry[ran_number].Link ) {
                var url = feed.Entry[ran_number].Link.split("=");

             }
             else {
                 var url = feed.Entry[0].Link.split("=");

            }

                 //var k = feed.Entry[i].URL;
                 html+= '<center><iframe src ="http://youtube.com/v/'+url[1]+'.swf" height="205px" width="275px" scrolling="no" frameborder="0"/></center>';
           
            
         }
          _gel("video").innerHTML = html;
       
       
   
  
       
       //http://api.flickr.com/services/feeds/photos_public.gne?tags=shahrukh,khan

     // The rest of the function parameters, which are optional: the number
     // of entries to return, and whether to return summaries.
     }, entries);

}

function getPics () {
 var url = "http://api.flickr.com/services/feeds/photos_public.gne?tags="+picsof;
             
            _IG_FetchXmlContent(url, function (response) {
         if (response == null || typeof(response) != "object" || response.firstChild == null) {
           _gel("content_div").innerHTML = "<i>Invalid data.</i>";
           return;
        }	

     var objNodeList = response.getElementsByTagName("entry"); 

var items =[];     
for (var i = 0; i < 20; ++i) {
       var xmlItem = objNodeList.item(i);
       var item = {};
       var added = false;
       for (var j = 0; j < xmlItem.childNodes.length; ++j) {
         var child = xmlItem.childNodes.item(j);
         if (child.childNodes.length > 0) { // (4) pull out the text for the children of the main tag
           var name = child.nodeName;
           var value = child.childNodes[0].nodeValue;
           item[name] = value;
           
              }
}

items.push(item);

}

var ran_number = Math.floor(Math.random()*10);
var html = "";


    //html+=  items[i]["content"];
 
    var url= items[ran_number]["content"].split("<img");

  var source = url[1].split("/>"); 

  html += '<center><img' + source[0] + '/><br></center>';


    
    //alert(html);
    _gel('photo').innerHTML = html; 
        
       		 
	 });	  
}

function getNews () {

_IG_FetchFeedAsJSON("http://news.google.com/news?hl=en&q="+newsabt+"&um=1&ie=UTF-8&resnum=1&ct=title&output=rss&ned=:ePkh8BM9E2IF2mHAQoQtQuxarJl5KZmJMOuMBPYfDld98eRU-LtQw_ui9XMn_2JjSs35xcaak5-cCKSZi1KTAXm0GYs",
             
            function(feed) { 
              if (feed == null){ 
                 alert("There is no data.");
                 return;
              }

  
         //var ran_number=Math.floor(Math.random()*10);

         // Start building HTML string that will be displayed in gadget.
         var html = "<span style='font-size:12px'><ul>";

     
         // Access the data for a given entry
         if (feed.Entry) {
  
             for (i=0;i<=5;++i) {
                 
                 html+='<li><a href="'+feed.Entry[i].Link+'" target="_blank">'+feed.Entry[i].Title+'</a></li>';
             }
            
         }
html+= '</ul></span>';

          _gel("news").innerHTML = html;
       
       
   
  
       
       //http://api.flickr.com/services/feeds/photos_public.gne?tags=shahrukh,khan

     // The rest of the function parameters, which are optional: the number
     // of entries to return, and whether to return summaries.
     }, entries);

}

_IG_RegisterOnloadHandler(init);
    </script>
<div id ="content">
  <div id ="video"></div>
  <div id ="photo"></div>
  <div id="news"></div>
</div>
<div id ="ad"><center>
<script type="text/javascript"><!--
google_ad_client = "pub-7199283646323733";
/* 234x60, created 3/15/08 */
google_ad_slot = "0483994695";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center></div>
]]></Content>
</Module>




