<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs scrolling="true" scaling="true" title="Bulletin Messenger" thumbnail="http://current.bulletinwireless.net/widgets/Docking.png" author="Bulletin Wireless" author_affiliation="Bulletin Wireless" screenshot="http://current.bulletinwireless.net/widgets/igoogle.png" description="Bulletin Messenger provides simple two-way SMS messaging from your igoogle page, desktop and any handset worldwide.    Currently only avaliable for Internet Explorer and Firefox on Windows" height="350" width="470">
<MayRequire type="browser" value="Firefox"/>
<MayRequire type="browser" value="Internet Explorer"/>
<MayRequire type="Platform" value="Windows"/>
<Require feature="setprefs" />
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="userId" display_name="userId"/>
<UserPref name="hash" display_name="hash"/>
<Content type="html"><![CDATA[
<style type="text/css">

  #sendmessages {
    position:absolute;
    height:317px;
    width: 232px;
    background-image: url('http://current.bulletinwireless.net/widgets/WidgetFront.png');
    background-repeat: no-repeat;
    z-index:-99;
  }

  #test {
    position:absolute;
    height:317px;
    width:232px;
    background-image: url('http://current.bulletinwireless.net/widgets/WidgetBack.png');
    background-repeat: no-repeat;
    z-index:-99;
  }

  .HelpButton {
    position:absolute;
    cursor: pointer;
    left:193px;
    top:25px;
    width:25px;
    height:25px;
    z-index:1;
  }

  #e {
    height:317px;
    width: 232px;
  }

  #Version {
    position:absolute;
    left:15px;
    top:25px;
    width:80px;
    height: 15px;
    font-weight:bold;
    font-family: Verdana;
    font-size: 7pt;
    color: white;
    z-index:1;
    text-align:left;
  }

  #SendButton {
    position:absolute;
    left:193px;
    top:145px;
    width:25px;
    height:25px;
    z-index:1;
  }

  #UserName {
    position:absolute;
    left:18px;
    top:95px;
    width:160px;
    height:15px;
    font-family: Verdana;
    font-size: 8pt;
    color: white;
    z-index:1;
    text-align:left;
  }

  #UserNameEdit {
    background-image: url('http://current.bulletinwireless.net/widgets/EditField.png');
    background-repeat: no-repeat;
    border: none;
    font-family: Verdana;
    font-size: 12pt;
    position:absolute;
    overflow: hidden;
    left:18px;
    top:110px;
    width:167px;
    height:35px;
    padding-top:4px;
    padding-left:4px;
    z-index:1;
    text-align:left;
  }

  #Password {
    position:absolute;
    left:18px;
    top:150px;
    width:160px;
    height:15px;
    font-family: Verdana;
    font-size: 8pt;
    color: white;
    z-index:1;
    text-align:left;
  }

  #PasswordEdit {
    background-image: url('http://current.bulletinwireless.net/widgets/EditField.png');
    background-repeat: no-repeat;
    border: none;
    font-family: Verdana;
    font-size: 12pt;
    position:absolute;
    overflow: hidden;
    left:18px;
    top:165px;
    width:167px;
    height:35px;
    padding-top:4px;
    padding-left:4px;
    z-index:1;
    text-align:left;
  }

  #AccountBalance {
    position:absolute;
    left:18px;
    top:205px;
    width:160px;
    height:15px;
    font-family: Verdana;
    font-size: 8pt;
    color: white;
    z-index:1;
    text-align:left;
  }

  #balance {
    background-image: url('http://current.bulletinwireless.net/widgets/ShortEditField.png');
    background-repeat: no-repeat;
    border: none;
    font-family: Verdana;
    font-size: 10pt;
    position:absolute;
    overflow: hidden;
    left:18px;
    top:220px;
    width:90px;
    height:35px;
    padding-top:10px;
    padding-left:4px;
    z-index:1;
    text-align:left;
  }

  .getButton {
    position:absolute;
    left:127px;
    top:270px;
    width:55px;
    height:27px;
    z-index:1;
  }

  .button {
    cursor:pointer;
  }

  #TopupButton {
    position:absolute;
    left:115px;
    top:225px;
    width:25px;
    height:25px;
    z-index:1;
  }

  #DoneButton {
    position:absolute;
    left:45px;
    top:270px;
    width:55px;
    height:27px;
    z-index:1;
    cursor: pointer;
  }  

  .recentcont {
    background-image: url('http://current.bulletinwireless.net/widgets/ListBox.png');
    background-repeat: no-repeat;
    position:absolute;
    left:18px;
    top:211px;
    width:168px;
    height:80px;
    z-index:1;
  }

  .recent {
    position:absolute;
    left:23px;
    top:215px;
    width:158px;
    height:71px;
    font-family: Verdana;
    font-weight: normal;
    font-size: 7pt;
    overflow-y: auto;
    overflow-x: hidden;
    z-index:1;
    text-align:left;
  }

  .Mobile {
    background-image: url('http://current.bulletinwireless.net/widgets/EditField.png');
    background-repeat: no-repeat;
    border: none;
    font-family: Verdana;
    font-size: 12pt;
    position:absolute;
    overflow: hidden;
    left:18px;
    top:70px;
    width:167px;
    height:35px;
    padding-top:4px;
    padding-left:4px;
    z-index:1;
    text-align:left;
  }

  .message {
    background-image: url('http://current.bulletinwireless.net/widgets/TextEditField.png');
    background-repeat: no-repeat;
    position:absolute;
    left:18px;
    top:125px;
    width:168px;
    height:66px;
    font-family: Verdana;
    font-size: 8pt;
    padding-top:3px;
    padding-left:3px;
    border:none;
    z-index:1;
    text-align:left;
  }


  #InfoButton {
    position:absolute;
    left:197px;
    top:282px;
    width:15px;
    height:15px;
    z-index:1;
    cursor: pointer;
  }

  #RefreshButton {
    position:absolute;
    left:193px;
    top:246px;
    width:25px;
    height:25px;
    z-index:1;
    cursor: pointer;
  }

  #ListToggle {
    position:absolute;
    left:193px;
    top:211px;
    width:25px;
    height:25px;
    z-index:1;
    cursor: pointer;
  }

  .recentpopup {
    position:absolute;
    left:23px;
    top:214px;
    width:165px;
    height:85px;
    visibility:hidden;
    font-family: Verdana;
    font-weight: normal;
    font-size: 8pt;
    color: darkblue;
    overflow-y: auto;
    overflow-x: auto;
    background-color: #f8fafc;
    border-style: solid;
    border-width: 1px;
    border-color: #b6d4fe;
    z-index:1;
    text-align:left;
  }

  #AddressHeading {
    position:absolute;
    left:18px;
    top:55px;
    width:160px;
    height:15px;
    font-family: Verdana;
    font-size: 7pt;
    color: white;
    z-index:1;
    text-align:left;
  }

  #MessageHeading {
    position:absolute;
    left:18px;
    top:110px;
    width:160px;
    height:15px;
    font-family: Verdana;
    font-size: 7pt;
    color: white;
    z-index:1;
    text-align:left;
  }

  #ListHeading {
    position:absolute;
    left:18px;
    top:196px;
    width:160px;
    height:15px;
    font-family: Verdana;
    font-size: 7pt;
    z-index:1;
    color: white;
    text-align:left;
  }

  .Alert {
    position: absolute;
    left: 10px;
    top:215px;
    width:170px;
    background: #fff6bf url('http://current.bulletinwireless.net/widgets/exclamation.png') center left no-repeat;
    text-align: left;
    padding: 5px 20px 5px 20px;
    border: 2px solid #ffd324;
    font-family: Verdana;
    font-size: 9pt;
    color: darkblue;
    z-index:99;
  }

  .Status {
    position: absolute;
    left: 10px;
    top:215px;
    width:170px;
    background: #f8fafc url('http://current.bulletinwireless.net/widgets/information.png') center left no-repeat;
    text-align: left;
    padding: 5px 20px 5px 20px;
    border: 2px solid #b6d4fe;
    font-family: Verdana;
    font-size: 9pt;
    color: darkblue;
    z-index: 99;
  }

</style>
<script language="Javascript">
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/

/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
  
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */

/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}

/*
* Perform a simple self-test to see if the VM is working
*/
function sha1_vm_test()
{
  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}

/*
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function core_sha1(x, len)
{
  /* append padding */
  x[len >> 5] |= 0x80 << (24 - len % 32);
  x[((len + 64 >> 9) << 4) + 15] = len;

  var w = Array(80);
  var a = 1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d = 271733878;
  var e = -1009589776;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;
    var olde = e;

    for(var j = 0; j < 80; j++)
    {
      if(j < 16) w[j] = x[i + j];
      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
      safe_add(safe_add(e, w[j]), sha1_kt(j)));
      e = d;
      d = c;
      c = rol(b, 30);
      b = a;
      a = t;
    }

    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
    e = safe_add(e, olde);
  }
  return Array(a, b, c, d, e);

}

/*
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d)
{
  if(t < 20) return (b & c) | ((~b) & d);
  if(t < 40) return b ^ c ^ d;
  if(t < 60) return (b & c) | (b & d) | (c & d);
  return b ^ c ^ d;
}

/*
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t)
{
  return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
  (t < 60) ? -1894007588 : -899497514;
}

/*
* Calculate the HMAC-SHA1 of a key and some data
*/
function core_hmac_sha1(key, data)
{
  var bkey = str2binb(key);
  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);

  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
  return core_sha1(opad.concat(hash), 512 + 160);
}

/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
* Convert an 8-bit or 16-bit string to an array of big-endian words
* In 8-bit function, characters >255 have their hi-byte silently ignored.
*/
function str2binb(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
  bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
  return bin;
}

/*
* Convert an array of big-endian words to a string
*/
function binb2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
  str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
  return str;
}

/*
* Convert an array of big-endian words to a hex string.
*/
function binb2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
    hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
  }
  return str;
}

/*
* Convert an array of big-endian words to a base-64 string
*/
function binb2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
    | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
    | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}

</script>
<script language="Javascript">
var BrowserDetect = {
  init: function () {
    this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
    this.version = this.searchVersion(navigator.userAgent)
    || this.searchVersion(navigator.appVersion)
    || "an unknown version";
    this.OS = this.searchString(this.dataOS) || "an unknown OS";
  },
  searchString: function (data) {
    for (var i=0;i<data.length;i++) {
      var dataString = data[i].string;
      var dataProp = data[i].prop;
      this.versionSearchString = data[i].versionSearch || data[i].identity;
      if (dataString) {
        if (dataString.indexOf(data[i].subString) != -1)
          return data[i].identity;
        }
      else if (dataProp)
      return data[i].identity;
    }
  },
  searchVersion: function (dataString) {
    var index = dataString.indexOf(this.versionSearchString);
    if (index == -1) return;
    return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
  },
  dataBrowser: [
  { string: navigator.userAgent,
    subString: "OmniWeb",
    versionSearch: "OmniWeb/",
    identity: "OmniWeb"
  },
  {
    string: navigator.vendor,
    subString: "Apple",
    identity: "Safari"
  },
  {
    prop: window.opera,
    identity: "Opera"
  },
  {
    string: navigator.vendor,
    subString: "iCab",
    identity: "iCab"
  },
  {
    string: navigator.vendor,
    subString: "KDE",
    identity: "Konqueror"
  },
  {
    string: navigator.userAgent,
    subString: "Firefox",
    identity: "Firefox"
  },
  {
    string: navigator.vendor,
    subString: "Camino",
    identity: "Camino"
  },
  { // for newer Netscapes (6+)
    string: navigator.userAgent,
    subString: "Netscape",
    identity: "Netscape"
  },
  {
    string: navigator.userAgent,
    subString: "MSIE",
    identity: "Explorer",
    versionSearch: "MSIE"
  },
  {
    string: navigator.userAgent,
    subString: "Gecko",
    identity: "Mozilla",
    versionSearch: "rv"
  },
  { // for older Netscapes (4-)
    string: navigator.userAgent,
    subString: "Mozilla",
    identity: "Netscape",
    versionSearch: "Mozilla"
  }
  ],
  dataOS : [
  {
    string: navigator.platform,
    subString: "Win",
    identity: "Windows"
  },
  {
    string: navigator.platform,
    subString: "Mac",
    identity: "Mac"
  },
  {
    string: navigator.platform,
    subString: "Linux",
    identity: "Linux"
  }
  ]
};
BrowserDetect.init();

var OS="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OS="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OS="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OS="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OS="Linux";



var RSSRequestObject
var contentstate
var previousdatein=""
var Backend
var n
var x="160";
var balancetext=""
var balance=""
var balancesub=""
var accounttype=""
var password="";
var hash="";
var userId="";
var status
var mobile
var message
var timer=""
var currency
var fullmessage = new Array();
var mobilenumbers = new Array();
var pref = new _IG_Prefs();
var browser= BrowserDetect.browser;
if(browser=="Explorer"){
  document.write("<div id='e'>");
}  
  
function loadmain(){
  document.getElementById("sendmessages").style.display="none";
  contentstate=1;
 
  if(browser != "Explorer" && browser != "Firefox" && browser != "" && browser != "undefined" || OS!="Windows"){
    showAlert("ErrorBack","Sorry this browser or OS is not currently supported. try using Firefox or Internet Explorer on Windows",10000);
  }

  if(pref.getString("userId") != "" && pref.getString("hash") !="") {
    document.getElementById("inputuserId").value=pref.getString("userId");
    document.getElementById("inputpassword").value=pref.getString("hash");
    main();
  }

  if(browser=="Explorer"){
    document.write("</div>");
  }

  if(browser=="Explorer"){
    document.getElementById("test").style.position="absolute";
    document.getElementById("test").style.height="317px"
    document.getElementById("test").style.width="232px";
    document.getElementById("sendmessages").style.position="absolute";
    document.getElementById("sendmessages").style.height="317px";
    document.getElementById("sendmessages").style.width="232px";
    document.getElementById("test").style.zIndex="2";
    document.getElementById("sendmessages").style.zIndex="2";
  }

  if(browser=="Safari"){
    document.getElementById("test").style.zIndex="2";
    document.getElementById("sendmessages").style.zIndex="2";
  }
};

//loads main gadget
function main(){
    if(browser != "Explorer" && browser != "Firefox" && browser != "" && browser != "undefined" || OS!="Windows"){
    showAlert("ErrorBack","Sorry this browser or OS is not currently supported. try using Firefox or Internet Explorer on Windows",10000);
    prefs();
    }
  
  userId = document.getElementById("inputuserId").value;
  
  if(document.getElementById("inputpassword").value != pref.getString("hash")) {
    hash = b64_sha1(document.getElementById("inputuserId").value+b64_sha1(document.getElementById("inputpassword").value));
  }
  if(userId != pref.getString("userId") || document.getElementById("inputpassword").value != pref.getString("hash")) {
    pref.set("userId",userId);
    pref.set("hash",hash);
    previousdatein=""
  }

  document.getElementById("inputpassword").value=pref.getString("hash");
  document.getElementById("sendmessages").style.display="Block";
  document.getElementById("test").style.display="none";
  RSSRequest();
};

function prefs() {
  document.getElementById("sendmessages").style.display="none";
  document.getElementById("test").style.display="Block";

  if(balancetext == 'On Account' || balancetext =='No Account') {
    document.getElementById("balance").style.color="black";
    document.getElementById("balance").innerHTML =' '+ balancetext;
    document.getElementById("topup").style.display="none"
  }else if(accounttype="PRE"){
    document.getElementById("topup").style.display="Block";
    document.getElementById("balance").style.color="black";

    if(lowbalance=="true") {
      document.getElementById("balance").style.color="red";
      document.getElementById("balance").innerHTML=' '+balancetext;//dollarsign+''+balances;
    }else if(lowbalance=="false"){
      document.getElementById("balance").style.color="black";
      document.getElementById("balance").innerHTML=' '+balancetext;//+dollarsign+''+balances;
    }
  }
};

function ReqChange() {
  var newmessage;

  if (RSSRequestObject.readyState != 4) {
    //showAlert("Status","Connecting ",30000);
    //window.setTimeout('showAlert("ErrorBack","Unable to connect at this time please try again later or click the help button for more information on this issue",10000);prefs();RSSRequestObject.abort()',30000);
  }

  if(RSSRequestObject.readyState==4){
    if(RSSRequestObject.status == 401){
      balancetext="";
      balancesub="";
      document.getElementById("recent").innerHTML = "";
      showAlert("ErrorBack","Incorrect Username and Password ",7000);
      prefs();
    }
  }

  //If http request is ready
  if (RSSRequestObject.readyState==4 && RSSRequestObject.status==200 ||RSSRequestObject.status==0) {
    // if data is valid
    if (RSSRequestObject.responseText.indexOf('invalid') == -1){
      var balancenum;
      if(browser=="Firefox"){
        try {
          netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        } catch (e) {
        }
      }

      if(window.ActiveXObject){
        var myDocument = new ActiveXObject("Microsoft.XMLDOM");
        myDocument.loadXML(RSSRequestObject.responseText);
      }else{
        var myDocument = new DOMParser().parseFromString(RSSRequestObject.responseText, 'text/xml');
      }


      var node = myDocument.getElementsByTagName('rss').item(0);

      // Get Channel information
      var channel = node.getElementsByTagName('channel').item(0);

      if (channel==null){
        document.getElementById("recent").innerHTML ='<font size=1 color=blue><center>User not Bulletin messenger</center></font><br/>';
      }else{

      var title = channel.getElementsByTagName('title').item(0).firstChild.data;
      var link = channel.getElementsByTagName('link').item(0).firstChild.data;
      var items = channel.getElementsByTagName('item');

      if(browser=="Explorer"){
        var account = channel.getElementsByTagName('account:account').item(0);

        if(account!=null){
          accounttype = account.getElementsByTagName('account:accountType').item(0).firstChild.data;
          currency = account.getElementsByTagName('account:currencyType').item(0).firstChild.data;
        }else if(account==null){
          accounttype="";
        }

        //checks if the account is prepaid and displays balance if prepaid else displays invoiced
        if (accounttype == "PRE"){
          balance = account.getElementsByTagName('account:formattedBalance').item(0).firstChild.data;
          balancetext = balance;
          var lowbalances = account.getElementsByTagName("account:lowBalance").item(0).firstChild.data;
          lowbalance = lowbalances

        }else if(accounttype == "INV"){
          balancetext='On Account';
        }else{
          balancetext='No Account';
        }

      }else{
        var account = channel.getElementsByTagName('account').item(0);
        
        if(account!=null){
          accounttype = account.getElementsByTagName('accountType').item(0).firstChild.data;
          currency = account.getElementsByTagName('currencyType').item(0).firstChild.data;
        }else if(account==null){
          accounttype="";
        }

        //checks if the account is prepaid and displays balance if prepaid else displays invoiced
        if (accounttype == "PRE"){
          balance = account.getElementsByTagName('formattedBalance').item(0).firstChild.data;
          balancetext = balance;
          var lowbalances = account.getElementsByTagName("lowBalance").item(0).firstChild.data;
          lowbalance = lowbalances
        }else if(accounttype == "INV"){
          balancetext='On Account';
        }else{
          balancetext='No Account';
        }
      }

      //checks if there are any messages if not displays no messages else displays messages
      if(items.length == 0 || channel.getElementsByTagName('item') == null){
        document.getElementById("recent").innerHTML ='<font size=1 color=blue><center>No Messages</center></font><br/>';
      }else{
        document.getElementById("recent").innerHTML="";
        //var messagetitle = items[0].getElementsByTagName('message:message').item[0];
        //var messagedate = messagetitle.getElementsByTagName('message:messageDate').item[0].firstChild.data;

        //checks if there are any new received messages
        if(contentstate == 1){
          var messagein = messagedate;
          if(previousdatein!= ""){
            if(previousdatein == messagein) {
              newmessage = 1;
            }else{
              newmessage = 2;
            }
          }else if(previousdatein = ""){
            newmessage = 1;
          }
          previousdatein = messagein;
        }else{
          newmessage=1;
        }


        var content= new Array();
        var mobilenumber = new Array();
        document.getElementById("recent").innerHTML="";
        var sender="";
        
        for (n=0;n<items.length;n++) {
          var messagetitle, recipient, messagedate, date, time, datetime, partialmessage, messagetype, statustext;
          if(browser=="Explorer" ||browser=="Opera" || browser=="Safari"){
            //loops through each item in the feed
            messagetitle=items[n].getElementsByTagName('message:message').item(0);
            recipient = messagetitle.getElementsByTagName('message:recipient').item(0);
            sender = messagetitle.getElementsByTagName('message:displayname').item(0).firstChild.data;
            messagedate = messagetitle.getElementsByTagName('message:messageDate').item(0).firstChild.data;
            date = messagedate.substring(0,10);
            time = messagedate.substring(12,16);
            datetime = date + ' ' + time;
            message = messagetitle.getElementsByTagName('message:body').item(0).firstChild.data;
            partialmessage = message.substring(0,22);
            mobile = messagetitle.getElementsByTagName('message:displayaddress').item(0).firstChild.data;
            status = recipient.getElementsByTagName('message:statuscode').item(0).firstChild.data;
            messagetype = messagetitle.getElementsByTagName('message:type').item(0).firstChild.data;
            statustext="";
          }else{
            //loops through each item in the feed
            messagetitle=items[n].getElementsByTagName('message').item(0);
            recipient = messagetitle.getElementsByTagName('recipient').item(0);
            sender = messagetitle.getElementsByTagName('displayname').item(0).firstChild.data;
            messagedate = messagetitle.getElementsByTagName('messageDate').item(0).firstChild.data;
            date = messagedate.substring(0,10);
            time = messagedate.substring(12,16);
            datetime = date + ' ' + time;
            message = messagetitle.getElementsByTagName('body').item(0).firstChild.data;
            partialmessage = message.substring(0,22);
            mobile = messagetitle.getElementsByTagName('displayaddress').item(0).firstChild.data;
            status = recipient.getElementsByTagName('statuscode').item(0).firstChild.data;
            messagetype = messagetitle.getElementsByTagName('type').item(0).firstChild.data;
            statustext="";
          }

          //Checks status of a message and assigns status text
          if(contentstate == 2 && messagetype == "out"){
            switch(status) {
              case "INF":
              statustext = "Not Sent (No Funds)";
              break;

              case "RCV":
              statustext = "Received";
              break;

              case "NUR":
              statustext = "Unreachable";
              break;

              case "NRCV":
              statustext = "Not Received";
              break;

              case "QTS":
              statustext = "Queued";
              break;

              case "REJ":
              statustext = "Rejected";
              break;

              case "SNT":
              statustext = "Sent";
              break;
        
              case "ERR":
              statustext = "Error";
              break;

              default:
              statustext="unknown";
          }
        }

        if(messagetype == "reply"){
          fullmessage[n] = '<b>From:</b> ' + sender + '<br/>' + '<b>Date:</b> ' +datetime + '<br/>' + '<b>Message:</b> ' + message+ '<br/>';
        }else{
          fullmessage[n] = '<b>To:</b> ' + sender + '<br/>' + '<b>Date:</b> ' +datetime + '<br/>' + '<b>Status:</b> ' +statustext + '<br/>' + '<b>Message:</b> '+ message;
        }

        mobilenumbers[n]= sender;

        //checks to see if the message length is less than or equal to 1 line; displays full message if less than or equal to else displays 1 line
        if (message.length <=22){
          content[n]= "<b id=s onclick=window.setTimeout('messagedetail(fullmessage["+n+"])','300'); ondblclick=fillmessagenumber(mobilenumbers["+n+"]);><b id=b style=font-size:7pt;color:blue;font-weight:normal>" +sender+ "</b> <b id=u style=font-size:7pt;color:blue;font-weight:normal>" +datetime+ "</b></br>&nbsp;<b id=i style=font-size:7pt;color:green;font-weight:normal>&nbsp;"+partialmessage+"</b></b></br/>";
        } else {
          content[n]= "<b id=s ondblclick=fillmessagenumber(mobilenumbers["+n+"]); onclick=window.setTimeout('messagedetail(fullmessage["+n+"])','300');><b id=b style=font-size:7pt;color:blue;font-weight:normal>" +sender+ "</b> <b id=u style=font-size:7pt;color:blue;font-weight:normal>" +datetime+ "</b></br>&nbsp;<b id=i style=font-size:7pt;color:green;font-weight:normal>&nbsp;"+partialmessage+"...</b></b><br/>";
        }

        document.getElementById("recent").innerHTML+=content[n];
        document.getElementById("i").id=n+1000;
        document.getElementById("b").id=n+10000;

        if(status == "RCV" || statustext == "unknown" || statustext==""){
          document.getElementById(n+1000).style.color="green";
        }else{
          document.getElementById(n+1000).style.color="red";
        }

        // displays full message
        document.getElementById("s").id=n;
        document.getElementById(n).style.cursor="pointer";

        if(newmessage ==2){
          showAlert("Status","You have new messages",7000);
        }
        }
      }
      }
    }
  }
}

//Popup for full message details
function messagedetail(message,n) {
  document.getElementById("recentpopup").style.visibility = "visible";
  document.getElementById("recent").style.visibility="hidden";
  document.getElementById("recentpopup").innerHTML = message;
};

//puts mobile number in the destination number field
function fillmessagenumber(number) {
  document.getElementById("innermobile").value = number;
};


function RSSRequest() {
  if(browser != "Explorer" && browser != "Firefox"){
    balancetext="";
    balancesub="";
    showAlert("ErrorBack","Sorry this browser or OS is not currently supported. try using Firefox or Internet Explorer on Windows",10000);
    prefs();
  }
  if(browser=="Firefox"){
    try {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    } catch (e) {
    }
  }

  var userIdreq = pref.getString("userId");
  var hashreq = pref.getString("hash");

  Backend = 'https://www.bulletinmessenger.net/api/2/sms/list';
  Backend += "?format=rss";
  Backend += "&userId="+urlEncode(userIdreq);
  Backend += "&password="+urlEncode(hashreq);

  checkingstate();

  if(RSSRequestObject!=null){
    RSSRequestObject=null;
  }

  if(pref.getString("userId")!="" && pref.getString("hash")!=""){
    if(RSSRequestObject==null){
      if (window.XMLHttpRequest){ // try to create XMLHttpRequest
        RSSRequestObject = new XMLHttpRequest();
        if(browser=="Firefox"){
          try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
          } catch (e) {
          }
        }
        if (!window.XMLHttpRequest) {
          window.XMLHttpRequest = function() {
            try {
              return RSSRequestObject = new ActiveXObject('MSXML2.XMLHTTP.3.0');
            }
            catch (ex) {
              return null;
            }
          }
        }
      }

      if(window.ActiveXObject){ // if ActiveXObject use the Microsoft.XMLHTTP
        RSSRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    if(RSSRequestObject !=null){

      // Prepare the request
      RSSRequestObject.open("GET", Backend , true,userIdreq,hashreq);

      // Set the onreadystatechange function
      RSSRequestObject.onreadystatechange = ReqChange;

      //stop IE from caching the request
      if(browser=="Explorer"){
        RSSRequestObject.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2005 00:00:00 GMT");
      }

      // Send
      RSSRequestObject.send(null);
    }
  }else{
    balancetext="";
    balancesub="";
    showAlert("ErrorBack","Incorrect Username and Password "+blank,7000);
    prefs();
  }
}

//addition to url for received messages
function buildin() {
  Backend += "&type=reply";
};

//addition to url for out messages
function buildout() {
  Backend += "&type=out";
};

function checkingstate() {
  if(contentstate==1) {
    buildin();
  } else if(contentstate==2){
    buildout();
  }
};

//Style changes for toggling between received and sent messages
function checkcontentstate() {
  if(contentstate==1) {
    contentstate=2;
    buildout();
    document.getElementById("toggle").title="View Received messages";
    document.getElementById("refresh").title="Refresh Outbox";
    document.getElementById("ListHeading").innerHTML="Sent Messages:";
    document.toggle.src=picurl+"OutButton.png";
    RSSRequest();
  }else if(contentstate==2) {
    contentstate=1;
    buildin();
    document.getElementById("toggle").title="View Sent Messages";
    document.getElementById("refresh").title="Refresh Inbox";
    document.getElementById("ListHeading").innerHTML="Received Messages:";
    document.toggle.src="http://current.bulletinwireless.net/widgets/InButton.png";
    RSSRequest();
  }
};

//set the max length to 160 characters
function maxlength() {
  var messagetext;
  messagetext = document.getElementById("MessageEditInputField").innerHTML;
  var maxlength = messagetext.substring(0,160);
  var length = document.getElementById("MessageEditInputField").value.length;
  var charleft= 160-length;
  document.getElementById("MessageEditInputField").innerHTML = maxlength;
  if(charleft>1){
    document.getElementById("MessageHeading").innerHTML = "Message Text ("+charleft+" Chars):"
  }else if(charleft==1){
    document.getElementById("MessageHeading").innerHTML = "Message Text ("+charleft+" Char):"
  }else{
    document.getElementById("MessageHeading").innerHTML = "Message Text (0 Chars):"
  }
};

//Toggle button mouseover and onclick event
function toggle_over() {
  if(contentstate==2){
    document.toggle.src="http://current.bulletinwireless.net/widgets/OutButtonHL.png";
  }else if(contentstate==1) {
    document.toggle.src="http://current.bulletinwireless.net/widgets/InButtonHL.png";
  }
};

var picurl = "http://current.bulletinwireless.net/widgets/";

function pic(name,src) {
  document[name].src="http://current.bulletinwireless.net/widgets/"+src;
}

//Toggle button mouseout event
function toggle_normal() {
  if(contentstate==2){
    document.toggle.src="OutButton.png";
  }else if(contentstate==1) {
    document.toggle.src="InButton.png";
  }
};

//Shows balance when mouseover message and recipient feilds
function messageover(id,message) {
  if (balancetext != "" && balancetext != "On Account" && balancetext != "No Account") {
    document.getElementById(id).title="Your balance is "+ balancetext
  }else{
    document.getElementById(id).title=message;
  }
};

//hides the full message popup
  function hidemessagedetail() {
  document.getElementById("recentpopup").style.visibility = "hidden";
  document.getElementById("recent").style.visibility="visible";
};

//Alert floating divs for status and error messages
function showAlert(type, msg, timeout) {
  var alertWin = null;

  if (type == "Status") {
    alertWin = document.getElementById("StatusAlert");
  }
  else if (type == "Error") {
    alertWin = document.getElementById("ErrorAlert");
  }
  else if (type == "ErrorBack") {
    alertWin = document.getElementById("ErrorAlertBack");
  }
  if (alertWin) {
    alertWin.innerHTML = msg;
    window.setTimeout("hideAlert()", timeout);
    alertWin.style.display = "Block";
  }
};

//Hide Alerts
function hideAlert() {
  var alertWin = document.getElementById("StatusAlert");
  alertWin.style.display = 'none';
  alertWin = document.getElementById("ErrorAlert");
  alertWin.style.display = 'none';
  alertWin = document.getElementById("ErrorAlertBack");
  alertWin.style.display = 'none';
};

//URL for making a payment
function payment() {
  window.open('https://www.bulletinonline.net/user/myAccount.do','_blank');
};

//URL for signing up through the widget promotion
function signups(){
  window.open('http://www.bulletinonline.net/promo/igoogle','_blank');
};

function urlEncode(str) {
  str = escape(str);
  str = str.replace(new RegExp('\\+', 'g'), '%2B');
  return str.replace(new RegExp('%20', 'g'), '+');
};

function changesend(){
  if(parseFloat(balancetext) <= 0.00 && balancetext!= 'invoiced' && balancetext != ''){
    showAlert("Status","Insufficient funds please topup to start sending messages",7000);
  }else if(RSSRequestObjectsend.status==400 || RSSRequestObjectsend.status==401 || RSSRequestObjectsend.status==403 || RSSRequestObjectsend.status==500 || RSSRequestObjectsend.status==200){
    showAlert("Status",RSSRequestObjectsend.statusText,7000);
  }else if (RSSRequestObjectsend.status==1223 || RSSRequestObjectsend.status==204){
    showAlert("Status","Message sent...",7000);
    document.getElementById("innermobile").value="";
    if(contentstate==2) {
      RSSRequest();
    }
  }else if (RSSRequestObjectsend.status==0) {
    showAlert("Error","Incorrect username/password",7000);
  }else{
    showAlert("Error",RSSRequestObjectsend.statusText+RSSRequestObjectsend.status,7000);
  }
};

//send messages
function sendmessages() {

  try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
  } catch (e) {
  }

  var userId = pref.getString("userId");
  var hash = pref.getString("hash");

  if (window.XMLHttpRequest){ // try to create XMLHttpRequest
    RSSRequestObjectsend = new XMLHttpRequest();
  }

  if(window.ActiveXObject){ // if ActiveXObject use the Microsoft.XMLHTTP
    RSSRequestObjectsend = new ActiveXObject("Microsoft.XMLHTTP");
  }

  var recipient = document.getElementById("innermobile").value;
  var message = document.getElementById("MessageEditInputField").value;

  //Create URL for Http Request
  var url = "https://www.bulletinmessenger.net/api/1/sms/out";
  url += "?to=" +urlEncode(recipient);
  url += "&body=" +urlEncode(message);
  url += "&userId="+urlEncode(userId);
  url += "&password="+urlEncode(hash);

  RSSRequestObjectsend.open("POST",url, true,userId,hash);

  // Set the onreadystatechange function
  RSSRequestObjectsend.onreadystatechange = changesend;

  // Send
  RSSRequestObjectsend.send('');
};

function checkEnter(event){
  var characterCode;
  e = event
  characterCode = e.keyCode

  if(characterCode == 13){
    main();
    return false
  }else{
    return true
  }
};

_IG_RegisterOnloadHandler(loadmain)
</script>

  <div id="sendmessages">
    <div id="FrontHelpButton" class="HelpButton">
      <img src="http://current.bulletinwireless.net/widgets/HelpButtonHL.png" name="frontgadgethelp" width="25" height="25"
      onclick="window.open('http://docs.bulletinwireless.net/display/public/Widgets+and+Gadgets+-+User+Guide','_blank')";
      onmousedown="pic('frontgadgethelp','HelpButton.png')"
      onmouseup="pic('frontgadgethelp','HelpButtonHL.png')" title="Help"/>
    </div>

    <div style="position:absolute; z-index:1; left:18px;top:55px;width:160px;height:15px;font-family: Verdana;font-size: 7pt;color: white; text-align:left;">
      Destination Phone Number:
    </div>
    
    <div class="Mobile" title="Enter the destination Phone Number" id="recipients"
    onmouseover="messageover('recipients','Destination Phone Number')">
      <input id="innermobile" type='text'
      style="border: none; border-width: 0px; width:157px; height:25px;font-family: Verdana; font-size: 12pt;" />
    </div>

    <div id='MessageHeading'>
      Message Text (160 Chars):
    </div>


    <div id="StatusAlert" class='Status' style="display:none;"
    onclick='hideAlert();'>
    </div>

    <div id="ErrorAlert" class='Alert' style="display: none;"
    onclick='hideAlert();'>
    </div>

    <div class="message" title="Enter you Message Text" id="message"
    onmouseover="messageover('message','Message Text')">
      <textarea id="MessageEditInputField" rows="5" cols="20"
      style="border:none; width:160px; height:59px; overflow:auto; font-family: Verdana;"
      onkeyup="maxlength()" contenteditable=true ></textarea>
    </div>

    <div id='SendButton'>
      <img class="button" title="Send Message" id="send" name="send" src="http://current.bulletinwireless.net/widgets/SendButtonHL.png" border="0"
      onmousedown="pic('send','SendButton.png')"
      onmouseup="pic('send','SendButtonHL.png')"
      onclick="sendmessages()"/>
    </div>

    <div id='ListHeading'>
      Received Messages
    </div>

    <div id="recentcont" class="recentcont">
    </div>

    <div id="recent" class="recent">
      <!--DIV for in/out box message list-->
    </div>

    <div id="recentpopup" class="recentpopup" onclick="hidemessagedetail();">
    </div>

    <div id='ListToggle'>
      <img class="button" name="toggle" id="toggle" title="View Sent Messages" src="http://current.bulletinwireless.net/widgets/InButtonHL.png" border="0" align="top"
      onclick="checkcontentstate()"
      onmousedown="toggle_normal()"
      onmouseup="toggle_over()" />
    </div>

    <div id='RefreshButton'>
      <img class="button" title="Refresh Inbox" name="refresh" src="http://current.bulletinwireless.net/widgets/RefreshButtonHL.png" border="0" align="bottom" id="refresh"
      onmousedown="pic('refresh','RefreshButton.png')"
      onmouseup="pic('refresh','RefreshButtonHL.png')"
      onclick="RSSRequest()"/>
    </div>

    <div id='InfoButton'>
      <img class="button" title="Information and Preferences" name="info" src="http://current.bulletinwireless.net/widgets/InfoButtonHL.png" border="0" align="top" id="info"
      onmousedown="pic('info','InfoButton.png')"
      onmouseup="pic('info','InfoButtonHL.png')"
      onclick="prefs()"/>
    </div>
  </div>

  <div id="test">
    <div id="Version">
      v1.0
    </div>

    <div id="BackHelpButton" class="HelpButton">
      <img class="button" src="http://current.bulletinwireless.net/widgets/HelpButtonHL.png" name="backgadgethelp" width="25" height="25"
      onclick="window.open('http://docs.bulletinwireless.net/display/public/Widgets+and+Gadgets+-+User+Guide','_blank')";
      onmousedown="pic('backgadgethelp','HelpButton.png')"
      onmouseup="pic('backgadgethelp','HelpButtonHL.png')" title="Help"/>
    </div>

    <div id='UserName'>
      Username:
    </div>

    <div id='UserNameEdit'>
      <input type=text id="inputuserId" style="border: none; border-width: 0px; width:157px; height:25px;
      font-family: Verdana; font-size: 12pt;" onkeypress="checkEnter(event)"/>
    </div>

    <div id='Password'>
      Password:
    </div>

    <div id='PasswordEdit'>
      <input style="border: none; border-width: 0px; width:157px; height:25px;
      font-family: Verdana; font-size: 12pt;" type="password" id="inputpassword" onkeypress="checkEnter(event)"/>
    </div>

    <div id='AccountBalance'>
      Balance:
    </div>

    <div class="balance" id="balance">
      <!-- DIV to display balance -->
    </div>

    <div id="ErrorAlertBack" class='Alert' style="display: none;"
    onclick='hideAlert();'>
    </div>

    <div id='TopupButton'>
      <img id="topup" onclick="payment()" name="topup" src="http://current.bulletinwireless.net/widgets/DollarButtonHL.png" border="0" class="button" title="Add credit to your account"
      onmousedown="pic('topup','DollarButton.png')"
      onmouseup="pic('topup','DollarButtonHL.png')"
      />
    </div>

    <div id='DoneButton'>
      <img title="Update preferences" id="done" class="button" src="http://current.bulletinwireless.net/widgets/DoneButton.png" name="done" border="0"
      onclick="main();"
      onmousedown="pic('done','DoneButtonHL.png')"
      onmouseup="pic('done','DoneButton.png')" />
    </div>

    <div class='getButton'>
      <img id="signup" onclick="signups()" src="http://current.bulletinwireless.net/widgets/SignupButton.png" border="0" name="signup" title="Signup for SMS services" class="button"
      onmousedown="pic('signup','SignupButtonHL.png')"
      onmouseup="pic('signup','SignupButton.png')"
      />
    </div>

  </div>

]]></Content>
</Module>






