;

/* settings:
 {:use_versioning=>false, :empty_template=>false, :file_handler=>"AnyHandableFile", :use_frontend=>true, :indirect_service_write_access=>"0", :use_system=>false}
*/

// /8::/202::/frontend:js -> <875> actionwidgetoverride.js 

ActionWidget = Class.create();
ActionWidget.prototype = {
  defaultOptions: function() {
    return {
      model: itemModel
    };
  },
  setup: function(){
    this.options.model.addObserver(this); 
  },
  afterAddFolderAllowedChanged: function() {
    this.redrawCompletely();
  },
  afterPathChanged: function() {
    this.redrawCompletely();
  },
  getHelpNode: function(alt) {
    var map = {
      "add item":    "Add Item in Actions Box",
      "add folder":  "Add Folder in Actions Box",
      "empty trash": "Empty Trash in Actions Box"
    }
    if (map[alt]) {
      return helpTexts.helperNode(map[alt], 14);
    }
    else {
      return EMPTY();
    }
  },
  itemAdd: function() {
    return this.generalAction(
      "add_item",
      "add item",
      translateText({path: ".action-widget", id: "add-item", args: [
        this.options.model.itemType()
      ]}),
      function() {
        this.options.model.actions.addItem();
      }.bind(this))
  },
  folderAdd: function() {
    var f = function() {
      this.options.model.actions.addFolder()
    }.bind(this)
    return this.generalAction(
      "add_folder",
      "add folder",
      translateText({path: ".action-widget", id: "add-folder"}),
      f
    )
  },
  emptyTrash: function() {
    var f = function() {
      verify(function() {
        this.options.model.emptyTrash();
      }.bind(this),
      "Delete all items in the Trash? This cannot be undone!") 
    }.bind(this)
    return this.generalAction(
      "delete",
      "empty trash",
      translateText({path: ".action-widget", id: "empty-trash"}),
      f
    )
  },
  generalAction: function(name, alt, msg, onclick) {
    var options = Object.extend({
      img_path: "/images/icons/mycons/24x24/" + name + ".png",
      link: false
    }, arguments[4] || {})
    var icon = Builder.node('img', {
      src: options.img_path,
      alt: alt,
      style: "border: 0px;"
    })
    if (typeof msg == "string") {
      var descr = TN(msg)
    }
    else {
      var descr = msg
    }
    if (options.link) {
      descr = Builder.node('a', {
        href: options.link,
        style: "border: 0px;color:black;text-decoration: none;"
      }, [descr])
      icon = Builder.node('a', {
        href: options.link,
        style: "border: 0px;color:black;text-decoration: none;"
      }, [icon])
    }
    var div = Builder.node('div', {
      style:"padding:5px;cursor:pointer;font-size:110%;font-weight:bolder;"
    }, [
      table({style:"text-align:left;"}, [
        {columnOptions:{width:"20%"},columnData:[icon]},
        {columnData:[descr, this.getHelpNode(alt)]}
      ])
    ])
    if (onclick) div.onclick = onclick
    div.onmouseover = function() {
      this.style.color = "black";
      this.style.background = "#efefef";      
    }
    div.onmouseout = function() {
      this.style.color = "black";
      this.style.background = "white";       
    }
    return div
  },
  makeWidgetContent: function(){
    var instance = this;
    var r = [];
    if (this.options.model.canWrite()){
      var cp = this.options.model.currentPath()
      if (cp == "/trash" || cp.startsWith("/trash/")) {
        r.push(this.emptyTrash());        
      }
      else {
        r.push(this.itemAdd());
        if (this.options.model.addFolderAllowed()){
          r.push(this.folderAdd())
        }        
      }
    }
    else {  
      var noadd = Builder.node('div',{
        style:"padding:5px;color:red;font-weight:bold;"
      },[
        translateText({path: ".action-widget", id: "no-permission"})
      ]);  
      r.push(noadd);
    }
    return Builder.node('span', {}, [r]);
  }
}
Object.extend(ActionWidget.prototype, WidgetCommon); 

;

// /8::/202::/frontend:js -> <8423> addbuddywidget.js 

addBuddyWidget = Class.create();
addBuddyWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({data:"",user:""},arguments[0]);
  },
  makeWidgetContent: function(){
    var aab = Builder.node('span')
    if (logged_in) {
      var dm = new DisplayModel({
        user: writeUserModel.data.username,
        service: "buddies"
      })
      dm.addObserver({update: function() {
        if (!$A(dm.getModel()).any(function(b) {
          return b.name == this.options.user
        }.bind(this))) {
          aab.appendChild(Builder.node('a',{
            href: serviceLink({
              user: write_username,
              service: "buddies",
              action: "?action=add_buddy&username=" + this.options.user
            }),
            style:"font-size:100%;text-decoration:none;color:black;",
            target: "_blank"
          },[
            translateText({path: ".add-buddy-widget", id: "add-as-buddy"})
          ]))
        }
      }.bind(this)})
    }
    return aab
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(addBuddyWidget.prototype, WidgetCommon); 

;

// /8::/202::/frontend:js -> <9106> badgewidget.js 

var BadgeWidget = {
  setup: function() {
    Object.extend(this, ConversationView)
  },
  makeWidgetContent: function() {
    var r = Builder.node('div', {
      id:        this.options.type+'_badge',
      style:     this.options.style,
      className: this.options.type + "_badge" //"badge"
    })
    if (itemModel.paramsInfo()) {
      r.appendChild(TN(itemModel.paramsInfo()))
      r.appendChild(BR())
    }
    if (itemModel.paramsLoginError() && this.loginErrorView) {
      r.appendChild(this.loginErrorView())
      r.appendChild(BR())
    }
    r.appendChild(this.makeProfileContent());
    return r;
  },
  getUserModel:function(){
    if (!this.userModel) {
      var userimage;
      if (this.options.profile.data.userimage) {
        userimage = localizeURL(this.options.profile.data.userimage)
      }
      var onlineP = true // this.options.profile.data.online
      var status = onlineP ? "online" : "offline"
      this.userModel = {
        user: this.options.profile.data.username,
        thumbnail_image_url: userimage || "/images/user_thumb_placeholder.jpg",
        // status:Builder.node('img', {
        //   src: "/core-services/images/x"+status+".gif",
        //   border: 0
        // })
        status: Builder.node('span')
      }      
    }
    return this.userModel;
  },
  makePhraseBox: function() {
    var phrase = Builder.node('div',{
      id: this.options.type+"_uphrase",
      className: "uphrase",
      style: "overflow:hidden;width:100%;padding:2px;height:15px;" +
             "font-size:12px;font-weight:bolder"
    });
    var username = this.options.profile.data.username
    // Otherwise we might run into troubles. Maybe due to cached data,
    // the first time this is loaded for a user it actually tries to
    // change to the /updates folder which of course doesn't exist for
    // the guest user!
    if (username == "guest") username = "team"
    this.phraseModel = new DisplayModel({
      service: "messages",
      user: username,
      sortByColumn: "added_at",
      reverse: true
    })
    //this.phraseModel.observeOnce({update: function() {
    //  gtuf = function() {
    //    this.phraseModel.observeOnce({afterPathChanged: function() {
    //      this.phraseModel.addObserver({update: function() {
    //        ms = this.phraseModel.getModel()
    //        if (ms.length > 0) {
    //          phrase.innerHTML = ms[0].status              
    //        }
    //        else {
    //          if (this.phraseModel.canWrite()) {
    //            phrase.innerHTML = ""
    //            phrase.appendChild(translateText({path: ".badge", id: "write-message"}))
    //          }
    //          else {
    //            phrase.innerHTML = ""
    //            phrase.appendChild(translateText({path: ".badge", id: "no-message"}))
    //          }
    //        }
    //      }.bind(this)})
    //    }.bind(this)})
    //    this.phraseModel.changeToFolder("/updates")
    //  }.bind(this)
    //  if (this.phraseModel.findItemByName("updates")) {
    //    gtuf()
    //  }
    //  else if (this.phraseModel.canWrite()) {
    //    var f = this.phraseModel.addFolder()
    //    f.permission = "everyone"
    //    f.name = "updates"
    //    this.phraseModel.storeItem(f, {afterStore: function() {
    //      gtuf()
    //    }})
    //  }
    //  else if (this.phraseModel.user() == "guest") {
    //    phrase.innerHTML = ""
    //    phrase.appendChild(translateText({path: ".badge", id: "login-or-register"}))
    //  }
    //  else {
    //    phrase.innerHTML = ""
    //    phrase.appendChild(translateText({path: ".badge", id: "no-message"}))
    //  }
    //}.bind(this)})
    if (this.phraseStyle) Element.setStyle(phrase, this.phraseStyle())
    var tip = Builder.node('div',{
      style:"color:black;position:relative;z-index:3;overflow:hidden;margin-top:-3px;" +
            "margin-left:30px;height:7px;"
    },[
      Builder.node('img',{src:"/core-services/images/bubbletip.gif"})
    ]);

 /*edited by mike*/
    var roundbox = roundIt({className:"roundBtnT",node:phrase,width:"100%"})        
    var phrasebox = Builder.node('div',{
      style:"position:relative;top:-37px;left:18%;width:80%;color:black;"
    },[/*tip,*/phrase/*,roundbox*/]);
    if (this.phraseBoxStyle) Element.setStyle(phrasebox, this.phraseBoxStyle())
    if (writeUserModel == this.options.profile) {
      phrasebox.style.cursor = "pointer"
      Event.observe(phrasebox, 'click', this.updatesWindow.bindAsEventListener(this))
    }
    return phrasebox;
  },
  updatesWindow: function(event) {
    new ThemedWindow({
      maximizable: false,
      minimizable: false,
      showEffect: Element.show,
      hideEffect: Element.hide,
      width: 500,
      height: 500
    }, function(w) {
      w.setContent(this.conversationView({
        msgs: $A(this.phraseModel.getModel()).map(function(u) {
          u.message = u.status
          return u;
        }).reverse()
      }))
      w.setZIndex(10000) // for IE
      w.showCenter()
    }.bind(this))    
  },
  makeUserStatus: function() {
    // The user status, currently disabled
    var sl = Builder.node('div',{
      id:this.options.type+"_ustatus",
      className: "ustatus",
      style:"overflow:hidden;width:100%;height:100%;padding:3px;"
    },[
      this.getUserModel().status
    ]);
    sl.type = this.options.type;
    return sl
  },
  userNameBox: function() {
    var unameBox = Builder.node('div',{
      style:"overflow:hidden;width:130px;color:#000000;font-weight:bolder;"
    },[
      TN(this.getUserModel().user)
    ]);
    return unameBox
  },
  userPic: function() {
    if (!this.up) {
      this.up = Builder.node('img',{
        src: this.getUserModel().thumbnail_image_url,
        alt: 'userimage',
        style: 'height:50px;width:50px;z-index:1;border:1px solid silver;',
        border: 0
      })       
    }
    return this.up
  },
  makeProfileContent:function(){
    if (logged_in) {
      var upper = this.upperView()
      var lower = this.lowerView()
    }
    else {
      var upper = this.loginViewUpper()
      var lower = this.loginViewLower()
    }
    var innertable = table(
      {cellspacing:0,cellpadding:0,border:0},
      [{columnOptions:{height:30},columnData:[upper]}],
      [{columnOptions:{height:30},columnData:[lower]}]
    )
    var phrasebox = this.makePhraseBox()
    var mainDiv = Builder.node('div',{},[
      this.mainView(innertable,phrasebox),
      phrasebox
    ]);
    return mainDiv;
  },
  cvSetup: function(c) {
    this.cv.model = this.phraseModel
  },
  cvFormSubmit: function(message, c, msgs) {
    this.phraseModel.storeItem(this.phraseModel.addItem({
      status: message,
      name: "update",
      permission: "everyone"
    }), {afterStore: function(m) {
      m.message = m.status
      this.cvUpdateView(m, c, msgs)
    }.bind(this)})    
  }
}

Object.extend(BadgeWidget, WidgetCommon)

;

// /8::/202::/frontend:js -> <865> boxwidget.js 

BoxWidget = Class.create();
BoxWidget.prototype = {
    defaultOptions: function() {
        return Object.extend({title:TN("someHead"),node:TN("content"),draggable:false,width:"100%",id:"b1"},arguments[0]|{});
    },
    setup:function(){

    }, 
    makeWidgetContent: function() { 
        var table = Builder.node('table',{cellpadding:0,cellspacing:0,width:this.options.width},[]);
        var tbody = Builder.node('tbody',{},[]);

        var tr1 = Builder.node('tr',{width:"100%"},[]);
        var tr2 = Builder.node('tr',{width:"100%"},[]);
        var tr3 = Builder.node('tr',{width:"100%"},[]);
 
        var td11 = Builder.node('td',{className:"bTL",width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td12 = Builder.node('td',{className:"bTF2",width:"100%"},[Builder.node('div',{className:"bTM"},[this.options.title])]);
        var td13 = Builder.node('td',{className:"bTF",width:"100%"},[Builder.node('div')]);
        var td14 = Builder.node('td',{className:"bTR",width:10},[Builder.node('div')]); 
 
        var td21 = Builder.node('td',{className:"bML",width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td22 = Builder.node('td',{className:"bMF",valign:"top"},[Builder.node('div',{style:"width:100%;overflow:hidden;",id:this.options.id+"_content",className:"bContent"},[this.options.node])]);
        var td23 = Builder.node('td',{className:"bMF",width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td24 = Builder.node('td',{className:"bMR",width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
 
        var td31 = Builder.node('td',{className:"bBL",width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td32 = Builder.node('td',{className:"bBM",width:"100%"},[]);
        var td33 = Builder.node('td',{className:"bBF",width:"100%"},[]);
        var td34 = Builder.node('td',{className:"bBR",width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
 
        appendChildren(tr1,[td11,td12,td13,td14]);
        appendChildren(tr2,[td21,td22,td23,td24]);
        appendChildren(tr3,[td31,td32,td33,td34]);
        appendChildren(tbody,[tr1,tr2,tr3]);
        table.appendChild(tbody);
        var thediv = Builder.node('div',{style:"width:"+this.options.width+";height:auto;"},[table]);
        if(this.options.draggable){
            new Draggable(thediv,{});
        }
        return thediv;
    },
    rerender: function(){
        var nc = this.makeWidgetContent()
        this.replaceChild(this.content, this.widgetContent, nc)
        this.widgetContent = nc
    },
    getId: function(){
        return this.options.id;
    },
    setContent:function(node){
        var wrapContent = Builder.node('div',{},[node]);
        $(this.getId()+"_content").replaceChild(wrapContent,$(this.getId()+"_content").down());
    } 
}
Object.extend(BoxWidget.prototype, WidgetCommon);   

;

// /8::/202::/frontend:js -> <31679> buddieswidget.js 

BuddiesWidget = Class.create();
BuddiesWidget.prototype = {
  defaultOptions: function() {
    return {}
  },
  makeWidgetContent: function() {
    var content = Builder.node('img', {src: "/images/spinner.gif"})
    var dm = new DisplayModel({
      service: "buddies",
      user: this.options.user,
      sortByColumn: "added_at",
      reverse: true
    })
    dm.addObserver({update: function() {
      var uninpT = translateButton({
        path: ".buddies-widget",
        id: "input",
        node: Builder.node('input', {
          type: "text",
          value: "",
          style: "border: 1px solid silver:color: #CCC;margin-right:5px;"
        })
      })
      var uninp = Element.down(uninpT, 'input')
      var defaultText = uninp.value
      var addUser = Builder.node('form', [table({width: ""},[
        Builder.node('img', {
          src: "/images/icons/mycons/24x24/add_item.png",
          alt: "back",
          border: 0,
          style: "margin-right:5px;"
        }),
        uninpT,
        translateButton({path: ".buddies-widget", id: "add-button"})
      ])])
      Event.observe(uninp, 'click', function(event) {
        Event.stop(event)
        if (uninp.value == defaultText) {
          uninp.value = ""
          uninp.style.color = "black"
        }
      })
      Event.observe(addUser, 'submit', function(event) {
        Event.stop(event)
        window.location.href = serviceLink({
          service: "buddies",
          user: this.options.user,
          action: "?action=add_buddy&username=" + escape(uninp.value)
        })
      }.bindAsEventListener(this))
      var buddies = table({})
      var tbody = Element.down(buddies, 'tbody')
      var back;
      var header = Builder.node('div', [
        back = Builder.node('div', {
          style: "font-weight:bold;cursor:pointer;font-style:italic;" +
                "font-variant:small-caps;display:none;"
        }, [table([
          Builder.node('img', {
            src: "/images/icons/mycons/24x24/previous.png",
            alt: "back",
            border: 0
          }),
          translateText({path: ".buddies-widget", id: "back"})
        ])]),
        addUser
      ])
      Event.observe(back, 'click', function(event) {
        Event.stop(event)
        $A([back,addUser,buddies,profileArea]).each(function(n) {
          Element.toggle(n)
        })
      })
      var profileArea = Builder.node('div', {style: "display:none;"})
      $MSH(dm.users()).each(function(pair) {
        if (pair.value.username == this.options.user) return;
        var tr = Builder.node('tr', [
          Builder.node('td', [
            Builder.node('img', {
              src: "/images/mybuddies.png",
              alt: '',
              title: '',
              border: 0,
              align: "absmiddle",
              style: "padding:3px;"
            })
          ]),
          Builder.node('td', {width: "100%"},[Builder.node('div', {
            style: "cursor:pointer;padding:3px;font-size:100%;font-weight:bolder;"
          }, [TN(pair.value.username)])])
        ])
        addMouseOver(tr)
        Event.observe(tr, 'click', function(event) {
          if (event) Event.stop(event)
          var pr = new ProfileDisplayModel({data: pair.value})
          var badge = new ReadUserBadgeWidget({profile: pr})
          profileArea.innerHTML = ""
          profileArea.appendChild(badge.htmlNode())
          profileArea.appendChild((new changeSiteWidget({
            profile: pr
          })).setPanelContent())
          $A([back,addUser,buddies,profileArea]).each(function(n) {
            Element.toggle(n)
          })
        }.bindAsEventListener(this))
        tbody.appendChild(tr)
      }.bind(this))
      var buddiesContent = Builder.node('div', {
        style: "padding:5px;"
      }, [
        header,
        Builder.node('hr', {
          style: "color:black;background-color:black;height:1px;border: 0px;"
        }),
        buddies,
        profileArea
      ])
      content.parentNode.replaceChild(buddiesContent, content)
    }.bind(this)})
    return content
  }
}

Object.extend(BuddiesWidget.prototype, WidgetCommon)
;

// /8::/202::/frontend:js -> <853> carousel.js 

 // VERSION 0.26

var Carousel = Class.create();
Carousel.prototype = {
  // Constructor
  initialize: function(carouselElemID) {
    this.carouselElemID = carouselElemID;
    
    this.options = Object.extend({
      numVisible:           4,
      scrollInc:            3,
      animParameters:      {},
      buttonStateHandler:  null,
      animHandler:         null,
      ajaxHandler:         null,
      initDoneHandler:     null,
      queue:               "carousel",
      size:                0,
      prevElementID:       "prev-arrow",
      nextElementID:       "next-arrow",
      ajaxParameters:      null,
      url:                 null
        }, arguments[1] || {});

        this.initDone = false;
        this.animRunning = "none";
    this.requestIsRunning = false;
    
        // add afterFinish options to animParameters (store old function)
        this.animAfterFinish = this.options.animParameters.afterFinish;
        Object.extend(this.options.animParameters, {afterFinish:  this._animDone.bind(this), queue: { position:'end', scope: this.options.queue }});
      
        // Event bindings
        this.prevScroll = this._prevScroll.bindAsEventListener(this);
        this.nextScroll = this._nextScroll.bindAsEventListener(this);
        this.onComplete = this._onComplete.bindAsEventListener(this);
        this.onFailure  = this._onFailure.bindAsEventListener(this);

        Event.observe(this.options.prevElementID, "click", this.prevScroll);
        Event.observe(this.options.nextElementID, "click", this.nextScroll);
        
        // Get DOM UL element
        var carouselListClass = "carousel-list";
        this.carouselList = document.getElementsByClassName(carouselListClass, $(carouselElemID))[0]
        this.options.size =  $(this.carouselList.getElementsByTagName("li")).length;
        // Init data
        this._init();
  },
  
  // Destructor
     destroy: function() {
      Event.stopObserving(this.options.prevElementID, "click", this.prevScroll);
      Event.stopObserving(this.options.nextElementID, "click", this.nextScroll);
    },
    
    scrollTo: function(newStart) {
        var old_inc = this.options.scrollInc;
        this.ignoreNoMoreImages = true;
        if(newStart > this.currentIndex) {
            this.options.scrollInc = newStart - this.currentIndex;
            this._nextScroll(this);
        } else {
            this.options.scrollInc = this.currentIndex - newStart;
            this._prevScroll(this);
        }
    this.options.scrollInc = old_inc;
    hook("scrolledSlider")
    },
    
  /* "Private" functions */
  _init: function() {
    this.currentIndex = 0;
      
    // Ajax content
    if (this.options.url)
        this._request(this.currentIndex, this.options.numVisible);
      // Static content
      else {
        this._getLiElementSize();
          this._updateButtonStateHandler(this.options.prevElementID, false);
          this._updateButtonStateHandler(this.options.nextElementID, this.options.size > this.options.numVisible);
      }
  },
  
  _prevScroll: function(event) {
    if (this.animRunning != "none" || this.currentIndex == 0)
      return;

    var inc = this.options.scrollInc;

    if (this.currentIndex - inc < 0)
      inc = this.currentIndex;

    this._scroll(inc)          
      return false;
  },
  
  _nextScroll: function(event) {    
    if (this.animRunning != "none")
      return false;
            
    // Check if there are enough elements in cache
    if (this.currentIndex + this.options.numVisible + this.options.scrollInc <= this.options.size) 
      this._scroll(-this.options.scrollInc);
    else {
      // Compute how many are in the cache
      this.nbInCache = this.options.size - (this.currentIndex + this.options.numVisible);
      if (this.options.url && this.noMoreImages == false) 
            this._request(this.currentIndex + this.options.numVisible + this.nbInCache, this.options.scrollInc - this.nbInCache);
        else  {
          if (this.nbInCache > 0)
          this._scroll(-this.nbInCache);
        }
      }
      return false;
  },
  
  _request: function(start, nb) {
    if (this.options.url && ! this.requestIsRunning) {
      this.requestIsRunning = true;
      
      if (this.options.ajaxHandler)
        this.options.ajaxHandler(this, "before");
      
      var params = "start=" + start + "&nb=" + nb;
      if (this.options.ajaxParameters != null)
        params += "&" + this.options.ajaxParameters
      
          new Ajax.Request(this.options.url, {parameters: params, onComplete: this.onComplete, onFailure: this.onFailure});
        }
  },
  
  _onComplete: function(originalRequest){
    this.requestIsRunning = false;
    this.carouselList.innerHTML += originalRequest.responseText;
    // Compute how many new elements we have
    var size = this.options.size;
    this.options.size = this.carouselList.getElementsByTagName("li").length;
    var inc = this.options.size - size;
    
        // First run, compute li size
        if (this.initDone == false) {
          this._getLiElementSize()
          this.currentIndex = 0;
          this.initDone = true;
      if (this.options.initDoneHandler) 
        this.options.initDoneHandler(this);
         
          // Update button states
          this._updateButtonStateHandler(this.options.prevElementID, false);
          this._updateButtonStateHandler(this.options.nextElementID, this.options.size == this.options.numVisible);
          this.noMoreImages = this.options.size < this.options.numVisible
        }
        // Add images
        else {
          if (!this.ignoreNoMoreImages)
            this.noMoreImages = inc != this.options.scrollInc;
          else
            this.ignoreNoMoreImages = false;
          // Add images
          if (inc > 0) {
        this._scroll(-inc, this.noMoreImages)
      }
      // No more images, disable next button
          else {
            if (this.nbInCache >0)
          this._scroll(-this.nbInCache, true);
            
            this._updateButtonStateHandler(this.options.nextElementID, false);
        }
        }
        if (this.options.ajaxHandler)
      this.options.ajaxHandler(this, "after");
  },
  
  _onFailure: function(originalRequest){    
    this.requestIsRunning = false;
  },

  _animDone: function(event){   
    if (this.options.animHandler)
      this.options.animHandler(this.carouselElemID, "after", this.animRunning);
     
    this.animRunning = "none";
    // Call animAfterFinish if exists
    if (this.animAfterFinish)
      this.animAfterFinish(event);
  },
  
  _updateButtonStateHandler: function(button, state) {
        if (this.options.buttonStateHandler) 
            this.options.buttonStateHandler(button, state)
   },
  
  _scroll: function(delta, forceDisableNext) {      
    this.animRunning = delta > 0 ? "prev" : "next";
    
    if (this.options.animHandler)
      this.options.animHandler(this.carouselElemID, "before", this.animRunning);

    new Effect.MoveBy(this.carouselList, 0, delta * this.elementSize, this.options.animParameters);
    this.currentIndex -= delta;
    this._updateButtonStateHandler(this.options.prevElementID, this.currentIndex != 0);
    
    if (this.options.url && this.noMoreImages == false)
      enable = true;
    else
      enable = (this.currentIndex + this.options.numVisible < this.options.size);
    this._updateButtonStateHandler(this.options.nextElementID, (forceDisableNext ? false : enable));
  },
  
  _getLiElementSize: function() {
    var li = $(this.carouselList.getElementsByTagName("li")[0]);
        this.elementSize = li.getDimensions().width + parseFloat(li.getStyle("margin-left")) + parseFloat(li.getStyle("margin-right"));
  }
}

 

;

// /8::/202::/frontend:js -> <839> carouselwidget.js 

var __car = null
 var carousel = null;
CarouselWidget = Class.create();
CarouselWidget.prototype = {
  defaultOptions: function() {
      var state = function(button, enabled) {}
    var anim = function(carouselID, status, direction) {
        var region = $(carouselID).down(".carousel-clip-region")
        if (status == "before") {
            Effect.Fade(region, {to: 0.9, queue: { position:'end', scope: "carousel" }, duration: 0.2})
            }
        if (status == "after") {
              Effect.Fade(region, {to: 1, queue: { position:'end', scope: "carousel" }, duration: 0.2})
        }
    }
    return Object.extend({
        id:"html-carousel",
        nodes:[],
        handlers:[anim,state],
        buttons:[],
        width:"200px"        
    },arguments[0]||{});
  },
  setup: function() {
    var instance = this;
    //autoAfterShowWidget(function() { instance.initCarousel(); }) 
  },
  makeWidgetContent: function() {
    __car = this
    rn2d = Builder.node('div',{className:'carousel-component',id:this.options.id,style:"width:"+this.options.width});
    rn2d1d = Builder.node('div',{className:'carousel-clip-region',id:'clipp'});
    rn2d1d_1_ul = Builder.node('ul',{className:'carousel-list'});

    for(var i = 0;i<this.options.nodes.length;i++){
        var rn2d1d_1_ul_1_li = Builder.node('li',{});
        var rn2d1d_1_ul_1_li_1_img = this.options.nodes[i];
        rn2d1d_1_ul_1_li.appendChild(rn2d1d_1_ul_1_li_1_img);
        rn2d1d_1_ul.appendChild(rn2d1d_1_ul_1_li);
    }
    rn2d1d.appendChild(rn2d1d_1_ul);
    rn2d.appendChild(rn2d1d);
    return rn2d;
    },
    initCarousel: function() {
        this.carousel = new Carousel(this.options.id, {
        animHandler:this.options.handlers[0],
        numVisible:1, 
        scrollInc:1,
        animParameters:{duration:0.5}, 
        buttonStateHandler:this.options.handlers[1], 
        nextElementID:this.options.buttons[0], 
        prevElementID:this.options.buttons[1], size:this.options.nodes.length})
        return this.carousel;
    },
    rerender: function(){
        var nc = this.makeWidgetContent()
        this.replaceChild(this.content, this.widgetContent, nc)
        this.widgetContent = nc
    }
}
Object.extend(CarouselWidget.prototype, WidgetCommon)

;

// /8::/202::/frontend:js -> <876> changesitewidget.js 

changeSiteWidget = Class.create();
changeSiteWidget.prototype = {
  defaultOptions: function() {
    return {
      style:"color:#FFFFFF;font-weight:bolder;width:140px;",
      profile: writeUserModel,
      text:"ChangeSite"
    }
  },
  onclick: function() {
    new ThemedWindow({
      width: 200,
      height: 300,
      minimizable:false,
      maximizable:false,
      showEffect:Element.show,
      hideEffect:Element.hide,
      destroyOnClose: true
    }, function(w) {
      w.setContent(this.setPanelContent())
      w.showCenter()
      w.toFront()
    }.bind(this))
  },
  makeWidgetContent: function() {
    var instance = this;
    var csite = Builder.node('a', {
      href:"javascript:void(0);",
      style:"text-decoration:none;"
    },[
      Builder.node('span',{style:this.options.style},[TN(this.options.text)])
    ]);
    Event.observe(csite,'click', this.onclick.bindAsEventListener(this));
    return csite;
  },
  setPanelContent:function() {
    //return new ServiceListWidget({
    //  user: this.options.profile.data.username
    //}).htmlNode()
    return EMPTY()
  }
}
Object.extend(changeSiteWidget.prototype, WidgetCommon);

;

// /8::/202::/frontend:js -> <861> colormethods.js 

 Color = function(init) {    
    var color = {
        r: 0,
        g: 0,
        b: 0,
        
        h: 0,
        s: 0,
        v: 0,
        
        hex: '',
        
        setRgb: function(r, g, b) {
            this.r = r;
            this.g = g;
            this.b = b;
                        
            var newHsv = ColorMethods.rgbToHsv(this);
            this.h = newHsv.h;
            this.s = newHsv.s;
            this.v = newHsv.v;
            
            this.hex = ColorMethods.rgbToHex(this);                    
        },
        
        setHsv: function(h, s, v) {
            this.h = h;
            this.s = s;
            this.v = v;
            
            var newRgb = ColorMethods.hsvToRgb(this);
            this.r = newRgb.r;
            this.g = newRgb.g;
            this.b = newRgb.b;    
            
            this.hex = ColorMethods.rgbToHex(newRgb);    
        },
        
        setHex: function(hex) {
            this.hex = hex;
            
            var newRgb = ColorMethods.hexToRgb(this.hex);
            this.r = newRgb.r;
            this.g = newRgb.g;
            this.b = newRgb.b;
            
            var newHsv = ColorMethods.rgbToHsv(newRgb);
            this.h = newHsv.h;
            this.s = newHsv.s;
            this.v = newHsv.v;            
        }
    };
    
    if (init) {
        if (init.hex)
            color.setHex(init.hex);
        else if (init.r)
            color.setRgb(init.r, init.g, init.b);
        else if (init.h)
            color.setHsv(init.h, init.s, init.v);            
    }
    
    return color;
};
ColorMethods = {
    hexToRgb: function(hex) {
        hex = this.validateHex(hex);

        var r='00', g='00', b='00';
        
        /*
        if (hex.length == 3) {
            r = hex.substring(0,1);
            g = hex.substring(1,2);
            b = hex.substring(2,3);
        } else if (hex.length == 6) {
            r = hex.substring(0,2);
            g = hex.substring(2,4);
            b = hex.substring(4,6);
        */
        if (hex.length == 6) {
            r = hex.substring(0,2);
            g = hex.substring(2,4);
            b = hex.substring(4,6);    
        } else {
            if (hex.length > 4) {
                r = hex.substring(4, hex.length);
                hex = hex.substring(0,4);
            }
            if (hex.length > 2) {
                g = hex.substring(2,hex.length);
                hex = hex.substring(0,2);
            }
            if (hex.length > 0) {
                b = hex.substring(0,hex.length);
            }                    
        }
        
        return { r:this.hexToInt(r), g:this.hexToInt(g), b:this.hexToInt(b) };
    },
    validateHex: function(hex) {
        hex = new String(hex).toUpperCase();
        hex = hex.replace(/[^A-F0-9]/g, '0');
        if (hex.length > 6) hex = hex.substring(0, 6);
        return hex;
    },
    webSafeDec: function (dec) {
        dec = Math.round(dec / 51);
        dec *= 51;
        return dec;
    },
    hexToWebSafe: function (hex) {
        var r, g, b;

        if (hex.length == 3) {
            r = hex.substring(0,1);
            g = hex.substring(1,1);
            b = hex.substring(2,1);
        } else {
            r = hex.substring(0,2);
            g = hex.substring(2,4);
            b = hex.substring(4,6);
        }
        return intToHex(this.webSafeDec(this.hexToInt(r))) + this.intToHex(this.webSafeDec(this.hexToInt(g))) + this.intToHex(this.webSafeDec(this.hexToInt(b)));
    },
    rgbToWebSafe: function(rgb) {
        return {r: this.webSafeDec(rgb.r), g: this.webSafeDec(rgb.g), b: this.webSafeDec(rgb.b) };
    },
    rgbToHex: function (rgb) {
        return this.intToHex(rgb.r) + this.intToHex(rgb.g) + this.intToHex(rgb.b);
    },
    intToHex: function (dec){
        var result = (parseInt(dec).toString(16));
        if (result.length == 1)
            result = ("0" + result);
        return result.toUpperCase();
    },
    hexToInt: function (hex){
        return(parseInt(hex,16));
    },
    rgbToHsv: function (rgb) {

        var r = rgb.r / 255;
        var g = rgb.g / 255;
        var b = rgb.b / 255;

        hsv = {h:0, s:0, v:0};

        var min = 0
        var max = 0;

        if (r >= g && r >= b) {
            max = r;
            min = (g > b) ? b : g;
        } else if (g >= b && g >= r) {
            max = g;
            min = (r > b) ? b : r;
        } else {
            max = b;
            min = (g > r) ? r : g;
        }

        hsv.v = max;
        hsv.s = (max) ? ((max - min) / max) : 0;

        if (!hsv.s) {
            hsv.h = 0;
        } else {
            delta = max - min;
            if (r == max) {
                hsv.h = (g - b) / delta;
            } else if (g == max) {
                hsv.h = 2 + (b - r) / delta;
            } else {
                hsv.h = 4 + (r - g) / delta;
            }

            hsv.h = parseInt(hsv.h * 60);
            if (hsv.h < 0) {
                hsv.h += 360;
            }
        }
        
        hsv.s = parseInt(hsv.s * 100);
        hsv.v = parseInt(hsv.v * 100);

        return hsv;
    },
    hsvToRgb: function (hsv) {

        rgb = {r:0, g:0, b:0};
        
        var h = hsv.h;
        var s = hsv.s;
        var v = hsv.v;

        if (s == 0) {
            if (v == 0) {
                rgb.r = rgb.g = rgb.b = 0;
            } else {
                rgb.r = rgb.g = rgb.b = parseInt(v * 255 / 100);
            }
        } else {
            if (h == 360) {
                h = 0;
            }
            h /= 60;

            // 100 scale
            s = s/100;
            v = v/100;

            var i = parseInt(h);
            var f = h - i;
            var p = v * (1 - s);
            var q = v * (1 - (s * f));
            var t = v * (1 - (s * (1 - f)));
            switch (i) {
                case 0:
                    rgb.r = v;
                    rgb.g = t;
                    rgb.b = p;
                    break;
                case 1:
                    rgb.r = q;
                    rgb.g = v;
                    rgb.b = p;
                    break;
                case 2:
                    rgb.r = p;
                    rgb.g = v;
                    rgb.b = t;
                    break;
                case 3:
                    rgb.r = p;
                    rgb.g = q;
                    rgb.b = v;
                    break;
                case 4:
                    rgb.r = t;
                    rgb.g = p;
                    rgb.b = v;
                    break;
                case 5:
                    rgb.r = v;
                    rgb.g = p;
                    rgb.b = q;
                    break;
            }

            rgb.r = parseInt(rgb.r * 255);
            rgb.g = parseInt(rgb.g * 255);
            rgb.b = parseInt(rgb.b * 255);
        }

        return rgb;
    }
}; 

;

// /8::/202::/frontend:js -> <874> colorpicker.js 

DefaultColorPickerSettings = {
    startMode:'h',
    startHex:'ff0000',
    clientFilesPath: '/images/'
};

ColorPicker = Class.create();
ColorPicker.prototype = {
    initialize:function(id, target, settings){
        this.id = id;
        var table = this.generateTable(this.id);
        $(target).appendChild(Builder.node('div',{style:"width:440px;height:280px;background:#EDEDED;padding:10px;",id:"colPick"},[table]));
        inst = this;

        Event.observe($("setColor"),"click",function(){
            win.close();
            var target =
this.target;
            inst.settings.setColor($F(inst.id+"_Hex"),target);
        });
        window.setTimeout(function(){
            inst.init(id, target, settings);
        },1000);    
    },
    setTarget:function(n){
        this.target = n;
    },
    init: function(id, target, settings) {
        this.id = id;
        this.settings = Object.extend(Object.extend({},DefaultColorPickerSettings), settings || {});

        // attach radio & check boxes
        this._hueRadio = $(this.id + '_HueRadio');
        this._saturationRadio = $(this.id + '_SaturationRadio');
        this._valueRadio = $(this.id + '_BrightnessRadio');

        this._redRadio = $(this.id + '_RedRadio');
        this._greenRadio = $(this.id + '_GreenRadio');
        this._blueRadio = $(this.id + '_BlueRadio');
        //this._webSafeCheck = $(this.id + '_WebSafeCheck');

        this._hueRadio.value = 'h';
        this._saturationRadio.value = 's';
        this._valueRadio.value = 'v';

        this._redRadio.value = 'r';
        this._greenRadio.value = 'g';
        this._blueRadio.value = 'b';

        // attach events to radio & checks

        this._event_onRadioClicked = this._onRadioClicked.bindAsEventListener(this);

        Event.observe( this._hueRadio,'click', this._event_onRadioClicked);
        Event.observe( this._saturationRadio,'click', this._event_onRadioClicked);
        Event.observe( this._valueRadio,'click', this._event_onRadioClicked);

        Event.observe( this._redRadio,'click', this._event_onRadioClicked);
        Event.observe( this._greenRadio,'click', this._event_onRadioClicked);
        Event.observe( this._blueRadio,'click', this._event_onRadioClicked);

        //this._event_webSafeClicked = this._onWebSafeClicked.bindAsEventListener(this);
        //Event.observe( this._webSafeCheck, 'click', this._event_webSafeClicked);


        // attach simple properties
        this._preview = $(this.id + '_Preview');


        // MAP
        this._mapBase = $(this.id + '_ColorMap');
        this._mapBase.style.width = '256px';
        this._mapBase.style.height = '256px';
        this._mapBase.style.padding = 0;
        this._mapBase.style.margin = 0;
        this._mapBase.style.border = 'solid 1px #000';


        this._mapL1 = Builder.node('img',{src:this.settings.clientFilesPath + 'blank.gif', width:256, height:256} ); //'blank.gif'});
        this._mapL1.style.margin = '0px';
        this._mapL1.style.display = 'block';
        this._mapBase.appendChild(this._mapL1);                

        this._mapL2 = Builder.node('img',{src:this.settings.clientFilesPath + 'blank.gif', width:256, height:256} ); //'blank.gif'});
        this._mapBase.appendChild(this._mapL2);
        this._mapL2.style.clear = 'both';
        this._mapL2.style.margin = '-256px 0px 0px 0px';
        this._mapL2.setOpacity(.5);
        this._mapL2.style.display = 'block';

        // BAR
        this._bar = $(this.id + '_ColorBar');
        this._bar.style.width = '20px';
        this._bar.style.height = '256px';
        this._bar.style.padding = 0;
        this._bar.style.margin = '0px 10px';
        this._bar.style.border = 'solid 1px #000';    

        this._barL1 = Builder.node('img',{src:this.settings.clientFilesPath + 'blank.gif', width:20, height:256});
        this._barL1.style.margin = '0px';
        this._barL1.style.display = 'block';    
        this._bar.appendChild(this._barL1);            

        this._barL2 = Builder.node('img',{src:this.settings.clientFilesPath + 'blank.gif', width:20, height:256} );
        this._barL2.style.margin = '-256px 0px 0px 0px';
        this._barL2.style.display = 'block';    
        this._bar.appendChild(this._barL2);

        this._barL3 = Builder.node('img',{src:this.settings.clientFilesPath + 'blank.gif', width:20, height:256} );
        this._barL3.style.margin = '-256px 0px 0px 0px';
        this._barL3.style.backgroundColor = '#ff0000';
        this._barL3.style.display = 'block';    
        this._bar.appendChild(this._barL3);

        this._barL4 = Builder.node('img',{src:this.settings.clientFilesPath + 'bar-brightness.png', width:20, height:256} );
        this._barL4.style.margin = '-256px 0px 0px 0px';
        this._barL4.style.display = 'block';    
        this._bar.appendChild(this._barL4);                

        // attach map slider
        this._map = new ColorSlider(this._mapL2, {xMaxValue: 255, yMinValue: 255, arrowImage: this.settings.clientFilesPath + 'mappoint.gif'});

        // attach color slider
        this._slider = new ColorSlider(this._barL4, {xMinValue: 1,xMaxValue: 1, yMinValue: 255, arrowImage: this.settings.clientFilesPath + 'rangearrows.gif'});;

        // attach color values
        this._cvp = new ColorValuePicker(this.id);

        // link up events
        var cp = this;

        this._slider.onValuesChanged = function() { cp.sliderValueChanged() };
        this._map.onValuesChanged = function() { cp.mapValueChanged(); }
        this._cvp.onValuesChanged = function() { cp.textValuesChanged(); }

        // browser!
        this.isLessThanIE7 = false;
        var version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        if ((version < 7) && (document.body.filters))
            this.isLessThanIE7 = true;


        // initialize values
        this.setColorMode(this.settings.startMode);
        if (this.settings.startHex)
            this._cvp._hexInput.value = this.settings.startHex;

        this._cvp.setValuesFromHex();

        this.positionMapAndSliderArrows();
        this.updateVisuals();

        this.color = null;
    },
    hideColorPickerArrows:function(){
        try{
        $("123/images/mappoint.gif").hide();
        $("123/images/rangearrows.gif").hide();
        }catch(e){

        }
    },
    showColorPickerArrows:function(){
        $("123/images/mappoint.gif").show();
        $("123/images/rangearrows.gif").show();
    },
    generateTable:function(id){
        id = id+"_";
        var colortable = table(
        [
        {columnOptions: {align:"top",width:256},columnData: [Builder.node('div',{id:id+"ColorMap",style:"width:256px;"})]},
        {columnOptions: {align:"top",width:30},columnData: [Builder.node('div',{id:id+"ColorBar"})]},
        {columnOptions: {align:"top",width:120},columnData: [
        table([
        {columnOptions: {colspan:3,width:120},columnData: [Builder.node('div',{id:id+"Preview",style:"background:#fff;width:60px;height:60px;border:solid 1px #000;"},[])]}],
        [
        {columnOptions: {width:10},columnData: [Builder.node('input',{ type:"radio",id:id+"HueRadio",name:id+"Mode",value:"0"})]},
        {columnOptions: {width:20},columnData: [Builder.node('label',{},[TN("H:")])]},
        {columnOptions: {width:10,align:"top"},columnData: [Builder.node('input',{ type:"text",id:id+"Hue",value:"0",style:"width: 40px;"}),TN("%")]}
        ],
        [
        {columnOptions: {width:10},columnData: [Builder.node('input',{ type:"radio",id:id+"SaturationRadio",name:id+"Mode",value:"1"})]},
        {columnOptions: {width:20},columnData: [Builder.node('label',{},[TN("S:")])]},
        {columnOptions: {width:10,align:"top"},columnData: [Builder.node('input',{ type:"text",id:id+"Saturation",value:"100",style:"width: 40px;"}),TN("%")]}
        ],
        [
        {columnOptions: {width:10},columnData: [Builder.node('input',{ type:"radio",id:id+"BrightnessRadio",name:id+"Mode",value:"1"})]},
        {columnOptions: {width:20},columnData: [Builder.node('label',{},[TN("B:")])]},
        {columnOptions: {},columnData: [Builder.node('input',{ type:"text",id:id+"Brightness",value:"100",style:"width: 40px;"}),TN("%")]}
        ],
        [{columnOptions: {colspan:3},columnData: []}],
        [
        {columnOptions: {width:10},columnData: [Builder.node('input',{ type:"radio",id:id+"RedRadio",name:id+"Mode",value:"0"})]},
        {columnOptions: {width:20},columnData: [Builder.node('label',{},[TN("R:")])]},
        {columnOptions: {width:40},columnData: [Builder.node('input',{ type:"text",id:id+"Red",value:"0",style:"width: 40px;"})]}
        ],
        [
        {columnOptions: {width:10},columnData: [Builder.node('input',{ type:"radio",id:id+"GreenRadio",name:id+"Mode",value:"1"})]},
        {columnOptions: {width:20},columnData: [Builder.node('label',{},[TN("G:")])]},
        {columnOptions: {},columnData: [Builder.node('input',{ type:"text",id:id+"Green",value:"100",style:"width: 40px;"})]}
        ],
        [
        {columnOptions: {width:10},columnData: [Builder.node('input',{ type:"radio",id:id+"BlueRadio",name:id+"Mode",value:"1"})]},
        {columnOptions: {width:20},columnData: [Builder.node('label',{},[TN("B:")])]},
        {columnOptions: {},columnData: [Builder.node('input',{ type:"text",id:id+"Blue",value:"100",style:"width: 40px;"})]}
        ],
        [
        {columnOptions: {},columnData: [TN("#")]},
        {columnOptions: {colspan:2},columnData: [Builder.node('input',{ type:"text",id:id+"Hex",value:"FF0000",style:"width: 60px;"})]}
        ],
        [{columnOptions: {colspan:3},columnData: [BR()]}],
        [
        {columnOptions: {colspan:3},columnData: [Builder.node('input',{type:"button",id:"setColor",value:"set color!"})]}
        ]
        )]}
        ]
        )
        var imagemaps = ['http:\/\/mike.myservic.es/get_file?id=3515',
            'http:\/\/mike.myservic.es/get_file?id=3516',        
            'http:\/\/mike.myservic.es/get_file?id=3513',
            'http:\/\/mike.myservic.es/get_file?id=3511',        
            'http:\/\/mike.myservic.es/get_file?id=3500',
            'http:\/\/mike.myservic.es/get_file?id=3499',
            'http:\/\/mike.myservic.es/get_file?id=3498',
            'http:\/\/mike.myservic.es/get_file?id=3497',
            'http:\/\/mike.myservic.es/get_file?id=3507',
            'http:\/\/mike.myservic.es/get_file?id=3508',
            'http:\/\/mike.myservic.es/get_file?id=3509',
            'http:\/\/mike.myservic.es/get_file?id=3510',    
            'http:\/\/mike.myservic.es/get_file?id=3506',
            'http:\/\/mike.myservic.es/get_file?id=3505',
            'http:\/\/mike.myservic.es/get_file?id=3503',
            'http:\/\/mike.myservic.es/get_file?id=3501',        
            'http:\/\/mike.myservic.es/get_file?id=3526',
            'http:\/\/mike.myservic.es/get_file?id=3525',
            'http:\/\/mike.myservic.es/get_file?id=3518',
            'http:\/\/mike.myservic.es/get_file?id=3517',
            'http:\/\/mike.myservic.es/get_file?id=3524',
            'http:\/\/mike.myservic.es/get_file?id=3523',        
            'http:\/\/mike.myservic.es/get_file?id=3520',
            'http:\/\/mike.myservic.es/get_file?id=3522',
            'http:\/\/mike.myservic.es/get_file?id=3519',
            'http:\/\/mike.myservic.es/get_file?id=3521']

        var images = [];
        imagemaps.each(function(i){
            images.push(Builder.node('img',{src:i}));
        });
        var imagemapdiv = Builder.node('div',{style:"display:none;"},images);
        return Builder.node('div',{style:"width:440px;"},[colortable,imagemapdiv]);
    },
    show: function() {
        this._map.Arrow.style.display = '';
        this._slider.Arrow.style.display = '';
        this._map.setPositioningVariables();
        this._slider.setPositioningVariables();
        this.positionMapAndSliderArrows();
    },
    hide: function() {
        this._map.Arrow.style.display = 'none';
        this._slider.Arrow.style.display = 'none';
    },
    _onRadioClicked: function(e) {
        this.setColorMode(e.target.value);
    },
    _onWebSafeClicked: function(e) {
        // reset
        this.setColorMode(this.ColorMode);
    },
    textValuesChanged: function() {
        this.positionMapAndSliderArrows();
        this.updateVisuals();
    },
    setColorMode: function(colorMode) {

        this.color = this._cvp.color;

        // reset all images        
        function resetImage(cp, img) {
            cp.setAlpha(img, 100);    
            img.style.backgroundColor = '';
            img.src = cp.settings.clientFilesPath + 'blank.gif';
            img.style.filter = '';
        }
        resetImage(this, this._mapL1);
        resetImage(this, this._mapL2);
        resetImage(this, this._barL1);
        resetImage(this, this._barL2);
        resetImage(this, this._barL3);
        resetImage(this, this._barL4);

        this._hueRadio.checked = false;
        this._saturationRadio.checked = false;
        this._valueRadio.checked = false;
        this._redRadio.checked = false;
        this._greenRadio.checked = false;
        this._blueRadio.checked = false;


        switch (colorMode) {
            case 'h':
                this._hueRadio.checked = true;

                // MAP
                // put a color layer on the bottom
                this._mapL1.style.backgroundColor = '#' + this.color.hex;                

                // add a hue map on the top
                this._mapL2.style.backgroundColor = 'transparent';
                this.setImg(this._mapL2, this.settings.clientFilesPath + 'map-hue.png');
                this.setAlpha(this._mapL2, 100);

                // SLIDER
                // simple hue map
                this.setImg(this._barL4,this.settings.clientFilesPath + 'bar-hue.png');

                this._map.settings.xMaxValue = 100;
                this._map.settings.yMaxValue = 100;
                this._slider.settings.yMaxValue = 359;

                break;

            case 's':
                this._saturationRadio.checked = true;            

                // MAP
                // bottom has saturation map
                this.setImg(this._mapL1, this.settings.clientFilesPath + 'map-saturation.png');

                // top has overlay
                this.setImg(this._mapL2, this.settings.clientFilesPath + 'map-saturation-overlay.png');
                this.setAlpha(this._mapL2,0);

                // SLIDER
                // bottom: color
                this.setBG(this._barL3, this.color.hex);

                // top: graduated overlay
                this.setImg(this._barL4, this.settings.clientFilesPath + 'bar-saturation.png');


                this._map.settings.xMaxValue = 359;
                this._map.settings.yMaxValue = 100;
                this._slider.settings.yMaxValue = 100;

                break;

            case 'v':
                this._valueRadio.checked = true;            

                // MAP
                // bottom: nothing

                // top
                this.setBG(this._mapL1,'000');
                this.setImg(this._mapL2, this.settings.clientFilesPath + 'map-brightness.png');                

                // SLIDER
                // bottom
                this._barL3.style.backgroundColor = '#' + this.color.hex;

                // top                
                this.setImg(this._barL4, this.settings.clientFilesPath + 'bar-brightness.png');


                this._map.settings.xMaxValue = 359;
                this._map.settings.yMaxValue = 100;
                this._slider.settings.yMaxValue = 100;
                break;

            case 'r':
                this._redRadio.checked = true;
                this.setImg(this._mapL2, this.settings.clientFilesPath + 'map-red-max.png');
                this.setImg(this._mapL1, this.settings.clientFilesPath + 'map-red-min.png');

                this.setImg(this._barL4, this.settings.clientFilesPath + 'bar-red-tl.png');
                this.setImg(this._barL3, this.settings.clientFilesPath + 'bar-red-tr.png');
                this.setImg(this._barL2, this.settings.clientFilesPath + 'bar-red-br.png');
                this.setImg(this._barL1, this.settings.clientFilesPath + 'bar-red-bl.png');                

                break;

            case 'g':
                this._greenRadio.checked = true;
                this.setImg(this._mapL2, this.settings.clientFilesPath + 'map-green-max.png');
                this.setImg(this._mapL1, this.settings.clientFilesPath + 'map-green-min.png');

                this.setImg(this._barL4, this.settings.clientFilesPath + 'bar-green-tl.png');
                this.setImg(this._barL3, this.settings.clientFilesPath + 'bar-green-tr.png');
                this.setImg(this._barL2, this.settings.clientFilesPath + 'bar-green-br.png');
                this.setImg(this._barL1, this.settings.clientFilesPath + 'bar-green-bl.png');                

                break;

            case 'b':
                this._blueRadio.checked = true;
                this.setImg(this._mapL2, this.settings.clientFilesPath + 'map-blue-max.png');
                this.setImg(this._mapL1, this.settings.clientFilesPath + 'map-blue-min.png');

                this.setImg(this._barL4, this.settings.clientFilesPath + 'bar-blue-tl.png');
                this.setImg(this._barL3, this.settings.clientFilesPath + 'bar-blue-tr.png');
                this.setImg(this._barL2, this.settings.clientFilesPath + 'bar-blue-br.png');
                this.setImg(this._barL1, this.settings.clientFilesPath + 'bar-blue-bl.png');

                //this.setImg(this._barL4, this.settings.clientFilesPath + 'bar-hue.png');            

                break;

            default:
                alert('invalid mode');
                break;
        }

        switch (colorMode) {
            case 'h':
            case 's':
            case 'v':

                this._map.settings.xMinValue = 1;
                this._map.settings.yMinValue = 1;                
                this._slider.settings.yMinValue = 1;
                break;

            case 'r':
            case 'g':
            case 'b':

                this._map.settings.xMinValue = 0;
                this._map.settings.yMinValue = 0;                
                this._slider.settings.yMinValue = 0;                    

                this._map.settings.xMaxValue = 255;
                this._map.settings.yMaxValue = 255;                
                this._slider.settings.yMaxValue = 255;    
                break;
        }

        this.ColorMode = colorMode;

        this.positionMapAndSliderArrows();

        this.updateMapVisuals();
        this.updateSliderVisuals();
    },
    mapValueChanged: function() {
        // update values

        switch(this.ColorMode) {
            case 'h':
                this._cvp._saturationInput.value = this._map.xValue;
                this._cvp._valueInput.value = 100 - this._map.yValue;
                break;

            case 's':
                this._cvp._hueInput.value = this._map.xValue;
                this._cvp._valueInput.value = 100 - this._map.yValue;
                break;

            case 'v':
                this._cvp._hueInput.value = this._map.xValue;
                this._cvp._saturationInput.value = 100 - this._map.yValue;
                break;

            case 'r':
                this._cvp._blueInput.value = this._map.xValue;
                this._cvp._greenInput.value = 256 - this._map.yValue;
                break;

            case 'g':
                this._cvp._blueInput.value = this._map.xValue;
                this._cvp._redInput.value = 256 - this._map.yValue;
                break;

            case 'b':
                this._cvp._redInput.value = this._map.xValue;
                this._cvp._greenInput.value = 256 - this._map.yValue;
                break;                
        }

        switch(this.ColorMode) {
            case 'h':
            case 's':
            case 'v':
                this._cvp.setValuesFromHsv();
                break;

            case 'r':
            case 'g':
            case 'b':
                this._cvp.setValuesFromRgb();
                break;                
        }        


        this.updateVisuals();
    },
    sliderValueChanged: function() {

        switch(this.ColorMode) {
            case 'h':
                this._cvp._hueInput.value = 360 - this._slider.yValue;
                break;
            case 's':
                this._cvp._saturationInput.value = 100 - this._slider.yValue;
                break;
            case 'v':
                this._cvp._valueInput.value = 100 - this._slider.yValue;
                break;

            case 'r':
                this._cvp._redInput.value = 255 - this._slider.yValue;
                break;
            case 'g':
                this._cvp._greenInput.value = 255 - this._slider.yValue;
                break;
            case 'b':
                this._cvp._blueInput.value = 255 - this._slider.yValue;
                break;                
        }

        switch(this.ColorMode) {
            case 'h':
            case 's':
            case 'v':
                this._cvp.setValuesFromHsv();
                break;

            case 'r':
            case 'g':
            case 'b':
                this._cvp.setValuesFromRgb();
                break;                
        }        

        this.updateVisuals();
    },
    positionMapAndSliderArrows: function() {
        this.color = this._cvp.color;

        // Slider
        var sliderValue = 0;
        switch(this.ColorMode) {
            case 'h':
                sliderValue = 360 - this.color.h;
                break;

            case 's':
                sliderValue = 100 - this.color.s;
                break;

            case 'v':
                sliderValue = 100 - this.color.v;
                break;

            case 'r':
                sliderValue = 255- this.color.r;
                break;

            case 'g':
                sliderValue = 255- this.color.g;
                break;

            case 'b':
                sliderValue = 255- this.color.b;
                break;                
        }    

        this._slider.yValue = sliderValue;
        this._slider.setArrowPositionFromValues();

        // color map
        var mapXValue = 0;
        var mapYValue = 0;
        switch(this.ColorMode) {
            case 'h':
                mapXValue = this.color.s;
                mapYValue = 100 - this.color.v;
                break;

            case 's':
                mapXValue = this.color.h;
                mapYValue = 100 - this.color.v;
                break;

            case 'v':
                mapXValue = this.color.h;
                mapYValue = 100 - this.color.s;
                break;

            case 'r':
                mapXValue = this.color.b;
                mapYValue = 256 - this.color.g;
                break;

            case 'g':
                mapXValue = this.color.b;
                mapYValue = 256 - this.color.r;
                break;

            case 'b':
                mapXValue = this.color.r;
                mapYValue = 256 - this.color.g;
                break;                
        }
        this._map.xValue = mapXValue;
        this._map.yValue = mapYValue;
        this._map.setArrowPositionFromValues();
    },
    updateVisuals: function() {
        this.updatePreview();
        this.updateMapVisuals();
        this.updateSliderVisuals();
    },
    updatePreview: function() {
        try {
            this._preview.style.backgroundColor = '#' + this._cvp.color.hex;
        } catch (e) {}
    },
    updateMapVisuals: function() {

        this.color = this._cvp.color;

        switch(this.ColorMode) {
            case 'h':
                // fake color with only hue
                var color = new Color({h:this.color.h, s:100, v:100});                    
                this.setBG(this._mapL1, color.hex);
                break;

            case 's':
                this.setAlpha(this._mapL2, 100 - this.color.s);
                break;

            case 'v':
                this.setAlpha(this._mapL2, this.color.v);
                break;

            case 'r':                                
                this.setAlpha(this._mapL2, this.color.r/256*100);
                break;

            case 'g':
                this.setAlpha(this._mapL2, this.color.g/256*100);
                break;

            case 'b':
                this.setAlpha(this._mapL2, this.color.b/256*100);
                break;                
        }
    },
    updateSliderVisuals: function() {

        this.color = this._cvp.color;

        switch(this.ColorMode) {
            case 'h':
                break;

            case 's':
                var saturatedColor = new Color({h:this.color.h, s:100, v:this.color.v});
                this.setBG(this._barL3, saturatedColor.hex);
                break;

            case 'v':
                var valueColor = new Color({h:this.color.h, s:this.color.s, v:100});
                this.setBG(this._barL3, valueColor.hex);
                break;
            case 'r':
            case 'g':                
            case 'b':

                var hValue = 0;
                var vValue = 0;

                if (this.ColorMode == 'r') {
                    hValue = this._cvp._blueInput.value;
                    vValue = this._cvp._greenInput.value;
                } else if (this.ColorMode == 'g') {
                    hValue = this._cvp._blueInput.value;
                    vValue = this._cvp._redInput.value;
                } else if (this.ColorMode == 'b') {
                    hValue = this._cvp._redInput.value;
                    vValue = this._cvp._greenInput.value;
                }

                var horzPer = (hValue /256)*100;
                var vertPer = ( vValue/256)*100;

                var horzPerRev = ( (256-hValue)/256)*100;
                var vertPerRev = ( (256-vValue)/256)*100;

                this.setAlpha(this._barL4, (vertPer>horzPerRev) ? horzPerRev : vertPer);
                this.setAlpha(this._barL3, (vertPer>horzPer) ? horzPer : vertPer); 
                this.setAlpha(this._barL2, (vertPerRev>horzPer) ? horzPer : vertPerRev);
                this.setAlpha(this._barL1, (vertPerRev>horzPerRev) ? horzPerRev : vertPerRev);

                break;


        }
    },
    setBG: function(el, c) {
        try {
            el.style.backgroundColor = '#' + c;
        } catch (e) {}
    },
    setImg: function(img, src) {

        if (src.indexOf('png') && this.isLessThanIE7) {
            img.pngSrc = src;
            img.src = this.settings.clientFilesPath + 'blank.gif';
            img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\');';    

        } else {
            img.src = src;
        }
    },
    setAlpha: function(obj, alpha) {
        if (this.isLessThanIE7) {            
            var src = obj.pngSrc;
            // exception for the hue map
            if (src != null && src.indexOf('map-hue') == -1)
                obj.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\') progid:DXImageTransform.Microsoft.Alpha(opacity=' + alpha + ')';    
        } else {
            obj.setOpacity(alpha/100);        
        }
    }
};

;

// /8::/202::/frontend:js -> <837> colorslider.js 

 SlidersList = [];

DefaultSliderSettings = {
    xMinValue: 0,
    xMaxValue: 100,
    yMinValue: 0,
    yMaxValue: 100,
    id:"123",
    arrowImage: '/images/rangearrows.gif'
}


ColorSlider = Class.create();
ColorSlider.prototype = {
    _bar: null,
    _arrow: null,

    initialize: function(id, settings) {
    
        this.id = id;
        this.settings = Object.extend(Object.extend({},DefaultSliderSettings), settings || {});

        this.xValue = 0;
        this.yValue = 0;

        // hook up controls
        this._bar = $(this.id);

        // build controls
        this._arrow = document.createElement('img');
        this._arrow.id = this.settings.id+this.settings.arrowImage;
        this._arrow.src = this.settings.arrowImage;
        this._arrow.margin = 0;
        this._arrow.padding = 0;
        this._arrow.style.zIndex = 9999;
            
        this._arrow.style.position = 'absolute';
        this._arrow.style.top = '0px';
        this._arrow.style.left = '0px';
  
        document.body.appendChild(this._arrow);

        //$("colPick").appendChild(this._arrow);


        // attach 'this' to html objects
        var slider = this;
        
        this.setPositioningVariables();
        
        this._event_docMouseMove = this._docMouseMove.bindAsEventListener(this);
        this._event_docMouseUp = this._docMouseUp.bindAsEventListener(this);

        Event.observe( this._bar, 'mousedown', this._bar_mouseDown.bindAsEventListener(this));
        Event.observe( this._arrow, 'mousedown', this._arrow_mouseDown.bindAsEventListener(this));

        // set initial position
        this.setArrowPositionFromValues();

        // fire events
        if(this.onValuesChanged)
            this.onValuesChanged(this);

        // final setup
        SlidersList.push(this);
    },
    
    
    setPositioningVariables: function() {
        // calculate sizes and ranges
        // BAR

        this._barWidth = this._bar.getWidth();
        this._barHeight = this._bar.getHeight();
        
        var pos = Position.cumulativeOffset(this._bar);
 
        this._barTop = pos[1]//.top;
        this._barLeft = pos[0]//.left;
        
        this._barBottom = this._barTop + this._barHeight;
        this._barRight = this._barLeft + this._barWidth;

        // ARROW
        this._arrow = $(this._arrow);
        this._arrowWidth = this._arrow.getWidth();
        this._arrowHeight = this._arrow.getHeight();

        // MIN & MAX
        this.MinX = this._barLeft;
        this.MinY = this._barTop;

        this.MaxX = this._barRight;
        this.MinY = this._barBottom;
    },
    
    setArrowPositionFromValues: function(e) {
        this.setPositioningVariables();
        
        // sets the arrow position from XValue and YValue properties

        var arrowOffsetX = 0;
        var arrowOffsetY = 0;
        
        // X Value/Position
        if (this.settings.xMinValue != this.settings.xMaxValue) {

            if (this.xValue == this.settings.xMinValue) {
                arrowOffsetX = 0;
            } else if (this.xValue == this.settings.xMaxValue) {
                arrowOffsetX = this._barWidth-1;
            } else {

                var xMax = this.settings.xMaxValue;
                if (this.settings.xMinValue < 1)  {
                    xMax = xMax + Math.abs(this.settings.xMinValue) + 1;
                }
                var xValue = this.xValue;

                if (this.xValue < 1) xValue = xValue + 1;

                arrowOffsetX = xValue / xMax * this._barWidth;

                if (parseInt(arrowOffsetX) == (xMax-1)) 
                    arrowOffsetX=xMax;
                else 
                    arrowOffsetX=parseInt(arrowOffsetX);

                // shift back to normal values
                if (this.settings.xMinValue < 1)  {
                    arrowOffsetX = arrowOffsetX - Math.abs(this.settings.xMinValue) - 1;
                }
            }
        }
        
        // X Value/Position
        if (this.settings.yMinValue != this.settings.yMaxValue) {    
            
            if (this.yValue == this.settings.yMinValue) {
                arrowOffsetY = 0;
            } else if (this.yValue == this.settings.yMaxValue) {
                arrowOffsetY = this._barHeight-1;
            } else {
            
                var yMax = this.settings.yMaxValue;
                if (this.settings.yMinValue < 1)  {
                    yMax = yMax + Math.abs(this.settings.yMinValue) + 1;
                }

                var yValue = this.yValue;

                if (this.yValue < 1) yValue = yValue + 1;

                var arrowOffsetY = yValue / yMax * this._barHeight;

                if (parseInt(arrowOffsetY) == (yMax-1)) 
                    arrowOffsetY=yMax;
                else
                    arrowOffsetY=parseInt(arrowOffsetY);

                if (this.settings.yMinValue < 1)  {
                    arrowOffsetY = arrowOffsetY - Math.abs(this.settings.yMinValue) - 1;
                }
            }
        }

        this._setArrowPosition(arrowOffsetX, arrowOffsetY);

    },
    _setArrowPosition: function(offsetX, offsetY) {
        
        
        // validate
        if (offsetX < 0) offsetX = 0
        if (offsetX > this._barWidth) offsetX = this._barWidth;
        if (offsetY < 0) offsetY = 0
        if (offsetY > this._barHeight) offsetY = this._barHeight;    

        var posX = this._barLeft + offsetX;
        var posY = this._barTop + offsetY;

        // check if the arrow is bigger than the bar area
        if (this._arrowWidth > this._barWidth) {
            posX = posX - (this._arrowWidth/2 - this._barWidth/2);
        } else {
            posX = posX - parseInt(this._arrowWidth/2);
        }
        if (this._arrowHeight > this._barHeight) {
            posY = posY - (this._arrowHeight/2 - this._barHeight/2);
        } else {
            posY = posY - parseInt(this._arrowHeight/2);
        }
        this._arrow.style.left = posX + 'px';
        this._arrow.style.top = posY + 'px';    
    },
    _bar_mouseDown: function(e) {
        this._mouseDown(e);
    },
    
    _arrow_mouseDown: function(e) {
        this._mouseDown(e);
    },
    
    _mouseDown: function(e) {
        ActiveSlider = this;
        
        this.setValuesFromMousePosition(e);
        
        Event.observe(document, 'mousemove', this._event_docMouseMove);
        Event.observe(document, 'mouseup', this._event_docMouseUp);        

        Event.stop(e);
    },
    
    _docMouseMove: function(e) {

        this.setValuesFromMousePosition(e);
        
        Event.stop(e);
    },
    
    _docMouseUp: function(e) {
        Event.stopObserving( document, 'mouseup', this._event_docMouseUp);
        Event.stopObserving( document, 'mousemove', this._event_docMouseMove);
        Event.stop(e);
    },    
    
    setValuesFromMousePosition: function(e) {
        //this.setPositioningVariables();
        
     
 
        var mouse = {x:Event.pointerX(e),y:Event.pointerY(e)}//Event.pointer(e);

        var relativeX = 0;
        var relativeY = 0;

        // mouse relative to object's top left
        if (mouse.x < this._barLeft)
            relativeX = 0;
        else if (mouse.x > this._barRight)
            relativeX = this._barWidth;
        else
            relativeX = mouse.x - this._barLeft + 1;

        if (mouse.y < this._barTop)
            relativeY = 0;
        else if (mouse.y > this._barBottom)
            relativeY = this._barHeight;
        else
            relativeY = mouse.y - this._barTop + 1;
            

        var newXValue = parseInt(relativeX / this._barWidth * this.settings.xMaxValue);
        var newYValue = parseInt(relativeY / this._barHeight * this.settings.yMaxValue);
        
        // set values
        this.xValue = newXValue;
        this.yValue = newYValue;    

        // position arrow
        if (this.settings.xMaxValue == this.settings.xMinValue)
            relativeX = 0;
        if (this.settings.yMaxValue == this.settings.yMinValue)
            relativeY = 0;        
        this._setArrowPosition(relativeX, relativeY);

        // fire events
        if(this.onValuesChanged)
            this.onValuesChanged(this);
    }    

}


 

;

// /8::/202::/frontend:js -> <856> colorvaluepicker.js 

ColorValuePicker = Class.create();
ColorValuePicker.prototype = {
    initialize: function(id) {

        this.id = id;

        this.onValuesChanged = null;

        this._hueInput = $(this.id + '_Hue');
        this._valueInput = $(this.id + '_Brightness');
        this._saturationInput = $(this.id + '_Saturation');

        this._redInput = $(this.id + '_Red');
        this._greenInput = $(this.id + '_Green');
        this._blueInput = $(this.id + '_Blue');

        this._hexInput = $(this.id + '_Hex');

        // assign events

        // events
        this._event_onHsvKeyUp = this._onHsvKeyUp.bindAsEventListener(this);
        this._event_onHsvBlur = this._onHsvBlur.bindAsEventListener(this);
        this._event_onRgbKeyUp = this._onRgbKeyUp.bindAsEventListener(this);
        this._event_onRgbBlur = this._onRgbBlur.bindAsEventListener(this);
        this._event_onHexKeyUp = this._onHexKeyUp.bindAsEventListener(this);

        // HSB
        Event.observe( this._hueInput,'keyup', this._event_onHsvKeyUp);
        Event.observe( this._valueInput,'keyup',this._event_onHsvKeyUp);
        Event.observe( this._saturationInput,'keyup',this._event_onHsvKeyUp);
        Event.observe( this._hueInput,'blur', this._event_onHsvBlur);
        Event.observe( this._valueInput,'blur',this._event_onHsvBlur);
        Event.observe( this._saturationInput,'blur',this._event_onHsvBlur);

        // RGB
        Event.observe( this._redInput,'keyup', this._event_onRgbKeyUp);
        Event.observe( this._greenInput,'keyup', this._event_onRgbKeyUp);
        Event.observe( this._blueInput,'keyup', this._event_onRgbKeyUp);
        Event.observe( this._redInput,'blur', this._event_onRgbBlur);
        Event.observe( this._greenInput,'blur', this._event_onRgbBlur);
        Event.observe( this._blueInput,'blur', this._event_onRgbBlur);

        // HEX
        Event.observe( this._hexInput,'keyup', this._event_onHexKeyUp);

        this.color = new Color();

        // get an initial value
        if (this._hexInput.value != '')
            this.color.setHex(this._hexInput.value);


        // set the others based on initial value
        this._hexInput.value = this.color.hex;

        this._redInput.value = this.color.r;
        this._greenInput.value = this.color.g;
        this._blueInput.value = this.color.b;

        this._hueInput.value = this.color.h;
        this._saturationInput.value = this.color.s;
        this._valueInput.value = this.color.v;        

    },
    _onHsvKeyUp: function(e) {
        if (e.target.value == '') return;
        this.validateHsv(e);
        this.setValuesFromHsv();
        if (this.onValuesChanged) this.onValuesChanged(this);
    },
    _onRgbKeyUp: function(e) {
        if (e.target.value == '') return;
        this.validateRgb(e);
        this.setValuesFromRgb();
        if (this.onValuesChanged) this.onValuesChanged(this);
    },
    _onHexKeyUp: function(e) {
        if (e.target.value == '') return;
        this.validateHex(e);
        this.setValuesFromHex();
        if (this.onValuesChanged) this.onValuesChanged(this);
    },
    _onHsvBlur: function(e) {
        if (e.target.value == '')
            this.setValuesFromRgb();
    },
    _onRgbBlur: function(e) {
        if (e.target.value == '')
            this.setValuesFromHsv();
    },
    HexBlur: function(e) {
        if (e.target.value == '')
            this.setValuesFromHsv();
    },
    validateRgb: function(e) {
        if (!this._keyNeedsValidation(e)) return e;
        this._redInput.value = this._setValueInRange(this._redInput.value,0,255);
        this._greenInput.value = this._setValueInRange(this._greenInput.value,0,255);
        this._blueInput.value = this._setValueInRange(this._blueInput.value,0,255);
    },
    validateHsv: function(e) {
        if (!this._keyNeedsValidation(e)) return e;
        this._hueInput.value = this._setValueInRange(this._hueInput.value,0,359);
        this._saturationInput.value = this._setValueInRange(this._saturationInput.value,0,100);
        this._valueInput.value = this._setValueInRange(this._valueInput.value,0,100);
    },
    validateHex: function(e) {
        if (!this._keyNeedsValidation(e)) return e;
        var hex = new String(this._hexInput.value).toUpperCase();
        hex = hex.replace(/[^A-F0-9]/g, '0');
        if (hex.length > 6) hex = hex.substring(0, 6);
        this._hexInput.value = hex;
    },
    _keyNeedsValidation: function(e) {

        if (e.keyCode == 9  || // TAB
            e.keyCode == 16  || // Shift
            e.keyCode == 38 || // Up arrow
            e.keyCode == 29 || // Right arrow
            e.keyCode == 40 || // Down arrow
            e.keyCode == 37    // Left arrow
            ||
            (e.ctrlKey && (e.keyCode == 'c'.charCodeAt() || e.keyCode == 'v'.charCodeAt()) )
        ) return false;

        return true;
    },
    _setValueInRange: function(value,min,max) {
        if (value == '' || isNaN(value))         
            return min;

        value = parseInt(value);
        if (value > max) 
            return max;
        if (value < min) 
            return min;

        return value;
    },
    setValuesFromRgb: function() {
        this.color.setRgb(this._redInput.value, this._greenInput.value, this._blueInput.value);
        this._hexInput.value = this.color.hex;
        this._hueInput.value = this.color.h;
        this._saturationInput.value = this.color.s;
        this._valueInput.value = this.color.v;
    },
    setValuesFromHsv: function() {
        this.color.setHsv(this._hueInput.value, this._saturationInput.value, this._valueInput.value);        

        this._hexInput.value = this.color.hex;
        this._redInput.value = this.color.r;
        this._greenInput.value = this.color.g;
        this._blueInput.value = this.color.b;
    },
    setValuesFromHex: function() {
        this.color.setHex(this._hexInput.value);

        this._redInput.value = this.color.r;
        this._greenInput.value = this.color.g;
        this._blueInput.value = this.color.b;

        this._hueInput.value = this.color.h;
        this._saturationInput.value = this.color.s;
        this._valueInput.value = this.color.v;
    }
};

;

// /8::/202::/frontend:js -> <872> commentswidgets.js 

var commentw;
CommentsWidget = Class.create();
CommentsWidget.prototype = {
  defaultOptions: function(){
    return {};
  }, 
  makeWidgetContent: function(){
    commentw = this;
    var ctextw =  Builder.node('span',{
      style: "vertical-align:top;cursor:pointer;cursor:hand;font-weight:bolder;"
    },[translateText({path: "", id: "comments"}), TN(" "), this.getCommentCount()]);
    Event.observe(ctextw,'click',function(event){
      Event.stop(event)
      this.onclick()
    }.bindAsEventListener(this))
    return ctextw;
  }, 
  onclick: function(event) {
    this.makeDisplayWin();    
  },
  getCommentCount: function(){
    return TN("("+this.options.m.comment_count+")");
  }, 
  makeAddButton: function(s){
    return Builder.node('img',{
      style: "vertical-align:bottom;",
      border: "0",
      src: "/images/icons/turquoise/" + s + "x" + s + "/action_edit.gif"
    });
  }, 
  makeReadButton: function(s){
    return Builder.node('img',{
      style: "vertical-align:bottom;",
      border: "0",
      src: "/images/icons/turquoise/" + s + "x" + s + "/misc_go.gif"
    });
  }, 
  makeDisplayWin: function(){
    new ThemedWindow({
      title: Builder.node('span', [translateText({
        path: ".comments",
        id: "window-title",
        args: [this.options.m.name]
      })]).innerHTML,
      width: 500,
      height: 400,
      minimizable:false,
      maximizable:false,
      showEffect:Element.show,
      hideEffect:Element.hide,
      destroyOnClose: true
    }, function(w) {
      w.setContent(new DisplayCommentsWidget({
        m: this.options.m,
        model: this.options.model
      }).htmlNode())
      w.showCenter()
      w.toFront()
    }.bind(this))
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}
Object.extend(CommentsWidget.prototype, WidgetCommon);

//-------------------------------------------------------------------------------

DisplayCommentsWidget = Class.create();
var dcw;
var morecomments,lesscomments;
var ccww;  
DisplayCommentsWidget.prototype = {
  defaultOptions: function(){
    return {};
  },
  setup:function(){
    dcw = this;
    this.comments = [];
    this.getComments();
  }, 
  getComments:function(){
    this.comments = [];
    this.options.model.commentsForItem(this.options.m,{
      success:function(s){this.commentsLoaded(s)}.bind(this)
    }); 
  },
  commentsLoaded:function(s){
    var comm = s.items;
    this.userModel = s.users;   
    comm.each(function(c,ii){  
      this.comments.push(this.makeCommentRow(c,ii));             
    }.bind(this));
    this.rerender();
  },
  makeWidgetContent: function(){
    var allcomm = this.comments; 
    var head =  Builder.node('div',{
      className:"article-header"
    },[TN(this.options.m.name)]) 
    return Builder.node('div',{ style: "padding:10px;"},[
      head,
      Builder.node('div',{id:"writeCommentBox"},[
        new WriteCommentsWidget({
          m: this.options.m,
          model: this.options.model,
          display:"block"
        }).htmlNode()
      ]),
      Builder.node('span',{style: "font-size:140%;"}, [
        translateText({path: "", id: "comments"}),
        TN(": "),
        TN("(" + this.options.m.comment_count + ")"),
        NBSP(),
        NBSP()
      ]),
      BR(),
      allcomm
    ]);
  },
  deleteComment:function(id){
    this.options.model.removeCommentForItemAndId(this.options.m,id);
    this.getComments();
  },
  makeCommentRow: function(c,i){
    var bg = "#EDEDED";
    if(isDeletingCommentAlllowed(this.options.m, c)){
      var del = Builder.node('div',{id:c.id},[
        Builder.node('img', {
          id:c.id,
          src: "/images/icons/mycons/24x24/delete.png",
          alt:"empty trash"
        })
      ]);
      Event.observe(del,'click',function(e){
        id = Event.element(e).id;
        this.deleteComment(id);
      }.bindAsEventListener(this));
    }else{
      var del = NBSP();
    }
    var table = Builder.node('table',{width: "100%"}, [
      Builder.node('tbody', [
        Builder.node('tr', [
          Builder.node('td',{width: "33%", className: ""},[]), 
          Builder.node('td',{width: "33%", className: ""},[
            TN("added: "), makeNiceDate(c.added_at)
          ]), 
          Builder.node('td',{width: "33%", className: ""},[del])
        ]), 
        Builder.node('tr', [
          Builder.node('td',{colspan: "3", className: ""},[
            Builder.node('div',{style:"font-size:140%;"},[TN(c.content)])
          ])
        ])
      ])
    ]); 
    if (i % 2 == 0){
      bg = "#EDEDED";
    }else{
      bg = "white"
    }
    var userBox = Builder.node('div',{style:""},[ 
      Builder.node('img', {
        width:"95",
        height:"63",
        src: this.userModel[c.account_id].userimage || "/images/user_thumb_placeholder.jpg",
        alt:"icon"
      }),
      Builder.node('div',{style:"font-size:130%;font-weight:bolder;"},[
        TN(this.userModel[c.account_id].username)
      ])  
    ]);
    var outertable = Builder.node('table',{width: "100%"}, [
      Builder.node('tbody', [
        Builder.node('tr', [
          Builder.node('td',{width: "10%", className: ""},[userBox]), 
          Builder.node('td',{width: "90%", className: "",valign:"top"},[table]), 
        ])
      ])
    ]); 
    var commarr = (Builder.node('div',{
      className: "commentrow",
      id:"commentrow_"+i,
      style: "background:" + bg + ";border-bottom:1px dashed silver;" +
             "margin-bottom:10px;width:100%;"
    }, [outertable]));
    return commarr;
  }, 
  showComments: function(){
    for(var i = 0;i<xx.length;i++){
      new Effect.SlideUp($("commentrow_"+i), { duration: 0.4}); 
    }
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}
Object.extend(DisplayCommentsWidget.prototype, WidgetCommon);

//-------------------------------------------------------------------------------

WriteCommentsWidget = Class.create();
var wcw; 
WriteCommentsWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({display:"block"},arguments[0]);
  }, 
  makeWidgetContent: function(){
    wcw = this;
    var commentbtn = translateButton({
      path: ".comments",
      id: "send-comment",
      node: Builder.node('input',{
        type: "button",
        id: "commentsend",
        value: ""
      })
    })
    Event.observe(commentbtn,'click',function(){
      if( $F("commenttext") != ""){
        new Effect.SlideUp($("mainAreaWriteComment_"+wcw.options.m.id), { duration: 0.4});
        // FIXME: Uses global varialbes wcw and dcw
        this.options.model.addCommentForItem(wcw.options.m,$F("commenttext"), {
          success: function(comment) {
            var m = wcw.options.m
            var usr = this.options.model.user(m.pretty_name)
            new UserMessages({
              user: usr,
              afterLoad: function(um) {
                um.sendMessage("User <a href=\"" + serviceLink({
                  service: "updates",
                  user: writeUserModel.data.username
                }) +"\">" + writeUserModel.data.username.capitalize() +
                "</a> added the following comment to <a href=\"" +
                this.options.model.currentPathPermalink(m) + "\">" +
                m.name + "</a>:<br />" + comment.data.content, {
                  noCopyForSender: true
                })
              }.bind(this)
            })
          }.bind(this)
        });
        window.setTimeout(function(){dcw.getComments();},500);
      }
    }.bind(this))
    var c1 = Builder.node('div',{
      style:"cursor:pointer;cursor:hand;",
      id:"topbarWriteComment"
    },[
      translateText({path: ".comments", id: "write-comment"}),
      NBSP(),
      Builder.node('img',{src: "/images/icons/turquoise/16x16/action_edit.gif"})
    ]); 
    Event.observe(c1,'click',function(){  
      new Effect.SlideDown($("mainAreaWriteComment_"+this.options.m.id), { duration: 0.4 });            
    }.bindAsEventListener(this))
    return Builder.node('div',{style:""},[
      c1,
      Builder.node('div',{
        id:"mainAreaWriteComment_"+this.options.m.id,
        style: "height:160px;padding:10px;display:"+this.options.display+";"
      },[
        Builder.node('div',{style: "font-size:140%;"}, [
          translateText({path: ".comments", id: "write-comment"}),
          TN(": ")
        ]), 
        Builder.node('div',{},[
          Builder.node('textarea',{
            width: "100%",
            id: "commenttext",
            className:"commentarea",
            style: "width:90%;font-family:Trebuchet MS"
          }),
          BR(),
          BR(),
          commentbtn,
          NBSP()/*,cancelbtn*/
        ])
      ])
    ]);
  }
}
Object.extend(WriteCommentsWidget.prototype, WidgetCommon)

//-------------------------------------------------------------------------------

;

// /8::/202::/frontend:js -> <871> contextmenuwidget.js 

//old?_delete *mike
 
 contextMenuWidget = Class.create();
contextMenuWidget.prototype =
{
    defaultOptions: function()
    {
       return Object.extend({
           m:null,
           style: "width:100px;height:100px;background:transparent;",
           menulinks:[{
               name: 'Item',
               className: 'Itm',
               callback: function() {
               alert('Click');
           }}]
       },arguments[0]||{});
    },
    setup:function(){
    cMenu = this; 
    this.generateMenu();

     $(document.body).observe('contextmenu',function(e){
        Event.stop(e);
        return false;
    });
    Event.observe($(document.body),'click',function(e){
        //Event.stop(e); 
        if($("cM")){
            $("cM").hide();
        }
    });
    Event.observe($(document.body),'mousedown',function(e){
        var t = Event.element(e);
        var pX = Event.pointerX(e);
        var pY = Event.pointerY(e);
        var d = $("root").getDimensions();
        $("root").setStyle({position:"absolute",width:d.width+"px",height:d.height+"px"});

        if(cMenu.isRightClick(e)){
            Event.stop(e);
            if(!$("cM").visible()){  
                $("cM").show();
                $("cM").setStyle({position:"absolute",marginLeft:pX+"px",marginTop:pY+"px"});
            }else{
                $("cM").setStyle({position:"absolute",marginLeft:pX+"px",marginTop:pY+"px"});    
            }
            return false;
        }else{  
            return true;
        }

    })
    },
    generateMenu:function(){
        var cX = Builder.node('div',{id:"contextNodes",style:this.options.style},[]);
        var cM = Builder.node('div',{id:"cM",style:this.options.style},[roundIt({className:"roundBtnT",node:cX,width:"170px"})]); 
        //$(cM).setOpacity(0.7); 

          //$(cX).setOpacity(1); 
        $(cM).hide(); 
        $(document.body).appendChild(cM); 
        this.setMenuLinks(this.options.menulinks);
        return true;
    },    
    setMenuLinks:function(lnk){
        var links = lnk;
        var a = Builder.node('div',{id:"contextNodeInner"},[]);
        links.each(function(l){
            var n = Builder.node('div',{className:l.className,style:"padding:5px;cursor:hand;cursor:pointer;color:#FFFFFF;width:95%;padding-bottom:4px;border-bottom:2px inset #888888;"},[]);
            var ico = Builder.node('img',{src:l.icon});
            var lb = table([{columnOptions:{width:40},columnData:[ico]},{columnOptions:{},columnData:[TN(l.name)]}])
            n.appendChild(lb);

            Event.observe(n,'click',function(e){
                 Event.stop(e);
                 $("cM").hide(); 
                 l.callback(e);
            });
            Event.observe(n,'mouseover',function(e){
                 Event.stop(e);
                 $(n).setStyle({backgroundColor:"#EDEDED",color:"#000000"});
            });
            Event.observe(n,'mouseout',function(e){
                 Event.stop(e);
                 $(n).setStyle({backgroundColor:"transparent",color:"#FFFFFF"});
            }); 

            a.appendChild(n);
        });
        //$("contextNodes").firstChild.remove();
        $("contextNodes").appendChild(a);
        return true;
    },
    isRightClick:function(event) {

        return (((event.which) && (event.which == 3)) ||

            ((event.button) && (event.button == 2)));

    }, 
    update:function(){

    },
    makeWidgetContent: function(){
         return EMPTY();
    }
}
Object.extend(contextMenuWidget.prototype, WidgetCommon);


/*
///INIT contextMenu with default actions
var cMn;
var myMenuItems; 
Event.observe(window,'load',function(e){
    myMenuItems = [
  {
    name: 'Add Item',
    className: 'edit',
    icon:"/images/icons/mycons/24x24/add_item.png", 
    callback: function() {
      itemModel.actions.addItem();
    }
  },{
    name: 'Add Folder',
    className: 'copy', 
    icon:"/images/icons/mycons/24x24/add_folder.png",
    callback: function() {
      itemModel.actions.addFolder();
    }
  },{
    name: 'Help',
    className: 'save',
    icon:"images/icons/mycons/24x24/help.png",
    callback: function() {
      initEditorialWindow("Help");
    }
  }
];

if(cMn == null){
    cMn = new contextMenuWidget({style:"background:transparent;",menulinks:myMenuItems}); 
}

})
*/

;

// /8::/202::/frontend:js -> <13648> conversationview.js 

ConversationView = {
  conversationView: function(c) {
    if (!this.cv) this.cv = {}
    this.cvSetup(c)
    var msgs = Builder.node('div', {
      style: "width:95%;height:78%;overflow: scroll;"
    },[
      this.showMessages(c.msgs)
    ])
    var cns = $(msgs).down('tbody', Prototype.Browser.IE ? 1 : 0).childNodes
    if (cns.length > 0) cns[cns.length-1].scrollIntoView()
    if (this.cvNoForm && this.cvNoForm()) {
      Element.setStyle(msgs, {height: "98%"})
      var reply = EMPTY()
    }
    else {
      var textarea;
      var form = Builder.node('form', {style: "height:100%;"}, [
        table({height: "100%"}, [
          {columnOptions: {width: "100%"}, columnData: [
            textarea = Builder.node('textarea', {
              name: "message",
              style: "width:100%;"
            })
          ]},
          Builder.node('input', {
            type: "submit",
            value: "Send",
            style: "margin-left: 5px;"
          })
        ])
      ])
      Event.observe(form, 'submit', function(event) {
        Event.stop(event)
        var form = Event.element(event)
        if (form.tagName != 'FORM') form = Element.up(form, 'form')
        var message = form.message.value
        form.message.value = ""
        this.cvFormSubmit(message, c, msgs)
      }.bindAsEventListener(this))
      $(textarea) // for IE      
      var prevValue = null
      var i = setInterval(function() {
        var v = textarea.up().offsetHeight
        if (v <= 0) return;
        if (prevValue && v > prevValue) {
          clearInterval(i)
          if (v > 20) v -= 10
          textarea.style.height = v + "px"
        }
        prevValue = v;
      }, 10)
      var reply = Builder.node('div', {style: "width:95%;height:18%;"}, [
        form
      ])
    }
    return Builder.node('div', {style: "width:100%;height:100%"}, [msgs, reply])
  },
  showMessages: function(messages) {
    var tbody = Builder.node('tbody', $A(messages).map(function(m) {
      if (m.name == "Welcome Message") {
        var profile = {
          username: "team",
          userimage: "/images/user_thumb_placeholder.jpg"
        }
      }
      else {
        var profile = this.cv.model.users()[m.account_id]        
      }
      var sender = Builder.node('td', [Builder.node('div', {
        style: "font-weight:bolder;font-style:italic;font-size:smaller;" +
               "border-top: 1px solid black;width:100%;padding-right:5px;" +
               "padding-bottom: 2px;"
      }, [
        TN(profile.username), BR(),
        Builder.node('img', {
          src: profile.userimage ? localizeURL(profile.userimage) : "/images/user_thumb_placeholder.jpg",
          alt: 'userimage',
          style: 'height:40px;',
          border: 0
        })
      ])])
      sender.style.verticalAlign = "top"
      var messageNode = this.formatMessage(m, profile)
      if (this.deleteMessage) {
        var delete_message = Builder.node('img', {
          style: "cursor:pointer;border:0px;",
          src: "/images/icons/mycons/24x24/delete.png"
        })
        Event.observe(delete_message, 'click', function(event) {
          if (event) Event.stop(event)
          verify(function() {
            this.deleteMessage(m)
            // Remove element from message list, but in place!
            for(var i = 0; i < messages.length; i++) {
              if (messages[i] == m) break;
            }
            messages.splice(i, 1)
            Effect.SlideUp(tr)
          }.bind(this), translateText({path: ".conversation-view", id: "delete-msg"}))
        }.bindAsEventListener(this))
      }
      else {
        var delete_message = EMPTY()
      }
      var message = Builder.node('td', {width: "100%"}, [Builder.node('div', {
        style: "border-top: 1px solid black;width:100%;"
      },[
        Builder.node('div', {
          style: "width:100%;text-align:right;font-size:x-small;"
        }, [
          TN("(" + this._formatDate(new Date(m.added_at)) + ")"),
          delete_message
        ]),
        messageNode
      ])])
      message.style.verticalAlign = "top"
      var tr = Builder.node('tr', [sender, message])
      return tr
    }.bind(this)))
    return Builder.node('table', {
      border: "0",
      cellpadding: "0",
      cellspacing: "0",
      width: "95%"
    }, [tbody])    
  },
  formatMessage: function(m, profile) {
    if (profile.username == "team") {
      var messageNode = Builder.node('span')
      messageNode.innerHTML = m.message
    }
    else if (m.report == "true") {
      var messageNode = Builder.node('div', {style: "background:#FF8080;"})
      messageNode.innerHTML = m.message
    }
    else {
      var messageNode = Builder.node('div')
      var mh = m.message.stripTags()
      mh = mh.gsub(/((http:\/\/|www)\S+\w)/, "<a href=\"#{1}\">#{1}</a>")
      mh = mh.gsub(/\r\n/, "<br />").gsub(/[\r\n]/, "<br />")
      messageNode.innerHTML = mh
    }
    return messageNode
  },
  cvUpdateView: function(m, c, msgs) {
    // Update this window
    c.msgs.push(m)
    c.date = m.added_at
    msgs.replaceChild(this.showMessages(c.msgs), msgs.firstChild)
  },
  _formatDate: function(date) {    
    function tdds(num) {
      if (num >= 0 && num <= 9) {
        return "0" + num
      }
      else {
        return num + ""
      }
    }
    var day = tdds(date.getDate()) + "/" + tdds(date.getMonth() + 1) +
              "/" + date.getFullYear()
    var time = tdds(date.getHours()) + ":" + tdds(date.getMinutes())
    return day + " " + time
  }
}

;

// /8::/202::/frontend:js -> <40574> displayblogwidget.js 

DisplayBlogWidget = Class.create();
DisplayBlogWidget.prototype = {
  defaultOptions: function() {
    return {
      model: itemModel,
      capItemsAt: 20,
      compact: false
    };
  },
  setup:function(){ 
    this.options.model.addObserver(this);
  }, 
  update:function(){
    this.redrawCompletely()
  },
  makeWidgetContent: function(){
    var allcomm = this.processEntriesArray(this.getEntries());
    return Builder.node('div', [allcomm]);
  }, 
  getEntries: function(){
    var xx = this.options.model.getModel();
    if (this.options.capItemsAt) {
      return xx.slice(0, Math.min(this.options.capItemsAt, xx.length))
    }
    else {
      return xx;
    }
  },
  processEntriesArray: function(arr){
    return $A(arr).map(function(item) {
      return new itemRowWidget({model: this.options.model, m: item}).htmlNode()
    }.bind(this))
  }
}
Object.extend(DisplayBlogWidget.prototype, WidgetCommon);

;

// /8::/202::/frontend:js -> <5270> fakeservicelist.js 

//old?_delete *mike
 
 
 var navicw;
var currentSelectedServiceName,currentSelectedServiceIcon,currentSelectedServiceUrl;
fakeServiceListWidget = Class.create();
fakeServiceListWidget.prototype = {
  defaultOptions: function() {
    return {}
  },
  makeWidgetContent: function() {
    list = this.serviceList();
    slw = this;
    slw.item = null;
    var l = [];
    list.each(function(m){
      var ico = Builder.node('img',{src:m.icon});
      var listitem = Builder.node('div',{
        style:"cursor:pointer;padding-left:5px;padding:2px;"
      },[table({},[{columnOptions:{width:25},columnData:[ico]},TN(m.displayName)])]); 
      listitem.url = m.url;
      listitem.displayName = m.displayName;
      listitem.ico = m.icon;
      Event.observe(listitem,'mouseover',function(){
        $(listitem).setStyle({backgroundColor:"#efefef"});
      });
      Event.observe(listitem,'mouseout',function(){
        $(listitem).setStyle({backgroundColor:"#ffffff"});
      });  
      Event.observe(listitem,'click',function(e){
        document.location.href = m.url;
        // currentSelectedServiceName = listitem.displayName;
        // currentSelectedServiceUrl = listitem.url;
        // currentSelectedServiceIcon= Builder.node('img',{src:listitem.ico});
        // slw.item =  listitem 
        // slw.rerender();
        // $("sList").hide();
        // $("lList").show();
      }); 
      l.push(listitem);     
    });
    // Most of this isn't probably in use anymore!
    var backToList = Builder.node('div',{
      style:"cursor:pointer;padding-left:5px;padding:2px;"
    },[TN("back")]);
    Event.observe(backToList,'click',function(){
      slw.rerender();
      $("sList").show();
      $("lList").hide(); 
    });
    var melink = Builder.node("div",{
      id:"sList",
      style:"cursor:pointer;padding:3px;font-size:100%;font-weight:bolder;"
    },[TN("Private")]);
    var wwwlink = Builder.node("div",{
      id:"sList",
      style:"cursor:pointer;padding:3px;font-size:100%;font-weight:bolder;"
    },[TN("Public")]); 
    Event.observe(melink,'mouseover',function(){
      $(melink).setStyle({backgroundColor:"#2FB6DE",color:"#FFFFFF"});
    });
    Event.observe(melink,'mouseout',function(){
      $(melink).setStyle({backgroundColor:"#ffffff",color:"#000000"});
    });
    Event.observe(melink,'click',function(){
      window.document.location.href = currentSelectedServiceUrl.gsub("www",
        write_username);
    });
    Event.observe(wwwlink,'mouseover',function(){
      $(wwwlink).setStyle({backgroundColor:"#2FB6DE",color:"#FFFFFF"});
    });
    Event.observe(wwwlink,'mouseout',function(){
      $(wwwlink).setStyle({backgroundColor:"#ffffff",color:"#000000"});
    });
    Event.observe(wwwlink,'click',function(){
      window.document.location.href = currentSelectedServiceUrl;
    });
    var div1 = Builder.node("div",{
      id:"sList",
      style:"font-size:130%;font-weight:bolder;"
    },l); 
    var div2 = Builder.node("div",{
      id:"lList",
      style:"display:none;font-size:130%;font-weight:bolder;"
    },[
      backToList,
      table({},[
        {columnOptions:{width:25},columnData:[currentSelectedServiceIcon]},
        TN(currentSelectedServiceName)
      ]),
      melink,
      wwwlink
    ]);
    var hdiv = Builder.node("div",{
      style:"padding:5px;font-size:100%;font-weight:bolder;"
    },[div1,div2]); 
    return (new BoxWidget({
      id: 'tBox',
      title:
      TN("Favorite Services:"),
      node:hdiv,
      className:"mybox",
      width:"200"
    }).htmlNode());
  },
  serviceList:function(){
    var sl = [{
      icon:"/images/myfavorites.png",
      url:"http:\/\/www.myfavorit.es",
      real_name:'favorites',
      displayName: 'My Favorites',
      description: 'your favorite sites'
    },{
      icon:"/images/myfiles.png",
      url:"http:\/\/www.myfil.es",
      real_name:'files',
      displayName: 'My Files',
      description: 'your uploaded files'
    },{
      icon:"/images/mymovies.png",
      url:"http:\/\/www.mymovi.es",
      real_name:'movies',
      displayName: 'My Movies'
    },{
      icon:"/images/mypictures.png",
      url:"http:\/\/www.mypictur.es",
      real_name:'pictures',
      displayName: 'My Pictures'
    },{
      icon:"/images/mytunes.png",
      url:"http:\/\/www.mytun.es",
      real_name:'tunes',
      displayName: 'My Tunes'
    }]//,
    return sl;
  },
  rerender: function(){
    var nc = this.makeWidgetContent()
    this.replaceChild(this.content, this.widgetContent, nc)
    this.widgetContent = nc
  } 
}

Object.extend(fakeServiceListWidget.prototype, WidgetCommon); 

;

// /8::/202::/frontend:js -> <855> flagswidget.js 

//old?_delete *mike
 
 
 var __flags = null;
FlagsWidget = Class.create();
FlagsWidget.prototype = {
  defaultOptions: function() {
    return {
    }
  },
  setup: function() {
    var instance = this;
  },
  makeWidgetContent: function() {

    __flags = this
    var theiconnode = Builder.node('div',{id:"langBox"},[
        Builder.node('img',{id:"selFlag",src:"/core-services/icons/flags/gb.gif",className:"flags"})
    ])
     return theiconnode;

  },
  rerender: function(){
      var nc = this.makeWidgetContent()
      this.replaceChild(this.content, this.widgetContent, nc)
      this.widgetContent = nc
  },
  makeTooltipContent:function(){
      var ico_en = Builder.node('img',{alt:"english", onclick:"setLanguage2(this)",src:"/core-services/icons/flags/gb.gif",className:"flags"})
      var ico_hr = Builder.node('img',{alt:"croatian",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/hr.gif",className:"flags"})
      var ico_de = Builder.node('img',{alt:"german",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/de.gif",className:"flags"})
      var ico_fi = Builder.node('img',{alt:"finnish",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/fi.gif",className:"flags"})
      var ico_fr = Builder.node('img',{alt:"french",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/fr.gif",className:"flags"})
      var ico_jp = Builder.node('img',{alt:"japanese",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/jp.gif",className:"flags"})
      var ico_no = Builder.node('img',{alt:"norwegian",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/no.gif",className:"flags"})
      var ico_pt = Builder.node('img',{alt:"portuguese",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/pt.gif",className:"flags"})
      var ico_se = Builder.node('img',{alt:"swedish",onclick:"setLanguage2(this)",src:"/core-services/icons/flags/se.gif",className:"flags"})

var ben = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_en, TN("  English") ]); 
var bhr = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_hr, TN("  Croatian") ]); 
var bde = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_de, TN("  German") ]); 
var bfi = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_fi, TN("  Finnish") ]);
var bfr = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_fr, TN("  French") ]);
var bjp = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_jp, TN("  Japanese") ]);
var bno = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_no, TN("  Norwegian") ]);
var bpt = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_pt, TN("  Portuguese") ]);
var bse = Builder.node('p', {className:"flagp",onclick:"__flags.setLang(this.firstChild);"}, [ico_se, TN("  Swedish") ]);

var arr =  [
        ben,
        bhr,
        bde,
        bfi, 
        bfr,
        bjp,
        bno,
        bpt,
        bse
    ]

for (var i = 0;i < arr.length;i++){
    arr[i].onmouseover = function(){
        this.style.textDecoration = "underline"
    }
    arr[i].onmouseout = function(){
        this.style.textDecoration = ""
    }
};    

var ttc = Builder.node('div', {className:"flagsList"},arr)

var ttn = new BoxWidget({id:'tooltip',title:TN("Languages:"),node:ttc,className:"tooltip",width:150}).htmlNode();

return ttn;
},
setLang: function(m){
    ptt2.hideTotally()
       setLanguage(m.alt);
       $("selFlag").src = m.src;
}
}
Object.extend(FlagsWidget.prototype, WidgetCommon); 


;

// /8::/202::/frontend:js -> <870> frontend.js 

var translations = {}

//MOVED TO CORE
//GA added by mike
//add_gajs("http:\/\/www.google-analytics.com/ga.js");
//add_gajs("http:\/\/www.google-analytics.com/urchin.js");

 
function afterInitPage() {
    // Otherwise there's a horizontal scrollbar in FF3
    $('title-bar-right').style.paddingRight = "2px"
    myFrontend();  
    hook("afterInitFrontend"); 
}
 

var ew;
var mainwin;
var tw;


function removeChildNodes(ctrl) {
  while (ctrl.childNodes[0]) {
    ctrl.removeChild(ctrl.childNodes[0]);
  }
}


function myFrontend(){  
 
    removeChildNodes($("left-bar-placeholder"));
    removeChildNodes( $("title-bar-main"));
    removeChildNodes($("title-bar-left"));
    removeChildNodes($("title-bar-right"));

    /*edited by mike*/
    $("main-content-placeholder").down().remove()
 
    $('left-bar-placeholder').appendChild(roundBox({
        node: Builder.node('div', {id: 'left-bar',style:'width:200px;'})
    }));
    var l1 = serviceLink({
        user: "core",
        service: "files@core",
        action:"get_file?path=/headtopfill.png"
    })

    $("title-bar").setStyle({
        height:"81px",
        background:"url("+l1+") repeat-x"
    })
    var l2 = serviceLink({
        user: "core",
        service: "files@core",
        action:"get_file?path=/headtopfill.png"
    })

    $("title-bar-main").setStyle({
        height:"81px",
        width:"100%",     
        background:"url("+l2+") repeat-x"
    })
    var l3 = serviceLink({
        user: "core",
        service: "files@core",
        action:"get_file?path=/headtopleft.png"
    })

    $("title-bar-left").setStyle({
        height:"81px",
        width:"200px",
        background:"url("+l3+") no-repeat",
        cursor: "pointer"
    })

 
    //make logo clickable:
    b = Builder.node('div',{style:"margin-top:0px;background:transparent;position:relative;height:70px;width:230px;"})
    Event.observe(b,'click',function(f){
        window.document.location.href = serviceLink({
            user: "everyone",
            service: "main"
        })
    });
    $("title-bar-left").appendChild(b);

    var l4 = serviceLink({
        user: "core",
        service: "files@core",
        action:"get_file?path=/headtopright.png"
    })

    $("title-bar-right").setStyle({
        height:"81px",
        width:"550px",
        background:"url("+l4+") no-repeat",
        backgroundPosition: "top right"
    })


  var clearer = Builder.node('br',{style:"clear:both;"}); 
  // This is global! Don't add a var!!!

    writeUserTopBadgeWidget = new WriteUserTopBadgeWidget();
    leftPlaceHolder = Builder.node('div',{style:"height:50px;"},[EMPTY()]);

    if (Prototype.Browser.IE) {
        leftPlaceHolder.style.height = (parseFloat(leftPlaceHolder.style.height)+6) + "px"
    }

    rightPlaceHolder = Builder.node('div',{style:"width:548px;"},[EMPTY()]);
    appendChildren($("title-bar-right"),[rightPlaceHolder,writeUserTopBadgeWidget]);
  
    var seldiv = Builder.node('div',{},[
        new SelectionWidget({
            listContent: makeGlobalSelectionListContent()
        }).htmlNode()
    ])
  var selnode = new BoxWidget({
    id: 'selnode',
    title: TN("Select"),
    node: seldiv,
    className: "mybox"
  }).htmlNode();

  var actiondiv = Builder.node('div',{},[
    new ActionWidget({model: itemModel}).htmlNode()
  ])
  var actionnode = new BoxWidget({
    id: 'awnode',
    title: Builder.node('span', [
      translateText({id: "actions"}),
      helpTexts.helperNode("Actions Title",14)
    ]),
    node: actiondiv,
    className: "mybox"
  }).htmlNode();

  if (readUserModel.data.username == writeUserModel.data.username || itemModel.service() == "main@core") {
    var badgeBox = EMPTY()
  }
  else {
    var badge = new ReadUserBadgeWidget({}).htmlNode();
    var badgeBox = new BoxWidget({
      id:'BadgeBox',
      title: translateText({id: "about-me"}),
      node:badge,
      className:"mybox"
    }).htmlNode();    
  }
  var ntw = new naviTreeWidget()
  var folderBox = new BoxWidget({
    id:'FolderBox',
    title: ntw.title(),
    node: Builder.node('div', {style: "font-size:120%;"}, [ntw.htmlNode()]),
    className:"mybox"
  }).htmlNode();

/*edited by mike*/
  //search bar
  //$('top_badge').appendChild(Builder.node('div',{style:"position:absolute;top:45px;right:270px;",id:"searchBox"},[
 //       new qSearchWidget().htmlNode()
 // ]));
 
  appendChildren($('left-bar'), [
    leftPlaceHolder,
    Builder.node('div',{id:"ownerWidgetBox",className:'leftbox'},[badgeBox]),
    Builder.node('div',{id:"folderWidgetBox",className:'leftbox'},[folderBox])
  ])
  if (logged_in) {
    appendChildren($('left-bar'), [
      Builder.node('div',{id:"actionNodeBox",className:'leftbox'},[actionnode])
    ])
  }
  var infonode = new BoxWidget({
    id: "InfoNode",
    title: translateText({path: ".info", id: "title"}),
    node: Builder.node('div', {style: "font-size:bigger;padding:5px;"}, [translate({
      path: ".info",
      id: "content",
      node: Builder.node('span'),
      setText: function(n, t) {
        n.innerHTML = t
      }
    })]),
    className: "mybox"
  }).htmlNode();
  $('left-bar').appendChild(
    Builder.node('div', {id: "infoNodeBox", className: "leftbox"}, [infonode])
  )
  if(itemModel.user() != "everyone" || itemModel.service() != "main@core"){
    var name = itemModel.itemType().toLowerCase().pluralize()
    if (itemModel.user() == writeUserModel.data.username) {
      var username = "Me"
    }
    else {
      var username = itemModel.user().capitalize()
    }
    if (!standardExplorer) standardExplorer = makeStandardExplorerWidget()
    var theTabs = [
      explorerTab(
        standardExplorer,
        "useritems",
        name,
        username
      )
    ]
    if (readUserModel.data.username == writeUserModel.data.username) {
      theTabs.push(explorerTab(
        new RecentBuddyDisplayModel({service: itemModel.serviceName()}),
        "buddiesitems",
        name,
        "Buddies"
      ))
    }
    else if (logged_in) {
      theTabs.push(explorerTab(
        new DisplayModel({
          user:         writeUserModel.data.username,
          sortByColumn: "added_at",
          reverse:      true
        }),
        "myitems",
        name,
        "Me"
      ))
      theTabs.push(explorerTab(
        new RecentBuddyDisplayModel({
          service: itemModel.serviceName(),
          user: writeUserModel.data.username
        }),
        "mybuddiesitems",
        name,
        "Buddies"
      ))
    }

 /*edited mike */
    theTabs.push(explorerTab(
      new RecentDisplayModel({user:"everyone",service: itemModel.serviceName()}),
      "everyonesitems",
      name,
      "Everyone"
    ))

var head = (new TabsWidget({name: "s", tabs: theTabs})).htmlNode();

   }
  else {
    var head = BR();
  }
  appendChildren($('main-content-placeholder'), [
    Builder.node('div',{id: "tabs-explorer"},[
      Builder.node('div',{style:"height:29px;background:transparent;"}),
      head
    ])
  ]);
}

 
function explorerTab(modelOrExplorer, id, name, user) {
  if (modelOrExplorer.getModel) {
    var explorer = makeStandardExplorerWidget({model: modelOrExplorer})    
  }
  else {
    var explorer = modelOrExplorer
  }
  if ($A(["me", "buddies", "everyone"]).include(user.toLowerCase())) {
    var t = translateText({path: "", id: user.toLowerCase()})
  }
  else {
    var t = user
  }
  return {
    name: id,
    title: t,
    widget: boxedExplorer(explorer, id+"-explorer"),
    afterInitiallyShowingTab: function() {
      explorer.slider.slider.initSlider()
    },
    beforeTabHide: function() {
      explorer.options.presenters.thumbsView.beforeTabHide()
    }
  }
}

function boxedExplorer(explorer, id) {
  var e = explorer ? explorer.htmlNode() : TN("")
  var p = explorer ? explorer.pathWidget.htmlNode() : TN("")
  var expl = Builder.node('div',{id: id + "_explorerNode"},[e]);
  var expltitle = table({width:"100%"},[
    {columnOptions:{},columnData:[Builder.node('div',{style:""},[p])]}
  ]);
  return new BoxWidget({
    id: id,
    title: expltitle,
    node: expl,
    className: "mybox",
    draggable: false
  });
}

function generateLoader(){
  try {
    var so = new SWFObject("/core-services/icons/progress.swf","myprogress","256px","256px","8","#FFFFFF");
    so.addParam("wmode", "transparent");
    so.write("idle-spinner");
  } catch(e){}
}

;

// /8::/202::/frontend:js -> <154203> frontsaveandshare.js 

  var el;
var swin;
var atw;

FrontSaveAndShareWidget = Class.create();
FrontSaveAndShareWidget.prototype = {
  defaultOptions: function(){
    return {
      item: null,
      model: itemModel,
      shortText: false,
      node:null
    }
  },
  makeWidgetContent: function(){
    atw = this;
    if (!this.options.shortText) {
      var text = translateText({path: ".share", id: "share-item", args: [
        this.options.model.itemType()
      ]})
    }
    else {
      var text = translateText({path: "", id: "share"})
    }

 
    this.textnode = Builder.node('div',{
      id:"addToMo",
      style:"cursor:pointer;cursor:hand;font-weight:bold;"
    }, [     
      text,NBSP(),TN(this.options.item.type)
    ]);
 
if(this.options.node != null){
    var addtomo = this.options.node
}else{
  
var addtomo = this.textnode
}
    addtomo.m = this.options.item;

    Event.observe(addtomo,'click',function(e){
        this.setContent(this.options.item);
        Event.stop(e);
        return false;
    }.bind(this));
    
    return addtomo;
  }, 
  windowContent: function(itm){
    instance = this;
    this.type = "";
    this.perma = "";
    this.item = null; 
    this.url = "";
    if(itm == null){
      //no item selected.. take currentPath
      itm = {name:""};
      this.item = itm;
      this.perma = this.options.model.currentPathPermalink() 
    }else{
      //selected item..check type
      this.item = itm;
      this.type = this.item.type;
      this.perma = this.options.model.currentPathPermalink(itm) 
    };
    var copyok = Builder.node('span',{
      id:"copyok",
      style:"display:none;text-align:center;width:190px;height:25px;" +
            "margin-top:0px;padding:2px;margin-left:16px;" +
            "font-size:14px;background:#EFEDED;"
    },[translateText({path: ".share", id: "copied-to-clipboard"})])
    if (this.options.compact) {
      var head = copyok;
      copyok.style.width = "90%"
    }
    else {
      var head = Builder.node('div',{
        style:"font-weight:bolder;font-size:180%;margin-bottom:15px;"
      },[table([
        {
          columnOptions:{width:45,valign:"bottom"},
          columnData:[Builder.node('img',{src:"/images/shareicon.png"})]
        },
        translateText({path: ".share", id: "share-item", args: [this.type]}),
        copyok
      ])]);      
    }
    var share = [];
    sel = {
      description: translateText({path: ".share", id: "share-url"}),
      value:{val:this.options.model.currentPathPermalink(itm)},
      template:"#{val}"
    }
    if(ManageItemDialog.prototype.getEmbedLinks){
      el = ManageItemDialog.prototype.getEmbedLinks(itm, this.options.model);
    }else{
      el = [];
    }
    el.unshift(sel);
    el.each(function(l){
      share.push(instance.makeEmbedInput(l));
    });
    var more = Builder.node('div',{style:"font-weight:bolder;"},[]);  
    var morenodes = [
      {text:translateText({path: ".share", id: "bookmark-item"}),icon:"/images/semailico.png",action:function(e){
        var bmbox = Builder.node('div',{id:"bmbox"},[
          getLinks(instance.item.name,cleanUrl(instance.perma))
        ]);
        generateWindow(bmbox);
      }}
    ]; 
    if(this.item.full_item_url){
      morenodes.push({text: translateText({path: ".share", id: "download"}),icon:"/images/sdlico.png",action:function(e){
        window.location.href = instance.item.full_item_url;
      }});
      morenodes.push({
        text: translateText({path: ".share", id: "send-to-mobile"}),
        icon:"/images/semailico.png",
        action:function(e){
          qrc = generateSaveQR(instance.item.full_item_url);             
          $("shareBox").parentNode.appendChild(Builder.node('div',{
            style:"padding:10px;"
          },[qrc]));            
          $("shareBox").hide();
        }
      });
    }
    var morearr = [];
    if(ManageItemDialog.prototype.getEmbedButtons){
      eb = ManageItemDialog.prototype.getEmbedButtons(itm);
      eb.each(function(e){                
        morenodes.push(e);
      });
    }else{
      eb = [];
    }
    morenodes.each(function(n){
      morearr.push(instance.makeEmbedButton(n))
    });
    appendChildren(more,morearr);
    share.push(more); 
    share.unshift(head);
    return Builder.node('div',{
      id:"shareBox",
      style:"padding:20px;padding-top:0px;"
    },share);      
  }, 
  makeEmbedInput:function(o){
    var te = new Template(o.template);
    var show = o.value;
    var val =  te.evaluate(show);
    if (typeof o.description == "string") {
      var txt = Builder.node('div',[TN(o.description)]);      
    }
    else {
      var txt = Builder.node('div', [o.description])
    }
    if (this.options.compact) {
      var style = "padding:4px;background:#FFF9DF;border:1px solid silver;" +
                  "width:145px;font-size:10px;margin-bottom:5px;"
    }
    else {
      var style = "padding:4px;background:#FFF9DF;border:1px solid silver;" +
                  "width:90%;font-size:10px;margin-bottom:15px;"
    }
    var node = Builder.node('input',{
      value:val,
      type:"text",
      style: style
    });
    Event.observe(node,'click',function(e){
      Event.stop(e);
      copyToClipboard(Event.element(e))
    });
    if(!show.val){
      return NBSP();
    }
    return Builder.node('div',[txt,node]);
  },
  makeEmbedButton:function(o){
    var ni = Builder.node('a',{style:"color:#000000;margin-right:10px;",href:"#"},[
      o.text
    ]);
    Event.observe(ni,'click',function(e){
      Event.stop(e);
      o.action(e);
    });
    var n = table([{columnOptions:{width:35},columnData:[
      Builder.node('img',{src:o.icon})
    ]},ni]);
    if (this.options.compact) {
      style = "float:left;height:32px;width:90%;overflow:hidden;"
    }
    else {
      var style = "float:left;height:32px;width:200px;overflow:hidden;"
    }
    return Builder.node('div',{
      style: style
    },[n]); 
  },
  rerender: function(){
    var nc = this.makeWidgetContent();
    this.replaceChild(this.content, this.widgetContent, nc);
    this.widgetContent = nc;
  },
  setContent:function(itm){
    var scdw = Builder.node('div',{id:"scdw"},[this.windowContent(itm)]);
    generateWindow(scdw);
  }
}  
Object.extend(FrontSaveAndShareWidget.prototype, WidgetCommon);

function generateWindow(c){
  if(swin != null){
    try{
      swin.hide();
      swin.destroy(); 
    }catch(e){}
  } 
  swin = new Window({
    destroyOnClose:true,
    zindex:9999,
    minimizable:false,
    maximizable:false,
    showEffect:Element.show,
    hideEffect:Element.hide,
    className: "tooltip",
    onClose:function(){
      endIdle();
    },
    onMove:function(){
    },
    onShow:function(){
    }
  }) 
  swin.setContent(c, true, true); 
  swin.setSize(570, 420);
  swin.setZIndex(9999);
  swin.showCenter();   
}

function generateSaveQR(data){
  qrcw = new QRCodeWidget({data:data});
  var close = Builder.node('input',{type:"button",value:"close"});
  Event.observe(close,'click',function(e){
    $("shareBox").show();
    $("qrBox").remove();
  });
  return Builder.node('div',{id:"qrBox",style:"padding:30px;"},[
    qrcw.htmlNode(),BR(),BR(),BR(),close
  ]);
}

function copyToClipboard(elt) {
  var swf = "http:\/\/mike.myservic.es/flash/cp.swf";
  var fc = 'fc';
  if(!$(fc)){
    var divholder = Builder.node('div',{id:"fc"});
    document.body.appendChild(divholder,{});
  }
  //Effect.Appear($("copyok"));
  $(fc).innerHTML = '';
  var divinfo = '<embed src="' + swf + '" FlashVars="cp='+escape(elt.value)+
                '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
  $(fc).innerHTML = divinfo;
  elt.select();
  //window.setTimeout(function(){
  //  Effect.Fade($("copyok"),{});
  //},1000);
  return true;
}

function bookmarkIt(title,url) {
  name=title; 
  if(window.sidebar) {                                 
    window.sidebar.addPanel(name, "http:\/\/"+url, '');
  } else if(document.all) {                             
    window.external.AddFavorite(url, name);
  } else if(window.opera && window.print) {             
    var e=document.createElement('a');
    e.setAttribute('href',url);
    e.setAttribute('title',name);
    e.setAttribute('rel','sidebar');
    e.click();
  }
}

function getLinks(title,url){    
  var itemurl = url;
  var addto = "";
  var title = title;
  var container = Builder.node('div',{style:"padding:10px;"},[]);
  var top = '<div ><span style="font-size:120%;font-weight:bold;">Bookmark: </span><br/>Save this link in your favorite bookmark manager:</div><a  style="color: black; font-size: 11px;" class="addto" href="javascript:bookmarkIt(\''+title+'\',\''+itemurl+'\')" title="Bookmark with your browser">Bookmark in your browser</a><br/><br/>'; 
  var bookmarks = [
    '<div id="My_Yahoo_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/e.my.yahoo.com/config/edit_bookmark?.src=bookmarks&.folder=1&.name=&.url=http%3A%2F%2F'+itemurl+'&.save=+Save+" title="Bookmark with My Yahoo Bookmarks"><img width="91" height="17" border="0" src="http:\/\/us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif" alt="My Yahoo Bookmarks"/></a></div>',
    '<div id="del.icio.us" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/del.icio.us/post?&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with del.icio.us"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/delicious.png" alt="del.icio.us"/></a></div>',
    '<div id="Mister-Wong" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mister-wong.com/index.php?action=addurl&bm_url=http%3A%2F%2F'+itemurl+'&bm_description=" title="Bookmark with Mister-Wong"><img width="80" height="15" border="0" src="http:\/\/www.mister-wong.com/img/wong.gif" alt="Mister-Wong"/></a></div>',
    '<div id="Technorati_Favorites" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/technorati.com/faves?add=http%3A%2F%2F'+itemurl+'" title="Bookmark with Technorati Favorites"><img width="91" height="17" border="0" src="http:\/\/static.technorati.com/pix/fave/tech-fav-5.gif" alt="Technorati Favorites"/></a></div>',
    '<div id="Furl" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.furl.net/storeIt.jsp?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with Furl"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/furl.png" alt="Furl"/></a></div>',
    '<div id="CiteULike" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.citeulike.org/posturl?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with CiteULike"><img width="94" height="15" border="0" src="http:\/\/static.citeulike.org/img/small-logo.png" alt="CiteULike"/></a></div>',
    '<div id="Hemidemi" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.hemidemi.com/user_bookmark/new?title=&url=http%3A%2F%2F'+itemurl+'&via=http%3A%2F%2Fwww.mysit.es%2F" title="Bookmark with Hemidemi"><img width="80" height="15" border="0" src="http:\/\/www.hemidemi.com/images/hemidemi.png" alt="Hemidemi"/></a></div>',
    '<div id="FunP" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/funp.com/portal/addrss.php?url=http%3A\/\/'+itemurl+'&via=mysites" title="Bookmark with FunP"><img width="90" height="22" border="0" src="http:\/\/funp.com/tools/images/subscribe_05.gif" alt="FunP"/></a></div>',
    '<div id="Xerpi" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.xerpi.com/block/add_link_from_extension?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Xerpi"><img width="91" height="17" border="0" src="http:\/\/www.xerpi.com/images/xerpipost.gif" alt="Xerpi"/></a></div>',
    '<div id="Facebook" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.facebook.com/share.php?src=bm&u=http%3A%2F%2F'+itemurl+'&t=&v=3" title="Bookmark with Facebook">Facebook</a></div>',
    '<div id="Netvouz" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.netvouz.com/action/submitBookmark?url=http%3A%2F%2F'+itemurl+'&title=&popup=no" title="Bookmark with Netvouz">Netvouz</a></div>',
    '<div id="Wink" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.wink.com/_/tag?url=http%3A%2F%2F'+itemurl+'&doctitle=" title="Bookmark with Wink">Wink</a></div>',
    '<div id="Ma.gnolia" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/ma.gnolia.com/bookmarklet/add?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Ma.gnolia">Ma.gnolia</a></div>',
    '<div id="BibSonomy" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.bibsonomy.org/BibtexHandler?requTask=upload&url=http%3A%2F%2F'+itemurl+'&description=" title="Bookmark with BibSonomy">BibSonomy</a></div>',
    '<div id="Jots" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.jots.com/?cmd=do_post&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Jots">Jots</a></div>',
    '<div id="Taggly" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.taggly.com/bookmarks/?action=add&address=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Taggly">Taggly</a></div>',
    '<div id="BlogMarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/blogmarks.net/my/new.php?mini=1&simple=1&title=&url=http%3A%2F%2F'+itemurl+'" title="Bookmark with BlogMarks">BlogMarks</a></div>',
    '<div id="Tailrank" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/tailrank.com/share/?link_href=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Tailrank">Tailrank</a></div>',
    //'<div id="Firefox_Opera_Safari_Internet_Explorer_Konqueror_Flock_Mozilla_Camino_Netscape" class="addtodiv"><a  style="color: black; font-size: 11px;" class="addto" href="javascript:bookmarkIt(\''+title+'\',\''+itemurl+'\')" title="Bookmark with your browser">My Browser</a></div>',
    '<div id="Windows_Live_Favorites" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/favorites.live.com/quickadd.aspx?url=http%3A\/\/'+itemurl+'&title=" title="Bookmark with Windows Live Favorites"><img width="106" height="17" border="0" src="http:\/\/shared.live.com/idYiNi0777CC-rhpYaj-HHSWi6kD2l2ATUPXIQ89GY9dmNXZasCQJowvlpjSsu4N/base/3200/Gallery/img/addlive.gif" alt="Windows Live Favorites"/></a></div>',
    '<div id="StumbleUpon" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.stumbleupon.com/submit?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with StumbleUpon"><img width="91" height="17" border="0" src="http:\/\/www.stumbleupon.com/images/su_micro.gif" alt="StumbleUpon"/></a></div>',
    '<div id="Protopage_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.protopage.com/add-button-site?url=http%3A%2F%2F'+itemurl+'&label=&type=page" title="Bookmark with Protopage Bookmarks"><img width="91" height="17" border="0" src="http:\/\/www.protopage.com/web/images/buttons/add-site-to-protopage.gif" alt="Protopage Bookmarks"/></a></div>',
    //'<div id="Shadows" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.shadows.com/features/tcr.htm?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Shadows"><img width="32" height="32" border="0" src="http:\/\/www.shadows.com/Features/images/bling/shadowme1_80x15.gif" alt="Shadows"/></a></div>',
    '<div id="Blinklist" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.blinklist.com/index.php?Action=Blink/addblink.php&Url=http%3A%2F%2F'+itemurl+'&Title=" title="Bookmark with Blinklist"><img width="80" height="18" border="0" src="http:\/\/www.blinklist.com/Theme/Graphic/Blink_Small_Button.gif" alt="Blinklist"/></a></div>',
    '<div id="YiGG" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/yigg.de/neu?exturl=http%3A%2F%2F'+itemurl+'&exttitle=" title="Bookmark with YiGG"><img width="80" height="15" border="0" src="http:\/\/www.yigg.de/images/yiggit-2.png" alt="YiGG"/></a></div>',
    '<div id="Segnalo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/segnalo.alice.it/post.html.php?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Segnalo"><img width="139" height="25" border="0" src="http:\/\/segnalo.alice.it/images/postasusegnalo.png" alt="Segnalo"/></a></div>',
    '<div id="YouMob" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/youmob.com/mob.aspx?mob=http%3A%2F%2F'+itemurl+'" title="Bookmark with YouMob"><img width="52" height="30" border="0" src="http:\/\/youmob.com/GetBeacon.axd?style=4&mob=http%3A%2F%2F'+itemurl+'" alt="YouMob"/></a></div>',
    '<div id="Slashdot" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/slashdot.org/bookmark.pl?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Slashdot">Slashdot</a></div>',
    '<div id="RawSugar" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.rawsugar.com/pages/tagger.faces?turl=http%3A%2F%2F'+itemurl+'&tttl=" title="Bookmark with RawSugar">RawSugar</a></div>',
    '<div id="Scuttle" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/scuttle.org/login/?action=add&address=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Scuttle">Scuttle</a></div>',
    '<div id="Smarking" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/smarking.com/editbookmark/?url=http%3A%2F%2F'+itemurl+'&description=" title="Bookmark with Smarking">Smarking</a></div>',
    '<div id="Jookster" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.jookster.com/JookThis.aspx?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Jookster">Jookster</a></div>',
    '<div id="Feedmarker_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.feedmarker.com/admin.php?do=bookmarklet_mark&url=http%3A%2F%2F'+itemurl+'&title=http%3A%2F%2F'+itemurl+'" title="Bookmark with Feedmarker Bookmarks">Feedmarker Bookmarks</a></div>',
    '<div id="OnlyWire" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.onlywire.com/b/?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with OnlyWire">OnlyWire</a></div>',
    '<div id="unalog" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/unalog.com/my/stack/link?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with unalog">unalog</a></div>',
    '<div id="Squidoo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.squidoo.com/lensmaster/bookmark?http%3A%2F%2F'+itemurl+'" title="Bookmark with Squidoo">Squidoo</a></div>',
    '<div id="Google_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.'+itemurl+'/bookmarks/mark?op=edit&bkmk=http%3A%2F%2F'+itemurl+'" title="Bookmark with Google Bookmarks"><img width="104" height="17" border="0" src="http:\/\/buttons.googlesyndication.com/fusion/add.gif" alt="Google Bookmarks"/></a></div>',
    '<div id="Thoof" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/thoof.com/submit?link=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Thoof"><img width="60" height="15" border="0" src="http:\/\/thoof.com/images/thoofit.gif" alt="Thoof"/></a></div>',
    '<div id="Spurl" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.spurl.net/spurl.php?title=&url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Spurl"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/spurl.png" alt="Spurl"/></a></div>',
    '<div id="Yample" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/yample.com/submit.php?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Yample"><img width="100" height="20" border="0" src="http:\/\/yample.com/100x20-yample-button.png" alt="Yample"/></a></div>',
    '<div id="Oneview" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.oneview.de:80/quickadd/neu/addBookmark.jsf?URL=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Oneview"><img width="74" height="17" border="0" src="http:\/\/www.oneview.de/img/book_buttons/ov_bm_020.gif" alt="Oneview"/></a></div>',
    '<div id="Linkatopia" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/linkatopia.com/add?uri=http%3A%2F%2F'+itemurl+',title=" title="Bookmark with Linkatopia"><img width="80" height="15" border="0" src="http:\/\/linkatopia.com/images/linkabutton80.gif" alt="Linkatopia"/></a></div>',
    '<div id="Simpy" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2F'+itemurl+'&title=&v=6" title="Bookmark with Simpy"><img width="80" height="15" border="0" src="http:\/\/www.simpy.com/img/chicklet-simpy-orange.png" alt="Simpy"/></a></div>',
    '<div id="BuddyMarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/buddymarks.com/add_bookmark.php?bookmark_url=http%3A%2F%2F'+itemurl+'&bookmark_title=" title="Bookmark with BuddyMarks"><img width="95" height="21" border="0" src="http:\/\/buddymarks.com/images/bmpromolink.gif" alt="BuddyMarks"/></a></div>',
    '<div id="Small_Things" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/smallthings.kilobox.mobi/login.php/?action=add&address=http%3A%2F%2F'+itemurl+'" title="Bookmark with Small Things"><img width="80" height="15" border="0" src="http:\/\/smallthings.kilobox.mobi/small-things.gif" alt="Small Things"/></a></div>',
    '<div id="Ask.com_MyStuff" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/mystuff.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Ask.com MyStuff">Ask.com MyStuff</a></div>',
    '<div id="Maple" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.maple.nu/bookmarks/bookmarklet?bookmark[url]=http%3A%2F%2F'+itemurl+'&bookmark[description]=" title="Bookmark with Maple">Maple</a></div>',
    '<div id="Wists" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/wists.com/r.php?r=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Wists">Wists</a></div>',
    '<div id="Kinja" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/kinja.com/id.knj?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Kinja">Kinja</a></div>',
    '<div id="Gravee" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.gravee.com/account/bookmarkpop?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with Gravee">Gravee</a></div>',
    '<div id="Connotea" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.connotea.org/add?uri=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Connotea">Connotea</a></div>',
    '<div id="Backflip" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.backflip.com/add_page_pop.ihtml?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Backflip">Backflip</a></div>',
    '<div id="MyLinkVault" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mylinkvault.com/link-page.php?u=http%3A%2F%2F'+itemurl+'&n=" title="Bookmark with MyLinkVault">MyLinkVault</a></div>',
    '<div id="SiteJot" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.sitejot.com/addform.php?iSiteAdd=http%3A%2F%2F'+itemurl+'&iSiteDes=" title="Bookmark with SiteJot">SiteJot</a></div>',
    '<div id="Digg" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/digg.com/submit?phase=2&url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Digg"><img width="100" height="20" border="0" src="http:\/\/digg.com/img/badges/100x20-digg-button.gif" alt="Digg"/></a></div>',
    '<div id="Mixx" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mixx.com/submit?page_url=http%3A%2F%2F'+itemurl+'" title="Add to Mixx"><img width="102" height="17" border="0" src="http:\/\/www.mixx.com/images/buttons/mixx-button1.png" alt="Mixx"/></a></div>',
    '<div id="Sphere" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.sphere.com/search?q=sphereit:http%3A%2F%2F'+itemurl+'" title="Add to Sphere"><img width="80" height="25" border="0" src="http:\/\/www.sphere.com/images/sphereit_button.png" alt="Sphere"/></a></div>',
    '<div id="Bitty_Browser" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.bitty.com/manual/?contenttype=website&contentvalue=http%3A%2F%2F'+itemurl+'" title="Add to Bitty Browser"><img width="91" height="17" border="0" src="http:\/\/www.bitty.com/img/bittychicklet_91x17.gif" alt="Bitty Browser"/></a></div>',
    '<div id="dzone" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.dzone.com/links/add.html?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to dzone"><img width="44" height="13" border="0" src="http:\/\/widgets.dzone.com/links/images/std/vwidget3/vwidget_logo.gif" alt="dzone"/></a></div>',
    '<div id="Diigo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.diigo.com/post?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Diigo"><img width="86" height="17" border="0" src="http:\/\/www.diigo.com/images/difb_big.gif" alt="Diigo"/></a></div>',
    '<div id="Design_Float" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.designfloat.com/submit.php?url=http%3A%2F%2F'+itemurl+'" title="Add to Design Float"><img width="54" height="17" border="0" src="http:\/\/www.designfloat.com/templates/green/images/df_button.gif" alt="Design Float"/></a></div>',
    '<div id="diglog" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.diglog.com/submit?act=like&returnurl=true&title=&url=http%3A%2F%2F'+itemurl+'" title="Add to diglog"><img width="80" height="15" border="0" src="http:\/\/www.diglog.com/images/diglog_80x15_4.gif" alt="diglog"/></a></div>',
    '<div id="Technotizie" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.technotizie.it/posta_ok?action=f2&title=&url=http%3A%2F%2F'+itemurl+'" title="Add to Technotizie"><img width="117" height="24" border="0" src="http:\/\/www.technotizie.it/images/technotiziesubmit3.png" alt="Technotizie"/></a></div>',
    '<div id="Reddit" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/reddit.com/submit?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Reddit">Reddit</a></div>',
    '<div id="NewsVine" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.newsvine.com/_tools/seed&save?u=http%3A%2F%2F'+itemurl+'&h=" title="Add to NewsVine">NewsVine</a></div>',
    '<div id="NowPublic" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/view.nowpublic.com/?src=http%3A%2F%2F'+itemurl+'&t=" title="Add to NowPublic">NowPublic</a></div>',
    '<div id="Hugg" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.hugg.com/submit?url=http%3A%2F%2F'+itemurl+'" title="Add to Hugg">Hugg</a></div>',
    '<div id="Care2_News" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.care2.com/news/news_post.html?url=http%3A%2F%2F'+itemurl+'&title=&v=1.3" title="Add to Care2 News">Care2 News</a></div>',
    '<div id="Netscape.com" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.netscape.com/submit/?U=http%3A%2F%2F'+itemurl+'&T=" title="Add to Netscape.com">Netscape.com</a></div>',
    '<div id="LiveJournal" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.livejournal.com/update.bml?subject=" title="Add to LiveJournal">LiveJournal</a></div>',
    '<div id="Feedo_Style" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.feedostyle.com/create_digest.aspx?feed=http%3A%2F%2F'+itemurl+'" title="Add to Feedo Style">Feedo Style</a></div>',
  ];
  var alldivs = "";
  bookmarks.sort().each(function(b){
    alldivs += b;
  });
  container.innerHTML = top+alldivs
  return container;
}

function cleanUrl(url){ 
  var nuurl = url.split('http:\/\/'); 
  return nuurl[1];
} 


;

// /8::/202::/frontend:js -> <857> guideswindow.js 

//old?_delete *mike
 
function initGuide(o){
o = Object.extend({
             model:null,
             controllerName:"guides@core",
             user:"mike",
             path:"/"},arguments[0]);
if(gwin != null){
gwin.destroy();  
}
var gwin = new Window({
    destroyOnClose:true,
    width:760,
    height:400,
     //title:'<div onclick="gwin.close();">Close</div>',
    zindex:9999,    
    minimizable:false,
    maximizable:false,
    showEffect:Element.show,
    hideEffect:Element.hide,
    className: "tooltip",
    onClose:function(){
         endIdle();
    },
    onMove:function(){
    },
    onShow:function(){

    }
});

var help = Builder.node('div',{style:"overflow:auto;width:100%;height:100%;"},[new HelpWidget(o).htmlNode()]);
gwin.setContent(help, true, true); 
gwin.setSize(760, 400);
gwin.setZIndex(9999);
gwin.showCenter();
 }

///////
HelpWidget = Class.create();
var dcw;
HelpWidget.prototype =
{
    defaultOptions: function()
    {
        return Object.extend({
             model:null,
             controllerName:"guides@core",
             user:"mike",
             path:"/"},arguments[0]);
    },
    setup:function(){
        serviceName = itemModel.serviceName();
        bits = serviceName.split("@");
        this.service = serviceName; 
        this.user = bits[1];
        this.options.model = new DisplayModel({controllerName:this.options.controllerName,user:this.user,path:bits[0]});
        this.options.model.setSortByColumn('name');
        this.options.model.addObserver(this);
    }, 
    update:function(){
        this.rerender();
    },
    makeWidgetContent: function(){
        dcw = this;  
        var allcomm = this.processEntriesArray(this.options.model.displayItems());
        var theindexlist = Builder.node('div',{style:"font-size:12px;text-align:center;color:black;"},[this.makeIndexList({style:"width:500px,font-size:12px;"})]); 
        var head =  Builder.node('div',{className:"article-header"},[table([Builder.node('img',{src:"http:\/\/mike.myservic.es/get_file?id=2442"}),TN("MyGuid.es: "),{columnOptions:{width:"80%"},columnData:[TN(this.options.model.currentPath())]}])])         
        return Builder.node('div',{style: "width:700px;padding:20px;z-index:9999"}, [/*prehead,*/head,theindexlist,Builder.node('div',{id:"writeCommentBox"}, []), BR(), allcomm]);
    }, 
    getEntries: function(){
        var xx = this.options.model.displayItems();
        return xx;
    },
    processEntriesArray: function(arr){
        var allcomm = [];
        var xx = arr;
        for(var ii =0;ii<xx.length;ii++){
            allcomm.push(this.makeEntryRow(xx[ii],ii));
        }
        if(xx.length == 0){
            allcomm.push(TN("No guide entries yet!"))
        }
        return allcomm;
    },
    makeEntryRow: function(c,i){
        var theDate = new Date(c.added_at);
        dateString = makeNiceDate(c.added_at);
        if (!c.body){
            c.body = "";
        }

        if(this.options.model.canWrite()){
               var control = Builder.node('span',[this.options.model.actions.actionsForItem({m: c})]);
        }else{ var control = NBSP();};               

        var body = c.body;
        var bodydiv = Builder.node('div',[]);
        bodydiv.innerHTML = this.processImages(body);
        var bodydivwrapper = Builder.node('div',[bodydiv]);
        var theanchor = Builder.node('a',{name:c.name.substr(0,1)},[]);
        var headdiv = Builder.node('div',[Builder.node('div',{style:"font-size:26px;font-weight:bold;"},[theanchor,TN(c.name),control])]);
        return Builder.node('div',{className:""},[headdiv,bodydivwrapper,BR()/*BR(),footdiv*/]);
    },
    makeIndexList:function(o){
        var alphabet = [
        "A","B","C","D","E","F","G","H","I","J","K","L","M",
        "N","O","P","Q","R","S","T","U","V","W","X","Y","Z" 
        ];
        var indexList = [];
        alphabet.each(function(letter){
            indexList.push(Builder.node('a',{style:"color:black;",href:"#"+letter},[TN(letter)])); 
        });
        var alphatable = [
            {columnOptions:{width:"20%"},columnData:[NBSP()]},
            {columnOptions:{width:"60%"},columnData:[table(o,indexList)]},
            {columnOptions:{width:"20%"},columnData:[NBSP()]}
        ];
        return table({width:"100%"},alphatable);   
    },
    rerender: function(){
        var nc = this.makeWidgetContent();
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    },
    processImages: function(html) {
    // ^some html {[Image:/foo.jpg]} some html$
    return html.gsub(/\{\[Image:([^\]}\n]+)\]\}/, function(m) { 
      var path = m[1]
      return "<img class='blogImage' src='" + 
          serviceLink({
            service: "pictures", 
            action: "get_file?path=" + path,
            noCrossSiteLink: true
          }) + 
          "'></img>"
    })
   } 
}
Object.extend(HelpWidget.prototype, WidgetCommon);

;

// /8::/202::/frontend:js -> <13787> help-texts.js 

// remove file!
;

// /8::/202::/frontend:js -> <859> iconloaderwidget.js 

//old?_delete *mike
 
 iconLoaderWidget = Class.create();
iconLoaderWidget.prototype = {
    defaultOptions: function() {
        return {smileys:[],target:null};
    },
    setup:function(){
        smileyModel = new DisplayModel({controllerName:"icons@mike",user:"mike"});
        smileyModel.addObserver(this);
    },
    makeWidgetContent: function() {
        instance = this;
        return Builder.node('div',{style:"width:200px;"},[this.generateSmileyList(this.options.smileys)]);
    },
    generateSmileyList:function(items){
        var smileynodes = [];
        items.each(function(i){
             var smiley = Builder.node('div',{style:"float:left;"},[Builder.node('img',{src:i.full_item_url})])
             smiley.onclick = function(){
                  ptt.hideTotally();
                  instance.options.target.innerHTML = this.innerHTML;  
             } 
             smileynodes.push(smiley);
        });
        return smileynodes;
    },
    update:function(){        
        this.rerender();
    }, 
    rerender: function(){
        this.options.smileys = smileyModel.displayItems();
        var nc = this.makeWidgetContent(this.options.smileys);
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    }
}
Object.extend(iconLoaderWidget.prototype, WidgetCommon);

;

// /8::/202::/frontend:js -> <90139> itemrowwidget.js 

var __itemRowWidgetTemplate = null;

itemRowWidget = Class.create();
itemRowWidget.prototype = {
  defaultOptions: function() {
    return {
      m:null,
      model:null,
      width:"100%"
    }
  },
  setup: function() {
    if (!__itemRowWidgetTemplate) {
      __itemRowWidgetTemplate = this.makeWidgetContentTemplate()
    }
  },
  makeWidgetContentTemplate: function() {
    var t = Builder.node('table',{
      cellpadding:0,
      cellspacing:0,
      width:this.options.width
    });
    var tbody = Builder.node('tbody');
    var tr1 = Builder.node('tr',{width:"100%"});
    var tr2 = Builder.node('tr',{width:"100%"});
    var tr3 = Builder.node('tr',{width:"100%"}); 
    var td11 = Builder.node('td',{className:"smlTL",width:10},[
      Builder.node('div',{style:"width:10px;height:7px;"})
    ]);
    var td12 = Builder.node('td',{className:"smlTF",width:"100%"},[
      Builder.node('div')
    ]);
    var td13 = Builder.node('td',{className:"smlTR",width:10},[
      Builder.node('div',{style:"width:10px;height:7px;"})
    ]);
    var l1 = serviceLink({
      user: "core",
      service: "files@core",
      action:"get_file?path=/blue-1.png"
    })
    var votebox = Builder.node('div',{
      style:"text-align:center;color:white;width:75px;height:60px;" +
            "background: url("+l1+");"
    },[
      Builder.node('div',{
        style:"font-size:25px;text-decoration:underline;font-weight:bolder;" +
              "padding-top:10px;"
      },[TN("template:value_of votes")]),
      Builder.node('div',{
        style:"font-weight:bolder;font-size:13px;text-decoration:none;" +
              "height:14px;line-height:14px;"
      },[TN("votes")])
    ]);    
    var l2 = serviceLink({
      user: "core",
      service: "files@core",
      action:"get_file?path=/icomment.png"
    })
    var comm = Builder.node('div',{
      style:"width:250px;float:right;color:#5EB4E1;font-size:120%;text-align_right;"
    },[
      Builder.node('div',{style:"float:left;"},[
        Builder.node('img',{style:"float:left;",src:l2})
      ]),
      Builder.node('div',{style:"float:left;"},[
        table({width: ""}, [
          Builder.node('div', {id: "template:reference_as comments"})
        ])
      ])
    ]);
    var rating = Builder.node('div',{
      style:"margin-top:8px;",
      id: "template:reference_as voteWidget"
    });
    var votewrap = Builder.node('div',[votebox,rating]);
    var innert2 = Builder.node("table",{
      width:"100%",height:"100%",cellpadding:0,cellspacing:5
    });
    var tb3 = Builder.node('tbody');
    var itd31 = Builder.node('td',{colspan:3},[
      Builder.node('div',{style:"height:30px;"},[TN("template:value_of desc")])
    ]);
    var itd32 = Builder.node('td',{width:250},[
      Builder.node('div',{style:"width:250px;overflow:hidden;"},[
        Builder.node('a',{
          href: "template:value_of item_url",
          id: "template:reference_as item_name",
          style:"border:0px solid black;color:#5EB4E1;font-size:24px;" +
                "text-decoration:underline;white-space:nowrap;"
        },[TN("template:value_of name")])
      ])
    ]);
    var itdby = Builder.node('td',{width:120},[
      Builder.node('div',{style:"white-space:nowrap;color:#666666;overflow:hidden;"},[
        TN("-added by"),NBSP(),
        Builder.node('span', {id: "template:reference_as activeUserName"}),
        BR(), Builder.node('span', {id: "template:reference_as niceDate"})
      ])
    ]);
    var itd33 = Builder.node('td',{colspan:2,width:250},[
      Builder.node('span',{
        style:"font-weight:bolder;font-style:italic;color:#666666;"
      },[TN("tags: "), Builder.node('span', {id: "template:reference_as tags"})])
    ]);
    var itd34 = Builder.node('td',{width:250},[
      Builder.node('span',{style:"width:100%;text-align:right;"},[comm])
    ]);
    var path = Builder.node('div',{
      style:"white-space:nowrap;width:220px;overflow:hidden;font-weight:bolder;"
    },[
      TN("added in "),
      Builder.node('a',{
        style:"color:#5EB4E1;font-style:italic;",
        href: "template:value_of folder_url"
      },[
        TN("template:value_of folder")
      ])
    ]);
    var itdpath = Builder.node('td',[path]); 
    var itr2 = Builder.node('tr',[itd32,itdby,itdpath]);
    var itr1 = Builder.node('tr',[itd31]);
    tb3.appendChild(itr2);
    var itr3 = Builder.node('tr',[itd33,itd34]);
    appendChildren(tb3,[itr2,itr1,itr3]);
    innert2.appendChild(tb3);
    var innert = Builder.node("table",{width:"100%",cellpadding:0,cellspacing:5});
    var tb2 = Builder.node('tbody');
    var itr = Builder.node('tr');
    innert.appendChild(tb2);
    tb2.appendChild(itr);
    var icon = Builder.node('img', {
      border:0,
      style:"text-align:center;margin-top:15px;",
      width:"97%",
      height:"70%",
      src: "template:value_of thumbnail_image_url"
    })
    var l3 = serviceLink({
      user: "core",
      service: "files@core",
      action:"get_file?path=/ifav.png"
    })
    var actionwrap = Builder.node('div',{style:"text-align:right;"},[
      Builder.node('div',{
        style:"margin-bottom:10px;width:53px;height:48px;background: url("+l3+");"
      }),
      Builder.node('div', {
        id: "template:reference_as shareWidget"
      })
    ]);
    var itd1 = Builder.node('td',{width:90},[votewrap]);
    var thumb = Builder.node('a',{
      href: "template:value_of item_url",
      style:"border:0px solid black;"
    },[icon]);
    var itd2 = Builder.node('td',{width:110,valign:"top"},[
      Builder.node('div',{
        style:"overflow:hidden;width:100px;height:100px;border:1px solid silver;" +
              "padding:1px;"
      },[thumb])
    ]);
    var itd3 = Builder.node('td',{width:"70%",className:"smlinnerT",valign:"top"},[
      Builder.node('div',{style:"width:100%;height:100%;"},[innert2])
    ]);
    var itd4 = Builder.node('td',{width:53},[actionwrap]);
    appendChildren(itr,[itd1,itd2,itd3,itd4]);  
    var td21 = Builder.node('td',{className:"smlML",width:10},[
      Builder.node('div',{style:"width:10px;"})
    ]);
    var td22 = Builder.node('td',{className:"smlMF",valign:"top"},[
      Builder.node('div',{
        style:"width:100%;",
        className:"smlContent"
      },[innert])
    ])
    var td23 = Builder.node('td',{className:"smlMR",width:10},[
      Builder.node('div',{style:"width:10px;"})
    ]);
    var td31 = Builder.node('td',{className:"smlBL",width:10},[
      Builder.node('div',{style:"width:10px;height:14px;"})
    ]);
    var td32 = Builder.node('td',{className:"smlBF",width:"100%"});
    var td33 = Builder.node('td',{className:"smlBR",width:10},[
      Builder.node('div',{style:"width:13px;height:14px;"})
    ]);
    appendChildren(tr1,[td11,td12,td13]);
    appendChildren(tr2,[td21,td22,td23]);
    appendChildren(tr3,[td31,td32,td33]);
    appendChildren(tbody,[tr1,tr2,tr3]);
    t.appendChild(tbody);
    var thediv = Builder.node('div',{
      style:"font-family:arial;font-face:arial;width:"+this.options.width+";height:auto;"
    },[t]);
    return new MSTemplate({create: function() { return thediv;}})
  },
  makeWidgetContent: function() {
    return this.contentFromTemplate(this.options.model, this.options.m)
  },
  contentFromTemplate: function(model, m) {
    var voteWidget = makeVoteWidget(model, m)
    var v = voteWidget.votesFromRating()
    if (m.description){
      var desc = m.description
    }
    else if (m.body) {
      var desc = m.body.stripTags().truncate(50)
    }
    else {
      var desc = "no description"
    }
    $A(["thumbnail_image_url", "full_item_url"]).each(function(f) {
      if (!m[f]) return;
      var tiu = localizeURL(m[f])
      if (m.service && tiu.match(/^http/)) {
        if (__no_dns || tiu.match(/^http:\/\/[^/]+\/[^/]+@[^/]+/)) {
          tiu = tiu.gsub(/[^/]+@[^/]+/, m.service)
        }
        else {
          tiu = tiu.gsub(/^(http:\/\/[^/]+)\//, "#{1}/"+m.service+"/")
        }
      }
      m[f] = tiu
    })
    var opts = {
      votes: v.up - v.down,
      desc: desc,
      name: m.name,
      item_url: model.currentPathPermalink(m),
      folder: model.currentPath(m),
      folder_url: model.currentPathPermalink(m).gsub(/[^/]+$/, ""),
      thumbnail_image_url: m.thumbnail_image_url
    }
    var nr = __itemRowWidgetTemplate.makeNodeAndReferences(opts)
    nr.references.comments.appendChild(new CommentsWidget({
      model: model, m: m
    }).htmlNode())
    nr.references.voteWidget.appendChild(voteWidget.htmlNode())
    nr.references.activeUserName.appendChild(this.activeUserName(model, m))
    nr.references.niceDate.appendChild(makeNiceDate(m.added_at))
    nr.references.tags.appendChild(this.getTags(m.tags))
    var l4 = serviceLink({
      user: "core",
      service: "files@core",
      action:"get_file?path=/ishare.png"
    })
    nr.references.shareWidget.appendChild(new shareWidget({
      model: model,
      item: m,
      node:Builder.node('div',{
        style:"cursor:pointer;width:53px;height:48px;background: url("+l4+");"
      })
    }).htmlNode())
    Event.observe(nr.references.item_name, 'click', function(event) {
      model.actions.showItem({m: m})
      // Only stop the event if the item can be opened in a window
      Event.stop(event)
    }.bindAsEventListener(this))
    return nr.node
  },
  rerender: function(){
    this.redrawCompletely()
  },
  getTags:function(tags){ 
    var str = tags;
    var ta = [];
    if(str != undefined && str != ""){
      var t = str.split(', ');
      t.each(function(t){
        var elt = Builder.node('a',{
            style:"text-decoration:none;color:#5EB4E1;",
            href:"#"
        },[TN(t)]);
        Event.observe($(elt),'click',function(e){
          alert("this does something really nice..you will see soon")
        });
        ta.push(elt);
        ta.push(TN(", ")); 
      });
      ta.pop();
    }
    return Builder.node('span',{},ta);
  },
  activeUserName: function(model, m) {
    var user = Builder.node('a', {
      style: "color:#666666;text-decoration:none;",
      href: "javascript:void(0)"
    }, [
      TN(model.user(m.pretty_name).capitalize())
    ])
    Event.observe(user, 'click', function(event) {
      Event.stop(event)
      var csw = new changeSiteWidget({
        profile: new ProfileDisplayModel({
          data: model.users()[m.account_id]
        }),
        text: ""
      })
      csw.onclick()
    }.bindAsEventListener(this))
    return user
  }
}
Object.extend(itemRowWidget.prototype, WidgetCommon);   

var __ratingTemplates = null;
VoteWidget = Class.create();
VoteWidget.prototype = {
  defaultOptions: function() {
    return {
      description: null,
      onchange: function(rating) {},
      m: null
    }
  },
  setup: function() {
    this.options.model.addObserver(this)
  },
  voteUp: function(num) {
    var l5 = serviceLink({
      user: "core",
      service: "files@core",
      action:"get_file?path=/iplus.png"
    })
    return this.vote({img: l5, rating: 5, num: num})
  },
  voteDown: function(num) {
    var l6 = serviceLink({
      user: "core",
      service: "files@core",
      action:"get_file?path=/iminus.png"
    })
    return this.vote({img: l6, rating: 1, num: num})
  },
  vote: function(o) {
    var nt = logged_in ? 'a' : 'span'
    var div = Builder.node(nt, {
      style: "color:black;",
      href: "javascript:void(0)"
    }, [table({width: ""}, [
      Builder.node('img', {
        src: o.img,
        style: "border: 0px;",
        title: this.you()
      })
    ])])
    if (logged_in) {
      Event.observe(div, 'click', function(event) {
        Event.stop(event)
        this.onchange(o.rating)
      }.bindAsEventListener(this))      
    }
    return div
  },
  you: function() {
    if (!logged_in) {
      return "Login to vote!"
    }
    else if (this.options.m.voted) {
      return "You voted!"
    }
    else if (this.options.m.voted == undefined) {
      // Doesn't exist for recent and top rated
      return ""
    }
    else {
      return "You didn't vote, yet!"
    }
  },
  makeWidgetContent: function() {
    var votes = this.votesFromRating()
    var div = Builder.node('div', [table({width:"", cellspacing: 0}, [
      this.voteUp(votes.up),NBSP(),
      this.voteDown(votes.down)
    ])])
    if(!logged_in){
      $(div).setOpacity(0.2);
    }
    return div
  },
  rerender: function() {
    this.redrawCompletely()
  },
  votesFromRating: function() {
    var m = this.options.m
    var up = Math.floor(((m.rating*m.nr_votes) - m.nr_votes)/4)
    return {
      up: up,
      down: m.nr_votes - up
    }
  },
  onchange: function(rating) {
    var m = this.options.m
    var model = this.options.model
    if (m.item_path) {
      var form_path = m.item_path.gsub(/\/[^/]*$/, "")
    }
    else {
      var form_path = model.currentPath()        
    }
    if (form_path == "") form_path = "/"
    var user = model.user(m.pretty_name)
    if (!model.queryDataAction) user = model.user()
    var dict = {
      form_name: m.pretty_name, 
      form_path: form_path, 
      form_rating: rating,
      form_username_override: user
    }
    if (logged_in) {
      AjaxRequestMixin.ajaxRequest({
        service: m.service || model.service(),
        user: user,
        action: "vote",
        onSuccess: function(success) {
          m = hash_merge(m, success)
          model.update();
        }
      }, dict)        
    }
    else {
      verify(
        function() {},
        "You need to be logged in to vote!",
        {cancelButton: false}
      )
    }
  }
}

Object.extend(VoteWidget.prototype, WidgetCommon)

function makeVoteWidget(model, m) {
  return new VoteWidget({m: m, model: model})
};

;

// /8::/202::/frontend:js -> <142094> languageflagswidget.js 

LanguageFlagsWidget = Class.create();
LanguageFlagsWidget.prototype = {
defaultOptions: function() {
    return {};
},
setup: function() {
    this.ar = [];
    this.supportedLanguages().each(function(l,c) {
        
        var imglnk = Builder.node('img',{src:this.supportedFlags()[c]}); 
        var flg = Builder.node('div',{id:l,style:"float:left;border:2px solid transparent;cursor:pointer;margin-left:3px;margin-top:3px;margin-right:3px;width:16px;height:11px;"},[imglnk]);
        Event.observe(flg,'click',function(e){
            var lang = flg.id.toLowerCase()
            setLanguage(lang);
            this.supportedLanguages().each(function(ll) {
                $(ll).setStyle({border:"2px solid transparent"})
            })

try{ //fix if node not aviable
            $(lang.capitalize()).setStyle({border:"2px solid #5EB1DC"})
}catch(e){

}
            if (logged_in) { 
                var prefs = this.dm.preferences()
                if (prefs.lang != lang) {
                    prefs.lang = lang
                    this.dm.setPreferences(prefs)          
                }
            }
        }.bindAsEventListener(this))
        this.ar.push(flg)
    }.bind(this))
    this.s = Builder.node('div', {}, this.ar)   

    if (logged_in) {
        this.dm = new DisplayModel({
            user: writeUserModel.data.username,
            service: "profiles"
         })
        this.dm.observeOnce({update: function() {
            var lang = this.dm.preferences().lang
            if (lang && this.supportedLanguages().include(lang.capitalize())) {
                this.setLanguage(lang)
            } else if (parameters().lang && this.supportedLanguages().include(parameters().lang.capitalize())) {
                this.setLanguage(parameters().lang)
                var prefs = this.dm.preferences()
                prefs.lang = parameters().lang
                this.dm.setPreferences(prefs)          
            }
        }.bind(this)})
    } else if (parameters().lang) {
        var l = parameters().lang
        if (this.supportedLanguages().include(l.capitalize())) {
            this.setLanguage(l)
        }
     }
    },
  setLanguage: function(lang) {
    setLanguage(lang)
    try{
         $(lang.capitalize()).setStyle({border:"2px solid #5EB1DC"})
;
    }catch(e){}
  },
  supportedLanguages: function() {
    return ["English", "German","Finnish"]
  },
  supportedFlags: function() {   
    return [
        serviceLink({service: "files@core",action: "get_file?path=/gb.png&username_override=core",noCrossSiteLink: true}), 
        serviceLink({service: "files@core",action: "get_file?path=/de.png&username_override=core",noCrossSiteLink: true}),
serviceLink({service: "files@core",action: "get_file?path=/fi.png&username_override=core",noCrossSiteLink: true}) 
    ]
  },
  makeWidgetContent: function() {
    return this.s
  }
}

Object.extend(LanguageFlagsWidget.prototype, WidgetCommon); 
  
;

// /8::/202::/frontend:js -> <2122> loadotherservice.js 

//old?_delete *mike
 
 
 function loadOtherService(model, idPrefix) {
  if (!idPrefix) idPrefix = "load-other-service"
  var cssId = idPrefix + "-css"
  var jsId  = idPrefix + "-js"
  var jsContent  = ""
  var cssContent = ""
  model.getModel().each(function(item) {
    if (item.name.match(/\.js$/)) {
      jsContent += "// " + item.name + "\n"
      jsContent += item.content + "\n"
    }
    else if (item.name.match(/\.css$/)) {
      cssContent += "/* " + item.name + " */\n"
      cssContent += item.content + "\n"
    }
  })
  // CSS
  var cssNode = $(cssId)
  if (cssNode) {
    Element.remove(cssNode)
  }
  cssNode = Builder.node('style',
    {type: 'text/css', id: cssId})
  $(document.documentElement).down('head').appendChild(cssNode)
  if (Prototype.Browser.IE) {
    // URLs like core.mythem.es/get_file?id=XXX don't work in IE so
    // we have to replace them by URLs on the same server.
    css = localizeURL(cssContent, "g")
    var ss = $A(document.styleSheets).find(function(s) { return s.id == cssId })
    ss.cssText = css
  }
  else {
    cssNode.innerHTML = cssContent    
  }
  // JS
  // BUG: Shouldn't be necessary
   jsContent = jsContent.replace(/&amp;/g, "&")
  var jsNode = $(jsId)
  if (jsNode) {
    Element.remove(jsNode)
  }
  jsNode = Builder.node('script',
    {type: 'text/javascript', id: jsId})
  document.body.appendChild(jsNode)
  if (Prototype.Browser.IE) {
    jsNode.text = jsContent;
  }
  else {
    jsNode.innerHTML = jsContent;    
  }
}
 
;

// /8::/202::/frontend:js -> <4668> mainpageoverride.js 

function initMainPage() {
  //commonHeader()
  setNewLeftbar();
  appendChildren($('main-content-placeholder'), [
    (new mainPageWidget().htmlNode())
  ])
  try{
    $("mysites-path").up().remove(); 
  }catch(e){}
}

function setNewLeftbar(){
  window.setTimeout(function(){
    var csw = new changeSiteWidget()
    var title = (logged_in ? "My" : "Favorite") + " Services:"
    var libo = (new BoxWidget({
      id: 'tBox',
      title: TN(title),
      node: Builder.node('div', {style: "font-size:120%;"}, [csw.setPanelContent()]),
      className:"mybox",
      width:"200"
    }).htmlNode());
    $("left-bar").appendChild(libo); 
    if(logged_in){
      $("actionNodeBox").remove();
    }  
    var fwb = $("folderWidgetBox")
    if (fwb) fwb.remove(); 
  },850);
  //cleanup leftbar 
  window.setTimeout(function(){
    try{
      $("ownerWidgetBox").remove();
      $("selectionWidgetBox").remove();
      $("tagsWidgetBox").remove();
      $("actionNodeBox").remove();
      $("folderWidgetBox").remove();
    }catch(e){}
  },760);
}

mainPageWidget = Class.create();
mainPageWidget.prototype = {
  defaultOptions: function() {
    return {}
  },
  makeTab: function(id, title, model) {
    return {
      id: id,
      title: title,
      widget: new BoxWidget({
        id: id+"-box",
        title: EMPTY(),
        node: Builder.node('div', {
          style: "padding:5px;"},[
          new DisplayBlogWidget({model: model}).htmlNode()
        ]),
        className: "mybox",
        draggable: false
      })      
    }
  },
  makeWidgetContent: function() {
    var updatesP = itemModel.service() == "updates@core"
    var rdm      = new RecentDisplayModel({any_item: updatesP})
    var trdm     = new TopRatedDisplayModel({any_item: updatesP})
    var theTabs = [this.makeTab(
      "recent-items",
      translateText({path: "", id: "whats-new"}),
      rdm
    ),this.makeTab(
      "toprated-items",
      translateText({path: "", id: "whats-hot"}),
      trdm
    )]
    var head = (new TabsWidget({name: "s", tabs: theTabs})).htmlNode();
    return head
  }
}
Object.extend(mainPageWidget.prototype, WidgetCommon); 

;

// /8::/202::/frontend:js -> <42851> messageswidget.js 

MessagesWidget = Class.create()
MessagesWidget.prototype = {
  defaultOptions: function() {
    return {
      model: itemModel,
      lb:    "left-bar"
    }
  },
  setup: function() {
    var m = this.options.model
    if (m.findItemByName("inbox")) {
      m.observeOnce({afterPathChanged: function() {
        this.afterInboxSetup()
      }.bind(this)})
      m.changeToFolder("/inbox")
    }
    else {
      var f = m.addFolder()
      f.name = "inbox"
      f.permission = "everyonesticky"
      m.storeItem(f, {afterStore: function() {
        m.observeOnce({afterPathChanged: function() {
          this.afterInboxSetup()
        }.bind(this)})
        m.changeToFolder("/inbox")
      }.bind(this)})
    }
  },
  afterInboxSetup: function() {
    var m = this.options.model
    var lw = m.findItemByName("last_viewed")
    if (lw) {
      lw.mod = new Date()
      m.storeItem(lw)
    }
    else {
      m.createItem({name: "last_viewed", mod: new Date()})
    }
    if (m.options.sortByColumn != "added_at" || m.reverse()) {
      m.setSortByColumn("added_at")
      if (m.reverse()) {
        m.setSortByColumn("added_at")
      }
    }
    m.addObserver(this)
    this.sentModel = new DisplayModel({
      sortByColumn: "added_at",
      reverse: false,
      service: this.options.model.service(),
      user: this.options.model.user()
    })
    this.sentModel.observeOnce({update: function() {
      var gts = function() {
        this.sentModel.observeOnce({afterPathChanged: function() {
          this._sentModelAvailable = true
          this.update()
          this.sentModel.addObserver(this)
        }.bind(this)})
        this.sentModel.changeToFolder("/sent")
      }.bind(this)
      if (!this.sentModel.findItemByName("sent")) {
        var f = this.sentModel.addFolder()
        f.name = "sent"
        this.sentModel.storeItem(f, {afterStore: function() { gts() }})
      }
      else {
        gts()
      }
    }.bind(this)})
  },
  writeNewMessage: function(event) {
    openMessageWindow(event)
  },
  usernameForMessage: function(msg) {
    if (msg.name == "Welcome Message") {
      var user = "team"
    }
    else {
      var user = msg.sent_to || this.options.model.users()[msg.account_id].username
    }
    return user
  },
  getConversations: function() {
    if (!this._sentModelAvailable) return []
    var messages = this.options.model.getModel().select(function(m) {
      return m.name != "last_viewed"
    })
    messages = messages.concat(this.sentModel.getModel())
    messages.sort(function(a,b) { return a.added_at - b.added_at })
    var conversations = $MSH({})
    messages.each(function(msg) {
      var user = this.usernameForMessage(msg)
      if (conversations[user]) {
        conversations[user].push(msg)
      }
      else {
        conversations[user] = [msg]
      }
    }.bind(this))
    var sortedConversations = conversations.map(function(pair) {
      return {
        user: pair.key,
        date: pair.value[pair.value.length-1].added_at,
        msgs: pair.value
      }
    })
    sortedConversations.sort(function(a,b) { return b.date - a.date })
    return sortedConversations
  },
  makeWidgetContent: function() {
    if (this.options.model.canWrite()) {
      if (!this.boxesDrawn && $(this.options.lb)) {
        var lb = $(this.options.lb)
        lb.appendChild(this.actionsBox())
        this.boxesDrawn = true
      }
      this.conversations = this.getConversations()
      if (this.conversations.length == 0) {
        var spinner = Builder.node('div', {
          style: "width: 90%;text-align:center;margin-top:20%;"
        }, [Builder.node('img', {
          src: localizeURL(
            "http://core.myservic.es/get_file?path=/messages/ajax-loader.gif"
          )
        })])
        return this._sentModelAvailable ? this.noMessages() : spinner
      }
      else {
        return this.showConversations(this.conversations)
      }      
    }
    else {
      return Builder.node('div', {
        style: "width:100%;font-size:50px;font-weight:bolder;" +
               "font-variant:small-caps;text-align:center;margin-top:100px;"
      }, [translateText({path: ".messages-widget", id: "private"})])
    }
  },
  noMessages: function() {
    return Builder.node('div', {
      style: "width:100%;font-size:50px;font-weight:bolder;" +
             "font-variant:small-caps;text-align:center;margin-top:100px;"
    }, [translateText({path: ".messages-widget", id: "no-messages"})])
  },
  drawSingleConversation: function(c) {
    var messageNode = c.msgs[c.msgs.length-1]
    var message = messageNode.message.stripTags().truncate(100)
    var delete_button = Builder.node('img', {
      style: "cursor:pointer;border:0px;",
      src: "/images/icons/mycons/24x24/delete.png"
    })
    Event.observe(delete_button, 'click', function(event) {
      if (event) Event.stop(event)
      verify(function() {
        this.deleteConversation(c)
      }.bind(this), translateText({path: ".messages-widget", id: "delete-conversation"}))
    }.bindAsEventListener(this))
    var tr = Builder.node('tr', [
      Builder.node('td', {width: "100%"}, [TN(message)]),
      Builder.node('td', [Builder.node('span', {
        style: "font-weight:bolder;font-style:italic;"
      },[
        TN(c.user)
      ])]),
      Builder.node('td', [Builder.node('span', {
        style: "white-space:nowrap;"
      },[
        TN(this._formatDate(new Date(c.date)))
      ])]),
      Builder.node('td', [delete_button])
    ])
    if (messageNode.report == "true") {
      tr.firstChild.innerHTML = message
      tr.firstChild.style.background = "#FF8080"
    }
    Element.setStyle(tr, {cursor: "pointer"})
    Event.observe(tr, 'click', function(event) {
      new ThemedWindow({
        title: Builder.node('span', [
          translateText({path: ".messages-widget", id: "conv-title", args: [c.user]})
        ]).innerHTML,
        minimizable: false,
        maximizable: false,
        width: 400,
        height: 400,
        showEffect: Element.show,
        hideEffect: Element.hide
      }, function(win) {
        win.setContent(this.conversationView(c))
        win.setLocation(event.clientY+5, event.clientX+5)
        win.show()
        win.toFront()
      }.bind(this))
    }.bindAsEventListener(this))
    c.tr = tr;
    return tr;
  },
  showConversations: function(conversations) {
    var tbody = Builder.node('tbody', [
      Builder.node('tr', [
        Builder.node('th', [translateText({path: ".messages-widget", id: "message"})]),
        Builder.node('th', [translateText({path: ".messages-widget", id: "sender"})]),
        Builder.node('th', [translateText({path: ".messages-widget", id: "date"})]),
        Builder.node('th')
      ])
    ])
    conversations.each(function(c) {
      tbody.appendChild(this.drawSingleConversation(c))
    }.bind(this))
    return Builder.node('table', {
      border: "1",
      cellpadding: "5",
      cellspacing: "0",
      width: "100%"
    }, [tbody])    
  },
  update: function() {
    this.redrawCompletely()
  },
  cvSetup: function(c) {
    this.um = new UserMessages({user: c.user})
    this.cv.model = this.options.model
  },
  cvFormSubmit: function(message,c, msgs) {
    // Send message
    this.um.sendMessage(message, {afterSend: function(m) {
      this.cvUpdateView(m, c, msgs)
      // Update the conversations (can't use update() as this would reload
      // the conversations array and therefore loose the new data.)
      this.conversations.sort(function(a,b) { return b.date - a.date })
      var nc = this.showConversations(this.conversations)
      this.replaceChild(this.content, this.widgetContent, nc)
      this.widgetContent = nc
    }.bind(this)})
  },
  _getAllUsernames: function(onSuccess) {
    var url = serviceLink({
      user: itemModel.user(),
      service: itemModel.service(),
      action: 'users',
      noCrossSiteLink: true
    })
    new Ajax.Request(url,  {
      evalScripts: true,
      method: "get",
      onSuccess: function(t) { 
        var data = t.responseText
        var users = $A(data.split(/[\n\r]+/)).map(function(l) {
          if (l.match(/,/)) {
            var d = l.split(/\s*,\s*/)
            return d[0]
          }
          else {
            return false
          }
        }).select(function(n) { return n})
        onSuccess(users)
      }
    })    
  },
  messageEveryone: function(event) {
    new ThemedWindow({
      title: Builder.node('span', [
        translateText({path: ".um", id: "write-title"})
      ]).innerHTML,
      minimizable: false,
      maximizable: false,
      width: 400,
      height: 300,
      theme: {user: "core", path: "/alphacube"},
      showEffect: Element.show,
      hideEffect: Element.hide
    }, function(win) {
      var everyone = Builder.node('span', [TN("everyone ...")])
      var users;
      this._getAllUsernames(function(usernames) {
        users = usernames
        everyone.innerHTML = users.length + " users"
      })
      var errors = Builder.node('span', {style: "color:red;"})
      var form = Builder.node('form', {style: "width:100%;"},[
        translateText({path: ".um", id: "to"}), TN(":"), BR(),
        everyone, BR(),
        translateText({path: ".um", id: "message"}), TN(":"), BR(),
        Builder.node('textarea', {name: "message", rows: "4", style: "width:97%;"}),
        translateButton({path: ".um", id: "reply-button"})
      ])
      var log = Builder.node('span')
      var content = Builder.node('div', {style: "width:100%;"},[errors, form, log])
      Event.observe(form, 'submit', function(event) {
        Event.stop(event)
        var messageText = form.message.value
        errors.innerHTML = ""
        if (messageText.length < 10) {
          errors.appendChild(TN("Message contains less than 10 characters! Not sending"))
          return;
        }
        Element.hide(form)
        var counterNode = $(Builder.node('b', [TN("Sending")]))
        var spinner = Builder.node('img', {src: "/images/spinner.gif"})
        log.appendChild(spinner)
        log.appendChild(counterNode)
        log.appendChild(BR())
        var userCount = users.length
        var failedSents = 0
        function sendNextMessage(usernames, idx) {
          var u = usernames.pop()
          counterNode.innerHTML = "Sending message " + (idx+1) + " of " + userCount +
            "(" + failedSents + " thereof couldn't be sent)"
          new UserMessages({
            user: u,
            afterLoad: function(um) {
              var n = counterNode.nextSibling.nextSibling
              if (um.canSendMessage()) {
                um.sendMessage(messageText, {
                  noCopyForSender: true,
                  afterSend: function() {
                    log.insertBefore(TN("Sent message to user " + u), n)
                    log.insertBefore(BR(), n)
                    if (usernames.length > 0) {
                      sendNextMessage(usernames, idx+1)
                    }
                    else {
                      var successFull = userCount - failedSents
                      counterNode.innerHTML = "DONE!<br/>Sent " + successFull + " of " +
                        userCount + " messages."
                      Element.hide(spinner)
                    }
                  }
                })
              }
              else {
                failedSents++
                log.insertBefore(Builder.node('span', {
                  style: "color:red;"
                },[
                  TN("Failed to send message to user " + u)
                ]), n)
                log.insertBefore(BR(), n)
                if (usernames.length > 0) {
                  sendNextMessage(usernames, idx+1)
                }
                else {
                  var successFull = userCount - failedSents
                  counterNode.innerHTML = "DONE!<br/>Sent " + successFull + " of " +
                    userCount + " messages."
                  Element.hide(spinner)
                }
              }
            }
          })
        }
        sendNextMessage(users.clone(), 0)
      }.bindAsEventListener(this))
      win.setContent(content)
      win.setLocation(event.clientY,event.clientX)
      win.show()
      win.toFront()
    }.bind(this))
  },
  actionsBox: function() {
    var wm = ActionWidget.prototype.generalAction(
      "comment",
      "write message",
      translateText({path: ".messages-widget", id: "write-message"}),
      function(event) { this.writeNewMessage(event) }.bindAsEventListener(this)
    )
    var actions = Builder.node('span', [wm])
    var f = function() {
      actions.appendChild(ActionWidget.prototype.generalAction(
        "comment",
        "message all users",
        translateText({path: ".messages-widget", id: "write-all-users"}),
        function(event) { this.messageEveryone(event)}.bindAsEventListener(this)
      ))      
    }.bind(this)
    if (writeUserModel.data.username == "core") {
      f()
    }
    else {
      var buddyOfCoreDM = new DisplayModel({
        user: "core",
        service: "buddies"
      })
      buddyOfCoreDM.observeOnce({update: function() {
        if (buddyOfCoreDM.findItemByName(writeUserModel.data.username)) {
          f()
        }
      }})      
    }
    var actionsBox = new BoxWidget({
      id: 'mawnode',
      title: translateText({path:"", id: "actions"}),
      node: actions,
      className: "mybox"
    }).htmlNode()
    return actionsBox;
  },
  deleteConversation: function(conversation) {
    $A(conversation.msgs).each(function(msg) {
      this.deleteMessage(msg)
    }.bind(this))
  },
  deleteMessage: function(msg) {
    if (msg.sent_to) {
      var model = this.sentModel
    }
    else {
      var model = this.options.model
    }
    model.actions.moveToTrash(msg, {
      ask: false,
      username_override: model.user()
    })
  }
}
Object.extend(MessagesWidget.prototype, WidgetCommon)
Object.extend(MessagesWidget.prototype, ConversationView)

;

// /8::/202::/frontend:js -> <10215> mikestabswidget.js 

//old?_delete *mike
 
 var __tabs = null
MikesTabsWidget = Class.create();
MikesTabsWidget.prototype = {
  defaultOptions: function() {
    return {
      defaultItem:{name:"new",link:function(){alert('boooooooom');},id:""}
    }
  },
  setup: function() {
    var instance = this;
    var tabid =  this.options.name;
  },
  makeWidgetContent: function() {

      __tabs = this

      var tabs = this.options.tabs;
      var name = this.options.name;

      var html2dom_root = Builder.node('div', {
          id: name+"_box",
          className: 'toptabs'
      });
      html2dom_root_1_div = Builder.node('div', {
          id: this.options.name+'_tabsF'
      });
      html2dom_root_1_div_1_ul = Builder.node('ul', {id:name+"_ul"});

      if(this.options.add){   
          xtab = this.addTab({name:"sdad", link:function(){},astyle:"margin-right:80px;background:transparent;",pstyle:"padding:2px 8px 2px 8px;border:2px solid silver;background:transparent;"})
          html2dom_root_1_div_1_ul.appendChild(xtab); 
          plustab = this.addTab({name:"+", link:function(){
              $(name+"_ul").appendChild(__tabs.addTab(__tabs.options.defaultItem))
             }
          })
          html2dom_root_1_div_1_ul.appendChild(plustab);
      }

      for (var i = 0; i < tabs.length; i ++ ) {
          var tab = this.addTab(tabs[i])
          html2dom_root_1_div_1_ul.appendChild(tab);
      }
      html2dom_root_1_div.appendChild(html2dom_root_1_div_1_ul);
      html2dom_root.appendChild(html2dom_root_1_div);
      html2dom_root.appendChild(Builder.node('div', {
          style: 'clear:both;'
      }));
      return html2dom_root
  },
  addTab: function(o){
      if(!o.astyle){
         o.astyle = "";
         o.pstyle = "";
      }
      if(!o.tooltip){
         o.tooltip = false;
      }

      html2dom_root_1_div_1_ul_1_li = Builder.node('li', {id:"li_"+o.name});
      html2dom_root_1_div_1_ul_1_li_1_a = Builder.node('a', {style:o.astyle});
      html2dom_root_1_div_1_ul_1_li_1_a.onclick = o.link;
      html2dom_root_1_div_1_ul_1_li_1_a_1_span = Builder.node('span',{id:"span_"+o.name,className:"taba",style:o.pstyle},[ TN(o.name)]);


 var closer;

      if(o.tooltip == true){
      closer = Builder.node('div',{style:"position:relative;margin:0 auto;margin-right:-14px; text-align: right;z-index:99999;top:-23px;width:8px;height:30px;background:transparent url(/core-services/themes/mymodules/rrr.gif) 0 0;"});
      closer.onclick= function(e){Event.stop(e);return false; }
var setbox = o.tooltipcontent;


 gtt(closer, {
 x:-8,
 y:1,
 className: "",
 zIndex: 1000,
 content:new BoxWidget({id:'fw',title:TN(o.name),node:setbox,className:"tooltip",width:200}).htmlNode()
 }
)



           html2dom_root_1_div_1_ul_1_li_1_a_1_span.appendChild(closer);
      }

      html2dom_root_1_div_1_ul_1_li_1_a.appendChild(html2dom_root_1_div_1_ul_1_li_1_a_1_span);
      html2dom_root_1_div_1_ul_1_li.appendChild(html2dom_root_1_div_1_ul_1_li_1_a);
      return html2dom_root_1_div_1_ul_1_li;
  },
  setText: function(node,o){
      var ss = "<div>"+o.name+"</div>"
      node.replace(ss);
  },  
  rerender: function(){
      var nc = this.makeWidgetContent()
      this.replaceChild(this.content, this.widgetContent, nc)
      this.widgetContent = nc
  },
  makeSortable: function(){
      Sortable.create(this.options.name+"_ul",
      {tag:'li',constraint: 'horizontal',
      onUpdate:function(){}});
  }
}
Object.extend(MikesTabsWidget.prototype, WidgetCommon) 


 
;

// /8::/202::/frontend:js -> <154958> moreeffects.js 

/*
	FYI:
		"restoreAfterFinish" is only used by Scale and all its subclasses and puts the element 
			back where it was the size that it was.

	Bugs:
		SlideLeftIn still doesn't work on IE ???

		'delete' does not work on IE

		Cannot set styles of table items in Builder.node due to IE bug

		stray commas after last item in lists causes IE to fail


		Effect.toggle on these effects doesn't seem to work quite right
			(  Effect.toggle('demo-effect-curtainopen','slideleft')  )

		Not allowing Effect.Curtain* to finish before clicking again causes a problem.

		Not allowing MOST effects to finish before clicking again causes a problem.
*/


/* This declaration doesn't show up correctly when using Firebug */
/* 
	Also, these toggles don't seem to work right either
	OK:  slideup, slidedown, slideright
	NOT: slideleft, curtain
*/
Effect.PAIRS = Object.extend(
	Effect.PAIRS, { 
		'slidedown':  ['SlideDownIn',  'SlideDownOut'],
		'slideup':    ['SlideUpIn',    'SlideUpOut'],
		'slideleft':  ['SlideLeftIn',  'SlideLeftOut'],
		'slideright': ['SlideRightIn', 'SlideRightOut'],
		'curtain':    ['CurtainClose', 'CurtainOpen']
	}
);


Object.extend(
	Effect, {
		_elementIsNotAListError: {
			name: 'ElementIsNotAListError',
			message: 'The specified DOM element is not a list exist, but is required to be for this effect to operate'
		}
  }
);


Effect.PulseList = Class.create();
Object.extend(Object.extend(Effect.PulseList.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		if(!this.element) throw(Effect._elementDoesNotExistError);
//		if( (this.element.tagName != "UL") && (this.element.tagName != "OL") )
		if( ! ['UL','OL'].include(this.element.tagName) )
			throw(Effect._elementIsNotAListError);
		if ( ! this.element.effectOn ) {
			this.element.effectOn = true;
			var options = Object.extend({
				_pulse: 1,
				direction: "down",		// up or down
				pulses: 1,
				continuous: false,
				bounce: false,
				duration: 2,
				min_opacity: 0.1
			}, arguments[1] || {});
			this.start(options);
		}
	},
	setup: function() {
		var num_items = this.element.immediateDescendants().size();
		var i = 1;
		var self = this;
		this.element.immediateDescendants().each( function(myitem){
			var mydelay = (self.options.direction == "down" ) 
				? (i++ - 1)/num_items
				: (num_items - i++)/num_items;
			var reverser   = function(pos){ return Effect.Transitions.sinoidal(1-Effect.Transitions.pulse(pos, 1)) }
			new Effect.Opacity(myitem, 
				Object.extend(Object.extend({
					delay: mydelay, 
					duration: self.options.duration, 
					from: self.options.min_opacity,
					afterFinishInternal: function(effect) {
						if ( ! ( self.options.direction == 'down' ? myitem.next() : myitem.previous() ) ) {
							if ( ( self.options.continuous ) || ( self.options._pulse++ < self.options.pulses ) ){
								if ( self.options.bounce) 
									self.options.direction = ( self.options.direction == 'up' ) ? 'down' : 'up';
								new Effect.PulseList(effect.element.parentNode, self.options || {} );
							}
						}
					}
				}, {}), {transition: reverser})
			);
		});
	},
	finish: function() {
//		delete(this.element.effectOn);
		this.element.effectOn = false;
	}
});


Effect.Gradient = Class.create();
Object.extend(Object.extend(Effect.Gradient.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		if(!this.element) throw(Effect._elementDoesNotExistError);
		var options = Object.extend({
			duration: 5,
			rows: 10,
			cols: 10,
			type: 'diagonal',		/*	vertical, horizontal, diagonal */
			colors: [ 'black', 'white', 'white', 'black' ]
		}, arguments[1] || {});
		if (options.type == 'horizontal') options.rows = 1;
		else if (options.type == 'vertical') options.cols = 1;

		dims = this.element.getDimensions();
		cellwidth  = dims.width  / options.cols;
		cellheight = dims.height / options.rows;
		this.cellids = [];
		var self = this;
		this.table = Builder.node('table', {
			border: 0, cellpadding: 0, cellspacing: 0,
			style:"margin: 0px; padding: 0px;"
		});
		tbody = Builder.node('tbody');
		$(tbody).setStyle({ margin: 0, padding: 0 });
		$R(1,options.rows).each( function(row){
			tr = Builder.node('tr');
			$(tr).setStyle({ margin: 0, padding: 0 });
			if (options.type == 'vertical') {
				cellcolor = Color.shade( 
					Color.string2hex(options.colors[0]), 
					Color.string2hex(options.colors[1]), 
					(row-1)/(options.rows-1) 
				);
			}
			$R(1,options.cols).each( function(col){
				cellid = "grcell-"+row+"-"+col;
				if (options.type == 'diagonal') {
					cellcolor = Color.shade( 
						Color.shade( 
							Color.string2hex(options.colors[0]), 
							Color.string2hex(options.colors[1]), 
							(col-1)/(options.cols-1) 
						), 
						Color.shade( 
							Color.string2hex(options.colors[2]), 
							Color.string2hex(options.colors[3]), 
							(col-1)/(options.cols-1) 
						),
						(row-1)/(options.rows-1) 
					);
				} else if (options.type == 'horizontal') {
					cellcolor = Color.shade( 
						Color.string2hex(options.colors[0]), 
						Color.string2hex(options.colors[1]), 
						(col-1)/(options.cols-1) 
					);
				}
				td = Builder.node('td',{
					id: cellid
				}, "" );
				$(td).setStyle({ margin: '0px', padding: '0px',
					height: cellheight+'px', 
					width:  cellwidth+'px', 
					backgroundColor: cellcolor
				});
				tr.appendChild(td);
				self.cellids.push(cellid);
			});
			tbody.appendChild(tr);
		});
		this.table.appendChild(tbody);

		this.start(options);
	},
	setup: function(){
		Position.absolutize(this.element);
		this.element.parentNode.appendChild(this.table);
		Position.absolutize(this.table);
	},
	finish: function(){
		new Effect.Fade( this.table , {
			afterFinish: function(effect) {
				effect.element.parentNode.removeChild(effect.element);
			}
		});
	}
});

Effect.ORIGGradient = Class.create();
Object.extend(Object.extend(Effect.ORIGGradient.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		if(!this.element) throw(Effect._elementDoesNotExistError);
		var options = Object.extend({
			duration: 5,
			rows: 10,
			cols: 10,
			type: 'diagonal',		/*	vertical, horizontal, diagonal */
			colors: [ 'black', 'white', 'white', 'black' ]
		}, arguments[1] || {});
		if (options.type == 'horizontal') options.rows = 1;
		else if (options.type == 'vertical') options.cols = 1;

		dims = this.element.getDimensions();
		cellwidth  = dims.width  / options.cols;
		cellheight = dims.height / options.rows;
		this.cellids = [];
		var self = this;
		this.table = Builder.node('table', {
			border: 0, cellpadding: 0, cellspacing: 0,
			style:"margin: 0px; padding: 0px;"
		});
		tbody = Builder.node('tbody', { style:"margin: 0px; padding: 0px;" });
		$R(1,options.rows).each( function(row){
			tr = Builder.node('tr', { style:"margin: 0px; padding: 0px;" });
			if (options.type == 'vertical') {
				cellcolor = Color.shade( 
					Color.string2hex(options.colors[0]), 
					Color.string2hex(options.colors[1]), 
					(row-1)/(options.rows-1) 
				);
			}
			$R(1,options.cols).each( function(col){
				cellid = "grcell-"+row+"-"+col;
				if (options.type == 'diagonal') {
					cellcolor = Color.shade( 
						Color.shade( 
							Color.string2hex(options.colors[0]), 
							Color.string2hex(options.colors[1]), 
							(col-1)/(options.cols-1) 
						), 
						Color.shade( 
							Color.string2hex(options.colors[2]), 
							Color.string2hex(options.colors[3]), 
							(col-1)/(options.cols-1) 
						),
						(row-1)/(options.rows-1) 
					);
				} else if (options.type == 'horizontal') {
					cellcolor = Color.shade( 
						Color.string2hex(options.colors[0]), 
						Color.string2hex(options.colors[1]), 
						(col-1)/(options.cols-1) 
					);
				}
				td = Builder.node('td',{
					id: cellid,
					style:"margin: 0px; padding: 0px; "
						+"height: "+cellheight+"px; "
						+"width: "+cellwidth+"px; "
						+"background-color: "+cellcolor
				}, "" );
				tr.appendChild(td);
				self.cellids.push(cellid);
			});
			tbody.appendChild(tr);
		});
		this.table.appendChild(tbody);

		Position.absolutize(this.element);
		this.element.parentNode.appendChild(this.table);
		Position.absolutize(this.table);
		this.start(options);
	},
	finish: function(){
		new Effect.Fade( this.table , {
			afterFinish: function(effect) {
				effect.element.parentNode.removeChild(effect.element);
			}
		});
	}
});


Effect.Pixelate = Class.create();
Object.extend(Object.extend(Effect.Pixelate.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		if(!this.element) throw(Effect._elementDoesNotExistError);
		var options = Object.extend({
			duration: 5,
			rows: 30,
			cols: 30,
			startcolor: 'transparent',
			endcolor: 'white'
		}, arguments[1] || {});
		options.cells = options.rows * options.cols;

		dims = this.element.getDimensions();
		cellwidth  = dims.width  / options.cols;
		cellheight = dims.height / options.rows;
		this.cellids = [];
		this.table = Builder.node('table', {
			border: 0, cellpadding: 0, cellspacing: 0,
			style:"margin: 0px; padding: 0px;"
		});
		/*	Cannot set styles of table items in Builder.node due to IE bug */
		var self = this;
		tbody = Builder.node('tbody');
		$(tbody).setStyle({ margin: 0, padding: 0 });
		$R(1,options.rows).each( function(row){
			tr = Builder.node('tr');
			$(tr).setStyle({ margin: '0px', padding: '0px' });
			$R(1,options.cols).each( function(col){
				cellid = "pxcell-"+row+"-"+col;
				td = Builder.node('td',{
					id: cellid
				}, '');
				$(td).setStyle({ margin: '0px', padding: '0px',
					height: cellheight+'px', 
					width:  cellwidth+'px', 
					backgroundColor: options.startcolor
				});
				tr.appendChild(td);
				self.cellids.push(cellid);
			});
			tbody.appendChild(tr);
		});
		this.cellids.sort( function(a,b){return (0.5 - Math.random());} );
		this.table.appendChild(tbody);
		this.start(options);
	},
	setup: function() {
		Position.absolutize(this.element);
		this.element.parentNode.appendChild(this.table);
		Position.absolutize(this.table);
	},
	update: function(position) {
		while ( this.cellids.size() && (this.cellids.size()/this.options.cells) > (1-position) ) {
			$(this.cellids.pop()).setStyle({ backgroundColor: this.options.endcolor });
		}
	},
	finish: function(){
		new Effect.Fade( this.table , {
			afterFinish: function(effect) {
				effect.element.parentNode.removeChild(effect.element);
			}
		});
	}
});



Effect.Duplicate = Class.create();
Object.extend(Object.extend(Effect.Duplicate.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		if(!this.element) throw(Effect._elementDoesNotExistError);

		this.element.makePositioned();
		this.elecopy = this.element.cloneNode(true);
		this.elecopy.setStyle({ color: 'red', backgroundColor: 'red', backgroundImage: '' });
		this.elecopy.id = element.id + '-copy';
		this.element.parentNode.appendChild(this.elecopy);
		Position.relativize(this.element);
		Position.relativize(this.elecopy);
		Position.absolutize(this.element);
		Position.absolutize(this.elecopy);

		var options = Object.extend({
		}, arguments[1] || {});
		this.start(options);
	},
	asetup: function() {
		return new Effect.Parallel ( [
			new Effect.SlideRightIn(this.element, { sync:true }),
			new Effect.SlideLeftIn( this.elecopy, { sync:true }) 
			], Object.extend({ 
				duration: 2
			}, arguments[1] || {})
		);
	},
	update: function(position) {
	},
	finish: function() {
		this.elecopy.undoClipping().undoPositioned().remove();
	}
});

Effect.Flicker = Class.create();
Object.extend(Object.extend(Effect.Flicker.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = $(element);
		if(!this.element) throw(Effect._elementDoesNotExistError);
		if ( ! this.element.effectOn ) {
			this.element.effectOn = true;
			var options = Object.extend({
				threshold: 0.5,
				endvisibility: "visible"
			}, arguments[1] || {});
			this.start(options);
		}
	},
	update: function(position) {
		var visibility = ( Math.random() < this.options.threshold ) ? "hidden" : "visible";
		this.element.setStyle({
			visibility: visibility
		});
	},
	finish: function() {
		this.element.setStyle({
			visibility: this.options.endvisibility
		});
//		delete(this.element.effectOn);
		this.element.effectOn = false;
	}
});


Effect.CurtainClose = function(element) {
/* 
	CurtainClose need to have the content of the element wrapped in a container element with fixed width AND height!
*/
	element = $(element).cleanWhitespace();
	var elementDimensions = element.getDimensions();

	element.makeClipping().makePositioned();
	element.parentNode.makeClipping();	//	stops SlideLeftIn flicker
	elecopy = $(element.cloneNode(true));
	elecopy.setStyle({ top: '0px', left: '0px' });
	elecopy.id = element.id + '-copy';
	element.parentNode.appendChild(elecopy);
	elecopy.makeClipping().makePositioned();
	Position.absolutize(element);

	return new Effect.Parallel ( [
		new Effect.SlideRightIn(element, { sync:true }),
		new Effect.SlideLeftIn( elecopy, { sync:true }) 
		], Object.extend({ 
			duration: 2,
			afterFinishInternal: function(effect){
				elecopy.undoClipping().undoPositioned().remove();
/*	why does the above work and the below does not? */
//				effect.effects[1].element.undoClipping().undoPositioned().remove();
				effect.effects[0].element.parentNode.undoClipping();
			}
		}, arguments[1] || {})
	);
}

Effect.CurtainOpen = function(element) {
/* 
	CurtainOpen need to have the content of the element wrapped in a container element with fixed width AND height!
*/
	element = $(element).cleanWhitespace();

	element.makeClipping().makePositioned();
	element.parentNode.makeClipping();
	elecopy = element.cloneNode(true);
	elecopy.setStyle({ top: '0px' });
	elecopy.id = element.id + '-copy';
	element.parentNode.appendChild(elecopy);
	Position.absolutize(element);
	Position.absolutize(elecopy);

	var elementDimensions = element.getDimensions();
	return new Effect.Parallel ( [
		new Effect.SlideRightOut(element, { sync:true }),
		new Effect.SlideLeftOut( elecopy, { sync:true })
		], Object.extend({ 
			duration: 2,
			beforeSetup: function(effect){
				effect.effects[1].element.makeClipping().makePositioned().show();
			},
			afterFinishInternal: function(effect){
				element.undoClipping().undoPositioned();
/*	why does the above work and the below does not? */
//				effect.effects[0].element.undoClipping().undoPositioned();	
				effect.effects[1].element.parentNode.undoClipping();
				effect.effects[1].element.undoClipping().undoPositioned().remove();
			}
		}, arguments[1] || {})
	);
}


Effect.SlideLeftIn = function(element) {
/* 
	SlideLeftIn need to have the content of the element wrapped in a container element with fixed width!
*/
	element = $(element).cleanWhitespace();
	if ( ! element.effectOn ) {
		element.effectOn = true;
		var elementDimensions = element.getDimensions();
		return new Effect.Parallel ( [
			new Effect.Move(element, 
				Object.extend({ 
					x: -(elementDimensions.width), 
					sync: true, 
					mode: 'relative', 
					beforeStartInternal: function(effect) {
						if(window.opera) effect.element.setStyle({left: ''});
						effect.element.setStyle({left: elementDimensions.width + 'px' });
						effect.element.show();
					}
				}, arguments[1] || {})
			),
			new Effect.Scale(element, 100,
				Object.extend({ scaleContent: false, 
					/* why does the use of sync: true make this flicker? */
					scaleY: false,
					scaleFrom: window.opera ? 0 : 1
				}, arguments[1] || {})
			)
			], Object.extend({
				beforeSetup: function(effect){
					effect.effects[0].element.parentNode.makeClipping();
					effect.effects[0].element.makeClipping();
				},
				afterFinishInternal: function(effect){
					effect.effects[0].element.parentNode.undoClipping();
					effect.effects[0].element.undoClipping();
				},
				afterFinish: function(effect){
//					delete(effect.effects[0].element.effectOn);
					effect.effects[0].element.effectOn = false;
				}
			}, arguments[1] || {})
		);
	}
}


Effect.SlideRightOut = function(element) {
/* 
	SlideRightOut need to have the content of the element wrapped in a container element with fixed width!
*/
	element = $(element).cleanWhitespace();
	var elementDimensions = element.getDimensions();
	return new Effect.Parallel ( [
		new Effect.Move(element, { x: element.getWidth(), sync: true, mode: 'relative' }),
		new Effect.Scale(element, window.opera ? 0 : 1, {	
			sync: true, 
			scaleContent: false, 
			scaleY: false,
			scaleFrom: 100,
			restoreAfterFinish: true
		})
		], Object.extend({ 
			beforeSetup: function(effect){
				effect.effects[0].element.makeClipping();
			},
			afterFinishInternal: function(effect){
				effect.effects[0].element.undoClipping().hide();
			}
		}, arguments[1] || {})
	);
}



/* from SlideUp */
Effect.SlideLeftOut = function(element) {
/*
	SlideLeftOut needs to have the content of the element wrapped in a container element with fixed width
	otherwise any text or images begin to wrap in stange ways!
*/
	element = $(element).cleanWhitespace();
	return new Effect.Scale(element, window.opera ? 0 : 1,
		Object.extend({ 
			scaleContent: false, 
			scaleY: false, 
			scaleMode: 'box',
			scaleFrom: 100,
			restoreAfterFinish: true,
			beforeStartInternal: function(effect) {
				effect.element.makePositioned();
				effect.element.down().makePositioned();
				if(window.opera) effect.element.setStyle({left: ''});
				effect.element.makeClipping().show();
			},  
			afterUpdateInternal: function(effect) {
				effect.element.down().setStyle(
					{right: (effect.dims[1] - effect.element.clientWidth) + 'px' }
				);
			},
			afterFinishInternal: function(effect) {
				effect.element.hide().undoClipping().undoPositioned();
				effect.element.down().undoPositioned();
			}
		}, arguments[1] || {})
	);
}


/* from SlideDown */
Effect.SlideRightIn = function(element) {
/*
	SlideRightIn needs to have the content of the element wrapped in a container element with fixed width!
*/
	element = $(element).cleanWhitespace();
	var elementDimensions = element.getDimensions();
	return new Effect.Scale(element, 100, 
		Object.extend({ 
			scaleContent: false, 
			scaleY: false, 
			scaleFrom: window.opera ? 0 : 1,
			scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
			restoreAfterFinish: true,
			afterSetup: function(effect) {
				effect.element.makePositioned();
				effect.element.down().makePositioned();
				if(window.opera) effect.element.setStyle({left: ''});
				effect.element.makeClipping().setStyle({width: '0px'}).show(); 
			},
			afterUpdateInternal: function(effect) {
				effect.element.down().setStyle({right: (effect.dims[1] - effect.element.clientWidth) + 'px' }); 
			},
			afterFinishInternal: function(effect) {
				effect.element.undoClipping().undoPositioned();
				effect.element.down().undoPositioned();
			}
		}, arguments[1] || {})
	);
}



Effect.SlideUpIn = function(element) {
/* 
	SlideUpIn need to have the content of the element wrapped in a container element with fixed height!
*/
	element = $(element).cleanWhitespace();
	var elementDimensions = element.getDimensions();
	return new Effect.Parallel ( [
		new Effect.Move(element, { y: -(element.getHeight()), sync: true, mode: 'relative' }),
		new Effect.Scale(element, 100, 
			Object.extend({
				sync: true,
				scaleContent: false,
				scaleX: false,
				scaleFrom: 0,
				scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
				beforeSetup: function(effect) {
					effect.element.hide();
				},
				afterSetup: function(effect) {
					effect.element.makeClipping().setStyle({height: '0px'}).show();
				},
				afterFinishInternal: function(effect) {
					effect.element.undoClipping();
				}
			}, arguments[1] || {})
		)
	], Object.extend({
		afterSetup: function(effect) {
			effect.effects[0].element.setStyle({top: elementDimensions.height + 'px' });
		}
	}, arguments[1] || {}));
}


Effect.SlideDownOut = function(element) {
/* 
	SlideDown need to have the content of the element wrapped in a container element with fixed height!
*/
	element = $(element).cleanWhitespace();
	var elementDimensions = element.getDimensions();
	return new Effect.Parallel ( [
		new Effect.Move(element, { y: element.getHeight(), sync: true, mode: 'relative' }),
		new Effect.Scale(element, 0,
			Object.extend({ 
				sync: true,
				scaleContent: false,
				scaleX: false,
				restoreAfterFinish: true,
				beforeSetup: function(effect){
					effect.element.makeClipping();
				},
				afterFinishInternal: function(effect) {
					effect.element.hide().undoClipping();
				}
			}, arguments[1] || {})
		)
	], Object.extend({
	}, arguments[1] || {}));
}



/* this is the original SlideDown */
Effect.SlideDownIn = function(element) {
	element = $(element).cleanWhitespace();
	// SlideDown need to have the content of the element wrapped in a container element with fixed height!
	var oldInnerBottom = element.down().getStyle('bottom');
	var elementDimensions = element.getDimensions();
	return new Effect.Scale(element, 100, 
		Object.extend({ 
			scaleContent: false, 
			scaleX: false, 
			scaleFrom: window.opera ? 0 : 1,
			scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
			restoreAfterFinish: true,
			afterSetup: function(effect) {
				effect.element.makePositioned();
				effect.element.down().makePositioned();
				if(window.opera) effect.element.setStyle({top: ''});
				effect.element.makeClipping().setStyle({height: '0px'}).show(); 
			},
			afterUpdateInternal: function(effect) {
				effect.element.down().setStyle({bottom:
				(effect.dims[0] - effect.element.clientHeight) + 'px' }); 
			},
			afterFinishInternal: function(effect) {
				effect.element.undoClipping().undoPositioned();
				effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); 
			}
		}, arguments[1] || {})
	);
}

/* this is the original SlideUp */
Effect.SlideUpOut = function(element) {
	element = $(element).cleanWhitespace();
	var oldInnerBottom = element.down().getStyle('bottom');
	return new Effect.Scale(element, window.opera ? 0 : 1,
		Object.extend({ 
			scaleContent: false, 
			scaleX: false, 
			scaleMode: 'box',
			scaleFrom: 100,
			restoreAfterFinish: true,
			beforeStartInternal: function(effect) {
				effect.element.makePositioned();
				effect.element.down().makePositioned();
				if(window.opera) effect.element.setStyle({top: ''});
				effect.element.makeClipping().show();
			},  
			afterUpdateInternal: function(effect) {
				effect.element.down().setStyle({bottom:
				(effect.dims[0] - effect.element.clientHeight) + 'px' });
			},
			afterFinishInternal: function(effect) {
				effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
				effect.element.down().undoPositioned();
			}
		}, arguments[1] || {})
	);
}

 
 
Effect.Scroll = Class.create();
Object.extend(Object.extend(Effect.Scroll.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    var options = Object.extend({
      x:    0,
      y:    0,
      mode: 'absolute'
    } , arguments[1] || {}  );
    this.start(options);
  },
  setup: function() {
    if (this.options.continuous && !this.element._ext ) {
      this.element.cleanWhitespace();
      this.element._ext=true;
      this.element.appendChild(this.element.firstChild);
    }

    this.originalLeft=this.element.scrollLeft;
    this.originalTop=this.element.scrollTop;

    if(this.options.mode == 'absolute') {
      this.options.x -= this.originalLeft;
      this.options.y -= this.originalTop;
    } else {

    }
  },
  update: function(position) {   
    this.element.scrollLeft = this.options.x * position + this.originalLeft;
    this.element.scrollTop  = this.options.y * position + this.originalTop;
  }
});



;

// /8::/202::/frontend:js -> <35077> multiupload-2.js 

multiUploadWidget = Class.create();
multiUploadWidget.prototype = {
  defaultOptions: function() {
    return {};
  }, 
  initialize:function(){ 

  }, 
  setup:function(){ 
   },
  makeWidgetContent: function() {
      var swfdiv = Builder.node("div");
      this.getSwfObject().write(swfdiv);
      return Builder.node('div',{id:"uploaderWidget"},[swfdiv]);
  },
  getSwfObject:function(){  
        var inst = this;

        var surl = serviceLink({
            service: "files@core",
            action: "get_file?path=/multipleuploader-15.swf&username_override=mike",
            noCrossSiteLink: true
        });

 
        var so = new SWFObject(surl+'&user='+write_username+'&path2='+itemModel.currentPath()+'&controller='+itemModel.controllerName()+'&cookie='+document.cookie.split("; ").inject({}, function(h, v) { vv = v.split("=", 2); h[vv[0]] = vv[1]; return h})["mysites"], "myuploader", "500", "210", "8", "#FFFFFF");
        so.addParam('allowScriptAccess', 'always');
        //so.addParam('flashVars', ) ;   
        so.addParam('wmode', 'transparent');   
        return so;   
  }
}

Object.extend(multiUploadWidget.prototype, WidgetCommon);

function onUploadEvent(e){

    var dat = e.split("onUploadEvent:")[1];

    document.body.appendChild(TN(dat));

    var v = window.eval("("+dat+")");
    //all files uploaded.. do post-upload stuff
    if(v.data == "DONE"){
      var obs = {afterPathChanged: function() {
        itemModel.removeObserver(obs)
           currentItemManager.m.edit = false
           currentItemManager.m.increation = false
        currentItemManager.closeWindow()
      }}
      itemModel.addObserver(obs)
      itemModel.changeToFolder(itemModel.currentPath());

    }
}  
  
;

// /8::/202::/frontend:js -> <3810> multiuploadwidget.js 

multiUploadWidget = Class.create();
multiUploadWidget.prototype = {
  defaultOptions: function() {
    return {};
  }, 
  initialize:function(){ 

  }, 
  setup:function(){ 
   },
  makeWidgetContent: function() {
      var swfdiv = Builder.node("div");
      this.getSwfObject().write(swfdiv);
      return Builder.node('div',{id:"uploaderWidget"},[swfdiv]);
  },
  getSwfObject:function(){  
        var inst = this;
 
        var surl = serviceLink({
            service: "files@core",
            action: "get_file?path=/multipleuploader-15.swf&username_override=core",
            noCrossSiteLink: true
        });

        var so = new SWFObject(surl+'&user='+write_username+'&path2='+itemModel.currentPath()+'&controller='+itemModel.controllerName()+'&cookie='+document.cookie.split("; ").inject({}, function(h, v) { vv = v.split("=", 2); h[vv[0]] = vv[1]; return h})["mysites"], "myuploader", "500", "210", "8", "#FFFFFF");
        so.addParam('allowScriptAccess', 'always');
        //so.addParam('flashVars', ) ;   
        so.addParam('wmode', 'transparent');   
        return so;   
  }
}

Object.extend(multiUploadWidget.prototype, WidgetCommon);

function onUploadEvent(e){
    var dat = e.split("onUploadEvent:")[1];
    var v = window.eval("("+dat+")");
    //all files uploaded.. do post-upload stuff
        
     if(v.data == "DONE"){ 

  
window.setTimeout(function(){
        var obs = {afterPathChanged: function() {
            itemModel.removeObserver(obs)
            currentItemManager.m.edit = false
            currentItemManager.m.increation = false
            currentItemManager.closeWindow()
        }}
        itemModel.addObserver(obs);
        itemModel.changeToFolder(itemModel.currentPath());
},800);
    }
}  
;

// /8::/202::/frontend:js -> <835> myhelpers.js 

/*
 var gttip;

var tipp;
 function gtt(node, obj) {
        var tt = new Tooltip( {
        className: obj.className,
        zIndex: obj.zIndex,
        position: {
            y: obj.y,
            x: obj.x
        },
 ySwapAdd: 5.1, 
        autoHide: true,
        generateTooltipContent: function(o) {
            return new BoxWidget({id:'gttt',title:NBSP(),node:obj.content,className:obj.className,width:obj.width}).htmlNode()
        }
    });
    node.onmouseover = function() {
        tt.delayedShow( {
            element: node
        })
        }
       tipp = tt;
}

*/
/*
 function test(){

var expl = Builder.node('div',{id:"explorerNode"},[standardExplorer.pathWidget.htmlNode(),BR(),standardExplorer.htmlNode()]);

var leftbar1 = Builder.node('div',{id:"pp1",className:"leftPanel2"},[expl]);
var leftbar2 = Builder.node('div',{id:"pp2",className:"leftPanel2"},[TN("Second Panel")]);

var cww = new CarouselWidget({id:"html-carousel",nodes:[leftbar1,leftbar2],width:"500px",buttons:["pp1","pp2"]});
mainwin.setContent(cww.htmlNode());
cww.initCarousel();

} 

*/


    //a different version of roundBox()

    //needed for better control of classes and width 

    function roundIt() {
        var o = Object.extend({
        node: null,
        width:100,
        className: ""
        }, arguments[0] || {});
        return table({width:o.width,className: o.className + "_table"}, 
            [cell(o.className + '_top-left'), cell(o.className + '_top'), cell(o.className + '_top-right')],
            [cell(o.className + '_main-left'), cell(o.className + '_content', htmlNode(o.node)), cell(o.className + '_main-right')],
            [cell(o.className + '_bottom-left'), cell(o.className + '_bottom'), cell(o.className + '_bottom-right')]
        )
    }

;

// /8::/202::/frontend:js -> <104816> myshellwidget.js 

var shell;
MyShellWidget = Class.create();
MyShellWidget.prototype = {
  defaultOptions: function() {
    return Object.extend({width:800,height:600,controller:itemModel.controllerName(),user:write_username},arguments[0]||{});
  }, 
  initialize:function(){ 
  }, 
  setup:function(){ 
  },
  makeWidgetContent: function() {
     shell = this;
    var si =  serviceLink({
            service: "files@core",
            action: "get_file?path=/shell-icon.png&username_override=core",
            noCrossSiteLink: true
        });
        var ico = Builder.node("div",{style:"background:url("+si+") no-repeat;width:94px;vertical-align:bottom;height:48px;font-size:130%;text-align:right;"},[TN("Shell")])
        Event.observe(ico,'click',function(e){
            $("shellopen").show();
        })

        var wm = Builder.node("div",{style:"cursor:pointer;margin-left:50px;"},[TN("open here")]);
        Event.observe(wm,'click',function(e){
            shell.showShell();
        })
 
        var fsm = Builder.node("div",{style:"cursor:pointer;margin-left:50px;"},[TN("open new window")]);
        Event.observe(fsm ,'click',function(e){
            window.open("http:\/\/"+write_username+".myservic.es/shell@mike?controller="+itemModel.controllerName()+"&user="+write_username,"MyShell",'location=no,menubar=no,toolbar=no,status=no,resizable=no,scrollbars=no,width=640,height=480');
        })
 
      this.shelldiv = Builder.node("div");
      this.getSwfObject().write(this.shelldiv);
      return Builder.node('div',{id:"MyShell",style:"margin:20px;font-size:12px;"},[ico,Builder.node('div',{id:"shellopen",style:"background:url("+serviceLink({service:"files@core",user:"core",action:"get_file?path=/shellarrow.gif"})+") no-repeat;width:180px;height:70px;display:none;"},[wm,fsm])]);
  },
  getSwfObject:function(){  
        var inst = this;
        var surl = serviceLink({
            service: "files@core",
            action: "get_file?path=/mysitesshell.swf&username_override=core",
            noCrossSiteLink: true
        });
        var so = new SWFObject(surl+'&username_override2='+this.options.user+'&path2='+itemModel.currentPath()+'&controller='+this.options.controller+'&cookie='+document.cookie.split("; ").inject({}, function(h, v) { vv = v.split("=", 2); h[vv[0]] = vv[1]; return h})["mysites"], "MyShell", this.options.width, this.options.height, "9", "#000000");
        so.addParam('allowScriptAccess', 'always');
        return so;   
    },
    showShell:function(){
        new ThemedWindow({
            title: "Shell",
            maximizable: false,
            minimizable: false,
            showEffect: Element.show,
            hideEffect: Element.hide,
            width: this.options.width,
            height: this.options.height,
            onClose: function() { }.bind(this)
        }, function(w) {
            var div = shell.shelldiv;
            w.setContent(div)
            w.showCenter()
            w.toFront()
        })
    }
}
Object.extend(MyShellWidget.prototype, WidgetCommon);  
 
;

// /8::/202::/frontend:js -> <6331> navitreewidget.js 

var prevFold = "f_/";
naviTreeWidget = Class.create();
naviTreeWidget.prototype = {
  defaultOptions: function() {
    return {
      model: itemModel,
      addHandler:function(){},
      addText:"Add Folder" 
    };
  },
  title: function() {
    return this.titleNode
  },  
  setup:function(){
    this.titleNode = Builder.node('span', [
      Builder.node('span', [
        translateText({path: ".navi-tree-widget", id: "navigation"})
      ]),
      Builder.node('span', {style: "display:none;"}, [
      translateText({path: ".navi-tree-widget", id: "services"})
      ]),
      helpTexts.helperNode("Navigation Title", 14)
    ])
    this.options.model.addObserver(this);   
    var instance = this;
    autoAfterShowWidget(function() { instance.generateFolderList() })
   },
  afterPathChanged: function() {
    $A(this.c0.childNodes).each(function(n) {
      if (n.id != "f_HOME") Element.remove(n)
    })
    this.generateFolderList();
  },
  update:function(){},
  makeWidgetContent: function() {
    var links = Builder.node('div', {
      style: "font-weight:bold;cursor:pointer;font-style:italic;font-variant:small-caps;"
    },[
      Builder.node('div', [
        translateText({path: ".navi-tree-widget", id: "show-services"}),
        TN(" >")
      ]),
      Builder.node("div", {style: "display:none;"}, [
        TN("< "),
        translateText({path: ".navi-tree-widget", id: "show-navigation"})
      ])
    ])
    var views = Builder.node('div', [
      this.makeNavigationView(),
      this.makeServicesView()
    ])
    var f = function(event) {
      if (event) Event.stop(event);
      $A([links, views, this.titleNode]).each(function(e) {
        $A([0,1]).each(function(i) {
          Element.toggle(e.childNodes[i])
        })        
      })
    }.bindAsEventListener(this)
    Event.observe(links, 'click', f)
    return Builder.node('div', {
      style: "padding:5px;"
    },[
      links,
      Builder.node('hr', {
        style: "color:black;background-color:black;height:1px;border: 0px;"
      }),
      views
    ])
  },
  makeServicesView: function() {
    var csw = new changeSiteWidget()
    return Builder.node('div', {style: "display:none;"}, [csw.setPanelContent()])
  },
  makeNavigationView: function(){
    if (logged_in && readUserModel.data.username == writeUserModel.data.username) {
      var shortcuts = Builder.node('div', {
        style:"font-size:12px;margin-top:5px;"
      },[
        table([{
          columnOptions: {width: 20},
          columnData: [
            Builder.node('img',{
              src:"/images/icons/turquoise/16x16/misc_folder.gif",
              style: "padding:3px;"
            })
          ]},
          Builder.node('span', {
            style: 'font-weight:bolder;',
            href: "javascript:void(0)"
          }, [
            translateText({path: ".navi-tree-widget", id: "trash"}),
            helpTexts.helperNode("Trash in Navigation", 12)
          ])
        ])
      ])
      var trash = Element.down(shortcuts, 'tr')
      addMouseOver(trash)
      Event.observe(trash, 'click', function() {
        this.options.model.changeToFolder("/trash")
      }.bindAsEventListener(this))
    }
    else {
      var shortcuts = EMPTY()
    }
    var hb = Builder.node('div', {
      id:"f_HOME",
      style:"width:100%;"
    },[
      table([
        {
          columnOptions:{width:20},
          columnData:[
            Builder.node('img',{
              src:"/images/icons/turquoise/16x16/misc_folder.gif",
              style: "padding:3px;"
            })
          ]
        },
        Builder.node('a',{
          href:"#",style:"color:black;"
        },[TN("/")])
      ]) 
    ]);
    addMouseOver(hb)
    Event.observe(hb,'click',function(){ 
      prevFold = "f_X"; 
      this.options.model.changeToFolder("/"); 
    }.bindAsEventListener(this))
    this.c0 = Builder.node('div',{
      id:"c_0",
      style:"font-size:12px;",
      className:"folderList"
    },[hb]);
    return Builder.node('div', [this.c0, shortcuts]);
  },
  generateFolderList:function(){ 
    var pfp = this.options.model.currentPath().replace(/\/[^\/]*$/, "")
    if (pfp != "") {
      var id = "f_up"
      var upf = Builder.node('div', {
        id: id,
        style:"width:100%;"
      },[
        table([
          {
            columnOptions:{width:20},
            columnData:[
              Builder.node('img',{
                src:"/images/icons/turquoise/16x16/misc_folder.gif",
                style: "padding:3px;"
              })
            ]
          },
          Builder.node('a',{
            href:"#",style:"color:black;"
          },[
            translateText({path: ".navi-tree-widget", id: "back"}),
            TN(" "),
            Builder.node('b', [TN(pfp.replace(/(.*\/)/, ""))])
          ])
        ]) 
      ]);
      addMouseOver(upf)
      Event.observe(upf,'click',function(){ 
        prevFold = "f_X"; 
        this.options.model.changeToFolder(pfp); 
      }.bindAsEventListener(this))
      var n = $(id)
      if (n) {
        this.c0.replaceChild(upf, n)
      }
      else {
        this.c0.appendChild(upf);        
      }
    }
    var items = this.options.model.getModel(); 
    vinstance = this;
    items.each(function(i){ 
      if(isFolder(i)){  
        if($("c_"+i.pretty_name)){
          return;
        }
        var base = this.options.model.currentPath();
        var fn = Builder.node('a',{
          id:base+"/f_"+i.pretty_name,
          rel:"f_"+i.pretty_name,
          href:"#",
          style:"color:black;"
        },[TN(i.name)])
        var xn = Builder.node('div',{
          id:"c_"+i.pretty_name,
          rel:i.pretty_name,
          style:"margin-left:18px;padding:3px;"
        },[
          table([{
            columnOptions:{width:20},
            columnData:[
              Builder.node('img',{
                border:0,
                src:"/images/icons/turquoise/16x16/misc_folder.gif",
                style: ""
              })
            ]
          },fn])]);
        addMouseOver(xn);
        Event.observe(xn,'click',function(e){
          Event.stop(e); 
          var l = Event.element(e);
          if (l.tagName != "A") l = Element.down(l, 'a')
          var t = l.id.split("f_")[0]+l.rel.gsub("f_",""); 
          this.options.model.changeToFolder(t);
        }.bindAsEventListener(this))  
        this.c0.appendChild(xn);
      }
    }.bind(this));
  }, 
  rerender: function(){
  },
  expand:function(node){
  }, 
  collapse:function(node){
  }  
}
Object.extend(naviTreeWidget.prototype, WidgetCommon); 

function addMouseOver(b){
  b.style.cursor = "pointer"
  Event.observe(b,'mouseover',function(event){
    Element.setStyle(b, {color:"#000000",backgroundColor:"#efefef"});
    Event.stop(event);
  });
  Event.observe(b,'mouseout',function(event){
    Element.setStyle(b, {color:"#000000",backgroundColor:"#FFFFFF"});
    Event.stop(event); 
  });
}

;

// /8::/202::/frontend:js -> <841> pathwidgetoverride.js 

// pathwidget.js
PathWidget = Class.create();
PathWidget.prototype = {
  defaultOptions: function() {
    return {
      model: itemModel
    };
  },
  setup: function() {
    this.options.model.addObserver(this); // afterPathChanged
  },
  currentPath: function() {
    var cp = this.options.model.currentPath();
    return cp.replace(/^\//, "\/ ")
  },
  parentFolder: function() {
    if (this.options.model.currentPath() != "/") {
      return this.options.model.currentPath().replace(/\/[^\/]*$/, "")
    }
    else {
      return "/"
    }
  },
  makeWidgetContent: function() {
    if (!actionsHidden && this.options.model.currentPath() != "/") {
      var pfn = this.parentFolder().replace(/(.*\/)/, "")
      if (pfn == "") pfn = "/"
      var prevfold = Builder.node('span',[
        Builder.node('a',{href:"#",style:"color:white;text-decoration:none;"},[
          TN("Return to "+pfn)
        ]),
        helpTexts.helperNode("Back to previous folder",14)
      ]);
      prevfold.onclick = function(event) {
        if (this.options.model.currentPath() != '/') {
          this.options.model.changeToFolder(this.parentFolder())
        } 
      }.bindAsEventListener(this)
      return Builder.node('span', {id: "mysites-path"}, [
        imageActionLink({
          fullImageName: iconPath(16, "back"), 
          title: "previous folder",
          onclick: function(event) {
            if (this.options.model.currentPath() != '/') {
              this.options.model.changeToFolder(this.parentFolder());
            }
            return false
          }.bindAsEventListener(this)
        }),
        NBSP(),
        prevfold
      ])
    }
    else {
      return Builder.node('span', {id: "mysites-path"})
    }
  },
  afterPathChanged: function() {
    this.redrawCompletely()
  }
}

Object.extend(PathWidget.prototype, WidgetCommon);
;

// /8::/202::/frontend:js -> <904> pwindow.js 

var __pw = null

var PWindow = Class.create();
PWindow.prototype = {
  initialize: function() {
    __pw = this;
    this.options = Object.extend({
      releaseHandler: function() { },
      title: "",
      htmlContent: null,  // deprecated, use contentWidget!
      contentWidget: null,
      header: true,
      name: null
    }, arguments[0] || {})
    if (this.checkNamedWindowAlreadyShowing) {
      var r = this.checkNamedWindowAlreadyShowing()
      if (r) { return r }
    }
    var cw = this.options.contentWidget
    var instance = this
    var sizes = {
      maxHeight: windowHeight() ,
      reserveHeight: 20,
      maxWidth: windowWidth(),
      reserveWidth: 0
    }
    if (cw && cw.adjustWindowSizes) { cw.adjustWindowSizes(sizes) }
    var imgHeight = 24
    sizes.height = sizes.maxHeight - sizes.reserveHeight - imgHeight
    sizes.width  = sizes.maxWidth  - sizes.reserveWidth
    var closeNode = Builder.node('div', {
      style: "height:" + imgHeight + "px;"
    },[NBSP()])
    if (this.options.header) {
      closeNode = Builder.node('a', { href: '#'}, [
        Builder.node('img', {
        src: iconPath(imgHeight, "close"),
        title: 'close window'})
      ])
      closeNode.onclick = function() {
        instance.close()
        return false; 
      }
    }
    //added by mike
    if(this.options.title){
        var title = TN(this.options.title);
    }else{
        var title = NBSP(); 
    }     
    //end added
    // this table is wrapped into BoxWidget
    this.table = /*new BoxWidget({
      id: 'mtable',
      title: title,
      width:"100%",
      node:*/ table({className: 'ms-window'}, [
        cell(),
        cell({className: "header"}, table([
          cell({className: "title", width: "100%"}, TN(this.options.title)),
          cell({className: "close"}, closeNode)
        ])),
        cell()
      ],[
        cell(), 
        cell({valign: "top"}, this.frameDiv = Builder.node('div', {
          className: 'frame'
        })), 
        cell()
      ],[
        cell({colspan: 3})
      ])/*,
      className:"diwbox"
    }).htmlNode()*/
    Element.setStyle(this.frameDiv, {
      height: sizes.height + "px",
      width:  sizes.width  + "px"
    })
//end of wrap 
    if (this.options.htmlContent) {
      this.frameDiv.innerHTML = this.options.htmlContent;
    } else if (cw) {
      this.frameDiv.appendChild(cw.htmlNode())
    }
    this.tab = new Tab(this, {name: this.options.name})
    this.frameDiv = $(this.frameDiv)
  },
  afterInitiallyShowingTab: function() { 
    documentRoot().appendChild(this.table);
    setBackgroundColor("#aaa")
  },
  resizeWindow: function() {
    this.offsetWidth = this.frameDiv.offsetWidth
    this.offsetHeight = this.frameDiv.offsetHeight
  },
  close: function() {
    if (this.options.contentWidget) {
      this.options.contentWidget.release()
    }
    currentWindow = null;
    this.options.releaseHandler();
    // FIXME: Why the error?
    try {
      documentRoot().removeChild(this.table)
      this.tab.remove();
    } catch(e) {}
  }
}

function namedWindow(name, createOptions) {
  var t = tabs.findTabNamed(name)
  if (!t || !t.options.window) { 
    var o = createOptions() 
    o.name = name
    return new PWindow(o)
  }
  tabs.activateTab(t)
  return t.options.window
}

;

// /8::/202::/frontend:js -> <902> qrcodelib.js 

//---------------------------------------------------------------------
// QRCode for ActionScript
// version 1.0.1
// Copyright (C) Kazuhiko Arase all rights reserved.
//---------------------------------------------------------------------

//---------------------------------------------------------------------
// QR8bitByte
//---------------------------------------------------------------------

function QR8bitByte(data) {
    this.mode = QRMode.MODE_8BIT_BYTE;
    this.data = data;
}

QR8bitByte.prototype = {

    getLength : function(buffer) {
        return this.data.length;
    },
    
    write : function(buffer) {
        for (var i = 0; i < this.data.length; i++) {
            // not JIS ...
            buffer.put(this.data.charCodeAt(i), 8);
        }
    }
};

//---------------------------------------------------------------------
// QRCode
//---------------------------------------------------------------------

function QRCode(typeNumber, errorCorrectLevel) {
    this.typeNumber = typeNumber;
    this.errorCorrectLevel = errorCorrectLevel;
    this.modules = null;
    this.moduleCount = 0;
    this.dataCache = null;
    this.dataList = { length  : 0 };
}

QRCode.prototype = {
    
    addData : function(data) {
        var newData = new QR8bitByte(data);
        this.dataList[this.dataList.length++] = newData;
        this.dataCache = null;
    },
    
    isDark : function(row, col) {
        if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
            throw new Error(row + "," + col);
        }
        return this.modules[row][col];
    },

    getModuleCount : function() {
        return this.moduleCount;
    },
    
    make : function() {
        this.makeImpl(false, this.getBestMaskPattern() );
    },
    
    makeImpl : function(test, maskPattern) {
        
        this.moduleCount = this.typeNumber * 4 + 17;
        this.modules = { length : this.moduleCount };
        
        for (var row = 0; row < this.moduleCount; row++) {
            
            this.modules[row] = { length : this.moduleCount };
            
            for (var col = 0; col < this.moduleCount; col++) {
                this.modules[row][col] = null;//(col + row) % 3;
            }
        }
    
        this.setupPositionProbePattern(0, 0);
        this.setupPositionProbePattern(this.moduleCount - 7, 0);
        this.setupPositionProbePattern(0, this.moduleCount - 7);
        this.setupPositionAdjustPattern();
        this.setupTimingPattern();
        this.setupTypeInfo(test, maskPattern);
        
        if (this.typeNumber >= 7) {
            this.setupTypeNumber(test);
        }
    
        if (this.dataCache == null) {
            this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
        }
    
        this.mapData(this.dataCache, maskPattern);
    },

    setupPositionProbePattern : function(row, col)  {
        
        for (var r = -1; r <= 7; r++) {
            
            if (row + r <= -1 || this.moduleCount <= row + r) continue;
            
            for (var c = -1; c <= 7; c++) {
                
                if (col + c <= -1 || this.moduleCount <= col + c) continue;
                
                if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
                        || (0 <= c && c <= 6 && (r == 0 || r == 6) )
                        || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
                    this.modules[row + r][col + c] = true;
                } else {
                    this.modules[row + r][col + c] = false;
                }
            }        
        }        
    },
    
    getBestMaskPattern : function() {
    
        var minLostPoint = 0;
        var pattern = 0;
    
        for (var i = 0; i < 8; i++) {
            
            this.makeImpl(true, i);
    
            var lostPoint = QRUtil.getLostPoint(this);
    
            if (i == 0 || minLostPoint >  lostPoint) {
                minLostPoint = lostPoint;
                pattern = i;
            }
        }
    
        return pattern;
    },
    
    createMovieClip : function(target_mc, instance_name, depth) {
    
        var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
        var cs = 1;
    
        this.make();

        for (var row = 0; row < this.modules.length; row++) {
            
            var y = row * cs;
            
            for (var col = 0; col < this.modules[row].length; col++) {
    
                var x = col * cs;
                var dark = this.modules[row][col];
            
                if (dark) {
                    qr_mc.beginFill(0, 100);
                    qr_mc.moveTo(x, y);
                    qr_mc.lineTo(x + cs, y);
                    qr_mc.lineTo(x + cs, y + cs);
                    qr_mc.lineTo(x, y + cs);
                    qr_mc.endFill();
                }
            }
        }
        
        return qr_mc;
    },

    setupTimingPattern : function() {
        
        for (var r = 8; r < this.moduleCount - 8; r++) {
            if (this.modules[r][6] != null) {
                continue;
            }
            this.modules[r][6] = (r % 2 == 0);
        }
    
        for (var c = 8; c < this.moduleCount - 8; c++) {
            if (this.modules[6][c] != null) {
                continue;
            }
            this.modules[6][c] = (c % 2 == 0);
        }
    },
    
    setupPositionAdjustPattern : function() {
    
        var pos = QRUtil.getPatternPosition(this.typeNumber);
        
        for (var i = 0; i < pos.length; i++) {
        
            for (var j = 0; j < pos.length; j++) {
            
                var row = pos[i];
                var col = pos[j];
                
                if (this.modules[row][col] != null) {
                    continue;
                }
                
                for (var r = -2; r <= 2; r++) {
                
                    for (var c = -2; c <= 2; c++) {
                    
                        if (r == -2 || r == 2 || c == -2 || c == 2 
                                || (r == 0 && c == 0) ) {
                            this.modules[row + r][col + c] = true;
                        } else {
                            this.modules[row + r][col + c] = false;
                        }
                    }
                }
            }
        }
    },
    
    setupTypeNumber : function(test) {
    
        var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
    
        for (var i = 0; i < 18; i++) {
            var mod = (!test && ( (bits >> i) & 1) == 1);
            this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
        }
    
        for (var i = 0; i < 18; i++) {
            var mod = (!test && ( (bits >> i) & 1) == 1);
            this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
        }
    },
    
    setupTypeInfo : function(test, maskPattern) {
    
        var data = (this.errorCorrectLevel << 3) | maskPattern;
        var bits = QRUtil.getBCHTypeInfo(data);
    
        // vertical        
        for (var i = 0; i < 15; i++) {
    
            var mod = (!test && ( (bits >> i) & 1) == 1);
    
            if (i < 6) {
                this.modules[i][8] = mod;
            } else if (i < 8) {
                this.modules[i + 1][8] = mod;
            } else {
                this.modules[this.moduleCount - 15 + i][8] = mod;
            }
        }
    
        // horizontal
        for (var i = 0; i < 15; i++) {
    
            var mod = (!test && ( (bits >> i) & 1) == 1);
            
            if (i < 8) {
                this.modules[8][this.moduleCount - i - 1] = mod;
            } else if (i < 9) {
                this.modules[8][15 - i - 1 + 1] = mod;
            } else {
                this.modules[8][15 - i - 1] = mod;
            }
        }
    
        // fixed module
        this.modules[this.moduleCount - 8][8] = (!test);
    
    },
    
    mapData : function(data, maskPattern) {
        
        var inc = -1;
        var row = this.moduleCount - 1;
        var bitIndex = 7;
        var byteIndex = 0;
        
        for (var col = this.moduleCount - 1; col > 0; col -= 2) {
    
            if (col == 6) col--;
    
            while (true) {
    
                for (var c = 0; c < 2; c++) {
                    
                    if (this.modules[row][col - c] == null) {
                        
                        var dark = false;
    
                        if (byteIndex < data.length) {
                            dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
                        }
    
                        var mask = QRUtil.getMask(maskPattern, row, col - c);
    
                        if (mask) {
                            dark = !dark;
                        }
                        
                        this.modules[row][col - c] = dark;
                        bitIndex--;
    
                        if (bitIndex == -1) {
                            byteIndex++;
                            bitIndex = 7;
                        }
                    }
                }
                                
                row += inc;
    
                if (row < 0 || this.moduleCount <= row) {
                    row -= inc;
                    inc = -inc;
                    break;
                }
            }
        }
        
    }

};

QRCode.PAD0 = 0xEC;
QRCode.PAD1 = 0x11;

QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
    
    var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
    
    var buffer = new QRBitBuffer();
    
    for (var i = 0; i < dataList.length; i++) {
        var data = dataList[i];
        buffer.put(data.mode, 4);
        buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) );
        data.write(buffer);
    }

    // Å‘åƒf[ƒ^”‚ðŒvŽZ
    var totalDataCount = 0;
    for (var i = 0; i < rsBlocks.length; i++) {
        totalDataCount += rsBlocks[i].dataCount;
    }

    if (buffer.getLengthInBits() > totalDataCount * 8) {
        throw new Error("code length overflow. ("
            + buffer.getLengthInBits()
            + ">"
            +  totalDataCount * 8
            + ")");
    }

    // I’[ƒR[ƒh
    if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
        buffer.put(0, 4);
    }

    // padding
    while (buffer.getLengthInBits() % 8 != 0) {
        buffer.putBit(false);
    }

    // padding
    while (true) {
        
        if (buffer.getLengthInBits() >= totalDataCount * 8) {
            break;
        }
        buffer.put(QRCode.PAD0, 8);
        
        if (buffer.getLengthInBits() >= totalDataCount * 8) {
            break;
        }
        buffer.put(QRCode.PAD1, 8);
    }

    return QRCode.createBytes(buffer, rsBlocks);
}

QRCode.createBytes = function(buffer, rsBlocks) {

    var offset = 0;
    
    var maxDcCount = 0;
    var maxEcCount = 0;
    
    var dcdata = { length : rsBlocks.length };
    var ecdata = { length : rsBlocks.length };
    
    for (var r = 0; r < rsBlocks.length; r++) {

        var dcCount = rsBlocks[r].dataCount;
        var ecCount = rsBlocks[r].totalCount - dcCount;

        maxDcCount = Math.max(maxDcCount, dcCount);
        maxEcCount = Math.max(maxEcCount, ecCount);
        
        dcdata[r] = { length : dcCount };
        
        for (var i = 0; i < dcdata[r].length; i++) {
            dcdata[r][i] = 0xff & buffer.buffer[i + offset];
        }
        offset += dcCount;
        
        var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
        var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);

        var modPoly = rawPoly.mod(rsPoly);
        ecdata[r] = { length : rsPoly.getLength() - 1 };
        for (var i = 0; i < ecdata[r].length; i++) {
            var modIndex = i + modPoly.getLength() - ecdata[r].length;
            ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
        }

    }
    
    var totalCodeCount = 0;
    for (var i = 0; i < rsBlocks.length; i++) {
        totalCodeCount += rsBlocks[i].totalCount;
    }

    var data = { length : totalCodeCount };
    var index = 0;

    for (var i = 0; i < maxDcCount; i++) {
        for (var r = 0; r < rsBlocks.length; r++) {
            if (i < dcdata[r].length) {
                data[index++] = dcdata[r][i];
            }
        }
    }

    for (var i = 0; i < maxEcCount; i++) {
        for (var r = 0; r < rsBlocks.length; r++) {
            if (i < ecdata[r].length) {
                data[index++] = ecdata[r][i];
            }
        }
    }

    return data;

}

/* -------------------------------------------------------------------- *
 *
 * QRMode
 *
 * -------------------------------------------------------------------- */
 
var QRMode = {
    MODE_NUMBER :        1 << 0,
    MODE_ALPHA_NUM :     1 << 1,
    MODE_8BIT_BYTE :     1 << 2,
    MODE_KANJI :        1 << 3
};
//---------------------------------------------------------------------
//
//---------------------------------------------------------------------
 
var QRErrorCorrectLevel = {
    L : 1,
    M : 0,
    Q : 3,
    H : 2
};

//---------------------------------------------------------------------
//
//---------------------------------------------------------------------

var QRMaskPattern = {
    PATTERN000 : 0,
    PATTERN001 : 1,
    PATTERN010 : 2,
    PATTERN011 : 3,
    PATTERN100 : 4,
    PATTERN101 : 5,
    PATTERN110 : 6,
    PATTERN111 : 7
};

//---------------------------------------------------------------------
//
//---------------------------------------------------------------------
 
var QRUtil = {

    PATTERN_POSITION_TABLE : [
        [],
        [6, 18],
        [6, 22],
        [6, 26],
        [6, 30],
        [6, 34],
        [6, 22, 38],
        [6, 24, 42],
        [6, 26, 46],
        [6, 28, 50],
        [6, 30, 54],        
        [6, 32, 58],
        [6, 34, 62],
        [6, 26, 46, 66],
        [6, 26, 48, 70],
        [6, 26, 50, 74],
        [6, 30, 54, 78],
        [6, 30, 56, 82],
        [6, 30, 58, 86],
        [6, 34, 62, 90],
        [6, 28, 50, 72, 94],
        [6, 26, 50, 74, 98],
        [6, 30, 54, 78, 102],
        [6, 28, 54, 80, 106],
        [6, 32, 58, 84, 110],
        [6, 30, 58, 86, 114],
        [6, 34, 62, 90, 118],
        [6, 26, 50, 74, 98, 122],
        [6, 30, 54, 78, 102, 126],
        [6, 26, 52, 78, 104, 130],
        [6, 30, 56, 82, 108, 134],
        [6, 34, 60, 86, 112, 138],
        [6, 30, 58, 86, 114, 142],
        [6, 34, 62, 90, 118, 146],
        [6, 30, 54, 78, 102, 126, 150],
        [6, 24, 50, 76, 102, 128, 154],
        [6, 28, 54, 80, 106, 132, 158],
        [6, 32, 58, 84, 110, 136, 162],
        [6, 26, 54, 82, 110, 138, 166],
        [6, 30, 58, 86, 114, 142, 170]
    ],

    G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
    G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
    G15_MASK : (1 << 14) | (1 << 12) | (1 << 10)    | (1 << 4) | (1 << 1),

    getBCHTypeInfo : function(data) {
        var d = data << 10;
        while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
            d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) );     
        }
        return ( (data << 10) | d) ^ QRUtil.G15_MASK;
    },

    getBCHTypeNumber : function(data) {
        var d = data << 12;
        while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
            d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) );     
        }
        return (data << 12) | d;
    },

    getBCHDigit : function(data) {

        var digit = 0;

        while (data != 0) {
            digit++;
            data >>>= 1;
        }

        return digit;
    },

    getPatternPosition : function(typeNumber) {
        return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
    },

    getMask : function(maskPattern, i, j) {
        
        switch (maskPattern) {
            
        case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0;
        case QRMaskPattern.PATTERN001 : return i % 2 == 0;
        case QRMaskPattern.PATTERN010 : return j % 3 == 0;
        case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0;
        case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0;
        case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0;
        case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0;
        case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0;

        default :
            throw new Error("bad maskPattern:" + maskPattern);
        }
    },

    getErrorCorrectPolynomial : function(errorCorrectLength) {

        var a = new QRPolynomial([1], 0);

        for (var i = 0; i < errorCorrectLength; i++) {
            a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) );
        }

        return a;
    },

    getLengthInBits : function(mode, type) {

        if (1 <= type && type < 10) {

            // 1 - 9

            switch(mode) {
            case QRMode.MODE_NUMBER     : return 10;
            case QRMode.MODE_ALPHA_NUM     : return 9;
            case QRMode.MODE_8BIT_BYTE    : return 8;
            case QRMode.MODE_KANJI      : return 8;
            default :
                throw new Error("mode:" + mode);
            }

        } else if (type < 27) {

            // 10 - 26

            switch(mode) {
            case QRMode.MODE_NUMBER     : return 12;
            case QRMode.MODE_ALPHA_NUM     : return 11;
            case QRMode.MODE_8BIT_BYTE    : return 16;
            case QRMode.MODE_KANJI      : return 10;
            default :
                throw new Error("mode:" + mode);
            }

        } else if (type < 41) {

            // 27 - 40

            switch(mode) {
            case QRMode.MODE_NUMBER     : return 14;
            case QRMode.MODE_ALPHA_NUM    : return 13;
            case QRMode.MODE_8BIT_BYTE    : return 16;
            case QRMode.MODE_KANJI      : return 12;
            default :
                throw new Error("mode:" + mode);
            }

        } else {
            throw new Error("type:" + type);
        }
    },

    getLostPoint : function(qrCode) {
        
        var moduleCount = qrCode.getModuleCount();
        
        var lostPoint = 0;
        
        // LEVEL1
        
        for (var row = 0; row < moduleCount; row++) {

            for (var col = 0; col < moduleCount; col++) {

                var sameCount = 0;
                var dark = qrCode.isDark(row, col);

                for (var r = -1; r <= 1; r++) {

                    if (row + r < 0 || moduleCount <= row + r) {
                        continue;
                    }

                    for (var c = -1; c <= 1; c++) {

                        if (col + c < 0 || moduleCount <= col + c) {
                            continue;
                        }

                        if (r == 0 && c == 0) {
                            continue;
                        }

                        if (dark == qrCode.isDark(row + r, col + c) ) {
                            sameCount++;
                        }
                    }
                }

                if (sameCount > 5) {
                    lostPoint += (3 + sameCount - 5);
                }
            }
        }

        // LEVEL2

        for (var row = 0; row < moduleCount - 1; row++) {
            for (var col = 0; col < moduleCount - 1; col++) {
                var count = 0;
                if (qrCode.isDark(row,     col    ) ) count++;
                if (qrCode.isDark(row + 1, col    ) ) count++;
                if (qrCode.isDark(row,     col + 1) ) count++;
                if (qrCode.isDark(row + 1, col + 1) ) count++;
                if (count == 0 || count == 4) {
                    lostPoint += 3;
                }
            }
        }

        // LEVEL3

        for (var row = 0; row < moduleCount; row++) {
            for (var col = 0; col < moduleCount - 6; col++) {
                if (qrCode.isDark(row, col)
                        && !qrCode.isDark(row, col + 1)
                        &&  qrCode.isDark(row, col + 2)
                        &&  qrCode.isDark(row, col + 3)
                        &&  qrCode.isDark(row, col + 4)
                        && !qrCode.isDark(row, col + 5)
                        &&  qrCode.isDark(row, col + 6) ) {
                    lostPoint += 40;
                }
            }
        }

        for (var col = 0; col < moduleCount; col++) {
            for (var row = 0; row < moduleCount - 6; row++) {
                if (qrCode.isDark(row, col)
                        && !qrCode.isDark(row + 1, col)
                        &&  qrCode.isDark(row + 2, col)
                        &&  qrCode.isDark(row + 3, col)
                        &&  qrCode.isDark(row + 4, col)
                        && !qrCode.isDark(row + 5, col)
                        &&  qrCode.isDark(row + 6, col) ) {
                    lostPoint += 40;
                }
            }
        }

        // LEVEL4
        
        var darkCount = 0;

        for (var col = 0; col < moduleCount; col++) {
            for (var row = 0; row < moduleCount; row++) {
                if (qrCode.isDark(row, col) ) {
                    darkCount++;
                }
            }
        }
        
        var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
        lostPoint += ratio * 10;

        return lostPoint;        
    }

};


//---------------------------------------------------------------------
//
//---------------------------------------------------------------------

var QRMath = {

    glog : function(n) {
    
        if (n < 1) {
            throw new Error("glog(" + n + ")");
        }
        
        return QRMath.LOG_TABLE[n];
    },
    
    gexp : function(n) {
    
        while (n < 0) {
            n += 255;
        }
    
        while (n >= 256) {
            n -= 255;
        }
    
        return QRMath.EXP_TABLE[n];
    },
    
    EXP_TABLE : { length : 256 },
    
    LOG_TABLE : { length : 256 }

};
    
for (var i = 0; i < 8; i++) {
    QRMath.EXP_TABLE[i] = 1 << i;
}
for (var i = 8; i < 256; i++) {
    QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4]
        ^ QRMath.EXP_TABLE[i - 5]
        ^ QRMath.EXP_TABLE[i - 6]
        ^ QRMath.EXP_TABLE[i - 8];
}
for (var i = 0; i < 255; i++) {
    QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i;
}

//---------------------------------------------------------------------
//
//---------------------------------------------------------------------

function QRPolynomial(num, shift) {

    if (num.length == undefined) {
        throw new Error(num.length + "/" + shift);
    }

    var offset = 0;

    while (offset < num.length && num[offset] == 0) {
        offset++;
    }

    this.num = { length : num.length - offset + shift };
    for (var i = 0; i < num.length - offset; i++) {
        this.num[i] = num[i + offset];
    }
}

QRPolynomial.prototype = {

    get : function(index) {
        return this.num[index];
    },
    
    getLength : function() {
        return this.num.length;
    },
    
    multiply : function(e) {
    
        var num = { length : this.getLength() + e.getLength() - 1 };
    
        for (var i = 0; i < this.getLength(); i++) {
            for (var j = 0; j < e.getLength(); j++) {
                num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) );
            }
        }
    
        return new QRPolynomial(num, 0);
    },
    
    mod : function(e) {
    
        if (this.getLength() - e.getLength() < 0) {
            return this;
        }
    
        var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) );
    
        var num = { length : this.getLength() };
        
        for (var i = 0; i < this.getLength(); i++) {
            num[i] = this.get(i);
        }
        
        for (var i = 0; i < e.getLength(); i++) {
            num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio);
        }
    
        // recursive call
        return new QRPolynomial(num, 0).mod(e);
    }
};

//---------------------------------------------------------------------
//
//---------------------------------------------------------------------

function QRRSBlock(totalCount, dataCount) {
    this.totalCount = totalCount;
    this.dataCount  = dataCount;
}

QRRSBlock.RS_BLOCK_TABLE = [

    // L
    // M
    // Q
    // H

    // 1
    [1, 26, 19],
    [1, 26, 16],
    [1, 26, 13],
    [1, 26, 9],
    
    // 2
    [1, 44, 34],
    [1, 44, 28],
    [1, 44, 22],
    [1, 44, 16],

    // 3
    [1, 70, 55],
    [1, 70, 44],
    [2, 35, 17],
    [2, 35, 13],

    // 4        
    [1, 100, 80],
    [2, 50, 32],
    [2, 50, 24],
    [4, 25, 9],
    
    // 5
    [1, 134, 108],
    [2, 67, 43],
    [2, 33, 15, 2, 34, 16],
    [2, 33, 11, 2, 34, 12],
    
    // 6
    [2, 86, 68],
    [4, 43, 27],
    [4, 43, 19],
    [4, 43, 15],
    
    // 7        
    [2, 98, 78],
    [4, 49, 31],
    [2, 32, 14, 4, 33, 15],
    [4, 39, 13, 1, 40, 14],
    
    // 8
    [2, 121, 97],
    [2, 60, 38, 2, 61, 39],
    [4, 40, 18, 2, 41, 19],
    [4, 40, 14, 2, 41, 15],
    
    // 9
    [2, 146, 116],
    [3, 58, 36, 2, 59, 37],
    [4, 36, 16, 4, 37, 17],
    [4, 36, 12, 4, 37, 13],
    
    // 10        
    [2, 86, 68, 2, 87, 69],
    [4, 69, 43, 1, 70, 44],
    [6, 43, 19, 2, 44, 20],
    [6, 43, 15, 2, 44, 16]

];

QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
    
    var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
    
    if (rsBlock == undefined) {
        throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
    }

    var length = rsBlock.length / 3;
    
    var list = { length : 0 };
    
    for (var i = 0; i < length; i++) {

        var count = rsBlock[i * 3 + 0];
        var totalCount = rsBlock[i * 3 + 1];
        var dataCount  = rsBlock[i * 3 + 2];

        for (var j = 0; j < count; j++) {
            list[list.length++] = new QRRSBlock(totalCount, dataCount);    
        }
    }
    
    return list;
}

QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {

    switch(errorCorrectLevel) {
    case QRErrorCorrectLevel.L :
        return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
    case QRErrorCorrectLevel.M :
        return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
    case QRErrorCorrectLevel.Q :
        return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
    case QRErrorCorrectLevel.H :
        return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
    default :
        return undefined;
    }
}

//---------------------------------------------------------------------
//
//---------------------------------------------------------------------

function QRBitBuffer() {
    this.buffer = { length : 0 };
    this.length = 0;
}

QRBitBuffer.prototype = {

    get : function(index) {
        var bufIndex = Math.floor(index / 8);
        return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
    },
    
    put : function(num, length) {
        for (var i = 0; i < length; i++) {
            this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
        }
    },
    
    getLengthInBits : function() {
        return this.length;
    },
    
    putBit : function(bit) {
    
        var bufIndex = Math.floor(this.length / 8);
        if (this.buffer.length <= bufIndex) {
            this.buffer[this.buffer.length++] = 0;
        }
    
        if (bit) {
            this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) );
        }
    
        this.length++;
    }
};
  
 

;

// /8::/202::/frontend:js -> <912> qrcodewidget.js 

 QRCodeWidget = Class.create();
QRCodeWidget.prototype =
{
    defaultOptions: function(){
        return Object.extend({data:"",mode:8,size:4},arguments[0]);
    },
    makeWidgetContent: function(){
        var qr = new QRCode(this.options.mode, QRErrorCorrectLevel.H);
        qr.addData(this.options.data);
        qr.make();
        var theqrarr = "";
        theqrarr += "<table style='border-width: 0px; border-style: none; border-color: #0000ff; border-collapse: collapse;'>";

        for (var r = 0; r < qr.getModuleCount(); r++) {
            theqrarr +="<tr>";
            for (var c = 0; c < qr.getModuleCount(); c++) {
                if (qr.isDark(r, c) ) {
                    theqrarr += "<td style='border-width: 0px; border-style: none; border-color: #0000ff; border-collapse: collapse; padding: 0; margin: 0; width: "+this.options.size+"px; height: "+this.options.size+"px; background-color: #000000;'/>";

                } else {
                    theqrarr += "<td style='border-width: 0px; border-style: none; border-color: #0000ff; border-collapse: collapse; padding: 0; margin: 0; width: "+this.options.size+"px; height: "+this.options.size+"px; background-color: #ffffff;'/>";
                }
            }
            theqrarr += "</tr>";
        }
        theqrarr +="</table>" ;
        var qrdiv = Builder.node('div',[]);
        qrdiv.innerHTML = theqrarr;
        return qrdiv;
    }, 
    rerender: function(){
        var nc = this.makeWidgetContent();
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    }
 }  
Object.extend(QRCodeWidget.prototype, WidgetCommon); 

 

;

// /8::/202::/frontend:js -> <6276> qsearchwidget.js 

qSearchWidget = Class.create();
var sdm,qswi; 
qSearchWidget.prototype = {
  defaultOptions: function() {
    return {};
  },
  makeWidgetContent: function() {

    Event.observe($("root"),'click',function(){
        if($("qsearchResBox") != null){
            new Effect.BlindUp($("qsearchResBox"));
        }
      }) 

    this.inputbox = Builder.node('input',{
        type:"text",
        id:"qsearchBoxWidgetInput",
        style:"font-weight:bold;z-index:888;padding:2px;padding-right:20px;width:100%;",
        value:"Search (beta)"
      });
 
    Event.observe($(this.inputbox),'focus',function(e){ 
        if($F(this.inputbox) == "Search (beta)"){
            $(this.inputbox).value = "";
        }
    }.bind(this));
 
    qswi = this;
    var searchtext = translateButton({
      path: ".search",
      id: "input",
      node: this.inputbox
    })
    var defaultValue = searchtext.value
    searchtext.onfocus = function(){
      this.value = "";
      if($("qsearchResBox").style.display != "none"){ 
        new Effect.Fade($("qsearchResBox")); 
      } 
    }
    searchtext.onblur = function(){
      if(this.value == ""){ 
        this.value = defaultValue;
      } 
    }
    var results = Builder.node('div',{
      id:"qsearchResBox",
      style:"position:relative;top:0px;left:0px;z-index:9999;overflow:auto;height:300px;display:none;border:1px solid silver;background:#EDEDED;border-bottom:2px double #2FB6DE;width:398px;"
    },[Builder.node('div',{id:"qsearchResBoxInner",style:"overflow:auto;position:relative;top:0px;left:0px;z-index:9999;height:300px;width:398px;"},[TN("results")])]);
    var icon = Builder.node('img',{
      style:"position:absolute;z-index:999;margin-left:-20px;top:6px;",
      width:15,
      height:15,
      src:"/core-services/images/search.gif"
    });

    var theform = Builder.node('form',{style:"position:relative;",action:"",name:"qsearch",id:"qsearch"},[searchtext,icon,results]); 
     var wrapdiv = Builder.node('div',{
      style:"position:absolute;width:175px;left:200px;top:0px;"
    },[theform]);
    theform.onsubmit =function(){   
   
      sdm = new SearchDisplayModel({q:$F("qsearchBoxWidgetInput")});
      sdm.addObserver(qswi); 
      return false;
    }
    return wrapdiv;
  },
  update:function(){  
    this.showResults(sdm);
  },
  showResults:function(sdm){
    removeChildNodes($("qsearchResBoxInner"));
    var arr =  this.processResults(sdm.getModel()); 
    appendChildren($("qsearchResBoxInner"),arr) 
    new Effect.BlindDown($("qsearchResBox")) 
  },
  processResults:function(model){
    var arr = []; 
    model.each(function(m){

      var node = Builder.node('div',{
        style:"padding:5px;width:90%;height:50px;overflow:hidden;cursor:pointer;font-size:10px;"
      },[TN(m.name + " ["+m.display_type+"]")]);
 
      Event.observe(node,'mouseover',function(){
        node.style.fontWeight = "bold";
        node.style.color = "white";
        node.style.background = "#2FB6DE";
      });
      Event.observe(node,'mouseout',function(){
        node.style.fontWeight = ""; 
        node.style.color = "black"; 
        node.style.background = "#EDEDED"; 
      })
      Event.observe(node,'click',function(){
        new Effect.Fade($("qsearchResBox"))  
        $("qsearchBoxWidgetInput").value = m.name;
        qswi.gotoSearch(m);
      }) 

      arr.push(node)               
    })
    return arr;          
  },
  gotoSearch:function(m){
        try{
            itemModel.actions.showItem({m:m});
        }catch(e){
            alert("no renderer found");
        }
    }
}
Object.extend(qSearchWidget.prototype, WidgetCommon);


//temp helper
function removeChildNodes(parent){
 return;
  while(parent.hasChildNodes()){
    parent.removeChild(parent.childNodes[0])
  }
}

;

// /8::/202::/frontend:js -> <866> quicknewswidget.js 

//old?_delete *mike

 
quickNewsWidget = Class.create();
quickNewsWidget.prototype = {
    defaultOptions: function() {
        return Object.extend({max:6,
                id:"quickNewsWidget",
                model:null,
                user:"core",
                service:"articles", 
                controllerName:"articles@core",
                path:"/news",
                style:"padding:5px;height:138px;overflow:auto;",
                action:"-news/"},arguments[0]||{});
    }, 
    afterPathChanged:function(){
        var model = this.options.model.getModel();
        this.initNews(model,this.options);
    }, 
    setup:function(){
        var dm = new DisplayModel({user:this.options.user,reverse:true,sortByColumn:'added_at',controllerName:this.options.controllerName,path:this.options.path});  
        this.options.model = dm;
        dm.addObserver(this);    
    },
    makeWidgetContent: function() { 

        return Builder.node('div',{style:"width:100%,height:100%;"},[Builder.node('div',{id:this.options.id,style:this.options.style},[Builder.node('div',{id:"spinner_"+this.options.id,style:"display:block;"},[Builder.node('img',{src:"/images/spinner.gif"})])])]);
    },
    initNews:function(model,options){
        var thenews  = [];
        model.slice(0,options.max).each(function(i){
            var newsitem = Builder.node('span',{style:"font-size:12px"},[]);
            var name = i.name;   
            var itemlink = serviceLink({user:options.user, service:options.service,controllerName:options.controllerName,action:options.action})

            newsitem.innerHTML = name;
            thenews.push(Builder.node('div',{style:"font-size:10px"},[
                TN("posted"),NBSP(),
                TN(makeNiceDate(i.added_at)),NBSP(),
                Builder.node('a',{href:itemlink+escape(i.pretty_name), target:"_blank",style:"color:black;text-decoration:none;font-weight:bolder;font-size:10px"},[TN("[read more]")]),
                BR(), newsitem, Builder.node('hr',{style:"border:0px;border-bottom:1px dashed silver;"})
           ]))
        });
        window.setTimeout(function(){
            $(options.id).down().remove();
            appendChildren($(options.id),thenews)
        },200);
    },
    rerender: function(){
        var nc = this.makeWidgetContent();
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    } 
}
Object.extend(quickNewsWidget.prototype, WidgetCommon);



;

// /8::/202::/frontend:js -> <154198> ratingwidgetoverride.js 

var __ratingTemplates = null;
FrontRatingWidget = Class.create();
FrontRatingWidget.prototype = {
  defaultOptions: function() {
    return {
      description: null,
      onchange: function(rating) {},
      m: null
    }
  },
  setup: function() {
    this.options.model.addObserver(this)
  },
  voteUp: function(num) {
    return this.vote({img: serviceLink({service:"files@core",user:"core",action:"get_file?path=/vup.png"}), rating: 5, num: num})
  },
  voteDown: function(num) {
    return this.vote({img: serviceLink({service:"files@core",user:"core",action:"get_file?path=/vdown.png"}), rating: 1, num: num})
  },
  vote: function(o) {
    var nt = logged_in ? 'a' : 'span'
    var div = Builder.node(nt, {
      style: "margin-right:10px;color:black;",
      href: "javascript:void(0);return false;"
    }, [table({width: "",cellpadding:0,cellspacing:1}, [
      Builder.node('img', {
        src: o.img,
        style: "border: 0px;",
        title: this.you()
      }),
      TN(o.num)
    ])])
    if (logged_in) {
      Event.observe(div, 'click', function(event) {
        Event.stop(event)
        this.onchange(o.rating)
      }.bindAsEventListener(this))      
    }
    return div
  },
  you: function() {
    if (!logged_in) {
      return "Login to vote!"
    }
    else if (this.options.m.voted) {
      return "You voted!"
    }
    else if (this.options.m.voted == undefined) {
      // Doesn't exist for recent and top rated
      return ""
    }
    else {
      return "You didn't vote, yet!"
    }
  },
  makeWidgetContent: function() {
    var votes = this.votesFromRating()
    var div = Builder.node('div', {style:"font-weight:bolder;"},[table({width:"", cellspacing: 0,cellpadding:0}, [
        TN("Vote"),NBSP(),      
        this.voteUp(votes.up),
        NBSP(),
      this.voteDown(votes.down)
    ])])
    return div
  },
  rerender: function() {
    this.redrawCompletely()
  },
  votesFromRating: function() {
    var m = this.options.m
    var up = Math.floor(((m.rating*m.nr_votes) - m.nr_votes)/4)
    return {
      up: up,
      down: m.nr_votes - up
    }
  },
  onchange: function(rating) {
    var m = this.options.m
    var model = this.options.model
    if (m.item_path) {
      var form_path = m.item_path.gsub(/\/[^/]*$/, "")
    }
    else {
      var form_path = model.currentPath()        
    }
    if (form_path == "") form_path = "/"
    var user = model.user(m.pretty_name)
    if (!model.queryDataAction) user = model.user()
    var dict = {
      form_name: m.pretty_name, 
      form_path: form_path, 
      form_rating: rating,
      form_username_override: user
    }
    if (logged_in) {
      AjaxRequestMixin.ajaxRequest({
        service: m.service,
        user: user,
        action: "vote",
        onSuccess: function(success) {
          m = hash_merge(m, success)
          model.update();
        }
      }, dict)        
    }
    else {
      verify(
        function() {},
        "You need to be logged in to vote!",
        {cancelButton: false}
      )
    }
  }
}

Object.extend(FrontRatingWidget.prototype, WidgetCommon)
 
;

// /8::/202::/frontend:js -> <9107> readuserbadgewidget.js 

ReadUserBadgeWidget = Class.create()
ReadUserBadgeWidget.prototype = {
  defaultOptions: function(){
    return {
      profile: readUserModel,
      type:    "left",
      style:   "width:100%;height:158px;font-size:140%;"
    };
  },
  addBuddyNode: function() {
    return Builder.node('div', [
      (new addBuddyWidget({user:this.getUserModel().user}).htmlNode())
    ]);
  },
  sendMessage: function() {
    var node = Builder.node('div', {
      style: "font-size:80%;text-decoration:none;color:black;cursor:pointer;"
    })
    if (itemModel.service() != "modules@core") {
      new UserMessages({
        user: this.options.profile.data.username,
        afterLoad: function(um) {
          if (um.canSendMessage()) {
            node.innerHTML = "send message"
            Event.observe(node, 'click', function(event) {
              new ThemedWindow({
                title:       "Send message",
                minimizable: false,
                maximizable: false,
                width: 400,
                height: 300
              }, function(win) {
                var form = Builder.node('form', [
                  TN("Message: "),
                  BR(),
                  Builder.node('textarea', {
                    name: "message",
                    style: "width:390px;height:200px;"
                  }),
                  BR(),
                  Builder.node('input', {type: "submit", value: "Send"})
                ])
                Event.observe(form, 'submit', function(event) {
                  Event.stop(event)
                  var form = Event.element(event)
                  if (form.tagName != "FORM") {
                    form = Element.up(form, 'form')
                  }
                  var text = form.message.value
                  if (text != "") {
                    um.sendMessage(text)
                  }
                  win.close()
                }.bindAsEventListener(this))
                win.setContent(form)
                win.showCenter()
              })
            }.bindAsEventListener(this))
          }
        }
      })      
    }
    return node
  },
  loginViewUpper: function() {
    return this.upperView()
  },
  loginViewLower: function() {
    return this.lowerView()
  },
  upperView: function() {
    var csw = new changeSiteWidget({
      profile: this.options.profile,
      text:this.getUserModel().user,
      style:"font-weight:bolder;font-size:120%;color:black;"
    })
    Element.setStyle(this.userPic(), {
      cursor: "pointer",
      float:  "left",
      marginRight: "5px"
    })
    var upper = table({
      style:"font-size:110%;font-weight: bolder;"
    }, [{columnOptions: { height:63 }, columnData:[
      this.userPic(),
      csw.htmlNode(),
      this.addBuddyNode(),
      this.sendMessage()
    ]}]);
    Element.observe(this.userPic(), 'click', function() {
      csw.onclick()
    })
    return upper;
  },
  lowerView: function() {
    var lower = table([
      {columnOptions:{width:"90%",height:30},columnData:[NBSP()]},
      {columnOptions:{width:"10%",height:30,id:"leftBtn"},columnData:[NBSP()]}
    ]);
    return lower;
  },
  mainView: function(innertable, phrasebox) {
    var maintable = table({cellspacing:0,border:0,cellpadding:0,vAlign:"top",border:0},
      [{columnOptions:{width:"100%",height:63,vAlign:"top"},columnData:[innertable]}]
    );
    return maintable;
  },
  phraseStyle: function() {
    return {height: "68px"}
  },
  phraseBoxStyle: function() {
    return {left:"5px",top:"-32px", width: "95%"}
  }
}

Object.extend(ReadUserBadgeWidget.prototype, BadgeWidget)

;

// /8::/202::/frontend:js -> <152852> recentitemswidget.js 

var dhtmlHistory_created = false; 

var __theRecentItemTemplate;  
  
RecentItemsWidget = Class.create();
RecentItemsWidget.prototype =
{
    defaultOptions: function()
    {
        return {
            mode:"recent_json",
            user:"team",
            service:"diaries@core",
            displayItemClicked:null,
            displayFolderClicked:function(model,folder){ 

 
                model.changeToFolder(model.currentPath()+folder.pretty_name);
                return false; 
            },
            history:false,
            model: null,
            autoscroll:false,
            icon:false,
            iconsize:"55px",
            onLoad:function(){return true;},
            scrollstep:3,
            scrollduration:10, 
            height:"200px",
            n:8,
            itemheight:"60px",
            actions:true 
        };
    },
    setup:function(){ 
        this.nodes = [Builder.node('img',{src:"/images/spinner.gif"})]; 
        this.currentModel = null;

 
        this.initHistory();
        this.rss =Builder.node('a',{rel:"nofollow",target:"_blank",href:"http:\/\/"+this.options.user+".mysites.com/"+this.options.service+"@core/recent_rss",style:"color:black;"},[Builder.node('img',{style:"margin:2px;",src:"http:\/\/core.myfil.es/get_file?path=/rss.png",width:12,height:12,border:0})]);  
        this.reload =Builder.node('a',{rel:"nofollow",target:"_self",href:"javascript:void(0);",style:"color:black;"},[Builder.node('img',{style:"margin:2px;",src:"http:\/\/core.myfil.es/get_file?path=/rel.png",width:12,height:12,border:0})]);   

        Event.observe(this.reload,'click',function(){
            this.getDataAndRender();
        }.bind(this));
 
        this.template = this.contentTemplate(); 

        if(this.options.model != null){
            this.currentModel = this.options.model;
            this.nodes = this.renderItems(this.currentModel);

            if (this.options.autoscroll == true){ 
                this.autoscroll();
            } 
            this.options.onLoad(); 
  
        }else{
            this.getDataAndRender(); 
        }     
     
    }, 
    initHistory:function(){
        if(this.options.history == true && dhtmlHistory_created != true){
            dhtmlHistory_created = true;
            window.dhtmlHistory.create({
                toJSON: function(o) {
                    return JSON.toJSON(o);
                }, 
                fromJSON: function(s) {
                    return JSON.parseJSON(s);
                }
            });
            var hListener = function(newLocation, historyData) {
                try{
                    var itm = this.currentModel.findItemByPrettyName(historyData);
                    if(itm != null){ 
                        Windows.closeAll()
                        this.handleClick(itm);
                    }
                }catch(e){}
            }.bind(this);

            dhtmlHistory.initialize();
            dhtmlHistory.addListener(hListener);
        }  
  
    },
    fillTemplate:function(n,users,idx){  
        var thumbnail = "";
        var body = "";
        var permalink = "";
        var name = "";
        var user = users[n.account_id];
        n.user = user.username; 

        if(user.userimage != undefined){
            thumbnail = user.userimage; 
        }
        if(this.options.icon == true && n.thumbnail_image_url != undefined){
            thumbnail =n.thumbnail_image_url;
        };
        if(n.body != undefined){
            body = n.body; 
            body = body.replace(/(<([^>]+)>)/ig,"") 
            if(body.length > 50){
                body = body.substr(0,50);
            }
        } 
        var aid = "c_"+this.options.service+"_"+n.id;
        name = n.name;
        if(name.length > 15){
            var name = name.substr(0,25)+" ...";
        }
 
        if(n.item_path != undefined){ 
            permalink = serviceLink({user:n.user,service:n.service,action:"-"+n.item_path.substr(1,n.item_path.length)})
        }else{
            permalink = serviceLink({user:n.user,service:this.currentModel.service(),action:"-"+n.pretty_name})
        }

        //text-stuff here
        var opts = {
            id:n.id,
            aid:aid,
            position:idx, 
            user:user.username,
            thumbnail:thumbnail,
            body:body,
            permalink:permalink
        }   

        //clickable stuff..buttons and actions here
        var namelink = Builder.node('a',{href:"javascript:void(0);",style:"color:black;"},[Builder.node('span',[TN(name)])]);
        Event.observe(namelink,'click',function(e){
            //e.preventDefault();
            Event.stop(e);
            window.open(permalink)
        });

        var userlink = Builder.node('a',{href:"javascript:void(0);",style:"color:black;"},[Builder.node('span',[TN(n.user)])])
        Event.observe(userlink,'click',function(e){
            //e.preventDefault();
            Event.stop(e);
            window.open("http:\/\/"+n.user+".mysites.com");
        });
  
        if(n.type != "folder" ){ 
            var actionbox = Builder.node('div',{style:"border-left:1px solid silver;width:100%;height:100%;padding-left:5px;background:transparent;font-size:10px;"},[
                new FrontSaveAndShareWidget({shortText:true,item:n,model:this.currentModel}).htmlNode(),
                new CommentsWidget({m: n,model: this.currentModel}).htmlNode(),
                new FrontRatingWidget({model:this.currentModel,m:n}).htmlNode() 
            ]);
        }else{
  
            var actionbox = EMPTY();
        }
        var nr = this.template.makeNodeAndReferences(opts);
        nr.references.actions.appendChild(actionbox);
        nr.references.date.appendChild(makeNiceDate(n.added_at));
        nr.references.namelink.appendChild(namelink);
        nr.references.userlink.appendChild(userlink);

        return nr.node;
    },
    contentTemplate:function(){  
        //prepare general template, which will be duplicated an filled
        var w = this.options.iconsize.replace("px","");
        var h = w;
        var img = Builder.node('div',{style:"width:"+this.options.iconsize+";height:"+this.options.iconsize+";border:1px solid silver;"},[Builder.node('img',{src:"template:value_of thumbnail",width:w,height:h})]);
        var leftimg = EMPTY();
        var more = EMPTY();
        if (this.options.icon == true){
            leftimg =Builder.node('div',{style:"margin-right:10px;width:"+this.options.iconsize+";float:left;"},[img])
        }
        if(this.options.service == "diaries@core"){
            more = Builder.node('a',{rel:"nofollow",target:"_blank",href:"template:value_of permalink",style:"color:black;"},[TN("...")])
        }   
 
        var divv = Builder.node('div',{className:"default_itementry",id:"template:value_of id",style:"width:97%;height:"+this.options.itemheight+";margin-bottom:3px;padding:2px;border-bottom:1px solid silver;border-top:1px solid silver;font-size:70%;background:transparent;"},[
            leftimg,
            Builder.node('div',{style:"width:96%;float:left;text-align:left;"},[
                Builder.node('div',{id:"template:reference_as namelink",style:"height:15px;font-size:12px;font-weight:bolder;"},[
                               
                ]), 
                Builder.node('div',{style:"height:12px;line-height:15px;font-size:9px;"},[
                    translateText({path: ".recent-widget", id:"posted"}),
                    NBSP(),
                    Builder.node('span',{id:"template:reference_as date"},[]),
                    NBSP(),
                    translateText({path: ".recent-widget", id: "by"}),
                    NBSP(),
                    Builder.node('span',{id:"template:reference_as userlink",style:"color:black;"},[
            
                    ])
                ]),
                Builder.node('div',{style:"height:12px;line-height:15px;font-size:11px;"},[
                    TN("template:value_of body"),NBSP(),more
                ])
            ]),
            Builder.node('div',{id:"template:value_of aid",style:"position:relative;left:0px;display:none;width:85px;height:"+this.options.itemheight+";float:right;"},[ 
                Builder.node('div',{id:"template:reference_as actions",style:"width:100%;height:100%;background:transparent;"})
            ]),
            Builder.node('BR',{style:"clear:both;"})  
        ])
        return new MSTemplate({create: function(){return divv;}}) ; 
    }, 
    getDataAndRender:function(){  
        var obs = {}; 
        obs.update = function(e){   

/*

        if(this.options.includebuddies){
            this.options.buddiesmodel = new RecentBuddyDisplayModel({service:this.options.service,user:this.options.user,n:this.options.n}); 
            var buobs = {}; 
            buobs.update = function(e){ 
                var oldnodes = this.nodes;
                this.nodes = this.renderItems(this.options.buddiesmodel).concat(oldnodes);                     
                this.rerender(); 
            }.bind(this);  
            this.options.buddiesmodel.addObserver(buobs); 
        }
*/     
            this.nodes = this.renderItems(this.currentModel);
            if (this.options.autoscroll == true){ 
                this.autoscroll();
            } 
            this.options.onLoad();              
            this.rerender(); 
        }.bind(this)

 
        if(this.options.mode == "recent_json"){
            this.currentModel = new RecentDisplayModel({service:this.options.service,user:this.options.user,n:this.options.n}); 
        }else if(this.options.mode == "model"){
            this.currentModel = new DisplayModel({path:"/",service:this.options.service,user:this.options.user,n:this.options.n});   
        } else{
            alert("mode problem");
        }
        this.currentModel.addObserver(obs);      
    },
    update:function(e){
    },
    makeWidgetContent: function(){
        this.statuscontainer = Builder.node('div',{style:"width:100%;height:25px;background:transparent;"},[]); 
        this.pathw = new PathWidget ({model:this.currentModel});
        this.statuscontainer.appendChild(this.pathw.htmlNode());
 
        var statarr = [this.statuscontainer];
        this.allnodes = statarr.concat(this.nodes);
        var currentTime = new Date();
        this.id = "super_"+currentTime.getTime();
 
        this.container = Builder.node('div',{id:this.id,style:"width:99%;height:"+this.options.height+";overflow:auto;background:transparent;text-align:left;"},this.allnodes);
        return this.container;
    }, 
    autoscroll:function(){
        this.autoscrollid = 0;
        var fun = function(){
            this.moveTo(this.nodes[this.autoscrollid].id);            
            this.autoscrollid += this.options.scrollstep;
            if(this.autoscrollid>this.nodes.length-1){
                this.autoscrollid = 0;
            }
        }.bind(this);
        this.pe = new PeriodicalExecuter(fun,this.options.scrollduration) 
    },
    moveTo:function(element){
        this.nodes.each(function(node){
            $(node).setStyle({backgroundColor:"transparent"})
        });
        Position.prepare();
        container = this.container;
        container_y = Position.cumulativeOffset($(container))[1]
        element_y = Position.cumulativeOffset($(element))[1] 
        $(element).setStyle({backgroundColor:"#ECECEC"}); 
        new Effect.Scroll(container, {x:0, y:(element_y-container_y)});
        return false;
    },
    renderItemInfoBox:function(){
        var nodes = [];
        this.typeList.each(function(pair){
            var typenode = Builder.node('div',{style:""},[TN(pair.key),TN(" ("+pair.value+")")]);
            nodes.push(typenode);
        });
        return Builder.node('div',{id:"itemInfoBox"},nodes);
    },
    renderItems:function(model){

        //we want the model.. so get all data, not only items
        if(this.options.mode == "model"){
            var be = model.sortedModel();
        }else{
            var be = model.displayItems();
        }
        var users = model.users();
        var inner = [];
        this.typeList = new Hash({});
 
        $(be).each(function(n,idx){ 
            //fill typelist with types found on iterating the items
            if(this.typeList[n.type] == undefined){
                this.typeList[n.type] = 0;
            }
            this.typeList[n.type] = this.typeList[n.type] +1;  
  
            var divv = this.fillTemplate(n,users,idx); 
            divv.id = n.id;
            divv.pos = idx ;
            divv.type = n.type;
            Event.observe(divv,'mouseover',function(e){
                $(divv).setStyle({background:"#F5F5F5"});
                if(this.options.actions){        
                    $("c_"+this.options.service+"_"+divv.id).show();
                }
                if(this.pe && this.options.autoscroll){
                    this.pe.stop();
                }
            }.bind(this));
            Event.observe(divv,'mouseout',function(e){  
                $(divv).setStyle({background:"transparent"});
                if(this.options.actions){        
                    $("c_"+this.options.service+"_"+divv.id).hide();
                }
                if(this.options.autoscroll){
                    this.autoscroll();
                }
            }.bind(this));
            Event.observe(divv,'click',function(e){ 
                Event.stop(e);
                //if (this.options.autoscroll == true){ 
                //    this.moveTo(divv.id);
                //    this.autoscrollid = divv.pos;
                //}

                if(n.type == "folder"){
                    //this.moveTo(divv.id);
                    Effect.SlideRightOut($(divv.parentNode),{afterFinish:function(){
                        this.handleClick(n);
                    }.bind(this)});
                }else{
                    this.handleClick(n);
                }
            }.bind(this)); 
            inner.push(divv);  
        }.bind(this))
        return inner; 

    },
    handleClick:function(n){
        if(this.options.history == true && window.dhtmlHistory != null){
            window.dhtmlHistory.add(n.pretty_name,n.pretty_name);
        }
        if(n.type == "folder"){
            this.options.displayFolderClicked(this.currentModel,n);
        }else{
            if(this.options.displayItemClicked != null){
                this.options.displayItemClicked(n);
            }
        }

    },
    IsImageOk:function(img) {
        if (!img.complete) {
            return false;
        }
        if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
            return false;
        }
        return true;
    },
    checkImages:function() {
        var allimg = $$("#"+this.id + " img");
        for (var i = 0; i < allimg.length-1; i++) {
            if (!this.IsImageOk(allimg[i])) {
                allimg[i].src = serviceLink({user:"core",service:"files@core",action:"get_file?path=/error-icon.png"});
            }
        }
    },
    rerender: function(){
        var nc = this.makeWidgetContent();  
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
        setTimeout(function(){
            this.checkImages(); 
        }.bind(this),10000);
        if(this.options.displayItemClicked != null){
            //Effect.SlideLeftIn($(nc),{duration:3});
             Effect.Appear($(nc),{duration:3});
        }
    }
}
Object.extend(RecentItemsWidget.prototype, WidgetCommon);
 
;

// /8::/202::/frontend:js -> <154337> rsh.js 

/*
Copyright (c) 2007 Brian Dillard and Brad Neuberg:
Brian Dillard | Project Lead | bdillard@pathf.com | http://blogs.pathf.com/agileajax/
Brad Neuberg | Original Project Creator | http://codinginparadise.org
   
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
    dhtmlHistory: An object that provides history, history data, and bookmarking for DHTML and Ajax applications.
    
    dependencies:
        * the historyStorage object included in this file.

*/
window.dhtmlHistory = {
    
    /*Public: User-agent booleans*/
    isIE: false,
    isOpera: false,
    isSafari: false,
    isKonquerer: false,
    isGecko: false,
    isSupported: false,
    
    /*Public: Create the DHTML history infrastructure*/
    create: function(options) {
        
        /*
            options - object to store initialization parameters
            options.debugMode - boolean that causes hidden form fields to be shown for development purposes.
            options.toJSON - function to override default JSON stringifier
            options.fromJSON - function to override default JSON parser
        */

        var that = this;

        /*set user-agent flags*/
        var UA = navigator.userAgent.toLowerCase();
        var platform = navigator.platform.toLowerCase();
        var vendor = navigator.vendor || "";
        if (vendor === "KDE") {
            this.isKonqueror = true;
            this.isSupported = false;
        } else if (typeof window.opera !== "undefined") {
            this.isOpera = true;
            this.isSupported = true;
        } else if (typeof document.all !== "undefined") {
            this.isIE = true;
            this.isSupported = true;
        } else if (vendor.indexOf("Apple Computer, Inc.") > -1) {
            this.isSafari = true;
            this.isSupported = (platform.indexOf("mac") > -1);
        } else if (UA.indexOf("gecko") != -1) {
            this.isGecko = true;
            this.isSupported = true;
        }

        /*Set up the historyStorage object; pass in init parameters*/
        window.historyStorage.setup(options);

        /*Execute browser-specific setup methods*/
        if (this.isSafari) {
            this.createSafari();
        } else if (this.isOpera) {
            this.createOpera();
        }
        
        /*Get our initial location*/
        var initialHash = this.getCurrentLocation();

        /*Save it as our current location*/
        this.currentLocation = initialHash;

        /*Now that we have a hash, create IE-specific code*/
        if (this.isIE) {
            this.createIE(initialHash);
        }

        /*Add an unload listener for the page; this is needed for FF 1.5+ because this browser caches all dynamic updates to the
        page, which can break some of our logic related to testing whether this is the first instance a page has loaded or whether
        it is being pulled from the cache*/

        var unloadHandler = function() {
            that.firstLoad = null;
        };
        
        this.addEventListener(window,'unload',unloadHandler);        

        /*Determine if this is our first page load; for IE, we do this in this.iframeLoaded(), which is fired on pageload. We do it
        there because we have no historyStorage at this point, which only exists after the page is finished loading in IE*/
        if (this.isIE) {
            /*The iframe will get loaded on page load, and we want to ignore this fact*/
            this.ignoreLocationChange = true;
        } else {
            if (!historyStorage.hasKey(this.PAGELOADEDSTRING)) {
                /*This is our first page load, so ignore the location change and add our special history entry*/
                this.ignoreLocationChange = true;
                this.firstLoad = true;
                historyStorage.put(this.PAGELOADEDSTRING, true);
            } else {
                /*This isn't our first page load, so indicate that we want to pay attention to this location change*/
                this.ignoreLocationChange = false;
                /*For browsers other than IE, fire a history change event; on IE, the event will be thrown automatically when its
                hidden iframe reloads on page load. Unfortunately, we don't have any listeners yet; indicate that we want to fire
                an event when a listener is added.*/
                this.fireOnNewListener = true;
            }
        }

        /*Other browsers can use a location handler that checks at regular intervals as their primary mechanism; we use it for IE as
        well to handle an important edge case; see checkLocation() for details*/
        var locationHandler = function() {
            that.checkLocation();
        };
        setInterval(locationHandler, 100);
    },    
    
    /*Public: Initialize our DHTML history. You must call this after the page is finished loading.*/
    initialize: function() {
        /*IE needs to be explicitly initialized. IE doesn't autofill form data until the page is finished loading, so we have to wait*/
        if (this.isIE) {
            /*If this is the first time this page has loaded*/
            if (!historyStorage.hasKey(this.PAGELOADEDSTRING)) {
                /*For IE, we do this in initialize(); for other browsers, we do it in create()*/
                this.fireOnNewListener = false;
                this.firstLoad = true;
                historyStorage.put(this.PAGELOADEDSTRING, true);
            }
            /*Else if this is a fake onload event*/
            else {
                this.fireOnNewListener = true;
                this.firstLoad = false;   
            }
        }
    },

    /*Public: Adds a history change listener. Note that only one listener is supported at this time.*/
    addListener: function(listener) {
        this.listener = listener;
        /*If the page was just loaded and we should not ignore it, fire an event to our new listener now*/
        if (this.fireOnNewListener) {
            this.fireHistoryEvent(this.currentLocation);
            this.fireOnNewListener = false;
        }
    },
    
    /*Public: Generic utility function for attaching events*/
    addEventListener: function(o,e,l) {
        if (o.addEventListener) {
            o.addEventListener(e,l,false);
        } else if (o.attachEvent) {
            o.attachEvent('on'+e,function() {
                l(window.event);
            });
        }
    },
    
    /*Public: Add a history point.*/
    add: function(newLocation, historyData) {
        
        if (this.isSafari) {
            
            /*Remove any leading hash symbols on newLocation*/
            newLocation = this.removeHash(newLocation);

            /*Store the history data into history storage*/
            historyStorage.put(newLocation, historyData);

            /*Save this as our current location*/
            this.currentLocation = newLocation;
    
            /*Change the browser location*/
            window.location.hash = newLocation;
        
            /*Save this to the Safari form field*/
            this.putSafariState(newLocation);

        } else {
            
            /*Most browsers require that we wait a certain amount of time before changing the location, such
            as 200 MS; rather than forcing external callers to use window.setTimeout to account for this,
            we internally handle it by putting requests in a queue.*/
            var that = this;
            var addImpl = function() {

                /*Indicate that the current wait time is now less*/
                if (that.currentWaitTime > 0) {
                    that.currentWaitTime = that.currentWaitTime - that.waitTime;
                }
            
                /*Remove any leading hash symbols on newLocation*/
                newLocation = that.removeHash(newLocation);

                /*IE has a strange bug; if the newLocation is the same as _any_ preexisting id in the
                document, then the history action gets recorded twice; throw a programmer exception if
                there is an element with this ID*/
                if (document.getElementById(newLocation) && that.debugMode) {
                    var e = "Exception: History locations can not have the same value as _any_ IDs that might be in the document,"
                    + " due to a bug in IE; please ask the developer to choose a history location that does not match any HTML"
                    + " IDs in this document. The following ID is already taken and cannot be a location: " + newLocation;
                    throw new Error(e); 
                }

                /*Store the history data into history storage*/
                historyStorage.put(newLocation, historyData);

                /*Indicate to the browser to ignore this upcomming location change since we're making it programmatically*/
                that.ignoreLocationChange = true;

                /*Indicate to IE that this is an atomic location change block*/
                that.ieAtomicLocationChange = true;

                /*Save this as our current location*/
                that.currentLocation = newLocation;
        
                /*Change the browser location*/
                window.location.hash = newLocation;

                /*Change the hidden iframe's location if on IE*/
                if (that.isIE) {
                    that.iframe.src = "blank.html?" + newLocation;
                }

                /*End of atomic location change block for IE*/
                that.ieAtomicLocationChange = false;
            };

            /*Now queue up this add request*/
            window.setTimeout(addImpl, this.currentWaitTime);

            /*Indicate that the next request will have to wait for awhile*/
            this.currentWaitTime = this.currentWaitTime + this.waitTime;
        }
    },

    /*Public*/
    isFirstLoad: function() {
        return this.firstLoad;
    },

    /*Public*/
    getVersion: function() {
        return "0.6";
    },

    /*Get browser's current hash location; for Safari, read value from a hidden form field*/

    /*Public*/
    getCurrentLocation: function() {
        var r = (this.isSafari
            ? this.getSafariState()
            : this.getCurrentHash()
        );
        return r;
    },
    
    /*Public: Manually parse the current url for a hash; tip of the hat to YUI*/
    getCurrentHash: function() {
        var r = window.location.href;
        var i = r.indexOf("#");
        return (i >= 0
            ? r.substr(i+1)
            : ""
        );
    },
    
    /*- - - - - - - - - - - -*/
    
    /*Private: Constant for our own internal history event called when the page is loaded*/
    PAGELOADEDSTRING: "DhtmlHistory_pageLoaded",
    
    /*Private: Our history change listener.*/
    listener: null,

    /*Private: MS to wait between add requests - will be reset for certain browsers*/
    waitTime: 200,
    
    /*Private: MS before an add request can execute*/
    currentWaitTime: 0,

    /*Private: Our current hash location, without the "#" symbol.*/
    currentLocation: null,

    /*Private: Hidden iframe used to IE to detect history changes*/
    iframe: null,

    /*Private: Flags and DOM references used only by Safari*/
    safariHistoryStartPoint: null,
    safariStack: null,
    safariLength: null,

    /*Private: Flag used to keep checkLocation() from doing anything when it discovers location changes we've made ourselves
    programmatically with the add() method. Basically, add() sets this to true. When checkLocation() discovers it's true,
    it refrains from firing our listener, then resets the flag to false for next cycle. That way, our listener only gets fired on
    history change events triggered by the user via back/forward buttons and manual hash changes. This flag also helps us set up
    IE's special iframe-based method of handling history changes.*/
    ignoreLocationChange: null,

    /*Private: A flag that indicates that we should fire a history change event when we are ready, i.e. after we are initialized and
    we have a history change listener. This is needed due to an edge case in browsers other than IE; if you leave a page entirely
    then return, we must fire this as a history change event. Unfortunately, we have lost all references to listeners from earlier,
    because JavaScript clears out.*/
    fireOnNewListener: null,

    /*Private: A variable that indicates whether this is the first time this page has been loaded. If you go to a web page, leave it
    for another one, and then return, the page's onload listener fires again. We need a way to differentiate between the first page
    load and subsequent ones. This variable works hand in hand with the pageLoaded variable we store into historyStorage.*/
    firstLoad: null,

    /*Private: A variable to handle an important edge case in IE. In IE, if a user manually types an address into their browser's
    location bar, we must intercept this by calling checkLocation() at regular intervals. However, if we are programmatically
    changing the location bar ourselves using the add() method, we need to ignore these changes in checkLocation(). Unfortunately,
    these changes take several lines of code to complete, so for the duration of those lines of code, we set this variable to true.
    That signals to checkLocation() to ignore the change-in-progress. Once we're done with our chunk of location-change code in
    add(), we set this back to false. We'll do the same thing when capturing user-entered address changes in checkLocation itself.*/
    ieAtomicLocationChange: null,
    
    /*Private: Create IE-specific DOM nodes and overrides*/
    createIE: function(initialHash) {
        /*write out a hidden iframe for IE and set the amount of time to wait between add() requests*/
        this.waitTime = 400;/*IE needs longer between history updates*/
        var styles = (historyStorage.debugMode
            ? 'width: 800px;height:80px;border:1px solid black;'
            : historyStorage.hideStyles
        );
        var iframeID = "rshHistoryFrame";
        var iframeHTML = '<iframe frameborder="0" id="' + iframeID + '" style="' + styles + '" src="blank.html?' + initialHash + '"></iframe>';
       var ifh = Builder.node('div',[]); 
        ifh.innerHTML = iframeHTML;
         $(document.body).appendChild(ifh);
        this.iframe = document.getElementById(iframeID);
    },
    
    /*Private: Create Opera-specific DOM nodes and overrides*/
    createOpera: function() {
        this.waitTime = 400;/*Opera needs longer between history updates*/
        var imgHTML = '<img src="javascript:location.href=\'javascript:dhtmlHistory.checkLocation();\';" style="' + historyStorage.hideStyles + '" />';
        var imh = Builder.node('div',[]); 
        imh.innerHTML = imgHTML;
         $(document.body).appendChild(imh);
      
 
    },
    
    /*Private: Create Safari-specific DOM nodes and overrides*/
    createSafari: function() {
        var formID = "rshSafariForm";
        var stackID = "rshSafariStack";
        var lengthID = "rshSafariLength";
        var formStyles = historyStorage.debugMode ? historyStorage.showStyles : historyStorage.hideStyles;
        var inputStyles = (historyStorage.debugMode
            ? 'width:800px;height:20px;border:1px solid black;margin:0;padding:0;'
            : historyStorage.hideStyles
        );
        var safariHTML = '<form id="' + formID + '" style="' + formStyles + '">'
            + '<input type="text" style="' + inputStyles + '" id="' + stackID + '" value="[]"/>'
            + '<input type="text" style="' + inputStyles + '" id="' + lengthID + '" value=""/>'
        + '</form>';

        var smh = Builder.node('div',[]); 
        smh.innerHTML = safariHTML;
         $(document.body).appendChild(smh);

    
        this.safariStack = document.getElementById(stackID);
        this.safariLength = document.getElementById(lengthID);
        if (!historyStorage.hasKey(this.PAGELOADEDSTRING)) {
            this.safariHistoryStartPoint = history.length;
            this.safariLength.value = this.safariHistoryStartPoint;
        } else {
            this.safariHistoryStartPoint = this.safariLength.value;
        }
    },
    
    /*Private: Safari method to read the history stack from a hidden form field*/
    getSafariStack: function() {
        var r = this.safariStack.value;
        return historyStorage.fromJSON(r);
    },

    /*Private: Safari method to read from the history stack*/
    getSafariState: function() {
        var stack = this.getSafariStack();
        var state = stack[history.length - this.safariHistoryStartPoint - 1];
        return state;
    },            
    /*Private: Safari method to write the history stack to a hidden form field*/
    putSafariState: function(newLocation) {
        var stack = this.getSafariStack();
        stack[history.length - this.safariHistoryStartPoint] = newLocation;
        this.safariStack.value = historyStorage.toJSON(stack);
    },

    /*Private: Notify the listener of new history changes.*/
    fireHistoryEvent: function(newHash) {
        /*extract the value from our history storage for this hash*/
        var historyData = historyStorage.get(newHash);
        /*call our listener*/
        this.listener.call(null, newHash, historyData);
    },
    
    /*Private: See if the browser has changed location. This is the primary history mechanism for Firefox. For IE, we use this to
    handle an important edge case: if a user manually types in a new hash value into their IE location bar and press enter, we want to
    to intercept this and notify any history listener.*/
    checkLocation: function() {
        
        /*Ignore any location changes that we made ourselves for browsers other than IE*/
        if (!this.isIE && this.ignoreLocationChange) {
            this.ignoreLocationChange = false;
            return;
        }

        /*If we are dealing with IE and we are in the middle of making a location change from an iframe, ignore it*/
        if (!this.isIE && this.ieAtomicLocationChange) {
            return;
        }
        
        /*Get hash location*/
        var hash = this.getCurrentLocation();

        /*Do nothing if there's been no change*/
        if (hash == this.currentLocation) {
            return;
        }

        /*In IE, users manually entering locations into the browser; we do this by comparing the browser's location against the
        iframe's location; if they differ, we are dealing with a manual event and need to place it inside our history, otherwise
        we can return*/
        this.ieAtomicLocationChange = true;

        if (this.isIE && this.getIframeHash() != hash) {
            this.iframe.src = "blank.html?" + hash;
        }
        else if (this.isIE) {
            /*the iframe is unchanged*/
            return;
        }

        /*Save this new location*/
        this.currentLocation = hash;

        this.ieAtomicLocationChange = false;

        /*Notify listeners of the change*/
        this.fireHistoryEvent(hash);
    },

    /*Private: Get the current location of IE's hidden iframe.*/
    getIframeHash: function() {
        var doc = this.iframe.contentWindow.document;
        var hash = String(doc.location.search);
        if (hash.length == 1 && hash.charAt(0) == "?") {
            hash = "";
        }
        else if (hash.length >= 2 && hash.charAt(0) == "?") {
            hash = hash.substring(1);
        }
        return hash;
    },

    /*Private: Remove any leading hash that might be on a location.*/
    removeHash: function(hashValue) {
        var r;
        if (hashValue === null || hashValue === undefined) {
            r = null;
        }
        else if (hashValue === "") {
            r = "";
        }
        else if (hashValue.length == 1 && hashValue.charAt(0) == "#") {
            r = "";
        }
        else if (hashValue.length > 1 && hashValue.charAt(0) == "#") {
            r = hashValue.substring(1);
        }
        else {
            r = hashValue;
        }
        return r;
    },

    /*Private: For IE, tell when the hidden iframe has finished loading.*/
    iframeLoaded: function(newLocation) {
        /*ignore any location changes that we made ourselves*/
        if (this.ignoreLocationChange) {
            this.ignoreLocationChange = false;
            return;
        }

        /*Get the new location*/
        var hash = String(newLocation.search);
        if (hash.length == 1 && hash.charAt(0) == "?") {
            hash = "";
        }
        else if (hash.length >= 2 && hash.charAt(0) == "?") {
            hash = hash.substring(1);
        }
        /*Keep the browser location bar in sync with the iframe hash*/
        window.location.hash = hash;

        /*Notify listeners of the change*/
        this.fireHistoryEvent(hash);
    }

};

/*
    historyStorage: An object that uses a hidden form to store history state across page loads. The mechanism for doing so relies on
    the fact that browsers save the text in form data for the life of the browser session, which means the text is still there when
    the user navigates back to the page. This object can be used independently of the dhtmlHistory object for caching of Ajax
    session information.
    
    dependencies: 
        * json2007.js (included in a separate file) or alternate JSON methods passed in through an options bundle.
*/
window.historyStorage = {
    
    /*Public: Set up our historyStorage object for use by dhtmlHistory or other objects*/
    setup: function(options) {
        
        /*
            options - object to store initialization parameters - passed in from dhtmlHistory or directly into historyStorage
            options.debugMode - boolean that causes hidden form fields to be shown for development purposes.
            options.toJSON - function to override default JSON stringifier
            options.fromJSON - function to override default JSON parser
        */
        
        /*process init parameters*/
        if (typeof options !== "undefined") {
            if (options.debugMode) {
                this.debugMode = options.debugMode;
            }
            if (options.toJSON) {
                this.toJSON = options.toJSON;
            }
            if (options.fromJSON) {
                this.fromJSON = options.fromJSON;
            }
        }        
        
        /*write a hidden form and textarea into the page; we'll stow our history stack here*/
        var formID = "rshStorageForm";
        var textareaID = "rshStorageField";
        var formStyles = this.debugMode ? historyStorage.showStyles : historyStorage.hideStyles;
        var textareaStyles = (historyStorage.debugMode
            ? 'width: 800px;height:80px;border:1px solid black;'
            : historyStorage.hideStyles
        );
        var textareaHTML = '<form id="' + formID + '" style="' + formStyles + '">'
            + '<textarea id="' + textareaID + '" style="' + textareaStyles + '"></textarea>'
        + '</form>';

 
       var tfh = Builder.node('div',[]); 
        tfh.innerHTML = textareaHTML;
         $(document.body).appendChild(tfh);

        this.storageField = document.getElementById(textareaID);
        if (typeof window.opera !== "undefined") {
            this.storageField.focus();/*Opera needs to focus this element before persisting values in it*/
        }
    },
    
    /*Public*/
    put: function(key, value) {
        this.assertValidKey(key);
        /*if we already have a value for this, remove the value before adding the new one*/
        if (this.hasKey(key)) {
            this.remove(key);
        }
        /*store this new key*/
        this.storageHash[key] = value;
        /*save and serialize the hashtable into the form*/
        this.saveHashTable();
    },

    /*Public*/
    get: function(key) {
        this.assertValidKey(key);
        /*make sure the hash table has been loaded from the form*/
        this.loadHashTable();
        var value = this.storageHash[key];
        if (value === undefined) {
            value = null;
        }
        return value;
    },

    /*Public*/
    remove: function(key) {
        this.assertValidKey(key);
        /*make sure the hash table has been loaded from the form*/
        this.loadHashTable();
        /*delete the value*/
        delete this.storageHash[key];
        /*serialize and save the hash table into the form*/
        this.saveHashTable();
    },

    /*Public: Clears out all saved data.*/
    reset: function() {
        this.storageField.value = "";
        this.storageHash = {};
    },

    /*Public*/
    hasKey: function(key) {
        this.assertValidKey(key);
        /*make sure the hash table has been loaded from the form*/
        this.loadHashTable();
        return (typeof this.storageHash[key] !== "undefined");
    },

    /*Public*/
    isValidKey: function(key) {
        return (typeof key === "string");
    },
    
    /*Public - CSS strings utilized by both objects to hide or show behind-the-scenes DOM elements*/
    showStyles: 'border:0;margin:0;padding:0;',
    hideStyles: 'left:-1000px;top:-1000px;width:1px;height:1px;border:0;position:absolute;',
    
    /*Public - debug mode flag*/
    debugMode: false,
    
    /*- - - - - - - - - - - -*/

    /*Private: Our hash of key name/values.*/
    storageHash: {},

    /*Private: If true, we have loaded our hash table out of the storage form.*/
    hashLoaded: false, 

    /*Private: DOM reference to our history field*/
    storageField: null,

    /*Private: Assert that a key is valid; throw an exception if it not.*/
    assertValidKey: function(key) {
        var isValid = this.isValidKey(key);
        if (!isValid && this.debugMode) {
            throw new Error("Please provide a valid key for window.historyStorage. Invalid key = " + key + ".");
        }
    },

    /*Private: Load the hash table up from the form.*/
    loadHashTable: function() {
        if (!this.hashLoaded) {    
            var serializedHashTable = this.storageField.value;
            if (serializedHashTable !== "" && serializedHashTable !== null) {
                this.storageHash = this.fromJSON(serializedHashTable);
                this.hashLoaded = true;
            }
        }
    },
    /*Private: Save the hash table into the form.*/
    saveHashTable: function() {
        this.loadHashTable();
        var serializedHashTable = this.toJSON(this.storageHash);
        this.storageField.value = serializedHashTable;
    },
    /*Private: Bridges for our JSON implementations - both rely on 2007 JSON.org library - can be overridden by options bundle*/
    toJSON: function(o) {
        return o.toJSONString();
    },
    fromJSON: function(s) {
        return s.parseJSON();
    }
}; 
;

// /8::/202::/frontend:js -> <90142> saveandsharewidget.js 

 var el;
var swin;
var atw;

shareWidget = Class.create();
shareWidget.prototype = {
  defaultOptions: function(){
    return {
      item: null,
      model: itemModel,
      shortText: false,
      node:null
    }
  },
  makeWidgetContent: function(){
    atw = this;
    if (!this.options.shortText) {
      var text = translateText({path: ".share", id: "share-item", args: [
        this.options.model.itemType()
      ]})
    }
    else {
      var text = translateText({path: "", id: "share"})
    }

 
    this.textnode = Builder.node('div',{
      id:"addToMo",
      style:"cursor:pointer;cursor:hand;font-weight:bold;"
    }, [
     
      text
    ]);
 
if(this.options.node != null){
    var addtomo = this.options.node
}else{
  
var addtomo = this.textnode
}
    addtomo.m = this.options.item;

    Event.observe(addtomo,'click',function(e){
        this.setContent(this.options.item);
        Event.stop(e);
        return false;
    }.bind(this));
    
    return addtomo;
  }, 
  windowContent: function(itm){
    instance = this;
    this.type = "";
    this.perma = "";
    this.item = null; 
    this.url = "";
    if(itm == null){
      //no item selected.. take currentPath
      itm = {name:""};
      this.item = itm;
      this.perma = this.options.model.currentPathPermalink() 
    }else{
      //selected item..check type
      this.item = itm;
      this.type = this.item.type;
      this.perma = this.options.model.currentPathPermalink(itm) 
    };
    var copyok = Builder.node('span',{
      id:"copyok",
      style:"display:none;text-align:center;width:190px;height:25px;" +
            "margin-top:0px;padding:2px;margin-left:16px;" +
            "font-size:14px;background:#EFEDED;"
    },[translateText({path: ".share", id: "copied-to-clipboard"})])
    if (this.options.compact) {
      var head = copyok;
      copyok.style.width = "90%"
    }
    else {
      var head = Builder.node('div',{
        style:"font-weight:bolder;font-size:180%;margin-bottom:15px;"
      },[table([
        {
          columnOptions:{width:45,valign:"bottom"},
          columnData:[Builder.node('img',{src:"/images/shareicon.png"})]
        },
        translateText({path: ".share", id: "share-item", args: [this.type]}),
        copyok
      ])]);      
    }
    var share = [];
    sel = {
      description: translateText({path: ".share", id: "share-url"}),
      value:{val:this.options.model.currentPathPermalink(itm)},
      template:"#{val}"
    }
    if(ManageItemDialog.prototype.getEmbedLinks){
      el = ManageItemDialog.prototype.getEmbedLinks(itm, this.options.model);
    }else{
      el = [];
    }
    el.unshift(sel);
    el.each(function(l){
      share.push(instance.makeEmbedInput(l));
    });
    var more = Builder.node('div',{style:"font-weight:bolder;"},[]);  
    var morenodes = [
      {text:translateText({path: ".share", id: "bookmark-item"}),icon:"/images/semailico.png",action:function(e){
        var bmbox = Builder.node('div',{id:"bmbox"},[
          getLinks(instance.item.name,cleanUrl(instance.perma))
        ]);
        generateWindow(bmbox);
      }}
    ]; 
    if(this.item.full_item_url){
      morenodes.push({text: translateText({path: ".share", id: "download"}),icon:"/images/sdlico.png",action:function(e){
        window.location.href = instance.item.full_item_url;
      }});
      morenodes.push({
        text: translateText({path: ".share", id: "send-to-mobile"}),
        icon:"/images/semailico.png",
        action:function(e){
          qrc = generateSaveQR(instance.item.full_item_url);             
          $("shareBox").parentNode.appendChild(Builder.node('div',{
            style:"padding:10px;"
          },[qrc]));            
          $("shareBox").hide();
        }
      });
    }
    var morearr = [];
    if(ManageItemDialog.prototype.getEmbedButtons){
      eb = ManageItemDialog.prototype.getEmbedButtons(itm);
      eb.each(function(e){                
        morenodes.push(e);
      });
    }else{
      eb = [];
    }
    morenodes.each(function(n){
      morearr.push(instance.makeEmbedButton(n))
    });
    appendChildren(more,morearr);
    share.push(more); 
    share.unshift(head);
    return Builder.node('div',{
      id:"shareBox",
      style:"padding:20px;padding-top:0px;"
    },share);      
  }, 
  makeEmbedInput:function(o){
    var te = new Template(o.template);
    var show = o.value;
    var val =  te.evaluate(show);
    if (typeof o.description == "string") {
      var txt = Builder.node('div',[TN(o.description)]);      
    }
    else {
      var txt = Builder.node('div', [o.description])
    }
    if (this.options.compact) {
      var style = "padding:4px;background:#FFF9DF;border:1px solid silver;" +
                  "width:145px;font-size:10px;margin-bottom:5px;"
    }
    else {
      var style = "padding:4px;background:#FFF9DF;border:1px solid silver;" +
                  "width:90%;font-size:10px;margin-bottom:15px;"
    }
    var node = Builder.node('input',{
      value:val,
      type:"text",
      style: style
    });
    Event.observe(node,'click',function(e){
      Event.stop(e);
      copyToClipboard(Event.element(e))
    });
    if(!show.val){
      return NBSP();
    }
    return Builder.node('div',[txt,node]);
  },
  makeEmbedButton:function(o){
    var ni = Builder.node('a',{style:"color:#000000;margin-right:10px;",href:"#"},[
      o.text
    ]);
    Event.observe(ni,'click',function(e){
      Event.stop(e);
      o.action(e);
    });
    var n = table([{columnOptions:{width:35},columnData:[
      Builder.node('img',{src:o.icon})
    ]},ni]);
    if (this.options.compact) {
      style = "float:left;height:32px;width:90%;overflow:hidden;"
    }
    else {
      var style = "float:left;height:32px;width:200px;overflow:hidden;"
    }
    return Builder.node('div',{
      style: style
    },[n]); 
  },
  rerender: function(){
    var nc = this.makeWidgetContent();
    this.replaceChild(this.content, this.widgetContent, nc);
    this.widgetContent = nc;
  },
  setContent:function(itm){
    var scdw = Builder.node('div',{id:"scdw"},[this.windowContent(itm)]);
    generateWindow(scdw);
  }
}  
Object.extend(shareWidget.prototype, WidgetCommon);

function generateWindow(c){
  if(swin != null){
    try{
      swin.hide();
      swin.destroy(); 
    }catch(e){}
  } 
  swin = new Window({
    destroyOnClose:true,
    zindex:9999,
    minimizable:false,
    maximizable:false,
    showEffect:Element.show,
    hideEffect:Element.hide,
    className: "tooltip",
    onClose:function(){
      endIdle();
    },
    onMove:function(){
    },
    onShow:function(){
    }
  }) 
  swin.setContent(c, true, true); 
  swin.setSize(570, 420);
  swin.setZIndex(9999);
  swin.showCenter();   
}

function generateSaveQR(data){
  qrcw = new QRCodeWidget({data:data});
  var close = Builder.node('input',{type:"button",value:"close"});
  Event.observe(close,'click',function(e){
    $("shareBox").show();
    $("qrBox").remove();
  });
  return Builder.node('div',{id:"qrBox",style:"padding:30px;"},[
    qrcw.htmlNode(),BR(),BR(),BR(),close
  ]);
}

function copyToClipboard(elt) {
  var swf = "http:\/\/mike.myservic.es/flash/cp.swf";
  var fc = 'fc';
  if(!$(fc)){
    var divholder = Builder.node('div',{id:"fc"});
    document.body.appendChild(divholder,{});
  }
  //Effect.Appear($("copyok"));
  $(fc).innerHTML = '';
  var divinfo = '<embed src="' + swf + '" FlashVars="cp='+escape(elt.value)+
                '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
  $(fc).innerHTML = divinfo;
  elt.select();
  //window.setTimeout(function(){
  //  Effect.Fade($("copyok"),{});
  //},1000);
  return true;
}

function bookmarkIt(title,url) {
  name=title; 
  if(window.sidebar) {                                 
    window.sidebar.addPanel(name, "http:\/\/"+url, '');
  } else if(document.all) {                             
    window.external.AddFavorite(url, name);
  } else if(window.opera && window.print) {             
    var e=document.createElement('a');
    e.setAttribute('href',url);
    e.setAttribute('title',name);
    e.setAttribute('rel','sidebar');
    e.click();
  }
}

function getLinks(title,url){    
  var itemurl = url;
  var addto = "";
  var title = title;
  var container = Builder.node('div',{style:"padding:10px;"},[]);
  var top = '<div ><span style="font-size:120%;font-weight:bold;">Bookmark: </span><br/>Save this link in your favorite bookmark manager:</div><a  style="color: black; font-size: 11px;" class="addto" href="javascript:bookmarkIt(\''+title+'\',\''+itemurl+'\')" title="Bookmark with your browser">Bookmark in your browser</a><br/><br/>'; 
  var bookmarks = [
    '<div id="My_Yahoo_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/e.my.yahoo.com/config/edit_bookmark?.src=bookmarks&.folder=1&.name=&.url=http%3A%2F%2F'+itemurl+'&.save=+Save+" title="Bookmark with My Yahoo Bookmarks"><img width="91" height="17" border="0" src="http:\/\/us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif" alt="My Yahoo Bookmarks"/></a></div>',
    '<div id="del.icio.us" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/del.icio.us/post?&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with del.icio.us"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/delicious.png" alt="del.icio.us"/></a></div>',
    '<div id="Mister-Wong" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mister-wong.com/index.php?action=addurl&bm_url=http%3A%2F%2F'+itemurl+'&bm_description=" title="Bookmark with Mister-Wong"><img width="80" height="15" border="0" src="http:\/\/www.mister-wong.com/img/wong.gif" alt="Mister-Wong"/></a></div>',
    '<div id="Technorati_Favorites" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/technorati.com/faves?add=http%3A%2F%2F'+itemurl+'" title="Bookmark with Technorati Favorites"><img width="91" height="17" border="0" src="http:\/\/static.technorati.com/pix/fave/tech-fav-5.gif" alt="Technorati Favorites"/></a></div>',
    '<div id="Furl" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.furl.net/storeIt.jsp?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with Furl"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/furl.png" alt="Furl"/></a></div>',
    '<div id="CiteULike" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.citeulike.org/posturl?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with CiteULike"><img width="94" height="15" border="0" src="http:\/\/static.citeulike.org/img/small-logo.png" alt="CiteULike"/></a></div>',
    '<div id="Hemidemi" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.hemidemi.com/user_bookmark/new?title=&url=http%3A%2F%2F'+itemurl+'&via=http%3A%2F%2Fwww.mysit.es%2F" title="Bookmark with Hemidemi"><img width="80" height="15" border="0" src="http:\/\/www.hemidemi.com/images/hemidemi.png" alt="Hemidemi"/></a></div>',
    '<div id="FunP" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/funp.com/portal/addrss.php?url=http%3A\/\/'+itemurl+'&via=mysites" title="Bookmark with FunP"><img width="90" height="22" border="0" src="http:\/\/funp.com/tools/images/subscribe_05.gif" alt="FunP"/></a></div>',
    '<div id="Xerpi" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.xerpi.com/block/add_link_from_extension?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Xerpi"><img width="91" height="17" border="0" src="http:\/\/www.xerpi.com/images/xerpipost.gif" alt="Xerpi"/></a></div>',
    '<div id="Facebook" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.facebook.com/share.php?src=bm&u=http%3A%2F%2F'+itemurl+'&t=&v=3" title="Bookmark with Facebook">Facebook</a></div>',
    '<div id="Netvouz" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.netvouz.com/action/submitBookmark?url=http%3A%2F%2F'+itemurl+'&title=&popup=no" title="Bookmark with Netvouz">Netvouz</a></div>',
    '<div id="Wink" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.wink.com/_/tag?url=http%3A%2F%2F'+itemurl+'&doctitle=" title="Bookmark with Wink">Wink</a></div>',
    '<div id="Ma.gnolia" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/ma.gnolia.com/bookmarklet/add?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Ma.gnolia">Ma.gnolia</a></div>',
    '<div id="BibSonomy" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.bibsonomy.org/BibtexHandler?requTask=upload&url=http%3A%2F%2F'+itemurl+'&description=" title="Bookmark with BibSonomy">BibSonomy</a></div>',
    '<div id="Jots" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.jots.com/?cmd=do_post&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Jots">Jots</a></div>',
    '<div id="Taggly" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.taggly.com/bookmarks/?action=add&address=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Taggly">Taggly</a></div>',
    '<div id="BlogMarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/blogmarks.net/my/new.php?mini=1&simple=1&title=&url=http%3A%2F%2F'+itemurl+'" title="Bookmark with BlogMarks">BlogMarks</a></div>',
    '<div id="Tailrank" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/tailrank.com/share/?link_href=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Tailrank">Tailrank</a></div>',
    //'<div id="Firefox_Opera_Safari_Internet_Explorer_Konqueror_Flock_Mozilla_Camino_Netscape" class="addtodiv"><a  style="color: black; font-size: 11px;" class="addto" href="javascript:bookmarkIt(\''+title+'\',\''+itemurl+'\')" title="Bookmark with your browser">My Browser</a></div>',
    '<div id="Windows_Live_Favorites" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/favorites.live.com/quickadd.aspx?url=http%3A\/\/'+itemurl+'&title=" title="Bookmark with Windows Live Favorites"><img width="106" height="17" border="0" src="http:\/\/shared.live.com/idYiNi0777CC-rhpYaj-HHSWi6kD2l2ATUPXIQ89GY9dmNXZasCQJowvlpjSsu4N/base/3200/Gallery/img/addlive.gif" alt="Windows Live Favorites"/></a></div>',
    '<div id="StumbleUpon" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.stumbleupon.com/submit?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with StumbleUpon"><img width="91" height="17" border="0" src="http:\/\/www.stumbleupon.com/images/su_micro.gif" alt="StumbleUpon"/></a></div>',
    '<div id="Protopage_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.protopage.com/add-button-site?url=http%3A%2F%2F'+itemurl+'&label=&type=page" title="Bookmark with Protopage Bookmarks"><img width="91" height="17" border="0" src="http:\/\/www.protopage.com/web/images/buttons/add-site-to-protopage.gif" alt="Protopage Bookmarks"/></a></div>',
    //'<div id="Shadows" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.shadows.com/features/tcr.htm?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Shadows"><img width="32" height="32" border="0" src="http:\/\/www.shadows.com/Features/images/bling/shadowme1_80x15.gif" alt="Shadows"/></a></div>',
    '<div id="Blinklist" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.blinklist.com/index.php?Action=Blink/addblink.php&Url=http%3A%2F%2F'+itemurl+'&Title=" title="Bookmark with Blinklist"><img width="80" height="18" border="0" src="http:\/\/www.blinklist.com/Theme/Graphic/Blink_Small_Button.gif" alt="Blinklist"/></a></div>',
    '<div id="YiGG" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/yigg.de/neu?exturl=http%3A%2F%2F'+itemurl+'&exttitle=" title="Bookmark with YiGG"><img width="80" height="15" border="0" src="http:\/\/www.yigg.de/images/yiggit-2.png" alt="YiGG"/></a></div>',
    '<div id="Segnalo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/segnalo.alice.it/post.html.php?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Segnalo"><img width="139" height="25" border="0" src="http:\/\/segnalo.alice.it/images/postasusegnalo.png" alt="Segnalo"/></a></div>',
    '<div id="YouMob" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/youmob.com/mob.aspx?mob=http%3A%2F%2F'+itemurl+'" title="Bookmark with YouMob"><img width="52" height="30" border="0" src="http:\/\/youmob.com/GetBeacon.axd?style=4&mob=http%3A%2F%2F'+itemurl+'" alt="YouMob"/></a></div>',
    '<div id="Slashdot" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/slashdot.org/bookmark.pl?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Slashdot">Slashdot</a></div>',
    '<div id="RawSugar" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.rawsugar.com/pages/tagger.faces?turl=http%3A%2F%2F'+itemurl+'&tttl=" title="Bookmark with RawSugar">RawSugar</a></div>',
    '<div id="Scuttle" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/scuttle.org/login/?action=add&address=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Scuttle">Scuttle</a></div>',
    '<div id="Smarking" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/smarking.com/editbookmark/?url=http%3A%2F%2F'+itemurl+'&description=" title="Bookmark with Smarking">Smarking</a></div>',
    '<div id="Jookster" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.jookster.com/JookThis.aspx?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Jookster">Jookster</a></div>',
    '<div id="Feedmarker_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.feedmarker.com/admin.php?do=bookmarklet_mark&url=http%3A%2F%2F'+itemurl+'&title=http%3A%2F%2F'+itemurl+'" title="Bookmark with Feedmarker Bookmarks">Feedmarker Bookmarks</a></div>',
    '<div id="OnlyWire" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.onlywire.com/b/?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with OnlyWire">OnlyWire</a></div>',
    '<div id="unalog" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/unalog.com/my/stack/link?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with unalog">unalog</a></div>',
    '<div id="Squidoo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.squidoo.com/lensmaster/bookmark?http%3A%2F%2F'+itemurl+'" title="Bookmark with Squidoo">Squidoo</a></div>',
    '<div id="Google_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.'+itemurl+'/bookmarks/mark?op=edit&bkmk=http%3A%2F%2F'+itemurl+'" title="Bookmark with Google Bookmarks"><img width="104" height="17" border="0" src="http:\/\/buttons.googlesyndication.com/fusion/add.gif" alt="Google Bookmarks"/></a></div>',
    '<div id="Thoof" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/thoof.com/submit?link=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Thoof"><img width="60" height="15" border="0" src="http:\/\/thoof.com/images/thoofit.gif" alt="Thoof"/></a></div>',
    '<div id="Spurl" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.spurl.net/spurl.php?title=&url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Spurl"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/spurl.png" alt="Spurl"/></a></div>',
    '<div id="Yample" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/yample.com/submit.php?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Yample"><img width="100" height="20" border="0" src="http:\/\/yample.com/100x20-yample-button.png" alt="Yample"/></a></div>',
    '<div id="Oneview" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.oneview.de:80/quickadd/neu/addBookmark.jsf?URL=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Oneview"><img width="74" height="17" border="0" src="http:\/\/www.oneview.de/img/book_buttons/ov_bm_020.gif" alt="Oneview"/></a></div>',
    '<div id="Linkatopia" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/linkatopia.com/add?uri=http%3A%2F%2F'+itemurl+',title=" title="Bookmark with Linkatopia"><img width="80" height="15" border="0" src="http:\/\/linkatopia.com/images/linkabutton80.gif" alt="Linkatopia"/></a></div>',
    '<div id="Simpy" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2F'+itemurl+'&title=&v=6" title="Bookmark with Simpy"><img width="80" height="15" border="0" src="http:\/\/www.simpy.com/img/chicklet-simpy-orange.png" alt="Simpy"/></a></div>',
    '<div id="BuddyMarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/buddymarks.com/add_bookmark.php?bookmark_url=http%3A%2F%2F'+itemurl+'&bookmark_title=" title="Bookmark with BuddyMarks"><img width="95" height="21" border="0" src="http:\/\/buddymarks.com/images/bmpromolink.gif" alt="BuddyMarks"/></a></div>',
    '<div id="Small_Things" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/smallthings.kilobox.mobi/login.php/?action=add&address=http%3A%2F%2F'+itemurl+'" title="Bookmark with Small Things"><img width="80" height="15" border="0" src="http:\/\/smallthings.kilobox.mobi/small-things.gif" alt="Small Things"/></a></div>',
    '<div id="Ask.com_MyStuff" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/mystuff.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Ask.com MyStuff">Ask.com MyStuff</a></div>',
    '<div id="Maple" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.maple.nu/bookmarks/bookmarklet?bookmark[url]=http%3A%2F%2F'+itemurl+'&bookmark[description]=" title="Bookmark with Maple">Maple</a></div>',
    '<div id="Wists" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/wists.com/r.php?r=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Wists">Wists</a></div>',
    '<div id="Kinja" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/kinja.com/id.knj?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Kinja">Kinja</a></div>',
    '<div id="Gravee" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.gravee.com/account/bookmarkpop?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with Gravee">Gravee</a></div>',
    '<div id="Connotea" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.connotea.org/add?uri=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Connotea">Connotea</a></div>',
    '<div id="Backflip" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.backflip.com/add_page_pop.ihtml?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Backflip">Backflip</a></div>',
    '<div id="MyLinkVault" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mylinkvault.com/link-page.php?u=http%3A%2F%2F'+itemurl+'&n=" title="Bookmark with MyLinkVault">MyLinkVault</a></div>',
    '<div id="SiteJot" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.sitejot.com/addform.php?iSiteAdd=http%3A%2F%2F'+itemurl+'&iSiteDes=" title="Bookmark with SiteJot">SiteJot</a></div>',
    '<div id="Digg" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/digg.com/submit?phase=2&url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Digg"><img width="100" height="20" border="0" src="http:\/\/digg.com/img/badges/100x20-digg-button.gif" alt="Digg"/></a></div>',
    '<div id="Mixx" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mixx.com/submit?page_url=http%3A%2F%2F'+itemurl+'" title="Add to Mixx"><img width="102" height="17" border="0" src="http:\/\/www.mixx.com/images/buttons/mixx-button1.png" alt="Mixx"/></a></div>',
    '<div id="Sphere" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.sphere.com/search?q=sphereit:http%3A%2F%2F'+itemurl+'" title="Add to Sphere"><img width="80" height="25" border="0" src="http:\/\/www.sphere.com/images/sphereit_button.png" alt="Sphere"/></a></div>',
    '<div id="Bitty_Browser" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.bitty.com/manual/?contenttype=website&contentvalue=http%3A%2F%2F'+itemurl+'" title="Add to Bitty Browser"><img width="91" height="17" border="0" src="http:\/\/www.bitty.com/img/bittychicklet_91x17.gif" alt="Bitty Browser"/></a></div>',
    '<div id="dzone" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.dzone.com/links/add.html?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to dzone"><img width="44" height="13" border="0" src="http:\/\/widgets.dzone.com/links/images/std/vwidget3/vwidget_logo.gif" alt="dzone"/></a></div>',
    '<div id="Diigo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.diigo.com/post?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Diigo"><img width="86" height="17" border="0" src="http:\/\/www.diigo.com/images/difb_big.gif" alt="Diigo"/></a></div>',
    '<div id="Design_Float" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.designfloat.com/submit.php?url=http%3A%2F%2F'+itemurl+'" title="Add to Design Float"><img width="54" height="17" border="0" src="http:\/\/www.designfloat.com/templates/green/images/df_button.gif" alt="Design Float"/></a></div>',
    '<div id="diglog" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.diglog.com/submit?act=like&returnurl=true&title=&url=http%3A%2F%2F'+itemurl+'" title="Add to diglog"><img width="80" height="15" border="0" src="http:\/\/www.diglog.com/images/diglog_80x15_4.gif" alt="diglog"/></a></div>',
    '<div id="Technotizie" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.technotizie.it/posta_ok?action=f2&title=&url=http%3A%2F%2F'+itemurl+'" title="Add to Technotizie"><img width="117" height="24" border="0" src="http:\/\/www.technotizie.it/images/technotiziesubmit3.png" alt="Technotizie"/></a></div>',
    '<div id="Reddit" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/reddit.com/submit?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Reddit">Reddit</a></div>',
    '<div id="NewsVine" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.newsvine.com/_tools/seed&save?u=http%3A%2F%2F'+itemurl+'&h=" title="Add to NewsVine">NewsVine</a></div>',
    '<div id="NowPublic" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/view.nowpublic.com/?src=http%3A%2F%2F'+itemurl+'&t=" title="Add to NowPublic">NowPublic</a></div>',
    '<div id="Hugg" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.hugg.com/submit?url=http%3A%2F%2F'+itemurl+'" title="Add to Hugg">Hugg</a></div>',
    '<div id="Care2_News" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.care2.com/news/news_post.html?url=http%3A%2F%2F'+itemurl+'&title=&v=1.3" title="Add to Care2 News">Care2 News</a></div>',
    '<div id="Netscape.com" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.netscape.com/submit/?U=http%3A%2F%2F'+itemurl+'&T=" title="Add to Netscape.com">Netscape.com</a></div>',
    '<div id="LiveJournal" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.livejournal.com/update.bml?subject=" title="Add to LiveJournal">LiveJournal</a></div>',
    '<div id="Feedo_Style" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.feedostyle.com/create_digest.aspx?feed=http%3A%2F%2F'+itemurl+'" title="Add to Feedo Style">Feedo Style</a></div>',
  ];
  var alldivs = "";
  bookmarks.sort().each(function(b){
    alldivs += b;
  });
  container.innerHTML = top+alldivs
  return container;
}

function cleanUrl(url){ 
  var nuurl = url.split('http:\/\/'); 
  return nuurl[1];
} 


;

// /8::/202::/frontend:js -> <903> searchwidget.js 

function suggestionSelected(c) {
  searchWidget.setCurrentTagSearch(
    searchWidget.setCurrentSearchTerm(
      searchWidget.currentLSResults()[c - 1]["tag"]
    )
  )
  searchWidget.refresh()
}

MyAbstractTimedObserver = function() {}
MyAbstractTimedObserver.prototype = {
  initialize: function(element, frequency, callback) {
    this.frequency = frequency;
    this.element   = element;
    this.callback  = callback;
    this.lastValue = this.getValue();
  },
  startObserving: function() {
    this.interval = setInterval(this.onTimerEvent.bind(this), 
        this.frequency * 1000);
  },
  stopObserving: function() {
    clearInterval(this.interval)
  },
  onTimerEvent: function() {
    var value = this.getValue();
    if (this.lastValue != value) {
      this.callback(this.element, value);
      this.lastValue = value;
    }
  }
}

MyFormObserver = Class.create();
MyFormObserver.prototype = Object.extend(new MyAbstractTimedObserver(), {
  getValue: function() {
    return Form.Element.getValue(this.element);
  }
});

SearchWidget = Class.create();
SearchWidget.prototype = {
  defaultOptions: function() {
    return {
      model: null,
      defaultMinimumRating: 2
    };
  },
  setup: function() {
    this.threshold = this.options.defaultMinimumRating
    var instance = this;
    this.minimumRating = new RatingWidget({
      defaultRating: this.options.defaultMinimumRating,
      description: "Min Rating:",
      onchange: function(threshold) {
        instance.threshold = threshold;
        standardExplorer.options.tooltip.hideTotally()
        instance.refresh()
      }
    })
    this.input = Builder.node('input', {value: "Tags"})
    this.model = new DisplayModel({
      data: [],
      sortByColumn: "count",
      reverse: true,
      columnNames: ["tag", "count"],
      columnDisplayNames: ["Keyword", "Count"],
      filter: function(model) {
        var c = 0;
        return model.select(function(i) { c += 1; return c < 10; })
      }
    });
    this.listView = new ListViewWidget({
      model: this.model,
      presenter: new ListViewContainerTagPresenter(),
      noCounter: true,
      noItems: function() {
        return [TN("there are no tags")]
      },
      scope: "keyword-search"
    })
    if (this.options.model) {
      this.setModel(this.options.model)
    }
  },
  setModel: function(m) {
    this.options.model = m
    this.options.model.addObserver(this)
    this.makeLiveSearchModel('')
    this.rerender()
  },
  currentTagSearch: function() {
    var v = this.input.value
    if (v == "Tags") {
      v = "";
    }
    return v;
  },
  setCurrentTagSearch: function(v) {
    if (v == "") {
      v = "Tags"
    }
    this.input.value = v
    this.adjustInputColor();
  },
  rerender: function() {
    this.makeLiveSearchModel(this.currentTagSearch())
  },
  afterPathChanged: function() {
    this.resetLiveSearch()
  },
  refresh: function() {
    // Results in stack overflow in FF3! Why is this needed anyway?
    // this.options.model.version = changeCounter()
    // this.options.model.update();
  },
  effectiveTagSearch: function() {
    return this.currentTagSearch().replace(/\S+$/, "")
  },
  setCurrentSearchTerm: function(term) {
    return this.tagsArray(this.effectiveTagSearch()).join(" ") + " " + term + " "
  },
  clearLiveSearch: function() {
    this.setCurrentTagSearch("")
    this.refresh()
  },
  resetLiveSearch: function() {
    this.setCurrentTagSearch("")
    this.refresh()
  },
  appendSpaceIfNotEmpty: function(s) {
    if (s == "") {
      return "";
    }
  },
  liveSearchSubmitted: function() {
    this.setCurrentTagSearch(this.appendSpaceIfNotEmpty(
        this.tagsArray(this.currentTagSearch()).join(" ")))
    this.refresh()
  },
  searchArray: function(search) {
    if (!search || search == "") {
      return []
    }
    return search.split(/\s+/)
  },
  currentSearchTerm: function(search) {
    if (search == "" ) {
      return ""
    }
    sa = this.searchArray(search)
    return sa[sa.length - 1]
  },
  makeLiveSearchModel: function(search) {
    tags = {}
    var re = new RegExp("\\b" + this.currentSearchTerm(search), "i")
    var instance = this;
    this.options.model.getModel().each(function(i) { 
      if (instance.matchTags(instance.effectiveTagSearch(), i["tags"])) {
        instance.tagsArray(i["tags"]).each(function(t) { 
          if (re.test(t)) {
            if (!tags[t]) { tags[t] = 0; }
            ++tags[t]
          }
        })
      }
    })

    this.tagsArray(this.effectiveTagSearch()).each(function(t) {
      tags[t] = undefined
    })

    lvs = []
    $MSH(tags).each(function(p) {
      if (p.value) {
        lvs.push({"tag": p.key, "count": p.value})
      }
    })

    this.model.data = lvs
    this.model.dataChanged()
  },
  clearSearchFilter: function() {
    this.setCurrentTagSearch("")
    instance.refresh()
  },
  currentLSResults: function() {
    var cd = containerData("ax-live-search")
    return prepareResultsModel(cd["sortByColumn"], cd["reverse"])
  },
  tagInFilter: function(t) {
    re = new RegExp('\\b' + t + '\\b')
    return re.test(this.currentTagSearch())
  },
  addToSearchFilter: function(t) {
    if (this.tagInFilter(t)) {
      return 
    }
    var tags = this.tagsArray(this.currentTagSearch())
    tags[tags.length] = t
    this.setCurrentTagSearch(tags.join(" ") + " ")
    this.refresh();
  },
  removeFromSearchFilter: function(t) {
    var tags = this.tagsArray(this.currentTagSearch())
    this.setCurrentTagSearch(tags.
        select(function(ta) { return ta != t }).join(" ") + " ")
    this.refresh()
  },
  tagsArray: function(tags) {
    if (!tags || tags == "") {
      return []
    }
    return tags.replace(/\s+$/, "").split(/\s+/)
  },
  adjustInputColor: function() {
    this.input.style.color= this.input.value == "Tags" ? "gray" : "black"
  },
  makeWidgetContent: function() {
    var ii = this
    return scope("keyword-search", function() {
      var go = null;
      var form = null;
      var clear = null;
      var r = [
 //START ADDED
 Builder.node('div',{className:"searchBox"},[
 //END ADDED
        form = Builder.node('form', {method: "post", action: ""}, [
          ii.input = Builder.node('input', {
            type: "text",
            maxlength: "2048",
            size: "15",
            style: "color: gray",
            value: "Tags",
            id: 'sq'
          }), 
          go = translateButton({id: "go"}) ]), BR(),BR(),

          clear = translateButton({id: 'clear'})           ,
          ii.listView.htmlNode()
 //START ADDED
,BR(),
Builder.node('div',{className:"searchBox",style:"margin:-5px;"},[  ii.minimumRating.htmlNode()])        
        ])

 ///END ADDED
      ]
      var instance = ii;
      ii.input.onclick = function(e) {
        if (instance.input.value == "Tags") {
          instance.input.value = "";
        }
        instance.adjustInputColor();
        instance.inputObserver.startObserving();
      }
      ii.input.onblur = function(e) {
        if (instance.input.value == "") {
          instance.input.value = "Tags";
        }
        instance.adjustInputColor();
        instance.inputObserver.stopObserving();
      }
      go.onclick = function() {
        instance.liveSearchSubmitted();
      }
      clear.onclick = function() {
        instance.clearLiveSearch();
      }
      form.onsubmit = function() {
        instance.liveSearchSubmitted();
        return false;
      }
      var oldValue = null;
      ii.inputObserver = new MyFormObserver(ii.input, 1, 
          function(element, value) {
           if (value != oldValue) {
              oldValue = value;
              instance.makeLiveSearchModel(value)
            }
          })
      return Builder.node('span', {className: 'keyword-search'}, [ r ]);
    })
  },
  matchTags: function(tags) {
    if (this.currentTagSearch() == tags) {
      return true
    }
    r = true
    this.currentTagSearch().split(/\s+/).each(function(t) { 
      re = new RegExp('\\b' + t + '\\b');
      if (!re.test(tags)) {
        r = false
      }
    })
    return r;
  }
}

Object.extend(SearchWidget.prototype, WidgetCommon)

;

// /8::/202::/frontend:js -> <864> sharexwidget.js 

//old?_delete *mike
 
 //var atw;
sharexWidget = Class.create();
sharexWidget.prototype =
{
    defaultOptions: function(){
        return Object.extend({item:null},arguments[0]);
    },
    makeWidgetContent: function(){
        var atw = this;
        var addtomo = Builder.node('div',{id:"addToMo",style:"cursor:pointer;cursor:hand;font-weight:bold;"}, [Builder.node('img',{src:"http:\/\/mike.myservic.es/core-services/images/addto.gif"}),NBSP(),TN("share this")]);
        addtomo.m = this.options.item;
        addtomo.onclick = function(){
            atw.setContent(itemModel.currentPathPermalink());
            return;
        }
        return addtomo;
    }, 
    rerender: function(){
        var nc = this.makeWidgetContent();
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    },
    setContent:function(itm){
        var scdw = new shareDisplayWidget({item:itm});
        var w = new PWindow({
            name: "Save and Share " + itm, header: true, 
            contentWidget: scdw
        })
    }
 }  
Object.extend(sharexWidget.prototype, WidgetCommon);

sharexDisplayWidget = Class.create();
sharexDisplayWidget.prototype =
{
    defaultOptions: function(){
        return Object.extend({},arguments[0]);

    },
    makeWidgetContent: function(){
        var instance = this; 

        var permalink = this.options.item;
   //var browsermark = Builder.node('div',[Builder.node('span',{style:"font-size:120%;font-weight:bold;text-decoration:underline;"},[TN("click here to bookmark in your browser")])]); 

   //browsermark.onclick = function(){
   //bookmarkIt(instance.options.item.name,permalink)
   //} 
        var textbox = Builder.node('input',{style:"width:80%;",type:"text",value:permalink});              
        var thesharebox = Builder.node('div',[Builder.node('span',{style:"font-size:120%;font-weight:bold;"},[TN("Share: ")]),BR(),TN("Copy this link to send it to your friends"),BR(),textbox]); 
        var thelinks = getLinks(instance.options.item.name,cleanUrl(permalink));
        var clearer = Builder.node('br',{style:"clear:both;"});



            var qrw = Builder.node('div',{},[TN("no QRCode aviable!")]);
            var thesavebox = Builder.node('div',[TN("no download aviable")]);
            var theqrbox = Builder.node('div',[readmorebtn,BR(),BR(),qrw]);


        var readmorebox = Builder.node('div',{id:"readmoreqrcode",style:"padding:10px;display:none;background:#ededed;width:100%;height:200px;"},[Builder.node('div',[TN("Some More Text")])]); 
        var readmorebtn = Builder.node('a',{href:"#"},[TN("[read more]")])
        readmorebtn.onclick = function(){
             new Effect.SlideDown($("readmoreqrcode"));
        }

        //var mbw = new myBuddiesWidget({user:write_username});

        //var buddyShare = Builder.node('div',[Builder.node('span',{style:"font-size:120%;font-weight:bold;"},[TN("Share with buddies from your buddylist: ")]),BR(),mbw.htmlNode()]);
                var moduleWidget = Builder.node('div',[TN("WIDGET")]);        
        var thepublishbox = Builder.node('div',[Builder.node('span',{style:"font-size:120%;font-weight:bold;"},[TN("Publish: ")]),BR(),moduleWidget])
        return Builder.node('div',{style:"padding:20px;padding-top:0px;"},[thesharebox ,BR(),thesavebox ,BR(),thelinks,clearer,BR(),theqrbox,readmorebox,BR(),thepublishbox,BR()/*,buddyShare*/]);
    }, 
    rerender: function(){
        var nc = this.makeWidgetContent();
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    }
 }  
Object.extend(sharexDisplayWidget.prototype, WidgetCommon);


function bookmarkIt(title,url) {
    name=title; 
     if(window.sidebar) {                                 
        window.sidebar.addPanel(name, "http:\/\/"+url, '');
    } else if(document.all) {                             
        window.external.AddFavorite(url, name);
    } else if(window.opera && window.print) {             
        var e=document.createElement('a');
        e.setAttribute('href',url);
        e.setAttribute('title',name);
        e.setAttribute('rel','sidebar');
        e.click();
    }
}


function getLinks(title,url){    
  var itemurl = url;
  var addto = "";
  var title = title;
  var container = Builder.node('div',[]);
    var top = '<div ><span style="font-size:120%;font-weight:bold;">Bookmark: </span><br/>Save this link in your favorite bookmark manager:</div><a  style="color: black; font-size: 11px;" class="addto" href="javascript:bookmarkIt(\''+title+'\',\''+itemurl+'\')" title="Bookmark with your browser">Bookmark in your browser</a><br/><br/>'; 
  var bookmarks = [
  '<div id="My_Yahoo_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/e.my.yahoo.com/config/edit_bookmark?.src=bookmarks&.folder=1&.name=&.url=http%3A%2F%2F'+itemurl+'&.save=+Save+" title="Bookmark with My Yahoo Bookmarks"><img width="91" height="17" border="0" src="http:\/\/us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif" alt="My Yahoo Bookmarks"/></a></div>',
  '<div id="del.icio.us" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/del.icio.us/post?&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with del.icio.us"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/delicious.png" alt="del.icio.us"/></a></div>',
  '<div id="Mister-Wong" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mister-wong.com/index.php?action=addurl&bm_url=http%3A%2F%2F'+itemurl+'&bm_description=" title="Bookmark with Mister-Wong"><img width="80" height="15" border="0" src="http:\/\/www.mister-wong.com/img/wong.gif" alt="Mister-Wong"/></a></div>',
  '<div id="Technorati_Favorites" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/technorati.com/faves?add=http%3A%2F%2F'+itemurl+'" title="Bookmark with Technorati Favorites"><img width="91" height="17" border="0" src="http:\/\/static.technorati.com/pix/fave/tech-fav-5.gif" alt="Technorati Favorites"/></a></div>',
  '<div id="Furl" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.furl.net/storeIt.jsp?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with Furl"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/furl.png" alt="Furl"/></a></div>',
  '<div id="CiteULike" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.citeulike.org/posturl?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with CiteULike"><img width="94" height="15" border="0" src="http:\/\/static.citeulike.org/img/small-logo.png" alt="CiteULike"/></a></div>',
  '<div id="Hemidemi" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.hemidemi.com/user_bookmark/new?title=&url=http%3A%2F%2F'+itemurl+'&via=http%3A%2F%2Fwww.mysit.es%2F" title="Bookmark with Hemidemi"><img width="80" height="15" border="0" src="http:\/\/www.hemidemi.com/images/hemidemi.png" alt="Hemidemi"/></a></div>',
  '<div id="FunP" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/funp.com/portal/addrss.php?url=http%3A\/\/'+itemurl+'&via=mysites" title="Bookmark with FunP"><img width="90" height="22" border="0" src="http:\/\/funp.com/tools/images/subscribe_05.gif" alt="FunP"/></a></div>',
  '<div id="Xerpi" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.xerpi.com/block/add_link_from_extension?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Xerpi"><img width="91" height="17" border="0" src="http:\/\/www.xerpi.com/images/xerpipost.gif" alt="Xerpi"/></a></div>',
  '<div id="Facebook" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.facebook.com/share.php?src=bm&u=http%3A%2F%2F'+itemurl+'&t=&v=3" title="Bookmark with Facebook">Facebook</a></div>',
  '<div id="Netvouz" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.netvouz.com/action/submitBookmark?url=http%3A%2F%2F'+itemurl+'&title=&popup=no" title="Bookmark with Netvouz">Netvouz</a></div>',
  '<div id="Wink" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.wink.com/_/tag?url=http%3A%2F%2F'+itemurl+'&doctitle=" title="Bookmark with Wink">Wink</a></div>',
  '<div id="Ma.gnolia" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/ma.gnolia.com/bookmarklet/add?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Ma.gnolia">Ma.gnolia</a></div>',
  '<div id="BibSonomy" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.bibsonomy.org/BibtexHandler?requTask=upload&url=http%3A%2F%2F'+itemurl+'&description=" title="Bookmark with BibSonomy">BibSonomy</a></div>',
  '<div id="Jots" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.jots.com/?cmd=do_post&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Jots">Jots</a></div>',
  '<div id="Taggly" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.taggly.com/bookmarks/?action=add&address=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Taggly">Taggly</a></div>',
  '<div id="BlogMarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/blogmarks.net/my/new.php?mini=1&simple=1&title=&url=http%3A%2F%2F'+itemurl+'" title="Bookmark with BlogMarks">BlogMarks</a></div>',
  '<div id="Tailrank" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/tailrank.com/share/?link_href=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Tailrank">Tailrank</a></div>',
  //'<div id="Firefox_Opera_Safari_Internet_Explorer_Konqueror_Flock_Mozilla_Camino_Netscape" class="addtodiv"><a  style="color: black; font-size: 11px;" class="addto" href="javascript:bookmarkIt(\''+title+'\',\''+itemurl+'\')" title="Bookmark with your browser">My Browser</a></div>',
  '<div id="Windows_Live_Favorites" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/favorites.live.com/quickadd.aspx?url=http%3A\/\/'+itemurl+'&title=" title="Bookmark with Windows Live Favorites"><img width="106" height="17" border="0" src="http:\/\/shared.live.com/idYiNi0777CC-rhpYaj-HHSWi6kD2l2ATUPXIQ89GY9dmNXZasCQJowvlpjSsu4N/base/3200/Gallery/img/addlive.gif" alt="Windows Live Favorites"/></a></div>',
  '<div id="StumbleUpon" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.stumbleupon.com/submit?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with StumbleUpon"><img width="91" height="17" border="0" src="http:\/\/www.stumbleupon.com/images/su_micro.gif" alt="StumbleUpon"/></a></div>',
  '<div id="Protopage_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.protopage.com/add-button-site?url=http%3A%2F%2F'+itemurl+'&label=&type=page" title="Bookmark with Protopage Bookmarks"><img width="91" height="17" border="0" src="http:\/\/www.protopage.com/web/images/buttons/add-site-to-protopage.gif" alt="Protopage Bookmarks"/></a></div>',
  //'<div id="Shadows" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.shadows.com/features/tcr.htm?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Shadows"><img width="32" height="32" border="0" src="http:\/\/www.shadows.com/Features/images/bling/shadowme1_80x15.gif" alt="Shadows"/></a></div>',
  '<div id="Blinklist" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.blinklist.com/index.php?Action=Blink/addblink.php&Url=http%3A%2F%2F'+itemurl+'&Title=" title="Bookmark with Blinklist"><img width="80" height="18" border="0" src="http:\/\/www.blinklist.com/Theme/Graphic/Blink_Small_Button.gif" alt="Blinklist"/></a></div>',
  '<div id="YiGG" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/yigg.de/neu?exturl=http%3A%2F%2F'+itemurl+'&exttitle=" title="Bookmark with YiGG"><img width="80" height="15" border="0" src="http:\/\/www.yigg.de/images/yiggit-2.png" alt="YiGG"/></a></div>',
  '<div id="Segnalo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/segnalo.alice.it/post.html.php?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Segnalo"><img width="139" height="25" border="0" src="http:\/\/segnalo.alice.it/images/postasusegnalo.png" alt="Segnalo"/></a></div>',
  '<div id="YouMob" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/youmob.com/mob.aspx?mob=http%3A%2F%2F'+itemurl+'" title="Bookmark with YouMob"><img width="52" height="30" border="0" src="http:\/\/youmob.com/GetBeacon.axd?style=4&mob=http%3A%2F%2F'+itemurl+'" alt="YouMob"/></a></div>',
  '<div id="Slashdot" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/slashdot.org/bookmark.pl?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Slashdot">Slashdot</a></div>',
  '<div id="RawSugar" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.rawsugar.com/pages/tagger.faces?turl=http%3A%2F%2F'+itemurl+'&tttl=" title="Bookmark with RawSugar">RawSugar</a></div>',
  '<div id="Scuttle" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/scuttle.org/login/?action=add&address=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Scuttle">Scuttle</a></div>',
  '<div id="Smarking" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/smarking.com/editbookmark/?url=http%3A%2F%2F'+itemurl+'&description=" title="Bookmark with Smarking">Smarking</a></div>',
  '<div id="Jookster" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.jookster.com/JookThis.aspx?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Jookster">Jookster</a></div>',
  '<div id="Feedmarker_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.feedmarker.com/admin.php?do=bookmarklet_mark&url=http%3A%2F%2F'+itemurl+'&title=http%3A%2F%2F'+itemurl+'" title="Bookmark with Feedmarker Bookmarks">Feedmarker Bookmarks</a></div>',
  '<div id="OnlyWire" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.onlywire.com/b/?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with OnlyWire">OnlyWire</a></div>',
  '<div id="unalog" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/unalog.com/my/stack/link?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with unalog">unalog</a></div>',
  '<div id="Squidoo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.squidoo.com/lensmaster/bookmark?http%3A%2F%2F'+itemurl+'" title="Bookmark with Squidoo">Squidoo</a></div>',
  '<div id="Google_Bookmarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.'+itemurl+'/bookmarks/mark?op=edit&bkmk=http%3A%2F%2F'+itemurl+'" title="Bookmark with Google Bookmarks"><img width="104" height="17" border="0" src="http:\/\/buttons.googlesyndication.com/fusion/add.gif" alt="Google Bookmarks"/></a></div>',
  '<div id="Thoof" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/thoof.com/submit?link=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Thoof"><img width="60" height="15" border="0" src="http:\/\/thoof.com/images/thoofit.gif" alt="Thoof"/></a></div>',
  '<div id="Spurl" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.spurl.net/spurl.php?title=&url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Spurl"><img width="80" height="15" border="0" src="http:\/\/www.blifaloo.com/dimages/spurl.png" alt="Spurl"/></a></div>',
  '<div id="Yample" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/yample.com/submit.php?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Yample"><img width="100" height="20" border="0" src="http:\/\/yample.com/100x20-yample-button.png" alt="Yample"/></a></div>',
  '<div id="Oneview" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.oneview.de:80/quickadd/neu/addBookmark.jsf?URL=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Oneview"><img width="74" height="17" border="0" src="http:\/\/www.oneview.de/img/book_buttons/ov_bm_020.gif" alt="Oneview"/></a></div>',
  '<div id="Linkatopia" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/linkatopia.com/add?uri=http%3A%2F%2F'+itemurl+',title=" title="Bookmark with Linkatopia"><img width="80" height="15" border="0" src="http:\/\/linkatopia.com/images/linkabutton80.gif" alt="Linkatopia"/></a></div>',
  '<div id="Simpy" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2F'+itemurl+'&title=&v=6" title="Bookmark with Simpy"><img width="80" height="15" border="0" src="http:\/\/www.simpy.com/img/chicklet-simpy-orange.png" alt="Simpy"/></a></div>',
  '<div id="BuddyMarks" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/buddymarks.com/add_bookmark.php?bookmark_url=http%3A%2F%2F'+itemurl+'&bookmark_title=" title="Bookmark with BuddyMarks"><img width="95" height="21" border="0" src="http:\/\/buddymarks.com/images/bmpromolink.gif" alt="BuddyMarks"/></a></div>',
  '<div id="Small_Things" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/smallthings.kilobox.mobi/login.php/?action=add&address=http%3A%2F%2F'+itemurl+'" title="Bookmark with Small Things"><img width="80" height="15" border="0" src="http:\/\/smallthings.kilobox.mobi/small-things.gif" alt="Small Things"/></a></div>',
  '<div id="Ask.com_MyStuff" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/mystuff.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Ask.com MyStuff">Ask.com MyStuff</a></div>',
  '<div id="Maple" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.maple.nu/bookmarks/bookmarklet?bookmark[url]=http%3A%2F%2F'+itemurl+'&bookmark[description]=" title="Bookmark with Maple">Maple</a></div>',
  '<div id="Wists" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/wists.com/r.php?r=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Wists">Wists</a></div>',
  '<div id="Kinja" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/kinja.com/id.knj?url=http%3A%2F%2F'+itemurl+'" title="Bookmark with Kinja">Kinja</a></div>',
  '<div id="Gravee" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.gravee.com/account/bookmarkpop?u=http%3A%2F%2F'+itemurl+'&t=" title="Bookmark with Gravee">Gravee</a></div>',
  '<div id="Connotea" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.connotea.org/add?uri=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Connotea">Connotea</a></div>',
  '<div id="Backflip" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.backflip.com/add_page_pop.ihtml?url=http%3A%2F%2F'+itemurl+'&title=" title="Bookmark with Backflip">Backflip</a></div>',
  '<div id="MyLinkVault" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mylinkvault.com/link-page.php?u=http%3A%2F%2F'+itemurl+'&n=" title="Bookmark with MyLinkVault">MyLinkVault</a></div>',
  '<div id="SiteJot" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.sitejot.com/addform.php?iSiteAdd=http%3A%2F%2F'+itemurl+'&iSiteDes=" title="Bookmark with SiteJot">SiteJot</a></div>',
  '<div id="Digg" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/digg.com/submit?phase=2&url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Digg"><img width="100" height="20" border="0" src="http:\/\/digg.com/img/badges/100x20-digg-button.gif" alt="Digg"/></a></div>',
  '<div id="Mixx" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.mixx.com/submit?page_url=http%3A%2F%2F'+itemurl+'" title="Add to Mixx"><img width="102" height="17" border="0" src="http:\/\/www.mixx.com/images/buttons/mixx-button1.png" alt="Mixx"/></a></div>',
  '<div id="Sphere" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.sphere.com/search?q=sphereit:http%3A%2F%2F'+itemurl+'" title="Add to Sphere"><img width="80" height="25" border="0" src="http:\/\/www.sphere.com/images/sphereit_button.png" alt="Sphere"/></a></div>',
  '<div id="Bitty_Browser" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.bitty.com/manual/?contenttype=website&contentvalue=http%3A%2F%2F'+itemurl+'" title="Add to Bitty Browser"><img width="91" height="17" border="0" src="http:\/\/www.bitty.com/img/bittychicklet_91x17.gif" alt="Bitty Browser"/></a></div>',
  '<div id="dzone" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.dzone.com/links/add.html?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to dzone"><img width="44" height="13" border="0" src="http:\/\/widgets.dzone.com/links/images/std/vwidget3/vwidget_logo.gif" alt="dzone"/></a></div>',
  '<div id="Diigo" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.diigo.com/post?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Diigo"><img width="86" height="17" border="0" src="http:\/\/www.diigo.com/images/difb_big.gif" alt="Diigo"/></a></div>',
  '<div id="Design_Float" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.designfloat.com/submit.php?url=http%3A%2F%2F'+itemurl+'" title="Add to Design Float"><img width="54" height="17" border="0" src="http:\/\/www.designfloat.com/templates/green/images/df_button.gif" alt="Design Float"/></a></div>',
  '<div id="diglog" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.diglog.com/submit?act=like&returnurl=true&title=&url=http%3A%2F%2F'+itemurl+'" title="Add to diglog"><img width="80" height="15" border="0" src="http:\/\/www.diglog.com/images/diglog_80x15_4.gif" alt="diglog"/></a></div>',
  '<div id="Technotizie" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.technotizie.it/posta_ok?action=f2&title=&url=http%3A%2F%2F'+itemurl+'" title="Add to Technotizie"><img width="117" height="24" border="0" src="http:\/\/www.technotizie.it/images/technotiziesubmit3.png" alt="Technotizie"/></a></div>',
  '<div id="Reddit" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/reddit.com/submit?url=http%3A%2F%2F'+itemurl+'&title=" title="Add to Reddit">Reddit</a></div>',
  '<div id="NewsVine" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.newsvine.com/_tools/seed&save?u=http%3A%2F%2F'+itemurl+'&h=" title="Add to NewsVine">NewsVine</a></div>',
  '<div id="NowPublic" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/view.nowpublic.com/?src=http%3A%2F%2F'+itemurl+'&t=" title="Add to NowPublic">NowPublic</a></div>',
  '<div id="Hugg" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.hugg.com/submit?url=http%3A%2F%2F'+itemurl+'" title="Add to Hugg">Hugg</a></div>',
  '<div id="Care2_News" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.care2.com/news/news_post.html?url=http%3A%2F%2F'+itemurl+'&title=&v=1.3" title="Add to Care2 News">Care2 News</a></div>',
  '<div id="Netscape.com" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.netscape.com/submit/?U=http%3A%2F%2F'+itemurl+'&T=" title="Add to Netscape.com">Netscape.com</a></div>',
  '<div id="LiveJournal" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.livejournal.com/update.bml?subject=" title="Add to LiveJournal">LiveJournal</a></div>',
  '<div id="Feedo_Style" class="addtodiv"><a target="_blank" style="color: black; font-size: 11px;" class="addto" href="http:\/\/www.feedostyle.com/create_digest.aspx?feed=http%3A%2F%2F'+itemurl+'" title="Add to Feedo Style">Feedo Style</a></div>',

];

var alldivs = "";
bookmarks.sort().each(function(b){
    alldivs += b;
});

container.innerHTML = top+alldivs
return container;
}

function cleanUrl(url){ 
    var nuurl = url.split('http:\/\/'); 
    return nuurl[1];
}

;

// /8::/202::/frontend:js -> <10273> tabswidget.js 

TabsWidget = Class.create();
TabsWidget.prototype = {
  defaultOptions: function() {
    return {
      tabs: [],
      showFirstTab: true
    }
  },
  showTab: function(event, tab) {
    if (this.current) {
      if (this.current.beforeTabHide) this.current.beforeTabHide()
      Element.hide(this.current._body)
      Element.toggleClassName(this.current._header.down('span'), "selected")
    }
    Element.show(tab._body)
    Element.toggleClassName(tab._header.down('span'), "selected")
    if (!tab._reshowing && tab.afterInitiallyShowingTab) {
      tab._reshowing = true
      tab.afterInitiallyShowingTab()
    }
    if (tab.afterTabShow) tab.afterTabShow()
    this.current = tab
  },
  makeWidgetContent: function() {
    var name = this.options.name;
    var headers = Builder.node('ul', {id:name+"_ul"});
    var toptabs = Builder.node('div', {
      id: name+"_box",
      className: 'toptabs'
    }, [
      Builder.node('div', {
        id: this.options.name+'_tabsF'
      }, [headers]),
      Builder.node('div', {
        style: 'clear:both;'
      })
    ]);
    var widget  = Builder.node('div', [toptabs])
    $A(this.options.tabs).each(function(tab) {
      this.renderTab(tab)
      headers.appendChild(tab._header)
      widget.appendChild(tab._body)
    }.bind(this))
    if (this.options.showFirstTab) {
      this.showTab(null, this.options.tabs[0])      
    }
    return widget
  },
  renderTab: function(tab) {
    tab._body = $(this.renderBody(tab))
    Element.hide(tab._body)
    tab._header = $(this.renderHeader(tab))
    Event.observe(
      Element.down(header, 'a'),
      'click',
      this.showTab.bindAsEventListener(this, tab)
    )
    return tab
  },
  renderHeader: function(tab){
    var o = Object.extend({astyle: "", pstyle: ""}, tab)
    if (typeof o.title == "string") {
      var title = Builder.node('span',{
        id:"span_"+o.name,
        className:"taba",
        style:o.pstyle
      },[TN(o.title)])
    }
    else {
      var title = o.title
      title.id = "span_"+o.name
      Element.addClassName(title, "taba")
      var obj = {}
      if (o.pstyle != "") {
        $A(o.pstyle.split(";")).each(function(p) {
          var sp = p.split(":")
          obj[sp[0]] = sp[1]
        })
        Element.setStyle(title, obj)        
      }
    }
    header = Builder.node('li', {id:"li_"+o.name});
    header_1_a = Builder.node('a', {style:o.astyle}, [title]);
    header.appendChild(header_1_a);
    return header;
  },
  renderBody: function(tab) {
    return tab.widget.htmlNode()
  },
  rerender: function(){
    this.redrawCompletely()
  }
}
Object.extend(TabsWidget.prototype, WidgetCommon)

;

// /8::/202::/frontend:js -> <911> tooltip.js 

function totalTop(element) {
  var r = element.offsetTop
  while ((element = element.offsetParent) != null) {
    if (element.tagName != 'HTML') {
      r += element.offsetTop
    }
  }
  return r
}

function totalLeft(element) {
  var r = element.offsetLeft
  while ((element = element.offsetParent) != null) {
    if (element.tagName != 'HTML') {
      r += element.offsetLeft
    }
  }
  return r
}

ElementLocator = Class.create();
ElementLocator.prototype = {
  initialize: function() {
    this.o = Object.extend({
      element: null,
      noXswap: true,
      minYleft: 180
    }, arguments[0] || {})
    this.e = this.o.element
    this.ySwapped = false
  },
  makeRel: function() {
    return Object.extend({
      x: 0,
      y: 0,
      ySwapAdd: 0
    }, arguments[0] || {})
  },
  locate: function(rel) {
    rel = this.makeRel(rel)
    var instance = this;
    function doLocate(rel, _o) {
      var o = Object.extend({
        fX: function(a, b) { return a * b },
        fY: null,
        totalTop: totalTop,
        totalLeft: totalLeft
      }, _o || {})
      if (!o.fY) {
        o.fY = o.fX
      }
      instance.y = o.totalTop(instance.e) + 
          (o.fY(instance.e.offsetHeight, rel.y))
      instance.x = o.totalLeft(instance.e) + 
          (o.fX(instance.e.offsetWidth, rel.x))
      instance.alignLeft = false
      if (!instance.o.noXswap) {
        var _totalLeft = instance.x + o.fX(instance.e.offsetWidth, 2-rel.x)
        instance.alignLeft = _totalLeft > windowWidth()
        if (instance.alignLeft) {
          instance.x = o.totalLeft(instance.e) - 
              (o.fX(instance.e.offsetWidth, rel.x))
        }
      }
    }
    doLocate(rel)
    var yLeft = (windowHeight() - (totalTop(this.e) + this.e.offsetHeight)) + 
        yScroll()
    if (yLeft < this.o.minYleft) {
      this.ySwapped = true
      var r = doLocate(rel, {
        fY: function(a, b) { return -(a * (1 - (b + rel.ySwapAdd))) },
        totalTop: function(e) { return windowHeight() - totalTop(e) }
      })
    } 
    return this;
  },
  useXSwap: function() {
    this.o.noXswap = false;
    return this
  },
  debug: function() {
    this._debug = true
    return this
  },
  applyWithOffset: function(e, rel) {
    rel = this.makeRel(rel);
    this.effectiveY = this.y + rel.y
    if (this.ySwapped) {
      e.style.top = null
      e.style.bottom = this.effectiveY + "px";
    } else {
      e.style.bottom = null
      e.style.top = this.effectiveY + "px";
    }
    this.effectiveX = (this.x + rel.x) 
    e.style.left = this.effectiveX + "px";
    if (this._debug) {
      d("Ax:" + this.x + "y:" + this.y + "yS:" + this.ySwapped)
    }
    return this
  },
  apply: function(e) {
    return this.applyWithOffset(e)
  },
  dump: function() {
    d("x:" + this.x + "y:" + this.y + "yS:" + this.ySwapped)
  }
}

AutoHideTooltip = Class.create()
AutoHideTooltip.prototype = {
  initialize: function() {
  },
  anotherTooltipActivated: function(current) {
    this.observers.select(function(o) { 
      return o.autoHide() && o != current
    }).each(function(o) { o.hideTotally() })
  },
  hideTooltips: function() {
    this.anotherTooltipActivated(null)
  },
  hideAllTooltips: function() {
    this.notifyObservers("hideTotally")
  }
}

Object.extend(AutoHideTooltip.prototype, Observable)

function hideAllTooltips() {
  if (__autoHider) { __autoHider.hideAllTooltips() }
}

var __autoHider = null

var __tt = null
var ll = null

Tooltip = Class.create();
Tooltip.prototype = {
  initialize: function(className) {
    if (!__autoHider) {
      __autoHider = new AutoHideTooltip()
    }
    this.o = Object.extend({
      className: "",
      zIndex: 20,
      generateTooltipContent: function(o) {
        return TN("No content specified!")
      },
      onShowIcon: function() {
      },
      onHideIcon: function() {
      },
      collapsing: false,
      ySwapMinLeft: 180,
      position: {x: 0, y: 0, ySwapAdd: 0},
      autoHide: false,
      defaultCollapsed: false
    }, arguments[0] || {})
    this.current = {};
    this.collapsed = this.o.defaultCollapsed
    this.belowDiv = this.makeDiv("arrow.gif")
    document.body.appendChild(this.belowDiv)
    this.aboveDiv = this.makeDiv("tt_arrow_down.gif", true)
    document.body.appendChild(this.aboveDiv)
    this.last = null
    this.isShown = false;
    var instance = this;
    if (this.o.collapsing) {
      __tt = this
      this.collapseBackground = this.makeCollapseBackground()
      document.body.appendChild(this.collapseBackground);
      this.collapseAbove = this.makeCollapseIcon("expand");
      this.collapseAbove.onclick = function() {
        instance.collapseIconClicked();
        return false
      }
      document.body.appendChild(this.collapseAbove)
      this.expandAbove = this.makeCollapseIcon("collapse");
      this.expandAbove.onclick = function() {
        instance.expandIconClicked();
        return false
      }
      document.body.appendChild(this.expandAbove)
      this.expandBelow = this.makeCollapseIcon("expand");
      this.expandBelow.onclick = function() {
        instance.expandIconClicked();
        return false
      }
      document.body.appendChild(this.expandBelow)
      this.collapseBelow = this.makeCollapseIcon("collapse");
      this.collapseBelow.onclick = function() {
        instance.collapseIconClicked()
        return false
      }
      document.body.appendChild(this.collapseBelow)
    }
    __autoHider.addObserver(this);
  },
  autoHide: function() {
    return this.o.autoHide
  },
  makeDiv: function(imageName, above) {
    var pos = (above ? "above" : "below")
    var arrow = this[pos + "Arrow"] = Builder.node('div', {
      className: 'arrow',
      style: "background-image: url('/images/" + imageName + "')"
    })
    var content = this[pos + "Content"] = Builder.node('div', {
      className: 'content'
    })
    var span = null;
    var r = Builder.node('div', {
      className: this.o.className,
      style: 'position: absolute; display: none; z-index: ' +
          this.o.zIndex + ';' 
    }, [ span = Builder.node('span', { className: 'tooltip' })])
    if (above) {
      span.appendChild(content)
      span.appendChild(arrow)

    } else {
      span.appendChild(arrow)
      span.appendChild(content)
    }
    if (this.o.autoHide) {
      var instance = this
      r.onmouseover = function() { instance.mouseover = true }
      r.onmouseout = function() { 
        instance.mouseover = false
        instance.hideTimeout = 2 
      }
    }
    return r
  },
  arrow: function() {
    return this.ySwapped ? this.aboveArrow : this.belowArrow
  },
  content: function() {
    return this.ySwapped ? this.aboveContent : this.belowContent
  },
  div: function() {
    return this.ySwapped ? this.aboveDiv : this.belowDiv
  },
  collapse: function() {
    return this.ySwapped ? this.collapseAbove : this.collapseBelow
  },
  expand: function() {
    return this.ySwapped ? this.expandAbove : this.expandBelow
  },
  makeCollapseBackground: function() {
    return Builder.node('div', {
      style: 'position: absolute; ' + 
          'z-index: ' + (this.o.zIndex - 1) + ';' +
          'background-color: #2FB6DE;' + 
          'height: 28px; ' + 
          'display: none; '
    }, [/*itemModel.actions.actionsForItem({m:this.o.m})*/])
  },
  makeCollapseIcon: function(imageName) {
    return Builder.node('div', {
      style: 'display: none; color: white;margin-left:40px;',
      className: 'tooltip-collapsing'
    }, [
      //translateText({id: "details"}),
      Builder.node('img', {
        src: '/images/' + imageName + '.gif',
        alt: '',
        align: "absmiddle"
      })
    ])
  },
  makeOptions: function() {
    return Object.extend({
      fast: false
    }, arguments[0] || {})
  },
  collapseIconClicked: function() {
    this.collapsed = true
    this.showIcon({fast: true})
    this.hide({fast: true})
  },
  expandIconClicked: function() {
    this.collapsed = false
    this.current = {}
    this.delayedShow(this.last, {fast: true});
  },
  locator: function() {
    return new ElementLocator({
      element: this.current.element, 
      minYleft: this.o.ySwapMinLeft
    })
  },
  showBackground: function(l) {
    if (this.o.collapsing) {
      this.collapseBackground.style.width = 
          this.current.element.offsetWidth + "px"
      if (l.ySwapped) {
        l.applyWithOffset(this.collapseBackground, {
          x: -(this.o.position.x * this.current.element.offsetWidth), 
          y: -18
        })
        var eTop = (windowHeight() - totalTop(this.current.element))
        this.collapseBackground.style.bottom = eTop + "px";
        this.collapseBackground.style.height = 
            26 + (l.effectiveY - eTop) + "px"
      } else  {
        l.applyWithOffset(this.collapseBackground, {
          x: -(this.o.position.x * this.current.element.offsetWidth), 
          y: -18
        })
        var eTop = totalTop(this.current.element) +
            this.current.element.offsetHeight
        this.collapseBackground.style.top = eTop + "px";
        this.collapseBackground.style.height = 
            26 + (l.effectiveY - eTop) + "px"
      }
      new Effect.Appear(this.collapseBackground, {duration: 0});
    }
  },
  showIcon: function() {
    this.isShown = true;
    if (this.o.collapsing) {
      var options = this.makeOptions(arguments[0]) 
      if (!this.current.element) {
        return
      }
      var l = this.locator().locate(this.o.position);
      this.ySwapped = l.ySwapped
      this.o.onShowIcon(this, options)
      var showElement = this.collapsed ? this.expand() : this.collapse()
      if (this.lastShownIcon) {
        this.lastShownIcon.hide()
      }
      l.applyWithOffset(showElement, {x: -24, y:-18})
      this.lastShownIcon = showElement
      this.showBackground(l)
      new Effect.Appear(showElement, {duration: (options.fast ? 0 : 0.01)});
    }
  },
  hideTotally: function() {
    if (this.isShown) {
      this.hide()
      this.hideIcon();
      if (this.o.autoHide) {
        clearInterval(this.hideInterval)
        this.hideInterval = null
      }
    }
  },
  hideIcon: function() {
    if (this.o.collapsing) {
      this.collapseBackground.hide()
      if (this.lastShownIcon) {
        this.lastShownIcon.hide()
      }
      this.o.onHideIcon(this)
    }
    this.isShown = false;
    this.current = {}
  },
  delayedShow: function(_o) {
    if (this.current.element == _o.element) {
      return 
    }
    var o = Object.extend({
      element: null
    }, _o || {})
    var options = this.makeOptions(arguments[1])
    this.current = o
    this.o.m = o.m;
    var instance = this;
    this.delayedShowInterval = setTimeout(function() { 
      if (instance.current.element == o.element) {
        __autoHider.anotherTooltipActivated(this)
        instance.showIcon(options);
        if (!instance.collapsed) {
          instance.makeTooltip(o, options)
        }
        instance.last = o
      }
    }, (options.fast ? 0 : 10));
  },
  hide: function() {
    var options = this.makeOptions(arguments[0])
    Effect.Fade(this.div(), { duration: (options.fast ? 0 : 0.1) })
  },
  refresh: function() {
    if (this.last) {
      if (!this.collapsed) {
        this.hide({fast: true})
        this.makeTooltip(this.last, {fast: true})
      }
      this.showIcon()
    }
  },
  checkAutohide: function() {
    this.hideTimeout = 2
    this.mouseover = false
    if (this.o.autoHide && !this.hideInterval) {
      var instance = this
      this.hideInterval = setInterval(function() { 
        if (instance.mouseover) { return }
        if (instance.hideTimeout < 1) { instance.hideTotally() }
        instance.hideTimeout--
      }, 500)
    }
  },
  makeTooltip: function(o, options) {
    this.current = o;
    var options = this.makeOptions(arguments[2])
    if (this.generatedContent) {
      this.previousDiv.hide()
      this.previousContent.removeChild(this.generatedContent);
    }

    var l = this.locator().useXSwap().locate(this.o.position);
    this.ySwapped = l.ySwapped
    l.apply(this.div())
    this.arrow().style.backgroundPosition = "center " + (l.alignLeft ? 
        'right;' : 'left')
    this.content().appendChild(this.generatedContent =
        this.o.generateTooltipContent(o))
    this.previousContent = this.content();
    this.previousDiv = this.div()
    new Effect.Appear(this.div(), {duration: (options.fast ? 0 : 0.1)});
    this.showIcon(options);
    this.checkAutohide()
  }
}


function makeStandardItemTooltip(o) {
  var o = Object.extend({
    select: false
  }, arguments[0] || {}) 
  var ttInstance = null;
  var selectBoxInput = null;
  var selectBox = null;
  if (o.select) {
    selectBox = Builder.node('div', {
      style: 'display: none',
      className: 'item-selecting'
    }, [
      selectBoxInput = Builder.node('input', {
        type: 'checkbox'
      })
    ])
    document.body.appendChild(selectBox)
    selectBoxInput.onclick = function() {
      toggleSelection(ttInstance.current)
    }
  }
  return scope("explorer .tooltip", function() { 
    return new Tooltip({
      position: {y: 1.15, x: 0.70, ySwapAdd: 0.1},
      className: "item", 
      collapsing: true,
      defaultCollapsed: true,
      ySwapMinLeft: 180,
      generateTooltipContent: function(o) {
        var r = Builder.node('div', [
          new shareWidget({item:o.m,model: o.model}).htmlNode(),
          new CommentsWidget({m:o.m,model: o.model}).htmlNode(),
          translateText({
            id: 'added-by',
            revert: "%1 by %2",
            args: [makeNiceDate(o.m.added_at), o.model.user(o.m.pretty_name)]
          }), BR()
        ])
        var rows = [{}]
        if (!o.model.actions.isFolder(o.m) && o.m.rating) {
          rows.push([
            Builder.node('span', {style: "font-weight: bolder"}, [
              TN("Rating: ")
            ]),
            makeRatingWidget(o.model, o.m).htmlNode()
          ])
        }
        rows.push([
          Builder.node('span', {style: "font-weight: bolder"}, [
            translateText({ id: 'privacy'})
          ]),
          TN(o.m.permission)
        ])
        if (!o.model.actions.isFolder(o.m) && o.m.tags) {
          rows.push([
            Builder.node('span', {style: "font-weight: bolder"}, [
              translateText({ id: 'tags'})
            ]),
            o.model.actions.selectableTags(o)
          ])
        }
        r.appendChild(table.apply(this, rows))
        return  Builder.node('div',{style:"margin:-10px;"},[
          new BoxWidget({
            id:'fw',
            title:NBSP(),
            node:r,
            className:"tooltip",
            width:220
          }).htmlNode()
        ])
      },
      onShowIcon: function(tt) {
        if (!o.select) {
          return
        }
        ttInstance = tt
        var options = tt.makeOptions(arguments[1]) 
        if (!tt.current.element) {
          return
        }
        tt.locator().locate(tt.o.position).applyWithOffset(selectBox, {
          x: (-(tt.o.position.x - 0.05) * tt.current.element.offsetWidth), y: -18
        })
        var s = tt.current.m.selected;
        selectBoxInput.checked = s != undefined && s != false
        new Effect.Appear(selectBox, {duration: (options.fast ? 0 : 0.01)});
      },
      onHideIcon: function(tt) {
        if (!o.select) {
          return
        }
        selectBox.hide();
      }
    })
  })
}

;

// /8::/202::/frontend:js -> <863> tooltipwidgetoverride.js 

var __ttw = null
TooltipWidget = Class.create();
TooltipWidget.prototype = {
  defaultOptions: function() {
    return {
      className: "",
      zIndex: 20,
      icon: function() { return TN("No icon") },
      tooltipContent: function(o) { return TN("No content") }
    }
  },
  setup: function() {
    var instance = this;
    this.tooltip = new Tooltip({
      className: this.options.className,
      zIndex: this.options.zIndex,
      position: {y: 0.7},
      autoHide: true,
      generateTooltipContent: function(o) {
////ADDED
          return new BoxWidget({id:'fw',title:NBSP(),node:instance.options.tooltipContent(o),className:"tooltip",width:150}).htmlNode()

///END ADDED

      }
    })
  },
  makeWidgetContent: function() {
    __ttw = this
    var div = this.options.icon()
    var instance = this;
    div.onmouseover = function() {
      instance.tooltip.delayedShow({element: div})
    }
    //div.onmouseout = function() {
    //  instance.tooltip.hideTotally()
    //}
    return div
  }
}

Object.extend(TooltipWidget.prototype, WidgetCommon)


;

// /8::/202::/frontend:js -> <90137> topbadgewidgets.js 

 var TopBadgeWidget = {
  setup: function() {
    Object.extend(this, ConversationView)
  },
  makeWidgetContent: function() {
    var r = Builder.node('div', {
      id:        this.options.type+'_badge',
      style:     this.options.style+'position:absolute;width:540px;;top:8px;',
      className: this.options.type + "_badge" //"badge"
    })
    if (itemModel.paramsInfo()) {
      r.appendChild(TN(itemModel.paramsInfo()))
      r.appendChild(BR())
    }
    if (itemModel.paramsLoginError() && this.loginErrorView) {
      r.appendChild(this.loginErrorView())
      r.appendChild(BR())
    }

 
    r.appendChild(this.makeProfileContent());
    $("title-bar-left").appendChild(this.headericons());
  
    //edited by mike 
    if(!logged_in){
        $("title-bar-left").appendChild(this.wordcloud()); 
    }

 
    if (Prototype.Browser.IE) {
        r.style.top = (parseFloat(r.style.top)-5) + "px"
    }
    return r;
  },
  wordcloud:function(){
      return Builder.node('div',{id:"topiconsdiv2",style:"position:absolute;padding:1px;float:left;height:48px;overflow:hidden;width:600px;left:175px;top:9px;"},[new WordCloudWidget().htmlNode()]);
  },
  getUserModel:function(){
    if (!this.userModel) {
      var userimage;
      if (this.options.profile.data.userimage) {
        userimage = localizeURL(this.options.profile.data.userimage)
      }
      var onlineP = true // this.options.profile.data.online
      var status = onlineP ? "online" : "offline"
      this.userModel = {
        user: this.options.profile.data.username,
        thumbnail_image_url: userimage || "/images/user_thumb_placeholder.jpg",
        // status:Builder.node('img', {
        //   src: "/core-services/images/x"+status+".gif",
        //   border: 0
        // })
        status: Builder.node('span')
      }      
    }
    return this.userModel;
  },
  makePhraseBox: function() { 
    var w = "";
    if(this.options.type == "top"){
        w = "285px"; 
    }else{
        w = "100%";
    }

 
    var l1 = serviceLink({
        user: "core",
        service: "files@core",
        action:"get_file?path=/phrase.png"
    })

 
    var phrase = Builder.node('div',{
      id: this.options.type+"_uphrase",
      className: "uphrase",
      style: "overflow:hidden;width:"+w+";padding:2px;height:37px;" +
             "font-size:12px;line-height:27px;font-weight:bolder;background:url("+l1+") no-repeat;"
    });
    this.phraseModel = new DisplayModel({
      service: "messages",
      user: this.options.profile.data.username,
      sortByColumn: "added_at",
      reverse: true
    })
    //this.phraseModel.observeOnce({update: function() {
    //  gtuf = function() {
    //    //this.phraseModel.observeOnce({afterPathChanged: function() {
    //    //  this.phraseModel.addObserver({update: function() {
    //    //    ms = this.phraseModel.getModel()
    //    //    if (ms.length > 0) {
    //    //      var s = ms[0].status 
    //    //      phrase.innerHTML = s ? s : "---"
    //    //    }
    //    //    else {
    //    //      if (this.phraseModel.canWrite()) {
    //    //        phrase.innerHTML = ""
    //    //        phrase.appendChild(translateText({path: ".badge", id: "write-message"}))
    //    //      }
    //    //      else {
    //    //        phrase.innerHTML = ""
    //    //        phrase.appendChild(translateText({path: ".badge", id: "no-message"}))
    //    //      }
    //    //    }
    //    //  }.bind(this)})
    //    //}.bind(this)})
    //    //this.phraseModel.changeToFolder("/updates")
    //  }.bind(this)
    //  if (this.phraseModel.findItemByName("updates")) {
    //    gtuf()
    //  }
    //  else if (this.phraseModel.canWrite()) {
    //    var f = this.phraseModel.addFolder()
    //    f.permission = "everyone"
    //    f.name = "updates"
    //    this.phraseModel.storeItem(f, {afterStore: function() {
    //      gtuf()
    //    }})
    //  }
    //  else if (this.phraseModel.user() == "guest") {
    //    phrase.innerHTML = ""
    //    phrase.appendChild(translateText({path: ".badge", id: "login-or-register"}))
    //  }
    //  else {
    //    phrase.innerHTML = ""
    //    phrase.appendChild(translateText({path: ".badge", id: "no-message"}))
    //  }
    //}.bind(this)})
    if (this.phraseStyle) Element.setStyle(phrase, this.phraseStyle())
    var tip = Builder.node('div',{
      style:"color:black;position:relative;z-index:3;overflow:hidden;margin-top:-3px;" +
            "margin-left:30px;height:7px;"
    },[
      Builder.node('img',{src:"/core-services/images/bubbletip.gif"})
    ]);

 /*edited by mike*/
   // var roundbox = roundIt({className:"roundBtnT",node:phrase,width:"100%"})        
    var phrasebox = Builder.node('div',{
      style:"position:absolute;top:0px;right:50px;width:80%;color:black;"
    },[/*tip,*/phrase/*,roundbox*/]);

     if (this.options.type == "top" && this.phraseBoxStyle) Element.setStyle(phrasebox, this.phraseBoxStyle())
  
    if (writeUserModel == this.options.profile) {
      phrasebox.style.cursor = "pointer"
      // Event.observe(phrasebox, 'click', this.updatesWindow.bindAsEventListener(this))
    }
    return phrasebox;
  },
  updatesWindow: function(event) {
    new ThemedWindow({
      maximizable: false,
      minimizable: false,
      showEffect: Element.show,
      hideEffect: Element.hide,
      width: 500,
      height: 500
    }, function(w) {
      w.setContent(this.conversationView({
        msgs: $A(this.phraseModel.getModel()).map(function(u) {
          u.message = u.status
          return u;
        }).reverse()
      }))
      w.setZIndex(10000) // for IE
      w.showCenter()
    }.bind(this))    
  },
  makeUserStatus: function() {
    // The user status, currently disabled
    var sl = Builder.node('div',{
      id:this.options.type+"_ustatus",
      className: "ustatus",
      style:"overflow:hidden;width:100%;height:100%;padding:3px;"
    },[
      this.getUserModel().status
    ]);
    sl.type = this.options.type;
    return sl
  },
  userNameBox: function() {
    var unameBox = Builder.node('div',{
      style:"position:absolute;right:30px;top:30px;overflow:hidden;width:130px;color:#000000;font-weight:bolder;"
    },[
      TN(this.getUserModel().user)
    ]);
    return unameBox
  },
  userPic: function() {
    if (!this.up) {
      this.up = Builder.node('img',{
        src: this.getUserModel().thumbnail_image_url,
        alt: 'userimage',
        style: 'height:50px;width:50px;z-index:1;border:1px solid silver;',
        border: 0
      })       
    }
    return this.up
  },
  makeProfileContent:function(){
    if (logged_in) {
      var upper = this.upperView()
      var lower = this.lowerView()
      var phrasebox = this.makePhraseBox() 
    }
    else {
      var upper = this.loginViewUpper()
      var lower = this.loginViewLower()
      var phrasebox = EMPTY()
    }
    var innertable = Builder.node('div',{},[upper,lower]); 
 
   
 
    var mainDiv = Builder.node('div',{id:"mainDiv"},[
      this.mainView(innertable,phrasebox),
      phrasebox
    ]);
    return mainDiv;
  },
  cvSetup: function(c) {
    this.cv.model = this.phraseModel
  },
  cvFormSubmit: function(message, c, msgs) {
    this.phraseModel.storeItem(this.phraseModel.addItem({
      status: message,
      name: "update",
      permission: "everyone"
    }), {afterStore: function(m) {
      m.message = m.status
      this.cvUpdateView(m, c, msgs)
    }.bind(this)})    
  }
}

Object.extend(TopBadgeWidget, WidgetCommon)

 
 
 ///////////////////////
 
 
 var updateMessages;
WriteUserTopBadgeWidget = Class.create()
WriteUserTopBadgeWidget.prototype = {
  defaultOptions: function(){
    return {
      profile: writeUserModel,
      type:    "top",
      style:   "float:right;width:540px;"
    };
  },
  loginErrorView: function() {
    return TN(itemModel.paramsLoginError())
  },
  loginForm: function() {
    var unameboxx = Builder.node('input', {
      type: "text",
      /*className:"inputBox",*/
      name: "username", 
      size: "15",
      value: "Username",
      style:"width:60px;height:12px;font-size:11px;font-family:Trebuchet MS;color:white;background:#bbbbbb;padding:1px;border:1px solid #666666;margin:1px;",
      id: this.options.type + "_username"
    });
    Event.observe(unameboxx,'focus',function(e) {
      if ($(unameboxx).value == "Username") {
        $(unameboxx).value = "";
      }
    });
    Event.observe(unameboxx,'blur',function(e) {
      if ($(unameboxx).value == "") {
        $(unameboxx).value = "Username";
      }
    });
    var upassboxx =  Builder.node('input', {
      type: "password",
      name: "password",
      /*className:"inputBox",*/
      size: "15",
      value: "PASSWORD",
      style:"width:60px;height:12px;font-size:11px;font-family:Trebuchet MS;color:white;background:#bbbbbb;padding:1px;border:1px solid #666666;margin:1px;",
      id: this.options.type + "_password"
    });
    Event.observe(upassboxx ,'focus',function(e) {
      if ($(upassboxx).value == "PASSWORD") {
        $(upassboxx).value = "";
      }
    });
    Event.observe(upassboxx ,'blur',function(e) {
      if ($(upassboxx).value == "") {
        $(upassboxx).value = "PASSWORD";
      }
    });

 

        var tbtn1 = translateButton({
          id: "login",
          node: Builder.node('input', {
            type: "submit",
            style:"color:black;margin:0px;width:64px;height:20px;font-family:Trebuchet MS;font-size:11px;",
            value: "login",
            /*className:"button",*/
            id: this.options.type + "_login"
          })
        })

 
 var logindiv = Builder.node('div',{style:"position:absolute;top:8px;right:25px;width:80px;"},[unameboxx,BR(),upassboxx,BR(),tbtn1]);

 
    var theform = Builder.node('form',{
      method: "post", 
      style:"margin:0 0;",
      action: serviceLink({
        user: "www",
        service: "sites",
        controllerName: "account",
        action: "login"
      })
    },[
      logindiv,
      Builder.node('input', {
        type:  "hidden",
        name:  "desired_url",
        value: window.location
      }), 
      Builder.node('input', {
        type:  "hidden",
        name:  "desired_service",
        value: itemModel.serviceName()
      }) 
    ])
    return theform;    
  },
  changeSite: function() {
    if (!this._cs) {
      this._cs = new changeSiteWidget({
        profile: this.options.profile,
        text:this.getUserModel().user,
        style:"font-weight:bolder;font-size:120%;color:black;margin-right:5px;"
      })
    }
    return this._cs;
  },
  loginViewUpper: function() {
    var upper = this.loginForm();
    return upper;
  },
  upperView: function() {
    var upper = Builder.node('div',{style:"font-family:Trebuchet MS;font-size:11px;position:absolute;text-align:center;top:12px;right:38px;width:130px;"},[this.makeUserStatus(),this.changeSite().htmlNode(),new LogoutWidget().htmlNode()]); 
    return upper;
  },
  loginViewLower: function() {
    var l1 = serviceLink({
        user: "core",
        service: "files@core",
        action:"get_file?path=/bluebtn.png"
    })
 
    var regbtn = Builder.node('div',{
      id: "register",
      style:"cursor:pointer;text-align:center;font-size:12px;background:url("+l1+");margin:3px;color:white;line-height:23px;width:100px;height:26px;"//,
      /*className:"button"*/
    },[translateText({path: ".badge", id: "join-now"})]);
      Event.observe(regbtn, 'click', function() {
        if (Prototype.Browser.IE) {
          window.location = serviceLink({
            user: "guest",
            service: "main",
            action: "?register="+readUserModel.data.username+"&lang="+__currentLanguage
          }) 
        }
        else {
          var w = new ThemedWindow({
            maximizable: false,
            minimizable: false,
            showEffect: Element.show,
            hideEffect: Element.hide,
            width: 500,
            height: 370,
            theme: {user: "core", path: "/alphacube"},
            onClose: function() {
              var mpm = $('mysites-promo-movie')
              if (mpm) mpm.show()          
            }
          }, function(win) {
            var mpm = $('mysites-promo-movie')
            if (mpm) mpm.hide()
            var regu = serviceLink({
              user: "guest",
              service: "main",
              action: "?register=true&lang="+__currentLanguage
            }) 
            win.setURL(regu)
            win.setZIndex(10000) // because of www.mysites.com
            win.showCenter()
          })
        }
      })      
    //var lower = Builder.node('div',{style:"position:absolute;top:20px;right:120px;width:100px;"},[regbtn]);  
    var lower =
    Builder.node('div',{style:"position:absolute;top:20px;right:120px;width:100px;"},[EMPTY()]);  
    return lower;
  },
  lowerView: function() {
    var lower = Builder.node('div',{id:"leftBtn"},[]); 
    return lower;
  },
  mainView: function(innertable, phrasebox) {
    if(logged_in){
        var up = this.userPic();
    }else{
        var up = EMPTY();
    }
    var pic = Builder.node('div',{style:"position:relative;left:322px;top:12px;width:50px;"},[up]);
    pic.style.cursor = "pointer"
    Event.observe(pic, 'click', function() {
      this.changeSite().onclick()
    }.bindAsEventListener(this))
    var maintable = Builder.node('div',{},[pic,innertable]); 
 
    if (!logged_in) {
      var tabs = EMPTY()
    }
    else {
      var messages = Builder.node('span', [TN("My Messages")])
      updateMessages = function() {
        new UserMessages({
          user: this.options.profile.data.username,
          afterLoad: function(um) {
            if (um.canSendMessage()) {
              messages.innerHTML = "My Messages (" + um.messageCount() + ")";
 /*edited by mike*/
try{
$("messcount").innerHTML = "("+um.messageCount()+")";
}catch(e){};
            }
          }
        })        
      }.bind(this)
      updateMessages()
      setInterval(updateMessages,1000*60*5)


      var tabs = Builder.node('div', {
        style: "position:absolute;top:83px;left:"+getLeft($('title-bar-main'))+"px;"
      }, [
        new TabsWidget({name: "t", showFirstTab: false, tabs: [{
          name: "startpage-tab",
          title: Builder.node('span', [
            TN("Home"),
            helpTexts.helperNode("Top Badge - Start Page", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            window.location.href = serviceLink({
              service: "main",
              user: "guest"
            })
          }.bind(this)
        },{
          name: 'services-tab',
          title: Builder.node('span', [
            TN("My Services"),
            helpTexts.helperNode("Top Badge - My Services", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            this.changeSite().onclick()
          }.bind(this)
        },{
          name: "buddies-tab",
          title: Builder.node('span', [
            TN("My Buddies"),
            helpTexts.helperNode("Top Badge - My Buddies",14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            new ThemedWindow({
              width: 300,
              height: 300,
              minimizable:false,
              maximizable:false,
              showEffect:Element.show,
              hideEffect:Element.hide,
              destroyOnClose: true
            }, function(w) {
              w.setContent(new BuddiesWidget({
                user: this.getUserModel().user
              }).htmlNode())
              w.showCenter()
              w.toFront()
            }.bind(this))
          }.bind(this)
        },{
          name: "messages-tab",
          title: Builder.node('span', [
            messages, // this gets updated!
            helpTexts.helperNode("Top Badge - My Messages", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            var contents = Builder.node('div', [
              Builder.node('img', {src: "/images/spinner.gif"})
            ])
            var dm = new DisplayModel({
              service: "messages",
              user: this.getUserModel().user
            })
            dm.addObserver({
              afterStore: updateMessages,
              afterRemoveItem: updateMessages
            })
            dm.observeOnce({update: function() {
              contents.innerHTML = ""
              contents.appendChild(new MessagesWidget({
                model: dm,
                lb: false
              }).htmlNode())
            }})
            new ThemedWindow({
              width: 500,
              height: 300,
              minimizable:false,
              maximizable:false,
              showEffect:Element.show,
              hideEffect:Element.hide,
              destroyOnClose: true
            }, function(w) {
              w.setContent(contents)
              w.showCenter()
              w.toFront()
            }.bind(this))
          }.bind(this)
        },{
          name: 'profile-tab',
          title: Builder.node('span', [
            TN("My Preferences"),
            helpTexts.helperNode("Top Badge - My Profile", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            window.location.href = serviceLink({
              service: "profiles",
              user: this.getUserModel().user
            })
          }.bind(this)
        }]}).htmlNode()
      ])      
      if (Prototype.Browser.IE) {
        tabs.style.top = (parseFloat(tabs.style.top)-3) + "px"
      }
    }

 
    //$('title-bar-main').appendChild(tabs)

    return maintable;
  },
  phraseBoxStyle: function() {
    return {position:"absolute", top: "10px", right: "220px", width: "280px"}
  },
  phraseStyle: function() {
    return {height: "30px"}
  },
    headericons:function(){  
       // var f1 = Builder.node('div',{style:"float:left;margin:3px;margin-top:5px;cursor:pointer;width:16px;height:11px;background:url(http:\/\/www.flaggr.com/i/de.png);"},[]);
 
        var sep = Builder.node('div',{style:"float:left;width:5px;height:23px;background:transparent;border-left:1px solid #9e9e9e;border-right:1px solid #9e9e9e;"},[]);
        var l1 = serviceLink({
            user: "core",
            service: "files@core",
            action:"get_file?path=/home.png"
        })  
       
        var hi1 = Builder.node('div',{style:"float:left;cursor:pointer;width:24px;height:24px;background:url("+l1+");"},[]);
        var messcount = Builder.node('div',{id:"messcount",style:"font-size:12px;font-weight:bolder;color:#2FB6DE;float:left;width:24px;height:24px;"},[]); 
         Event.observe(hi1,'click',function(){ 
            window.location.href = serviceLink({
              service: "main",
              user: "guest"
            }) 
        }.bindAsEventListener(this));

        var l2 = serviceLink({
            user: "core",
            service: "files@core",
            action:"get_file?path=/settings.png"
        })
 
        var hi2 = Builder.node('div',{style:"float:left;cursor:pointer;width:24px;height:24px;background:url("+l2+");"},[]);
        Event.observe(hi2,'click',function(){
            window.location.href = serviceLink({
              service: "profiles",
              user: this.getUserModel().user
            }) 
        }.bindAsEventListener(this));

/*
        var l3 = serviceLink({
            user: "core",
            service: "files@core",
            action:"get_file?path=/buddies.png"
        })
        var hi3 = Builder.node('div',{style:"float:left;cursor:pointer;width:24px;height:24px;background:url("+l3+");"},[]);
        Event.observe(hi3,'click',function(){ 
            new ThemedWindow({
              width: 300,
              height: 300,
              minimizable:false,
              maximizable:false,
              showEffect:Element.show,
              hideEffect:Element.hide,
              destroyOnClose: true
            }, function(w) {
              w.setContent(new BuddiesWidget({
                user: this.getUserModel().user
              }).htmlNode())
              w.showCenter()
              w.toFront()
            }.bind(this))
         }.bindAsEventListener(this));

*/
        var l4 = serviceLink({
            user: "core",
            service: "files@core",
            action:"get_file?path=/messages.png"
        })
        var hi4 = Builder.node('div',{style:"float:left;cursor:pointer;width:24px;height:24px;background:url("+l4+");"},[]);
        Event.observe(hi4,'click',function(){
        var contents = Builder.node('div', [ Builder.node('img', {src: "/images/spinner.gif"})]);
        var dm = new DisplayModel({service: "messages",user: this.getUserModel().user})
    
        dm.addObserver({afterStore: updateMessages, afterRemoveItem: updateMessages})
            dm.observeOnce({update: function() {
              contents.innerHTML = ""
              contents.appendChild(new MessagesWidget({
                model: dm,
                lb: false
              }).htmlNode())
            }})
            new ThemedWindow({
              width: 500,
              height: 300,
              minimizable:false,
              maximizable:false,
              showEffect:Element.show,
              hideEffect:Element.hide,
              destroyOnClose: true
            }, function(w) {
              w.setContent(contents)
              w.showCenter()
              w.toFront()
            }.bind(this))
           
        }.bindAsEventListener(this));

        tbew = new topBarEditorialWidget();

        var icoarr = []
        if(logged_in){
            icoarr =[/*f1,*/hi1,hi2,/*hi3,*/hi4,messcount,sep,tbew.htmlNode()]
        }else{
            icoarr = [tbew.htmlNode()];
        } 
//edited mike
        var sem1 = serviceLink({
            user: "core",
            service: "files@core",
            action:"get_file?path=/white-20.png"
        })

        this.searrchnode = new qSearchWidget().htmlNode() ;
        if (is_developer) {
          icoarr.push(this.searrchnode);
        }
 
        this.divheadericons = Builder.node('div',{id:"topiconsdiv",style:"background:url("+sem1+");position:absolute;padding:1px;float:left;height:24px;width:600px;left:175px;top:59px;"},icoarr);

/**/
        if (Prototype.Browser.IE) {
            this.divheadericons.style.top = (parseFloat(this.divheadericons.style.top)-3) + "px"
        }
        return this.divheadericons;
    }
}

Object.extend(WriteUserTopBadgeWidget.prototype, TopBadgeWidget)




;

// /8::/202::/frontend:js -> <847> topbareditorialwidget.js 

topBarEditorialWidget = Class.create();
topBarEditorialWidget.prototype = {
    defaultOptions: function() {
        return {quotes:[],target:null};
    },
    makeWidgetContent: function() {
        instance = this;
        //var terms = Builder.node('a',{href:"#",style:"color:#000000;"},[
        //  TN("Legal Information")
        //]);
        //terms.onclick = function(){  
        ///    initEditorialWindow("Terms");
        //}
        return Builder.node('div',{
          style:"float:left;margin-left:9px;height:22px;text-align:left;z-index:5;top:90px;" +
                "width:200px;color:#000000;font-weight:bolder;right:5px;font-size:70%;"
        },[table({}, [/*terms, */new LanguageFlagsWidget().htmlNode()])]);
    },
    update:function(){        
        this.redrawCompletely()
    }
}
Object.extend(topBarEditorialWidget.prototype, WidgetCommon);


var ewin;
function initEditorialWindow(o){

    if(ewin != null){
        try{
            ewin.destroy();  

          }catch(e){}
    }

    ewin = new Window({
        destroyOnClose:true,
        width:760,
        height:400,
        //title:'<div onclick="gwin.close();">Close</div>',
        zindex:9999,
        minimizable:false,
        maximizable:false,
        showEffect:Element.show,
        hideEffect:Element.hide,
        className: "tooltip",
        onClose:function(){
             endIdle();
        },
        onMove:function(){
        },

        onShow:function(){
        }
    })

var qm = {
    update:function(){
        var article = editorialModel.findItemByName(o);
        var ii = Builder.node('div',{style:"overflow:auto;width:100%;height:100%;"},[]);
        $(ii).update(article.body);
        ewin.setContent(ii, true, true); 
        ewin.setSize(760, 400);
        ewin.setZIndex(9999);
        ewin.showCenter();
     } 
}
var editorialModel = new DisplayModel({controllerName:"articles@core",user:"core",path:"/"});

editorialModel.addObserver(qm); 
}

;

// /8::/202::/frontend:js -> <840> topbarquoteswidget.js 

//old?_delete *mike
 
 
 topBarQuotesWidget = Class.create();
topBarQuotesWidget.prototype = {
    defaultOptions: function() {
        return {quotes:[],style:"position:absolute;z-index:3333;color:#ffffff;font-weight:bolder;font-size:90%;"};
    },
    setup:function(){
        qModel = new DisplayModel({controllerName:"quotes@core",user:"core",path:"headquotes"});
        qModel.addObserver(this);
        itemModel.addObserver(this);
    },
    makeWidgetContent: function() {
        instance = this;

          var elq = this.options.quotes;
        if(elq.length>0){
            var q = instance.generateQ(elq).random();
        }else{

        var q = NBSP()
        }
        return Builder.node('div',{style:this.options.style},[Builder.node('div',{style:"width:100%;height:100%;"},[q])]);
    },
    generateQ:function(items){
        var quotesnodes = [];
        items.each(function(i){
             var quote = Builder.node('div',{},[TN(i.quote)])
             quotesnodes.push(quote);
        });
        return quotesnodes;
    },
    update:function(){        
        this.rerender();
    }, 
    rerender: function(){
        this.options.quotes = qModel.displayItems();
        var nc = this.makeWidgetContent(this.options.quotes);
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
    }
}
Object.extend(topBarQuotesWidget.prototype, WidgetCommon);

Array.prototype.random = function() {
    return this[Math.floor((Math.random()*this.length))];
}

;

// /8::/202::/frontend:js -> <844> topbarsearchwidget.js 

/**
* @author Michael
*/

topBarSearchWidget = Class.create();
var sdm; 
topBarSearchWidget.prototype = {
  defaultOptions: function() {
    return {};
  },
  makeWidgetContent: function() {
    instance = this;
    var searchtext = Builder.node('input',{
      type:"text",
      id:"searchBoxWidgetInput",
      style:"font-weight:bold;z-index:888;padding:2px;padding-right:20px;width:100%;",
      value:"Search"
    });
    searchtext.onfocus = function(){
      this.value = "";
      if($("searchResBox").style.display != "none"){ 
        new Effect.Fade($("searchResBox")); 
      } 
    }
    searchtext.onblur = function(){
      if(this.value == ""){ 
        this.value = "Search";
      } 
    }
    var results = Builder.node('div',{
      id:"searchResBox",
      style:"overflow:auto;display:none;border:1px solid silver;background:#EDEDED;height:110px;width:174px;"
    },[TN("results")]);
    var icon = Builder.node('img',{
      style:"position:relative;z-index:999;margin-left:-20px;top:3px;",
      width:15,
      height:15,
      src:"/core-services/images/search.gif"
    });

    var theform = Builder.node('form',{action:"#",name:"search"},[searchtext,icon,results]); 
     var wrapdiv = Builder.node('div',{
      style:"position:relative;width:150px;height:66px;top:11px;"
    },[theform]);
    theform.onsubmit = function(){    
      sdm = new DisplayModel({controllerName:"articles",user:"core"});
      sdm.addObserver(instance); 
      return false;
    }
    return wrapdiv;
  },
  update:function(){  
    this.showResults(sdm);
  },
  showResults:function(sdm){
    removeChildNodes($("searchResBox"));
    var arr =  this.processResults(sdm.getModel()); 
    appendChildren($("searchResBox"),arr) 
    new Effect.Appear($("searchResBox")) 
  },
  processResults:function(model){
    var arr = []; 
    model.each(function(m){
      var node = Builder.node('div',{
        style:"padding:5px;cursor:pointer;font-size:12px;"
      },[TN(m.name)]);
      node.onmouseover = function(){
        this.style.fontWeight = "bold";
        this.style.color = "white";
        this.style.background = "#2FB6DE";
      }
      node.onmouseout = function(){
        this.style.fontWeight = ""; 
        this.style.color = "black"; 
        this.style.background = "#EDEDED"; 
      }
      node.onclick = function(){
        $("searchBoxWidgetInput").value = m.name;
        new Effect.Fade($("searchResBox"))  
      } 
      arr.push(node)               
    })
    return arr;          
  } 
}
Object.extend(topBarSearchWidget.prototype, WidgetCommon);


//temp helper
function removeChildNodes(parent){
  while(parent.hasChildNodes()){
    parent.removeChild(parent.childNodes[0])
  }
}

;

// /8::/202::/frontend:js -> <838> topbarserviceswidget.js 

  topBarServicesWidget = Class.create();
topBarServicesWidget.prototype = {
  defaultOptions: function() {
    return {};
  },
  url: function(service) {
    return serviceLink({
      user: (logged_in ? write_username : "www"), 
      service: service
    })
   },
  serviceLink: function(service,controller, iconName, displayName, extendedText) {
    return Builder.node('a', {
      href: this.url(service)+ controller,
      className: 'action-link'
    }, [
      Builder.node('img', {
         src: iconPath(16, "service_" + iconName),
        alt: '',
        title: '',
        border: 0,
        align: "absmiddle"
      }),
      Builder.node('span',{style:"font-weight:bolder;color:white;"},[TN(" " + displayName)]),Builder.node('span',{style:"font-size:12px;color:white;"},[TN(extendedText)]), BR()
    ])
  },
  makeWidgetContent: function() {
    return Builder.node('div', {style:"height:auto;overflow:hidden;",id: 'myservices' }, [
      this.serviceLink('articles','', 'myarticles', 'My Articles',' - your text-articles'),
      this.serviceLink('buddies','', 'mybuddies', 'My Buddies',' - your MySites buddylist'),
      this.serviceLink('services','/blog@mike', 'myarticles', 'My Blog',' - your personal blog'),
      this.serviceLink('services','/calendar@mike', 'myarticles', 'My Calendar',' - your personal calendar'),
      this.serviceLink('favorites','', 'myfavorites', 'My Favorites',' - your favorite sites'),
      this.serviceLink('files','', 'myfiles', 'My Files',' - your uploaded files'),
      this.serviceLink('mobiles','', 'mymobiles', 'My Mobiles',' - your mobile interface'),
      this.serviceLink('modules','', 'mymodules', 'My Modules',' - your flashbased modules'),
      this.serviceLink('movies','', 'mymovies', 'My Movies',' - your videos'),
      this.serviceLink('pages','', 'mypages', 'My Pages',' - your personal homepage'),
      this.serviceLink('pictures','', 'mypictures', 'My Pictures',' - your pictures'),
      this.serviceLink('sites','', 'mysites', 'My Sites',' - main site'),
      this.serviceLink('tunes','', 'mytunes', 'My Tunes',' - your music')

     ])
  }

}
Object.extend(topBarServicesWidget.prototype, WidgetCommon);


;

// /8::/202::/frontend:js -> <218763> translations-core.js 


;

// /8::/202::/frontend:js -> <11519> usermessages.js 

UserMessages = Class.create();
UserMessages.prototype = {
  initialize: function(options) {
    //this.options = Object.extend({
    //  user: itemModel.user(),
    //  afterLoad: function(um) {}
    //}, options || {})
    //this._loaded = false
    //this.messagesModel = new DisplayModel({
    //  service: "messages",
    //  path: "/",
    //  user: this.options.user
    //})
    //this.messagesModel.observeOnce({update: function() {
    //  this._checkForInbox()
    //}.bind(this)})
    //if (writeUserModel.data.username != "guest") {
    //  this.sentModel = new DisplayModel({
    //    service: "messages",
    //    path: "/",
    //    user: writeUserModel.data.username
    //  })
    //  this.sentModel.observeOnce({update: function() {
    //    if (!this.sentModel.findItemByName("sent")) {
    //      var f = this.sentModel.addFolder()
    //      f.name = "sent"
    //      this.sentModel.storeItem(f, {afterStore: function() {
    //        this._goToSent()
    //      }.bind(this)})
    //    }
    //    else {
    //      this._goToSent()
    //    }
    //  }.bind(this)})
    //}
  },
  _goToSent: function() {
    //this.sentModel.observeOnce({afterPathChanged: function() {
    //  this._sentPresent = true
    //}.bind(this)})
    //this.sentModel.changeToFolder("/sent")
  },
  _checkForInbox: function() {
    //if (this.messagesModel.findItemByName("inbox")) {
    //  this._loadData()
    //}
    //else {
    //  if (!this.messagesModel.canWrite()) {
    //    this._loadData()
    //  }
    //  else {
    //    var f = this.messagesModel.addFolder()
    //    f.name = "inbox"
    //    f.permission = "everyonesticky"
    //    this.messagesModel.storeItem(f, {afterStore: function() {
    //      this._loadData()
    //    }.bind(this)})
    //  }
    //}
  },
  _loadData: function() {
    //this._canSendMessage = !!this.messagesModel.findItemByName("inbox")
    //if (this.canSendMessage()) {
    //  this.messagesModel.observeOnce({afterPathChanged: function() {
    //    this._countNewMessages()          
    //  }.bind(this)})
    //  this.messagesModel.changeToFolder("/inbox")
    //}
    //else {
    //  this.options.afterLoad(this)
    //}
  },
  _countNewMessages: function() {
    //var lw = this.messagesModel.findItemByName("last_viewed")
    //if (lw) {
    //  this._messageCount = 0
    //  this.messagesModel.getModel().each(function(m) {
    //    if (m.name == "last_viewed") return;
    //    if (m.added_at >= lw.modified_at) {
    //      this._messageCount += 1
    //    }
    //  }.bind(this))
    //}
    //else {
    //  this._messageCount = this.messagesModel.getModel().length          
    //}
    //this._loaded = true
    //this.options.afterLoad(this)    
  },
  canSendMessage: function() {
    //return this._canSendMessage && logged_in
    return false
  },
  sendMessage: function(text, o) {
    //var options = Object.extend({
    //  afterSend: function() {},
    //  report:    false,
    //  noCopyForSender: false
    //}, o || {})
    //// TODO: More than just text
    //if (this.canSendMessage()) {
    //  var m = {
    //    name: writeUserModel.data.username,
    //    message: text,
    //    report: options.report
    //  }
    //  if (options.noCopyForSender) {
    //    this.messagesModel.storeItem(this.messagesModel.addItem(m), {
    //      afterStore: options.afterSend
    //    })
    //  }
    //  else {
    //    this.messagesModel.createItem(m)
    //    var i = setInterval(function() {
    //      if (!this._sentPresent) return;
    //      clearInterval(i)
    //      var m = {
    //        name: this.options.user, // here we use the user we sent the message to.
    //        message: text,
    //        // We can be sure that this field will never be mangled
    //        sent_to: this.options.user,
    //        report:  options.report
    //      }
    //      this.sentModel.storeItem(this.sentModel.addItem(m), {
    //        afterStore: options.afterSend
    //      })
    //      if (options.report && this.options.user != "team") {
    //        var dm = new DisplayModel({
    //          user: "team",
    //          service: "messages",
    //          path: "/inbox"
    //        })
    //        dm.observeOnce({update: function() {
    //          dm.createItem({
    //            name:      this.options.user,
    //            message:   text,
    //            sent_to:   this.options.user,
    //            sent_from: writeUserModel.data.username,
    //            report:    true
    //          })
    //        }.bind(this)})
    //      }
    //    }.bind(this), 100)
    //  }
    //}
  },
  messageCount: function() {
    //return this._messageCount
    return 0;
  },
  loaded: function() {
    //return this._loaded
    return true;
  },
  replyDiv: function(afterSend) {
    //var form = Builder.node('form', [
    //  translateText({path: ".um", id: "reply-text"}),
    //  TN(": "),
    //  BR(),
    //  Builder.node('textarea', {
    //    name: "message",
    //    style: "width:390px;height:200px;"
    //  }),
    //  BR(),
    //  translateButton({path: ".um", id: "reply-button"})
    //])
    //Event.observe(form, 'submit', function(event) {
    //  Event.stop(event)
    //  var form = Event.element(event)
    //  if (form.tagName != "FORM") {
    //    form = Element.up(form, 'form')
    //  }
    //  var text = form.message.value
    //  if (text != "") {
    //    this.sendMessage(text, {afterSend: afterSend || function() {}})
    //  }
    //}.bindAsEventListener(this))    
    //return form
    return EMPTY()
  },
  replyWindow: function(title) {
    //new ThemedWindow({
    //  title:       title || "Send message",
    //  minimizable: false,
    //  maximizable: false,
    //  width: 400,
    //  height: 300
    //}, function(win) {
    //  win.setContent(this.replyDiv(function() {win.close()}))
    //  win.showCenter()
    //}.bind(this))
  }
}

function openMessageWindow(event) {
  //new ThemedWindow({
  //  title: Builder.node('span', [
  //    translateText({path: ".um", id: "write-title"})
  //  ]).innerHTML,
  //  minimizable: false,
  //  maximizable: false,
  //  width: 300,
  //  height: 200,
  //  theme: {user: "core", path: "/alphacube"},
  //  showEffect: Element.show,
  //  hideEffect: Element.hide
  //}, function(win) {
  //  var content = Builder.node('div', {
  //    style: "width:100%;"
  //  },[
  //    Builder.node('form', {style: "width:100%;"},[
  //      translateText({path: ".um", id: "to"}), TN(":"), BR(),
  //      Builder.node('input', {type: "text", name: "username"}), BR(),
  //      translateText({path: ".um", id: "message"}), TN(":"), BR(),
  //      Builder.node('textarea', {name: "message", rows: "4", style: "width:97%;"}),
  //      translateButton({path: ".um", id: "reply-button"})
  //    ])
  //  ])
  //  var form = $(content).down('form')
  //  Event.observe(form, 'submit', function(event) {
  //    Event.stop(event)
  //    new UserMessages({
  //      user: form.username.value,
  //      afterLoad: function(um) {
  //        // TODO: Handle case when message can't be delivered
  //        um.sendMessage(form.message.value, {afterSend: function() {
  //          win.close()
  //          // TODO: Reload the conversations
  //        }})
  //      }
  //    })
  //  }.bindAsEventListener(this))
  //  win.setContent(content)
  //  win.setLocation(event.clientY,event.clientX)
  //  win.show()
  //  win.toFront()
  //}.bind(this))
}
;

// /8::/202::/frontend:js -> <177277> wordcloudwidget.js 

WordCloudWidget = Class.create();
WordCloudWidget.prototype = {
    defaultOptions: function() {
        return {
    
        }
    },
    makeTip:function(){
        this.tip = Builder.node('div',{style:"font-weight:bolder;position:absolute;z-index:999;top:0px;left:0px;width:200px;height:auto;text-align:left;padding:5px;background:white;border:1px solid silver;font-size:110%;"},[TN("TIP")]);
        $(this.tip).hide();
        $(document.body).appendChild(this.tip); 
    },
    showTip:function(n){  
        this.tip.show(); 
        this.tip.innerHTML = '';
        this.tip.appendChild(n);
    },
    hideTip:function(){
        this.tip.hide(); 
    },
    moveTip:function(e){
        mouseX = Event.pointerX(e);
        mouseY = Event.pointerY(e);
        this.tip.setStyle({left:mouseX+8+"px",top:mouseY+10+"px"});
    }, 
    getNodes:function(){ 
     
      var buzz = [
        {size:"111",icon:"",descriptionnode:translateText({path: ".cloud", id: "save_desc"}),textnode:translateText({path: ".cloud", id: "save_txt"})},
        {size:"129",icon:"",descriptionnode:translateText({path: ".cloud", id: "play_desc"}),textnode:translateText({path: ".cloud", id: "play_txt"})},
        {size:"81",icon:"",descriptionnode:translateText({path: ".cloud", id: "combine_desc"}),textnode:translateText({path: ".cloud", id: "combine_txt"})},
        {size:"73",icon:"",descriptionnode:translateText({path: ".cloud", id: "share_desc"}),textnode:translateText({path: ".cloud", id: "share_txt"})},
        {size:"121",icon:"",descriptionnode:translateText({path: ".cloud", id: "social_desc"}),textnode:translateText({path: ".cloud", id: "social_txt"})},
        {size:"83",icon:"",descriptionnode:translateText({path: ".cloud", id: "blog_desc"}),textnode:translateText({path: ".cloud", id: "blog_txt"})},
        {size:"116",icon:"",descriptionnode:translateText({path: ".cloud", id: "mobile_desc"}),textnode:translateText({path: ".cloud", id: "mobile_txt"})},
        {size:"107",icon:"",descriptionnode:translateText({path: ".cloud", id: "community_desc"}),textnode:translateText({path: ".cloud", id: "community_txt"})},
        {size:"124",icon:"",descriptionnode:translateText({path: ".cloud", id: "privacy_desc"}),textnode:translateText({path: ".cloud", id: "privacy_txt"})}

    ];

    var nodes = []; 
    $(buzz).each(function(wrd){
        var fs = wrd.size;/*50+Math.floor(Math.random()*100);
*/
        var buzzwrd = Builder.node('div',{style:"cursor:pointer;float:left;font-size:"+fs+"%;font-weight:bolder;color:white;padding:5px;"},[wrd.textnode]);
 
        Event.observe($(buzzwrd),'mouseover',function(e){ 
            var tipinner = Builder.node('div',{style:"font-size:12px;"},[wrd.descriptionnode]);
            var strr = tipinner.firstChild.innerHTML;
            strr = strr.replace(/&lt;br\/&gt;/g,"<BR>");
  
            tipinner.innerHTML = strr;
            this.showTip(tipinner);
            this.moveTip(e);
        }.bind(this));
        Event.observe($(buzzwrd),'click',function(e){ 
           //alert(wrd.descriptionnode.innerHTML);
        }.bind(this)); 
        Event.observe($(buzzwrd),'mouseout',function(e){ 
            this.hideTip();
        }.bind(this));
        Event.observe($(buzzwrd),'mousemove',function(e){ 
            this.moveTip(e);
        }.bind(this)); 
        nodes.push(buzzwrd);
    }.bind(this));
      return nodes;
    }, 
    makeWidgetContent: function() {
        this.makeTip();
        var nodes = this.getNodes();
        return Builder.node('div',{style:"overflow:hidden;width:100%;"},nodes);
    }
}
Object.extend(WordCloudWidget.prototype, WidgetCommon); 
;

// /8::/202::/frontend:js -> <9180> writeuserbadgewidget.js 

WriteUserBadgeWidget = Class.create()
WriteUserBadgeWidget.prototype = {
  defaultOptions: function(){
    return {
      profile: writeUserModel,
      type:    "top",
      style:   "float:right;"
    };
  },
  loginErrorView: function() {
    return TN(itemModel.paramsLoginError())
  },
  loginForm: function() {
    var unameboxx = Builder.node('input', {
      type: "text",
      className:"inputBox",
      name: "username",
      size: "15",
      value: "Username",
      style:"width:60px;",
      id: this.options.type + "_username"
    });
    Event.observe(unameboxx,'focus',function(e) {
      if ($(unameboxx).value == "Username") {
        $(unameboxx).value = "";
      }
    });
    Event.observe(unameboxx,'blur',function(e) {
      if ($(unameboxx).value == "") {
        $(unameboxx).value = "Username";
      }
    });
    var upassboxx =  Builder.node('input', {
      type: "password",
      name: "password",
      className:"inputBox",
      size: "15",
      value: "PASSWORD",
      style:"width:60px;",
      id: this.options.type + "_password"
    });
    Event.observe(upassboxx ,'focus',function(e) {
      if ($(upassboxx).value == "PASSWORD") {
        $(upassboxx).value = "";
      }
    });
    Event.observe(upassboxx ,'blur',function(e) {
      if ($(upassboxx).value == "") {
        $(upassboxx).value = "PASSWORD";
      }
    });
    var logintable = table({width:"100%",height:30,style:"padding:2px;"},[ 
      {columnOptions:{},columnData:[unameboxx]},
      {columnOptions:{},columnData:[upassboxx]},
      {columnOptions:{},columnData:[
        translateButton({
          id: "login",
          node: Builder.node('input', {
            type: "submit",
            style:"color:black;margin:3px;",
            value: "login",
            className:"button",
            id: this.options.type + "_login"
          })
        })
      ]}
    ])
    var theform = Builder.node('form',{
      method: "post", 
      style:"margin:0 0;",
      action: serviceLink({
        user: "www",
        service: "sites",
        controllerName: "account",
        action: "login"
      })
    },[
      table({width:"100%"},[logintable]),
      Builder.node('input', {
        type:  "hidden",
        name:  "desired_url",
        value: window.location
      }), 
      Builder.node('input', {
        type:  "hidden",
        name:  "desired_service",
        value: itemModel.serviceName()
      }) 
    ])
    return theform;    
  },
  changeSite: function() {
    if (!this._cs) {
      this._cs = new changeSiteWidget({
        profile: this.options.profile,
        text:this.getUserModel().user,
        style:"font-weight:bolder;font-size:120%;color:black;margin-right:5px;"
      })
    }
    return this._cs;
  },
  loginViewUpper: function() {
    var upper = table({
      height:30,
      style:"background:transparent " +
             "url(/core-services/themes/mynewtheme/my_dlbg.png) repeat-x;"
    },[
      this.loginForm(),
      {columnOptions:{width:"65%",height:30},columnData:[EMPTY()]}
    ]);
    return upper;
  },
  upperView: function() {
    var upper = table({
      height:30,
      style:"font-size:110%;cursor:pointer;"
    },[
      this.makeUserStatus(),
      this.changeSite().htmlNode(),
      {
        columnOptions:{width:"65%",height:30, align:"right"},
        columnData:[new LogoutWidget().htmlNode()]
      }
    ]);
    return upper;
  },
  loginViewLower: function() {
    var regbtn = Builder.node('input',{
      id: "register",
      type: "button",
      value: "Register",
      style:"margin:3px;color:black;",
      className:"button"
    });
    Event.observe(regbtn, 'click', function() {
      var w = new ThemedWindow({
        maximizable: false,
        minimizable: false,
        showEffect: Element.show,
        hideEffect: Element.hide,
        width: 370,
        height: 370,
        theme: {user: "core", path: "/alphacube"},
        onClose: function() {
          var mpm = $('mysites-promo-movie')
          if (mpm) mpm.show()          
        }
      }, function(win) {
        var mpm = $('mysites-promo-movie')
        if (mpm) mpm.hide()
        win.setURL("http://www.mysites.com/?register=true")
        win.setZIndex(10000) // because of www.mysites.com
        win.showCenter()
      })
    })
    if (Prototype.Browser.IE && window.location.href != "http://www.mysites.com") {
      regbtn = EMPTY()
    }
    var lower = table([
      {columnOptions:{width:"90%",height:30},columnData:[NBSP()]},
      {columnOptions:{width:"10%",height:30},columnData:[regbtn]}
    ]);
    return lower;
  },
  lowerView: function() {
    var lower = table([
      {columnOptions:{width:"90%",height:30},columnData:[NBSP()]},
      {columnOptions:{width:"10%",height:30,id:"leftBtn"},columnData:[NBSP()]}
    ]);
    return lower;
  },
  mainView: function(innertable, phrasebox) {
    var pic = this.userPic()
    pic.style.cursor = "pointer"
    Event.observe(pic, 'click', function() {
      this.changeSite().onclick()
    }.bindAsEventListener(this))
    var maintable = table(
      {cellspacing:0,border:0,cellpadding:0,vAlign:"top",border:0},
      [{
        columnOptions:{id:"upictd",width:95,height:63,vAlign:"top"},
        columnData:[pic]
      },{
        columnOptions:{width:"100%",height:63,vAlign:"top"},
        columnData:[innertable]
      }]
    );
    if (!logged_in) {
      var tabs = EMPTY()
    }
    else {
      var messages = Builder.node('span', [TN("My Messages")])
      var updateMessages = function() {
        new UserMessages({
          user: this.options.profile.data.username,
          afterLoad: function(um) {
            if (um.canSendMessage()) {
              messages.innerHTML = "My Messages (" + um.messageCount() + ")"          
            }
          }
        })        
      }.bind(this)
      updateMessages()
      setInterval(updateMessages,1000*60*5)
      var tabs = Builder.node('div', {
        style: "position:absolute;top:83px;left:"+getLeft($('title-bar-main'))+"px;"
      }, [
        new TabsWidget({name: "t", showFirstTab: false, tabs: [{
          name: "startpage-tab",
          title: Builder.node('span', [
            TN("Home"),
            helpTexts.helperNode("Top Badge - Start Page", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            window.location.href = serviceLink({
              service: "main",
              user: "guest"
            })
          }.bind(this)
        },{
          name: 'services-tab',
          title: Builder.node('span', [
            TN("My Services"),
            helpTexts.helperNode("Top Badge - My Services", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            this.changeSite().onclick()
          }.bind(this)
        },{
          name: "buddies-tab",
          title: Builder.node('span', [
            TN("My Buddies"),
            helpTexts.helperNode("Top Badge - My Buddies",14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            new ThemedWindow({
              width: 300,
              height: 300,
              minimizable:false,
              maximizable:false,
              showEffect:Element.show,
              hideEffect:Element.hide,
              destroyOnClose: true
            }, function(w) {
              w.setContent(new BuddiesWidget({
                user: this.getUserModel().user
              }).htmlNode())
              w.showCenter()
              w.toFront()
            }.bind(this))
          }.bind(this)
        },{
          name: "messages-tab",
          title: Builder.node('span', [
            messages, // this gets updated!
            helpTexts.helperNode("Top Badge - My Messages", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            var contents = Builder.node('div', [
              Builder.node('img', {src: "/images/spinner.gif"})
            ])
            var dm = new DisplayModel({
              service: "messages",
              user: this.getUserModel().user
            })
            dm.addObserver({
              afterStore: updateMessages,
              afterRemoveItem: updateMessages
            })
            dm.observeOnce({update: function() {
              contents.innerHTML = ""
              contents.appendChild(new MessagesWidget({
                model: dm,
                lb: false
              }).htmlNode())
            }})
            new ThemedWindow({
              width: 500,
              height: 300,
              minimizable:false,
              maximizable:false,
              showEffect:Element.show,
              hideEffect:Element.hide,
              destroyOnClose: true
            }, function(w) {
              w.setContent(contents)
              w.showCenter()
              w.toFront()
            }.bind(this))
          }.bind(this)
        },{
          name: 'profile-tab',
          title: Builder.node('span', [
            TN("My Preferences"),
            helpTexts.helperNode("Top Badge - My Profile", 14)
          ]),
          widget: new EasyWidget({render: function() { return EMPTY()}}),
          afterTabShow: function() {
            window.location.href = serviceLink({
              service: "profiles",
              user: this.getUserModel().user
            })
          }.bind(this)
        }]}).htmlNode()
      ])      
      if (Prototype.Browser.IE) {
        tabs.style.top = (parseFloat(tabs.style.top)-3) + "px"
      }
    }
    $('title-bar-main').appendChild(tabs)
    return Builder.node('div', {style: "position:relative;"}, [maintable/*,tabs*/])
  },
  phraseBoxStyle: function() {
    return {top: "-2px", left: "5px", width: "95%"}
  },
  phraseStyle: function() {
    return {height: "30px"}
  }
}

Object.extend(WriteUserBadgeWidget.prototype, BadgeWidget)


;

