//declare public variables
var widthChanged = false;
var isLoaded = false;
var maxFeedID = 0;
var doRefresh = false;    //Refresh every time you sync with third party APIs
var lMy = false;
var lFollow = false;
var curPageLabels = false;
var magicJohnson = false;
var newLabel = false;
var curRow = 1;
var staticContent = false; //about, info e.t.c
var oPrivacy = 0;
var gb_labelName = ''; //collects label name-when clicked (in case of MY,FOLLOW,LABEL is empty)
//var lb_right_enable = 1;
var refTimer;
var toRemove = [];

var lblAjax = new WADJAX('Labels', {});
var twiAjax = new WADJAX('Labels', {statusBar: false});

//for page Labs
var labAjax = new WADJAX('Lab', {statusBar: false});
//for search
var searchQuery = true; // handle search query
var jkeyword = '';
var currentView = {type: '', label: 0, page: 1, rows: 10, filter: 0, hide: '', exclude: '', minID: 0};
var usersRight = {on: 1, of: 1};

var composeView = [
      {cType: "Post", lType: ""}, // 0 - Empty
      {cType: "Post", lType: "Custom"}, // 1 - Custom
      {cType: "SMS", lType: "SMS"},  // 2 - SMS
      {cType: "Email", lType: "Email"}, // 3 - Email
      {cType: "Post", lType: "Trash"}, // 4 - Trash
      {cType: "Post", lType: "Starred"}, // 5 - Starred
      {cType: "Post", lType: "Contacts"}, // 6 - Contacts
      {cType: "Post", lType: "Friends"}, // 7 - Friends
      {cType: "Post", lType: "Help"}, // 8 - Help
      {cType: "Post", lType: "Notes"}, // 9 - Notes
      {cType: "Post", lType: "Location"}, // 10 - Location
      {cType: "Gifts", lType: "Gifts"}, // 11 - Gifts
      {cType: "Post", lType: "Media"}, // 12 - Media
      {cType: "Post", lType: "Twitter"}, // 13 - Twitter
      {cType: "Post", lType: "YouTube"}, // 14 - YouTube
      {cType: "Post", lType: "Theme"}, // 15 - Theme
      {cType: "Post", lType: "Wadja Team"}, // 16 - Wadja Team
      {cType: "Post", lType: ""}, // 17 - Empty
      {cType: "Post", lType: "Flickr"}, //18 - Flickr
      {cType: "Post", lType: "Vimeo"}, //19 - Vimeo
      {cType: "DLR", lType: "DLR"}, //20 - Delivery Reports
      {cType: "Post", lType: "Credits"} //21 - Credits
    ];

      var wUser = {
          detailsID: 0,
          wadjaID: null,
          feeds: [],  // Items / Rows / Feeds
          DDL: {My: [], Follow: [], Every: [], All: []},
          labels: [], // Label Name
          labelsEvery: [], // Label Name
          follow: [], // Users Followed
          myfollow: [], // Viewers Followed
          users: [],  // Users on Left
          hidden: [], // Users not to show in stream

          exclude: {My: [], All: [], Follow: [], Every: [], Current: []}, // Labels not to show

          loadLabelFeeds: function() {
              Wadjebug.Log('wUser.loadLabelFeeds');
              this.startTimer();
              wadja.showLoading("Loading Labels", "Still Loading...", 5);
              this.exclude.Current = eval('this.exclude.' + currentView.type + '.toString();');
              var tmpArr1 = (currentView.type == "Every" ? this.DDL.My : this.exclude.Current);
              var tmpArr2 = [];
              for (var i = 0; i < tmpArr1.length; i++) {
                  if (currentView.type == "My" || currentView.type == "Follow") {
                      tmpArr2.push(tmpArr1[i]);
                  }
                  else if (currentView.type == "Every") {
                      if (("," + this.exclude.Every.toString() + ",").indexOf("," + tmpArr1[i].id + ",") == -1) {
                          tmpArr2.push(tmpArr1[i].id);
                      }
                  }
              }
              currentView.exclude = tmpArr2.toString();
              while (currentView.exclude.indexOf(',') == 0)
                  currentView.exclude = currentView.exclude.substring(1);

              currentView.minID = 0;
              lblAjax.send('Feed', this.detailsID, JSON.encode(currentView), wUser.CB_loadLabelFeeds);
          },

          checkNewItems: function() {
              Wadjebug.Log('wUser.checkNewItems');
              this.startTimer();
              currentView.minID = maxFeedID;
              $('aNewFeeds').addClass('dnd');
              twiAjax.send('Feed', this.detailsID, JSON.encode(currentView), wUser.CB_loadLabelFeeds);
          },

          countNewItems: function() {
              Wadjebug.Log('wUser.countNewItems');

              if (top.location.hash.toLowerCase().replaceAll('#', '').split('/')[0] == 'search')
                  return; // if Search - No Updates              

              this.startTimer();
              currentView.minID = maxFeedID;
              twiAjax.send('Count', this.detailsID, JSON.encode(currentView), wUser.CB_Count);
              twiAjax.send('MarkRead', "", function(res) {updateCounter(res.value);});

          },
          loadApplyDDL: function(idApply) {
              return "";
              Wadjebug.Log('wUser.loadApplyDDL');
              var sd = $('ulTemp').innerHTML;

              while (sd.indexOf('#target#') >= 0)
                  sd = sd.replaceAll('#target#', idApply);

              sd = sd.replaceAll('#labels/create', '#labels/create/' + idApply);

              return sd;
          },

          loadLabelsDDL: function(lblSearch, lblList, oType, RowID) {
              //return;
              Wadjebug.Log('wUser.loadLabelsDDL');
              //if (lblList != null) lblList = lblList;

              lblSearch = lblSearch.trim();

              if (oType.toLowerCase() != "apply") {
                  RowID = 1;
              }
              if (typeof RowID == "undefined") {
                  RowID = curRow;
              }

              curRow = RowID;

              //$('ulLbl' + oType).empty();
              //$('ulTemp').empty();

              var __lbl = "";
              var __tmp = "";

              //if (lblSearch != "") {
              var j = 0;
              for (var i = 0; i < lblList.length; i++) {
                  if (lblList[i].name.toLowerCase().trim().indexOf(lblSearch.toLowerCase()) == 0) {
                      var lblName = "<b>" + lblList[i].name.substring(0, lblSearch.length) + "</b>" + lblList[i].name.substring(lblSearch.length);
                      var lblLI = new DomElement('li');

                      var isChecked = ("," + currentView.exclude + ",").indexOf("," + lblList[i].id + ",") == -1;

                      if (lblList[i].permissions.system && false) {
                          //var lblA = new DomElement('a', { 'href': '#labels/' + oType + '/' + lblList[i].id + '/' + RowID, 'html': '<input id="chkLabelMy_' + lblList[i].id + '"' + (lblList[i].isLocation ? ' class="chkLoc"' : '') + '" type="checkbox" ' + (isChecked ? 'checked="checked"' : '') + ' onclick="return wUser.filterFeeds(' + lblList[i].id + ', this.checked, \'My\'); return false;" class="vam" /> ' + lblName, 'title': lblList[i].name.replaceAll("amp;", ""), 'class': (lblList[i].isLocation ? 'lblLocation' : 'lblSystem') }); //CHK-st
                          var lblA = new DomElement('a', {'href': '#labels/' + oType + '/' + lblList[i].id + '/' + RowID + (oType == 'MyUpdateLocation' || oType == 'MyUploadPhotos' ? '/' + lblList[i].name : ''), 'html': lblName, 'title': lblList[i].name.replaceAll("amp;", ""), 'class': (lblList[i].isLocation ? 'lblLocation' : 'lblSystem')});
                          lblLI.AC(lblA);

                          var lblIMG = new DomElement('img', {'src': '/images/nav/lock.png', 'alt': 'System Label', 'title': 'System Label'});
                          lblLI.AC(lblIMG);
                      }
                      else {
                          //var lblA = new DomElement('a', { 'href': '#labels/' + oType + '/' + lblList[i].id + '/' + RowID, 'html': '<input id="chkLabelMy_' + lblList[i].id + '" type="checkbox" ' + (isChecked ? 'checked="checked"' : '') + ' onclick="return wUser.filterFeeds(' + lblList[i].id + ', this.checked, \'My\'); return false;" class="vam" /> ' + lblName, 'title': lblList[i].name.replaceAll("amp;", "") }); //CHK-st
                          var lblA = new DomElement('a', {'href': '#labels/' + oType + '/' + lblList[i].id + '/' + RowID + (oType == 'MyUpdateLocation' || oType == 'MyUploadPhotos' ? '/' + lblList[i].name : ''), 'html': lblName, 'title': lblList[i].name.replaceAll("amp;", "")});
                          lblLI.AC(lblA);
                      }

                      __lbl += lblLI.toHTML();
                      j++;
                  }
              }

              if (j > 0 && oType == 'MyUpdateLocation') {
                  var lblLI = new DomElement('li');

                  var lblA = new DomElement('a', {'href': '/user/new.aspx?label=0&name=' + lblSearch, 'html': '"<b>' + lblSearch + '</b>" (create new)', 'rel': 'facebox'});
                  lblLI.AC(lblA);

                  __lbl += lblLI.toHTML();
              }

              if (j == 0) {

                  var lblLI = new DomElement('li');
                  if (detailsID > 0) {
                      var lblA = new DomElement('a', {'href': '/user/new.aspx?label=0&name=' + lblSearch, 'html': '"<b>' + lblSearch + '</b>" (create new)', 'rel': 'facebox'});
                      lblLI.AC(lblA);
                  }
                  else {
                      lblLI.AC('Join to create label');
                  }
                  __lbl += lblLI.toHTML();

              }

              if (oType == 'MyUpdateLocation' || oType == 'MyUploadPhotos')
                  getIFrameDocument('frame_file').getElementById('ulLbl' + oType).innerHTML = __lbl;
              else
                  $('ulLbl' + oType).innerHTML = __lbl;

              myFacebox = new mooFacebox();

          },

          filterFeeds: function(chkBoxID, toWhat, oType) {
              Wadjebug.Log('wUser.filterFeeds');
              var isFound = false;

              if (oType == "My") {
                  for (var i = 0; i < this.exclude.My.length; i++) {
                      if (this.exclude.My[i] == chkBoxID) {
                          this.exclude.My.splice(i, 1);
                          isFound = true;
                      }
                  }
                  if (!isFound)
                      this.exclude.My.push(chkBoxID);
              } else if (oType == "Follow") {
                  for (var i = 0; i < this.exclude.Follow.length; i++) {
                      if (this.exclude.Follow[i] == chkBoxID) {
                          this.exclude.Follow.splice(i, 1);
                          isFound = true;
                      }
                  }
                  if (!isFound)
                      this.exclude.Follow.push(chkBoxID);
              } else if (oType == "Every") {
                  this.exclude.Every = [];

                  $('ulLblEvery').getElements('input[type=checkbox]').each(function(el) {
                      if (el.checked) {
                          wUser.exclude.Every.push(el.id.replaceAll('chkLabelEvery_', ''));
                      }
                  });
              }

              window.setTimeout('$("chkLabel' + oType + '_' + chkBoxID + '").checked = ' + toWhat, 50);

              currentView.type = oType;
              if (oCall_Backs.length == 0) {
                  oCall_Backs.push('wUser.loadLabelFeeds();');
              }

              return false;
          },


          parseFeeds: function(tmpMinID) {
              Wadjebug.Log('wUser.parseFeeds');

              if (tmpMinID == 0)
                  if ($('dvFeeds'))
                  $('dvFeeds').empty();

              //eval("this.loadLabelsDDL('', this.DDL." + currentView.type + ", '" + currentView.type + "');");

              try {
                  if (this.feeds.length == 0 && tmpMinID == 0)
                      this.doPaging(1, 1);
              }
              catch (err) {
                  //do something when error occurs
                  $('debug_0').set('html', err);
              }

              try {
                  var strFeeds = $('dvFeeds').innerHTML;

                  // Static
                  var dvFeedRow = new DomElement('div', {'class': 'fItem fItemSlide [#myFeed]', 'id': 'fItem_[#id]'});

                  var dvFeedPic = new DomElement('div', {'class': 'fPhoto'});
                  var dvFeedPicA = new DomElement('a', {'target': '[#picTrg]', 'href': '[#picHrf]', 'class': 'b_r'});
                  var dvFeedPicIMG = new DomElement('img', {'width': '55px', 'height': '55px', 'id': 'imgPr_[#id]', 'src': '[#picUrl]'});
                  dvFeedPicA.AC(dvFeedPicIMG);
                  dvFeedPic.AC(dvFeedPicA);

                  var dvFeedCnt = new DomElement('div', {'class': 'fContent'});
                  var dvFeedCntBR = new DomElement('div', {'class': 'b_r'});
                  var dvFeedCntDiv = new DomElement('div', {'html': '[#inbox]'});
                  dvFeedCntDiv.AC("[#cnt]");
                  var dvFeedCntSm = new DomElement('div', {'class': 'lblSmall', 'html': '[#dtAgo]'});
                  var dvFeedCntCnt = new DomElement('div', {'class': 'lblContainer', 'html': '[#labels]'});
                  dvFeedCntBR.AC(dvFeedCntDiv);
                  dvFeedCntBR.AC(dvFeedCntSm);
                  dvFeedCntBR.AC(dvFeedCntCnt);
                  dvFeedCnt.AC(dvFeedCntBR);

                  var dvFeedBtns = new DomElement('div', {'class': 'fButtons', 'id': 'fButtons_[#id]'});
                  //var dvFeedBtnsAct = new DomElement('a', { 'class': 'top-lnk top-arr [#actDND]', 'rel': '[#id]', 'href': 'javascript: void(0);', 'html': f_actions + '<span><img alt="ddl" src="/images/trans.gif" /></span>', 'events': { 'click': function(e, el) { var parID = $('fButtons_' + el.rel); parID.addClass('fButtonON'); $('ulTemp').innerHTML = $('ddlActions').innerHTML.replaceAll('[#RowID]', el.rel); dropdownmenu(el, e, 'ulTemp', 0, 0, "$('" + parID.id + "').removeClass('fButtonON');"); } } });
                  //var dvFeedBtnsSpc = new DomElement('span', { 'class': 'padL5', 'html': '&nbsp;' });
                  var dvFeedBtnsAct = new DomElement('a', {'class': 'applyStar [#actDND]', 'html': '&nbsp;', 'href': '#labels/star/[#id]', 'id': 'hrfStar[#id]'});
                  var dvFeedBtnsTr = new DomElement('a', {'class': 'applyTrash [#actDND]', 'html': '&nbsp;', 'href': '#labels/trash/[#id]'});
                  var dvFeedBtnsSpc = new DomElement('span', {'class': 'padL5', 'html': '&nbsp;'});
                  var dvFeedBtnsApp = new DomElement('a', {'class': 'top-link-apply [#appDND] marR3', 'rel': '[#id]', 'href': 'javascript: void(0);', 'html': '<span class=\"applyLabel\">' + f_apply + '</span><span class=\"applyLabelArrow\">&nbsp;</span>', 'events': {'click': function(e, el) {var parID = $('fButtons_' + el.rel);parID.addClass('fButtonON');$('txtLabelsApply').value = "";wUser.loadLabelsDDL($('txtLabelsApply').value, wUser.DDL.My, 'Apply', el.rel);dropdownmenu(el, e, 'ddLblApply', 0, 0, "$('" + parID.id + "').removeClass('fButtonON');");}}});
                  //var dvFeedBtnsHide = new DomElement('a', { 'class': 'top-link-apply [#appDND]', 'rel': '[#id]', 'href': 'javascript: void(0);', 'html': '<span id=\"ActiveHide\" class=\"applyLabel\">' + f_hide + '</span><span id=\"ActiveArrow\" class=\"applyLabelArrow\">&nbsp;</span>', 'events': { 'click': function(e, el) { var parID = $('fButtons_' + el.rel); $('ActiveHide').addClass('activeHide'); $('ActiveArrow').addClass('dnd'); parID.addClass('fButtonON'); dropdownmenu(el, e, 'ddLblHide', -133, -3, "$('" + parID.id + "').removeClass('fButtonON');$('ActiveHide').removeClass('activeHide'); $('ActiveArrow').removeClass('dnd');"); } } });

                  //dvFeedBtns.AC(dvFeedBtnsHide);
                  dvFeedBtns.AC(dvFeedBtnsApp);
                  dvFeedBtns.AC(dvFeedBtnsSpc);
                  dvFeedBtns.AC(dvFeedBtnsAct);
                  dvFeedBtns.AC(dvFeedBtnsTr);

                  dvFeedRow.AC(dvFeedPic);
                  dvFeedRow.AC(dvFeedCnt);
                  dvFeedRow.AC(dvFeedBtns);

                  //-HIDE
                  hideElements = GetHideElements();
                  document.getElementById("testSpan").innerHTML = hideElements;

                  for (var i = 0; i < this.feeds.length; i++) {
                      if (this.feeds[i].ItemID > maxFeedID)
                          maxFeedID = this.feeds[i].ItemID;

                      $('dvFeeds').removeClass('dnd');

                      if (i == 0 && tmpMinID == 0)
                          this.doPaging(this.feeds[i].Rows, this.feeds[i].Pages);

                      var _Pic = this.labelPic(this.feeds[i]);

                      var OwnerID = ((this.feeds[i].TypeID == 7 && this.detailsID == this.feeds[i].DetailsID) ? this.feeds[i].FriendWID : this.feeds[i].DetailsWID);
                      if (currentView.type.toLowerCase() == "my") {
                          OwnerID = this.wadjaID;
                      }

                      var isPremium = false;
                      if (this.feeds[i].TypeID == 2) {
                          var oTooo = this.feeds[i].Content.split('|')[0];
                          isPremium = (oTooo.indexOf('#') == 0 && oTooo.lastIndexOf('#') == (oTooo.length - 1));
                      }

                      var inbDiv = this.feeds[i].TypeID == 3 ? '<div id="feed_inbox_' + this.feeds[i].ItemID + '" class="dnd"></div>' : '';
                      var oSubj = ""; //(this.feeds[i].TypeID == 3 ? "" : this.feeds[i].Content.split('|')[1].trim());
                      var eml_To = (this.detailsID == this.feeds[i].DetailsID ? this.feeds[i].FriendWID : this.feeds[i].DetailsWID);

                      if (this.feeds[i].TypeID == 3) {
                          if (eml_To.trim() == "") {
                              eml_To = this.feeds[i].Content.split('|')[0].trim();
                          }
                          oSubj = this.feeds[i].Content.split('|')[1].trim();
                      }

                      var dtAgo = '<div class="lblSmall">' + (this.feeds[i].TypeID == 2 ? "Sent " : "") + this.feeds[i].Date + (this.feeds[i].TypeID == 2 ? " - " + this.labelDelivery(this.feeds[i].ContentType, isPremium, oTooo, this.feeds[i].ContentID) : "") + (this.feeds[i].TypeID == 3 ? ' - <a id="lnkOpen' + this.feeds[i].ItemID + '" href="javascript: jinbox.conversation(' + (oSubj.StartsWith('[ref:') ? this.feeds[i].ContentID + ', ' + this.feeds[i].ItemID : this.feeds[i].ItemID) + ', \'' + eml_To + '\', \'' + oSubj + '\');">' + f_open_conv + '</a>' : '') + (this.feeds[i].TypeID == 6 ? ' - <a id="lnkOpen" href="#1"></a>' : '') + '</div>';

                      toRemove = [];
                      var hashLabel = "";
                      if (this.feeds[i].hashName.trim() != "") {
                          var notFrnd = (typeof (this.feeds[i].FriendWID) == "undefined") || this.feeds[i].FriendWID.trim() == "";
                          hashLabel = '<a class="lblLnk" href="/' + (notFrnd ? this.feeds[i].DetailsWID : this.feeds[i].FriendWID) + '#labels/My/' + this.feeds[i].hashLabel + '/1">#' + this.feeds[i].hashName + '</a> &nbsp;';
                          toRemove.push(('#' + this.feeds[i].hashName).toLowerCase());
                      }

                      var rowAdd = dvFeedRow.toHTML(
                          {find: '[#id]', replace: this.feeds[i].ItemID},
                          {find: '[#myFeed]', replace: ((this.feeds[i].DetailsID == this.detailsID && currentView.type != 'My' && currentView.type != 'All' ? ' myFeed' : '') + (this.feeds[i].ContentType == 1 ? ' unread' : ''))},

                          {find: '[#picTrg]', replace: _Pic.targ},
                          {find: '[#picHrf]', replace: _Pic.url},
                          {find: '[#picUrl]', replace: _Pic.img},

                          {find: '[#inbox]', replace: inbDiv},
                          {find: '[#dWID]', replace: this.feeds[i].DetailsWID},
                          {find: '[#fWID]', replace: this.feeds[i].FriendWID},
                          {find: '[#dSN]', replace: this.feeds[i].DetailsName},
                          {find: '[#cnt]', replace: this.labelContent(this.feeds[i])},
                          {find: '[#hashLbl]', replace: hashLabel},
                          {find: '[#dtAgo]', replace: dtAgo},

                          {find: '[#labels]', replace: this.labelLabels(this.feeds[i].Labels, OwnerID, this.feeds[i].ItemID, this.feeds[i].DetailsID, this.feeds[i].FriendWID)}
                      );

                      if (rowAdd.Contains('lblStar')) rowAdd = rowAdd.replaceAll('applyStar', 'applyStar dnd');
                      if (rowAdd.Contains('lblTrash')) rowAdd = rowAdd.replaceAll('applyTrash', 'applyTrash dnd');

                      var showAct = false, showApp = false;

                      if (this.feeds[i].DetailsID == this.detailsID || currentView.type.toLowerCase() == "my") {
                          if (this.feeds[i].TypeID != 3 || true) {
                              if (isOwner) showAct = true;
                              if (isOwner) showApp = true;
                          }
                      }

                      rowAdd = rowAdd.replaceAll('[#actDND]', (showAct ? '' : 'dnd'));
                      rowAdd = rowAdd.replaceAll('[#appDND]', (showApp ? '' : 'dnd'));

                      if (tmpMinID == 0) {
                          strFeeds += rowAdd;
                          ///Add ad after first
                          //if (i == 0)
                          //    strFeeds += "<iframe id=\"iGadTop\" name=\"iGadTop\" width=\"720px\" height=\"90px\" scrolling=\"no\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" src=\"/user/ads/top.htm\" style=\"margin-bottom: 3px;\"></iframe>";
                          ///Add ad before last
                          //if (this.feeds.length > 6) {
                          //    if (i == this.feeds.length - 4)
                          //        strFeeds += "<iframe id=\"iGadBottom\" name=\"iGadTop\" width=\"720px\" height=\"90px\" scrolling=\"no\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" src=\"/user/ads/bottom.htm\" style=\"margin-bottom: 3px;\"></iframe>";
                          //}
                          //else
                          //    if (i == this.feeds.length - 2)
                          //    strFeeds += "<iframe id=\"iGadBottom\" name=\"iGadTop\" width=\"720px\" height=\"90px\" scrolling=\"no\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" src=\"/user/ads/bottom.htm\" style=\"margin-bottom: 3px;\"></iframe>";
                      }
                      else
                          strFeeds = rowAdd + strFeeds;

                  }
                  ///if first time load WELCOME FEEDS
                  if (isFirstTime == 0 && isOwner) {
                      if ($('dvFeeds_intro')) {
                          $('dvFeeds_intro').removeClass('dnd');
                          $('dvFeeds_intro').load('/user/wadja/firstuser.aspx');
                      }
                  }
                  else {
                      $('dvFeeds_intro').addClass('dnd');
                  }

                  $('dvFeeds').innerHTML = strFeeds;

                  this.hidePreviousConversations();

                  if (isFirstTime == 0 && isOwner)
                      myFacebox = new mooFacebox();

                  window.setTimeout(function() {
                      var midWidth = ($('profileTHEME').getSize().x - 415) + 'px'; // 458
                      var errorWidth = ($('profileTHEME').getSize().x - 411) + 'px'; // 458
                      var adWidth = ($('profileTHEME').getSize().x - 403) + 'px'; // 458
                      var headerWidth = ($('profileTHEME').getSize().x - 402) + 'px'; // 458                    

                      $('dvFeeds').style.width = midWidth;

                      if ($('iGadTop')) $('iGadTop').style.width = adWidth;
                      if ($('iGadBottom')) $('iGadBottom').style.width = adWidth;
                      if ($('dvStatic_content')) $('dvStatic_content').style.width = midWidth;
                      if ($('showProfileMenu')) $('showProfileMenu').style.width = headerWidth;
                      if ($('errorDiv')) $('errorDiv').style.width = errorWidth;

                  }, 100);
              }
              catch (err) {
                  //do something when error occurs
                  $('debug_0').set('html', err);
              }

              if ($('dvFeeds')) {
                  $('dvFeeds').getElements('.fItemSlide').each(function(item) {

                      if (tmpMinID != 0) {
                          var thisSlider = new Fx.Slide(item, {duration: 750, hideOverflow: false});
                          thisSlider.hide();
                          thisSlider.slideIn();

                          item.replaces(item.getParent());
                      }

                      item.removeClass('fItemSlide');
                  });
              }
              myFacebox = new mooFacebox();

              window.setTimeout(function() {
                  var midWidth = ($('profileTHEME').getSize().x - 415) + 'px'; // 458
                  var adWidth = ($('profileTHEME').getSize().x - 403) + 'px'; // 458
                  var headerWidth = ($('profileTHEME').getSize().x - 402) + 'px'; // 458                    

                  $('dvFeeds').style.width = midWidth;

                  if ($('iGadTop')) $('iGadTop').style.width = adWidth;
                  if ($('iGadBottom')) $('iGadBottom').style.width = adWidth;
                  if ($('dvStatic_content')) $('dvStatic_content').style.width = midWidth;
                  if ($('showProfileMenu')) $('showProfileMenu').style.width = headerWidth;

              }, 150);

              if (tmpMinID != 0)
                  return;

              if (this.users.length == 0 || isconversation == false) {
                  $('proLeft').addClass('dnd');
              }
              else if (wUser.wadjaID == 'wadja')
                  $('proLeft').addClass('dnd');
              else if (isconversation == true) {
                  $('proLeft').removeClass('dnd');
                  $('proLeft').show();
                  //alert(lb_right_enable);
                  ///Generate right-people
                  // Users
                  var dvUsrRow = new DomElement('div', {'class': '[#css] [#page]'});

                  var dvUsrRowPic = new DomElement('div');
                  var dvUsrRowPicImg = new DomElement('img', {'onclick': "top.location = '/[#wID]'", 'src': '/components/cropimage.aspx?user=[#wID]&height=25&width=25'});
                  dvUsrRowPic.AC(dvUsrRowPicImg);

                  var dvUsrRowLnk = new DomElement('div');
                  var dvUsrRowLnkA = new DomElement('a', {'class': 'lnkName', 'title': 'Click here to view profile', 'href': '/[#wID]', 'html': '[#wNM]'});
                  var dvUsrRowLnkH = new DomElement('a', {'class': 'f_r', 'id': 'aHide[#dID]', 'href': 'javascript: wUser.showHide([#i], [#k]);', 'html': '[#trans]'});
                  dvUsrRowLnk.AC(dvUsrRowLnkA);
                  dvUsrRowLnk.AC("<br /><span class=\"f_l\">[#country]</span>");
                  dvUsrRowLnk.AC(dvUsrRowLnkH);

                  dvUsrRow.AC(dvUsrRowPic);
                  dvUsrRow.AC(dvUsrRowLnk);

                  var __Left = "";

                  for (var i = 0; i < this.users.length; i++) {
                      var j = 0;
                      var isMore = false, isShowing = false;

                      var tmpTitle = new DomElement('div', {'class': 'left-title', 'html': (this.users[i].label == "" ? (f_recent_people + " (" + this.users[i].users.length + ")") : this.users[i].label)});
                      __Left += (tmpTitle.toHTML() + "<div id=\"LiveChatInConv\" class=\"dnd cursor\"><span class=\"f_r\"><span  class=\"left-title\"><a id=\"LiveChatInConvLink\" href=\"\">" + live_chat + "</a></span><span class=\"liveChatIcon\">&nbsp;</span></span></div>");
                      for (var k = 0; k < this.users[i].users.length; k++) {
                          if (this.users[i].users[k].dID != 0) {

                              if (this.users[i].users[k].name.trim() == "")
                                  this.users[i].users[k].name = this.users[i].users[k].wID;

                              this.users[i].users[k].visible = !(
                            (currentView.hide.indexOf(this.users[i].users[k].dID) == 0) ||
                            (currentView.hide.indexOf(',' + this.users[i].users[k].dID + ',') > -1) ||
                            (currentView.hide.indexOf(this.users[i].users[k].dID) == (currentView.hide.length - this.users[i].users[k].dID.toString().length))
                          );

                              $('proLeft').removeClass('dnd');

                              __Left += dvUsrRow.toHTML(
                           {find: '[#css]', replace: (isMore = (j > 3) ? 'left-more dnd' : '')},
                           {find: '[#wID]', replace: this.users[i].users[k].wID},
                           {find: '[#dID]', replace: this.users[i].users[k].dID},
                           {find: '[#wNM]', replace: this.users[i].users[k].name},
                           {find: '[#country]', replace: this.users[i].users[k].country},
                           {find: '[#trans]', replace: (this.users[i].users[k].visible ? f_recent_hide : f_recent_show)},
                           {find: '[#i]', replace: i.toString()},
                           {find: '[#k]', replace: k.toString()},
                           {find: '[#page]', replace: 'usrPg_' + (Math.ceil((j + 1) / 4))}
                          );

                              j++;
                          }

                          if ((k == this.users[i].users.length - 1) && isMore) {
                              usersRight.on = 1;
                              usersRight.of = Math.ceil(this.users[i].users.length / 4);

                              var tmpMore = new DomElement('div', {
                                  'id': 'hrfLeftMore',
                                  'class': "left-link",
                                  'html': '<div class=\"padT1\" id="usrPaging">1  ' + vOf + ' ' + usersRight.of + '</div><div class="tar padB3"><a href="/user/seeall.aspx?lbl=' + currentView.label + '&type=' + currentView.type + '&detId=' + wUser.detailsID + '&filt=' + currentView.filter + '&hide=' + currentView.hide + '&excl=' + currentView.exclude + '&page=1" rel="facebox" title=\"' + vConversation + '\">' + f_recent_more + '</a></div><div class=\"recentMoreFront\" onclick="wUser.switchUsers(-1);">&nbsp;</div><div class=\"recentMoreBack\" onclick="wUser.switchUsers(1);">&nbsp;</div>',
                                  'events': {
                                      'click': function() {
                                          //$('proLeft').getElements('.left-more').removeClass('dnd');
                                          //$('hrfLeftMore').addClass('dnd');
                                          //$('hrfLeftLess').removeClass('dnd');
                                      }
                                  }
                              });

                              __Left += tmpMore.toHTML();
                              isShowing = true;
                          }
                      }
                      $('proLeft').innerHTML = __Left;
                      myFacebox = new mooFacebox();
                  }
                  ///end of right-people code snippet
              }

              try {
                  if (this.feeds.length == 0) {

                      $('dvFeeds').addClass('dnd');
                      $('pagingBottom').addClass('dnd');

                      switch (currentView.label) {
                          case "5":
                              $('dvFeeds').innerHTML += search_res;
                              break;
                          case "6":
                              $('dvFeeds').innerHTML += search_res;
                              break;
                      }
                  }
                  else {
                      if (staticContent) {

                      }
                      else {

                          $('dvFeeds').removeClass('dnd');
                          $('pagingBottom').removeClass('dnd');
                      }
                  }
              }
              catch (err) {
                  $('dvFeeds').innerHTML += "<br />" + error_fixing + "";
              }
          },

          switchUsers: function(byWhat) {
              usersRight.on += byWhat;
              if (usersRight.on < 1) usersRight.on = usersRight.of;
              if (usersRight.on > usersRight.of) usersRight.on = 1;

              $('usrPaging').innerHTML = usersRight.on + " of " + usersRight.of;

              for (var i = 1; i <= usersRight.of; i++) {
                  if (i == usersRight.on) $('proLeft').getElements('.usrPg_' + i).removeClass('dnd');
                  else $('proLeft').getElements('.usrPg_' + i).addClass('dnd');
              }
          },

          showHide: function(i, k) {
              Wadjebug.Log('wUser.showHide');
              var toHide = $('aHide' + this.users[i].users[k].dID).innerHTML == f_recent_hide;
              $('aHide' + this.users[i].users[k].dID).innerHTML = (toHide ? f_recent_show : f_recent_hide);

              if (toHide) {
                  this.hidden.push(this.users[i].users[k].dID);
                  //wadja.showBar('Hiding' + ' ' + this.users[i].users[k].wID + '\'s feeds from this conversation');
                  wadja.showBar(vHiding + ' ' + this.users[i].users[k].wID + ' ' + vHidingT);
              }


              else {
                  var oTemp = [];
                  //wadja.showBar('Showing' + ' ' + this.users[i].users[k].wID + '\'s feeds in this conversation');
                  wadja.showBar(vShowing + ' ' + this.users[i].users[k].wID + ' ' + vShowingT);
                  for (var j = 0; j < this.hidden.length; j++) {
                      if (this.hidden[j] != this.users[i].users[k].dID) {
                          oTemp.push(this.hidden[j]);   //re-construct array of hidden users, omiting the current user to Show                     
                      }
                  }

                  this.hidden = oTemp;
              }

              currentView.hide = this.hidden.join(',');  //hide feeds from these users
              this.loadLabelFeeds();
          },
          //Manage Feed photo
          labelPic: function(lblFeed) {
              Wadjebug.Log('wUser.labelPic');

              var oURL = '/' + lblFeed.DetailsWID;
              var oTarget = '_self';
              var oIMG = '/components/cropImage.aspx?user=' + lblFeed.DetailsWID + '&height=55&width=55';

              switch (lblFeed.TypeID) {
                  case 7: // Friend
                      oURL = '/' + lblFeed.DetailsWID;
                      oIMG = '/components/cropImage.aspx?user=' + lblFeed.DetailsWID + '&height=55&width=55';
                      break;
                  case 6: // Contact
                      oURL = '/' + lblFeed.FriendWID;
                      oIMG = '/components/cropImage.aspx?user=' + lblFeed.FriendWID + '&height=55&width=55';
                      break;
                  case 11: //Gifts
                      if (lblFeed.Content.split('},{')[0].replace('{', '').replace('}', '') == '1') {
                          oURL = '#anonymous';
                          oIMG = '/images/def/default_anonimous_n.png';
                      }
                      else {
                          oURL = '/' + lblFeed.DetailsWID;
                          oIMG = '/components/cropImage.aspx?user=' + lblFeed.DetailsWID + '&height=55&width=55';
                      }
                      break;
                  case 16: // System
                      oURL = '/wadja';
                      oIMG = '/components/cropImage.aspx?user=wadja&height=55&width=55';
                      break;

                  case 13: // Twitter
                      oTarget = '_blank';
                      oURL = 'http://twitter.com/' + lblFeed.Content.split('|')[0].split(' ')[0];
                      oIMG = lblFeed.Content.split('|')[1];
                      break;
              }

              return {img: oIMG, url: oURL, targ: oTarget};
              //return '<a class="border-radius" href=\"' + oURL + '\" target=\"' + oTarget + '\"><img id="imgPr_' + lblFeed.ItemID + '" width="55px" height="55px" src="' + oIMG + '" /></a>';
          },
          //manage feed header
          labelContent: function(lblFeed) {
              Wadjebug.Log('wUser.labelContent');

              var txtLabel = "";
              var hasTo = false;
              var isPremium = false;

              var OwnerID = ((lblFeed.TypeID == 7 && this.detailsID == lblFeed.DetailsID) ? lblFeed.FriendWID : lblFeed.DetailsWID);
              if (currentView.type.toLowerCase() == "my") {
                  OwnerID = this.wadjaID;
              }

              txtLabel += '<div>';

              // ************ Sender  *******************
              if (lblFeed.TypeID != 13 && lblFeed.TypeID != 3 && lblFeed.TypeID != 11) {
                  txtLabel += '<a class="lblBig" href="/' + lblFeed.DetailsWID + '">' + lblFeed.DetailsName + '</a> &nbsp;';
              }
              // ************ Gifts Sender **************
              if (lblFeed.TypeID == 11) {
                  if (lblFeed.Content.split('},{')[0].replace('{', '').replace('}', '') == '1')
                      txtLabel += '<span class=\"bolt\">Anonymous</span>&nbsp;';
                  else
                      txtLabel += '<a class="lblBig" href="/' + lblFeed.DetailsWID + '">' + lblFeed.DetailsName + '</a> &nbsp;';
              }
              // ****************************************
              // ************ Recepient  ****************
              if (lblFeed.FriendID != 0 && lblFeed.FriendID != lblFeed.DetailsID && lblFeed.TypeID != 6 && lblFeed.TypeID != 7 && lblFeed.TypeID != 3) {
                  txtLabel += '<a class="lblLnk" href="/' + lblFeed.FriendWID + '">' + (lblFeed.TypeID == 2 ? "+" : "") + (lblFeed.TypeID == 9 ? "@" : "") + (lblFeed.TypeID == 11 ? "@" : "") + lblFeed.FriendWID + '</a> &nbsp;';
                  hasTo = true;
                  toRemove.push(((lblFeed.TypeID == 2 ? "+" : "") + (lblFeed.TypeID == 9 ? "@" : "") + (lblFeed.TypeID == 11 ? "@" : "") + lblFeed.FriendWID).toLowerCase());
              }

              // Manage feed header
              switch (lblFeed.TypeID) {
                  case 2: // SMS
                      var oTooo = lblFeed.Content.split('|')[0];
                      isPremium = (oTooo.indexOf('#') == 0 && oTooo.lastIndexOf('#') == (oTooo.length - 1));

                      if (!hasTo) {
                          if (isPremium) {
                              oTooo = oTooo.substring(0, oTooo.length - 1).substring(1);
                              txtLabel += '<span class="lblLnk fwb">' + oTooo + ' Recipient(s)</span> &nbsp;';
                          } else {
                              txtLabel += '<a class="lblLnk" href="#1">+' + lblFeed.Content.split('|')[0] + '</a> &nbsp;';
                          }
                      }

                      txtLabel += "<br /><span id='dvContent" + lblFeed.ItemID + "'>" + this.findLinks(this.fixText(lblFeed.Content.split('|')[1])) + "</span>";
                      break;

                  case 3: // Email
                      txtLabel += '<div id="dvInb' + lblFeed.ItemID + '">';

                      if (lblFeed.FriendID == lblFeed.DetailsID) {
                          txtLabel += '<a class="lblBig hrfEmlFrom" title="' + lblFeed.Content.split('|')[0] + '" href="javascript: void(0);">' + lblFeed.Content.split('|')[0] + '</a> &nbsp;';
                      }
                      else {
                          txtLabel += '<a class="lblBig hrfEmlFrom" title="' + lblFeed.DetailsWID + '" href="/' + lblFeed.DetailsWID + '">' + lblFeed.DetailsName + '</a> &nbsp;';
                      }

                      if (lblFeed.FriendID != 0 && lblFeed.FriendID != lblFeed.DetailsID) {
                          txtLabel += '<a class="lblLnk hrfEmlTo" title="' + lblFeed.FriendWID + '" href="/' + lblFeed.FriendWID + '">' + lblFeed.FriendWID + '@wadja.com</a> &nbsp;';
                      }
                      else if (lblFeed.FriendID == lblFeed.DetailsID) {
                          txtLabel += '<a class="lblLnk hrfEmlTo" title="' + lblFeed.DetailsWID + '" href="/' + lblFeed.DetailsWID + '">' + lblFeed.DetailsWID + '</a> &nbsp;';
                      }
                      else {
                          txtLabel += lblFeed.Content.split('|')[0] + ' &nbsp;';
                      }

                      //txtLabel += '<a class="lblSmall f_r" id="aDetails_' + lblFeed.ItemID + '" onclick="" href="#1">Show Details</a>';

                      var oSubj = lblFeed.Content.split('|')[1].trim();
                      if (oSubj == "") oSubj = "(no subject)";

                      if (!oSubj.StartsWith('[ref:')) txtLabel += "<br /><b class=\"hrfEmlSubj\">" + oSubj + "</b>";
                      txtLabel += "<br /><span id='dvContent" + lblFeed.ItemID + "' class='wsnw grayColor'>" + this.findLinks(this.fixText(lblFeed.Content.split('|')[2])) + "</span>";
                      txtLabel += '</div>';

                      break;

                  case 6: // Contact
                      contactInfo = "";
                      contactArray = lblFeed.Content.split(',');
                      if (contactArray.length == 2) {
                          if (contactArray[0].length > 0) {
                              contactInfo = contactArray[0];
                          }
                          else {
                              if (contactArray[1].length > 0)
                                  contactInfo = contactArray[1];
                              else
                                  contactInfo = lblFeed.FriendName;
                          }
                      }
                      else
                          contactInfo = lblFeed.FriendName;

                      txtLabel += "labeled <a href=\"/" + lblFeed.FriendWID + "\">" + contactInfo + "</a> " + dict_0;
                      txtLabel += "<div class=\"dnd\" id=\"contact_form_" + lblFeed.FriendID + "\"></div>";
                      txtLabel += "<br /><a id=\"contact_link_" + lblFeed.ItemID + "\" onmouseover=\"jtipit.on_tipit(this.id,'" + dict_3 + "','5');\" onmouseout=\"jtipit.off_tipit(this.id);\" href=\"javascript:jcontacts.get_contact('" + lblFeed.FriendID + "', '" + lblFeed.ItemID + "');\">" + dict_1 + "</a>";
                      break;

                  case 7: // Friend
                      txtLabel += "labeled <a href=\"/" + lblFeed.FriendWID + "\">" + lblFeed.FriendName + "</a> " + dict_2;
                      break;

                  case 8: // Help
                  case 9: // Notes
                  case 14: // YouTube
                  case 18: // Flickr

                      // THEO (Feb 16, 2010) remove double @alex #label @alex #label
                      for (var jimbo = 0; jimbo < toRemove.length; jimbo++) {
                          var indxOF = lblFeed.Content.toLowerCase().indexOf(toRemove[jimbo]);
                          while (indxOF >= 0) {
                              lblFeed.Content = lblFeed.Content.substring(0, indxOF) + lblFeed.Content.substring(indxOF + toRemove[jimbo].length);
                              lblFeed.Content = lblFeed.Content.trim();
                              indxOF = lblFeed.Content.toLowerCase().indexOf(toRemove[jimbo]);
                          }
                      }

                      txtLabel += ("[#hashLbl]" + this.findLinks(lblFeed.Content));
                      break;

                  case 12: // Media 
                      mediaArray = lblFeed.Content.split('[]');
                      if (mediaArray.length == 1)
                          photodescr = "";
                      else
                          photodescr = mediaArray[1].replace('[a href', '<a href').replace(']#', '>#').replace('[/a]', '</a>').replace('##', '#');
                      //txtLabel += '<div><a class="imgWadja" style="background-image: url(/components/mediaFile.ashx?id=' + lblFeed.Content.trim() + '&w=100)" rel="facebox" title="Media" href="/user/media.aspx?v=' + lblFeed.Content + '"></a></div>';
                      txtLabel += photodescr + '&nbsp;<div><a class="imgWadja" style="background-image: url(/components/mediaFile.ashx?id=' + mediaArray[0] + '&w=100)" rel="facebox" title="Media" href="/account/lab/slideshow4/iframe.aspx?fid=' + mediaArray[0] + '&did=' + lblFeed.DetailsID + '"></a></div>';
                      break;

                  case 13: // Twitter
                      txtLabel += '<a class="lblBig" target="_blank" href="http://twitter.com/' + lblFeed.Content.split('|')[0].split(' ')[0] + '">' + lblFeed.Content.split('|')[0] + '</a> &nbsp;';
                      txtLabel += '<div>' + lblFeed.Content.split('|')[2].replaceAll("<a href", "<a target=\"_blank\" href") + '</div>';
                      break;

                  case 11: // Gifts
                      //txtLabel += lblFeed.Content.split('},{')[2].replace('{', '').replace('}', '') + " <div><img class=\"lnk\" onclick=\"vx.OpenGift('" + lblFeed.ContentID + "');\" src=\"" + lblFeed.Content.split('},{')[1].replace('{', '').replace('}', '') + "\" /></div>";                      
                      if (lblFeed.Content.substring(0, 3) != '{2}' || isOwner || lblFeed.DetailsWID == detailsID || lblFeed.FriendWID == detailsID) 
                      {
                          txtLabel += lblFeed.Content.split('},{')[2].replace('{', '').replace('}', '') + " <div><img class=\"lnk\" onclick=\"vx.OpenGift('" + lblFeed.ContentID + "', '0" + "');\" src=\"" + lblFeed.Content.split('},{')[1].replace('{', '').replace('}', '') + "\" /></div>";
                      }
                      else //private gift: message only visible to the sender/receiver
                      {
                          txtLabel += " <div><img class=\"lnk\" onclick=\"vx.OpenGift('" + lblFeed.ContentID + "', '2" + "');\" src=\"" + lblFeed.Content.split('},{')[1].replace('{', '').replace('}', '') + "\" /></div>";
                      }
                      break;

                  case 15: // Theme
                      txtLabel += '<div><img class="imgTheme" style="max-width: 100px;" src="' + lblFeed.Content + '" /></div>';
                      break;

                  case 16: // System
                      txtLabel += "<div>" + this.fixText(lblFeed.Content) + "</div>";
                      break;

                  case 10: // Location
                  case 17: // User
                      txtLabel += lblFeed.Content + ' &nbsp;';
                      txtLabel += '<div style="width: 100%; height: 150px;" class="border-radius" id="dvLocation' + lblFeed.ItemID + '"></div>';

                      if (lblFeed.Content != "")
                          window.setTimeout('wUser.mapLocation("dvLocation' + lblFeed.ItemID + '", "' + lblFeed.Content + '");', 500);
                      break;
                  case 21: // Credits
                      creditArray = lblFeed.Content.split(',');
                      if (creditArray[3] == "1")
                          txtProvider = "smscoin";
                      else if (creditArray[3] == "2")
                          txtProvider = "zong";
                      else if (creditArray[3] == "4")
                          txtProvider = "credit card";
                      else if (creditArray[3] == "5")
                          txtProvider = "Offerpal";
                      else if (creditArray[3] == "0")
                          txtProvider = "";

                      if (creditArray[0] == "1") //purchased credits
                      {
                          txtCreditsText = "You have purchased <b>" + creditArray[2] + " credits</b> via " + txtProvider;

                          if (creditArray[4] == "6") {
                              txtCreditsText = "You have earned <b>" + creditArray[2] + " credit</b> by changing your location";
                          }
                          else if (creditArray[4] == "8") {
                              txtCreditsText = "You have earned <b>" + creditArray[2] + " credits</b>";

                              try {
                                  if (creditArray[5] != undefined)
                                      txtCreditsText += " for " + creditArray[5];
                              }
                              catch (Error) { }
                          }
                      }
                      if (creditArray[0] == "2") //spent credits
                      {
                          if (creditArray[4] == "1")
                              txtSpentFor = "removing the banner ads.";
                          if (creditArray[4] == "2")
                              txtSpentFor = "increasing sms to 160 characters.";
                          if (creditArray[4] == "3")
                              txtSpentFor = "";
                          if (creditArray[4] == "4")
                              txtSpentFor = "designing a label.";
                          if (creditArray[4] == "5")
                              txtSpentFor = "";

                          txtCreditsText = "You have spent <b>" + creditArray[2].replace("-", "") + " credits</b> for " + txtSpentFor;
                      }

                      txtLabel += txtCreditsText + "<div></div>";
                      break;
              }

              txtLabel += '</div>';
              //txtLabel += '<div>' + lblFeed.ItemID + '</div>';

              return txtLabel;
          },

          labelDelivery: function(oTps, isP, oCnt_, cntID_) {
              Wadjebug.Log('wUser.labelDelivery');

              if (isP)
                  return "<a title=\"Delivery reports\" href=\"javascript:dlrPOPUP('" + cntID_ + "');\">" + oCnt_.replace("#", "") + " Delivery Report(s)</a>";
              //return "<a rel=\"facebox\" title=\"Delivery reports\" href=\"/user/dlr.aspx?bid=" + cntID_ + "\">" + oCnt_ + " Delivery Report(s)</a>";

              switch (oTps) {
                  case 1:return "<font class='fwb' style='color: #70c175;'>" + f_delivered + "</font>";
                  case 2:return "<font class='fwb' style='color: #d3002d;'>" + f_failed + "</font>";
                  default:return "<font class='fwb' style='color: #e9be14;'>" + f_pending + "</font>";
              }
          },

          labelLabels: function(lblList, OwnerID, ItemID, Details_ID, Friend_ID) {
              Wadjebug.Log('wUser.labelLabels');

              var testString = "";
              for (var i = 0; i < lblList.length; i++) {
                  var OwnerWFID = (lblList[i].Owner_ID != 0 && lblList[i].Owner_ID != Details_ID && Friend_ID.trim() != "" ? Friend_ID : OwnerID);
                  //if (top.location.hash.toLowerCase().replaceAll('#', '').split('/')[0] == 'search') OwnerWFID = lblList[i].Owner_ID
                  var tmpBool = ((isOwner && currentView.type == "My" && lblList[i].id != 20) || (Details_ID == detailsID && lblList[i].id != 20));
                  var tmpCSS = (lblList[i].StyleID == 0 ? "" : "<span id=\"labelBox_" + lblList[i].id + "_" + ItemID + "\" onmouseover=\"PlaySoundLabel('" + lblList[i].musicURL + "');\" onmouseout=\"StopSound();\"><span class=\"f_l h_" + (lblList[i].bgColor).replace('#', '') + " " + (tmpBool ? "cssOwnerDes " : "") + "\"  style=\"font-family:" + lblList[i].fontFamily + "; background-image:" + (lblList[i].bgImageURL != "" ? lblList[i].bgImageURL : "none") + "; color:" + lblList[i].fontColor + ";\"><a href=\"#1\" class=\"" + (lblList[i].thumbURL == "" ? "dnd" : "padT1 vam padR3") + "\"><img width=\"17px\" height=\"14px\" src=\"" + lblList[i].thumbURL + "\"/></a>");
                  testString += tmpCSS + "<span id=\"labelBox_" + lblList[i].id + "_" + ItemID + "\" class=\"" + (lblList[i].StyleID == 0 ? "lblBox" : "") + " border-radius " + (tmpBool ? "cssOwner " : "") + lblList[i].style + "\">" + (lblList[i].StyleID == 0 ? "<a href=\"/" + OwnerWFID.toLowerCase() + "#labels/My/" + lblList[i].id + "/1\" class=\"border-radius\">" + lblList[i].name + "</a>" : "<span onclick=\"top.location.href='" + OwnerWFID.toLowerCase() + "#labels/My/" + lblList[i].id + "/1';\" class=\"border-radius\">" + lblList[i].name + "</span></span></span>") + (lblList[i].musicURL != 0 ? " <span title=\"Music\" onmouseover=\"PlaySoundLabel('" + lblList[i].musicURL + "');\" onmouseout=\"StopSound();\" class=\"f_l h_" + (lblList[i].bgColor).replace('#', '') + "\" style=\"" + (tmpBool ? "-moz-border-radius: 0px; -khtml-border-radius: 0px; -webkit-border-radius: 0px;" : "") + "border-left:1px solid #fff;margin-left:0;min-width:0px; background-image:url(/images/labels/music_label.png);padding:3px 8px;background-position: center 50%;\">&nbsp;</span>" : "") + "<span title=\"Followers\" class=\"" + ((lblList[i].Count != 0 && lblList[i].Count < 99) && lblList[i].StyleID != 0 ? "" : "dnd") + " border-radius\"><span class=\"f_l h_" + (lblList[i].bgColor).replace('#', '') + "\" style=\"border-left:1px solid #fff;margin-left:0px;margin-right:0;font-family:" + lblList[i].fontFamily + ";background-image:" + (lblList[i].bgImageURL != null ? lblList[i].bgImageURL : "none") + "; color:" + lblList[i].fontColor + ";" + (tmpBool ? "-moz-border-radius-bottomright: 0px; -moz-border-radius-topright: 0px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;" : "-moz-border-radius-bottomright: 2px; -moz-border-radius-topright: 2px;") + "\">" + lblList[i].Count + "</span></span><span title=\"Followers\"  class=\"" + (lblList[i].Count > 99 && lblList[i].StyleID != 0 ? "" : "dnd") + " border-radius\"><span class=\"f_l h_" + (lblList[i].bgColor).replace('#', '') + "\" style=\"border-left:1px solid #fff;margin-left:0;min-width:0px;font-family:" + lblList[i].fontFamily + ";background-image:" + (lblList[i].bgImageURL != null ? lblList[i].bgImageURL : "none") + "; color:" + lblList[i].fontColor + ";" + (tmpBool ? "-moz-border-radius-bottomright: 0px; -moz-border-radius-topright: 0px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;" : "-moz-border-radius-bottomright: 2px; -moz-border-radius-topright: 2px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;") + "border-left:1px solid #fff;margin-right:0;padding:3px 3px 3px 5px;margin-left:0;\">99+</span></span>" + (tmpBool ? " <span onclick=\"return wUser.removeLabel(" + lblList[i].id + ", " + ItemID + ")\" class=\"border-radius f_l h_" + (lblList[i].bgColor).replace('#', '') + "\" style=\"font-family:" + lblList[i].fontFamily + "; background-image:" + lblList[i].bgImageURL + "; color:" + lblList[i].fontColor + "; margin-left:0;border-left:1px solid #fff;min-width:0px;\">X</span>" : "") + "</span>"; //VASO
                  //testString += tmpCSS + "<span id=\"labelBox_" + lblList[i].id + "_" + ItemID + "\">" + (lblList[i].StyleID == 0 ? "<a href=\"/" + OwnerWFID.toLowerCase() + "#labels/My/" + lblList[i].id + "/1\" class=\"border-radius\">" + lblList[i].name + "</a>" : "<span onclick=\"top.location.href='/user/default.aspx?u=" + OwnerWFID.toLowerCase() + "#labels/My/" + lblList[i].id + "/1';\" class=\"border-radius\">" + lblList[i].name + "</span></span></span></span>") + (lblList[i].musicURL != 0 ? " <span title=\"Music\">&nbsp;</span>" : "") + "<span title=\"Followers\">" + lblList[i].Count + "</span</span><span title=\"Followers\"  class=\"" + (lblList[i].Count > 99 && lblList[i].StyleID != 0 ? "" : "dnd") + " border-radius\"><span class=\"f_l h_" + (lblList[i].bgColor).replace('#', '') + "\" style=\"font-family:" + lblList[i].fontFamily + ";background-image:" + (lblList[i].bgImageURL != null ? lblList[i].bgImageURL : "none") + "; color:" + lblList[i].fontColor + ";" + (tmpBool ? "-moz-border-radius-bottomright: 0px; -moz-border-radius-topright: 0px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;" : "-moz-border-radius-bottomright: 2px; -moz-border-radius-topright: 2px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;") + "border-left:1px solid #fff;margin-right:0;padding:3px 3px 3px 5px;margin-left:0;\">99+</span</span>" + (tmpBool ? " <span onclick=\"return wUser.removeLabel(" + lblList[i].id + ", " + ItemID + ")\" class=\"border-radius f_l h_" + (lblList[i].bgColor).replace('#', '') + "\" style=\"font-family:" + lblList[i].fontFamily + "; background-image:" + lblList[i].bgImageURL + "; color:" + lblList[i].fontColor + ";border-left:1px solid #fff;margin-left:0;min-width:0px;\">X</span>" : "") + "</span></span>"; //VASO
              }

              return testString;
          },

          labelActions: function(itemID, TypeID) {
              Wadjebug.Log('wUser.labelActions');
              return "";
          },

          labelLabelsAdd: function(oRes) {
              Wadjebug.Log('wUser.labelLabelsAdd');
              //var OwnerWFID = (oRes.Owner_ID != 0 && oRes.Owner_ID != Details_ID && Friend_ID.trim() != "" ? Friend_ID : OwnerID);
              var tmpBoolApply = ((isOwner && currentView.type == "My" && oRes.id != 20) || (Details_ID == detailsID && oRes.id != 20));
              // $('fItem_' + oRes.itemID).getElement('.lblContainer').innerHTML +=(oRes.style == 0 ? "" : "<span onmouseover=\"PlaySoundLabel('" + oRes.music + "');\" onmouseout=\"StopSound();\"><span class=\"h_" + (oRes.bgColor).replace('#', '') + " " + (tmpBool ? "cssOwnerDes " : "") + "\"  style=\"font-family:" + oRes.fontFamily + "; background-image:" + (oRes.bgImageURL != "" ? oRes.bgImageURL : "none") + "; color:" + oRes.fontColor + ";\"><a href=\"#1\" class=\"" + (oRes.thumbURL == "" ? "dnd" : "padT1 vam padR3") + "\"><img width=\"17px\" height=\"14px\" src=\"" + oRes.thumbURL + "\"/></a>");
              $('fItem_' + oRes.itemID).getElement('.lblContainer').innerHTML += (oRes.style == 0 ? "" : "<span id=\"labelBox_" + oRes.labelID + "_" + oRes.itemID + "\" onmouseover=\"PlaySoundLabel('" + oRes.music + "');\" onmouseout=\"StopSound();\"><span class=\"f_l h_" + (oRes.bgColor).replace('#', '') + " " + (tmpBoolApply ? "cssOwnerDes " : "") + "\"  style=\"font-family:" + oRes.fontFamily + "; background-image:" + (oRes.bgImage != "" ? oRes.bgImage : "none") + "; color:" + oRes.fontColor + ";\"><a href=\"#1\" class=\"" + (oRes.thumbURL == "" ? "dnd" : "padT1 vam padR3") + "\"><img width=\"17px\" height=\"14px\" src=\"" + oRes.thumbURL + "\"/></a>") + "<span id=\"labelBox_" + oRes.labelID + "_" + oRes.itemID + "\" class=\"" + (oRes.style == 0 ? "lblBox" : "") + " border-radius " + (tmpBoolApply ? "cssOwner " : "") + oRes.cssClass + "\">" + (oRes.style == 0 ? "<a href=\"/" + this.wadjaID + "#labels/My/" + oRes.labelID + "/1\" class=\"border-radius\">" + oRes.labelName + "</a>" : "<span onclick=\"top.location.href='" + this.wadjaID + "#labels/My/" + oRes.labelID + "/1';\" class=\"border-radius\">" + oRes.labelName + "</span></span></span>") + (oRes.music != 0 ? " <span title=\"Music\" onmouseover=\"PlaySoundLabel('" + oRes.music + "');\" onmouseout=\"StopSound();\" class=\"f_l h_" + (oRes.bgColor).replace('#', '') + "\" style=\"" + (tmpBoolApply ? "-moz-border-radius: 0px; -khtml-border-radius: 0px; -webkit-border-radius: 0px;" : "") + "border-left:1px solid #fff;margin-left:0;min-width:0px; background-image:url(/images/labels/music_label.png);padding:3px 8px;background-position: center 50%;\">&nbsp;</span>" : "") + "<span title=\"Followers\" class=\"" + ((oRes.Count != 0 && oRes.Count < 99) && oRes.style != 0 ? "" : "dnd") + " border-radius\"><span class=\"f_l h_" + (oRes.bgColor).replace('#', '') + "\" style=\"font-family:" + oRes.fontFamily + ";background-image:" + (oRes.bgImage != null ? oRes.bgImage : "none") + "; color:" + oRes.fontColor + ";" + (tmpBoolApply ? "-moz-border-radius-bottomright: 0px; -moz-border-radius-topright: 0px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;" : "-moz-border-radius-bottomright: 2px; -moz-border-radius-topright: 2px;") + "border-left:1px solid #fff;margin-left:0px;margin-right:0;padding:3px 3px 3px 5px;\">" + oRes.Count + "</span></span><span title=\"Followers\"  class=\"" + (oRes.Count > 99 && oRes.style != 0 ? "" : "dnd") + " border-radius\"><span class=\"f_l h_" + (oRes.bgColor).replace('#', '') + "\" style=\"font-family:" + oRes.fontFamily + ";background-image:" + (oRes.bgImage != null ? oRes.bgImage : "none") + "; color:" + oRes.fontColor + ";" + (tmpBoolApply ? "-moz-border-radius-bottomright: 0px; -moz-border-radius-topright: 0px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;" : "-moz-border-radius-bottomright: 2px; -moz-border-radius-topright: 2px;-moz-border-radius-bottomleft: 0px; -moz-border-radius-topleft: 0px;") + "border-left:1px solid #fff;margin-right:0;padding:3px 3px 3px 5px;margin-left:0;\">99+</span></span>" + (tmpBoolApply ? " <span onclick=\"return wUser.removeLabel(" + oRes.labelID + ", " + oRes.itemID + ")\" class=\"border-radius f_l h_" + (oRes.bgColor).replace('#', '') + "\" style=\"font-family:" + oRes.fontFamily + "; background-image:" + oRes.bgImage + "; color:" + oRes.fontColor + ";border-left:1px solid #fff;margin-left:0;min-width:0px;\">X</span>" : "") + "</span>";
              // $('fItem_' + oRes.itemID).getElement('.lblContainer').innerHTML += '<span class="lblBox border-radius cssOwner ' + oRes.cssClass + '" id="labelBox_' + oRes.labelID + '_' + oRes.itemID + '"><a class="border-radius" href="/' + this.wadjaID + '#labels/My/' + oRes.labelID + '/1">' + oRes.labelName + '</a> <span class="border-radius" onclick="return wUser.removeLabel(' + oRes.labelID + ', ' + oRes.itemID + ')">X</span></span></span>';
          },

          removeLabel: function(labelID, ItemID, fName) {
              Wadjebug.Log('wUser.removeLabel');
              var oCnfrm = f_remove_Lbl;

              if (labelID == 6) {
                  oCnfrm = f_delete_Lbl;
              }

              if (confirm(oCnfrm)) {
                  lblAjax.send('removeLabel', labelID, ItemID, function(res) {
                      if (labelID == 6) {
                          if ($('dvFriend')) $('dvFriend').addClass('dnd');
                      }
                      else {
                          $('labelBox_' + labelID + '_' + ItemID).destroy();
                      }

                      if (labelID == currentView.label) {
                          var thisSlider = new Fx.Slide($('fItem_' + ItemID), {duration: 750, hideOverflow: false});
                          thisSlider.slideOut();

                          window.setTimeout(function() {
                              $('fItem_' + ItemID).getParent().destroy();
                          }, 1000);
                      }
                  });
              }

              return false;
          },

          mapLocation: function(oDiv, oLocation) {
              Wadjebug.Log('wUser.mapLocation');
              if (GBrowserIsCompatible()) {
                  var map = new GMap2($(oDiv));
                  map.setCenter(new GLatLng(41.897997, -87.790203), 3);

                  var geocoder = new GClientGeocoder();
                  geocoder.getLatLng(oLocation, function(point) {
                      if (!point) { }
                      else {map.setCenter(point, 3);}

                      var marker = new GMarker(point);
                      map.addOverlay(marker);
                  });

                  map.addControl(new GSmallMapControl());
                  //map.setMapType(G_PHYSICAL_MAP); //apostolis
                  map.setMapType(G_NORMAL_MAP);
              }
          },

          hidePreviousConversations: function() {

              var all_From = $$('.hrfEmlFrom');
              var all_To = $$('.hrfEmlTo');
              var all_Subj = $$('.hrfEmlSubj');

              for (var i = 0; i < all_From.length; i++) {
                  for (var j = 0; j < all_From.length; j++) {
                      if (i == j) break;

                      var boolFrom = (all_From[i].title.toLowerCase() == all_From[j].title.toLowerCase());
                      var boolFromRe = (all_From[i].title.toLowerCase() == all_To[j].title.toLowerCase());

                      var boolTo = (all_To[i].title.toLowerCase() == all_To[j].title.toLowerCase());
                      var boolToRe = (all_To[i].title.toLowerCase() == all_From[j].title.toLowerCase());

                      var boolSubj = all_Subj[i].innerHTML.toLowerCase().EndsWith(all_Subj[j].innerHTML.toLowerCase());
                      var boolSubjRe = all_Subj[j].innerHTML.toLowerCase().EndsWith(all_Subj[i].innerHTML.toLowerCase());

                      if (((boolFrom && boolTo) || (boolFromRe && boolToRe)) && (boolSubj || boolSubjRe)) {
                          //alert(all_From[i].title + "->" + all_To[i].title + ": [" + all_Subj[i].innerHTML + "]");
                          all_From[i].getParent('.fItem').destroy();
                      }
                  }
              }
          },

          findLinks: function(s) {
              Wadjebug.Log('wUser.findLinks');
              /*
              s = " " + s + " ";
              //var hlink = /\s(ht|f)tp:\/\/([^ \,\;\:\!\)\(\"\'\<\>\f\n\r\t\v])+/g;
              var hlink = /\s(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/g;
              return (s.replace(hlink, function($0, $1, $2) {
              s = $0; //.substring(1, $0.length);
              while (s.length > 0 && s.charAt(s.length - 1) == '.') s = s.substring(0, s.length - 1);
              //problem with bitly-links must stay as is-lower and upper case
              //var s2 = s.toLowerCase();
              var s2 = s;
              if (s2.indexOf('http') == -1) s2 = "http://" + s2;
              if (s.trim().Contains(' ')) return s;
              return ' <a target="_blank" href="' + s2.trim() + '">' + s + '</a>';
              }));
              */
              if (s.indexOf('imgYouTube') > 0)
                  return s; ///exclude feed content
              else {
                  var myregexp = /((?:(?:https?):\/\/[\-A-Z0-9+&@#\/%=~_|$?!:,.]{4,})|(?:(?:www|ftp)\.[\-A-Z0-9+&@#\/%=~_|$?!:,.]{4,}))/ig;
                  var result;         // my match (valid url)
                  var s_withurl = s;   // final text with url links


                  while ((result = myregexp.exec(s)) != null) {
                      var temp = result[0].substring(0, 4).toLowerCase(); // check if http exists at start of result[0], if not add it to the url
                      if (temp == 'http') {
                          s_withurl = s_withurl.replace(result[0], '<a target=\"_blank\" href=\"' + result[0] + '\">' + result[0] + '</a>');
                      } else {
                          s_withurl = s_withurl.replace(result[0], '<a target=\"_blank\" href=\"http://' + result[0] + '\">' + result[0] + '</a>');
                      };
                  };
              }
              return (s_withurl);
          },

          doPaging: function(oRows, oPages) {
              Wadjebug.Log('wUser.doPaging');
              var wholeNumber = oRows % currentView.rows;

              var onPageTemp = currentView.page - 1;
              var oPages = (oRows - wholeNumber) / currentView.rows;  // Calculate total pages.
              if (wholeNumber > 0) oPages += 1;

              if (oPages < onPageTemp)
                  onPageTemp = oPages;

              var sbPager = "";

              if (onPageTemp != 0) {
                  sbPager += '<a href="#labels/' + currentView.type + '/' + currentView.label + '/' + onPageTemp + '">< Prev</a> ';
              }

              var intLow = onPageTemp - 1;
              var intHigh = onPageTemp;

              if (intLow < 1) intLow = 1;
              if (intHigh > oPages) intHigh = oPages + 1;

              var maxShownPages = 5;
              if (intHigh - intLow < maxShownPages) while ((intHigh < intLow + (maxShownPages - 1)) && intHigh < oPages) intHigh++;
              if (intHigh - intLow < maxShownPages) while ((intLow > intHigh - (maxShownPages - 1)) && intLow > 1) intLow--;

              if (intLow < 1) intLow = 1;
              if (intHigh > oPages) intHigh = oPages + 1;

              for (var x = intLow; x < intHigh + 1; x++) {
                  // numeric links
                  if (x == onPageTemp + 1) {
                      sbPager += '<span>' + x + '</span> ';
                  }
                  else {
                      sbPager += '<a href="#labels/' + currentView.type + '/' + currentView.label + '/' + x + '">' + x + '</a> ';
                  }
              }

              if (onPageTemp != (oPages - 1)) {
                  sbPager += '<a href="#labels/' + currentView.type + '/' + currentView.label + '/' + (onPageTemp + 2) + '">' + f_next + ' ></a> ';
              }

              $('pagingBottom').innerHTML = sbPager;
          },

          setType: function(oType, oLabel, oPage) {
              Wadjebug.Log('wUser.setType');

              //alert('oLabel= ' + oLabel);
              currentView.type = oType;
              currentView.label = oLabel;
              currentView.page = oPage;

              if (currentView.type != "Every" && currentView.label != '7' && parseInt(currentView.filter) > 2) {
                  currentView.filter = 0;
                  $('dvFilter0').addClass('tofromImage');
              }

              if (oLabel == 1)
                  oLabel = 2;

              if (oLabel == "1" || oLabel == "2" || oLabel == "5" || oLabel == "6" || oLabel == "3332" || oLabel == "3" || oLabel == "20") {
                  $('EmbedFeed').addClass('dnd');
              }
              else if (currentView.label > 0 && detailsID > 0)//edited by itsopelas 
              {
                  $('EmbedFeed').removeClass('dnd');
                  $('EmbedFeed_text').set('value', '<iframe name=\"I1\" frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" style=\"border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; width: 300px; height: 560px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial;\" src=\"http://www.wadja.com/user/connect.aspx?wadjaid=' + oWadjaID + '&label=' + oLabel + '\" id=\"I1\"></iframe>');
              }

              if (detailsID <= 0) $('EmbedFeed').addClass('dnd'); //do not display if signed out

              //itsopelas: code added in order to check the Lab settings of the user for Meeboo Rooms 
              if (ismeeboo == true && parseInt(this.detailsID) > 0) {
                  /* Chat room for everyone */
                  if (currentView.type.toLowerCase().trim() == "every") {
                      $('proLeft').addClass('dnd'); //jGUI.hideConversation();
                      ///Enable everyone Chat Room
                      if ($('LiveChat') && detailsID > 0) {
                          if (parseInt(this.detailsID) > 0 && parseInt(currentView.label) == 0) {

                              $('LiveChat').removeClass('dnd');
                              $('LiveChatLink').set('href', 'javascript:meeboRm.getEmbed("7","43");');
                          }
                          else if (parseInt(currentView.label) > 0) {
                              meeboRm.roomExists(currentView.label, this.detailsID);
                          }
                      }
                      $('EmbedFeed').addClass('dnd');
                      jGUI.trash_off();
                  }
                  else if (currentView.type.toLowerCase().trim() == "my") {
                      if ($('LiveChat') && detailsID > 0) {
                          if (parseInt(this.detailsID) > 0 && parseInt(currentView.label) == 0) {

                              $('LiveChat').removeClass('dnd');
                              $('LiveChatLink').set('href', 'javascript:meeboRm.getEmbed("7","43");');
                          }
                          else if (parseInt(currentView.label) > 0) {
                              meeboRm.roomExists(currentView.label, this.detailsID);
                          }
                      }
                      if (parseInt(detailsID) > 0 && (oLabel == "0" || oLabel == ""))
                          $('EmbedFeed').addClass('dnd');

                  }
                  else if (currentView.type.toLowerCase().trim() == "follow") {
                      if ($('LiveChat') && detailsID > 0) {
                          if (parseInt(this.detailsID) > 0 && parseInt(currentView.label) == 0) {

                              $('LiveChat').removeClass('dnd');
                              $('LiveChatLink').set('href', 'javascript:meeboRm.getEmbed("7","43");');
                          }
                          else if (parseInt(currentView.label) > 0) {
                              meeboRm.roomExists(currentView.label, this.detailsID);
                          }
                      }
                      $('EmbedFeed').addClass('dnd');

                  }
                  else {
                      ///Disable everyone Chat Room
                      //if ($('LiveChat'))
                      //    $('LiveChat').addClass('dnd');
                      ///Load Label Room     
                      meeboRm.roomExists(currentView.label, this.detailsID);
                      //end of label room
                      ///Embed Label
                      $('EmbedFeed').addClass('dnd');
                  }
              }
              else if (ismeeboo == false) {
                  $('LiveChat').addClass('dnd');
                  $('EmbedFeed').addClass('dnd');
              }

              if (detailsID > 0 && embedEnabled == 'False') {
                  $('EmbedFeed').addClass('dnd');
              }
              if (wUser.wadjaID == 'wadja')
                  $('LiveChat').addClass('dnd');
              //if (parseInt(this.detailsID) <= 0) $('EmbedFeed').addClass('dnd'); //do not display if signed out

              /* Manage Filters */
              /*********************************************************************/

              label_search = oLabel;
              switch (parseInt(oLabel)) {
                  case 1: //SMS
                      jGUI.snapabug_on();
                      break;
                  case 2: //Email
                      jGUI.snapabug_on();
                      break;
                  case 9: //Location
                      jGUI.location_on();
                      jGUI.trash_on();
                      break;
                  case 7: //Help
                      jGUI.help_on();
                      jGUI.trash_on();
                      jGUI.snapabug_on();
                      $('dvFilters').removeClass('dnd');
                      break;
                  case 5: //contacts
                      jGUI.help_off();
                      jGUI.trash_on();
                      //............
                      //label_search = 5;
                      //............
                      $('dvFilters').addClass('dnd');
                      $('dvContacts').removeClass('dnd');
                      //...........
                      //$('dvContacts_refresh').set('href', '#labels/My/5');
                      $('dvContacts_imp_span').set('html', vrAddContact);
                      $('dvContacts_add').removeClass('dnd');
                      //$('dvContacts_sync').removeClass('dnd');
                      break;
                  case 6: //friends
                      jGUI.friends_on();
                      jGUI.trash_on();
                      //............
                      //label_search = 6;                      
                      //............
                      $('dvContacts').addClass('dnd');
                      break;
                  default:
                      $('dvFilters').removeClass('dnd');
                      jGUI.trash_on();
                      //...........
                      $('dvContacts').addClass('dnd');
                      jGUI.location_off();
                      jGUI.help_off();
                      jGUI.friends_off();
                      jGUI.location_off();
                      jGUI.search_off();
                      jGUI.fromto_on();
                      jGUI.snapabug_off();
                      //label_search = 0;
                      break;
              }
              /* end filters */

              if (currentView.label != 7 && currentView.filter > 2) {
                  currentView.filter = 0;
              }

              ///Help-default everybody
              if (currentView.label == 7) {
                  if (currentView.type.toLowerCase() == 'every') {
                      //set default filter under help when accessed via EVERY
                      currentView.filter = 3;
                      WADJAX_labels_filter(3);
                  }
                  else if (currentView.type.toLowerCase() == 'my') {
                      //set default filter under help when accessed via MY
                      currentView.filter = 0;
                      WADJAX_labels_filter(0);
                  }

              }

              if (currentView.type.toLowerCase() != 'my' || !isOwner || currentView.label == 0 || currentView.label == 3)
                  jGUI.trash_off();

              if (isOwner && currentView.type.toLowerCase() == 'my' && currentView.label == 3)
                  $('dvTrashForever').removeClass('dnd');
              else
                  $('dvTrashForever').addClass('dnd');

              if (isOwner) {
                  wadja.createCookie("prof_Tabs_" + this.detailsID, oType, 30);
              }

              if (oType == 'My' && currentView.label != 5) {
                  $('dvFilters').getElements('.toHide').each(function(el, index) {
                      el.removeClass('dnd');
                  });
              }
              else {
                  $('dvFilters').getElements('.toHide').each(function(el, index) {
                      if (currentView.label != 7)
                          el.addClass('dnd');
                  });
              }
               if (wUser.wadjaID == 'wadja')
               {
                  $('hrfLblFollow').addClass('dnd');
                  $('spanLblFollow').addClass('dnd');
               }

              ['hrfLblMy', 'hrfLblFollow', 'hrfLblEvery'].each(function(item, index) {
                  if ('hrfLbl' + oType == item) {
                      $(item).addClass('top-sel');
                  }
                  else {
                      $(item).removeClass('top-sel');
                  }
              });
              //******************************************
              //Feeds Startup                      

              if (isOwner)                      //display upload photo icon...
              {
                  if ($('uploadMedia')) {
                      $('uploadMedia').removeClass('dnd');
                  }
              }
              else {
                  if ($('uploadMedia'))
                      $('uploadMedia').addClass('dnd');
              }
              //alert(searchQuery);

              if (currentView.label == 3 && $('compose'))
                  $('compose').addClass('dnd');

              ///IF WADJA AND INFO,PRESS RELEASES, RESOURCES HIDE COMPOSE LOAD STATIC INFO
              if (wUser.wadjaID == 'wadja' && (parseInt(currentView.label) == 20120 || parseInt(currentView.label) == 20121 || parseInt(currentView.label) == 20122)) {
                  //if ((parseInt(currentView.label) == 617 || parseInt(currentView.label) == 20121 || parseInt(currentView.label) == 20122)) {
                  ///LOAD CONTENT
                  staticContent = true;
                  ///GUEST
                  if ($('wj_masterContent_dvGuest'))
                      $('wj_masterContent_dvGuest').addClass('dnd');
                  ///USER
                  if ($('compose'))
                      $('compose').addClass('dnd');

                  if ($('dvFilters'))
                      $('dvFilters').addClass('dnd');
                  if ($('dvFeeds'))
                      $('dvFeeds').addClass('dnd');
                  if ($('aFollow'))
                      $('aFollow').addClass('dnd');

                  $('pagingBottom').addClass('dnd');
                  $('pagingBottom_spacer').addClass('dnd');
                  $('dvFilters_placeholder').addClass('dnd');


                  ///Load static content
                  $('dvStatic_content').removeClass('dnd');
                  $('dvStatic_content').empty();
                  if (parseInt(currentView.label) == 20120) {
                      $('dvStatic_content').load('/user/wadja/info.aspx');
                  }
                  else if (parseInt(currentView.label) == 20121) {
                      $('dvStatic_content').load('/user/wadja/releases.aspx');
                  }
                  else if (parseInt(currentView.label) == 20122) {
                      $('dvStatic_content').load('/user/wadja/resources.aspx');
                  }

                  ///Remove adds
                  if ($('iGadTop'))
                      $('iGadTop').addClass('dnd');
              }
              else {
                  staticContent = false;
                  $('dvStatic_content').addClass('dnd');
                  ///GUEST
                  if ($('wj_masterContent_dvGuest'))
                      $('wj_masterContent_dvGuest').removeClass('dnd');
                  ///USER
                  //if ($('compose'))
                  //    $('compose').removeClass('dnd');

                  if ($('iGadTop'))
                      $('iGadTop').removeClass('remove');
                  if ($('dvFilters'))
                      $('dvFilters').removeClass('dnd');

                  $('pagingBottom').removeClass('dnd');
                  $('pagingBottom_spacer').removeClass('dnd');
                  $('dvFilters_placeholder').removeClass('dnd');
              }

              if (staticContent) {
                  ///Fix size
                  var fixWidth = ($('profileTHEME').getSize().x - 415) + 'px'; // 458
                  if ($('dvFeeds_static'))
                      $('dvFeeds_static').style.width = fixWidth;

              }
              else {
                  this.loadLabelFeeds();        //load feeds......
              }
              this.setComposeText();
              window.scrollTo(0, 0);    //scroll top......
          },

          setSearch: function(labelKeyword, labelID, labelPublic) {
              Wadjebug.Log('wUser.setSearch');
              //set label in text box:label name
              //$('text_search').set('value', 'label:' + labelKeyword);
              //$('text_search_id').set('value', labelID);
              //******************************************       
          },
          setComposeText: function() {
              Wadjebug.Log('wUser.setComposeText');
              var PrivacyID = false;

              //alert(gup('sURL'));
              //                  var url_query = "";
              //                  if (gup('sURL'))
              //                  {
              //                    url_query = gup('sURL');
              //                  }              
              //alert(url_query);

              if (typeof jCompose != "undefined") {

                  var tmpBlaBla = ((isOwner ? '' : '@' + this.wadjaID)).trim() + '  ';
                  $('txtBody').value = $('txtBody').value + (tmpBlaBla == '  ' ? '' : tmpBlaBla);
                  $('txtBody').value = (tmpBlaBla == '  ' ? '' : tmpBlaBla) + (url_query == "" ? '' : url_query + '  ');
                  //$('txtBody').focus();
                  try { $('txtBody').focus(); } catch (e) { }
                   
                  $('aFollow').addClass('dnd');
                  $('spFollow').addClass('dnd');

                  if (parseInt(currentView.label) == 0) {
                      jCompose.setType("Post");
                  }
                  else if (parseInt(currentView.label) != 0) {
                      $('aFollow').title = "";
                      for (var i = 0; i < this.DDL.My.length; i++) {
                          if (this.DDL.My[i].id == currentView.label) {

                              PrivacyID = this.DDL.My[i].privacy;

                              var oType = composeView[this.DDL.My[i].type].cType;
                              if (oType == "Post") {
                                  $('compose').removeClass('focused');
                              }

                              jCompose.setType(oType);
                              //set search box
                              this.setSearch(this.DDL.My[i].name, currentView.label, 1);
                              gb_labelName = this.DDL.My[i].name; //global label name

                              if (this.DDL.My[i].type == 1 || this.DDL.My[i].type == 8 || this.DDL.My[i].type == 7 || this.DDL.My[i].type == 10 || this.DDL.My[i].type == 12 || this.DDL.My[i].type == 14) {
                                  $('txtBody').value = ((isOwner ? '' : '@' + this.wadjaID) + '  ' + '#' + this.DDL.My[i].name).trim() + '  ' + (url_query == "" ? '' : url_query + '  ');
                                  $('txtBody').focus();
                              }


                              $('aFollow').removeClass('dnd');
                              $('spFollow').removeClass('dnd');

                              if (this.detailsID == Owner.dID) {
                                  $('aFollow').title = InviteTofollowTitle;
                                  $('aFollow').innerHTML = InviteTofollow;
                                  $('aFollow').href = '#labels/invite/' + this.DDL.My[i].id + '/' + this.DDL.My[i].name;
                                  $('aFollow').style.backgroundColor = '#3a5898';
                              }
                              else {
                                  var lblFound = false;

                                  for (var j = 0; j < this.myfollow.length; j++) {
                                      if (this.myfollow[j].ID == this.DDL.My[i].id && this.myfollow[j].Owner == this.detailsID) {
                                          $('aFollow').innerHTML = StopTofollow;
                                          $('aFollow').href = '#labels/nofollow/' + this.DDL.My[i].id + '/' + this.DDL.My[i].name;
                                          $('aFollow').style.backgroundColor = '#d74848';
                                          lblFound = true;
                                          break;
                                      }
                                  }

                                  if (!lblFound) {
                                      $('aFollow').innerHTML = FollowtheLabel;
                                      $('aFollow').href = '#labels/yesfollow/' + this.DDL.My[i].id + '/' + this.DDL.My[i].name;
                                      $('aFollow').style.backgroundColor = '#68a548';
                                  }
                              }
                              break;
                          }
                      }
                  }
              }
              else {
                  if (parseInt(currentView.label) != 0) {
                      for (var i = 0; i < this.DDL.My.length; i++) {
                          if (this.DDL.My[i].id == currentView.label) {
                              //set search box
                              this.setSearch(this.DDL.My[i].name, currentView.label, 0);
                          }
                      }

                      //follow noLogin
                      if (parseInt(currentView.label) > 3) {
                          folLink = "/validation/invitetofollow.aspx?did=" + pg_details_ID + "&fl=1&lid=" + currentView.label + "&embed=1";
                          $('aFollow').innerHTML = FollowtheLabel;
                          $('aFollow').href = 'javascript:location.href=\"' + folLink + '\"';
                          $('aFollow').style.backgroundColor = '#68a548';
                          $('aFollow').removeClass('dnd');
                      }
                  }
              }

              /* if guest-not signed in */

              if (detailsID == 0 && parseInt(currentView.label) > 0) {
                  for (var i = 0; i < this.DDL.My.length; i++) {
                      if (this.DDL.My[i].id == currentView.label) {
                          gb_labelName = this.DDL.My[i].name; //global label name
                      }
                  }
              }

              if (!PrivacyID) {
                  for (var i = 0; i < this.DDL.My.length; i++) {
                      if (this.DDL.My[i].id == 8) {
                          PrivacyID = this.DDL.My[i].privacy;
                      }
                  }
              }

              this.setPrivacyBar(PrivacyID);
              if (typeof jCompose != "undefined") {
                  jCompose.wadjaThinking();
              }

              //if Wadja Info, PressRelease, Resources, do NOT show "Follow label"             
              if (wUser.wadjaID == 'wadja' && (parseInt(currentView.label) == 20120 || parseInt(currentView.label) == 20121 || parseInt(currentView.label) == 20122)) {
                  $('aFollow').addClass('dnd');
              }
           },
          //
          setPrivacyBar: function(Privacy_ID) {
              var oTitle;
              oPrivacy = Privacy_ID;
              switch (Privacy_ID.toString()) {
                  case "4":
                      oTitle = "Everyone";
                      break;
                  case "3":
                      oTitle = "Friends";
                      break;
                  case "2":
                      oTitle = "Only Me";
                      break;
                  case "1":
                  default:
                      Privacy_ID = 1;
                      oTitle = "No One";
                      break;
              }
              ///Manage privacy
              var oHTML = "<a href=\"/user/edit.aspx?id=" + currentView.label + "\" rel=\"facebox\" title=\"" + oTitle + "\" class=\"dib hoverNounderline  lblPr_" + Privacy_ID + "\">&nbsp;</a>";
              if (isOwner && (currentView.type.toLowerCase().trim() == "my")) {
                  if ($('dvPrivacy')) $('dvPrivacy').innerHTML = oHTML;
                  if ($('dvPrivacyCmp')) $('dvPrivacyCmp').innerHTML = oHTML;
              }
              else {
                  if ($('dvPrivacy')) $('dvPrivacy').innerHTML = "";
                  if ($('dvPrivacyCmp')) $('dvPrivacyCmp').innerHTML = "";
              }

          },

          getUserLabels: function() {
              Wadjebug.Log('wUser.getUserLabels');
              lblAjax.send('Labels', this.detailsID, wUser.CB_getUserLabels);

          },

          getFollowing: function() {
              Wadjebug.Log('wUser.getFollowing');
              lblAjax.send('Follow', this.detailsID, wUser.CB_getFollowing);

          },

          applyLabel: function(item_ID, label_ID) {
              Wadjebug.Log('wUser.applyLabel');
              lblAjax.send('applyLabel', item_ID, label_ID, wUser.CB_applyLabel);
          },

          createLabel: function(item_ID) {
              Wadjebug.Log('wUser.createLabel');

              var lbl_Name = (arguments.length == 1 ? $('txtNewLabel').value : arguments[1]);

              //Label name cannot start with # character.
              if ($('txtNewLabel').value.trim().charAt(0) == "#") {
                  alert("Label cannot start with # character.");
                  return;
              }

              wadja.showLoading('Creating Label "' + lbl_Name + '"', 'Still Creating Label', 5)

              var wYT = true;
              var wTW = true;
              var wPR = 4;

              if (typeof bYT !== "undefined") wYT = bYT;
              if (typeof bTW !== "undefined") wTW = bTW;
              if (typeof bPR !== "undefined") wPR = bPR;

              ///if checked Create Meebo room
              var wMB = false;
              if ($('meeboChat').checked)
                  wMB = true;

              lblAjax.send('createLabel', lbl_Name, item_ID, wPR, wYT, wTW, wMB, wUser.CB_createLabel);
          },

          saveLabel: function(item_ID) {
              Wadjebug.Log('wUser.saveLabel');

              var lbl_Name = $('txtNewLabel').value;
              wadja.showLoading('Saving Label "' + lbl_Name + '"', 'Still Saving Label', 5)

              var wYT = true;
              var wTW = true;
              var wPR = 4;

              if (typeof bYT !== "undefined") wYT = bYT;
              if (typeof bTW !== "undefined") wTW = bTW;
              if (typeof bPR !== "undefined") wPR = bPR;

              lblAjax.send('saveLabel', lbl_Name, item_ID, wPR, wYT, wTW, function(res) {
                  tmpObj.close();
                  wUser.setType(currentView.type, item_ID, 1);
                  wUser.setPrivacyBar(wPR);
                  myFacebox = new mooFacebox();
              });
          },

          invite: function(lblID, lblName) {
              Wadjebug.Log('wUser.invite');

              var oInvites = ",";
              $(document.body).getElements('input[id^=chkBox_]').each(function(el) {
                  if (el.checked) {
                      oInvites += (el.value + ",");
                  }
              });
              boxInvite.close();
              alert(oInvites);
              //lblAjax.send('SendInvites', lblID, lblName, oInvites, function(res) { });

          },

          fixText: function(cntText) {
              Wadjebug.Log('wUser.fixText');
              return cntText.replaceAll('\n', ' ').replaceAll('<br>', ' ').replaceAll('<br/>', ' ').replaceAll('<br />', ' ');
          },

          CB_applyLabel: function(res) {
              Wadjebug.Log('wUser.CB_applyLabel');
              wUser.labelLabelsAdd(JSON.decode(res.value));
          },

          CB_createLabel: function(res) {
              Wadjebug.Log('wUser.CB_createLabel');

              wadja.hideLoading("Done!", 1);
              var oRes = JSON.decode(res.value);
              if (oRes.itemID >= 0) {
                  if (tmpObj != null)
                      tmpObj.close();
                  try {
                      if (boxNewLabel != null) //filters
                      {boxNewLabel.close();}
                  }
                  catch (e) {
                  }

                  //Reload left nav-display new label
                  //check to see if the left nav-display is visible or not
                  if ($('labelLeft')) {
                      labelListOBJ.loadLBs();
                  }
                  wadja.showBar('Your label ' + oRes.labelName + ' has been created!');

                  if (oRes.itemID > 0) {
                      wUser.labelLabelsAdd(oRes);
                  }

                  newLabel = oRes.labelID;
                  wUser.getUserLabels();
                  if ($('labelLeft')) {
                      labelListOBJ.loadLBs();
                  }

                  if ($('select_label')) {      //filters
                      jcollector.getlabels_dropdown(oRes.labelID);
                  }
              }
              else {
                  $('dvNewError').innerHTML = oRes.labelName;
              }
          },

          CB_Count: function(res) {
              Wadjebug.Log('wUser.CB_Count');

              if (res.value != null) {
                  if (res.value != "0") {
                      $('aNewFeeds').removeClass('dnd');
                      document.title = "(" + res.value + ") " + f_title_page;
                      $('aNewFeeds').getElement('span').innerHTML = res.value;
                      return;
                  }
              }

              document.title = f_title_page;
              $('aNewFeeds').addClass('dnd');
          },

          CB_loadLabelFeeds: function(res) {
              Wadjebug.Log('wUser.CB_loadLabelFeeds');

              var tmpTimer = new Date().getTime();

              var currentTime = new Date();
              //disabled.x:iGad.location = "/user/includes/ads.aspx/" + wUser.wadjaID + "&l=" + currentView.label + "&s=" + currentTime.getTime();
              //disabled:iGad.location = "/user/includes/ads.htm";
              document.title = f_title_page;

              // sync twitter
              sync.twitter(wUser.detailsID, currentView.label);
              sync.youtube(wUser.detailsID, currentView.label);
              ///

              if (res.value == null) {
                  wadja.hideLoading("An error occured!", 1);
                  return;
              }

              var oRes = res.value.split('@sp@l@it@'); //2

              wUser.feeds = JSON.decode(oRes[1]);

              if (currentView.minID == 0) {
                  //alert(oRes.length);
                  wUser.users = [];

                  if (oRes.length > 2) {
                      wUser.users = JSON.decode(oRes[2]);
                  }

                  if (oRes.length > 3) {
                      var tmlLbls = eval('wUser.DDL.' + currentView.type);
                      var tmCount = JSON.decode(oRes[3]);
                      curPageLabels = false;

                      for (var ti = 0; ti < tmlLbls.length; ti++) {
                          tmlLbls[ti].Count = 0;
                          for (var tj = 0; tj < tmCount.length; tj++) {
                              if (tmCount[tj].lblID == tmlLbls[ti].id) {
                                  tmlLbls[ti].Count = 1;

                                  if (!curPageLabels) curPageLabels = tmCount[tj].lblID;
                                  else curPageLabels += "," + tmCount[tj].lblID;

                                  break;
                              }
                          }
                      }
                      eval('wUser.DDL.' + currentView.type + ' = tmlLbls;');
                  }
                  else {
                      var tmlLbls = eval('wUser.DDL.' + currentView.type);
                      for (var ti = 0; ti < tmlLbls.length; ti++) {
                          tmlLbls[ti].Count = 0;
                      }
                      eval('wUser.DDL.' + currentView.type + ' = tmlLbls;');
                  }
              }

              wUser.parseFeeds(oRes[0]);

              // sync twitter
              sync.twitter(wUser.detailsID, curPageLabels);
              sync.youtube(wUser.detailsID, curPageLabels);

              if (doRefresh) {
                  window.setTimeout('wUser.checkNewItems();', 100);
              }

              // document.location.hash += ('#' + ((new Date().getTime()) - tmpTimer));
              // var jPage_endTime = Date.now();
              // var jPage_TotalTime = jPage_endTime - jPage_startTime;
              // $('debug_1').set('html', 'page load time in ms: ' + jPage_TotalTime);
          },

          CB_getUserLabels: function(res) {
              Wadjebug.Log('wUser.CB_getUserLabels');
              var oRes = res.value.split('@sp@l@it@');

              wUser.DDL.My = JSON.decode(oRes[0]);
              wUser.DDL.Follow = JSON.decode(oRes[1]);
              wUser.DDL.Every = JSON.decode(oRes[2]);

              for (var i = 0; i < wUser.DDL.My.length; i++) {
                  asMessage.push('#' + wUser.DDL.My[i].name.trim());
              }

              if (lFollow && !magicJohnson) {
                  wUser.startTheMagic();
              }
              else {
                  lMy = true;
              }

              if (newLabel) {
                  document.location.hash = '#labels/My/' + newLabel + '/1';
                  newLabel = false;
              }
          },

          CB_getFollowing: function(res) {
              Wadjebug.Log('wUser.CB_getFollowing');

              var oRes = res.value.split('@sp@l@it@');

              wUser.myfollow = JSON.decode(oRes[1]);

              if (lMy && !magicJohnson) {
                  wUser.startTheMagic();
              }
              else {
                  lFollow = true;
              }
          },

          startTimer: function() {
              clearInterval(refTimer);
              refTimer = setInterval(function() {wUser.countNewItems();}, 45000);
          },

          stopTimer: function() {
              Wadjebug.Log('wUser.stopTimer');
              clearInterval(refTimer);
          },

          toggleDDL: function(cssClass, oImg, oType) {
              Wadjebug.Log('wUser.toggleDDL');
              var isOpen = false;

              if (oType == 'MyUpdateLocation' || oType == 'MyUploadPhotos') {
                  if (getIFrameDocument('frame_file').getElementById('ddLbl' + oType).getElements('.' + cssClass).length == 0) {
                      isOpen = !ddlView[oImg.alt].open;
                  }
                  else {
                      getIFrameDocument('frame_file').getElementById('ddLbl' + oType).getElements('.' + cssClass).each(function(el) {
                          el.toggleClass('dnd');
                          isOpen = !el.hasClass('dnd');
                      });
                  }
              } else {
                  if ($('users').getElements('.' + cssClass).length == 0) {
                      isOpen = !ddlView[oImg.alt].open;
                  }
                  else {
                      $('users').getElements('.' + cssClass).each(function(el) {
                          el.toggleClass('dnd');
                          isOpen = !el.hasClass('dnd');
                      });
                  }
              }

              ddlView[oImg.alt].open = isOpen;

              wadja.createCookie("prof_My_" + this.detailsID + "_" + oImg.alt, (isOpen ? 1 : 0), 30);

              if (isOpen) {
                  if (oType == 'MyUpdateLocation' || oType == 'MyUploadPhotos')
                      getIFrameDocument('frame_file').getElementById('hrfDDL_' + oType + '_' + oImg.alt).addClass('lblSystem');
                  else
                      $('hrfDDL_' + oType + '_' + oImg.alt).addClass('lblSystem');
              }
              else {
                  if (oType == 'MyUpdateLocation' || oType == 'MyUploadPhotos')
                      getIFrameDocument('frame_file').getElementById('hrfDDL_' + oType + '_' + oImg.alt).removeClass('lblSystem');
                  else
                      $('hrfDDL_' + oType + '_' + oImg.alt).removeClass('lblSystem');
              }

              if (oImg.src.Contains("ddle-")) {
                  oImg.src = ((ddlView[oImg.rel] = isOpen) ? '/images/ddle-open.gif' : '/images/ddle-closed.gif');
              }
              else {
                  oImg.src = ((ddlView[oImg.rel] = isOpen) ? '/images/ddl-open.gif' : '/images/ddl-closed.gif');
              }
          },
          ///Remove friend request
          removeFriend: function(fID) {
              Wadjebug.Log('wUser.removeFriend');
              if (confirm(f_delete_Lbl)) {
                  lblAjax.send('RemoveFriend', fID, function() {
                      $('dvFriend').addClass('dnd');
                      wadja.showBar(friend_remove);
                      ///Change to +
                  });
              }

          },
          cancelFriend: function(fID) {
              Wadjebug.Log('wUser.cancelFriend');
              if (confirm(f_cancel_Lbl)) {
                  lblAjax.send('CancelFriend', fID, function() {
                      $('dvFriend').addClass('dnd');
                      wadja.showBar(friend_cancel);
                      ///Change to +
                  });
              }

          },
          ///Accept friend request
          acceptFriend: function(fID) {
              Wadjebug.Log('wUser.acceptFriend');
              lblAjax.send('AcceptFriend', this.detailsID, function() {
                  $('dvFriend').addClass('dnd');
                  wadja.showBar(friend_accept);
                  ///Change to x
              });
          },
          trashAll: function() {
              lblAjax.send('trashAll', currentView.label, function(res) {
                  document.location.hash = '#labels/my';
              });
          },
          friendlyLabelUrl: function() {
            //declare Ajax Call
            var wadjaxGetLabelID = new WADJAX('Labels', {statusBar: false});
            var otmp = document.location.hash;

            if (otmp.length >0){
                 //---START ajax ASYNC call---
                 wadjaxGetLabelID.send('getLabelID', otmp.substring(1), function(oRes){
                     //alert('oRes.value: ' + oRes.value);
                     if (oRes.value != 0) {
                        wUser.setType('My', oRes.value, 1);
                     } else {
                        wUser.setType('Follow', 0, 1);
                     }
                 });
                 //---END ajax ASYNC call---
            }
         },
         startTheMagic: function(e) {
              Wadjebug.Log('wUser.startTheMagic');
              magicJohnson = true;

              var curHash = top.location.hash.toLowerCase();

              var _Type = 'My';
              var _Label = 0;
              var _Page = 1;

              var arrHash = curHash.replaceAll('#', '').split('/');

              if (arrHash.length >= 3) _Label = arrHash[2];
              if (arrHash.length >= 4) _Page = arrHash[3];

              if (isOwner) {
                  $('hrfLblNew').removeClass('dnd');
              }

              if (curHash.Contains('labels/my')) {
                  _Type = 'My';
              }
              else if (curHash.Contains('labels/follow')) {
                  _Type = 'Follow';
              }
              else if (curHash.Contains('labels/every')) {
                  _Type = 'Every';
              }
              else if (curHash.Contains('labels/all')) {
                  _Type = 'Every';
              }
              else if (isOwner) {
                  _Type = wadja.readCookie("prof_Tabs_" + this.detailsID);
                  //alert(_Type);
                  if (_Type == null)
                  {_Type = 'Follow';}
              }
              else {
                  _Type = 'My';
                  //_Type = 'Follow';
              }

              if (_Type != 'My' && _Type != 'Every' && _Type != 'Follow' && _Type != 'All') {
                  //_Type = 'My';
                  _Type = 'Follow';
              }

              if (curHash.replaceAll('#', '').split('/')[0] == 'search')
                  return;

              if(curHash.length > 3 && curHash.replaceAll('#', '').split('/').length == 1)
                this.friendlyLabelUrl();
              else
                wUser.setType(_Type, _Label, _Page);

              isLoaded = true;
              this.startTimer();

              if (showTipBanner == "0")
                  OpenHowto();
          }
      };

//sync Twitter, Youtube
var sync = {
    twitter: function(par1, par2) {
        Wadjebug.Log('sync.twitter');

        doRefresh = false;
        //par1:user's detailsid,par2:current page label

        twiAjax.send('Twitter', par1, par2, function(res) {
            if (res.value == 1) {
                doRefresh = true;
            }
        });
    },
    youtube: function(par1, par2) {
        Wadjebug.Log('sync.youtube');
        doRefresh = false;
        //par1:user's detailsid,par2:current page label

        twiAjax.send('YouTube', par1, par2, function(res) {
            if (res.value == 1) {
                doRefresh = true;
            }
        });
    }
}

function WADJAX_labels_my() {
    Wadjebug.Log('WADJAX_labels_my');
    if (isLoaded)
        wUser.setType('My', (arguments.length == 0 ? 0 : arguments[0]), (arguments.length <= 1 ? 1 : arguments[1]));
}

function WADJAX_labels_follow() {
    Wadjebug.Log('WADJAX_labels_follow');
    if (isLoaded)
        wUser.setType('Follow', (arguments.length == 0 ? 0 : arguments[0]), (arguments.length <= 1 ? 1 : arguments[1]));
}

function WADJAX_labels_every() {
    Wadjebug.Log('WADJAX_labels_every');
    if (isLoaded)
        wUser.setType('Every', (arguments.length == 0 ? 0 : arguments[0]), (arguments.length <= 1 ? 1 : arguments[1]));
}

function WADJAX_labels_all() {
    Wadjebug.Log('WADJAX_labels_all');
    if (isLoaded)
        wUser.setType('All', (arguments.length == 0 ? 0 : arguments[0]), (arguments.length <= 1 ? 1 : arguments[1]));
}

function WADJAX_labels_refresh() {
    Wadjebug.Log('WADJAX_labels_refresh');
    wUser.checkNewItems();
    document.location.href = '#labels';
}
///Filter feeds
///0:To/From me, 1:From me, 2:To me, 3:Everyone, 4:Wadja Team
function WADJAX_labels_filter() {
    Wadjebug.Log('WADJAX_labels_filter');
    //remove:currentView.page = 1;
    currentView.filter = arguments[0];

    if (currentView.filter == 1) //if filter From is chosen from the dropdown menu
    {
        if (!isOwner)
            $('dvFilter0').title = vFrom + ' ' + wUser.wadjaID; //div title = "From user"
        else $('dvFilter0').title = vFrom + ' ' + vMe;
    }
    else if (currentView.filter == 2) //if filter To is chosen from the dropdown menu
    {
        if (!isOwner)
            $('dvFilter0').title = vTo + ' ' + wUser.wadjaID;
        else $('dvFilter0').title = vTo + ' ' + vMe;
    }
    else {
        if (!isOwner)
            $('dvFilter0').title = vFromTo + ' ' + wUser.wadjaID;
        else $('dvFilter0').title = vFromTo + ' ' + vMe;
    }

    ['tofromImage', 'fromImage', 'toImage'].each(function(item, index) {
        if (index == currentView.filter) {
            $('dvFilter0').addClass(item);
        }
        else {
          $('dvFilter0').removeClass(item);
        }
    });

    //               
    //      ['0', '1', '2','3','4'].each(function(item, index) {
    //          if (item == currentView.filter) {
    //             if ($('dvFilter' + item)) 
    //                $('dvFilter' + item).addClass('top-sel');
    //          }
    //          else {
    //              if ($('dvFilter' + item))
    //                $('dvFilter' + item).removeClass('top-sel');
    //          }
    //      });

    wUser.loadLabelFeeds();
}


function WADJAX_labels_apply(labelID, itemID) {
    Wadjebug.Log('WADJAX_labels_apply');
    wUser.applyLabel(itemID, labelID);
}

var boxNew;
function WADJAX_labels_create() {
    Wadjebug.Log('WADJAX_labels_create');
    closeDropDown();

    var tmpLabelID = 0;

    if (arguments.length > 0)
        tmpLabelID = arguments[0];

    if (arguments.length > 1) {
        tmpLabelName = arguments[1];

        //wUser.createLabel(0, tmpLabelName);
        wUser.createLabel(0);
    }
    else {
        boxNew = new Facebox({
            title: 'New label',
            url: "/user/new.aspx?label=" + tmpLabelID,
            width: 500
        });
        boxNew.show();
    }

    document.location.href = '#labels';
}

//var boxInvite;
//function WADJAX_labels_invite(labelID, oName) {
//    Wadjebug.Log('WADJAX_labels_invite');
//    boxInvite = new Facebox({
//        title: 'Invite friends to follow this label',
//        url: "/user/frames/iframe.aspx?label=" + labelID + '&name=' + oName,
//        width: 500,
//        height:300
//    });
//    boxInvite.show();
//    document.location.href = '#labels';
//}

var boxInvite
function WADJAX_labels_invite(labelID, oName) {
    boxInvite = new Facebox({
        url: '/invite/iframe.aspx?lid=' + labelID,
        width: 550,
        height: 430,
        title: "Invite to follow",
        cancelValue: "Close",
        submitValue: "Send Invitations",
        submitFunction: function() {
            var inviteSent = document.getElementById('frame_file').contentWindow.SendInvitations();
            if (inviteSent != false)
                boxInvite.close();
        }
    });
    boxInvite.show();
    document.location.href = '#labels';
}

function WADJAX_labels_nofollow(labelID, oName) {
    Wadjebug.Log('WADJAX_labels_nofollow');

    lblAjax.send('EditFollow', wUser.detailsID, labelID, false, function(res) {

        for (var i = 0; i < wUser.myfollow.length; i++) {
            if (wUser.myfollow[i].Owner == wUser.detailsID && wUser.myfollow[i].ID == labelID) {
                wUser.myfollow.splice(i, 1);
                break;
            }
        }

        $('aFollow').innerHTML = FollowtheLabel;
        $('aFollow').href = '#labels/yesfollow/' + labelID + '/' + oName;
        $('aFollow').style.backgroundColor = '#68a548';

        document.location.href = '#labels/My/' + currentView.label + '/' + currentView.page;
    });

}

function WADJAX_labels_yesfollow(labelID, oName) {
    Wadjebug.Log('WADJAX_labels_yesfollow');
    lblAjax.send('EditFollow', wUser.detailsID, labelID, true, function(res) {
        var tmpFollow = {Owner: wUser.detailsID, ID: labelID, Name: oName};
        wUser.myfollow.push(tmpFollow);

        $('aFollow').innerHTML = StopTofollow;
        $('aFollow').href = '#labels/nofollow/' + labelID + '/' + oName;
        $('aFollow').style.backgroundColor = '#d74848';

        document.location.href = '#labels/My/' + currentView.label + '/' + currentView.page;
    });

}

function WADJAX_labels_invitefollow(LabelID, DetailsID, LabelName) {
    Wadjebug.Log('WADJAX_labels_invitefollow');
    lblAjax.send('SendInvites', LabelID, '', DetailsID, function(res) {
        //$('aFollow_' + DetailsID).innerHTML = Blockfromfollow;
        $('aFollow_' + DetailsID).href = '#labels/blockfollow/' + LabelID + '/' + DetailsID;
        document.location.href = '#labels';
    });

}

function WADJAX_labels_blockfollow(LabelID, DetailsID) {
    Wadjebug.Log('WADJAX_labels_blockfollow');
    lblAjax.send('BlockFollow', LabelID, DetailsID, function(res) {
        $('aFollow_' + DetailsID).innerHTML = InviteTofollow;
        $('aFollow_' + DetailsID).href = '#labels/invitefollow/' + LabelID + '/' + DetailsID;
        document.location.href = '#labels';
    });

}

function WADJAX_labels_trash(itemID) {
    Wadjebug.Log('WADJAX_labels_trash');
    lblAjax.send('Trash', itemID, function(res) {
        var thisSlider = new Fx.Slide($('fItem_' + itemID), {duration: 750, hideOverflow: false});
        thisSlider.slideOut();

        window.setTimeout(function() {
            if ($('fItem_' + itemID).getParent().id == 'dvFeeds') {
                $('fItem_' + itemID).destroy();
            } else {
                $('fItem_' + itemID).getParent().destroy();
            }
            $('ulTemp').empty();
        }, 1000);
    });
}

function WADJAX_labels_star(itemID) {
    Wadjebug.Log('WADJAX_labels_star');
    if ($('fItem_' + itemID).getElement('.lblContainer').innerHTML.Contains('lblStarred'))
        return;

    lblAjax.send('Star', itemID, function(res) {
        $('hrfStar' + itemID).addClass('dnd');
        $('fItem_' + itemID).getElement('.lblContainer').innerHTML += '<div class="lblBox border-radius cssOwner lblStarred" id="labelBox_4_' + itemID + '"><a class="border-radius" href="#labels/My/4/1">Starred</a> <span class="border-radius" onclick="return wUser.removeLabel(4, ' + itemID + ')">X</span></div>';
    });

}

function WADJAX_labels_timer() {
    //    Wadjebug.Log('WADJAX_labels_timer');
    //    var tmpItem = $('dvFilters').getElement('.dvTimer');

    //    if (tmpItem.innerHTML == "Pause") {
    //        wUser.stopTimer();
    //        tmpItem.innerHTML = "Play";
    //    } else {
    //        wUser.startTimer();
    //        tmpItem.innerHTML = "Pause";
    //    }

    //    document.location.href = '#labels';
}

function WADJAX_labels_link(linkType, linkLabel, linkFilter) {
    currentView.type = linkType;
    currentView.label = linkLabel;
    currentView.filter = linkFilter;
    //reload feeds
    wUser.setType(linkType, linkLabel, 1);
    WADJAX_labels_filter(linkFilter);
}

function WADJAX_labels_trashall() {
    if (currentView.label == 0) {
        alert(f_alert_lbl);
    } else if (confirm(f_deleteall_lbl.replaceAll('<br/>', '\n'))) {
        wUser.trashAll();
    }
}

function WADJAX_profile_add(friendID) {
    jCompose.Type = "Add";
    jCompose.Add = friendID;
    $('txtBody').value = 'Hi ' + nmOwner + ', ' + '\n' + nmGuest + ' would like to add you as a friend.';
    ///Change to ?
    $('dvFriend').addClass('dnd');
}

wUser.detailsID = tmpUser_dID;
wUser.wadjaID = tmpUser_wID;

wUser.getUserLabels();
wUser.getFollowing();

window.addEvent('domready', function() {
    if (gup('sURL')) {
        url_query = gup('sURL');
    }

    $('txtLabels').addEvent('keydown', function(evt) {
        if (evt.key == 'enter') return false;
    });

    $('txtLabels').addEvent('keyup', function() {
        wUser.loadLabelsDDL($('txtLabels').value, wUser.DDL.My, 'My');
    });

    $('hrfLblMy').getElement('span').addEvent('click', function(event) {
        event.stopPropagation();
        //});
        //$('hrfLblMy').addEvent('mouseover', function (event) {
        $('txtLabels').value = "";
        wUser.loadLabelsDDL($('txtLabels').value, wUser.DDL.My, 'My');
        dropdownmenu($('hrfLblMy'), event, 'ddLblMy', 0, 2);
        try {$('txtLabels').focus();} catch (e) { }
        return false;
    });

    $('txtLabelsFollow').addEvent('keydown', function(evt) {
        if (evt.key == 'enter') return false;
    });

    $('txtLabelsFollow').addEvent('keyup', function() {
        wUser.loadLabelsDDL($('txtLabelsFollow').value, wUser.DDL.Follow, 'Follow');
    });

    $('hrfLblFollow').getElement('span').addEvent('click', function(event) {
        event.stopPropagation();
        //});
        //$('hrfLblFollow').addEvent('mouseover', function (event) {
        $('txtLabelsFollow').value = "";
        wUser.loadLabelsDDL($('txtLabelsFollow').value, wUser.DDL.Follow, 'Follow');
        dropdownmenu($('hrfLblFollow'), event, 'ddLblFollow', 0, 2);
        try {$('txtLabelsFollow').focus();} catch (e) { }
        return false;
    });

    $('txtLabelsEvery').addEvent('keydown', function(evt) {
        if (evt.key == 'enter') return false;
    });

    $('txtLabelsEvery').addEvent('keyup', function() {
        wUser.loadLabelsDDL($('txtLabelsEvery').value, wUser.DDL.Every, 'Every');
    });

    $('hrfLblEvery').getElement('span').addEvent('click', function(event) {
        event.stopPropagation();
        //});
        //$('hrfLblEvery').addEvent('mouseover', function (event) {
        $('txtLabelsEvery').value = "";
        wUser.loadLabelsDDL($('txtLabelsEvery').value, wUser.DDL.Every, 'Every');
        dropdownmenu($('hrfLblEvery'), event, 'ddLblEvery', 0, 2);
        try {$('txtLabelsEvery').focus();} catch (e) { }
        return false;
    });

    $('txtLabelsApply').addEvent('keyup', function() {
        wUser.loadLabelsDDL($('txtLabelsApply').value, wUser.DDL.My, 'Apply');
    });
});



function ToggleCheckBox(idCheckBox) {
    Wadjebug.Log('ToggleCheckBox');
    $(idCheckBox).checked = !$(idCheckBox).checked;
}

function checkBoxes(chkBox, toWhat) {
    Wadjebug.Log('checkBoxes');
    $(document.body).getElements('input[type=checkbox]').each(function(el) {
        if (el.id.indexOf(chkBox) == 0) {
            el.checked = toWhat;
        }
    });
}

function faddphoto() {
    Wadjebug.Log('faddphoto');
    wUser.setType('My', 11, 1);
    $('compose').getElement('.imgProfile').src = "/components/cropImage.aspx?user=" + wUser.wadjaID + "&height=85&width=85&nocache=" + Math.random();
    tmpObj.close();
}

function toggleCountry(toWhat, oType) {
    Wadjebug.Log('toggleCountry');

    wUser.exclude.Every = [];

    $('ulLbl' + oType).getElements('input[type=checkbox]').each(function(el) {
        if (el.hasClass('chkLoc')) {
            el.checked = toWhat;
        }

        if (el.checked) {
            wUser.exclude.Every.push(el.id.replaceAll('chkLabelEvery_', ''));
        }
    });

    currentView.type = oType;
    if (oCall_Backs.length == 0) oCall_Backs.push('wUser.loadLabelFeeds();');
}

function LoginAnonymous() {
    Wadjebug.Log('LoginAnonymous');

    $("logMsg").style.display = "none";
    aEmail = $("aEmail").value;
    aPassword = $("aPassword").value;

    validation_anonymousLogin.LoginAnonymous(aEmail, aPassword, function(res) {
        if (!res.error) {
            if (res.value == "1") {
                $("logForm").style.display = "none";
                $("logMsg").style.display = "";
                $("logMsg").innerHTML = success_login;
            }
            else {
                $("logMsg").style.display = "";
                $("logMsg").innerHTML = error_login;
            }
        }
        else
            alert(res.error);
    });
}

//handle querystrings
function gup(name) {
    Wadjebug.Log('gup');
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");

    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);

    if (results == null)
        return "";
    else
        return results[1];
}

function ShowCreditsNotification() {
    Wadjebug.Log('ShowCreditsNotification');
    if (creditNotification == "1") {
        //start('notification_bar');
        //canvas.opacity('notification_bar', '0.9');
        //$('notification').set('html', verSMS);
        wadja.showBar(verSMS);
    }
}
//toggle html elements

//function start(elementID) {
//    Wadjebug.Log('start');
//    $('notification_bar').style.display = '';
//}

//function end(elementID) {
//    Wadjebug.Log('end');
//    $('notification_bar').style.display = 'none';
//}

//var canvas = {
//    opacity: function(elementID, opacityvalue) {
//        Wadjebug.Log('canvas.opacity');
//        $(elementID).set('opacity', opacityvalue);
//    }
//}

///Manage filters GUI
var jGUI = {
    snapabug_on: function() {
        if ($('SnapABug_bImg'))
            $('SnapABug_bImg').removeClass('');
    },
    snapabug_off: function() {
        if ($('SnapABug_bImg'))
            $('SnapABug_bImg').addClass('');
    },
    location_on: function() {
        //$('dvLocation_FindMe').removeClass('dnd');
        //$('dvLocation_sep').removeClass('dnd');
        $('dvLocation_CheckIn').removeClass('dnd');
    },
    location_off: function() {
        //$('dvLocation_FindMe').addClass('dnd');
        //$('dvLocation_sep').addClass('dnd');
        $('dvLocation_CheckIn').addClass('dnd');
    },
    help_on: function() {
        //$('dvFilter3_sep').removeClass('dnd');
        //$('dvFilter3').removeClass('dnd');

        $('dvFilter4_sep').addClass('dnd');
        $('dvFilter4').addClass('dnd');
         $('dvFilter5_sep').addClass('dnd');
        $('dvFilter5').addClass('dnd');

        $('dvFilter0_sep').removeClass('dnd');
        $('dvFilter0').removeClass('dnd');

        //$('dvFilter1_sep').removeClass('dnd');
        // $('dvFilter1').removeClass('dnd');

        //        $('dvFilter2_sep').removeClass('dnd');
        //        $('dvFilter2').removeClass('dnd');

        if (currentView.type.toLowerCase() == 'every') {
            $('dvFilter0_sep').addClass('dnd');
            $('dvFilter0').addClass('dnd');
            
            // $('dvFilter1').set('href', '#labels/link/My/7/1');
            //$('dvFilter2').set('href', '#labels/link/My/7/2');
            $('dvFilter3').set('href', '#labels/filter/3');
            $('dvFilter4').set('href', '#labels/follow/20/1');
            
        }
        else {
            $('dvFilter0_sep').removeClass('dnd');
            $('dvFilter0').removeClass('dnd');
            
             //$('dvFilter0').set('href', '#labels/filter/0');
            // $('dvFilter1').set('href', '#labels/filter/1');
            //$('dvFilter2').set('href', '#labels/filter/3');
            $('dvFilter3').set('href', '#labels/every/7/1');
            $('dvFilter4').set('href', '#labels/follow/20/1');
        }
    },
    help_off: function() {
        $('dvFilter3_sep').addClass('dnd');
        $('dvFilter3').addClass('dnd');
        $('dvFilter4_sep').addClass('dnd');
        $('dvFilter4').addClass('dnd');
    },
    friends_on: function() {
        $('dvFilter5_sep').removeClass('dnd');
        $('dvFilter5').removeClass('dnd');
    },
    friends_off: function() {
        $('dvFilter5_sep').addClass('dnd');
        $('dvFilter5').addClass('dnd');
    },
    search_on: function() {
        $('dvsearch_options').removeClass('dnd');
        $('dvFilters').removeClass('dnd');
    },
    search_off: function() {
        if ($('dvsearch_options'))
            $('dvsearch_options').addClass('dnd');
    },
    trash_on: function() {
        if (isOwner)
            $('dvTrashAll').removeClass('dnd');

    },
    trash_off: function() {
        $('dvTrashAll').addClass('dnd');
    },
    fromto_off: function() {
        $('dvFilter0_sep').addClass('dnd');
        $('dvFilter0').addClass('dnd');
        //  $('dvFilter1_sep').addClass('dnd');
        //  $('dvFilter1').addClass('dnd');
        //        $('dvFilter2_sep').addClass('dnd');
        //        $('dvFilter2').addClass('dnd');
    },
    fromto_on: function() {
        $('dvFilter0_sep').removeClass('dnd');
        $('dvFilter0').removeClass('dnd');

        //  $('dvFilter1_sep').removeClass('dnd');
        //  $('dvFilter1').removeClass('dnd');

        //        $('dvFilter2_sep').removeClass('dnd');
        //        $('dvFilter2').removeClass('dnd');

        if (currentView.type.toLowerCase() == 'every') {
            $('dvFilter0').set('href', '#labels/filter/0');
            //     $('dvFilter1').set('href', '#labels/link/My/7/1');
            //    $('dvFilter2').set('href', '#labels/link/My/7/2');

            $('dvFilter3').set('href', '#labels/filter/3');
            $('dvFilter4').set('href', '#labels/follow/20/1');
        }
        else {
                $('dvFilter0').set('href', '#labels/filter/0');
            //    $('dvFilter1').set('href', '#labels/filter/1');
            //$('dvFilter2').set('href', '#labels/filter/2');
        }
    },
    hide_all: function() {
        jGUI.help_off();
        jGUI.friends_off();
        jGUI.fromto_off();
    }
}
///Meebo Rooms
var newwindow;
var meeboRm = {
    getEmbed: function(lblID, vwID) {
        /*lblAjax.send('GetRoom', lblID, vwID,
        function(res) {
        if (!res.error)
        alert(res.value);  ///call pop link              
        }
        );*/
        meeboRm.openChatPopup(vwID, lblID);
    },
    roomExists: function(lblID, vwID) {
        lblAjax.send('roomExists', lblID, vwID,
            function(res) {
                if (!res.error) {
                    if (res.value == 'True') {
                        //if(ismeeboo==true)
                        meeboRm.roomLink_on(lblID, vwID);
                    }
                    else //if(ismeeboo==false)
                        meeboRm.roomLink_off(lblID, vwID);
                }
            }
        );
    },
    roomEveryone_on: function() {
        if ($('LiveChat') && detailsID > 0)
            $('LiveChat').removeClass('dnd');
    },
    roomEveryone_off: function() {
        if ($('LiveChat'))
            $('LiveChat').addClass('dnd');
    },
    roomLink_on: function(lblID, vwID) {
        if ($('LiveChat') && detailsID > 0)
        //if(ismeeboo==true)//itsopelas : code added in order to check the Lab settings for meeboo for the user 
        {
            var chatName = '';
            if ((lblID.toString() == '7') && (vwID.toString() == '43'))
                chatName = 'Chat room - Everyone';
            else if ($('hLabelList_' + lblID))
                chatName = 'Chat room - ' + $('hLabelList_' + lblID).innerHTML;
            $('LiveChat').removeClass('dnd');
            $('LiveChatLink').set('href', 'javascript:meeboRm.getEmbed(' + lblID + ',' + vwID + ');');
            $('LiveChatLink').set('html', chatName);

        }
        // else if (ismeeboo==false) 
        //{
        // $('LiveChat').addClass('dnd');
        //}



        //            var chatName = '';
        //            if ((lblID.toString() == '7') && (vwID.toString() == '43'))
        //                chatName = 'Chat room - Everyone';
        //            else if ($('hLabelList_'+lblID))
        //                chatName = 'Chat room - ' + $('hLabelList_'+lblID).innerHTML;
        //            $('LiveChat').removeClass('dnd');
        //            $('LiveChatLink').set('href', 'javascript:meeboRm.getEmbed(' + lblID + ',' + vwID + ');');
        //            $('LiveChatLink').set('html', chatName);



        //inconversation:if ($('LiveChatInConv')) {
        //    $('LiveChatInConv').removeClass('dnd');
        //    $('LiveChatInConvLink').set('href', 'javascript:meeboRm.getEmbed(' + lblID + ',' + vwID + ');');
        //}
    },
    roomLink_off: function() {
        if ($('LiveChat'))
        //if(ismeeboo==false)//itsopelas : code added in order to check the Lab settings for meeboo for the user
            $('LiveChat').addClass('dnd');
        //if ($('LiveChatInConv'))
        //$('LiveChatInConv').addClass('dnd');
    },
    popstatic: function(url, name) {
        newwindow = window.open(url, name, 'height=700,width=700');
        if (window.focus) {newwindow.focus()}
    },
    openChatPopup: function(detailsID, lblLabelsID) {
        var popup_url = '/user/includes/chatroom.aspx?detailsID=' + escape(detailsID) + '&lblLabelsID=' + escape(lblLabelsID);
        var name = 'chatroom' + detailsID + lblLabelsID;
        meeboRm.popstatic(popup_url, name);
    }
}

function dlrPOPUP(dlrID) {
    var confirmbox = new Facebox({
        url: '/user/iframe_dlr.aspx?bid=' + dlrID,
        title: 'Delivery reports',
        cancelValue: 'Close',
        width: 550
    });
    confirmbox.show();
}

function facePOP(fcTitle, fcURL) {
    var fcPOP = new Facebox({
        title: fcTitle,
        url: fcURL
    });
    fcPOP.show();
}

function PlaySoundLabel(surl) {
    if (surl != '') {
        $('soundEmbedSpan').set('html', '<embed src="' + surl + '" hidden="true" volume="100" autostart="true" loop="false">');
    }
}

function StopSound() {
    $('soundEmbedSpan').set('html', '');
}

function GetHideElements() {
    var hideElements = "<ul class=\"submenuProfile\"><li><span class=\"padR5 f_l padT6\">";
    hideElements += "<input type=\"checkbox\"/></span><span class=\"f_l\">";
    hideElements += "<a href=\"#1\">Message</a>";
    hideElements += "</span></li></ul>";

    return hideElements;
}
function OpenHowto() {
    var howtobox = new Facebox({
        url: '/howto/howto_banner.aspx',
        width: 550,
        //height: 227,
        title: 'All your messaging in one place',
        cancelValue: vclose,
        cancelFunction: function() {
            HideTipBanner();
            howtobox.close();
        }
    });
    howtobox.show();
}

function HideTipBanner() {
    wadja.createCookie("tipbanner", "1", 365);
}

var steps = {
    next: function() {
    $('pop_1').addClass('dnd');
    $('pop_2').removeClass('dnd');
    $('next_btn').addClass('dnd');
    $('back_btn').removeClass('dnd');
        // class="greenButton" 
//        if (!$('pop_1').hasClass('dnd')) {
//            $('pop_1').addClass('dnd');
//            //$('pop_3').addClass('dnd');
//            //$('pop_4').addClass('dnd');

//            $('pop_2').removeClass('dnd');
//            //$('next_btn').removeClass('dnd');
//            $('back_btn').removeClass('dnd');
//        }
//        else if (!$('pop_2').hasClass('dnd')) {
//            $('pop_1').removeClass('dnd');
//            $('pop_2').addClass('dnd');
//            //$('pop_4').addClass('dnd');
//            //$('pop_3').removeClass('dnd');
//            $('next_btn').removeClass('dnd');
//            //$('back_btn').removeClass('dnd');
//        }
//        else if (!$('pop_3').hasClass('dnd')) {
//            $('pop_2').addClass('dnd');
//            $('pop_3').addClass('dnd');
//            $('pop_1').addClass('dnd');
//            $('pop_4').removeClass('dnd');
//            $('back_btn').removeClass('dnd');
//            $('next_btn').addClass('dnd');
//        }

    },
    previous: function() {
     $('pop_2').addClass('dnd');
    $('pop_1').removeClass('dnd');
    $('back_btn').addClass('dnd');
    $('next_btn').removeClass('dnd');
//        if (!$('pop_2').hasClass('dnd')) {
//            $('pop_1').removeClass('dnd');
//            //$('pop_3').addClass('dnd');
//            //$('pop_4').addClass('dnd');
//            $('pop_2').addClass('dnd');
//            $('back_btn').addClass('dnd');
//            $('next_btn').removeClass('dnd');
//        }
//        else if (!$('pop_3').hasClass('dnd')) {
//            $('pop_2').removeClass('dnd');
//            $('pop_1').addClass('dnd');
//            $('pop_4').addClass('dnd');
//            $('pop_3').addClass('dnd');
//            $('back_btn').removeClass('dnd');
//            $('next_btn').removeClass('dnd');
//        }
//        else if (!$('pop_4').hasClass('dnd')) {
//            $('pop_3').removeClass('dnd');
//            $('pop_1').addClass('dnd');
//            $('pop_4').addClass('dnd');
//            $('pop_2').addClass('dnd');
//            $('back_btn').removeClass('dnd');
//            $('next_btn').removeClass('dnd');
//        }
    }
}


