<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs height="250" width="320" scrolling="false" scaling="false"
author="MyFavoriteECards.Com"
author_affiliation="CJRMTechnology LLC."
author_location="Reston, VA"
title="MyFavoriteECards: My Personal ECards"
title_url="http://www.MyFavoriteECards.com/googlegadget.aspx"
directory_title="Free Animated ECards"
author_email="rick@MyFavoriteECards.com"
render_inline="optional"
description="Animated ECards for birthdays holidays or anytime. Displays weekly reminders and favorite ecards."
category="funandgames" category2="lifestyle"
screenshot="http://www.MyFavoriteECards.com/GGadget/scrnshot1.png"
thumbnail="http://www.MyFavoriteECards.com/GGadget/Thumb1.png" >
<Require feature="flash" />
</ModulePrefs>
<UserPref name="sECBAEmail" display_name="ECBA member e-mail" required="false" default_value="* your membership email only"/>
<UserPref name="bUseFavorites" display_name="Favorite ECards?" datatype="bool" default_value="true"/>
<UserPref name="bUseFeatured" display_name="Featured ECards?" datatype="bool" default_value="true"/>


<Content type="html">
<![CDATA[




<center>
<table style=" width : 320px; height: 250px; padding:0 0 0 0; border-collapse:collapse; background-image: url(http://www.myfavoriteecards.com/GGadget/images/ggbkg1.png); background-repeat:no-repeat;" id="Table1">
<tr>
<td valign="top" align="right" style="height:26px; color: #0000ff; font-family: Arial, sans-serif; font-size: 10px;">
<span id="Span2" style="cursor: pointer; color: #ffffff; font-family: Arial, sans-serif; font-size: 12px;" onclick="popupECBASite();">More ECards&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span>
<input id="varECard" type="hidden" value="0" />
<table style="padding:0 0 0 0; border-collapse:collapse;" id="Table2">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top" colspan="2">
<!-- Main table-->
<table id="mainTable" style="width:320px; height:210px; padding:0 0 0 0; border-collapse:collapse; " >

<tr>
<td style="width:57px;" ></td>
<td style="height:30px; text-align:center; color: #ffffff; font-family: Arial, sans-serif; font-size: 12px;">
Click on an ECard to Preview
</td>
<td style="width:57px;" ></td>
</tr>
<tr>
<td valign="top" align="center" style="width:57px;" >
<input type="image" src="http://www.myfavoriteecards.com/GGadget/images/SrchBtn_First.png" alt="" onclick="pageFirst()" />

<input type="image" src="http://www.myfavoriteecards.com/GGadget/images/SrchBtn_Prev.png" alt="" onclick="pagePrev()" /></td>
<td valign="top" align="center" style="width:206px;">
<div id="thumbs_div"></div>
</td>
<td valign="top" align="center" style="width:57px;" >
<input type="image" src="http://www.myfavoriteecards.com/GGadget/images/SrchBtn_Last.png" alt="" onclick="pageLast()" />

<input type="image" src="http://www.myfavoriteecards.com/GGadget/images/SrchBtn_Next.png" alt="" onclick="pageNext()" />
</td>
</tr>
<tr>
<td valign="top"  colspan="3" style="text-align:center;">
</td>
</tr>
<tr>
<td valign="top"  colspan="3" style="font-family:Arial;font-size:10px;color:#f0f0ff;text-align:center">
<div id="content_div">
</div>
</td>
</tr>

</table>
<!-- Viewer table-->
<table id="set" style="display: none; width : 320px; height: 210px; padding:0 0 0 0; border-collapse:collapse; font-size:10px; font-family: verdana;">
<tr>
<td style="text-align:center; height: 17px">
<span id="Span1" style="cursor: pointer; color: #ffffff; font-family: Arial, sans-serif; font-size: 12px;" onclick="toggleSettings();">Show ECards</span>
</td>
</tr>

<tr>
<td style="text-align:center">
<div id="flashcontainer">
<br /><br />&nbsp;&nbsp;
<strong>
<span id="SpanPF" style="cursor: pointer; color: #ff0000; font-family: Arial, sans-serif; font-size: 12px;" onclick="popupGetFlash();">
Please Click here<br />to upgrade your Flash Player
</span>
</strong>
<br /><br />
</div>
</td>
</tr>
<tr>
<td align="center">
<span id="Span4" style="width:100px;cursor: pointer; color: #ffffff; font-family: Arial, sans-serif; font-size: 10px;" onclick="popupFullSize();">View full size</span>
</td>
</tr>
<tr>
<td align="center">
<input type="image" src="http://www.myfavoriteecards.com/GGadget/images/GGSendECard.png" alt="" onclick="sendECard()" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>




<script type="text/javascript">

var fileList = new Array();
var descList = new Array();
var Reminders = new Array();
var listLength = 0;


var thumbIndex = 0;
var maxIndex = 0;
var endIndex = 0;
var numThumbs = 4; //number of thumbs to view
var thumbStep = 4; //number of thumbs to scroll
var maxReminders =4; //dont show more than this many reminders for the week

function displayReminders(){
var maxlen = Reminders.length;
if(maxlen >maxReminders){
maxlen=maxReminders;
}
var prefHTML = "<span style='color:#ffffff;'><strong>Reminders for this week are:</strong></span></br />";
for (var i = 0; i < maxlen ; i++) {
var val = Reminders[i]+"<br />";
prefHTML += val;
}
if(Reminders.length>0)
_gel('content_div').innerHTML = prefHTML;
}
                    
                    
function displayThumbs(){

 // _gel('content_div').innerHTML = "in display thumbs";
                    
maxIndex = fileList.length;
endIndex = thumbIndex + numThumbs;
var thumbHTML = "<table>";

j=0;
for (var i = thumbIndex; i < endIndex; i++) {
if(j % 2 == 0){
thumbHTML += "<tr>";
}
thumbHTML += "<td style='width:102px;height:54px;'>";
var file = fileList[i];
var desc = descList[i];
var onclk = "onclick=' showECard(" + j + ")'";
thumbHTML += "<input type='image' src='http://www.myfavoriteecards.com/ecardstorage/cards/"+file+".jpg' "+onclk+" title='"+desc+"' />";
// thumbHTML += "&nbsp";
thumbHTML += "</td>";
if(!(j % 2 == 0)){
thumbHTML += "</tr>";
}
j++;
}
thumbHTML += "</table>";
_gel('thumbs_div').innerHTML = thumbHTML;
  
 

}

function stopFlash()
{
var url="http://www.myfavoriteecards.com/GGadget/StopAll.swf";
previewFlash(url);
}
function previewFlash(card) {

var cardSpec = fileList[card];
var url = "http://www.myfavoriteecards.com/ECardStorage/Cards/"+cardSpec+".swf";

// alert(cardSpec+" card="+card+" thumbIdx="+thumbIndex+" url="+url);

_IG_EmbedFlash(url, "flashcontainer", {
swf_version: 6,
id: "flashid",
width: 304,
height: 160 }
);
}
function pageFirst(){
thumbIndex = 0;
displayThumbs();
}
function pagePrev(){
thumbIndex -= thumbStep;
if(thumbIndex <0)
thumbIndex = 0;
displayThumbs();
}
function pageNext(){
thumbIndex +=thumbStep;
if(thumbIndex > maxIndex-numThumbs)
thumbIndex = maxIndex-numThumbs;
displayThumbs();
}
function pageLast(){
thumbIndex = maxIndex-numThumbs;
displayThumbs();
}
function showECard(thumbID)
{
var cardID = thumbID + thumbIndex;
document.getElementById("varECard").setAttribute("value", cardID);
//Force to Preview screen
document.getElementById("mainTable").style.display = "none";
document.getElementById("set").style.display = "inline";

previewFlash(cardID);

return true;
}

function toggleSettings(){
/* If setting screen is on - change to main table screen */
if (document.getElementById("set").style.display == "inline") {
document.getElementById("mainTable").style.display = "inline";
document.getElementById("set").style.display = "none";
stopFlash();
/* Else - change to settings screen */
}else{
document.getElementById("mainTable").style.display = "none";
document.getElementById("set").style.display = "inline";
}
}
function openResultWindow__MODULE_ID__(properties_str){
var ecba = ("about:blank","ecba",properties_str);
ecba.focus();
return true;
}
function popupGetFlash()
{
var url = "http://www.macromedia.com/software/flash/about/";
var ecba = window.open(url,"ecba","width=800,height=600,resizeable=1, scrollbars=1");
ecba.focus();
}
function sendECard()
{
toggleSettings(); //go to thumbs so that the current ecard stops playing else conflicts audio w. full view
var cardID = document.getElementById("varECard").getAttribute("value" );
var cardSpec = fileList[cardID];
// pass-> ?card=/ECardStorage/Cards/Anytime/12.swf
var ecba = window.open("http://www.myfavoriteecards.com/ComposeECardWizard.aspx?card=/ECardStorage/Cards/"+cardSpec+".swf","ecba","width=900,height=650, menubar=1, resizable=1, scrollbars=1");
ecba.focus();
}
function popupFullSize()
{
toggleSettings(); //go to thumbs so that the current ecard stops playing else conflicts audio w. full view
var cardID = document.getElementById("varECard").getAttribute("value");
var cardSpec = fileList[cardID];
var demoSpec = " &msg=Your personal message appears here &to=Your Friend &from=Your Name &greet=To &end=From";
var ecba = window.open("http://www.myfavoriteecards.com/ECardPreViewer.aspx?swf=http://www.myfavoriteecards.com/ECardStorage/Cards/"+cardSpec+".swf","MFEC","width=640,height=450,resizable=1, scrollbars=1");
ecba.focus();
}
function popupECBASite()
{
var ecba = window.open("http://www.myfavoriteecards.com","ecba","width=900,height=650,menubar=1,resizable=1, scrollbars=1");
ecba.focus();
}
  
  
function getXMLData2() {
// XML ecard data from GGadget\GGEcardList
var url = "http://www.myfavoriteecards.com/GGadget/GGECardList.xml";

_IG_FetchXmlContent(url, function (response) {
if (response == null || typeof(response) != "object" || response.firstChild == null) {
_gel('content_div').innerHTML = "<i>Cant retrieve Featured ECards.</i>";
return;
}

// Get a list of the <card> element nodes in the file
var itemList = response.getElementsByTagName("card");

// Loop through all <card> nodes

var lastItem = fileList.length;

for (var i = 0; i < itemList.length ; i++) {
var item = itemList[i];
// now we have the item object, time to get the contents
var file = item.getElementsByTagName("file")[0].firstChild.nodeValue;
var desc = item.getElementsByTagName("description")[0].firstChild.nodeValue;
fileList[i+lastItem]=file;
descList[i+lastItem]=desc;
//_gel('content_div').innerHTML = file;

}

displayThumbs();
});
}


 
function getXMLData() {

// XML ecard data 
var url = "http://www.myfavoriteecards.com/ECardStorage/FeaturedECards.xml";
//var url = "http://www.myfavoriteecards.com/GGadget/FeaturedECards.xml";

 

_IG_FetchXmlContent(url, function (response) {
if (response == null || typeof(response) != "object" || response.firstChild == null) {
//if (response == null  ) {
_gel('content_div').innerHTML = "<i>Cant retrieve Featured ECards.</i>";
return;
}
else
{
  var iL = response.getElementsByTagName("ECardDataList");
  var len = iL.length;
// _gel('content_div').innerHTML = "<i>Read "+len+ " Featured ECards.</i>";
}

 


// Get a list of the <card> element nodes in the file
var itemList = response.getElementsByTagName("ECardDataList");
// _gel('content_div').innerHTML = "<i>ItemList "+itemList.length+ " Featured ECards.</i>";
// Loop through all <card> nodes

var lastItem = fileList.length;
var klen = 0;
// _gel('content_div').innerHTML = "<i>LastItem "+lastItem+ " Featured ECards.</i>";

 
for (var i = 0; i < itemList.length-2 ; i++) {
  var file = "";
  var desc = "";

  var item = itemList[i];
// now we have the item object, time to get the contents
  try{
  file = item.getElementsByTagName("file")[0].firstChild.nodeValue;
  desc = item.getElementsByTagName("info")[0].firstChild.nodeValue;
  }
  catch(err){
   //  _gel('content_div').innerHTML = "ERROR: "+err;
  }
  if(file != null && file != ""){
    fileList[i+lastItem]=file;
    if(desc != null){
        descList[i+lastItem]=desc;
    }
    else{
        descList[i+lastItem]="";
    }
    klen++;
  }
   
  
}
//  _gel('content_div').innerHTML = "<i>Read "+klen+ " Featured ECards.</i>";
  pageFirst();
  displayThumbs();


});
}
 
function getXMLFavoritesData(ecbaEmail) {

// This is the favorites layout in http://www.myfavoriteecards.com/ecardstorage/membersdata/rickmini@cox.net.xml
// <favorites>
// <ECardFavoriteEntry>
// <ECardPath>Holiday/5</ECardPath>

// XML ecard data
var url = "http://www.myfavoriteecards.com/ECardStorage/MembersData/"+ecbaEmail+".xml";

_IG_FetchXmlContent(url, function (response) {
if (response == null || typeof(response) != "object" || response.firstChild == null) {
_gel('content_div').innerHTML = "<i>Cant retrieve ECard Favorites for "+ecbaEmail+"</i>";
// document.getElementById("ID_DebugText").value += "Cant retrieve ECard Favorites for "+ecbaEmail;
return;
}
// document.getElementById("ID_DebugText").value += " URL="+url+" ";
// Get a list of the <card> element nodes in the file
var itemList = response.getElementsByTagName("ECardFavoriteEntry"); //("favorites");
// Loop through all <card> nodes
var listLength = itemList.length;


var lastItem = fileList.length;
// document.getElementById("ID_DebugText").value += " lastItem1="+lastItem+" favlen="+itemList.length+" ";

for (var i = 0; i < itemList.length ; i++) {
var item = itemList[i];
var file = item.getElementsByTagName("ECardPath")[0].firstChild.nodeValue;
fileList[i+lastItem]=file;
descList[i+lastItem]="Your Favorite # "+(i+1);
// document.getElementById("ID_DebugText").value += " "+file;

}
// document.getElementById("ID_DebugText").value += " lastItem="+lastItem+" favlen="+itemList.length+" ";

displayThumbs();
});
}

function getXMLReminderData(ecbaEmail,thismonth,thisday) {

// This is the favorites layout in http://www.myfavoriteecards.com/ecardstorage/membersdata/rickmini@cox.net.xml
// <calendar>
// <CalendarEntry>
// <name>New Year</name>
// <month>1</month>
// <day>1</day>

// XML ecard data
var url = "http://www.myfavoriteecards.com/ecardstorage/membersdata/"+ecbaEmail+".xml";

_IG_FetchXmlContent(url, function (response) {
if (response == null || typeof(response) != "object" || response.firstChild == null) {
_gel('content_div').innerHTML = "<i>Cant retrieve ECard Calendar for "+ecbaEmail+"</i>";
// document.getElementById("ID_DebugText").value += "Cant retrieve ECard Calendar for "+ecbaEmail;
return;
}
// document.getElementById("ID_DebugText").value += " URL="+url+" ";
// Get a list of the <card> element nodes in the file
var itemList = response.getElementsByTagName("CalendarEntry");
// Loop through all <card> nodes
var listLength = itemList.length;

var j=0;
for (var i = 0; i < itemList.length ; i++) {
var item = itemList[i];
var name="";
var month=0;
var day=0;
try{
name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
month = item.getElementsByTagName("month")[0].firstChild.nodeValue;
day = item.getElementsByTagName("day")[0].firstChild.nodeValue;
if(thismonth==month && (day >= thisday && day <= (thisday+7)) )
{
var centry = name + " : "+month+"/"+day+" ";
if( name != null && name != "" && centry != ""){
Reminders[j++]=centry;
}
}
}//try
catch(err){
//alert(err);
}
}

// alert("Reminders:"+Reminders);
displayReminders();
});
}

function runIT(){
// Get the user preferences
var user_prefs = new _IG_Prefs(__MODULE_ID__);
var ecbaEmail = user_prefs.getString("sECBAEmail");
var bUseFeatured = user_prefs.getBool("bUseFeatured");
var bUseFavorites = user_prefs.getBool("bUseFavorites");


var bIsMember = (ecbaEmail.indexOf("*") == -1);

 
  
if(bUseFeatured){
getXMLData();
}

if(bUseFavorites && bIsMember){
getXMLFavoritesData(ecbaEmail);
}

//Date today and reminders
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();

if(bIsMember){
getXMLReminderData(ecbaEmail, month, day);
}
 
  
}

_IG_RegisterOnloadHandler(runIT);
</script>

]]>
</Content>
</Module>




