<?xml version="1.0" encoding="UTF-8" ?> 
<Module> 
<ModulePrefs
      title="__MSG_gadget_title__"
      description="demonstrate the basic function of poster editor provided by snapfish"
      author="anonymous"
      author_email="whysomanywhy@gmail.com"
      screenshot="http://hosting.gmodules.com/ig/gadgets/file/112375570725200634982/pe.png"
      thumbnail="http://hosting.gmodules.com/ig/gadgets/file/112375570725200634982/pe.png"
      author_location="where"
      author_affiliation="here"
      title_url="http://www.snapfish.com/"
      directory_title="demo of poster editor for snapfish"
      width="396" height="515"
      scrolling="true">
  <Require feature="flash" />
  <Require feature="tabs" />
  <Require feature="dynamic-height" />
  <Require feature="setprefs" />
  <Require feature="analytics" />
  
  <Locale messages="http://hosting.gmodules.com/ig/gadgets/file/112375570725200634982/demo_ALL_ALL.xml"/>
  <Locale lang="zh-cn" messages="http://hosting.gmodules.com/ig/gadgets/file/112375570725200634982/demo_zh_CN_ALL.xml"/>
 
</ModulePrefs>

<UserPref name="width" display_name="Editor Width" default_value="380" datatype="string"/>
<UserPref name="height" display_name="Editor Height" default_value="280" datatype="string"/>
<UserPref name="promotionItems" display_name="Promotions" default_value="3" datatype="string"/>
<UserPref name="displayOtherFlash" display_name="Display Other Flash?" default_value="false" datatype="bool"/>
<UserPref name="newFlashURL" display_name="New Flash URL" default_value="http://doc.examples.googlepages.com/Trevor-speak.swf" datatype="string"/>
<UserPref name="newFlashVars" display_name="New Flash Vars" default_value="ip=http://16.157.65.120:8080/webdav/poster&amp;albumId=178586243" datatype="string"/>

<Content type="html">
<![CDATA[

<div id="flash">
  <center><h3>__MSG_struggle__<br>just drag the pictures into poster, click to choose layout. have a try now!</h3></center>
  <div id="flashcontainer" style="text-align: center;">Flash Example For SnapFish</div> 
  <center><h3>easy and funny, isn't it?!<br>==>>> <a target="_blank" href="http://www.snapfish.com">get a free formal account and find more right now!</a></h3></center>
</div>

<div id="promotion">
  promotion actions come here<br>
  <b><span id="promotionitems"></span></b>&nbsp;promotion actions by default
  <hr>
  <div id="pitems">Loading...</div>
  <table width=100%><tr><td align="right"><a target=_blank href="http://groups.google.com/group/Google-Gadgets-API/">More>>></a></table>
</div>


<script type="text/javascript">
	var stop_loading=0;
	var is_loading=0;
	var h_timeout;
  	var cur_loading_str="";

        function init(){
          showLoadingMessage();
          createTabs();
          playFlash();
          stop_loading=1;
        }
        var tabs = new _IG_Tabs(__MODULE_ID__, "SnapFishGadget");

        function createTabs(){
          tabs.addTab(  "PosterEditor Demo"
                      , "flash"
                      );

          //var promotion_Id = tabs.addTab("Promotions","promotion");
          tabs.addTab("__MSG_tab_title_promotions__", "promotion",getPromotionFeed);
          _gel("promotionitems").innerHTML= prefs.getInt("promotionItems");

          tabs.setSelectedTab(0);

        }

        function showLoadingMessage(){
           if(stop_loading==0){
             if(is_loading==0) my_str = "&nbsp;" + cur_loading_str + ".";
             if(is_loading==1) my_str = "&nbsp;" + cur_loading_str + "..";
             if(is_loading==2) my_str = "&nbsp;" + cur_loading_str + "...";
             if(is_loading==3) my_str = "&nbsp;" + cur_loading_str + "";
             is_loading++;
             is_loading = is_loading%4;
             _gel("flashcontainer").innerHTML = "Loading" + my_str;
             h_timeout = setTimeout(showLoadingMessage,500);
           }else is_loading=0;
        }

        var prefs = new _IG_Prefs(__MODULE_ID__);
        function playFlash(){
          var flashUrl = "http://16.157.67.22:8080/webdav/poster/PostEditor.swf";
          var flashVars = "ip=http://16.157.67.22:8080/webdav/poster&albumId=178586243";

          var width = prefs.getInt("width");
          var height = prefs.getInt("height");
          var useOtherFlash = prefs.getBool("displayOtherFlash");
          var newFlashUrl = prefs.getString("newFlashURL");
          if (useOtherFlash  && newFlashUrl!=null){
            flashUrl = newFlashUrl;
          }
          var newFlashVars = prefs.getString("newFlashVars");
          if (newFlashVars!=null){
            flashVars = newFlashVars;
          }

          _IG_EmbedFlash(flashUrl, 'flashcontainer' 
                          ,{swf_version: 6
                            ,id: 'posteditor4snapfish'
                            ,width: width,height: height
                            ,allowScriptAccess:'sameDomain'
                            ,quality:'high',bgcolor:'#869ca7'
                            ,wmode: 'window',align:'middle'
                            ,play:true,loop:false
                            ,flashvars:flashVars
                           }
                          );
          _IG_AdjustIFrameHeight();
        }
        
        _IG_RegisterOnloadHandler(init);
  
        function getPromotionFeed(){
          var entries = prefs.getInt("promotionItems");
          if (entries==null || entries<0 || entries>9) entries=9;

          var showdate=true;
          var summary=false;

          _IG_FetchFeedAsJSON(
                "http://groups.google.com/group/Google-Gadgets-API/feed/rss_v2_0_msgs.xml"
                ,function(feed) {    
                  if (feed == null){ 
                    alert("There is no data.");
                    return;
                }
  
                // Start building HTML string that will be displayed in gadget.
                var html = "";
                // Access the fields in the feed
                html += "<div><b>" + feed.Title + "</b></div>";
                html += "<div>" + feed.Description + "</div><br>";
                // Access the data for a given entry
                if (feed.Entry) {
                    html += "<ol>"
                    for (var i = 0; i < feed.Entry.length; i++) {
                      html += "<li>"
                           +   "<a target='_blank' href='" + feed.Entry[i].Link + "'>"
                           +   feed.Entry[i].Title
                           +   "</a> ";
                      if (showdate==true){
                         // The feed entry Date field contains the timestamp in seconds
                         // since Jan. 1, 1970. To convert it to the milliseconds needed
                         // to initialize the JavaScript Date object with the correct date, 
                         // multiply by 1000.
                         var milliseconds = (feed.Entry[i].Date) * 1000;   
                         var date = new Date(milliseconds);      
                         html += date.toLocaleDateString();
                         html += " ";
                         html += date.toLocaleTimeString();
                      }          
                      if (summary==true) {
                         html += "<br><i>" + feed.Entry[i].Summary + "</i>";
                      }
                      html += "</li>";
                    }
                    html+="</ol>";
                }

                  _gel("pitems").innerHTML = html;

                  // The rest of the function parameters, which are optional: the number
                  // of entries to return, and whether to return summaries.
                }
                , entries
                , summary
            );
        }
        
	_IG_Analytics("UA-3150632-1", "/demopostereditor");
</script>
]]>
</Content>
</Module>


