;

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

// /8::/202::/core:js -> <461056> albumselectoverlaywidget.js 

var album = "";
AlbumSelectOverlayWidget = Class.create();
AlbumSelectOverlayWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      content:null
    },arguments[0]);
  },
  setup:function(){    
    this.theitems = [];
    if(sdloader.loader != null){
      this.loadedItems(sdloader);
    }
    sdloader.observeOnce(this);
  }, 
  loadedItems:function(d){
    window.setTimeout(function(){
      this.options.model = d.loader;
      this.theitems = this.options.model.items();
      this.sortByName()
    }.bind(this),200);
  },
  sortit:function(sf){
    if(sf != null){
      this.theitems.sort(sf)
    }else{
      this.theitems.sort()
    }
    this.redrawCompletely();
  },
  sortByName:function(){
    var sf2 = function(a,b){
      var x = a.name.toLowerCase();
      var y = b.name.toLowerCase(); 
      return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    }
    this.sortit(sf2);
  },
  makeButton:function(t,w){
    var btnstyle= "cursor:pointer;width:"+w+"px;height:26px;";
    btnstyle += "background:url("+this.imageurl(t)+");"
    var btn = Builder.node('div',{style:btnstyle},[]);
    Event.observe($(btn),'mouseover',function(e){
      $(btn).setStyle({backgroundPosition:"0px 26px"});
    }.bind(this));
    Event.observe($(btn),'mouseout',function(e){
      $(btn).setStyle({backgroundPosition:"0px 0px"});
    }.bind(this));
    return btn;
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  makeModalBG:function(){
    var modalstyle = "width:100%;position:absolute;background:#000;"
    modalstyle += "z-index:8888;top:0px;left:0px;";
    this.bg = Builder.node('div',{style:modalstyle},[]);
    Event.observe($(this.bg),'click',function(){
      this.area.hide();
    }.bind(this));
    this.bg.hide();
    $(document.body).appendChild(this.bg);
    this.setBGStyle();
  },
  makeModal:function(){
    var mstyle = "z-index:9999;position:absolute;width:295px;height:151px;";
    mstyle += "background:url("+this.imageurl("album-overlay.png")+");";
    var bstyle = "width:150px;position:absolute;bottom:25px;right:15px;";
    var cancel = this.makeButton("album-cancel.png",66);
    Event.observe($(cancel),'click',function(e){
      this.hideModal();
    }.bind(this));

    var ok = this.makeButton("album-ok.png",62);
    Event.observe($(ok),'click',function(e){
      this.hideModal()
      uplw.finallyUpload(album);
    }.bind(this));

    this.buttons = Builder.node('div',{style:bstyle},[
      Builder.node('div',{style:"width:70px;float:left;"},[
        ok
      ]),
      Builder.node('div',{style:"width:70px;float:left;"},[
        cancel
      ]),
      Builder.node('div',{style:"clear:both;"},[])
    ]);
    this.modal = Builder.node('div',{style:mstyle},[
      this.buttons      
    ]);
    this.modal.hide();
    $(document.body).appendChild(this.modal);
    this.setModalStyle();
  },
  setModalStyle: function() {
    var pagesize = this.getPageSize();
    var d = $(this.modal).getDimensions();
    $(this.modal).setStyle({left: ((pagesize[0] - d.width) / 2) + 'px', top: (((pagesize[1]+$(document.viewport).getScrollOffsets().top*2) - d.height) / 2) + 'px' });
  },
  getPageSize: function()  {
    var de = document.documentElement;
    var w = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var h = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    return [w, h];
  },
  setBGStyle:function(){
    if (window.innerHeight && window.scrollMaxY) {
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
      // all but Explorer Mac
      yScroll = document.body.scrollHeight;
    } else {
      yScroll = document.body.offsetHeight;
    }
    $(this.bg).setStyle({height:yScroll+"px"})
    $(this.bg).setOpacity(0.9);
  },
  showModal:function(){
    this.makeHead();
    this.makeDropdown();
    this.setBGStyle();
    this.setModalStyle();
    this.modal.show();
    this.bg.show();
  },
  hideModal:function(){
    this.modal.hide();
    this.bg.hide();
  },
  makeDropdown:function(){
    var dstyle = "position:absolute;right:30px;top:60px;";
    dstyle += "width:132px;height:26px;overflow:hidden;";
    var astyle = "position:absolute;right:25px;top:83px;";
    astyle += "width:185px;height:126px;overflow:hidden;";
    astyle += "background:url("+this.imageurl("album-drop-bg.png")+");";
    if(this.dropdown){
      this.dropdown.remove();
    }
    var innerstyle = "width:173px;height:114px;margin:6px;overflow:auto;";
    this.inner = Builder.node('div',{style:innerstyle},[]);
    this.area = Builder.node('div',{style:astyle},[this.inner]);
    this.area.hide();

    this.setFolders(this.theitems);

    $(this.drop).setStyle({paddingLeft:"5px",paddingTop:"2px",fontWeight:"bolder"});
    this.drop.innerHTML = "Current Folder"
    this.dropdown = Builder.node('div',{style:dstyle},[this.drop]);
    $(this.modal).appendChild(this.dropdown);
    $(this.modal).appendChild(this.area);
  },
  setFolders:function(folders){
    this.inner.innerHTML = "";
    $(folders).each(function(itm){
      if(itm.type == "folder"){
        this.inner.appendChild(this.makeSingleFolder(itm));
      }
    }.bind(this));
    this.drop = this.makeButton("album-drop.png",132);
    Event.observe($(this.drop),'click',function(){
      this.area.toggle();
    }.bind(this));
  },
  makeSingleFolder:function(btn){
    var fstyle = "line-height:30px;width:100%;height:30px;cursor:pointer;color:#990000;";
    var icostyle = "margin-left:3px;margin-right:3px;margin-top:5px;width:19px;height:16px;float:left;";
    icostyle += "background:url("+this.imageurl("icons-type.png")+") -40px 0px;";

    var ico = Builder.node('div',{style:icostyle},[]);
    var txt = Builder.node('div',{style:"width:80%;height:20px;float:left;"},[TN(btn.name)]);
    var c = Builder.node('div',{style:"clear:both;"},[]);
    var folder = Builder.node('div',{style:fstyle},[
      ico,txt,c
    ]);
    Event.observe($(folder),'click',function(e){
      this.area.toggle();
      album = btn.pretty_name;
      this.drop.innerHTML = btn.name
    }.bind(this));
    Event.observe($(folder),'mouseover',function(e){
      $(folder).setStyle({background:"#333333",color:"white"});
    }.bind(this));
    Event.observe($(folder),'mouseout',function(e){
      $(folder).setStyle({background:"white",color:"#990000"});      
    }.bind(this));

    return folder
  },
  makeHead:function(){
    if(this.head){
      $(this.head).remove();
    }
    var headstyle = "width:180px;height:30px;position:absolute;top:25px;z-index:9999;";
    headstyle += "left:30px;";
    var txt = Builder.node('span',{style:"font-weight:bolder;"},[
      Builder.node('span',[TN("Add ")]),
      Builder.node('span',{style:"color:#009966;"},[TN(fc)]),
      Builder.node('span',[TN(" files")])
    ]);
    this.head = Builder.node('div',{style:headstyle},[txt])
    $(this.modal).appendChild(this.head);
  },
  makeWidgetContent: function(){  
    this.makeModalBG();
    this.makeModal();
    Event.observe($(window),'resize',function(e){
      this.setBGStyle();
      this.setModalStyle();
    }.bind(this));

    return EMPTY()
  },
  rerender: function() {
    var nc = this.makeWidgetContent();
    this.replaceChild(this.content, this.widgetContent, nc);
    this.widgetContent = nc;
  }

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

// /8::/202::/core:js -> <444702> blackbuttonwidget-2.js 

BlackButtonWidget = Class.create();
BlackButtonWidget.prototype = {
  defaultOptions: function(){
    return {
      caption:TN("BUTTON"),
      onClickAction:function(e){},
      width:100
    }
  },
  setup:function(){
    var obs = {clicked:function(d,e){
      this.sel = false;
      this.out(e);
    }.bind(this)};
    this.addObserver(obs);
  },
  over:function(e){
    if(!this.sel){
      $(this.leftcorner).setStyle({background:"url("+this.imageurl("btn-o-left.png")+")"});
      $(this.rightcorner).setStyle({background:"url("+this.imageurl("btn-o-right.png")+")"});
      $(this.btnfill).setStyle({color:"white",background:"url("+this.imageurl("btn-o-fill.png")+")"});
    }
  },
  out:function(e){
    if(!this.sel){
      $(this.leftcorner).setStyle({background:"url("+this.imageurl("btn-n-left.png")+")"});
      $(this.rightcorner).setStyle({background:"url("+this.imageurl("btn-n-right.png")+")"});
      $(this.btnfill).setStyle({color:"white",background:"url("+this.imageurl("btn-n-fill.png")+")"});
     }
  },
  selected:function(e){
    this.sel = true;
    $(this.leftcorner).setStyle({background:"url("+this.imageurl("btn-s-left.png")+")"});
    $(this.rightcorner).setStyle({background:"url("+this.imageurl("btn-s-right.png")+")"});
    $(this.btnfill).setStyle({color:"black",background:"url("+this.imageurl("btn-s-fill.png")+")"});
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  makeWidgetContent: function(){
    var width = this.options.width;

    var bstyle = "width:"+width+"px;position:relative;top:0px;cursor:pointer;";
    var txtstyle = "line-height:33px;text-align:center;color:white;text-decoration:none;font-size:12px;";

    var sstyle = "width:3px;height:33px;float:left;";

    var leftimg = this.imageurl("btn-n-left.png");
    var rightimg = this.imageurl("btn-n-right.png");
    var fillimg = this.imageurl("btn-n-fill.png");

    var fillstyle = "height:33px;float:left;width:"+(width-6)+"px;background:url("+fillimg+"); repeat-x;"

    this.leftcorner = Builder.node('div',{style:sstyle+"background:url("+leftimg+");"});
    this.rightcorner = Builder.node('div',{style:sstyle+"background:url("+rightimg+");"});
    this.btnfill = Builder.node('div',{style:txtstyle+fillstyle},[
      this.options.caption
    ]);

    var btninner = Builder.node('div',{style:bstyle},[
      this.leftcorner,
      this.btnfill,
      this.rightcorner,
      Builder.node('div',{style:"clear:both;"})
    ]);

    Event.observe($(btninner),'mouseover',function(e){
      this.over(e);
    }.bind(this));
    Event.observe($(btninner),'mouseout',function(e){
      this.out(e);
    }.bind(this));
    Event.observe($(btninner),'mousedown',function(e){
      this.out(e)
    }.bind(this));
    Event.observe($(btninner),'mouseup',function(e){
      this.over(e);
    }.bind(this));
    Event.observe($(btninner),'click',function(e){
      this.notifyObservers("clicked",e);
      this.options.onClickAction();
window.setTimeout(function(){
      this.selected("");
}.bind(this),100)
    }.bind(this));

    var bg = "background:transparent;"
    var btnwrapper = Builder.node('div',{style:bstyle+bg+"clear:both;"},[btninner]);
    return btnwrapper;
  }
}  
Object.extend(BlackButtonWidget.prototype, WidgetCommon);
Object.extend(BlackButtonWidget.prototype, Observable);

;

// /8::/202::/core:js -> <455965> blankpagewidget.js 

BlankPageWidget = Class.create();
BlankPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      content:null
    },arguments[0]);
  },
  setup:function(){
    
  }, 
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  makeWidgetContent: function(){  
    var left = [

    ];   

    var right = [
      Builder.node('div',{style:"height:450px;"},[TN(this.options.content.page)])
    ];   
 
    layoutwidget = new LayoutWidget({left:left,right:right});

    return layoutwidget.htmlNode();
  }
}  
Object.extend(BlankPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <452685> carouselwidget.js 

CarouselWidget = Class.create();
CarouselWidget.prototype = {
	defaultOptions: function() {
		return {
			_widgetid:"CarouselWidget",
			auto:false,
			id:"0",
			slidewidth:300,
			slideheight:350,
			slides:[
				{text:"",node:TN("Slide1")},
				{text:"",node:TN("Slide2")},
				{text:"",node:TN("Slide3")}
			],
			slidecount:0
		}
	},
	setup:function(){
		this.options.slidecount = this.options.slides.length;		
	},
	makeOneSlide:function(con,c){
		var innernode = Builder.node('div',{className:"slide_content",style:"padding:5px;margin:0 auto;width:"+(this.options.slidewidth-40)+"px;"},[con.node]);
		var slide = Builder.node('div',{className:"slide"+this.options.id,id:"slide-"+c+this.options.id,style:"font-size:120%;float: left;width:"+this.options.slidewidth+"px;height:"+this.options.slideheight+"px;"},[innernode]);
		return slide;
	},
	makeWidgetContent:function(){
		
		var s = Builder.node('div',{id:"scroller"+this.options.id,style:"text-align:left;width:"+this.options.slidewidth+"px;height:"+this.options.slideheight+"px;overflow: hidden;float:left;"},[]);
		this.cont = Builder.node('div',{id:"content"+this.options.id,style:"width:"+(this.options.slidecount * this.options.slidewidth)+"px"},[]);
		$(s).appendChild(this.cont);
	
		$(this.options.slides).each(function(slide,c){
			this.slidenode = this.makeOneSlide(slide,c);
			$(this.cont).appendChild(this.slidenode);
		}.bind(this));
		//this.borderw.render($$("div.slide_content"));
		var icon1 = EMPTY();
		//$(icon1).setStyle({position:"relative",top:(( this.options.slideheight / 2 )-29)+"px"});
		this.controlnext =  Builder.node('div',{style:"border-left:0px solid #3B3C3F;position:relative;float:left;height:"+this.options.slideheight+"px"},[Builder.node('a',{href:"javascript:void(0);",rel:"next",className:"carousel-control"+this.options.id,style:""},[icon1])]);
		$(this.controlnext).setOpacity(0.5);
		Event.observe($(this.controlnext),'mouseover',function(e){
			$(this.controlnext).setOpacity(0.9);
		}.bind(this));
		Event.observe($(this.controlnext),'mouseout',function(e){
			$(this.controlnext).setOpacity(0.5);
		}.bind(this));
		var icon2 = EMPTY();
		//$(icon2).setStyle({position:"relative",top:(( this.options.slideheight / 2 )-29)+"px"});
		this.controlprev = Builder.node('div',{style:"border-right:0px solid #3B3C3F;position:relative;float:left;height:"+this.options.slideheight+"px"},[Builder.node('a',{href:"javascript:void(0);",rel:"prev",className:"carousel-control"+this.options.id,style:""},[icon2])]);
		$(this.controlprev).setOpacity(0.5);
		Event.observe($(this.controlprev),'mouseover',function(e){
			$(this.controlprev).setOpacity(0.9);
		}.bind(this));
		Event.observe($(this.controlprev),'mouseout',function(e){
			$(this.controlprev).setOpacity(0.5);
		}.bind(this));
	
		$(document.body).appendChild(Builder.node('div',{id:"carousel"+this.options.id,style:"position:relative;overflow:hidden;text-align:center;margin:0 auto;width:"+(60+this.options.slidewidth)+"px;height:"+(this.options.slideheight+20)+"px;"},[this.controlprev,s,this.controlnext,Builder.node('div',{className:"clearer"})]));
	
		window.setTimeout(function(e){
			this.carousel = this.initCarousel($('scroller'+this.options.id), $$('.slide'+this.options.id), $$('a.carousel-jumper'+this.options.id, 'a.carousel-control'+this.options.id), {auto:this.options.auto,duration:1.5,beforeMove:function(){
//$("content"+this.options.id).setOpacity(0.5);
return;}.bind(this),afterMove:function(){
//$("content"+this.options.id).setOpacity(1);
return;}.bind(this)});
		}.bind(this),100);
	
		this.finalnode = $("carousel"+this.options.id);	
		return this.finalnode;
	},
	initCarousel: function (scroller, slides, controls, options) {

		this.scrolling	= false;
		this.scroller	= scroller;
		this.slides		= slides;
		this.controls	= controls;

		this.options2    = Object.extend({ duration: 3, frequency: 10, controlClassName: 'carousel-control'+this.options.id, jumperClassName: 'carousel-jumper'+this.options.id }, options || {});

		this.slides.each(function(slide, index) {
			slide._index = index; 
		});

		if (this.controls) {
			this.controls.invoke('observe', 'click', this.click.bind(this));
		}

		if (this.options2.auto) {
			this.start();
			//this.slides.invoke('observe', 'mouseover', this.pause.bind(this));
			//this.slides.invoke('observe', 'mouseout', this.resume.bind(this));
		}

	},	
	click: function (event) {

		this.stop();

		var element = event.findElement('a');

		if (!element.hasClassName('disabled')) {
			this.deactivateControls();
			if (element.hasClassName(this.options2.controlClassName)) {
				eval("this." + element.rel + "()");
			} else if (element.hasClassName(this.options2.jumperClassName)) {
				this.moveTo(element, element.rel);
			}
		}
		event.stop();

	},
	moveTo: function (trigger, element) {


		this.notifyObservers("SlideScrollStart");

		if (this.options2.beforeMove && (typeof this.options2.beforeMove == 'function')) {
			this.options2.beforeMove();
		}

		if (this.controls && this.options2.selectedClassName) {
			this.controls.each((function (elm) { elm.removeClassName(this.options2.selectedClassName); }).bind(this));
			trigger.addClassName(this.options2.selectedClassName);
		}

		this.previous= this.current ? this.current : this.slides[0];
		this.current = $(element);

		var scrollerOffset = this.scroller.cumulativeOffset();
		var elementOffset = this.current.cumulativeOffset();
		
		if (this.scrolling) {
			this.scrolling.cancel();
		}

		this.scrolling = new Effect.SmoothScroll(this.scroller, {
				//transition:Effect.Transitions.SwingTo,
				duration: this.options2.duration, 
				x: (elementOffset[0] - scrollerOffset[0]), 
				y: (elementOffset[1] - scrollerOffset[1]), 
				queue: {position: 'end', limit: 1, scope: this.scroller.id}, 
				afterFinish: (function () { 
					if (this.controls) {
						this.activateControls(); 
					}
					if (this.options2.afterMove && (typeof this.options2.afterMove == 'function')) {
						this.options2.afterMove();	
					}
					this.notifyObservers("SlideScrollEnd");
				}).bind(this)});



		return false;

	},
	prev: function () {
		if (this.current) {
			var currentIndex = this.current._index;
			var prevIndex = (currentIndex == 0) ? this.slides.length - 1 : currentIndex - 1;
		} else { 
			var prevIndex = this.slides.length - 1;
		}
		this.moveTo(this.controls ? this.controls[prevIndex] : false, this.slides[prevIndex]);
	},
	next: function () {
		if (this.current) {
			var currentIndex = this.current._index;
			var nextIndex = (this.slides.length - 1 == currentIndex) ? 0 : currentIndex + 1;      
		} else {
			var nextIndex = 1;
		}		
		this.moveTo(this.controls ? this.controls[nextIndex] : false, this.slides[nextIndex]);
	},
	first: function () {
		var firstIndex = 0;
		if (this.current) {
			var currentIndex = this.current._index;
		}
		this.moveTo(this.controls[firstIndex], this.slides[firstIndex]);	
	},
	last: function () {
		var lastIndex = (this.slides.length - 1);
		if (this.current) {
			var currentIndex = this.current._index;
		}

		this.moveTo(this.controls[lastIndex], this.slides[lastIndex]);
	},	
	toggle: function () {
		if (this.previous) {
			this.moveTo(this.controls[this.previous._index], this.slides[this.previous._index]);
		} else {
			return false;
		}
	},
	stop: function () { clearTimeout(this.timer); },
	start: function () { this.periodicallyUpdate(); },		
	pause: function (event) {
		this.stop();
		this.activateControls();
	},
	resume: function (event) {
		if (event) {
			var related = event.relatedTarget || event.toElement;	
			if (!related || (!this.slides.include(related) && !this.slides.any(function (slide) { return related.descendantOf(slide); }))) {
				this.start();
			}
		} else {
			this.start();
		}
	},	
	periodicallyUpdate: function () {
		if (this.timer != null) {
			clearTimeout(this.timer);
			this.next();
		}
		this.timer = setTimeout(this.periodicallyUpdate.bind(this), this.options2.frequency * 1000);
	},
	deactivateControls: function () {
		this.controls.invoke('addClassName', 'disabled');
	},
	activateControls: function () {
		this.controls.invoke('removeClassName', 'disabled');
	}	
}
Object.extend(CarouselWidget.prototype, WidgetCommon);
Object.extend(CarouselWidget.prototype, Observable);
;

// /8::/202::/core:js -> <452050> defaultbuttonwidget.js 

DefaultButtonWidget = Class.create();
DefaultButtonWidget.prototype = {
  defaultOptions: function(){
    return {
      caption:TN("BUTTON"),
      onClickAction:function(e){},
      width:100
    }
  },
  setup:function(){
    var obs = {clicked:function(d,e){

    }.bind(this)};
    this.addObserver(obs);
  },
  over:function(e){
      $(this.leftcorner).setStyle({backgroundPosition:"0px -26px"});
      $(this.rightcorner).setStyle({backgroundPosition:"0px -26px"});
      $(this.btnfill).setStyle({backgroundPosition:"0px -26px"});
  },
  out:function(e){
      $(this.leftcorner).setStyle({backgroundPosition:"0px 0px"});
      $(this.rightcorner).setStyle({backgroundPosition:"0px 0px"});
      $(this.btnfill).setStyle({backgroundPosition:"0px 0px"});
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  makeWidgetContent: function(){
    var width = this.options.width;

    var bstyle = "width:"+width+"px;position:relative;top:0px;cursor:pointer;";
    var txtstyle = "line-height:26px;text-align:center;color:black;text-decoration:none;font-size:12px;";

    var sstyle = "width:2px;height:26px;float:left;";

    var leftimg = this.imageurl("gbtn-l.png");
    var rightimg = this.imageurl("gbtn-r.png");
    var fillimg = this.imageurl("gbtn-m.png");

    var fillstyle = "height:26px;float:left;width:"+(width-4)+"px;background:url("+fillimg+"); repeat-x;"

    this.leftcorner = Builder.node('div',{style:sstyle+"background:url("+leftimg+");"});
    this.rightcorner = Builder.node('div',{style:sstyle+"background:url("+rightimg+");"});
    this.btnfill = Builder.node('div',{style:txtstyle+fillstyle},[
      this.options.caption
    ]);

    var btninner = Builder.node('div',{style:bstyle},[
      this.leftcorner,
      this.btnfill,
      this.rightcorner,
      Builder.node('div',{style:"clear:both;"})
    ]);

    Event.observe($(btninner),'mouseover',function(e){
      this.over(e);
    }.bind(this));
    Event.observe($(btninner),'mouseout',function(e){
      this.out(e);
    }.bind(this));
    Event.observe($(btninner),'mousedown',function(e){
      this.out(e)
    }.bind(this));
    Event.observe($(btninner),'mouseup',function(e){
      this.over(e);
    }.bind(this));
    Event.observe($(btninner),'click',function(e){
      this.notifyObservers("clicked",e);
      this.options.onClickAction();
    }.bind(this));

    var bg = "background:transparent;"
    var btnwrapper = Builder.node('div',{style:bstyle+bg+"clear:both;"},[btninner]);
    return btnwrapper;
  }
}  
Object.extend(DefaultButtonWidget.prototype, WidgetCommon);
Object.extend(DefaultButtonWidget.prototype, Observable);

;

// /8::/202::/core:js -> <909> displayitemwidgets.js 

DisplayItemComponent = {
  defaultOptions: function() {
    return {
      defaultItem: null,
      model: null,
      containerElement: null,
      condensed: false,
      closeButton: false,
      progressSlider: false,
      tooltip: null
    }
  },
  adjustWindowSizes: function(sizes) {
    sizes.reserveHeight = 0 //54
  },
  setup: function() {
    this.m = this.options.defaultItem
    this.model = this.options.model
    this.model.addObserver(this)
    this.playMode = false
    var instance = this
    // atw = new shareWidget({item:instance.m,model:instance.model});
    // commWid = new CommentsWidget({m: instance.m,model: instance.model});
    this.templateProcessingList = []
    this.playDelay = 2000
    if (this.afterSetup) {
      this.afterSetup()
    }
    this.anticipateResume = false
  },
  makeWidgetContent: function() {
    var r = Builder.node('span', {}, [
      this.makeDisplayContentAndNavigationTemplate() 
    ])
    this.updateDisplayContentAndNavigation()
    if (this.options.tooltip) {
      var instance = this
      r.onmouseover = function() {
        instance.options.tooltip.delayedShow({
          m: instance.m, 
          element: r,
          model: instance.model
        })
      }
    }
    return r;
  },
  makePlayAction: function() {
    var instance = this
    var playLink =  this.activeLink((instance.playMode ? "pause" : "play" ), {
      onclick: function(event) {
        if (event) Event.stop(event)
        if (instance.playMode) {
          instance.anticipateResume = true
          instance.stop()
          instance.rerender()
        } else {
          instance.start()
          instance.rerender()
        }
        return false
      }
    })
    // "Override" the onTemplateProcessing of the above activeLink.
    this.onTemplateProcessing(function(i, n) {
      n.parameters["play_image_name"] = 
        iconPath(22, (i.playMode ? "pause" : "play"))
      n.parameters["play_title"] = (i.playMode ? "pause" : "play" )
    })
    return playLink;
  },
  start: function() {
    this.playMode = true
    var instance = this
    if (this.autoplayDelay) {
      this.playInterval = setTimeout(function() {
        if (!instance.model.hasNext(instance.m))  {
          instance.stop()
          instance.rerender()
          return 
        }
        instance.next()
      }, this.autoplayDelay)
    }
    if (this.anticipateResume && this.afterResume) {
      this.anticipateResume = false
      this.afterResume()
    } else if (this.afterStart) {
      this.afterStart()
    }
  },
  stop: function() {
    this.playMode = false
    if (this.autoplayDelay) {
      clearInterval(this.playInterval)
    }
    if (this.anticipateResume && this.afterPause) {
      this.afterPause()
    } else if (this.afterStop) {
      this.afterStop()
    }
  },
  maxHeightPx: function() {
    if (this.options.window) {
      var h = this.options.window().height - 65 
    }
    else if (this.options.containerElement) {
      var h = this.options.containerElement().frameDiv.offsetHeight - 65       
    }
    else {
      var h = 0
    }
    h -= 10
    return Math.max(h, 0) + "px"
  },
  maxWidthPx: function() {
    if (this.options.window) {
      var h = this.options.window().width
    }
    else if (this.options.containerElement) {
      var h = this.options.containerElement().frameDiv.offsetWidth
    }
    else {
      var h = 0
    }
    h -= 10
    return Math.max(h, 0) + "px"
  },
  autoSizeItemNode: function(itemNode) {
    var fun = function() {
      var mwp = this.maxWidthPx()
      if (mwp == "none") return;
      itemNode.style.maxWidth  = mwp;
      itemNode.style.maxHeight = this.maxHeightPx();
    }.bind(this)
    autoSize('displayitem', fun)
    if (this.options.window) {
      this.options.window().addOnResize(fun)
    }
    var i = setInterval(function() {
      if (this.maxHeightPx() == "none") return
      clearInterval(i)
      fun()
    }.bind(this), 100)
    return itemNode
  },
  makeDisplayContentAndNavigationTemplate: function() {
    var topbar = this.makeTopBarTemplate()
    var bar = this.makeActionBarTemplate()
    var idat = table(
      {width: "100%", height: "100%", id: "template:reference_as idat"}, [
        Builder.node('div', {
          className: 'item-display-area'
        }, [
          this.makeDisplayContentTemplate()
        ])
    ])
    this.onTemplateProcessing(function(i, n) {
      var f = function() {
        $(n.references.idat).setStyle({
          height: this.maxHeightPx(),
          width: this.maxWidthPx()
        })        
      }.bind(this)
      f()
      if (this.options.window) {
        this.options.window().addOnResize(f)
      }
    }.bind(this))
    // bar.style.height = "65px"
    Element.down(idat, 'td').setStyle({
      verticalAlign: "middle",
      textAlign:     "center"
    })
    var r = Builder.node('div', {}, [topbar,idat,bar])
    this.template = new MSTemplate({create: function() { return r}})
    this.templateAccessors = this.template.makeAccessors()
    return this.template.templateNode
  },
  activeLink: function(active, action, o) {
    if (arguments.length == 2) {
      o      = action
      action = active
      active = function() { return true; }
    }
    this.onTemplateProcessing(function(i, n) {
      n.parameters[action + "_onclick"] = 
          (active() ? o.onclick : function() { return false })
      n.parameters[action + "_image_name"] = 
          iconPathForColor(
            active() ? iconsColor : "grey",
            o.iconSize || 22,
            action
          )
      n.parameters[action + "_title"] = action
    })
    return imageActionLink({
      onclick: "template:value_of " + action + "_onclick",
      fullImageName: "template:value_of " + action + "_image_name",
      title: "template:value_of " + action + "_title"
    })
  },
  previous: function() {
    this.anticipateResume = false
    if (!this.model.hasPrevious(this.m)) {
      return
    }
    this.m = this.model.previous(this.m)
    if (this.options.window) {
      var a = Builder.node('div', [Builder.node('a', {
        href: this.model.currentPathPermalink(this.m),
        target: "_blank",
        style: "color:black;"
      }, [TN(this.m.name)])])
      this.options.window().setTitle(a.innerHTML)
      var i = $("item_"+this.m.pretty_name)
      if (i) i.onclick()      
    }
    if (this.playMode) {
      this.stop()
      this.start()
    }
    if (this.afterPrevious) {
      this.afterPrevious()
    } else {
      this.rerender()
    }
  },
  next: function() {
    this.anticipateResume = false
    if (!this.model.hasNext(this.m)) {
      return
    }
    this.m = this.model.next(this.m)
    if (this.options.window) {
      var a = Builder.node('div', [Builder.node('a', {
        href: this.model.currentPathPermalink(this.m),
        target: "_blank",
        style: "color:black;"
      }, [TN(this.m.name)])])
      this.options.window().setTitle(a.innerHTML)
      var i = $("item_"+this.m.pretty_name)
      if (i) i.onclick()      
    }
    if (this.playMode) {
      this.stop()
      this.start()
    }
    if (this.afterNext) {
      this.afterNext()
    } else {
      this.rerender()
    }
  },
  activateNewItem: function(m) {
    if (this.playMode) {
      this.stop()
    }
    this.m = m
    this.anticipateResume = false
    this.start()
    this.rerender()
  },
  onTemplateProcessing: function(l) {
    this.templateProcessingList.push(l)
  },
  makeTopBarTemplate: function() {
    if (this.options.window) return EMPTY()
    var instance = this
    var d = Builder.node('div', {className: 'top-bar'})
    var row = []
    var checkbox
    row.push({
      columnOptions: {
        /* width: "20%" */
      },
      columnData: [
        fnNode = Builder.node('div', {
            id: 'template:reference_as fn_span',
            style: "white-space: nowrap;",
            className: "filename"
          }, [
          checkbox = Builder.node('input', {
            id: 'template:reference_as checkbox',
            type: 'checkbox',
            checked: true
          }) ,
          TN("template:value_of filename") 
        ])
      ]
    })
    this.onTemplateProcessing(function(i, n) {
      n.parameters["filename"] = i.m.name
      var s = i.m.selected != undefined && i.m.selected != false
      n.references.fn_span.style.backgroundColor = s ? "#ccc" : "transparent"
      
     var checkbox = n.references.checkbox
      checkbox.checked = s
      checkbox.onclick = function() {
        toggleSelection({
          m: i.m, 
          element: fnNode, 
          model: i.model,
          onselect: function(e) {
            e.style.background = "#ccc"
          },
          onunselect: function(e) {
            e.style.background = ""
          }
        })
      } 
    })
    if (!this.options.condensed) {
      row.push(["Rating:", Builder.node('span', {id: 'template:reference_as rating'})])
      this.onTemplateProcessing(function(i, n) {
        replaceChild(n.references.rating, makeRatingWidget(i.model, i.m))
      })
      row.push({
        columnOptions: {
          /* width: "20%" */
        },
        columnData: [Builder.node('span', {style: "white-space: nowrap;"}, [
          NBSP(), Builder.node('b', {}, [translateText({id: "tags"})]), TN(" "), 
          Builder.node('span', {id: 'template:reference_as tags'}, [])
        ])]
      })
      this.onTemplateProcessing(function(i, n) {
        replaceChild(n.references.tags, i.model.actions.selectableTags(
            {sensitive: true, m: i.m}))
      })
      row.push({columnOptions: {align: "center", width: "100%"}, columnData: [
        TN("template:value_of filename")
      ]})
      if (this.options.closeButton && this.options.containerElement) {
        row.push([
          this.activeLink("close",{
            onclick: function() {
              instance.options.containerElement().close()
              return false;
            },
            iconSize: 24
          })
        ])
      }
    }

    var barRow = []
    if (this.leftSideActions) {
      barRow.push(this.leftSideActions())
    }
    var ds = Builder.node('span', {})
    var t = table({cellspacing: "2"}, row.flatten())
    // Can't set style attribute on table cells in IE
    if (!this.options.condensed) {
      Element.down(t, 'td[align="center"]').style.paddingRight = "20%"
    }
    ds.appendChild(t)
    barRow.push({
      columnOptions: {
        width: "100%"
      },
      columnData: [ ds ]
    })
    d.appendChild(table(barRow))
    return d
  },
  makeActionBarTemplate: function() {
    var d = Builder.node('div', {
      className: 'action-bar',
      style: "font-size:12px;"
    })
    var td1 = Builder.node('td')
    td1.style.textAlign = "left" // necessary for the slider!
    if (this.sliderAction) {
      td1.appendChild(Builder.node('span', {
        id: 'template:reference_as slider_action'
      }))
      this.onTemplateProcessing(function(i, n) {
        if (!this.slider) {
          replaceChild(
            n.references.slider_action,
            Builder.node('span', this.sliderAction())
          )          
        }
      }.bind(this))
    }
    var td2 = Builder.node('td')
    td2.style.textAlign = "center"
    td2.appendChild(this.activeLink(function() { 
      return this.model.hasPrevious(this.m) 
    }.bind(this), "previous", {onclick: function(event) {
      if (event) Event.stop(event)
      this.previous(true)
      return false;
    }.bind(this)}))
    if (this.playAction) {
      td2.appendChild(this.playAction())
    }
    td2.appendChild(this.activeLink(function() {
      return this.model.hasNext(this.m) 
    }.bind(this), "next", {onclick: function(event) {
      if (event) Event.stop(event)
      this.next(true)
      return false
    }.bind(this)}))
    if (!this.options.condensed) {
      // IE merges adjacent text nodes on cloneNode(), which we use in
      // MSTemplate. Therefore we need to wrap each TN in a span node.
      $A([
        TN("template:value_of di_current"),
        TN(" / "),
        TN("template:value_of di_total")
      ]).each(function(n) {
        td2.appendChild(Builder.node('span', [n]))
      })
      this.onTemplateProcessing(function(i, n) {
        n.parameters["di_current"] = i.m.index
        n.parameters["di_total"] = i.model.displayItems().length
      })
    }
    var td3 = Builder.node('td')
    td3.style.textAlign = "center"
    var td4 = Builder.node('td')
    td4.style.textAlign = "center"
    var td5 = Builder.node('td')
    td5.style.textAlign = "center"
    if (!this.options.condensed) {
      td3.appendChild(Builder.node('span', {id: 'template:reference_as share'}))
      this.onTemplateProcessing(function(i, n) {
        replaceChild(n.references.share, new shareWidget({
          item:i.m,
          model:this.model,
          shortText: true
        }).htmlNode())
      }.bind(this))
      td4.appendChild(Builder.node('span', {
        style:"white-space: nowrap;",
        id: "template:reference_as rate"
      }))
      this.onTemplateProcessing(function(i, n) {
        replaceChild(n.references.rate, makeRatingWidget(this.model, i.m).htmlNode())
      }.bind(this))
      td5.appendChild(  Builder.node('span', {
        id: "template:reference_as comment",
        style: "white-space: nowrap;"
      }))
      this.onTemplateProcessing(function(i, n) {
        replaceChild(n.references.comment, new CommentsWidget({
          m: i.m,
          model:this.model
        }).htmlNode())
      }.bind(this))
    }
    var barRow = []
    if (this.leftSideActions) {
      barRow.push(this.leftSideActions())
    }
    $A([td1,td2,td3,td4,td5]).each(function(td) {
      td.style.verticalAlign = "middle"
    })
    var ds = Builder.node('span', {})
    ds.appendChild(Builder.node('table', {
      cellspacing: "2",
      border: "0",
      width: "99%"
    }, [
      Builder.node('tbody', [
        Builder.node('tr', [td1, td2, td3,td4,td5])
      ])
    ]))
    barRow.push({
      columnOptions: {
        width: "99%"
      },
      columnData: [ ds ]
    })
    d.appendChild(table(barRow))
    return d
  },
  updateDisplayContentAndNavigation: function() {
    var instance = this;
    var n = {
      parameters: {m: this.m},
      references: this.templateAccessors.references
    }
    this.templateProcessingList.each(function(p) {
      p(instance, n)
    })
    this.templateAccessors.processor(n.parameters)
  },
  volumeChanged: function(v) {
    this.volume = 1 - v;
    if (this.afterVolumeChanged) {
      this.afterVolumeChanged()
    }
  },
  makeVolumeAction: function() {
    var instance = this
    return new EasySliderWidget({
        defaultSliderValue: 0.8,
        axis: 'vertical',
        trackImage: "scaler_slider_track_vertical.gif",
        onSlide: function(v) { instance.volumeChanged(v) },
        onChange: function(v) { instance.volumeChanged(v) }
      }).htmlNode()
  },
  positionChanged: function(v) {
    this.position = v
    this.updateTime()
    if (this.afterPositionChanged) {
      this.afterPositionChanged()
    }
  },
  positionSlided: function(v) {
    this.position = v;
    this.updateTime();
    if (this.afterPositionSlided) {
      this.afterPositionSlided();
    }
  },
  updateTime: function() {
    this.timeNode.nodeValue = 
        makeFormattedSmallTime(this.totalTimeMs * this.position)
  },
  makePositionSlider: function() {
    var o = Object.extend({
      width: "default"
    }, arguments[0] || {}) 
    this.position = 0
    this.totalTimeMs = 6 * 60 * 1000  // 6 mins
    var instance = this
    var r = [(this.positionSlider  = new EasySliderWidget({
        width: o.width,
        defaultSliderValue: 0,
        trackImage: "scaler_slider_fixed_track.gif",
        onSlide: function(v) { instance.positionSlided(v) },
        onChange: function(v) { instance.positionChanged(v) }
      })).htmlNode(),
      this.timeNode = TN()
    ]
    this.updateTime();
    return r;
  },
  setPosition: function(v) { // 0..1
    this.positionSlider.slider.setValue(v)
  },
  rerender: function() {
    this.updateDisplayContentAndNavigation()
  }
}

Object.extend(DisplayItemComponent, WidgetCommon)

DisplayPictureWidget = Class.create()
DisplayPictureWidget.prototype = {
  preloadImages: function(m) {
    if (this.model.hasPrevious(m)) {
            new Image().src = this.model.previous(m).display_item_url
        }
    if (this.model.hasNext(m)) {
      new Image().src = this.model.next(m).display_item_url
    }
  },
  afterNext: function() { this.waitForImage() },
  afterPrevious: function() { this.waitForImage() },
  waitForImage: function() { 
    startIdle(true)
    var instance = this;
    var loader = new Image()
    var instance = this
    loader.onload = function() {
      instance.rerender()
      endIdle();
    }
    loader.src = this.m.display_item_url
  },
  makeDisplayContentTemplate: function() {
    var di = this.displayImage = Builder.node('img', {
      className: 'item',
      src: "template:value_of m.display_item_url"
    })
    this.autoSizeItemNode(di)
    //this.preloadImages(m)
    return di
  },
  playAction: function() {
    return this.makePlayAction()
  },
  onSlide: function(v) {
    v = (v * 19) + 1
    this.autoplayDelay = v * 1000
    this.vNode.nodeValue = Math.round(v) +  "s"
  },
  sliderAction: function() {
    this.slider = new EasySliderWidget({
      onSlide: function(v) { this.onSlide(v) }.bind(this),
      onChange: function(v) { this.onSlide(v) }.bind(this)
    })
    this.vNode = TN("2s")
    return [table({width: ""}, [
      this.slider.htmlNode(),
      this.vNode,
      helpTexts.helperNode("Item Widget - Slider", 14)
    ])]
  }
}

Object.extend(DisplayPictureWidget.prototype, DisplayItemComponent)

var __daw = null
var __n = null

DisplayArticleWidget = Class.create()
DisplayArticleWidget.prototype = {
  afterSetup: function() {
    __daw = this
  },
  articleReferenceNode: function(articleName, description) {
    var a = this.model.findItemByName(articleName)
    var instance = this
    if (a) {
      return actionLink({
        text: description,
        onclick: function() {
          instance.activateNewItem(a)
        }
      })
    }
    return Builder.node('span', {}, [
      TN(description),
      actionLink({
        text: "?",
        onclick: function() {
          instance.model.actions.addItem({name: articleName})
        }
      })
    ])
  },
  processArticleReferenceNode: function(n) {
    n.parentNode.replaceChild(
        this.articleReferenceNode(n.getAttribute("articlename"), 
        n.firstChild.nodeValue), n)
  },
  articleReferenceNodes: function() {
    return $A(this.displayNode.getElementsByTagName('span')).
        select(function(n) { return n.className == 'article-reference' })
  },
  processReferences: function() {
    var instance = this
    this.articleReferenceNodes().each(function(n) {
      instance.processArticleReferenceNode(n)
    })
  },
  markReferences: function(html) {
    // ^some html [[Article Name]] some html$
    return html.gsub(/\[\[([^\]\n]+)\]\]/, function(m) { 
      var c = m[1].split("|")
      var n = c[0]
      var d = c[1] || n
      return "<span class='article-reference' articlename='" + n + "'>" + 
          d + "</span>";
    })
  },
  processImages: function(html) {
    // Be careful to just replace URLs in IMG tags.
    return html.gsub(/<img\s*(.*)\s*src=\"([^"]+)\"/i, function(m) { 
      return "<img " + m[1] + " src=\"" + localizeURL(m[2]) + "\""
    })    
  },
  afterShow: function() {
    this.processReferences()
  },
  makeDisplayContentTemplate: function() {
    var instance = this
    var d
    Builder.node('span', {}, [
      // The noscript tag doesn't work like this in IE!
      // Builder.node('noscript', {}, [
        d = Builder.node('div', {className: 'article-display'}, [ ])
      // ])
    ])
    this.displayNode = d


    this.onTemplateProcessing(function(i, n) {
      i.displayNode = $(instance.template.templateNode).down('.article-display')
      i.displayNode.innerHTML = 
          /* "<div class='article-header'>" + i.m.name + "</div>" */
              i.processImages(i.markReferences(i.m.body))
      i.displayNode.appendChild(
        autoAfterShowWidget(function() { i.afterShow() }))
    })

    this.autoSizeItemNode(d)
    return this.displayNode;
  }
}
Object.extend(DisplayArticleWidget.prototype, DisplayItemComponent)

function displayItemClass(m) {
  return javaScript["Display" + localType(m) + "Widget"]
}

function displayItemLeftBarClass(m) {
  return javaScript["DisplayLeftBar" + localType(m) + "Widget"]
}

function haveDisplayItemClass(m) {
  return displayItemClass(m) != undefined || 
      displayItemLeftBarClass(m) != undefined
}

var leftBarDisplayWidgets = {}

function localType(m) { return m.type.gsub(/^[^:]*:/, "").capitalize()}

var sidebarplayer;
function displayItem(m, model) {
  var lbClass = displayItemLeftBarClass(m)
  if (lbClass != undefined) {
    var w = leftBarDisplayWidgets[localType(m)]
    if (w == undefined) {
      var widget = new (lbClass)({
        progressSlider: true,
        condensed: true,
        model: model,
        defaultItem: m,
        // containerElement: function() { return EMPTY() },
        tooltip: ""//makeStandardItemTooltip()
      })
      leftBarDisplayWidgets[m.type] = widget
      if(sidebarplayer){
        $(sidebarplayer).remove();
      }
      sidebarplayer = new BoxWidget({
        id: 'sbtp',
        title: TN("TunesPlayer"),
        node: widget.htmlNode(),
        className: "mybox",
        width: "200"
      }).htmlNode()
      var theplayer = Builder.node('div', {
        id: localType(m).toLowerCase(),
        style: "margin-left:-1px;border:0px solid black;"
      }, [sidebarplayer])
      $("left-bar").appendChild(theplayer);
    } else {
      leftBarDisplayWidgets[localType(m)].activateNewItem(m)
    }
  } else {
    var resizeCallbacks = []
    var a = Builder.node('div', [Builder.node('a', {
      href: model.currentPathPermalink(m),
      target: "_blank",
      style: "color:black;"
    }, [TN(m.name)])])
    new ThemedWindow({
      title: a.innerHTML,
      width:  displayItemClass(m).prototype.width  || 600,
      height: displayItemClass(m).prototype.height || 400,
      minimizable: true,
      maximizable: true,
      showEffect: Element.show,
      hideEffect: Element.hide,
      destroyOnClose: true,
      onClose: function(w) {
        w.widget.stop()
      },
      onResize: function(w) {
        $A(resizeCallbacks).each(function(rc) {
          rc(w)
        })
      },
      onMaximize: function(w) { w._notify("onResize")},
      onMinimize: function(w) {
        w.explorerElement = itemInfoInstance.previousElement
      },
      onShow: function(w) {
        if (w.explorerElement) {
          itemInfoInstance.showActionsForItem(m, model, w.explorerElement)
        }
      }
    }, function(w) {
      w.addOnResize = function(rc) { resizeCallbacks.push(rc)}
      w.widget = new (displayItemClass(m))({
        closeButton: false,
        defaultItem: m,
        model: model,
        window: function() { return w; }
      })
      var t = table({width: "100%", height: "100%"}, [
        w.widget.htmlNode()
      ])
      var td = Element.down(t, 'td')
      Element.down(t, 'td').setStyle({
        verticalAlign: "middle",
        textAlign:     "center"
      })
      w.setContent(t)
      w.showCenter()
      w.toFront()
    })
    // for the permalinks
    if ($("item_"+m.pretty_name)) $("item_"+m.pretty_name).onclick()
  }
}


;

// /8::/202::/core:js -> <910> displaymodeloverride.js 


;

// /8::/202::/core:js -> <907> displaystreamitemwidgets.js 

DisplayFlashComponent = {
  genericAfterSetup: function(style,type) {
    this.uniqueID = "flash-player-" + (new Date()).getTime()
    this.tunePlayer = Builder.node("div", {
      style: style,
      className: "tunePlayer",
      id: this.uniqueID
    },[ 
      Builder.node('img', {
        style: "padding:5px;margin:0px auto;",
        src:   "/images/spinner.gif"
      })
    ]);
    this.ttype = type; 
    this.start();
  },
  makeDisplayContentTemplate: function() {
    this.autoSizeItemNode(this.tunePlayer)
    this.autoSizeFlash();
    return this.tunePlayer;
  }, 
  afterStart: function() {
    window.setTimeout(function(){
      // Probably due to the use of cloneNode in MSTemplate in IE
      // instance.tunePlayer doesn't refer to the right node so we
      // have to get the right one here.
      var node = $(this.uniqueID)
      this.getSwfObject(this.m.flv_url, this.ttype).write(node);
    }.bind(this),1000); 
  }, 
  getSwfObject:function(flv,type){       
    var so = new SWFObject(
      '/core-services/myplayer.swf?'+Math.random(),
      "mymovie",
      this.maxWidthPx(),
      this.maxHeightPx(),
      "7",
      "#FFFFFF"
    );
    so.addParam('allowScriptAccess', 'always'); 
    var flvpath = flv;  
    so.addParam('flashVars', 'v='+flvpath+'&d=true&t='+type);   
    so.addParam('allowFullscreen', "true");  
    return so;   
  }, 
  autoSizeFlash: function() {
    var fun = function() {
      var tp = $(this.uniqueID)
      if (!tp) return
      var em = tp.firstChild
      var w = parseInt(this.maxWidthPx());
      var h = parseInt(this.maxHeightPx());
      if (!isNaN(w)) {
        switch (em.tagName) {
          case "EMBED":
            em.width  = w;
            em.height = h;
            break;
          case "OBJECT":
            em.width  = w;
            em.height = h;            
            break;
          default:
            // Ignore all other cases
            break;
        }
      }
    }.bind(this)
    autoSize('displayitem', fun)
    if (this.options.window) {
      this.options.window().addOnResize(fun)
    }
    var i = setInterval(function() {
      if (this.maxHeightPx() == "none") return
      if (this.tunePlayer.firstChild.tagName == "IMG") return
      clearInterval(i)
      fun()
    }.bind(this), 100)
  }
}

DisplayTuneWidget = Class.create()
DisplayTuneWidget.prototype = {
  afterSetup: function() {
    this.genericAfterSetup("","tune");
  },
  width:  300,
  height: 200
}
Object.extend(DisplayTuneWidget.prototype, DisplayFlashComponent)
Object.extend(DisplayTuneWidget.prototype, DisplayItemComponent)

DisplayMovieWidget = Class.create()
DisplayMovieWidget.prototype = {
  afterSetup: function() {
    this.genericAfterSetup("","movie");
  }
}
Object.extend(DisplayMovieWidget.prototype, DisplayFlashComponent);
Object.extend(DisplayMovieWidget.prototype, DisplayItemComponent);


;

// /8::/202::/core:js -> <433788> externaluploader.js 

function fileQueued(file) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus("Waiting...");
		progress.toggleCancel(true, swfu);

		this.customSettings.tdFilesQueued.innerHTML = this.getStats().files_queued;	

	} catch (ex) {
		this.debug(ex);
	}
}

function fileQueueError(file, errorCode, message) {
	try {
		if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
			alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
			return;
		}

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
			progress.setStatus("File is too big.");
			this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
			progress.setStatus("Cannot upload Zero Byte files.");
			this.debug("Error Code: Zero byte file, File name: " + file.name + ", File                 size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
			progress.setStatus("Invalid File Type.");
			this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		default:
			if (file !== null) {
				progress.setStatus("Unhandled Error");
			}
}
  }catch(ex){
        this.debug(ex);
    }
}

function fileDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		if (numFilesSelected > 0) {
			$(this.customSettings.cancelButtonId).disabled = false;
		}
		
		/* I want auto start the upload and I can do that here */
		//this.startUpload();

                if (numFilesQueued > 0) {
try{
                 $("albumselection").hide();
}catch(e){}
  $("uploadbtns").setStyle({top:"-1000px"});
  $("permissionselect").show();

                }                

	} catch (ex)  {

        this.debug(ex);

	}
}


function uploadStart(file) {
	try {
	
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus("Uploading...");
		progress.toggleCancel(true, swfu);
                updateDisplay.call(this, file);
	}
	catch (ex) {}
	
	return true;
}

function uploadProgress(file, bytesLoaded, bytesTotal) {
	try {
		var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setProgress(percent);
		progress.setStatus("Uploading...");
                updateDisplay.call(this, file);
	} catch (ex) {
		this.debug(ex);
	}
}

var uploadpath = document.location.href;
var uploadmodel = null;
var uploaditem = null;

function parseServerData(serverData){
  try{
    var bits = serverData.split("var model_data = ");
    var bits2 = bits[1].split("var write_username = ");
    var modeldata = bits2[0];
    uploadmodel = (modeldata).evalJSON();
    uploaditem = uploadmodel.items[0];
    uploadpath =  uploadmodel.path.gsub("/","");
    if(uploadpath.length < 3 && uploadpath.match(/http:/) != null){
      uploadpath = "";
    }

  }catch(e){};
}

function uploadSuccess(file, serverData) {

        parseServerData(serverData);

	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setComplete();
		progress.setStatus("Complete.");
		progress.toggleCancel(false);
                updateDisplay.call(this, file);
	} catch (ex) {
		this.debug(ex);
	}
}

function uploadError(file, errorCode, message) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
			progress.setStatus("Upload Error: " + message);
			this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
			progress.setStatus("Upload Failed.");
			this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.IO_ERROR:
			progress.setStatus("Server (IO) Error");
			this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
			progress.setStatus("Security Error");
			this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
			progress.setStatus("Upload limit exceeded.");
			this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
			progress.setStatus("Failed Validation.  Upload skipped.");
			this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
			// If there aren't any files left (they were all cancelled) disable the cancel button
			if (this.getStats().files_queued === 0) {
				$(this.customSettings.cancelButtonId).disabled = true;
			}
			progress.setStatus("Cancelled");
			progress.setCancelled();
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
			progress.setStatus("Stopped");
			break;
		default:
			progress.setStatus("Unhandled Error: " + errorCode);
			this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}

var lastuploadedfile = null;

function uploadComplete(file) {
	this.customSettings.tdFilesQueued.innerHTML = this.getStats().files_queued;
	//this.customSettings.tdFilesUploaded.innerHTML = this.getStats().successful_uploads;
	//this.customSettings.tdErrors.innerHTML = this.getStats().upload_errors;

	if (this.getStats().files_queued === 0) {
		$(this.customSettings.cancelButtonId).disabled = true;
	}else {
            this.startUpload();
        }
        lastuploadedfile = file;
}

// This event comes from the Queue Plugin
function queueComplete(numFilesUploaded) {
	//var status = $("divStatus");
	//status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded.";

  window.setTimeout(function(){
    ssuw.notification.showNotification(TN("Your Files have been uploaded."));
    window.setTimeout(function(){
      if(ssuw.options.afterUpload != null){
        ssuw.options.afterUpload();
      }else{
          //if(ssuw.options.album_name != ""){
var url = "http://";
url += write_user_model_data.username;
url += ".mysites.com/-";
url += uploadpath;

           document.location = url ;

          //}
      }
    }.bind(this),2000)
  }.bind(this),2000);

  //ssuw.options.model.update();
}

function updateDisplay(file) {

if(ssuw.options.status){

	this.customSettings.tdCurrentSpeed.innerHTML = SWFUpload.speed.formatBPS(file.currentSpeed);
	//this.customSettings.tdAverageSpeed.innerHTML = SWFUpload.speed.formatBPS(file.averageSpeed);
	//this.customSettings.tdMovingAverageSpeed.innerHTML = SWFUpload.speed.formatBPS(file.movingAverageSpeed);
	this.customSettings.tdTimeRemaining.innerHTML = SWFUpload.speed.formatTime(file.timeRemaining);
	//this.customSettings.tdTimeElapsed.innerHTML = SWFUpload.speed.formatTime(file.timeElapsed);
	this.customSettings.tdPercentUploaded.innerHTML = SWFUpload.speed.formatPercent(file.percentUploaded);
	//this.customSettings.tdSizeUploaded.innerHTML = SWFUpload.speed.formatBytes(file.sizeUploaded);
	//this.customSettings.tdProgressEventCount.innerHTML = this.customSettings.progressCount;

}

}


function FileProgress(file, targetID) {
	this.fileProgressID = file.id;

	this.opacity = 100;
	this.height = 0;

	this.fileProgressWrapper = $(this.fileProgressID);

	if (!this.fileProgressWrapper) {
		this.fileProgressWrapper = Builder.node("div",{
                                             id:this.fileProgressID,
                                             className:"progressWrapper"
                                           });
	
		this.fileProgressElement = Builder.node("div",{className:"progressContainer"});

		var progressCancel = Builder.node("a",{
                                       style:"",
                                       href:"#",
                                       className:"progressCancel"},[TN(" ")]);		

		var progressText = Builder.node("div",{className:"progressName"},[
                                     TN(file.name)
                                   ]);		

		var progressBar = Builder.node("div",{className:"progressBarInProgress"});		

		var progressStatus = Builder.node("div",{className:"progressBarStatus"});		
		progressStatus.innerHTML = "&nbsp;";

		this.fileProgressElement.appendChild(progressCancel);
		this.fileProgressElement.appendChild(progressText);
		this.fileProgressElement.appendChild(progressStatus);
		this.fileProgressElement.appendChild(progressBar);

		this.fileProgressWrapper.appendChild(this.fileProgressElement);

		$(targetID).appendChild(this.fileProgressWrapper);
	} else {
		this.fileProgressElement = this.fileProgressWrapper.firstChild;
		this.reset();
	}

	this.height = this.fileProgressWrapper.offsetHeight;
	this.setTimer(null);


}

FileProgress.prototype.setTimer = function (timer) {
	this.fileProgressElement["FP_TIMER"] = timer;
};
FileProgress.prototype.getTimer = function (timer) {
	return this.fileProgressElement["FP_TIMER"] || null;
};
FileProgress.prototype.reset = function () {
	this.fileProgressElement.className = "progressContainer";

	this.fileProgressElement.childNodes[2].innerHTML = "&nbsp;";
	this.fileProgressElement.childNodes[2].className = "progressBarStatus";
	
	this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
	this.fileProgressElement.childNodes[3].style.width = "0%";
	
	this.appear();	
};
FileProgress.prototype.setProgress = function (percentage) {
	this.fileProgressElement.className = "progressContainer green";
	this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
	this.fileProgressElement.childNodes[3].style.width = percentage + "%";

	this.appear();	
};
FileProgress.prototype.setComplete = function () {
	this.fileProgressElement.className = "progressContainer blue";
	this.fileProgressElement.childNodes[3].className = "progressBarComplete";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	this.setTimer(setTimeout(function () {
                Effect.SlideUp($(oSelf.fileProgressElement));
                Effect.Fade($(oSelf.fileProgressElement));
	}, 800));
};
FileProgress.prototype.setError = function () {
	this.fileProgressElement.className = "progressContainer red";
	this.fileProgressElement.childNodes[3].className = "progressBarError";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	this.setTimer(setTimeout(function () {
                Effect.SlideUp($(oSelf.fileProgressElement));
		Effect.Fade($(oSelf.fileProgressElement));
	}, 2000));
};
FileProgress.prototype.setCancelled = function () {
	this.fileProgressElement.className = "progressContainer";
	this.fileProgressElement.childNodes[3].className = "progressBarError";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	this.setTimer(setTimeout(function () {
                Effect.SlideUp($(oSelf.fileProgressElement));
		Effect.Fade($(oSelf.fileProgressElement));
	}, 1000));
};
FileProgress.prototype.setStatus = function (status) {
	this.fileProgressElement.childNodes[2].innerHTML = status;
};

// Show/Hide the cancel button
FileProgress.prototype.toggleCancel = function (show, swfUploadInstance) {
	this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
	if (swfUploadInstance) {
		var fileID = this.fileProgressID;
		this.fileProgressElement.childNodes[0].onclick = function () {
			swfUploadInstance.cancelUpload(fileID);
			return false;
		};
	}
};

FileProgress.prototype.appear = function () {
	if (this.getTimer() !== null) {
		clearTimeout(this.getTimer());
		this.setTimer(null);
	}
	
	$(this.fileProgressWrapper).setOpacity(1);
		
	this.fileProgressWrapper.style.height = "";
	
	this.height = this.fileProgressWrapper.offsetHeight;
	this.opacity = 100;
	this.fileProgressWrapper.style.display = "";
	
};

var swfu;
var ssuw = null;

externalUploader = Class.create();
externalUploader.prototype = {
  defaultOptions: function(){
    return Object.extend({
      afterUpload:null,
      width:500,
      permission:"onlyme",
      status:true,
      album_name:"",
      model:null,
      style:"position:relative;padding:5px;margin-bottom:5px;background:white;"
    },arguments[0]);
  },
  setup:function(){
    this.notification = new simpleNotificationWidget({s:"",width:250,height:50,icon:true});
   
this.options.style = this.options.style+"width:"+(this.options.width)+"px";
    ssuw = this;
    //this.permission = this.options.permission;
  },
  updateUrl:function(p){
    var perms = "?permission="+p;
    var album = "&album_name="+this.options.album_name;
    var url = "http://www.mysites.com/upload"+perms+album;
    swfu.setUploadURL(url);
  },
  startUploader:function(){
    this.updateUrl(this.options.permission);

if(this.options.status){
    $("uploadstats").show();
}
    window.setTimeout(function(){
       swfu.startUpload();
    }.bind(this),200);
  },
  expand:function(){
    if(!this.moving && !this.expanded){
      this.moving = true;
      $("selectalbums").show();
      new Effect.Appear($("selectalbums"),{duration:0.00001,afterFinish:function(){
        this.moving = false;
        this.expanded = true;
        $(this.arrow).setOpacity(0.2);
      }.bind(this)});
    }
  },
  collapse:function(){
   if(!this.moving && this.expanded){
       // this.sendToSwf($F("album_name"));
        this.moving = true;
       //$("selectalbums").show();
        new Effect.Fade($("selectalbums"),{duration:0.00001,afterFinish:function(){
          this.moving = false;
          this.expanded = false
          $(this.arrow).setOpacity(1);
        }.bind(this)});
      } 
  }, 
  makeAlbumSelection:function(){
    return EMPTY();
  },
  makeAlbumSelector:function(){

  //no albums for guest
  if(!logged_in){
    return EMPTY();
  }
  
  var inp = Builder.node('input',{id:"album_name",style:"color:silver;width:100%;",type:"text",name:"album_name",value:this.options.album_name != "" ? this.options.album_name : "Enter an album name"},[]);

  var albuminputnode = Builder.node('div',
    {style:"float:left;width:"+(this.options.width-150)+"px;margin-right:20px;"},[
      inp
  ]);

  var albumtxt = Builder.node('div',{style:"text-align:right;height:30px;float:left;width:95px;margin-right:5px;"},[
Builder.node('div',{style:"height:20px;margin-top:2px;"},[
Builder.node('a',{href:"javascript:void(0);",style:"font-size:17px;font-weight:bolder;"},[TN("My Albums")])
])
]);

  Event.observe($(albumtxt),'click',function(e){
    this.expand();
  }.bind(this));


  this.arrow = Builder.node('div',{style:"cursor:pointer;border:1px solid silver;float:left;width:29px;height:29px;background:white;"},[
Builder.node('div',{style:"margin-top:5px;margin-left:5px;width:18px;height:16px;background:url(http://core.myfil.es/get_file/social/arrowdown.png);"})
  ]);

  Event.observe($(this.arrow),'click',function(e){
    this.expand();
  }.bind(this));

  var cl = Builder.node('div',{style:"clear:both;"},[]);
  var albuminput = Builder.node('div',{style:""},[
    Builder.node('div',{style:"width:150px;"},[             
      Builder.node('label',{"for":"album_name",style:"width:200px;"},[
        TN("Album:"),NBSP(),Builder.node('span',{style:"color:grey;"},[TN("(optional)")
      ])
    ])
  ]),albuminputnode,albumtxt,this.arrow,cl]);

  if(this.options.album_name == ""){
   // $(albuminput).hide();
  }

    Event.observe($(inp),'focus',function(){
      $("album_name").setStyle({color:"black"});
      if($F("album_name") == "Enter an album name"){
        $("album_name").value = "";
        $("album_name").setAttribute("value","");
      }
    }.bind(this));

    Event.observe($(inp),'blur',function(){
      this.collapse();
      if($F("album_name") == ""){
        $("album_name").setStyle({color:"silver"});
        $("album_name").value = "Enter an album name";
        $("album_name").setAttribute("value","Enter an album name");
      }
    }.bind(this));

    //send typed data to flash.. needs fix for IE
    Event.observe($(inp),'keyup',function(){

      this.suggest($F("album_name"));
      //if(this.options.mode == "flash"){
        //this.sendToSwf($F("album_name"));
        this.options.album_name = $F("album_name");
        this.updateUrl(this.options.permission);
      //}

    }.bind(this));

    var albumnodes = Builder.node('div',{id:"albumselection",style:"margin-bottom:10px;"},[albuminput])

window.setTimeout(function(){
    Event.observe($(document.body),'click',function(){
      this.collapse();
    }.bind(this));


try{
//$(albuminput).show();
$("selectalbums").hide();
$("selectalbums").firstChild.innerHTML = "";
$("selectalbums").firstChild.appendChild(this.makeAlbumSelection());
}catch(e){}

}.bind(this),150);

    return albumnodes;
  },
  suggest:function(d){

     var arr = [];
     $(sdloader.loader.items()).each(function(item){
       var r = new RegExp(d, "gi")
       if(item.name.match(r)){
         arr.push(item);
       }
     }.bind(this));
     this.albumnavi.setItems(arr);
     window.setTimeout(function(){
       if(arr.length >0){
          this.expand();
       }
     }.bind(this),500);
  },
  makePermissionDialog:function(){
    
    var everyone = Builder.node('div',{style:"float:left;background:url(http://core.myfil.es/get_file/social/001-40.png);width:24px;height:24px;margin-right:10px;"},[]);
    var everyonetxt = Builder.node('div',{style:"float:left;height:24px;margin-right:10px;"},[TN("Public")]);

    var onlyme = Builder.node('div',{style:"float:left;background:url(http://core.myfil.es/get_file/social/001-42.png);width:24px;height:24px;margin-right:10px;"},[]);
    var onlymetxt = Builder.node('div',{style:"float:left;height:24px;margin-right:10px;"},[TN("Private")]);

    var s = "font-size:14px;font-weight:bolder;border:2px solid transparent;cursor:pointer;float:left;margin-right:10px;padding:10px;";

    this.ppublic = Builder.node('input',{style:"display:none;",type:"radio",name:"permission",value:"everyone"});
    this.pprivate = Builder.node('input',{style:"display:none;",type:"radio",name:"permission",value:"onlyme"});

    var c = Builder.node('div',{style:"clear:both;"},[]);

    var perms = Builder.node('div',{style:"width:320px;margin:0 auto;"},[
Builder.node('div',{style:""},[
      
      Builder.node('div',{id:"perm_public",style:s},[this.ppublic,everyone,everyonetxt]),
      Builder.node('div',{id:"perm_private",style:s},[this.pprivate,onlyme,onlymetxt]),
      c
])
    ]);  

    var pdinner = Builder.node('div',{style:""},[
Builder.node('div',{style:""},[
BR(),BR(),BR(),
        perms
])
      ]);

    this.pd = Builder.node('div',{id:"permissionselect",style:""},[
      pdinner
    ]);

    window.setTimeout(function(){
      Event.observe($("perm_public"),'click',function(e){
this.options.permission = "everyone";
        this.selectPublic();
        $(this.pd).hide();        
        $("fsUploadProgress").show();
        this.startUploader();
      }.bind(this));

      Event.observe($("perm_private"),'click',function(e){
this.options.permission = "onlyme";
        this.selectPrivate();
        $(this.pd).hide();        
        $("fsUploadProgress").show();
        this.startUploader();
      }.bind(this));
  
if(this.options.permission == "onlyme"){
      this.selectPrivate();
}else{
      this.selectPublic();
}

    }.bind(this),300);

    $(this.pd).hide();

    return this.pd;
  },
  selectPublic:function(){

   // this.permission = "everyone";

    $(this.ppublic).checked = "checked";
    $(this.pprivate).checked = "";

    $("perm_private").setStyle({fontStyle:"normal",color:"black",border:"2px solid transparent"});
    $("perm_public").setStyle({border:"2px dotted silver"});       
    $("perm_public").setStyle({color:"black",fontStyle:"italic",fontWeight:"bolder"});
    $("perm_private").setStyle({background:"transparent"});
    $("perm_private").setOpacity(0.3);
    $("perm_public").setOpacity(1);
  },
  selectPrivate:function(){
   // this.permission = "onlyme";

    $(this.ppublic).checked = "";
    $(this.pprivate).checked = "checked";

    $("perm_public").setStyle({fontStyle:"normal",color:"black",border:"2px solid transparent"});
    $("perm_public").setStyle({background:"transparent"});
    $("perm_private").setStyle({border:"2px dotted silver"});
    $("perm_private").setStyle({color:"black",fontStyle:"italic",fontWeight:"bolder"});
    $("perm_public").setOpacity(0.3);
    $("perm_private").setOpacity(1);
  },
  initUploader:function(){
    var furl = "http://www.mysites.com/core-services/swfupload.swf";

    this.settings = {
      upload_url : "http://www.mysites.com/upload"+"?permission=everyone", 
      flash_url : furl,
      file_post_name:"Filedata",
     // post_params: "",
      file_size_limit : "4096 MB",
      file_types : "*.*",
      file_types_description : "All Files",
      file_upload_limit : 100,
      file_queue_limit : 0,
      moving_average_history_size: 40,
      custom_settings : {
        progressTarget : "fsUploadProgress",
        cancelButtonId : "upcancel",
        tdFilesQueued : document.getElementById("tdFilesQueued"),
        //tdFilesUploaded : document.getElementById("tdFilesUploaded"),
        //tdErrors : document.getElementById("tdErrors"),
        tdCurrentSpeed : document.getElementById("tdCurrentSpeed"),
        //tdAverageSpeed : document.getElementById("tdAverageSpeed"),
        //tdMovingAverageSpeed : document.getElementById("tdMovingAverageSpeed"),
        tdTimeRemaining : document.getElementById("tdTimeRemaining"),
        //tdTimeElapsed : document.getElementById("tdTimeElapsed"),
        tdPercentUploaded : document.getElementById("tdPercentUploaded")
        //tdSizeUploaded : document.getElementById("tdSizeUploaded"),
        //tdProgressEventCount : document.getElementById("tdProgressEventCount")
      },
      debug: false,
      button_image_url: "http://core.myfil.es/get_file/social/ubtnbg.png",
      button_width: "130",
      button_height: "30",
      button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
      button_cursor: SWFUpload.CURSOR.HAND,
      button_placeholder_id : "upselect",
      button_text: '<span class="theFont">Select Files</span>',
      button_text_style: ".theFont { font-size: 16; text-align:center; font-family: \"Trebuchet MS\"}",
      button_text_left_padding: 0,
      button_text_top_padding: 3,
  
      file_queued_handler : fileQueued,
      file_queue_error_handler : fileQueueError,
      file_dialog_complete_handler : fileDialogComplete,
      upload_start_handler : uploadStart,
      upload_progress_handler : uploadProgress,
      upload_error_handler : uploadError,
      upload_success_handler : uploadSuccess,
      upload_complete_handler : uploadComplete,
      queue_complete_handler : queueComplete
    };

    swfu = new SWFUpload(this.settings); 

  },
  updateDynamicSettings: function () {
    var params = this.getParamsObject();
    swfu.setPostParams(params);
  },
  getParamsObject: function () {
    var params = {};
    //for (var i = 0; i < this.selParams.options.length; i++) {
    //  var name =  this.selParams.options[i].text;
    //  var value =  this.selParams.options[i].value;
    //  params[name] = value;
    //}
    return this.settings;
  },
  makeUploader:function(){
/*

//Builder.node('div',{},[TN("Files Uploaded:"),Builder.node('div',{id:"tdFilesUploaded"},[])]),
      //Builder.node('div',{},[TN("Errors:"),Builder.node('div',{id:"tdErrors"},[])]),
      //Builder.node('div',{},[TN("Average Speed:"),Builder.node('div',{id:"tdAverageSpeed"},[])]),
      //Builder.node('div',{},[TN("Moving Average Speed:"),Builder.node('div',{id:"tdMovingAverageSpeed"},[])]),
      //Builder.node('div',{},[TN("Time Elapsed:"),Builder.node('div',{id:"tdTimeElapsed"},[])]),
      //Builder.node('div',{},[TN("Size Uploaded:"),Builder.node('div',{id:"tdSizeUploaded"},[])]),
      //Builder.node('div',{},[Builder.node('div',{id:"tdProgressEventCount"},[])])
*/

    var stat = Builder.node('div',{id:"uploadstats",style:"position:relative;top:-30px;clear:both;width:"+(this.options.width)+"px;height:40px;font-size:12px;"},[

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Files Queued:"),NBSP(),Builder.node('span',{id:"tdFilesQueued"},[])]),

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Current Speed:"),NBSP(),Builder.node('span',{id:"tdCurrentSpeed"},[])]),

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Time Remaining:"),NBSP(),Builder.node('span',{id:"tdTimeRemaining"},[])]),

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Percent Uploaded:"),NBSP(),Builder.node('span',{id:"tdPercentUploaded"},[])]),

Builder.node('div',{style:"clear:both;"},[])
    ]);

$(stat).hide();

    var uform = Builder.node('form',{style:"width:"+(this.options.width)+"px;height:100px;",action:"",height:"100",enctype:"multipart/form-data"},[]);

var fsup = Builder.node('div',{id:"fsUploadProgress",style:"height:100px;"});
$(fsup).hide();

    $(uform).appendChild(Builder.node('div',{id:"divStatus",style:"font-style:italic;"},[]));
    $(uform).appendChild(fsup);

    var upl = Builder.node('div',{id:"uploadbtns",style:this.options.style},[  Builder.node('div',{style:"float:left;margin-right:20px;width:130px;background:url(http://core.myfil.es/get_file/social/ubtnbg.png);"},[
Builder.node('span',{style:"",id:"upselect"},[])
]),

Builder.node('div',{id:"upcancel",style:"display:none;float:left;margin-right_20px;background:url(http://core.myfil.es/get_file/social/ubtnbg.png);width:130px;height:30px;"},[
Builder.node('input',{value:"cancel",disabled:"disabled",className:"bigbutton",type:"button",style:"margin:0 auto;margin-top:0px;font-weight:normal;height:20px;width:130px;font-size:15px;height:30px;background:transparent:border:0px solid transparent;"})
]),

Builder.node('div',{style:"clear:both;"})
    ]);

    $(uform).appendChild(this.makePermissionDialog());
    $(uform).appendChild(upl);    
    

var alb = Builder.node('div',{id:"selectalbums",style:"background:#EDEDED;width:"+(this.options.width)+"px;height:200px;border:1px solid silver;position:absolute;z-index:9999;padding:5px;"},[
Builder.node('div',{style:"position:relative;height:200px;overflow:auto;"},[
Builder.node('div',{id:"albums",style:""},[])
])
]);

$(alb).hide();

    this.uploader = Builder.node('div',{style:"position:absolute;z-index:888;height:100px;"},[]);
    $(this.uploader).appendChild(uform);
    $(this.uploader).appendChild(this.makeAlbumSelector());
    $(this.uploader).appendChild(alb);
        $(this.uploader).appendChild(Builder.node('div',{style:"position:relative;top:-80px;z-index:888;width:300px;margin:0 auto;height:50px;"},[
this.notification.htmlNode()
]));

    $(this.uploader).appendChild(Builder.node('div',{style:"clear:both;"}));
    $(this.uploader).appendChild(stat);

    //$(this.uploader).appendChild();

    return this.uploader;   
  },
  makeWidgetContent: function(){    
    this.wrapper = this.makeUploader();

    window.setTimeout(function(){
      this.initUploader();
      if(guestpage != null){
          this.makeCloudBg();
          this.makeCloudTexts();
      }
    }.bind(this),150);

    return this.wrapper;
  }, 
makeCloudBg:function(){
    var c = Builder.node('div',{style:"left:-65px;top:-120px;z-index:-2;background:url(http://core.myfil.es/get_file/social/mycloud.png);position:absolute;width:600px;height:344px;"},[]);
    this.wrapper.appendChild(c);
  },
  makeCloudTexts:function(){
    var t1 = Builder.node('div',{style:"z-index:-2;top:-270px;left:0px;background:url(http://core.myfil.es/get_file/social/t-1.png);position:absolute;width:228px;height:112px;"},[]);
    var t2 = Builder.node('div',{style:"z-index:-2;top:60px;left:-150px;background:url(http://core.myfil.es/get_file/social/t-2.png);position:absolute;width:159px;height:72px;"},[]);
    var t3 = Builder.node('div',{style:"z-index:-2;top:80px;left:20px;background:url(http://core.myfil.es/get_file/social/t-3.png);position:absolute;width:187px;height:235px;"},[]);
    var t4 = Builder.node('div',{style:"z-index:-2;top:80px;left:220px;background:url(http://core.myfil.es/get_file/social/t-4.png);position:absolute;width:221px;height:151px;"},[]);
    var t5 = Builder.node('div',{style:"z-index:-2;top:50px;left:350px;background:url(http://core.myfil.es/get_file/social/t-5.png);position:absolute;width:128px;height:77px;"},[]);

$(t1).hide();
$(t2).hide();
$(t3).hide();
$(t4).hide();
$(t5).hide();

new Effect.Appear($(t1),{delay:0});
new Effect.Appear($(t2),{delay:1*0.6});
new Effect.Appear($(t3),{delay:2*0.6});
new Effect.Appear($(t4),{delay:3*0.6});
new Effect.Appear($(t5),{delay:4*0.6});
 this.wrapper.appendChild(Builder.node('div',{style:"z-index:-1;position:relative;top:-50px;left:80px;"},[t1,t2,t3,t4,t5]));
  },
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(externalUploader.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <443520> footerwidget.js 

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

  },
  makePartners:function(){
    var url = "http://core.myfil.es/get_file/design/";
    var s = "cursor:pointer;float:right;position:relative;z-index:1;top:5px;width:130px;height:70px;";
    var partners = Builder.node('div',{style:"position:relative;overflow:hidden;height:80px;width:100%;clear:both;style:float:left;"},[

Builder.node('a',{style:"width:100px;height:100%;",href:"http://www.nforce.nl"},[
Builder.node('div',{style:s+"background:url("+url+"nforce.png);"},[])
]),

Builder.node('a',{style:"width:100px;height:100%;",href:"http://www.dazzboard.com"},[
Builder.node('div',{style:s+"background:url("+url+"dazzboard.png);"},[])
]),
Builder.node('a',{style:"width:100px;height:100%;",href:"http://www.valve.fi"},[
Builder.node('div',{style:s+"width:100px;background:url("+url+"valve.png);"},[])
]),
Builder.node('a',{style:"width:100px;height:100%;",href:"http://www.xihalife.com"},[
Builder.node('div',{id:"xiha",style:s+"background:url("+url+"xihalife.png);"},[])
]),
Builder.node('div',{style:"margin-top:7px;margin-right:17px;height:62px;width:2px;float:right;background:url("+url+"footer-separator.png);"},[]),

      Builder.node('div',{style:"clear:both;"},[])
    ]);

    return partners;
  },
  makeUpper:function(){
    var ustyle2 = "overflow:hidden;width:50%;float:right;margin-right:30px;";
    var s1 = "Get MySites on your mobile. Save, view and share anything.";
    var s2 = "Save your files easily, directly from your desktop.";

    return Builder.node('div',{style:"overflow:hidden;height:80px;clear:both;"},[
      Builder.node('div',{style:"width:460px;float:left;margin-left:0px;top:5px;position:relative;"},[
        this.makeLeftIcon({icon:"ico-phone.png",head:TN("Mobile"),sub:TN(s1)}),
        this.makeLeftIcon({icon:"ico-laptop.png",head:TN("Desktop"),sub:TN(s2)}),
        Builder.node('div',{style:"clear:both;"},[])
      ]),
      Builder.node('div',{style:ustyle2},[
        this.makePartners()
      ])
    ]);
  },
  makeSingleLink:function(o){
    var as = "font-size:13px;color:white;text-decoration:none;";
    var s = "line-height:28px;margin-right:5px;float:left;";
    href = "http://www.mysites.com/?page="+o.link

    if(o.href){
      href = o.href
    }
    var a = Builder.node('a',{href:href,style:as},[o.caption]);

    var btn = Builder.node('div',{style:s},[a]);
    Event.observe($(btn),'mouseover',function(){
      $(a).setStyle({textDecoration:"underline"});
    });
    Event.observe($(btn),'mouseout',function(){
      $(a).setStyle({textDecoration:"none"});
    });

    return btn;
  },
  makeLinks:function(){
    var btns = [];
    var s = "line-height:28px;margin-right:5px;float:left;";
    $([
//      {caption:TN("About us"),link:"about"},
//      {caption:TN("Press"),link:"press"},
//      {caption:TN("Blog"),link:"blog"},
      {caption:TN("Developer API"),link:"api",href:"http://core.mysites.com/get_file/2009-week-39/mysites-api.html"},
//      {caption:TN("Feedback"),link:"feedback"},
      {caption:TN("Terms of use"),link:"terms",href:"http://core.myarticl.es/get_file/terms"}
    ]).each(function(btn){
      btns.push(this.makeSingleLink(btn));
      btns.push(Builder.node('div',{style:s},[TN("|")]));
    }.bind(this));
    btns.pop();
    btns.push(Builder.node('div',{style:"clear:both;"},[]));
    var links = Builder.node('div',{style:"width:340px;float:right;"},btns);

     return links;
  },
  makeLeftIcon:function(o){
    var istyle = "width:100px;height:64px;float:left;";
    istyle += "background:url(http://core.myfil.es/get_file/design/"+o.icon+");";
    var cstyle = "width:130px;float:left;line-height:14px;font-size:12px;";
    var wstyle = "width:230px;height:64px;float:left;overflow:hidden;font-size:13px;";
    var hstyle = "font-weight:bolder;width:100%;line-height:14px;margin-top:5px;";
    var sstyle = "width:100%;font-size:90%;";
  
    var icon = Builder.node('div',{style:istyle},[]);
    var head = Builder.node('div',{style:hstyle},[o.head]);
    var sub = Builder.node('div',{style:sstyle},[o.sub]);
    var content = Builder.node('div',{style:cstyle},[head,sub]);
  
    var div = Builder.node('div',{style:wstyle},[
      icon,content,Builder.node('div',{style:"clear:both;"})
    ]);
    return div;
  },
  makeTwitter:function(){
    var as = "font-size:13px;color:white;text-decoration:none;";
    var icourl = "http://core.myfil.es/get_file/design/ico-twtr.png";
    var icostyle = "margin-right:15px;width:28px;height:28px;background:url("+icourl+");";
    var a = Builder.node('a',{href:"http://twitter.com/mysites",style:as},[
      TN("Follow us on Twitter")
    ]);
    var ico = Builder.node('div',{style:icostyle},[]);
    var twitter = Builder.node('div',{},[
      Builder.node('div',{style:"width:28px;float:left;"},[ico]),
      Builder.node('div',{style:"width:130px;float:left;line-height:28px;"},[
        a
      ]),
      Builder.node('div',{style:"clear:both;"},[])
    ]);

    Event.observe($(twitter),'mouseover',function(){
      $(a).setStyle({textDecoration:"underline"});
    });
    Event.observe($(twitter),'mouseout',function(){
      $(a).setStyle({textDecoration:"none"});
    });

    return twitter;
  },
  makeLower:function(){
    var s = "width:40%;margin-top:10px;";
    var cstyle = "font-weight:bolder;height:25px;line-height:25px;font-size:13px;";

    return Builder.node('div',{style:"height:45px;clear:both;"},[
      Builder.node('div',{style:s+"float:left;margin-left:30px;"},[
        Builder.node('div',{style:cstyle},[TN("© 2010 COPYRIGHT MYSITES")])
      ]),
      Builder.node('div',{style:s+"width:55%;float:right;margin-right:10px;text-align:right;"},[
        Builder.node('div',{style:"margin-top:0px;width:160px;float:left;overflow:hidden;"},[
this.makeTwitter()
]),
        Builder.node('div',{style:"margin-top:0px;width:350px;float:right;text-align:right;overflow:hidden;"},[
this.makeLinks()
])
      ])
    ]);
  },
  makeWidgetContent: function(){
    var url1 = "http://core.myfil.es/get_file/design/foot.png";
    var s = {id:"myfooter",style:"z-index:0;width:100%;height:125px;background:url("+url1+") repeat-x;"};
    return Builder.node('div',s,[
      this.makeUpper(),
      this.makeLower(),
    ]);
  },
  rerender: function(){
    this.redrawCompletely()
  }
}
Object.extend(FooterWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <851> formsettingsoverride.js 

// the old definition in presentation.js is commented out now!
function makeInput(item) {
  var name    = item[0]
  var id      = item[1]
  var value   = item[2]
  var options = item[3] || {}
  var input;
  if (options.textarea) {
    input = "<textarea cols='" + options.cols + "' rows='" +
      options.rows + "name='" + (options.generic ? "" : "form_") + id +
      "'>" + (value ? value : "") + "</textarea><br/>"
  }
  else if (options.checkbox) {
    if (!value) value = []
    input = options.items.map(function(i) {
      var isChecked = value.include(i.id)
      var checkbox = "<input type='checkbox' name='" + id + "[]' " +
                     "value='" + i.id + "' " +
                     (isChecked ? "checked='checked'" : "") + "'/>"
      var descr    = "<b>" + i.display + "</b>"
      return "<tr><td>" + checkbox + "</td><td>" + descr + "</td></tr>"
    }).join("")
    input = "<table><tbody>" + input + "</tbody></table>"
  }
  else {
    var style = "font-family:Trebuchet MS;margin-top:3px;"             +
                "margin-bottom:3px;color:white;font-weight:bold;"      +
                "font-size:15px;background-color:#2FB6DE;padding:0px;" +
                "center;width:100%;border:0px solid silver;"           +
                "height:auto;line-height:25px;"
    input = "<input style='" + style + "' " +
      (options.type ? "type='" + options.type + "' " : "")  +
      (value ? "value='" + value + "' " : "") +
      (options.size ? "size='" + options.size + "' " : "") +
      "name='" + (options.generic ? "" : "form_") +  id + "'/>"
  }
  return  {
    description: (name == "" ? "" : "<b>" + name + "</b>:"), 
    input: input
  }
}

//overriding this for styling purposes 
function generalFormSettings(m, count, options) {
  p = m["permission"]
  // Just override here so that the default for edit and upload is everyone,
  // but that it doesn't make stuff public that wasn't supposed to be (which
  // might happen if we changed this in the DisplayModel).
  if (m.id == -1) {
    p = "guest"
  }
  var whoCanView = Builder.node('span', [
    translateText({path: ".creation", id: "permission", args: [
      options.itemName
    ]})
  ]).innerHTML
  var onlyme = Builder.node('span', [
    translateText({path: ".creation .permission", id: "onlyme"})
  ]).innerHTML
  
  var everyone = Builder.node('span', [
    translateText({path: ".creation .permission", id: "everyone"})
  ]).innerHTML
  
  return '<div style="padding:15px;" class="share">' + 
    '<div style="font-size:150%;font-weight:bold;">' + whoCanView + ':</div><br>' + 
    '<table align="center" style="text-align:center;width:100%;font-size:130%;">' +
    '<tbody><tr><td><img onclick="$(\'fponlyme\').click();" ' +
    'src="/core-services/images/onlyme.gif" border="0"/></td>'+
    //'<td><img onclick="$(\'fpallbuddies\').click();" ' +
    //'src="/core-services/images/buddies.gif" border="0"/></td>'+
    '<td>' +
    '<img onclick="$(\'fpeveryone\').click();" ' +
    'src="/core-services/images/everyone.gif" border="0"/></td></tr><tr>' + 
    '<td width="33%"><input id="fponlyme" class="rb" name="form_permission" ' +
    'value="onlyme" ' + (p == 'onlyme' ? 'checked="checked"' : '') + 
    ' type="radio"><b>' + onlyme + '</b></input></td>' + 
    //'<td width="33%">' +
    //'<input id="fpallbuddies" class="rb" name="form_permission" ' +
    //'value="allbuddies" ' + (p == 'allbuddies' ? 'checked="checked"' : '') + 
    //'type="radio"><b>' + allbuddies + '</b></input></td>' + 
    '<td width="33%"><input id="fpeveryone" class="rb" name="form_permission" ' +
    'value="everyone" ' + (p == 'everyone' ? 'checked="checked"' : '') + 
    'type="radio"><b>' + everyone + '</b></input></td>' +
    "</tr></tbody></table>" + 
    "</div>"
}

//overriding this for styling purposes
ManageItemDialog.prototype.makeEditFormGeneral = function(url, formItems, o) {
  options = Object.extend({
    encoding: undefined,
    ajaxRequestHandler: undefined,
    onsubmitReturnValue: undefined,
    hiddenFields: undefined,
    itemName: this.itemName()
  }, o || {})
  currentItemManager = this
  var rest = ""; 
  var addtxt = "";
  hf = Object.extend(Object.extend({
    "form_path": this.model.currentPath(),
    "form_pretty_name": this.m.pretty_name
  }, options.hiddenFields || {}), this.hiddenFields || {}) 
  return ajax_link_to_remote(url, hf, 
    function(rn, success) {
      var m = currentItemManager.m
      var idBefore = m.id
      //eval("var update = " + json_update);
      m = hash_merge(m, success.item_info)
      m.edit = false
      m.increation = false
      currentItemManager.closeWindow()
      currentItemManager.model.update()
    },function() {
      nextViewId()
      return "<iframe style='border: 0pt none; width: 10px;" + 
        "height: 0px;' src='' name='upload-target-" + preparingViewId() + "-"
        + currentItemManager.index + "' id='upload-target-" + preparingViewId() +
        "-" + currentItemManager.index + "'></iframe><div id='incwrapper' " +
        "style='width:630px;margin: 0 auto;background:#EFEFEF;'>" +
        "<div class='increation' style='width:100%;'>" +
        "<table align='center' width='100%' cellpadding='10' cellspacing='10'><tbody>" + 
        formItems.map(function(item) {
          item[0] = Builder.node('span', [
            translateText({
              path: ".creation .fields",
              id: item[1],
              revert: item[0]
            })
          ]).innerHTML
          input = makeInput(item);
          if(item[1] == "tags"){
            input.description += " " + Builder.node('span', [
              translateText({path: ".creation .fields .tags", id: "example"})
            ]).innerHTML
          }
          //check if Service-author defined multi-Upload
          var multi = false;
          if(ManageItemDialog.prototype.multiUpload && !window.navigator.userAgent.match(/Linux/)){
            multi = ManageItemDialog.prototype.multiUpload();
          }
          if(item[3] && item[3].type == "file"){
            if(multi){     
              var uploadfield = roundAndReturnHTML({
                className:"roundBtn",
                node:(new iHTMLWidget({html:getUploader(),mode:"inner"})).htmlNode(),
                width:600
              });  
              if(itemModel.itemType().toLowerCase() == "picture"){
                var largeFiles = Builder.node('span', [
                  translateText({path: ".pictures", id: "large-files"})
                ]).innerHTML
                addtxt = '<tr><td><span style="font-size:140%;font-weight:bolder;' +
                  'margin-left:40px;">' + largeFiles + '</span></td></tr>';
              }else{
                addtxt = '';
              }
              return "<tr><td colspan='2'><div style='margin-left:5px;'>" +
                uploadfield+"</div></td>"+addtxt+"</tr>";
            } 
          }
          var inputfield = '<div style="padding:2px;">'+input.input+'<div>'
          var field =  "<div style='padding:5px;'><div><table width='100%'>" +
            "<tbody><tr><td width='85%' style='font-size:150%;'>" +
            input.description + "</td></tr></tbody></table></div><div>" + inputfield  + "</div></div>";
          var myhtmlwidget = new iHTMLWidget({html:field ,mode:"inner"});
          if(currentItemManager.m.type == "folder" || currentItemManager.m.edit == true){ 
            rest = "";
            rest += "<tr><td colspan='2'>"; 
            rest += generalFormSettings(
              currentItemManager.m,
              currentItemManager.index,
              options
            );
            rest += '</td></tr>';
            rest += '<tr><td colspan="2"><div id="buttonBox">';
            rest += roundAndReturnHTML({
              className:"roundBtn",
              node:(new iHTMLWidget({
                html: Builder.node('span', [
                  translateButton({
                    path: "",
                    id: "save"
                  })
                ]).innerHTML + "&nbsp;&nbsp;" + Builder.node('span', [
                  translateButton({
                    path: "",
                    id: "cancel",
                    node: Builder.node('input', {
                      type: "submit",
                      name: "cancel",
                      value: "",
                      onclick: 'currentItemManager.cancelEdit(); return false;'
                    })
                  })
                ]).innerHTML + 
                  "<span id='upload-status-" + preparingViewId() + "-" +
                    currentItemManager.index + "' class='upload-status'/>",
                mode:"inner"
              })).htmlNode(),
              width:600
            });
            rest += '</div></td></tr></tbody></table></div></div>';
          }
          if(currentItemManager.m.increation == true && currentItemManager.m.type != "folder" && multi){
            rest = "";
          }
          return '<tr height="10"><td style="padding:4px;" colspan="2">' +
            roundAndReturnHTML({
              className:"roundBtn",
              node:myhtmlwidget.htmlNode(),
              width:600
            })+'</td></tr>'
        }).join("") + rest
      }, this.index, options.encoding, options.ajaxRequestHandler, 
        options.onsubmitReturnValue)
  }




  //shuffle array..quickhack..should be somewhere
  function shuffle(o){
        for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
        return o;
    };
    //First creates a roundBox around content
    //wraps in a div and returns innerHTML of wrapper
    //needed for innerHTML approach of makeEditFormGeneral since roundIt returns dom-node
    function roundAndReturnHTML(o){
        rb = Builder.node('div',[roundIt(o)]);
        return rb.innerHTML;  
    }

// generate uploadWidget, wrap in div and return innerHTML
function getUploader(){
    var muw = (new multiUploadWidget()).htmlNode();
    var upl = Builder.node('div',[muw]);
    return upl.innerHTML; 
}


/*
function onUploadEvent(e){
    var dat = e.split("onUploadEvent:")[1];
    var u = eval("("+dat+")");
    //$("uploaderWidget").appendChild(TN(u.type));
}
*/

//helperfunction to show context-help
function whatsThat(i){
    if(i == "tags"){
        alert("Tag your items to make it easier for you and your buddies to find and categorize your items"); 
    }else{
        alert("Enter item-specific information");  
    }
}


;

// /8::/202::/core:js -> <453598> frontinfowidget.js 

FrontInfoWidget = Class.create();
FrontInfoWidget.prototype = {
  defaultOptions: function(){
    return {
      width:147
    }
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  }, 
  makeInfoBox:function(o){
    var hstyle = ""
    hstyle += "cursor:pointer;width:117px;height:41px;margin-left:-8px;";
    hstyle += "background:url("+this.imageurl(o.ico)+");";
    var bstyle = "margin-top:30px;float:left;width:240px;height:110px;margin-right:40px;overflow:hidden;";

    var head = Builder.node('div',{style:hstyle},[]);
    Event.observe($(head),'click',function(){
      window.open(o.link);
    });
    var body = Builder.node('div',{style:""},[o.text]);
    var box = Builder.node('div',{style:bstyle},[head,body]);
    return box;
  }, 
  makeWidgetContent: function(){
    var wstyle = "font-style: italic;margin-top:-10px;letter-spacing:-1px;";
    wstyle += "color:#898989;margin-left:10px;";

    var txt1 = "A great repository for anything you want to keep available online";
    var txt2 = "MySites is quite a comprehensive cloud hosting service";
    var txt3 = "Unlimited storage that MySites offers for free of charge with no restrictions(!) sounds very appealing";

    var txt4 = "The one place you need for your storage needs";
    var txt5 = "Want Unlimited Cloud Storage?";

    var div = Builder.node('div',{style:wstyle},[
this.makeInfoBox({link:"http://startupmeme.com/mindtrek-2009-mysites-one-year-later-and-i-bet-its-going-to-grow-even-further/",text:txt4,ico:"ico-meme.png"}),
this.makeInfoBox({link:"http://www.readwriteweb.com/archives/want_unlimited_cloud_storage_dazzboard_and_mysites_team_up.php",text:txt5,ico:"ico-rww.png"}),     this.makeInfoBox({link:"http://mashable.com/2008/09/25/mysites/",text:txt1,ico:"ico-mash.png"}),
this.makeInfoBox({link:"http://eu.techcrunch.com/2009/09/03/dazzboard-partners-with-mysites-to-offer-unlimited-cloud-storage/",text:txt2,ico:"ico-tc.png"}),
      Builder.node('div',{style:"clear:both;"})
    ]);

    return [div];
  }
}  
Object.extend(FrontInfoWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <443537> frontpagewidget-2.js 

var dd = null;
FrontPageWidget = Class.create();
FrontPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      checkforupdates:true,
      m:null,
      captions:[
        "MySites saves all your HD photos, videos and files. <b>For free. Forever</b>",
        "Share, download, link, bookmark, email and sms.",
        "Music and video players for your blog and your friends",
        "All your content, on your mobile. <b>With you. Anywhere</b>",
        "Your hard drive. <b>On the web (coming soon)</b>"
      ]
    },arguments[0]);
  },
  setup:function(){
    this.m = this.options.m;    
  }, 
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  setDotActive:function(i){
    this["d"+i].setStyle({background:"url("+this.imageurl("dot-filled.png")+")"});
  },
  setDotInactive:function(i){
    this["d"+i].setStyle({background:"url("+this.imageurl("dot-default.png")+")"});
  },
  makeDots:function(){
    var ds = "cursor:pointer;width:10px;height:10px;margin-right:10px;float:left;";
    ds += "background:url("+this.imageurl("dot-default.png")+");";

    this.d1 = Builder.node('div',{style:ds},[]);
    Event.observe($(this.d1),'click',function(e){
      this.carousel.moveTo(false,this.carousel.slides[0])
    }.bind(this));

    this.d2 = Builder.node('div',{style:ds},[]);  
    Event.observe($(this.d2),'click',function(e){
      this.carousel.moveTo(false,this.carousel.slides[1])
    }.bind(this));  

    this.d3 = Builder.node('div',{style:ds},[]);
    Event.observe($(this.d3),'click',function(e){
      this.carousel.moveTo(false,this.carousel.slides[2])
    }.bind(this)); 
 
    this.d4 = Builder.node('div',{style:ds},[]);
    Event.observe($(this.d4),'click',function(e){
      this.carousel.moveTo(false,this.carousel.slides[3])
    }.bind(this));  

    this.d5 = Builder.node('div',{style:ds},[]);
    Event.observe($(this.d5),'click',function(e){
      this.carousel.moveTo(false,this.carousel.slides[4])
    }.bind(this));  

    var dots = Builder.node('div',{style:"position:relative;margin:0 auto;height:10px;width:100px;z-index:99;top:-130px;"},[
        this.d1,this.d2,this.d3,this.d4,this.d5,
        Builder.node('div',{style:"clear:both;"})
      ]);

    this.setDotActive(1);

    return dots;
  },
  makeFloor:function(){
    var fs = "position:relative;height:110px;width:700px;background:green;float:right;";
    var fs2 = "background:url("+this.imageurl("floor-fill.png")+") repeat-x;";
    fs2 += "width:"+(document.viewport.getWidth()-717)+"px";
    var fs3 = "background:url("+this.imageurl("floor-l.png")+") no-repeat;";

var fsm = "clear:both;z-index:50;position:relative;width:100%;height:110px;overflow:hidden;top:-111px;";

    this.leftfloor = Builder.node('div',{style:fs+fs2},[]);

    var floor = Builder.node('div',{style:fsm},[
      Builder.node('div',{style:"width:3000px;height:110px;float:right;"},[
        this.leftfloor,
        Builder.node('div',{style:fs+fs3},[]),    
        Builder.node('div',{style:"clear:both;"},[])
      ]),Builder.node('div',{style:"clear:both;"},[])
    ]);

    return floor;
  },
  makeCarousel:function(){
    var cs = "width:700px;height:340px;";
    this.carousel = new CarouselWidget({auto:true,id:"c1",slidewidth:700,slides:[		{text:"",node:Builder.node('div',{style:cs+"background:url("+this.imageurl("slide-1.png")+") no-repeat -10px 0px;;"},[])},		{text:"",node:Builder.node('div',{style:cs+"background:url("+this.imageurl("slide-2.png")+") no-repeat -10px 0px;"},[])},		{text:"",node:Builder.node('div',{style:cs+"background:url("+this.imageurl("slide-3.png")+") no-repeat -10px 0px;"},[])},		{text:"",node:Builder.node('div',{style:cs+"background:url("+this.imageurl("slide-4.png")+") no-repeat -10px 0px;"},[])},		{text:"",node:Builder.node('div',{style:cs+"background:url("+this.imageurl("slide-5.png")+") no-repeat -10px 0px;"},[])}
	]});

    var obs = {SlideScrollEnd:function(e){
      dd = e;

      [0,1,2,3,4].each(function(d){
        this.setDotInactive(d+1);
      }.bind(this));
      this.setHeading(this.options.captions[$(e).current._index]);
      this.setDotActive($(e).current._index+1);
    }.bind(this)}
    this.carousel.addObserver(obs);

 
    var cs = "z-index:55;position:relative;width:700px;height:350px;margin:0 auto;";

    var s = "position:relative;float:left;width:20px;height:100%;";

    this.l = Builder.node('div',{style:s+"z-index:999;left:20px;background:url("+this.imageurl("fade-left.png")+") 0px -44px;"},[]);
    this.r = Builder.node('div',{style:s+"z-index:999;left:20px;background:url("+this.imageurl("fade-right.png")+") 0px -44px;"},[]);
    var ca = Builder.node('div',{style:s+"z-index:88;width:660px;background:transparent;"},[
      this.carousel.htmlNode()
    ]);
    var c = Builder.node('div',{style:"clear:both;"},[]);

    this.carouseldiv = Builder.node('div',{style:cs},[
      this.l,ca,this.r,c
    ]);

    var hs = "left:20px;position:relative;z-index:9999;top:0px;";
    hs += "width:100%;height:350px;background:red;";
    this.hider = Builder.node('div',{style:hs},[]);
    //$(this.carouseldiv).appendChild(this.hider);

    var dots = this.makeDots();

    this.floor = this.makeFloor();
    
    var hs = "text-shadow: 2px 1px 5px #999999;margin-left:30px;width:773px;height:36px;";
    hs += "float:left;color:black;font-size:27px;letter-spacing:-1px;";

    var tstyle = "width:107px;height:26px;background:url("+this.imageurl("tour-default.png")+");"
    var innerbtn = Builder.node('div',{style:tstyle},[])
    Event.observe($(innerbtn),'mouseover',function(e){
      $(innerbtn).setStyle({background:"url("+this.imageurl("tour-over.png")+")"})
    }.bind(this))
    Event.observe($(innerbtn),'mouseout',function(e){
      $(innerbtn).setStyle({background:"url("+this.imageurl("tour-default.png")+")"})
    }.bind(this))
    var tourbtn = Builder.node('a',{href:"http://www.mysites.com/?page=tour"},[
      innerbtn
    ]);

    this.heading = Builder.node('div',{style:hs},[]);

    return Builder.node('div',{style:"position:relative;height:450px;width:100%;overflow:hidden;"},[
BR(),
Builder.node('div',{},[
this.heading,
/*Builder.node('div',{style:"float:right;right:20px;position:relative;"},[tourbtn]),*/
Builder.node('div',{style:"clear:both;"})
]),
      this.carouseldiv,
      this.floor,
      dots,
      Builder.node('div',{style:"clear:both;"})
    ]);
  },
  setHeading:function(html){
    $(this.heading).innerHTML = html;
  },
  makeBackground:function(){
    var istyle = "height:450px;width:100%;position:relative;top:-43px;";
    var wstyle = "position:relative;top:0px;height:450px;width:95%;float:right;";
    wstyle += "background:url("+this.imageurl("front-shade.png")+") repeat-x;";

    var wstylel = "float:right;position:relative;top:0px;left:0px;height:450px;width:17px;background:url("+this.imageurl("front-shade-left.png")+");"

    var bg = Builder.node('div',{style:istyle},[
      Builder.node('div',{style:"width:100%;left:0px;position:relative;"},[        
        Builder.node('div',{id:"regandinfo",style:wstyle},[
          this.makeRegAndInfo()
        ]),
        Builder.node('div',{style:wstylel},[])
      ]),
      Builder.node('div',{style:"clear:both;"})
    ]);
    return Builder.node('div',{style:"width:100%;float:right;"},[bg]);
  },
  makeRegAndInfo:function(){
    var rstyle = "float:right;width:60%;position:relative;z-index:9999;";
    var reg = Builder.node('div',{style:"position:relative;top:0px;"},[
      Builder.node('div',{style:rstyle+"right:60px;width:340px;"},[
        new FrontRegisterWidget().htmlNode()
      ]),
      Builder.node('div',{style:rstyle+"left:20px;float:left;"},[
        new FrontInfoWidget().htmlNode()
      ]),
      Builder.node('div',{style:"clear:both;"})
    ]);
    return reg;
  },
  redrawFloorAndCarousel:function(){
    $("regandinfo").setStyle({width:(document.viewport.getWidth()-39)+"px"})
    if(document.viewport.getWidth() <= 1024){
      $(this.r).hide();
      $(this.l).hide();
    }else{
      $(this.r).show();
      $(this.l).show();
    }
    $(this.leftfloor).setStyle({width:(document.viewport.getWidth()-717)+"px"});    
  },
  makeWidgetContent: function(){  
    var left = [

    ];   

    var right = [
      this.makeCarousel(),
     // Builder.node('div',{style:"clear:both;"}),
      this.makeBackground()      
      //(new ItemListWidget().htmlNode())
    ];   
 
    layoutwidget = new LayoutWidget({left:left,right:right});

    Event.observe(window,"resize",function(e){
      this.redrawFloorAndCarousel();
    }.bind(this));
    window.setTimeout(function(e){
      this.redrawFloorAndCarousel();
    }.bind(this),100);

    this.setHeading(this.options.captions[0]);

    return layoutwidget.htmlNode();
  }, 
  rerender: function(){
    //this.redrawCompletely()
  }
}  
Object.extend(FrontPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <453202> frontregisterwidget.js 

FrontRegisterWidget = Class.create();
FrontRegisterWidget.prototype = {
  defaultOptions: function(){
    return {
      width:147
    }
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },  
  makeAlert:function(c){
    var corr = 30 * c;
    var as = "width:113px;height:30px;";
    as += "background:url("+this.imageurl("alerts.png")+") 0px -"+corr+"px;"
    var alert = Builder.node('div',{id:"alert_"+c,style:as},[]);
    return alert;
  },
  makeButton:function(mode){
    var bstyle = "width:287px;height:41px;"
    var istyle = "background:url("+this.imageurl("button-blue-"+mode+".png")+");";
    var wstyle = "cursor:pointer;margin:0 auto;position:relative;top:10px;";
    var cstyle = "background:url("+this.imageurl("confirm-txt.png")+");";
    cstyle += "width:80px;height:14px;position:relative;margin:0 auto;top:15px;";

    var btn = Builder.node('div',{style:bstyle+istyle},[
      Builder.node('div',{style:cstyle},[])
    ]);
    return Builder.node('div',{style:bstyle +wstyle},[
      btn
    ]);
  },
  makeTop:function(){
    var tstyle = "background:url("+this.imageurl("reg-top.png")+");";
    tstyle += "position:relative;width:335px;height:118px;";
    var istyle = "top:82px;left:29px;position:relative;width:180px;height:24px;";
    var ustyle = "font-size:12px;background:transparent;border:0px;height:100%;width:100%;";

    var astyle = "position:relative;width113px;height:30px;left:198px;top:55px;";

    this.username = Builder.node('input',{type:"text",style:ustyle,value:"Username"});
    var usernamediv = Builder.node('div',{style:istyle},[
      this.username
    ]);
    this.namealert = Builder.node('div',{style:astyle},[this.makeAlert(0)]);
    $(this.namealert).hide();

    var top = Builder.node('div',{style:tstyle},[
      usernamediv,this.namealert
    ]);

    Event.observe($(this.username),'keyup',function(e){
      if($F(this.username) != ""){
        this.validateUsername();
      }
    }.bind(this));
    Event.observe($(this.username),'focus',function(e){
      $(this.namealert).show();
      if($F(this.username) == "Username"){
        $(this.username).value = "";
      }
      if(!$(this.mid).hasClassName("open")){
        Effect.SlideDown($(this.mid),{duration:0.3,afterFinish:function(){
          $(this.mid).addClassName("open");
        }.bind(this)});
      }
    }.bind(this));
    Event.observe($(this.username),'blur',function(e){
      if($F(this.username) == ""){
        $(this.username).value = "Username";
      }
    }.bind(this));

    return top;
  },
  makeCenter:function(){
    var tstyle = "background:url("+this.imageurl("reg-mid.png")+");";
    tstyle += "position:relative;width:335px;height:163px;";
    var istyle = "top:35px;left:29px;position:relative;width:180px;height:24px;";
    var ustyle = "font-size:12px;background:transparent;border:0px;height:100%;width:100%;";
    var pstyle = "top:35px;left:29px;position:relative;width:180px;height:24px;";
    var tistyle = "top:20px;left:21px;position:relative;width:20px;height:20px;";
    var tickstyle = "background:url("+this.imageurl("reg-tick.png")+");width:20px;height:20px;";

    var tosstyle = "top:0px;left:112px;position:relative;width:80px;height:20px;background:transparent;cursor:pointer;";
    var tos = Builder.node('div',{style:tosstyle});;

    this.pass = Builder.node('input',{type:"password",style:ustyle,value:"Password"});
    var passdiv = Builder.node('div',{style:pstyle},[
      this.pass
    ]);
    this.email = Builder.node('input',{type:"text",style:ustyle,value:"Email"});
    var emaildiv = Builder.node('div',{style:istyle},[
      this.email
    ]);
    this.tick = Builder.node('div',{style:tickstyle});
    var tickdiv = Builder.node('div',{style:tistyle},[
      this.tick
    ]);
    $(this.tick).hide();

    var astyle = "position:relative;width:113px;height:30px;left:198px;top:7px;";
    this.passalert = Builder.node('div',{style:astyle},[this.makeAlert(2)]);
    $(this.passalert).style.visibility = "hidden";
    this.emailalert = Builder.node('div',{style:astyle+"top:9px;"},[this.makeAlert(1)]);
    $(this.emailalert).style.visibility = "hidden"

    Event.observe($(tickdiv),'click',function(e){
      this.ischecked = false;
      $(this.tick).toggle();
      this.checkInputs(e);
    }.bind(this));
    Event.observe($(tos),'click',function(e){
      document.location = "http://core.myarticl.es/get_file/terms"
    }.bind(this));

    Event.observe($(this.pass),'keyup',function(e){
      if($F(this.pass) != ""){
        this.validatePassword();
      }
    }.bind(this));
    Event.observe($(this.pass),'focus',function(e){
      if($F(this.pass) == "Password"){
        $(this.pass).value = "";
      }
    }.bind(this));
    Event.observe($(this.pass),'blur',function(e){
      if($F(this.pass) == ""){
        $(this.pass).value = "Password";
      }
    }.bind(this));

    Event.observe($(this.email),'keyup',function(e){
      if($F(this.email) != ""){
        this.validateEmail();
      }
    }.bind(this));
    Event.observe($(this.email),'focus',function(e){
      if($F(this.email) == "Email"){
        $(this.email).value = "";
      }
    }.bind(this));
    Event.observe($(this.email),'blur',function(e){
      if($F(this.email) == ""){
        $(this.email).value = "Email";
      }
    }.bind(this));

    this.mid = Builder.node('div',{style:"position:relative;width:335px;height:163px;"},[
      Builder.node('div',{style:tstyle},[
        passdiv,this.passalert,
        emaildiv,this.emailalert,
        tickdiv,tos
      ])
    ]);

    $(this.mid).hide();

    return this.mid;
  },
  makeBottom:function(){
    var tstyle = "background:url("+this.imageurl("reg-btm.png")+");";
    tstyle += "position:relative;width:335px;height:89px;";
    var istyle = "top:82px;left:29px;position:relative;width:180px;height:24px;";
    var ustyle = "font-size:12px;background:transparent;border:0px;height:100%;width:100%;";
    this.button = Builder.node('div',{style:"padding-top:5px;"},[this.makeButton("inactive")]);
    var btm = Builder.node('div',{style:tstyle},[
      this.button
    ]);
    return btm;
  },
  makeFacebook:function(){
    var tstyle = "background:url("+this.imageurl("reg-fb.png")+");";
    tstyle += "cursor:pointer;position:relative;width:194px;height:34px;";  
    var fb = Builder.node('div',{style:tstyle},[]);
    Event.observe($(fb),'click',function(e){
      document.location = "http://www.mysites.com/facebook";
    });
    return fb;
  },
  validatePassword:function(){
    if ($(this.pass).value.length < 6) {
      $(this.passalert).style.visibility = "";
      this.passok = false;
    } else {
      this.passok = true;
     // $(this.passalert).style.visibility = "hidden";
$(this.passalert).down().setStyle({backgroundPosition:"0px -330px"});
    }
  },
  validateEmail:function(){
    if ($(this.email).value.length >= 5 && $(this.email).value.match(/.+@.+\..+/)) {
//      $(this.emailalert).style.visibility = "hidden";
$(this.emailalert).down().setStyle({backgroundPosition:"0px -330px"});
      this.emailok = true;
    } else {
       $(this.emailalert).style.visibility = "";
       this.emailok = false;    
    }
  },
  validateUsername:function(){
    if($(this.username).value.length >= 3){
      var sidm = new SingleItemDisplayModel({
        item_path: "/",
        pretty_name: "",
        user: $(this.username).value,
        onErroneousSubmit: function(inst, error) {
          if (error.error_type == "UnknownUser") {
//            $(this.namealert).hide();
            this.userok = true;

$(this.namealert).down().setStyle({backgroundPosition:"0px -330px"});

          } else if (error.error_type == "Master::RequestFailed") {
            //$(this.namealert).hide();
            this.userok = true;
$(this.namealert).down().setStyle({backgroundPosition:"0px -330px"});

          } else {
$(this.namealert).down().setStyle({backgroundPosition:"0px 0px"});
            //$(this.namealert).show();
            this.userok = false;
          }
        }.bind(this)
      });
      sidm.addObserver({afterPathChanged: function() {
        //$(this.namealert).show();
$(this.namealert).down().setStyle({backgroundPosition:"0px 0px"});
        this.userok = false;
      }.bind(this)})
    }else{
      $(this.namealert).show();
      $(this.namealert).down().setStyle({backgroundPosition:"0px -210px"});
      this.userok = false;
    }
  },
  register: function(event, reg, token) {
    Event.stop(event);
    from_site = "mysites";
    var regstring = "";
    
    regstring += "username="+reg.username;
    regstring += "&password="+reg.password;
    regstring += "&password_confirmation="+reg.password;
    regstring += "&email="+reg.email;
    regstring += "&full_name="+reg.email;

    new AjaxFormBuilder({
      user: itemModel.user(),
      service: itemModel.service(),
      action: "create_account",
      onSuccessfulSubmit: function(afb, success) {
        var loginForm = Builder.node('form', {
          style: 'display:none;',
          method: "post", 
          action: serviceLink({
            user: "www",
            service: "main",
            controllerName: "account",
            action: "login"
          })
        }, $H({
            desired_url: serviceLink({
              user: "everyone",
              service: "main"
            }),
            desired_service: "main@core",
            username: reg.username,
            password: reg.password
          }).map(function(pair) {
            return Builder.node('input', {
              type: "hidden",
              name: pair.key,
              value: pair.value
            })
          })
        )
        this.content.appendChild(loginForm)
        loginForm.submit();

      }.bind(this),
      onErroneousSubmit: function(afb, error) {
        var fields = [];
        var error_type = error.error_type.gsub(/Master::/, "")

//fix for IE
alert(error_type);
try{
window.setTimeout(function(){
$(loginForm).remove();
},300);
}catch(e){
alert(e);
}

        switch(error_type) {
          case "UsernameTooShort": case "UsernameAlreadyTaken": case "InvalidUsername":
            fields.push("username")
            break;
          case "InvalidEmailAddress": case "EmailAddressAlreadyUsed":
            fields.push("email")
            break;
          case "PasswordsDontMatch": case "PasswordTooShort":
            fields.push("password")
            fields.push("password_confirmation")
            break;
          case "FullNameTooShort":
            fields.push("full_name")
            break;
          default:
            break;
        }

      }
    }).performAjaxRequest(regstring+ "&from_site=" + from_site)      
    return false

  },
  makeWidgetContent: function(){
    var wstyle = "position:relative;top:-40px;height:410px;width:335px;float:right;"
    var div = Builder.node('div',{style:wstyle},[
      this.makeTop(),
      this.makeCenter(),
      this.makeBottom(),
      this.makeFacebook()
    ]);

   Event.observe($(div),'mousemove',function(e){
    if(!this.ischecked){
      this.checkInputs(e);
    }
   }.bind(this));

    return [div, Builder.node('div',{style:"clear:both;"})];
  },
  checkInputs:function(e){
    var fff = function(e){
              this.register(e,reg,"");
            }.bind(this);

    if(this.userok && $(this.username).value != "Username" && $(this.username).value != "" &&
        this.passok && $(this.pass).value != "Password" && $(this.pass).value != "" &&
         this.emailok && $(this.email).value != "Email" && $(this.email).value != "" &&
           $(this.tick).visible()){
            
            this.ischecked = true;

            $(this.button).down(1).setStyle({
             background:"url("+this.imageurl("button-blue-default.png")+")"
            });

            var reg = {
              username:$(this.username).value,
              password:$(this.pass).value,
              email:$(this.email).value
            };

            Event.observe($(this.button),'click',fff);

            Event.observe($(this.button),'mouseover',function(e){
              $(this.button).down(1).setStyle({
               background:"url("+this.imageurl("button-blue-over.png")+")"
              });
            }.bind(this));
            Event.observe($(this.button),'mouseout',function(e){
              $(this.button).down(1).setStyle({
               background:"url("+this.imageurl("button-blue-default.png")+")"
              });
            }.bind(this));
    }else{
       $(this.button).down(1).setStyle({
          background:"url("+this.imageurl("button-blue-inactive.png")+")"
       }); 

       Event.stopObserving($(this.button),'click',fff);
    }
  }
}  
Object.extend(FrontRegisterWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <443519> headerwidget.js 

HeaderWidget = Class.create();
HeaderWidget.prototype = {
  defaultOptions: function(){
    return {
    }
  },
  makeWidgetContent: function(){
    var url1 = "http://core.myfil.es/get_file/design/head.png";
    var logourl = "http://core.myfil.es/get_file/design/logo.png";
    var s = {
id:"logo",
      href:"http://"+write_username+".mysites.com",
      style:"float:left;cursor:pointer;width:200px;height:114px;background:url("+logourl+");"
    };

    var logo = Builder.node('div',s,[]);
    if(logged_in){
      Event.observe($(logo),'click',function(e){
        document.location = "http://"+read_user_model_data.username+".mysites.com";
      });
    }
    var links = [];

    if(!logged_in){
      links.push(Builder.node('div',{style:"width:455px;"},[new LoginWidget().htmlNode()]));
    }else{
      links.push(Builder.node('div',{style:"width:455px;"},[NBSP()]));
    }

    if(logged_in){
      var mf = new BlackButtonWidget({onClickAction:function(){
        document.location = "http://"+write_username+".mysites.com";
      },caption:TN("My files")});
      var pc = new BlackButtonWidget({onClickAction:function(){
        document.location = "http://www.mysites.com";
      },caption:TN("Public Content"),width:150});
  
      links.push(mf.htmlNode());
      links.push(pc.htmlNode());
  
      if(itemModel.canWrite()){
        mf.selected();
      }else{
        pc.selected();
      }
     // links.push(new BlackButtonWidget({caption:TN("Tools")}).htmlNode());
    }

    var btn = new BlackButtonWidget({caption:TN("Logout")}).htmlNode();
    Event.observe($(btn),'click',function(e){
      $(logoutf).submit();
    });

    var logoutf = Builder.node('form', {style:"background:transparent;width:100px;",
        action: serviceLink({
          user: "www",
          service: "sites",
          controllerName: "account",
          action: "logout"
        }),
        method: "POST"
      }, [btn]);

    if(logged_in){
      links.push(NBSP());
      links.push(NBSP());
      links.push(logoutf);
    }

    var fs = {style:"height:114px;padding-top:25px;"};
    var c = Builder.node('div',{style:"clear:both;"});
    var headd = Builder.node('div',{style:"margin-top:-10px;width:100%;height:114px;background:url("+url1+") repeat-x;"},[
      Builder.node('div',[
        logo,Builder.node('div',fs,[new LinkListWidget({links:links}).htmlNode()]),c
      ])
    ]);

    return Builder.node('div',{style:"width:100%;"},[headd]);   
  }
}  
Object.extend(HeaderWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <905> ide.js 

IDE = {
  defaultOptions: function() {
    return Object.extend({
      model:  itemModel,
      window: null,
      defaultPermission: "everyone"
    }, this.editorOptions());
  },
  makeWidgetContent: function() {
    this.editPane = Builder.node('span', {}, [EMPTY()])
    return table({className: "ide"}, 
        [cell({className: "items-pane", width: "200", valign: "top"}, 
            roundBox({node: this.itemsPane()})), 
        cell({className:  "editor-pane", valign: "top"}, 
        roundBox({node: this.editPane}))])
  },
  autoselectItem: function() {
    // if (this.m) {
    //   return 
    // }
    // if (this.options.model.getModel().length > 0) {
    //   this.activateItem(this.options.model.getModel().first())
    // }
  },
  activateDialog: function(d) {
    replaceChild(this.editPane, d)
  },
  activateItem: function(m) {
    if (this.currentEditDialog) {
      this.m.content = this.currentEditDialog.editor().content()
    }
    this.m = m
    this.currentEditDialog = this.getEditDialog()
    this.activateDialog(this.currentEditDialog.dialog)
    this.currentEditDialog.editor().setContent(this.m.content)
    this.currentItemManageDialog().refreshCurrentItemManager()
  },
  isCss: function() { return /\.css$/.test(this.m.name.toLowerCase()) },
  isJs: function() { return /\.js$/.test(this.m.name.toLowerCase()) },
  isSettings: function() {return /^settings$/.test(this.m.name.toLowerCase())},
  currentItemManageDialog: function() {
    if (this.isCss() && this.cssManageDialog) {
      return this.cssManageDialog
    }
    if (this.isJs() && this.jsManageDialog) {
      return this.jsManageDialog
    }
    return this.binaryManageDialog
  },
  setup: function() {
    this.m = null
    this.autoselectItem()
    this.options.model.addObserver(this)
    var instance = this;
    $A(["js", "css", "binary"]).each(function(pt) {
      if (instance.options[pt+"Pane"]) {
        instance[pt+"Dialog"]();
      }
    })
  },
  hideEditor: function() { hideEditableIframe() },
  getEditDialog: function() {
    var edit = null
    var mode = (this.isJs() ? "JS" : "CSS")
    var dialog =  this.makeInlineEditDialog({
      items: [
        makeInlineEditString('Title', 'name'),
        makeInlineEditString('Tags', 'tags'),
        makeInlineEditSelection('Permission', 'permission',
          [{"onlyme": "Private"}, 
          //{"allbuddies": "All my Buddies"}, 
	  {"everyone": "Public"}]),
        //edit = javaScript["makeInlineEdit" + mode + 
        //    "Code"]('Content', 'content', true)
        edit = makeInlineEditTextArea('Content', 'content')
      ]
    })
    return {
      dialog: dialog,
      editor: edit.editor,
      mode: mode
    }
  },
  lv: function(re, invert) {

    var instance = this
    var lvw =  new ListViewWidget({
      showHeader: true,
      model: new ModelFilter(this.options.model, {
        filter: function(m) {
          return m.select(function(m) { 
            var r = re.test(m.name.toLowerCase())
            if (invert) { r = !r }
            return r
          })
        }
      }),
      presenter: new IDEItemPresenter(this),
      noCounter: true,
      noItems: function() {
        return [TN("No items.")]
      },
      scope: "items"
    })
    //lvw.resortByColumn("name")
     return lvw
  },
  type: function() { 
    if (this.isJs()) { return "javascript"}
    if (this.isCss()) { return "stylesheet" }
    if (this.isSettings()) { return "settings" }
    return "other"
  },
  makeInlineEditDialog: function() {
    var instance = this
     _m = this.m
    var options = Object.extend({
      action: "edit",
      noCancel: true,
      afterShowEdit: function() {
        processAfterShow({
          maxHeightWindowAccessor: {
            totalHeightElement: function() {
              return instance.options.window().frameDiv
            }
          }
        });
      }, 
      hiddenFields: {
        "type": this.type(),
        "form_path": this.options.model.currentPath(),
        "form_pretty_name": this.m.pretty_name
      },
      onlyEdit: true,
      afterSaveOrCancel: function() {
        //currentItemManager.checkEditCancel();
        //instance.options.model.update()
      },
      afterSuccessfulSubmit: function() {
        //instance.m.edit = false
        //instance.m.increation = false
      },
      model: this.m
    }, arguments[0] || {})
    return new InlineEditDialog(options)
  },
  makeComponentDialog: function(o) {
    var options = Object.extend({
      itemName: null,
      method: null,
      type: null
    }, o || {})
    var d = new ManageItemDialog().withHiddenFields({ "type": options.type })
    d.makeItemCreateForm = function() { return this[options.method]() }
    d.itemName = function() { return options.itemName }
    return d
  },
  cssDialog: function() {
    this.cssManageDialog = this.makeComponentDialog({
      method: "makeItemCreateFormSimple",
      itemName: "CSS Item",
      type: "stylesheet"
    })    
  },
  jsDialog: function() {
    this.jsManageDialog = this.makeComponentDialog({
      method: "makeItemCreateFormSimple",
      itemName: "JavaScript Item",
      type: "javascript"
    })    
  },
  binaryDialog: function() {
    this.binaryManageDialog = this.makeComponentDialog({
      method: "makeItemCreateFormUpload", 
      itemName: "Binary"
    })    
  },
  typePane: function(args) {
    var instance = this;
    var model = this.options.model;
    var r = args.fileRegexp ? args.fileRegexp : (new RegExp("\\"+args.suffix+"$"));
    var item = {type: args.type, permission: this.options.defaultPermission}
    if (args.suffix) {
      item.name = args.suffix;
    }
    return [
      TN(args.header),
      BR(),
      htmlNode(this.lv(r, args.invert)),
      imageActionLink({fullImageName: iconPath(22, "add_item"), 
        title: "add item",
        onclick: function() {
          var dialog = instance[args.type.toLowerCase()+"ManageDialog"];
          if (!dialog) {
            dialog = instance.jsManageDialog;
          }
          dialog.withItem(
            model.addItem(item), model).
            showAddItemForm()
          return false
        }
      }),
      BR()
    ];
  },
  jsPane: function() {
    return this.typePane({header: "JS Files", suffix: ".js", type: "JavaScript"});
  },
  cssPane: function() {
    return this.typePane({header: "CSS Files", suffix: ".css", type: "CSS"});
  },
  binaryPane: function() {
    return this.typePane({header: "Binary Files", type: "binary",
      fileRegexp: /\.css$|\.js$|^[Ss]ettings$|^[Pp]references$/, invert: true});
  },
  explore: function() {
    var instance = this;
    this.options.model.disallowChangeFolder()
    var w = namedWindow("Explorer - " + this.options.m.name, function() {
      return {
        contentWidget: new ExplorerWidget({
          model: instance.options.model
        })
      }})
  },
  itemsPane: function() {
    var instance = this
    panes = []
    $A(["js", "css", "binary"]).each(function(pt) {
      if (instance.options[pt+"Pane"]) {
        panes.push(instance[pt+"Pane"]())
      }
    })
    panes.push([
      this.editorItemsPane(),
      actionLink({
        text: "View in Explorer",
        onclick: function() { instance.explore() }
      }),BR(),
      codeEditorHelp()
    ]);
    return Builder.node('span', {}, panes)
  }
}

Object.extend(IDE, WidgetCommon);

IDEItemPresenter = Class.create();
IDEItemPresenter.prototype = {
  initialize: function(editor) {
    this.editor = editor
    this.options = Object.extend({
    }, arguments[1] || {})
  }, 
  loadVariables: function() {
  },
  draw: function(m, c, element) {
    var instance = this
    element.onclick = function() {
      instance.editor.activateItem(m)
    }
    if (m.full_item_url) {
      var d = (Builder.node('span', {}, [
        TN(m.name),
        TN(" ["),
        Builder.node('a', {href: m.full_item_url}, [TN("url")]),
        TN("]")
      ]))
    }
    else {
      var d = TN(m.name);      
    }
    return {content: asTableData([d])}
  }
}

function showIDE(m, path, editor, editorOpts) {
  var opts = Object.extend({
    model: new DisplayModel({ 
      noPagination: true,
      path: path,
      columnNames: ["name"],
      columnDisplayNames: ["Name"]
    }),
    window: function() { return w },
    m: m
  }, editorOpts || {})
  var w = namedWindow("Editor - " + m.name, function() {
    return {
      releaseHandler: function() {
        hideEditableIframe()
      },
      contentWidget: new javaScript[editor](opts)
    }
  })
}


;

// /8::/202::/core:js -> <868> ihtmlwidget.js 

//old?_delete *mike
 
 
 /**
 * @author Michael
 */


/*
var markup = '<a href="#">i am an innerHTML widget</a>';
var myhtmlwidget = new iHTMLWidget({html:markup,mode:"dom"});
var myhtml = myhtmlwidget.htmlNode();

var markup = '<a href="#">i am an innerHTML widget</a>';
var myhtmlwidget = new iHTMLWidget({html:"",mode:"string"});
var domm1 = myhtmlwidget.getDOMNodes(markup);
 var domm2 = myhtmlwidget.getDOMString(markup);
myhtmlwidget.setContent(markup)

*/

//modes: string, dom(builder),dom(dom)
iHTMLWidget = Class.create();
iHTMLWidget.prototype =
{
    defaultOptions: function()
    {
        return Object.extend({html:"<i>nothing</i>",id:"",mode:"inner"},arguments[0]);
    },
    makeWidgetContent: function(){ 
        return this.initContent(this.options.html);
    },
    initContent :function(content){
        var nuhtml = content;
        var node = Builder.node('div',{id:this.options.id},[]);
        if(this.options.mode == "inner"){
            node.innerHTML = nuhtml;
            return node;
        }else if(this.options.mode == "dom"){
            var nodes = this.getDOMNodes(content);
            node.appendChild(nodes); 
            return node;
        }else{  
            var nodes = this.getBuilderNodes(content);
            node.appendChild(nodes); 
            return node;
        }
    },
    setContent:function(content){  
        this.options.html = content;
        this.rerender();
    },
    getDOMString:function(content){
        html2dom.getDOM(content);
        return html2dom.result; 
    },
    getDOMNodes:function(content){
        var nodes = this.getDOMString(content);
        eval(nodes);
        return mydom_root;
    },
    getBuilderString:function(content){
        html2builder.getDOM(content);
        return html2builder.result; 
    },
    getBuilderNodes:function(content){
        var nodes = this.getBuilderString(content);
        eval(nodes);
        return mydom_root;
    },  
    rerender: function(){
        var nc = this.makeWidgetContent();
        this.replaceChild(this.content, this.widgetContent, nc);
        this.widgetContent = nc;
   } 
}
Object.extend(iHTMLWidget.prototype, WidgetCommon);

var html2builder = {
    result: new String(),
    getDOM: function (html, appendTo){
        if (html.length = 0) {
            this.result = "";
            return this.result;
        }
        var root_name = "mydom" + Math.round((Math.random() * 99999)+10000);
        html = "<" + root_name + ">" +html +  "</" + root_name + ">";
        var doc;

        // code for IE
        if (window.ActiveXObject) {
            doc=new ActiveXObject("Microsoft.XMLDOM");
            doc.async="false";
            doc.loadXML(html);
        // code for Mozilla, Firefox, Opera, etc.
        } else {
            var parser=new DOMParser();
            doc=parser.parseFromString(html,"text/xml");
        }
        var root = doc.documentElement;
        if (root.hasChildNodes()) {
            if (appendTo) {
                if (typeof(appendTo) == "object") {
                    this.result = "var mydom_root = " + appendTo + ";";
                } else if (typeof(appendTo) == "string") {
                    this.result = 'var mydom_root = document.getElementById("' + appendTo + '");';
                }
            } else {
                this.result = "var mydom_root = Builder.node('div',[]);";
            }
            this.result += "\n";
            this.traverse(root, "mydom_root");
        }
    },
    traverse: function (el, variable){
        var children = el.childNodes;
        var max = children.length;
        for (var i = 0; i < max; i++) {
            var nodeval = this.escape(children[i].nodeValue);
            var newvar = variable + '_' + (i + 1);
            switch (children[i].nodeType) {
                case 1: // element
                    newvar += '_' + children[i].nodeName;
                    this.result += newvar + ' = Builder.node(\''+ children[i].nodeName;
                    this.result +=  '\'';
                    this.result += ',{';
                    if (children[i].attributes){
                        for (var j = 0, a; a = children[i].attributes[j]; j++) {
                            this.result += a['nodeName']+':"'+this.escape(a['nodeValue'])+'",'; 
                        }
                    }
                    this.result += 'className:""});\n'; 
                    break;
                case 3: // text
                    newvar += '_text';
                    this.result += newvar + ' = TN(\''+ nodeval +'\');\n';
                    break;
                case 8: //comment
                    newvar += '_comment';
                    this.result += newvar + ' = document.createComment("'+ nodeval +'");\n';
                    break;
            }
            if (children[i].hasChildNodes()){
                this.traverse(children[i], newvar);
            }
            this.result += variable + '.appendChild('+ newvar + ');\n';
        }
    },
    escape: function (str) {
        if (!str) return null;
        str = str.replace(/\\/g,'\\\\');
        str = str.replace(/\"/g,'\\\"');
        str = str.replace(/\n/g,'\\n');
        str = str.replace(/\r/g,'\\r');
        return str;
    }
}

var html2dom = {

    result: new String(),

    getDOM: function (html, appendTo)
    {
        if (html.length = 0) {
            this.result = "";
            return this.result;
        }

        var root_name = "mydom" +
                        Math.round((Math.random() * 99999)+10000);

        html = "<" + root_name + ">" +
               html +
               "</" + root_name + ">";

        var doc;
        // code for IE
        if (window.ActiveXObject) {
            doc=new ActiveXObject("Microsoft.XMLDOM");
            doc.async="false";
            doc.loadXML(html);
        // code for Mozilla, Firefox, Opera, etc.
        } else {
            var parser=new DOMParser();
            doc=parser.parseFromString(html,"text/xml");
        }
        var root = doc.documentElement;

        if (root.hasChildNodes()) {

            if (appendTo) {
                if (typeof(appendTo) == "object") {
                    this.result = "var mydom_root = " + appendTo + ";";
                } else if (typeof(appendTo) == "string") {
                    this.result = 'var mydom_root = document.getElementById("' + appendTo + '");';
                }
            } else {
                this.result = "var mydom_root = document.createElement('div');";
            }
            this.result += "\n";
            this.traverse(root, "mydom_root");
        }
    },

    traverse: function (el, variable)
    {
        var children = el.childNodes;
        var max = children.length;
        for (var i = 0; i < max; i++) {

            var nodeval = this.escape(children[i].nodeValue);

            var newvar = variable + '_' + (i + 1);

            switch (children[i].nodeType) {
                case 1: // element
                    newvar += '_' + children[i].nodeName;
                    this.result += newvar
                                + ' = document.createElement("'
                                + children[i].nodeName
                                +'");\n';
                    if (children[i].attributes) {
                        for (var j = 0, a; a = children[i].attributes[j]; j++) {
                            this.result += newvar
                                        +  '.setAttribute("'
                                        + a['nodeName']
                                        +'", "'
                                        + this.escape(a['nodeValue'])
                                        +'");\n';
                        }
                    }
                    break;
                case 3: // text
                    newvar += '_text';
                    this.result += newvar + ' = document.createTextNode("'+ nodeval +'");\n';
                    break;
                case 8: //comment
                    newvar += '_comment';
                    this.result += newvar + ' = document.createComment("'+ nodeval +'");\n';
                    break;

            }

            if (children[i].hasChildNodes()) {
                this.traverse(children[i], newvar);
            }


            this.result += variable + '.appendChild('+ newvar + ');\n';
        }

    },

    escape: function (str) {
        if (!str) return null;
        str = str.replace(/\\/g,'\\\\');
        str = str.replace(/\"/g,'\\\"');
        str = str.replace(/\n/g,'\\n');
        str = str.replace(/\r/g,'\\r');
        return str;
    }
}

;

// /8::/202::/core:js -> <448554> itemlistwidget.js 

var foldercount = 0;
var folderPermission =  "everyone";
var currentItem = {
};
var itemlist;

ItemListWidget = Class.create();
ItemListWidget.prototype = {
  defaultOptions: function(){
    return {
      mixin:true,
      caption:TN("BUTTON"),
      onClickAction:function(e){},
      width:100,
      items:itemModel.items(),
      model:itemModel,
      folders:[]
    }
  },
  getType:function(m){
    var type = "file";
    var mime = "";
    try{
      var mime = mimeTypeCategory(m);
      switch(mime){
        case "Audio":
          type = "tune";
          break;
        case "Video":
          type = "movie";
          break;
        case "Image":
          type = "picture";
          break;
        case "File":
          type = "file";
          break;
        default:
      }
    }catch(e){
      return (m.type !== undefined ? m.type : "file");
    }
    return type;
  },
  loadedItems:function(d){
    window.setTimeout(function(){
      this.options.model2 = d.loader;
      this.theitems = this.options.model2.items();
      this.items = this.theitems;

      if(this.items.length > 0){
        var itms = []
        $(this.items).each(function(itm){
          if(itm.type == "folder" && itm.name != "" && itm.name != "trash"){
            itms.push(itm);
          }
        });
        this.options.folders = itms;
        this.makeFolders(this.options.folders)
       this.olditems = this.options.items;
       this.folders = this.options.folders
       //this.options.items = this.options.items.concat(itms);
       //this.sortByDate();
      }
    }.bind(this),200);
  },
  sortit:function(sf){
    if(sf != null){
      this.options.items.sort(sf)
    }else{
      this.options.items.sort()
    }
    //this.redrawCompletely();
  },
  sortByName:function(){
    var sf2 = function(a,b){
      var x = a.name.toLowerCase();
      var y = b.name.toLowerCase(); 
      return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    }
    this.sortit(sf2);
  },
  sortByDate:function(){
    var sf2 = function(a,b){
      var x = a.added_at || 0;
      var y = b.added_at || 0; 
      return ((x < y) ? 1 : ((x > y) ? -1 : 0));
    }
    this.sortit(sf2);
  },
  sortByType:function(){
    var sf2 = function(a,b){
      var x = a.type.toLowerCase();
      var y = b.type.toLowerCase(); 
      return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    }
    this.sortit(sf2);
  },
  setup:function(){
    itemlist = this;
    if(this.options.mixin == true){
      var obs = {update:function(){
        //this.redrawCompletely()
      }.bind(this)}
      itemModel.addObserver(obs)
  
      this.theitems = [];
      if(sdloader.loader != null){
        this.loadedItems(sdloader);
      }
      sdloader.observeOnce(this);
    }
  },
  over:function(e){

  },
  out:function(e){

  },
  unselectAll:function(){
    $([this.r1,this.r2,this.r3,this.r4]).each(function(d){
      d.selected = false;
     // $(d.cell).innerHTML = "";
      $(d.cell).setStyle({background:"url("+this.imageurl("row-default.png")+")"});
    }.bind(this));
  },
  selected:function(d){
    if(!d.selected){
      this.unselectAll();
      d.selected = true;
      //$(d.cell).appendChild(this.makeArrow(d));
      $(d.cell).setStyle({background:"url("+this.imageurl("row-selected.png")+")"});
   }else if(d.selected){
      this.unselectAll();
      //$(d.cell).appendChild(this.makeArrow(d));
      d.selected = false;
      $(d.cell).setStyle({background:"url("+this.imageurl("row-selected.png")+")"});
    }
    //d.fn();
    //if(d.selected){
    //  alert("reverse");
    //  d.selected = false;
    //}
  },
  makeArrow:function(o){
    var s = "background:url("+this.imageurl("row-arrow.png")+");";
    return Builder.node("div",{style:s+"float:right;width:9px;height:19px;cursor:pointer;"},[]);
  },
  makeButton:function(o){
    var s = "cursor:pointer;float:left;height:16px;width:"+(o.width)+"px;margin-right:2px;";
var btn;

if(o.href != null){
   btn = Builder.node('div',{id:o.id,style:s},[])

var hrefnode = Builder.node('a',{href:o.href,style:"font-size:12px;color:#3ebded;text-decoration:none;"},[]);
$(hrefnode).appendChild(btn);

}else{
   btn = Builder.node('div',{id:o.id,style:s},[]);
}

    $(btn).setStyle({background:"url("+this.imageurl(o.icon)+")"});


    if(o.buttonAction != null){
      var actionFn = o.buttonAction || function(e){alert("blank");}
      Event.observe($(btn),'click',function(e){
        Event.stop(e);
        actionFn(e,o);
      });
    }
    Event.observe($(btn),'mouseover',function(e){
      $(btn).setStyle({backgroundPosition:"0px -16px"});
    });
    Event.observe($(btn),'mouseout',function(e){
      $(btn).setStyle({backgroundPosition:"0px 0px"});
    });

    if(o.href != null){
      return hrefnode
    }else{
      return btn
    }
  },
  makeBlankButton:function(txt){
    var btnstyle= "cursor:pointer;width:66px;height:26px;";
    btnstyle += "background:url("+this.imageurl("blank-btn.png")+");"
    var btn = Builder.node('div',{style:btnstyle},[txt||NBSP()]);
    Event.observe($(btn),'mouseover',function(e){
      this.over($(btn))
    }.bind(this));
    Event.observe($(btn),'mouseout',function(e){
      this.out($(btn))
    }.bind(this));
    return btn;
  },
  makeShare:function(e,o){
    try{
      $(share).remove();
    }catch(e){}

    share = Builder.node('div',{style:"position:absolute;margin-top:0px;z-index:9999;"},[new ShareButtonWidget({item:o}).htmlNode()]);
    $(Event.element(e).up()).appendChild(share);

  },
  makeActions:function(o){

    //new ShareButtonWidget({item:o}).htmlNode()
    var buttons = [];
    var actionb = null;

  var wall = new simpleFBPublishStreamWidget({
        style:"",
        name:o.name,
        caption:"",
        captionnode:bb,
        items:[o]
    })


    var bb = this.makeButton({id:"wall"+o.id,icon:"btn-wall.png",width:49,buttonAction:function(e){
  wall.streamPublish()
}});
  
    buttons.push(bb);     

    $([
      {id:"email"+o.id,icon:"btn-email.png",width:62},
      {id:"sms"+o.id,icon:"btn-sms.png",width:54},
      {id:"share"+o.id,icon:"btn-share.png",width:33,buttonAction:function(e){
        this.makeShare(e,o);
      }.bind(this)}
    ]).each(function(btn){
      var b = this.makeButton(btn);
      buttons.push(b);
    }.bind(this));

    var c = Builder.node("div",{style:"clear:both;"});
    buttons.push(c);


    window.setTimeout(function(){
      try{
try{
url = this.options.model.currentPathPermalink(o)
}catch(e){
url = "";
}
        BREEZETAGS.create({
          attach_type:'behavior', 
          dest_id:"email"+o.id,
          default_view:'email', 
          url:url, 
          title:o.name,
          link_text:'', 
          tooltip:"Open share widget on email tab"
        })

        BREEZETAGS.create({
          attach_type:'behavior', 
          dest_id:"sms"+o.id,
          default_view:'phone', 
          url:url, 
          title:o.name,
          link_text:'', 
          tooltip:"Open share widget on phone tab"
        })
      }catch(e){
        //alert(e)
      }
    }.bind(this),2000);

    actionb = Builder.node("div",{style:"z-index:0;height:17px;margin-top:8px;float:right;"},buttons);


    return [actionb];
  },
  makeDownload:function(o){

    var buttons = [];
var vv = ( o.full_item_url != undefined ? o.full_item_url : o.display_item_url )
    $([
      {id:"download"+o.id,href:vv,icon:"btn-download.png",width:79,buttonAction:function(){
        document.location = vv;
      }}
    ]).each(function(btn){
      var b = this.makeButton(btn);
      buttons.push(b);
    }.bind(this));

    buttons.push(Builder.node("div",{style:"float:right;width:50px;"},[]));

    var c = Builder.node("div",{style:"clear:both;"});
    buttons.push(c);
    if(o.type != "folder"){
      return [Builder.node("div",{style:"margin-top:8px;"},buttons)];
    }else{
      return [TN("Folder")];
    }
  },
  makeName:function(o){
    var itemtype = this.getType(o);
    var corr = 1;
    switch(itemtype){
      case "tune":
        corr = 0;
      break;
      case "picture":
        corr = 1;
      break;
      case "file":
        corr = 2;
      break;
      case "movie":
        corr = 3;
      break;
      default:
      corr = 2;
    }
    var icos = "background:url("+this.imageurl("icons-type.png")+") -"+(corr*20)+"px 0px;width:20px;";
    icos += "margin:4px;height:20px;float:left;";

    var wedits = "display:none;width:40px;height:17px;float:right;margin-top:5px;"
    var edits= "background:url("+this.imageurl2("edit-sml.png")+");cursor:pointer;width:17px;margin-right:4px;height:17px;float:left;"
    var dels = "background:url("+this.imageurl2("del-sml.png")+");cursor:pointer;width:17px;height:17px;float:left;"

    var ico = Builder.node('div',{style:icos},[]);
    var name = Builder.node('div',{style:"float:left;width:80%;"},[
      Builder.node('a',{
        style:"text-decoration:none;font-size:12px;color:black;",
        href:this.options.model.currentPathPermalink(o)
      },[TN(o.name)])
    ]);

    var editbtn = Builder.node('div',{style:edits},[]);

    Event.observe($(editbtn),'click',function(e){
      $(editbtn).up(1).setOpacity(0.2);
      o.onCancel = function(){
        $(editbtn).up(1).setOpacity(1);
      }
      var editrow = this.makeEditItemRow(o);
      $(editbtn).up(2).appendChild(editrow);
    }.bind(this));
    Event.observe($(editbtn),'mouseover',function(e){
      $(editbtn).setStyle({backgroundPosition:"0px 17px"});
    });
    Event.observe($(editbtn),'mouseout',function(e){
      $(editbtn).setStyle({backgroundPosition:"0px 0px"});
    });
    
    var delbtn = Builder.node('div',{style:dels},[]);
    Event.observe($(delbtn),'click',function(e){
      this.deleteItem(o)
    }.bind(this));

    Event.observe($(delbtn),'mouseover',function(e){
      $(delbtn).setStyle({backgroundPosition:"0px 17px"});
    });
    Event.observe($(delbtn),'mouseout',function(e){
      $(delbtn).setStyle({backgroundPosition:"0px 0px"});
    });
    var editmode = Builder.node('div',{id:"editmode"+o.id,style:wedits},[
      editbtn,
      delbtn,
      c
    ]);
    if(!itemModel.canWrite()){
      editmode = Builder.node('div',{id:"editmode"+o.id,style:wedits},[]);
    }
    var c = Builder.node('div',{style:"clear:both;"},[]);
    return [ico,name,editmode,c];
  },
  deleteItem:function(o){
    if(confirm("Are you sure you want to delete?")){
      this.finallyDeleteItem(o);
    }
  },
  finallyDeleteItem:function(o){
    var p = itemModel.currentPathPermalink(o);
    arr = p.split("/");
    arr.pop()
    str = arr[arr.length-1];  
    var path = "/";
    if(arr.length > 3){
      path = str.substr(1,str.length)
    }
    itemModel.ajaxRequest({
      action: "move_to_trash",
      onSuccess: function(success) { 
        this.options.model.removeItem(o);
        this.options.items = this.options.model.items();
        this.redrawCompletely()       
      }.bind(this)
    }, {
      form_path: path,
      form_name: o.pretty_name
    })
  },
  makeTabsHead:function(){
    this.tabswidget = new TopTabsWidget({mode:"explorer"});
    this.tabsfunctions = {
      Explorer:function(){
        if(this.options.folders.length > 0 ){
          this.list.innerHTML = ""
          this.list.appendChild(this.foldersxx);
        }
      }.bind(this),
      Recent:function(){
        this.list.innerHTML = ""
        this.list.appendChild(this.listxx);
      }.bind(this)
    };
    this.tabswidget.addObserver(this.tabsfunctions);

    var s = "position:relative;width:100%;height:32px;margin-top:-32px;background:transparent;";
    return Builder.node('div',{style:s},[this.tabswidget.htmlNode()]);
  },
  uploadItemAction:function(e){
    $(this.downloaddiv).toggle();
  },
  createFolderAction:function(e){

this.tabsfunctions.Explorer()

    this.folderarea.appendChild(this.makeFolderRow({id:'folder'+foldercount}));
    foldercount++;
  },
  makeListPreHead:function(){
    var s0 = "position:relative;width:100px;height:16px;top:5px;left:3px;";
    var s = "border:1px solid white;position:relative;width:100%;height:59px;background:white;";
    var btnstyle = "float:left;width:100px;height:26px;margin-right:20px;";

    var upl = Builder.node('div',{style:s0+"background:url("+this.imageurl("upload-text.png")+");"});
    var fol =  Builder.node('div',{style:s0+"left:0px;background:url("+this.imageurl("folder-text.png")+");"});


    var uploadBTN = Builder.node('div',{style:btnstyle},[
      new DefaultButtonWidget({caption:upl,onClickAction:function(){
        this.uploadItemAction();
      }.bind(this)}).htmlNode()
    ]);
    var createBTN = Builder.node('div',{style:btnstyle},[
      new DefaultButtonWidget({caption:fol,onClickAction:function(){
        this.createFolderAction();
      }.bind(this)}).htmlNode()
    ]);

    var btns = Builder.node('div',{style:"margin-left:15px;margin-top:15px;width:300px;height:26px;"},[
      uploadBTN,
      createBTN,
Builder.node('div',{style:"clear:both;"},[])
    ]);
    return Builder.node('div',{style:s},[btns]);
  },
  makeListMainHead:function(){
    var s = "position:relative;border:1px solid #c4c4c4;width:100%;height:26px;";
    s += "background:url("+this.imageurl("row-top.png")+") repeat-x;line-height:26px;font-weight:bolder;font-size:14px;";

    return Builder.node('div',{style:s},[TN(this.options.model.currentPath())]);
  },
  makeListSubHead:function(){
    var s = "position:relative;border:1px solid #c4c4c4;margin-top:-1px;z-index:2;";
    s += "background:url("+this.imageurl("row-default.png")+") repeat-x;width:100%;height:19px;";

    var s2 = "padding-left:3px;padding-right:3px;cursor:pointer;float:left;border-right:1px solid #c4c4c4;";
    s2 += "line-height:19px;background:url("+this.imageurl("row-default.png")+") repeat-x;width:25%;height:19px;";

    this.r0 = {
      selected:true,
      cell:Builder.node('div',{style:s2+"width:20px;"},[TN("")]),
      fn:function(e){}.bind(this)
    };
    this.r1 = {
      selected:true,
      cell:Builder.node('div',{style:s2+"width:35%;"},[TN("Name")]),
      fn:function(e){this.sortByName()}.bind(this)
    };
    this.r2 = {
      selected:false,
      cell:Builder.node('div',{style:s2+"width:15%;"},[TN("Date")]),
      fn:function(e){this.sortByDate();}.bind(this)
    };
    this.r3 = {
      selected:false,
      cell:Builder.node('div',{style:s2+"width:15%;"},[TN("Type")]),
      fn:function(e){this.sortByType()}.bind(this)
    };
    this.r4 = {
      selected:false,
      cell:Builder.node('div',{style:s2+"width:29%;border-right:0px;"},[TN("Share")]),
      fn:function(e){
      }
    };

    window.setTimeout(function(){
      this.selected(this.r2);
    }.bind(this),1000);

    $([this.r1,this.r2,this.r3,this.r4]).each(function(d){
      Event.observe($(d.cell),'click',function(e){
        this.selected(d);
        d.fn();
      }.bind(this));
    }.bind(this));

//(is_developer == true ?  : EMPTY())

    return Builder.node('div',{style:s},[
      this.r0.cell,
      this.r1.cell,
      this.r2.cell,
      this.r3.cell,
      this.r4.cell,
      Builder.node('div',{style:"clear:both;"})
    ]);

  },
  makePrivacyThing:function(item){
    var istyle = "float:left;width:17px;height:17px;";
    istyle += "background:url("+this.imageurl2("item-lock.png")+");";

    var icon = Builder.node('div',{style:istyle},[]);
    var lnk = Builder.node('a',{style:"",href:"javascript:void(0);",title:"this file is public"},[icon]);
    var txt = Builder.node('div',{style:"color:#9e0b0f;cursor:pointer;"},[]);

    Event.observe($(lnk),'click',function(){
if(itemModel.canWrite()){
      $(txt).innerHTML = "";
item.permission = (item.permission == "everyone" ? "onlyme" : "everyone");

itemPermission = item.permission;

      if(item.permission == "onlyme"){
        $(txt).appendChild(TN(""));
        $(icon).setStyle({backgroundPosition:"0px -17px"});
$(lnk).title = "this file is private";
      }else{
        $(txt).appendChild(TN(""));
        $(icon).setStyle({backgroundPosition:"0px 0px"});
$(lnk).title = "this file is public";
      }
      //save here!!!!!
      this.saveItem(item);
}else{
alert("no permission");
}
    }.bind(this));

    var priv = Builder.node('div',{},[
      lnk,
      //txt,
      Builder.node('div',{style:"clear:both;"},[])
    ]);

    if(item.permission == "onlyme"){
      $(txt).appendChild(TN(""));
      $(icon).setStyle({backgroundPosition:"0px -17px"});
    }else{
      $(txt).appendChild(TN(""));
      $(icon).setStyle({backgroundPosition:"0px 0px"});
    }

    return priv;
  },
  makeRow:function(o){
    var s = "width:100%;margin-top:-1px;z-index:1;background:white;border:1px solid #d5e4ed;height:30px;"

    var s2 = "position:relative;padding-left:3px;padding-right:3px;line-height:30px;border-right:1px solid #d5e4ed;float:left;width:25%;height:100%;";

var permcell = Builder.node('div',{style:s2+"width:20px;overflow:hidden;"},[this.makePrivacyThing(o)]);

    var namecell = Builder.node('div',{style:s2+"width:35%;overflow:hidden;"},this.makeName(o));

    Event.observe($(namecell),'mouseover',function(e){
      $("editmode"+o.id).show();
    });
    Event.observe($(namecell),'mouseout',function(e){
      $("editmode"+o.id).hide();
    })


    var row = Builder.node('div',{style:s},[
      permcell,
      namecell,
      Builder.node('div',{style:s2+"width:15%;overflow:hidden;"},[makeNiceDate(o.added_at)]),
      Builder.node('div',{style:s2+"width:15%;overflow:hidden;"},this.makeDownload(o)),
      Builder.node('div',{style:s2+"width:29%;border-right:0px;"},this.makeActions(o)),
      Builder.node('div',{style:"clear:both;"})
    ]);

    Event.observe($(row),'click',function(){
      try{
        $(share).remove();
      }catch(e){}
    });

    Event.observe($(row),'mouseover',function(e){
      $(row).setStyle({background:"#eef9ff"});
    });
    Event.observe($(row),'mouseout',function(e){
      $(row).setStyle({background:"#ffffff"});
    })

    return row;
  },
  makeFolderRow:function(o){
    var id = o.id;
    var s = "width:100%;margin-top:-1px;z-index:1;background:#FFFBCC;border:1px solid #d5e4ed;height:30px;"

    var s2 = "position:relative;padding-left:3px;padding-right:3px;line-height:30px;float:left;width:25%;height:100%;";

    var save = Builder.node('div',{id:"savefolder"+id},[this.makeBlankButton(Builder.node('div',{style:"color:#00a651;width:66px;text-align:center;font-size:16px;font-weight:bolder;"},[TN("Save")]))]);
    var row = Builder.node('div',{style:s},[
      Builder.node('div',{style:s2+"width:35%;overflow:hidden;"},[this.makeFileText(id)]),
      Builder.node('div',{style:s2+"width:60%;border-right:0px;"},[]),
      Builder.node('div',{style:"clear:both;"})
    ]);

var lowerstyle= "margin-left:-10px;padding-right:20px;margin-bottom:-10px;overflow:hidden;width:100%;height:38px;";
    lowerstyle += "background:url("+this.imageurl("upl-lower.png")+") repeat-x;";
    var btnstyle = "float:right;margin-right:0px;text-align:right;width:400px;height:26px;padding-top:7px;";
    var visstyle = "float:left;width:400px;height:26px;";
    visstyle += "line-height:38px;font-weight:bolder;margin-left:10px;"
    var btnstyle2 = "float:right;width:90px;"
    var cancel = this.makeBlankButton(Builder.node('div',{style:"color:#9e0b0f;width:66px;text-align:center;font-size:16px;font-weight:bolder;"},[TN("Cancel")]));
    Event.observe($(cancel),'click',function(e){
      $("row"+id).remove();
    }.bind(this))
    var btndiv = Builder.node('div',{style:btnstyle},[      
        Builder.node('div',{style:btnstyle2+"width:70px;margin-right:10px;"},[ cancel ]),
        Builder.node('div',{style:btnstyle2+"width:70px;"},[save]),
        Builder.node('div',{style:"clear:both"},[])
    ]);
    var radiostyle = "width:17px;height:17px;float:left;margin-top:10px;margin-right:5px;";
    radiostyle += "background:url("+this.imageurl("upl-radio.png")+") 0 0;";

    var publicradio = Builder.node('div',{style:radiostyle},[]);
    var publictext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Normal")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var public = Builder.node('div',{style:"cursor:pointer;width:120px;float:left;"},[
      publicradio,publictext,c
    ]);
    
    window.setTimeout(function(){
      $(public).addClassName('selected');
      $(publicradio).setStyle({backgroundPosition:"0px 17px"});
      folderPermission =  "everyone";
    },200);

    Event.observe($(public),'click',function(){
        $(publicradio).setStyle({backgroundPosition:"0px 17px"});
        $(privateradio).setStyle({backgroundPosition:"0px 0px"});
        folderPermission =  "everyone";
    }.bind(this))

    var privateradio = Builder.node('div',{style:radiostyle},[]);
    var privatetext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Private")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var private = Builder.node('div',{style:"cursor:pointer;width:120px;float:left;"},[
      privateradio,privatetext,c
    ]);
    Event.observe($(private),'click',function(){
        $(publicradio).setStyle({backgroundPosition:"0px 0px"});
        $(privateradio).setStyle({backgroundPosition:"0px 17px"});
        folderPermission =  "onlyme";
    }.bind(this))
   
    var visibilitydiv = Builder.node('div',{style:visstyle},[
      Builder.node('div',{style:"width:70px;float:left;"},[TN("VISIBILITY:")]),
      public, private, Builder.node('div',{style:"clear:both;"})
    ])
    var c = Builder.node('div',{style:"clear:both;"},[])
    
    

    var row2 = Builder.node('div',{style:s+"height:38px;"},[visibilitydiv,btndiv,c])

    Event.observe($(row),'click',function(){
      try{
        $(share).remove();
      }catch(e){}
    });
    var divvv = Builder.node('div',{id:'row'+id,style:''},[row,row2]);
    Event.observe($(save),'click',function(){
      try{         
          this.saveFolder(o);
          $("row"+id).remove();
          sdloader.setup();
      }catch(e){
alert(e);
}
    }.bind(this));

    return divvv
  },
  makeEditText:function(o){
    var id = o.id;

    var s= "cursor:pointer;float:right;line-height:30px;text-align:center;";
    s += "padding-top:1px;width:78px;height:26px;margin-right:20px;";

    var ss = "margin-left:-15px;margin-right:-10px;padding-left:15px;font-size:12px;height:40px;border-bottom:1px solid silver;";
    var fnstyle = "padding-top:4px;float:left;margin-right:10px;width:80%;";
    fnstyle += "";
    var fnmid = "height:23px;width:98%;float:left;";
    fnmid += "background:url("+this.imageurl("upl-text-mid.png")+") repeat-x;"
    var rlstyle = "width:2px;height:23px;float:left;";
    var rstyle = "background:url("+this.imageurl("upl-text-right.png")+");";
    var lstyle = "background:url("+this.imageurl("upl-text-left.png")+");";
    var istyle = "width:100%;line-height:23px;font-size:12px;";
    istyle += "border:0px;background:transparent;";

    var filenamebox = Builder.node('div',{style:fnmid},[
      Builder.node('input',{id:"edit"+id,type:"text",value:o.name,style:istyle})
    ]);
    var l = Builder.node('div',{style:rlstyle+lstyle},[]);
    var r = Builder.node('div',{style:rlstyle+rstyle},[]);

    var filename = Builder.node('div',{style:fnstyle},[
      l,
      filenamebox,
      r,
      Builder.node('div',{style:"clear:both;"})
    ]);
    var icos = "background:url("+this.imageurl("icons-type.png")+") -40px 0px;width:20px;";
    icos += "margin:4px;height:20px;width:20px;float:left;";

    var ico = Builder.node('div',{style:icos},[]);
    var c = Builder.node('div',{style:"clear:both;"},[]);
    return [ico,filename,c];

  },
  makeEditItemRow:function(o){
    var id = o.id;
    var s = "width:100%;margin-top:-1px;z-index:1;background:#FFFBCC;border:1px solid #d5e4ed;height:30px;"

    var s2 = "position:relative;padding-left:3px;padding-right:3px;line-height:30px;float:left;width:25%;height:100%;";

    var save = Builder.node('div',{},[this.makeBlankButton(Builder.node('div',{style:"color:#00a651;width:66px;text-align:center;font-size:16px;font-weight:bolder;"},[TN("Save")]))]);
    var row = Builder.node('div',{style:s},[
      Builder.node('div',{style:s2+"width:35%;overflow:hidden;"},[this.makeEditText(o)]),
      Builder.node('div',{style:s2+"width:60%;border-right:0px;"},[]),
      Builder.node('div',{style:"clear:both;"})
    ]);

var lowerstyle= "margin-left:-10px;padding-right:20px;margin-bottom:-10px;overflow:hidden;width:100%;height:38px;";
    lowerstyle += "background:url("+this.imageurl("upl-lower.png")+") repeat-x;";
    var btnstyle = "float:right;margin-right:0px;text-align:right;width:400px;height:40px;padding-top:3px;";
    var visstyle = "float:left;width:400px;height:40px;";
    visstyle += "line-height:38px;font-weight:bolder;margin-left:10px;"
    var btnstyle2 = "float:right;width:90px;"
    var cancel = this.makeBlankButton(Builder.node('div',{style:"color:#9e0b0f;width:66px;text-align:center;font-size:16px;font-weight:bolder;"},[TN("Cancel")]));
    Event.observe($(cancel),'click',function(e){
      $("editrow"+id).remove();
      o.onCancel();
    }.bind(this))
    var btndiv = Builder.node('div',{style:btnstyle},[      
        Builder.node('div',{style:btnstyle2+"width:70px;margin-right:10px;"},[ cancel ]),
        Builder.node('div',{style:btnstyle2+"width:70px;"},[save]),
        Builder.node('div',{style:"clear:both"},[])
    ]);
    var radiostyle = "width:17px;height:17px;float:left;margin-top:10px;margin-right:5px;";
    radiostyle += "background:url("+this.imageurl("upl-radio.png")+") 0 0;";

    var publicradio = Builder.node('div',{style:radiostyle},[]);
    var publictext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Normal")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var public = Builder.node('div',{style:"cursor:pointer;width:120px;float:left;"},[
      publicradio,publictext,c
    ]);
    
    window.setTimeout(function(){
      $(public).addClassName('selected');

      $(publicradio).setStyle({backgroundPosition:"0px 17px"});
      this.sortByDate();
    }.bind(this),200);

    Event.observe($(public),'click',function(){
        $(publicradio).setStyle({backgroundPosition:"0px 17px"});
        $(privateradio).setStyle({backgroundPosition:"0px 0px"});
        currentItem.permission = "everyone"
    }.bind(this))

    var privateradio = Builder.node('div',{style:radiostyle},[]);
    var privatetext = Builder.node('div',{style:"width:80px;float:left;"},[
      TN("Private")
    ]);
    var c = Builder.node('div',{style:"clear:both;"});
    var private = Builder.node('div',{style:"cursor:pointer;width:120px;float:left;"},[
      privateradio,privatetext,c
    ]);
    Event.observe($(private),'click',function(){
        $(publicradio).setStyle({backgroundPosition:"0px 0px"});
        $(privateradio).setStyle({backgroundPosition:"0px 17px"});
        currentItem.permission = "onlyme"
    }.bind(this))
   
    var visibilitydiv = Builder.node('div',{style:visstyle},[
      Builder.node('div',{style:"width:70px;float:left;"},[TN("VISIBILITY:")]),
      public, private, Builder.node('div',{style:"clear:both;"})
    ])
    var c = Builder.node('div',{style:"clear:both;"},[])    

    var row2 = Builder.node('div',{style:s+"height:45px;"},[
      visibilitydiv,btndiv,c
    ])

    Event.observe($(save),'click',function(){
      try{
//todo
        o.permission = currentItem.permission || o.permission;
        o.name = $F("edit"+o.id);
        
        this.saveItem(o);
      }catch(e){
        //alert(e);
      }
    }.bind(this));

    var retdiv = Builder.node('div',{id:'editrow'+id,style:'height:40px;'},[
      row,row2
    ]);
    return retdiv
  },
  saveItem:function(m){
    
    var options = Object.extend({
      afterStore: function() {}
    }, arguments[1] || {});
    delete m.onCancel;

    var instance = itemModel;
    var fields = itemModel.storeRequestFieldsForItem(m)
    var action = (m.id == -1 ? "create_item" : "edit")
    if (isFolder(m) || m.generic_folder) {
      action = (m.id == -1 ? "create_folder" : "edit")
    }
    if (__patch_ajax_action) { action = __patch_ajax_action }
    var p = itemModel.currentPathPermalink(m);
    var arr = p.split("/");
    arr.pop()

    var str = arr[arr.length-1];   
if(arr.length > 3){
   var path = str.substr(1,str.length);
}else{
   var path = "/";
}   
 
    new AjaxFormBuilder({
      user: itemModel.user(),
      service: itemModel.service(),
      action: action,
      onSuccessfulSubmit: function(afb, success) {
        hash_merge(m, success.item_info)
        m.edit = false
        m.increation = false
        itemlist.redrawCompletely();
        instance.notifyObservers("afterStore")
        //options.afterStore(m)
        //instance.onDone()
        //delete instance.onDone
      }
    }).performAjaxRequest(fields.merge({
      form_path: path,
      form_username_override: itemModel.user()
    }))
    itemModel.observeOnce({update:function(d){
      ///alert("SAVED")
//this.redrawCompletely()
    }.bind(this)});
  },
  saveFolder:function(o){
    var f = itemModel.addFolder()
    f.name = $F(o.id)
    f.permission = folderPermission
    itemModel.storeItem(f);
  },
  makeFileText:function(id){
    var s= "cursor:pointer;float:right;margin-right:20px;text-align:center;line-height:30px;";
    s += "padding-top:1px;width:78px;height:26px;";

    var ss = "font-size:12px;height:40px;border-bottom:1px solid silver;";
    ss += "margin-left:-15px;margin-right:-10px;padding-left:15px;";
    var fnstyle = "padding-top:4px;float:left;margin-right:10px;width:80%;";
    fnstyle += "";
    var fnmid = "height:23px;width:98%;float:left;";
    fnmid += "background:url("+this.imageurl("upl-text-mid.png")+") repeat-x;"
    var rlstyle = "width:2px;height:23px;float:left;";
    var rstyle = "background:url("+this.imageurl("upl-text-right.png")+");";
    var lstyle = "background:url("+this.imageurl("upl-text-left.png")+");";
    var istyle = "width:100%;line-height:23px;font-size:12px;";
    istyle += "border:0px;background:transparent;";

    var filenamebox = Builder.node('div',{style:fnmid},[
      Builder.node('input',{id:id,type:"text",value:"Untitled Folder",style:istyle})
    ]);
    var l = Builder.node('div',{style:rlstyle+lstyle},[]);
    var r = Builder.node('div',{style:rlstyle+rstyle},[]);

    var filename = Builder.node('div',{style:fnstyle},[
      l,
      filenamebox,
      r,
      Builder.node('div',{style:"clear:both;"})
    ]);
    var icos = "background:url("+this.imageurl("icons-type.png")+") -40px 0px;width:20px;";
    icos += "margin:4px;height:20px;width:20px;float:left;";

    var ico = Builder.node('div',{style:icos},[]);
    var c = Builder.node('div',{style:"clear:both;"},[]);
    return [ico,filename,c];

  },
  makeFolderArea:function(){
    this.folderarea = Builder.node('div',{},[]);
    return this.folderarea;
  },
  makeList:function(items){
    this.listxx = Builder.node('div',{style:""},[]);
    $(items).each(function(r){
      var b = this.makeRow(r);
      this.listxx.appendChild(b);
      this.listxx.appendChild(Builder.node('div',{style:"clear:both;"}));
    }.bind(this));
    return this.listxx;
  },
  makeFolders:function(items){
    this.foldersxx = Builder.node('div',{style:""},[]);
    $(items).each(function(r){
      var b = this.makeRow(r);
      this.foldersxx.appendChild(b);
      this.foldersxx.appendChild(Builder.node('div',{style:"clear:both;"}));
    }.bind(this));
    return this.foldersxx;
  },
  makeUploadArea:function(){
    this.uploadwidget = new UploadWidget();
    this.downloaddiv = Builder.node('div',{style:"width:100%;"},[
      this.uploadwidget.htmlNode()
    ]);
    $(this.downloaddiv).hide();
    return this.downloaddiv;
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  imageurl2:function(img){
    return "http://core.myfil.es/get_file/design-2/"+img
  },
  makeWidgetContent: function(){

    this.list = Builder.node('div',{},[this.makeList(this.options.items)]);

    var wrapper = Builder.node('div',{style:"clear:both;color:black;font-size:11px;"},[
      this.makeTabsHead(),
      (itemModel.canWrite() ? this.makeListPreHead() : EMPTY()),
new BreadcrumbWidget().htmlNode(),
      (itemModel.canWrite() ? this.makeListMainHead() : EMPTY()),
      this.makeListSubHead(),
      (itemModel.canWrite() ? this.makeUploadArea() : EMPTY()),
      (itemModel.canWrite() ? this.makeFolderArea() : EMPTY()),
      this.list
    ]);
    return wrapper;
  }
}  
Object.extend(ItemListWidget.prototype, WidgetCommon);
Object.extend(ItemListWidget.prototype, Observable);

;

// /8::/202::/core:js -> <463516> itempagewidget.js 

var itemPermission;

ItemPageWidget = Class.create();

var fun;

ItemPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      content:null,
      m:null,
      item:null,
      buttons:[
        {
          icon:4,
          type:"reddit",
          text:"Reddit",
          link:"http://reddit.com/submit?url=URL&title=TITLE"
        },{
          icon:3,
          type:"google",
          text:"Google",
          link:"http://www.google.com/bookmarks/mark?op=edit&bkmk=URL&title=TITLE"
        },{
          icon:2,
          type:"delicious",
          text:"Delicious",
          link:"http://del.icio.us/post?url=URL"
        },{
          icon:1,
          type:"digg",
          text:"Digg",
          link:"http://digg.com/submit?phase=2&url=URL&title=TITLE"
        }
      ]
    },arguments[0]);
  },
  setup:function(){    

    fun = function(e){
      this.makeEditMode();
    }.bind(this);

    var it = (this.options.item.content_type ? this.options.item.content_type : "/")
    var ctype = it.split("/");
    var type = ctype[0];

    if(this.options.item.full_item_url != undefined){
      var tok = this.options.item.full_item_url.split('.')
      var ext = tok[tok.length-1]; //last token
      if(ext.toLowerCase() == 'ppt' 
        || ext.toLowerCase() == 'doc' 
          || ext.toLowerCase() == 'pdf'){
            window.setTimeout(function(){
              this.setGoogleDocsReader(this.options.item);
            }.bind(this),2000);
      }else if(type == "application"){
        window.setTimeout(function(){
          $(this.itemcontent).setStyle({border:"0px",height:"30px"});
          var info = "<div>We do not have a viewer for this file (yet!).</div>"
          $(this.itemcontent).update(info);
        }.bind(this),2000);
      }
    }
  }, 
  setGoogleDocsReader:function(m){
    var iframe = '<iframe src="http://docs.google.com/gview?url='+m.full_item_url+'&embedded=true" style="width:100%; height:100%;" frameborder="0"></iframe>';

    $(this.itemcontent).update(iframe);
  },
  getType:function(m,b){
    var type = "file";
    var mime = "";
    try{
      var mime = mimeTypeCategory(m);
      switch(mime){
        case "Audio":
          type = "tune";
          break;
        case "Video":
          type = "movie";
          break;
        case "Image":
          type = "picture";
          break;
        case "File":
          type = "file";
          break;
        default:
      }
    }catch(e){
      return (m.type != undefined ? m.type : "file");
    }
    if(b){
      type = (mime != undefined ? mime : m.type);
    }
    return type;
  },
  getEmbed:function(){
    var e = [];
    var m = this.options.item;
    var type = this.getType(m);
    if(m.type == "folder"){
      type = m.type;
    }


    //we clean up embed
    embedcode = embedcode.gsub("'","\\'");
    embedcode = embedcode.gsub("\"","'");


    switch(type){
        case "movie":
            var flv_url = m.flv_url;
            var embedtext = embedcode;
window.setTimeout(function(){
$("emb").value = embedcode;
},3000);
            e.push({embed:embedtext,text:"Embed code"});
           // e.push({embed:m.full_item_url,text:"Original file"});
           // e.push({embed:itemModel.currentPathPermalink(m),text:"This page"});
            break;
        case "picture":
            var embedtext = "[URL="+itemModel.currentPathPermalink(m)+"][IMG]"+ m.full_item_url +"[/IMG][/URL]";
            e.push({embed:embedtext,text:"Forum code"});
          //  e.push({embed:m.full_item_url,text:"Original file"});
          //  e.push({embed:itemModel.currentPathPermalink(m),text:"This page"});
            break;
        case "tune":
            var flv_url = m.flv_url;
            var embedtext = embedcode;
window.setTimeout(function(){
$("emb").value = embedcode;
},3000);
            e.push({embed:embedtext,text:"Embed code"});
           // e.push({embed:m.full_item_url,text:"Original file"});
           // e.push({embed:itemModel.currentPathPermalink(m),text:"This page"});
            break; 
        case "file": 
           e.push({embed:m.full_item_url,text:"Original file"});
            break; 
        case "folder":
             var folder = itemModel.currentPath();
             var user = read_user_model_data.username;

             var jsembed = "<script src='http://static.mysites.com/get_file/embed/embed.js?v=1.0.0&user="+user +"&folder="+folder+"' type='text/javascript' id='mysites-embed'></script>";

          //    e.push({embed:jsembed,text:"Embed this album"});
              e.push({embed:document.location.href,text:"This album"});
              break; 
        default:
            e.push({embed:"---",text:"no embed code"}); 
    } 
    return e;
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  imageurl2:function(img){
    return "http://core.myfil.es/get_file/design-2/"+img
  },
  makePermissions:function(){
    var radiostyle = "width:17px;height:17px;float:left;margin-top:10px;margin-right:5px;";
    radiostyle += "background:url("+this.imageurl("upl-radio.png")+") 0 0;";

    var publicradio = Builder.node('div',{id:"itempublicradio",style:radiostyle},[]);
    var publictext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Normal")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var public = Builder.node('div',{id:"itempublic",style:"cursor:pointer;width:120px;float:left;"},[
      publicradio,publictext,c
    ]);

    var privateradio = Builder.node('div',{id:"itemprivateradio",style:radiostyle},[]);
    var privatetext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Private")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var private = Builder.node('div',{id:"itemprivate",style:"cursor:pointer;width:120px;float:left;"},[
      privateradio,privatetext,c
    ]);

    Event.observe($(public),'click',function(){
        $(publicradio).setStyle({backgroundPosition:"0px 17px"});
        $(privateradio).setStyle({backgroundPosition:"0px 0px"});
        itemPermission =  "everyone";
    }.bind(this));
    Event.observe($(private),'click',function(){
        $(publicradio).setStyle({backgroundPosition:"0px 0px"});
        $(privateradio).setStyle({backgroundPosition:"0px 17px"});
        itemPermission =  "onlyme";
    }.bind(this));

    window.setTimeout(function(){
      if(itemModel.canWrite() && this.options.item.type != "folder"){
        if(this.options.item.permission == "everyone"){
          $("itempublic").addClassName('selected');
          $("itempublicradio").setStyle({backgroundPosition:"0px 17px"});
          itemPermission =  "everyone";
        }else{
          $("itemprivate").addClassName('selected');
          $("itemprivateradio").setStyle({backgroundPosition:"0px 17px"});
          itemPermission =  "onlyme";
        }
      }
    }.bind(this),200);

    var visstyle = "float:left;width:400px;height:26px;";
    visstyle += "line-height:38px;font-weight:bolder;margin-left:10px;"

    var visibilitydiv = Builder.node('div',{style:visstyle},[
      Builder.node('div',{style:"width:70px;float:left;"},[
        TN("VISIBILITY:")
      ]),
      public, 
      private, 
      Builder.node('div',{style:"clear:both;"})
    ])
    var row2 = Builder.node('div',{style:"font-size:12px;height:38px;"},[visibilitydiv])
    return row2;
  },
  makeButton:function(o){
    var s = "cursor:pointer;height:26px;width:"+(o.width)+"px;";
    var c = Builder.node('div',{style:"clear:both;"},[]);

    var btnr = Builder.node('div',{style:"float:left;background:url("+this.imageurl2("blankr.png")+");width:5px;height:100%;"},[]);
    var btnc = Builder.node('div',{style:"float:left;background:url("+this.imageurl2("blankf.png")+") repeat-x;width:"+(o.width-10)+"px;font-size:13px;height:100%;line-height:26px;text-align:center;"},[
      o.textnode
    ]);
    var btnl = Builder.node('div',{style:"float:left;background:url("+this.imageurl2("blankl.png")+") no-repeat;width:5px;height:100%;"},[]);

    var btn = Builder.node('div',{style:s},[
      btnl,
      btnc,
      btnr,
      c
    ]);
    
    var actionFn = o.buttonAction || function(e){alert("blank");}
    Event.observe($(btn),'click',function(e){
      Event.stop(e);
      actionFn(e,o);
    });
    Event.observe($(btn),'mouseover',function(e){
      $(btnr).setStyle({backgroundPosition:"0px -26px"});
      $(btnc).setStyle({backgroundPosition:"0px -26px"});
      $(btnl).setStyle({backgroundPosition:"0px -26px"});
    });
    Event.observe($(btn),'mouseout',function(e){
      $(btnr).setStyle({backgroundPosition:"0px 0px"});
      $(btnc).setStyle({backgroundPosition:"0px 0px"});
      $(btnl).setStyle({backgroundPosition:"0px 0px"});
    });
    return btn;
  },
  makeEmbedBox:function(o){
    var istyle = "margin-top:5px;margin-left:5px;color:black;font-family:Trebuchet MS;width:180px;border:0px solid transparent;background:transparent;font-size:12px;";
    var sstyle = "width:203px;height:33px;background:url("+this.imageurl2("item-embed.png")+");";
    var inp = Builder.node('input',{id:o.id,value:o.val,type:"text",style:istyle},[]);
    var boxx = Builder.node('div',{style:sstyle},[inp]);
    return Builder.node('div',{style:"margin-bottom:5px;"},[
      Builder.node('div',{style:"font-size:13px;"},[TN(o.head)]),boxx
    ]);
  },
  makeShareBox:function(){
    var sstyle = "";
    var boxx = Builder.node('div',{style:sstyle},[
      Builder.node('div',{style:"font-weight:bolder;"},[
        TN("SHARE THIS "),TN(this.getType(this.options.item).toUpperCase())
      ]),
      this.makeShareButton(this.options.buttons[3]),
      this.makeShareButton(this.options.buttons[2]),
      this.makeShareButton(this.options.buttons[1]),
      this.makeShareButton(this.options.buttons[0])
    ]);
    return boxx;
  },
  makeShareButton:function(o){
    var sstyle = "cursor:pointer;width:196px;height:28px;margin-bottom:10px;";
    sstyle += "background:url("+this.imageurl2("item-big-btn.png")+");"
    var tstyle = "float:left;width:150px;height:18px;text-align:center;";
    tstyle += "font-size:12px;font-weight:bolder;color:#9e0b0f;line-height:28px;";
    var istyle = "float:left;width:20px;height:22px;margin:4px;";
    istyle += "background:url("+this.imageurl("icons-select.png")+") 0px "+(o.icon*22)+"px;";
    var boxx = Builder.node('div',{style:sstyle},[
      Builder.node('div',{style:istyle},[]),
      Builder.node('div',{style:tstyle},[TN(o.text)]),
      Builder.node('div',{style:"clear:both;"},[])
    ]);
    Event.observe($(boxx),'mouseover',function(){
      $(boxx).setStyle({backgroundPosition:"0px 28px"});
    });
    Event.observe($(boxx),'mouseout',function(){
      $(boxx).setStyle({backgroundPosition:"0px 0px"});
    });
    var URL = itemModel.currentPathPermalink(this.options.item)+"?static-only=1";
    var TITLE = escape(this.options.item.name);
    var LINK = o.link.replace("URL",URL).replace("TITLE",TITLE);;
    var b = Builder.node('a',{
      style:"width:100%;height:100%;background:white;color:#9e0b0f;",
      href:LINK,
      target:"_blank"
    },[boxx]);

    return b;
  },
  makeQRBox:function(){
    var qrs1 = "position:relative;top:20px;margin-left:20px;width:155px;";
    var qrsrc = 'http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl='
    qrsrc += document.location.href+'&chld=L|0';

    this.qrimg = Builder.node('div',{style:qrs1},[
        Builder.node('img',{src:qrsrc})
    ]);

    var sstyle = "";
    var qrstyle = "width:196px;height:193px;background:url("+this.imageurl2("item-qr.png")+");";
    var boxx = Builder.node('div',{style:sstyle},[
      Builder.node('div',{style:"font-weight:bolder;"},[TN("MOBILE UP-CODE")]),
      Builder.node('div',{style:qrstyle},[this.qrimg])
    ]);
    return boxx;
  },
  makeLeftBar:function(){
    var lstyle = "float:left;width:190px;height:100%;padding:10px;position:relative;"
    var ec = this.getEmbed()[0];
    var vv = ( this.options.item.full_item_url ? this.options.item.full_item_url : "--");
    var lb = Builder.node('div',{style:lstyle},[
      Builder.node('div',{style:"font-weight:bolder;"},[TN("SHARE")]),
      this.makeEmbedBox({id:"dl",head:"Direct download link:",val:vv}),
      this.makeEmbedBox({id:"emb",head:ec.text+":",val:ec.embed}),
      BR(),
      this.makeShareBox(),
      BR(),
      this.makeQRBox()
    ]);

    return lb;
  },
  makeHead:function(){
var o = this.options.item;
    var hstyle = "font-weight:bolder;width:700px;font-size:18px;"
    this.head = Builder.node('div',{style:hstyle},[
      this.makeCaption()
    ]);
 

    if(itemModel.canWrite()){


      var savestyle = "color:#00a651;font-weight:bolder;";
      var cancelstyle = "color:#9e0b0f;";
      var saveBTN = this.makeButton({
        textnode:Builder.node('span',{style:savestyle},[TN("SAVE")]),
        buttonAction:function(){

          this.saveItem(this.options.item);

        }.bind(this),    
        width:80
      });

      this.perms = this.makePermissions();
      $(this.perms).hide();

      var cancelBTN = this.makeButton({
        textnode:Builder.node('span',{style:cancelstyle},[TN("Cancel")]),
        buttonAction:function(){
          this.redrawCompletely()
        }.bind(this),
        width:100
      });
      var eleft = Builder.node('div',{style:"width:100px;float:left;"},[saveBTN]);
      var eright = Builder.node('div',{style:"width:120px;float:left;"},[cancelBTN]);
      var ecent = Builder.node('div',{style:"width:400px;float:left;"},[this.perms]);
      this.editactions = Builder.node('div',{id:"itemactions",style:"width:100%;"},[
        ecent,
        eleft,
        eright,
        Builder.node('div',{style:"clear:both;"},[])
      ]);


      $(this.editactions).hide()
      $(this.head).appendChild(this.editactions);   
      //$(this.head).appendChild(this.perms);
   
    }
    return Builder.node('div',{},[this.head]);
  },
 saveItem:function(m){
try{
    if($F("nameedit") && $F("nameedit") != this.options.item.name){
      m.name = $F("nameedit");
      m.name = $("nameedit").value;
     // alert("save changed name")
    }
}catch(e){}

    m.permission = itemPermission;

    var options = Object.extend({
      afterStore: function() {}
    }, arguments[1] || {});
    delete m.onCancel;

    var instance = itemModel;
    var fields = itemModel.storeRequestFieldsForItem(m)

fields.permission = m.permission;

    var action = (m.id == -1 ? "create_item" : "edit")
    if (isFolder(m) || m.generic_folder) {
      action = (m.id == -1 ? "create_folder" : "edit")
    }
    if (__patch_ajax_action) { action = __patch_ajax_action }
    var p = itemModel.currentPathPermalink(m);
    var arr = p.split("/");
    arr.pop()
    var str = arr[arr.length-1];      
    var path = str.substr(1,str.length)

    new AjaxFormBuilder({
      user: itemModel.user(),
      service: itemModel.service(),
      action: action,
      onSuccessfulSubmit: function(afb, success) {
        hash_merge(m, success.item_info)
        m.edit = false
        m.increation = false
        instance.update();
        instance.notifyObservers("afterStore")
        //options.afterStore(m)
        //instance.onDone()
        //delete instance.onDone
      }
    }).performAjaxRequest(fields.merge({
      form_path: path,
      form_username_override: itemModel.user()
    }))
    itemModel.observeOnce({update:function(d){
      this.redrawCompletely();
    }.bind(this)});
  },
  makeCaption:function(){
    this.headcaption = Builder.node('div',{style:"cursor:pointer;"},[TN(this.options.item.name)]);
    Event.observe($(this.headcaption),'click',fun);
    return this.headcaption;
  },
  makeEditMode:function(t){

try{

    $(this.headcaption).innerHTML = "";
    var bgstyle = "background:url("+this.imageurl2("item-edit-mode.png")+");";
    bgstyle += "width:215px;height:31px;margin-bottom:10px;";
    var inpstyle = "background:transparent;border:0px solid black;";
    inpstyle += "padding-left:5px;width:90%;height:100%;";
    var inp = Builder.node('input',{id:"nameedit",type:"text",value:this.options.item.name,style:inpstyle},[]);
    var editbg = Builder.node('div',{style:bgstyle},[inp]);
    $(this.headcaption).appendChild(editbg);
    $(this.editactions).show()
    $(this.perms).show();

    Event.stopObserving($(this.headcaption),'click',fun);

    window.setTimeout(function(){
      if(this.options.item.permission == "everyone"){
        $("itempublic").addClassName('selected');
        $("itempublicradio").setStyle({backgroundPosition:"0px 17px"});
        itemPermission =  "everyone";
      }else{
        $("itemprivate").addClassName('selected');
        $("itemprivateradio").setStyle({backgroundPosition:"0px 17px"});
        itemPermission =  "onlyme";
      }
    }.bind(this),200);

}catch(e){};


  },
  makeSubHead:function(){
    var hstyle = "line-height:27px;width:100%;height:27px;font-size:12px;";
    hstyle += "padding-left:10px;margin-left:-10px;padding-right:10px;margin-top:20px;";
    hstyle += "background:url("+this.imageurl2("item-sep.png")+") repeat-x;"
    var head = Builder.node('div',{style:hstyle},[
      new BreadcrumbWidget().htmlNode()//TN(itemModel.currentPathPermalink(this.options.item))
    ]);
    return head;
  },
  makePrivacyThing:function(){

    var istyle = "float:left;width:17px;height:17px;";
    istyle += "background:url("+this.imageurl2("item-lock.png")+");";

    var icon = Builder.node('div',{style:istyle},[]);
    var txt = Builder.node('div',{style:"color:#9e0b0f;cursor:pointer;"},[]);
    Event.observe($(txt),'click',function(){
      $(txt).innerHTML = "";
this.options.item.permission = (this.options.item.permission == "everyone" ? "onlyme" : "everyone");

itemPermission = this.options.item.permission;

      if(this.options.item.permission == "onlyme"){
        $(txt).appendChild(TN("This File is private"));
        $(icon).setStyle({backgroundPosition:"0px -17px"});
      }else{
        $(txt).appendChild(TN("This File is public"));
        $(icon).setStyle({backgroundPosition:"0px 0px"});
      }
      //save here
      this.saveItem(this.options.item);
    }.bind(this));

    var priv = Builder.node('div',{},[
      icon,
      txt,
      Builder.node('div',{style:"clear:both;"},[])
    ]);

    if(this.options.item.permission == "onlyme"){
      $(txt).appendChild(TN("This File is private"));
      $(icon).setStyle({backgroundPosition:"0px -17px"});
    }else{
      $(txt).appendChild(TN("This File is public"));
      $(icon).setStyle({backgroundPosition:"0px 0px"});
    }


    return priv;
  },
  makeActionsHead:function(){

    var o = this.options.item;

 var edits= "background:url("+this.imageurl2("edit-sml.png")+");cursor:pointer;width:17px;margin-right:4px;height:17px;float:left;"
    var dels = "background:url("+this.imageurl2("del-sml.png")+");cursor:pointer;width:17px;height:17px;float:left;"

    var wedits = "width:40px;height:17px;float:right;margin-top:5px;"

    var editbtn = Builder.node('div',{style:edits},[]);
    Event.observe($(editbtn),'click',function(e){  
      this.makeEditMode();    
    }.bind(this));
/*
    Event.observe($(editbtn),'mouseover',function(e){
      $(editbtn).setStyle({backgroundPosition:"0px 17px"});
    });
    Event.observe($(editbtn),'mouseout',function(e){
      $(editbtn).setStyle({backgroundPosition:"0px 0px"});
    });   
*/ 
    var delbtn = Builder.node('div',{style:dels},[]);
    Event.observe($(delbtn),'click',function(e){
      this.deleteItem()
    }.bind(this));
/*
    Event.observe($(delbtn),'mouseover',function(e){
      $(delbtn).setStyle({backgroundPosition:"0px 17px"});
    });
    Event.observe($(delbtn),'mouseout',function(e){
      $(delbtn).setStyle({backgroundPosition:"0px 0px"});
    });
*/
    var c = Builder.node('div',{style:"clear:both;"},[])    

    var editmode = Builder.node('div',{id:"editmode"+o.id,style:wedits},[
      editbtn,
      delbtn,
      c
    ]);

if(!itemModel.canWrite()){
editmode = EMPTY();
}

 var infoleft = Builder.node('div',{style:"width:50%;float:left;"},[
      Builder.node('div',{},[
      Builder.node('div',{style:"width:150px;float:left;"},[
        TN("Added"),NBSP(),makeNiceDate(this.options.item.added_at)
      ]),
      Builder.node('div',{style:"width:150px;float:left;"},[
        this.makePrivacyThing()
      ]),
      editmode,
      Builder.node('div',{style:"clear:both;"},[])
    ])

    ]);
/*
$(editmode).hide();
Event.observe(infoleft,'mouseover',function(e){
$(editmode).show();
});
Event.observe(infoleft,'mouseout',function(e){
$(editmode).hide();
});
*/
    var inforight = Builder.node('div',{style:"width:50%;float:left;"},[]);
    var actionrow1 = Builder.node('div',{style:"width:100%;margin-bottom:10px;"},[
      infoleft,
      inforight,
      Builder.node('div',{style:"clear:both;"},[])
    ]);
    return actionrow1;
},
  makeActionsArea:function(){   


    var actionsleft = Builder.node('div',{style:"width:50%;float:left;"},[]);
    var actionsright = Builder.node('div',{style:"width:50%;float:left;margin-top:0px;"},[]);

    var actionrow2 = Builder.node('div',{style:"width:100%;"},[
      actionsleft,
      actionsright,
      Builder.node('div',{style:"clear:both;"},[])
    ]);
/*
    var actions1 = Builder.node('div',{style:"width:160px;float:left;"},[
      this.makeButton({
        buttonAction:function(){},
        textnode:Builder.node('span',{style:"color:#00a651;"},[TN("Upload new version")]),
        width:150
      })
    ]);

    var actions2 = Builder.node('div',{style:"width:120px;float:left;"},[
      this.makeButton({
        buttonAction:function(){this.deleteItem()}.bind(this),
        textnode:Builder.node('span',{style:"color:#9e0b0f;"},[TN("Delete")]),
        width:100
      })
    ]);
  
    var actionrowl = Builder.node('div',{style:"width:100%;"},[
      //actions1,
      actions2,
      Builder.node('div',{style:"clear:both;"},[])
    ]);
    actionsleft.appendChild(actionrowl);
*/

var vv = ( this.options.item.full_item_url ? this.options.item.full_item_url : "http://www.mysites.com");

    var actions21 = Builder.node('div',{style:"width:120px;float:right;"},[
      this.makeActionButton({href:vv,
        buttonAction:function(){          
          window.open(vv);
        }.bind(this),
        subnode:TN("to your hard drive"),
        textnode:TN("SAVE"),
        y:42
      })
    ]);

    var n = Builder.node('div',{},[this.makeActionButton({
        buttonAction:function(){},
        subnode:TN("Publish to your wall"),
        textnode:TN("SHARE"),
        y:0
      })
    ]);

    var actions22 = Builder.node('div',{style:"width:120px;float:right;"},[
     new simpleFBPublishStreamWidget({
        style:"",
        name:this.options.item.name,
        caption:"",
        captionnode:n,
        items:[this.options.item]
      }).htmlNode()
    ]);
    var actions23 = Builder.node('div',{style:"width:70px;float:right;"},[
      new simpleRetweetWidget({link:document.location+"/?static-only=1"}).htmlNode()
    ]);
    var actionrowr = Builder.node('div',{style:"width:95%;text-align:right;"},[
      actions23,
      actions22,
      actions21,
      Builder.node('div',{style:"clear:both;"},[])
    ]);
    actionsright.appendChild(actionrowr);

    var ssstyle = "margin-right:10px;margin-left:10px;width:100%;margin-top:5px;";

var box = Builder.node('div',{style:ssstyle},[/*actionrow1,*/actionrow2]);


    return box
  },
  makeActionButton:function(o){
    var innerstyle = "width:96px;height:42px;line-height:40px;text-align:center;";
    innerstyle += "cursor:pointer;font-size:12px;color:#3ebded;weight:bolder;"
    var abstyle = "text-align:left;width:120px;height:55px;color:#000000;font-size:12px;";
    innerstyle += "background:url("+this.imageurl2("item-actions.png")+") 0px "+o.y+"px;"

if (o.href != null){

    var ab = Builder.node('a',{href:o.href,style:"font-size:12px;color:#3ebded;text-decoration:none;"},[
Builder.node('div',{style:abstyle},[
      Builder.node('div',{style:innerstyle},[
        o.textnode
      ]),
      o.subnode
    ])
]);

}else{
    var ab = Builder.node('div',{style:abstyle},[
      Builder.node('div',{style:innerstyle},[
        o.textnode
      ]),
      o.subnode
    ]);

    Event.observe($(ab),'click',function(e){
      o.buttonAction();
    }.bind(this));
}
    return ab;
  },
  makeCommentsArea:function(){
    return Builder.node('div',{style:"width:700px;margin-left:10px;"},[
      new FBCommentsWidget({title:this.options.item.name}).htmlNode()
    ]);
  },
  deleteItem:function(){
    if (confirm("Are you sure you want to delete?")) { 
      this.finallyDelete();
    }
  },
  finallyDelete:function(){
    var o = this.options.item;
    var p = itemModel.currentPathPermalink(o);
    arr = p.split("/");
    arr.pop()
    str = arr[arr.length-1];      
    var path = str.substr(1,str.length)

    itemModel.ajaxRequest({
      action: "move_to_trash",
      onSuccess: function(success) { 
        //itemModel.removeItem(o);
var arr = document.location.toString().split("/")
arr.pop();
document.location = arr.join("/");
        //itemModel.update();       
      }.bind(this)
    }, {
      form_path: path,
      form_name: o.pretty_name
    })
  },
  makeContentArea:function(){
    var h = (768/100) * 70;
    var w = (1024/100) * 70;
    var cstyle = "height:"+h+"px;color:black;border:2px solid #CCCCCC;";
    cstyle += "z-index:10;overflow:auto;cursor:pointer;width:"+(w-17)+"px;";
    cstyle += "margin:0 auto;margin-top:20px;";

    this.itemcontent = Builder.node('div',{style:cstyle},[]);

    Event.observe($(this.itemcontent),'click',function(){
      var vv = ( this.options.item.full_item_url ? this.options.item.full_item_url : "");
      window.open(vv);
    }.bind(this));
    return this.itemcontent;
  },
  makeWidgetContent: function(){  

    var left = [
      
    ];   

    var s = "width:100%;height:32px;margin-top:-32px;background:transparent;";
    s += "position:relative;margin-left:230px;";
    var cstyle = "width:"+($(document.viewport).getWidth()-(250 + 5 + 17 + 1))+"px;padding:10px;";
    cstyle += "height:100%;float:left;background:white;";

    var wstyle = "height:100%;width:17px;float:left;";
    wstyle += "background:url("+this.imageurl("front-shade-left.png")+") no-repeat;";
    this.tabswidget = new TopTabsWidget({mode:"explorer",singletab:true});
    var obs = {};
    this.tabswidget.addObserver(obs);

    var right = [
      Builder.node('div',{style:"position:relative;top:0px;"},[
        Builder.node('div',{style:s},[this.tabswidget.htmlNode()]),
        Builder.node('div',{style:"height:1100px;overflow:hidden;"},[
          this.makeLeftBar(),
          Builder.node('div',{style:wstyle},[]),
          Builder.node('div',{style:cstyle},[
            this.makeHead(),
this.makeActionsHead(),
            this.makeSubHead(),
            this.makeContentArea(),
            (this.options.item.type != "folder" ? this.makeActionsArea() : EMPTY()),
            
            (this.options.item.type != "folder" ? this.makeCommentsArea() : EMPTY()) 
          ]) 
        ]),
        Builder.node('div',{style:"clear:both;"},[])
      ])
    ];   
    if(this.options.item.type == "folder"){
      right = [new ItemListWidget({mixin:false}).htmlNode()]
    }
    layoutwidget = new LayoutWidget({left:left,right:right});

    return layoutwidget.htmlNode();
  }
}  
Object.extend(ItemPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <443518> layoutwidget.js 

function is_iphone(){
  var agent = navigator.userAgent.toLowerCase();
  var isiphone = ( agent.indexOf('iphone') != -1 );
  return isiphone
}

var ichecked = false;
LayoutWidget = Class.create();

LayoutWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({tabs:true,top:null,bottom:null,left:[],right:[]},arguments[0]);
  },
  setup:function(){
    if(is_iphone() && !ichecked){
      ichecked =  true;
      //alert("iphone..niiice");
      this.is_iphone = is_iphone();
    }
  },
  makeContentHolder:function(){  

    this.contenthead = EMPTY();
    if(this.options.top != null){
      this.contenthead = Builder.node('div',
        {id:"myhead",style:"overflow:hidden;height:0px;width:100%;background:transparent;"},
          this.options.top);
    }

    this.contentleft = Builder.node('div',
      {id:"myleft",style:"overflow:hidden;float:left;height:100%;width:300px;background:transparent;"},
        this.options.left);

    this.contentright = Builder.node('div',
      {id:"myright",style:"height:100%;float:left;width:100%;background:transparent;"},
        this.options.right);

    this.contentbottom = EMPTY();
    if(this.options.bottom != null){
      this.contentbottom = Builder.node('div',
        {id:"mybottom",style:"height:1px;width:860px;background:transparent;"},
          this.options.bottom);
    }

    return Builder.node('div',{style:"width:100%;"},[
        this.contenthead,
        this.contentleft,this.contentright,
        Builder.node('div',{style:"clear:both;"}),
        this.contentbottom
    ]);

  },
  makeWidgetContent: function(){  
    
    var style1 = {style:"width:99.6%;padding-bottom:0px;margin:0 auto;clear:both;color:black;"};

    this.wrapper = Builder.node('div',{id:"layout",style:"overflow:hidden;color:white;width:100%;background:#e9f2f8;"},[
                     new HeaderWidget().htmlNode(),  
                     Builder.node('div',style1,[                       
                       this.makeContentHolder()                       
                     ]),
                     new FooterWidget().htmlNode()
                    ]); 

    return this.wrapper 
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(LayoutWidget.prototype, WidgetCommon); 



BreadcrumbWidget = Class.create();
BreadcrumbWidget.prototype = {
  defaultOptions: function() {
    return {};
  },
  setup: function() {
  
  },
  makeLink:function(d){
    var s = "float:left;font-size:16px;color:black;text-decoration:none;";

      var nitem = 
        Builder.node('a',{
          href:this.buildLinkUrl(d),style:s},[
         Builder.node('div',{style:""},[ TN(d.text)])        
      ]);
    return nitem;
  },
  buildLinkUrl:function(d){
    if(d.link != ""){
      return d.link;
    }else{
      arr = d.loc.slice(0,d.count);
      return "http://"+this.readuser+".mysites.com/"+arr.join("/");
    }
  },
  makeWidgetContent: function() {
    var navitems = [];
    var loc = document.location.href;
    loc = loc.gsub(".mysit.es","").gsub(".mysites.com","").gsub("http://","").split("/");
    loc = $(loc).without("");

    this.readuser = loc[0];
    this.writeuser = write_user_model_data.username;

    loc[0] = "";
    loc = $(loc).without("");   
  
navitems.push(Builder.node('div',{style:"float:left;margin-left:10px;margin-right:10px;"},[TN("/")]));
navitems.push(this.makeLink({text:"Home",link:"http://www.mysites.com",loc:loc,count:99+1}));

if(this.readuser != "www"){
navitems.push(Builder.node('div',{style:"float:left;margin-left:10px;margin-right:10px;"},[TN("/")]));
navitems.push(this.makeLink({text:this.readuser,link:"http://"+this.readuser+".mysites.com",loc:loc,count:99+1}));
navitems.push(Builder.node('div',{style:"float:left;margin-left:10px;margin-right:10px;"},[TN("/")]));
}

    $(loc).each(function(el,i){  
      var data = el;      
      if(data.indexOf("-") === 0){
        data = data.substr(1,data.length);
        if(loc[0] == "-"){
          data = "/"  
        }
      };
      var nitem = this.makeLink({text:data,link:"",loc:loc,count:i+1});
      navitems.push(nitem);
navitems.push(Builder.node('div',{style:"float:left;margin-left:10px;margin-right:10px;"},[TN("/")]));
    }.bind(this));

if(this.readuser != "www"){
    navitems.pop();
}
    var txt = (logged_in ?  translateText({path: ".nm-sia", id: "Home"}): translateText({path: ".nm-sia", id: "Welcome"}));
    var home = this.makeLink({text:txt.innerHTML,link:"http://www.mysites.com/",loc:loc});  
    navitems.push(Builder.node('div',{style:"clear:both;"}));
    return Builder.node('div',{id:"topnavi",style:""},navitems);
  }
}
Object.extend(BreadcrumbWidget.prototype, WidgetCommon); 
;

// /8::/202::/core:js -> <445235> linklistwidget.js 

LinkListWidget = Class.create();
LinkListWidget.prototype = {
	defaultOptions: function() {
		return {
			_widgetid:"LinkListWidget",
			id:"ll",
			register:false,
			links:[],
			style:"",
			style2:""
		};
	},
	makeWidgetContent:function(){		
		var nodesul = Builder.node('ul',{className:"main_linklist"},[]);
		this.options.links.each(function(link){
			var linkdiv = Builder.node('div',{style:"width:auto;float:left;"},[link]);
			var linknode = Builder.node('li',{style:this.options.style},[linkdiv]);
			nodesul.appendChild(linknode);
		}.bind(this));
		nodesul.appendChild(Builder.node('div',{className:"clearer"},[]));
		return Builder.node('div',{style:this.options.style2+""},[nodesul,Builder.node('div',{className:"clearer"})]);
	}
}
Object.extend(LinkListWidget.prototype, WidgetCommon);   
;

// /8::/202::/core:js -> <445430> loginwidget.js 

LoginWidget = Class.create();
LoginWidget.prototype = {
  defaultOptions: function(){
    return {
      caption:TN("BUTTON"),
      onClickAction:function(e){},
      width:147
    }
  },
  setup:function(){
/*
    if(logged_in){
        var loginForm = Builder.node('form', {
          style: 'display:none;',
          method: "post", 
          action: serviceLink({
            user: "www",
            service: "main",
            controllerName: "account",
            action: "login"
          })
        }, $H({
            desired_url: serviceLink({
              user: "everyone",
              service: "main"
            }),
            desired_service: "main@core",
            username: reg.username,
            password: reg.password
          }).map(function(pair) {
            return Builder.node('input', {
              type: "hidden",
              name: pair.key,
              value: pair.value
            })
          })
        )
        $(document.body).appendChild(loginForm)
        loginForm.submit();
      }
*/
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  over:function(t,i){
    $(t).setStyle({background:"url("+this.imageurl(i)+")"});
  },
  out:function(t,i){
     $(t).setStyle({background:"url("+this.imageurl(i)+")"});
  },
   
  makeWidgetContent: function(){
    var width = this.options.width;

    var bstyle = "width:"+width+"px;height:26px;overflow:hidden;position:relative;top:0px;cursor:pointer;";
    var txtstyle = "background:transparent;border:0px;color:white;line-height:20px;margin:2px;margin-top:3px;text-align:left;text-decoration:none;font-size:12px;";

    var bg = "background:url("+ this.imageurl("input.png") +");"

    var username = Builder.node('input',{name:"username",id:"username",style:"width:"+(width-6)+"px;"+txtstyle+bstyle,type:"text",value:"Username"});
    var password = Builder.node('input',{name:"password",id:"password",style:"width:"+(width-6)+"px;"+txtstyle+bstyle,type:"password",value:"@@@@@@@@"});

    var user = Builder.node('div',{style:txtstyle+bstyle+bg+"clear:both;"},[
      username
    ]);
    var pass = Builder.node('div',{style:txtstyle+bstyle+bg+"clear:both;"},[
       password
    ]);

    Event.observe($(password),'focus',function(){
      if($F(password) == "@@@@@@@@" ){
        $(password).setAttribute("value","");
        $(password).value = "";
      }
    }.bind(this));
    Event.observe($(password),'blur',function(){
      if($F(password) == "" ){
       $(password).setAttribute("value","@@@@@@@@");
       $(password).value = "@@@@@@@@";
      }
    }.bind(this));

    Event.observe($(username),'focus',function(){
      if($F(username) == "Username" ){
        $(username).setAttribute("value","");
        $(username).value = "";
      }
    }.bind(this));
    Event.observe($(username),'blur',function(){
      if($F(username) == "" ){
        $(username).setAttribute("value","Username");
        $(username).value = "Username";
      }
    }.bind(this));

    var ls = "font-weight:bolder;line-height:26px;text-align:center;";
    ls += "width:56px;height:26px;color:white;font-size:12px;";

    this.logininner = Builder.node('div',{style:ls},[TN("Login")]);
    this.fbinner = Builder.node('div',{style:"width:29px;height:26px;"},[]);

    Event.observe($(this.logininner),'mouseover',function(e){
      this.over(this.logininner,"login-o.png");
    }.bind(this));
    Event.observe($(this.logininner),'mouseout',function(e){
      this.out(this.logininner,"login-n.png");
    }.bind(this));
    Event.observe($(this.logininner),'mousedown',function(e){
      this.out(this.logininner,"login-n.png");
    }.bind(this));
    Event.observe($(this.logininner),'mouseup',function(e){
      this.over(this.logininner,"login-o.png");
    }.bind(this));
    Event.observe($(this.logininner),'click',function(e){
      $("loginf").submit();
    }.bind(this));

    Event.observe($(this.fbinner),'mouseover',function(e){
      this.over(this.fbinner,"fb-o.png");
    }.bind(this));
    Event.observe($(this.fbinner),'mouseout',function(e){
      this.out(this.fbinner,"fb-n.png");
    }.bind(this));
    Event.observe($(this.fbinner),'mousedown',function(e){
      this.out(this.fbinner,"fb-n.png");
    }.bind(this));
    Event.observe($(this.fbinner),'mouseup',function(e){
      this.over(this.fbinner,"fb-o.png");
    }.bind(this));
    Event.observe($(this.fbinner),'click',function(e){
      document.location = "http://www.mysites.com/facebook";

    }.bind(this));

    this.out(this.logininner,"login-n.png");
    this.out(this.fbinner,"fb-n.png");


    this.login = Builder.node('div',{style:"margin:3px;cursor:pointer;width:56px;height:26px;"},[
      this.logininner
    ]);
    this.fb = Builder.node('div',{style:"margin:3px;cursor:pointer;width:29px;height:26px;"},[
      this.fbinner
//(new simpleFBLoginWidget().htmlNode())
    ]);

    var theform = Builder.node('form',{id:"loginf",name:"loginf",action:"http://www.mysites.com/login",method:"post"},[
      Builder.node('div',{},[
        Builder.node('div',{style:"width:160px;float:left;"},[user]),
        Builder.node('div',{style:"width:160px;float:left;"},[pass]),
        Builder.node('div',{style:"width:70px;float:left;"},[this.login]),
        Builder.node('div',{style:"width:50px;float:left;"},[this.fb]),
        Builder.node('div',{style:"clear:both;"},[])
      ])
    ]);

    Event.observe($(theform),'submit',function(e){
      if($F("password") == "" || $F("password") == "@@@@@@@@" 
        || $F("username") == "" || $F("username") == "Username"){
        Event.stop(e);
        $(password).setStyle({border:"1px solid red"});
        $(username).setStyle({border:"1px solid red"});
        return false;
      }else{
        
      }
      return true;
    });


    var formdiv = Builder.node('div',{style:""},[theform]);

    return formdiv;
  }
}  
Object.extend(LoginWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <6278> searchdisplaymodel.js 

SearchDisplayModelCommon = {}
Object.extend(SearchDisplayModelCommon, DisplayModel.prototype)
Object.extend(SearchDisplayModelCommon,  {
  changeToFolder: function(p) { 
    if (this.noChangeFolder) { return }
    //startIdle();
    var instance = this
    var ar = (new AjaxFormBuilder({
      user: this.user(),
      service: this.service(),
      action: this.queryDataAction(),
      onSuccessfulSubmit: function(afb, success) {
        try {
          instance.data = success
          instance.version = changeCounter()
          instance.notifyObservers("afterPathChanged")
          instance.update()
          //endIdle()
        } catch (e) {
          //endIdle()
          handleUpdateException(e)
          throw e
        }
      }
    }))
    ar.performAjaxRequest({
      q:this.options.q,
      form_username_override: this.user()
    })
  }
})

SearchDisplayModel = Class.create();
SearchDisplayModel.prototype = {
defaultOptions: function() {return Object.extend({q:null},arguments||{})},
queryDataAction: function() { return "search_json" }
}
Object.extend(SearchDisplayModel.prototype, SearchDisplayModelCommon) 
;

// /8::/202::/core:js -> <448478> sharebutton.js 

ShareButtonWidget = Class.create();
ShareButtonWidget.prototype = {
  defaultOptions: function(){
    return {
      caption:TN("BUTTON"),
      onClickAction:function(e){},
      width:100,
      item:null,
      buttons:[
        {
          caption:"Twitter",
          y:0,
          link:"http://twitter.com/?status=TITLE: URL"
        },{
          caption:"Reddit",
          y:22,
          link:"http://reddit.com/submit?url=URL&title=TITLE"
        },{
          caption:"Google",
          y:44,
          link:"http://www.google.com/bookmarks/mark?op=edit&bkmk=URL&title=TITLE"
        },{
          caption:"Delicious",
          y:66,
          link:"http://del.icio.us/post?url=URL"
        },{
          caption:"Digg",
          y:88,
          link:"http://digg.com/submit?phase=2&url=URL&title=TITLE"
        }
      ]
    }
  },
  setup:function(){
    this.options.onClickAction = function(){
      alert(this.options.item.name);
    }.bind(this);
  },
  over:function(e){

  },
  out:function(e){

  },
  selected:function(e){

  },
  makeIcon:function(o){
    var s = "margin-left:8px;width:20px;height:20px;float:left;";
    s += "background:url("+this.imageurl("icons-select.png")+") 0px -"+o.y+"px;";
    s+= "margin-right:3px;";
    var ico = Builder.node('div',{style:s},[])
    return ico;
  },
  makeButton:function(o){
    var s = "width:50px;float:left;line-height:20px;font-size:12px;color:#9e0b0f;";
    var s2 = "margin-left:6px;width:93px;margin-bottom:1px;cursor:pointer;";

    var btn = Builder.node('div',{style:s2},[
      this.makeIcon(o),
      Builder.node('div',{style:s},[TN(o.caption)]),
      Builder.node('div',{style:"clear:both;"},[])
    ]);
    var URL = itemModel.currentPathPermalink(this.options.item)+"?static-only=1";
    var TITLE = escape(this.options.item.name);
    var LINK = o.link.replace("URL",URL).replace("TITLE",TITLE);;
    var b = Builder.node('a',{
      style:"width:100%;height:100%;background:white;color:#9e0b0f;",
      href:LINK,
      target:"_blank"
    },[btn]);
    return b;
  },
  makeOverlay:function(){

    var s = "";
    s += "background:url("+this.imageurl("select-bg.png")+");";
    s += "font-size:13px;color:#9e0b0f;font-weight:bolder;overflow:hidden;";

    this.overlay = Builder.node('div',{style:s+"width:105px;height:122px;padding-top:8px;"},[]);
    $(this.options.buttons).each(function(btn){
      var b = this.makeButton(btn);

      Event.observe($(b),'mouseover',function(e){
        $(b).down().setStyle({background:"#313437",color:"white"});
      });
      Event.observe($(b),'mouseout',function(e){
        $(b).down().setStyle({background:"white",color:"#9e0b0f"});
      });
      //Event.observe($(b),'click',function(e){   
        //this.options.onClickAction();
      //}.bind(this));

      this.overlay.appendChild(b);
    }.bind(this));
    return this.overlay;
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  makeWidgetContent: function(){
    var btnwrapper = Builder.node('div',{style:"float:right;"},[this.makeOverlay()]);
    return btnwrapper;
  }
}  
Object.extend(ShareButtonWidget.prototype, WidgetCommon);
Object.extend(ShareButtonWidget.prototype, Observable);

;

// /8::/202::/core:js -> <218758> simple-translations-core.js 


;

// /8::/202::/core:js -> <203569> simple.js 

String.prototype.reflexive = function() {
if (this.endsWith("s")) { return this.substr(0) }
return this + "'s"
}




DisplayModel.prototype.userForItem = function(m){
if(this.users()[m.account_id] == undefined){
return read_user_model_data.username
}
return (this.users()[m.account_id].username != undefined ? this.users()[m.account_id].username : "read_user_model_data.username")
}


var helpTexts = {};
helpTexts.helperNode = function(){};

Tooltip = Class.create();
Tooltip.prototype = {
initialize: function(className) {}
}

document.observe("dom:loaded", function() {

if(read_user_model_data.username == "guest"){
var redd = Builder.node('div');
redd.innerHTML = '<a href="http://www.reddit.com/r/IAmA/comments/c99pc/by_request_i_am_someone_who_works_with_a_file">Hello Reddit!</a>';
document.body.appendChild(redd);
}

  $("root").down().setStyle({display:"none"});
  $(document.body).setStyle({margin:"0px",padding:"0px"});

  if(parameters().login_error){   
    window.setTimeout(function(){
       makeNotification("Login Error!<br/>Recheck your username and password!")
    }.bind(this),2000);
  }
});


function makeNotification(msg){
    var close = Builder.node('div',{style:"position:relative;top:0px;float:right;top:-40px;cursor:pointer;width:17px;height:16px;"},[TN("x")]);
    Event.observe($(close),'click',function(e){
        Effect.Fade($(notification),{afterFinish:function(){
          Effect.SlideUp($(layoutwidget.contenthead));
        }});        
    }.bind(this));

    var guestinfo = msg;


    var info = Builder.node('div',{style:"font-size:10px;"},[]);
    info.innerHTML = guestinfo;

    var notification = Builder.node('div',
{style:";position:absolute;width:858px;height:88px;background:#FF512F;border:1px solid #CF2200;"},
[Builder.node('div',{style:"position:relative;margin:10px;width:auto;font-size:150%;"},[info,close])]);

    notification.hide();
    window.setTimeout(function(){
      Effect.Appear($(notification));
    }.bind(this),500);

   $("myhead").innerHTML = "";
   $("myhead").appendChild(notification);
   $("myhead").setStyle({height:"90px",marginBottom:"20px"});
}


function hideAllTooltips(){};

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')]
        )
    }

var shareModel;
function onSimpleUploadEvent(e){
    var dat = e.split("onUploadEvent:")[1];
    var v = window.eval("("+dat+")");

    //all files uploaded.. do post-upload stuff
    if(v.data == "DONE"){
      //alert("done");
      try{
        // theuploadernode.remove();
        window.setTimeout(function(){
          document.location = "http://"+write_username+".mysites.com/";
        }.bind(this),1000);
      }catch(e){}
    }
};

function makeSimpleButton(b){
  var btn = Builder.node('div',{style:"cursor:pointer;text-align:center;color:white;font-weight:bolder;font-size:14px;background:url("+serviceLink({user: "core",service: "files@core",action:"get_file?path=/bluebtn.png"})+");margin:3px;line-height:26px;width:100px;height:26px;"},[
    b
  ]);
  return btn;
}

function initShareModel(){

    shareModel = new DisplayModel({service:"share@mike",user:"mike"});   
    var shareobs = {}; 
    shareobs.afterPathChanged=function(){
        shareModel.notifyObservers("loaded");
        simplefavicon.change("http://www.mysites.com/core-services/myfavi.ico");
        $(document).title = "MySites";
    }.bind(this)
    shareModel.observeOnce(shareobs); 

    $(document.body).setStyle({margin:"0px"});
    $("root").down().setStyle({display:"none"});

if (logged_in) {
        var dm = new DisplayModel({
            user: writeUserModel.data.username,
            service: "profiles"
         })
        dm.observeOnce({update: function() {
            var lang = dm.preferences().lang
            if (lang) {
                setLanguage(lang)
            } else if (parameters().lang ) {
                setLanguage(parameters().lang)
                var prefs = 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)
        //}
     }

}

var sdloader;
function initDataLoader(){

window.fbAsyncInit = function() {
    FB.init({appId: '92d5008711f9c77376aadda711c9f49c', status: true, cookie: true,
             xfbml: true});
    FB.Event.subscribe('auth.sessionChange', function(response) {
      if (response.session) {
        // A user has logged in, and a new cookie has been saved
        facebook_onlogin();
      } else {
        // The user has logged out, and the cookie has been cleared
      }
    });
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    $(document.body).appendChild(e);
  }());

   sdloader = new simpleDataLoaderWidget();
}


//item and fodler permalinks
function displayItemSimple(m) {
    initDataLoader();
    //initShareModel();
    //$(document.body).innerHTML = "";
    //var sidw = new simpleItemPageWidget({m:m});
    //$(document.body).appendChild(new simpleHeaderWidget().htmlNode());
    //$(document.body).appendChild(sidw.htmlNode());
    //simpleDisplayItem($(sidw.itemcontent.node), m);
    //if(is_developer){
      var ip = new ItemPageWidget({item:m});
      $(document.body).appendChild(ip.htmlNode());
      simpleDisplayItem($(ip.itemcontent), m);
    //}    
}


function folderPermalink(m) {
    initDataLoader();
    initShareModel();
    //$(document.body).innerHTML = "";   
    //$(document.body).appendChild(new simpleHeaderWidget().htmlNode());
    //$(document.body).appendChild(new simpleFolderPageWidget({m:m}).htmlNode());
    //if(is_developer){
      var ip = new ItemPageWidget({item:m});
      $(document.body).appendChild(ip.htmlNode());
     // simpleDisplayItem($(ip.itemcontent.node), m);
    //}
}
;

// /8::/202::/core:js -> <204257> simplealbumcontrolswidget.js 

simpleAlbumControlsWidget = Class.create();
simpleAlbumControlsWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({buddies:[],height:200},arguments[0]);
  },
  setup:function(){
    
  },
  makeSorter:function(sort){
    var txt = translateText({path: ".nm-ac", id:sort.name})
    var opt = Builder.node('option',{value:sort.value+";"+sort.reverse},[TN(txt.innerHTML)]);
    opt.doreverse = sort.reverse;
    return opt;
  },
  selectDropdownOption:function(element,text){
    try{
      for (var i=0; i < element.options.length; i++){
        if (element.options[i].value == text) {
          element.options[i].selected = true;
        } else {
          element.options[i].selected = false;
        }
      }
    }catch(e){}
  },
  makeAllSorters:function(t,sorters,evt){
   var sel = Builder.node('select',{style:"font-size:12px;font-family:Trebuchet MS;padding:1px;"},[]);
    Event.observe($(sel),'change',function(e){
      this.notifyObservers(evt,$(sel)[$(sel).selectedIndex].value);
    }.bind(this));
    $(sorters).each(function(sort){
      $(sel).appendChild(this.makeSorter(sort));
    }.bind(this));
    var c = Builder.node('div',{style:"clear:both;"},[]);
    this.seldesc = Builder.node('div',{style:"float:left;margin-right:10px;"},[t]);
    this.selnode = Builder.node('div',{style:"float:left;margin-right:10px;"},[sel]);
    return Builder.node('div',{style:"float:left;margin-right:10px;"},[this.seldesc,this.selnode,c]);
  },
  makeServiceSelection:function(){
    var sorters = [
      {reverse:false,value:"",name:"All File Types"},
      {reverse:false,value:"picture",name:"Pictures Only"},
      {reverse:false,value:"movie",name:"Videos Only"},
      {reverse:false,value:"tune",name:"Music Only"}
    ];
    return Builder.node('div',{style:"float:left;margin-right:10px;"},[
      this.makeAllSorters(translateText({path: ".nm-ac", id: "Show"}),sorters,"serviceChanged")
    ]);
  },
  makeSortingSelection:function(){
    var sorters = [
      {reverse:true,value:"newest",name:"newest"},
      {reverse:false,value:"oldest",name:"oldest"},
      {reverse:false,value:"name",name:"a-z"},
      {reverse:true,value:"name",name:"z-a"}
//,{reverse:false,value:"type",name:"type"}
    ];
    return Builder.node('div',{style:"float:left;margin-right:10px;"},[
      this.makeAllSorters(translateText({path: ".nm-ac", id: "Sort by"}),sorters,"sortingChanged")
    ]);
  },
  makeWidgetContent: function(){ 

    var sorting = this.makeSortingSelection();
    var sselection = this.makeServiceSelection();
    var c = Builder.node('div',{style:"clear:both;"},[]);
    this.wrapper = Builder.node('div',{style:"margin-bottom:20px;height:100%;"},[
      sselection,
      sorting,
      c,BR()
    ]);
    window.setTimeout(function(){
      //try{
        this.selectDropdownOption($(sorting).down(4),"newest;true");
        this.selectDropdownOption($(sselection).down(4),";false");
      //}catch(e){}
    }.bind(this),500);
    return this.wrapper;

  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleAlbumControlsWidget.prototype, WidgetCommon);
Object.extend(simpleAlbumControlsWidget.prototype, Observable);
;

// /8::/202::/core:js -> <204256> simplealbumnavigationwidget.js 

simpleAlbumNavigationWidget = Class.create();
simpleAlbumNavigationWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({uploadmode:false,displayItemClicked:null,model:itemModel},arguments[0]);
  },
  setup:function(){

    sdloader.observeOnce(this);

    window.setTimeout(function(){
      if(sdloader.loader != null){
        this.loadedItems(sdloader);
      }      
    }.bind(this),250);

window.setTimeout(function(){
this.checkAlbums();
}.bind(this),4000);

    this.theitems = this.options.model.items();

    //if(this.options.uploadmode ){

      sdloader.observeOnce(this);

      window.setTimeout(function(){
        if(sdloader.loader != null){
          this.loadedItems(sdloader);
        }      
      }.bind(this),250);
    //}
  },
  setItems:function(itms){
    this.theitems = itms;
    window.setTimeout(function(){
      this.rerender()      
    }.bind(this),250);
  },
  loadedItems:function(d){
    this.options.model = d.loader;
    this.theitems = this.options.model.items();
    this.setItems(this.theitems);
  },
  makeWidgetContent: function(){ 

    var d = this.theitems;    

    var folders = [];

    $(d).each(function(itm){

if(itm.type != undefined && itm.name != "trash"){
      if(itm.type == "folder"){

        var anchor = Builder.node('a',{
          style:"text-decoration:none;color:black;font-size:16px;font-weight:bolder;",
          href:this.options.model.currentPathPermalink(itm)
          },[TN(itm.name)]);

        if(itm.permission == "onlyme"){
          var icon = Builder.node('img',{
            width:24,
            height:24,
            style:"",
            src:"http://core.myfil.es/get_file/social/001-42.png",
            border:"0"
          });
        }else{
          var icon = Builder.node('img',{
            width:24,
            height:24,
            style:"",
            src:"http://core.myfil.es/get_file/social/trans.png",
            border:"0"
          });
        }

        var fldr = Builder.node('div',{
          style:"padding:5px;background:transparent;height:24px;margin-bottom:5px;clear:both;"},[
Builder.node('div',{style:"width:25px;height:25px;float:left;margin-right:10px;"},[icon]),
Builder.node('div',{style:"width:200px;overflow:hidden;height:25px;float:left;"},[anchor]),
Builder.node('div',{style:"clear:both;"},[])
]);

Event.observe($(fldr),'mouseover',function(e){
$(fldr).setStyle({background:"#DFDFDF"});
}.bind(this));
Event.observe($(fldr),'mouseout',function(e){
$(fldr).setStyle({background:"transparent"});
}.bind(this));

        if(this.options.displayItemClicked != null){
          $(anchor).setAttribute("href","javascript:void(0);");
          Event.observe($(fldr),'click',function(e){
            this.options.displayItemClicked(itm);
          }.bind(this));
        }
        folders.push(fldr);
      }
}
    }.bind(this));

    if(folders.length == 0){
      folders.push(Builder.node('img', {src: "/images/spinner.gif"}));
    }

    return Builder.node('div',{id:"albums",style:"font-weight:bolder;font-size:16px;"},folders);
  }, 
  checkAlbums:function(){
    if(this.theitems.length <= 0){
try{
      $("albums").innerHTML = ""
      $("albums").appendChild(TN("no albums found"));
}catch(e){};
    }
  },
  rerender: function(){
    var nc = this.makeWidgetContent()
    this.replaceChild(this.content, this.widgetContent, nc)
    this.widgetContent = nc
  }
}  
Object.extend(simpleAlbumNavigationWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <216400> simplearticlewidget.js 

simpleArticleWidget = Class.create();
simpleArticleWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({model:writeUserModel},arguments[0]);
  },
  saveItem:function(o){
      var m ={
        name:o.name,
        type:"Article",
        display_type:"article",
        permission:o.permission,
        content_type:"text/html",
        body:o.body
      };
      //if(o.name == ""){
      //  delete m.name;
      //}

      var obs = {update:function(){
          document.location = document.location.href
//this.rerender();
      }.bind(this)};

      this.options.model.createItem(m);
      this.options.model.observeOnce(obs);
      
  },
  makeWidgetContent: function(){  
    this.title = Builder.node('div',[
Builder.node('input',{id:"pastetitle",type:"text",style:"padding:9px;font-family:Trebuchet MS;font-weight:bolder;border:1px solid silver;width:100%;margin-bottom:10px;",value:"Title"},[])
]);
    $(this.title).setOpacity(0.3);
    Event.observe($(this.title),'click',function(){
      $(this.title).setOpacity(1);     
    }.bind(this));

    var txta = Builder.node('div',{style:"padding:10px;border:1px solid silver;width:500px;height:200px;overflow:auto;"},[
Builder.node('textarea',{id:"pastetxt",style:"font-family:Trebuchet MS;border:0px;width:100%;height:97%;"},[])
    ]);

    var b = Builder.node('div',{style:"margin-right:20px;float:left;width:100px;height:40px;"},[
      Builder.node('input',{
        type:"button",className:"bigbutton",
        style:"width:100px;height:40px;",
        value:"Paste!"
      })
    ]);

    Event.observe($(b),'click',function(e){
      var body = $F("pastetxt");
      var title = $F("pastetitle");
      $("pastetitle").setStyle({border:"1px solid silver"});
      $("pastetxt").up().setStyle({border:"1px solid silver"});
      if(title == "" ){
        $("pastetitle").setStyle({border:"1px solid red"});
        return false;
      }
      if(body == ""){
        $("pastetxt").up().setStyle({border:"1px solid red"});
        return false;
      }

      var formatting = $F("formatting");

      if(formatting == "noformat"){
         body = body.replace(/\n/g,"<br/>");
      }else{
         body = '<pre class="sh_'+formatting+'">'+body+'</pre>';
      }
     

this.saveItem({name:title.replace("Title",""),body:body,permission:Form.getInputs('pasteform','radio','permission').find(function(radio) { return radio.checked; }).value
});    
    }.bind(this));

    var perms = Builder.node('div',{style:"margin-top:10px;font-weight:bolder;font-family:Trebuchet MS;float:left;width:210px;font-size:20px;margin-right:20px;"},[Builder.node('input',{type:"radio",checked:"checked",name:"permission",value:"everyone"}),Builder.node('label',[TN("Public")]),NBSP(),NBSP(),Builder.node('input',{type:"radio",name:"permission",value:"onlyme"}),Builder.node('label',[TN("Private")])]);
    var hl = Builder.node('div',{style:"font-size:20px;font-family:Trebuchet MS;float:left;width:150px;"},[
      Builder.node('select',{id:"formatting",style:"font-size:16px;font-family:Trebuchet MS;padding:5px;"},[
       Builder.node('option',{value:"ruby"},[TN("Ruby")]),
       Builder.node('option',{value:"flex"},[TN("Actionscript")]),
       Builder.node('option',{value:"php"},[TN("PHP")]),
       Builder.node('option',{value:"javascript"},[TN("Javascript")]),
       Builder.node('option',{value:"noformat"},[TN("no formatting")]),
      ])
    ]);

    var c = Builder.node('div',{style:"clear:both;"});
    var cont = Builder.node('div',{style:"height:40px;"},[b,perms,hl,c]);

    return Builder.node('div',{className:"mypaste",style:"width:500px;"},[
      Builder.node('form',{id:"pasteform"},[this.title,txta,BR(),cont])
    ]);;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleArticleWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <199075> simplebadgewidget.js 

simpleBadgeWidget = Class.create();
simpleBadgeWidget.prototype = {
  defaultOptions: function(){
    return {
      status:false,
      width:200,
      height:80,
      iconsize:32,
      mode:"horizontal",
      icon:true,
      fontsize:"140%",
      usermodel:current_user_model
    }
  },
  setup:function(){
//only for profile badge
if(this.options.usermodel.username == write_user_model_data.username){
    writeUserModel.addObserver({profileChanged:function(d,data){

this.options.usermodel = Object.extend(this.options.usermodel,data);
this.redrawCompletely();

    }.bind(this)});
}
  },
  makeIcon:function(s){
    if(!this.options.icon){
       return EMPTY();
    }else if(!this.options.usermodel.userimage){

      this.icon = Builder.node('div',{style:s+"position:relative;overflow:hidden;border:4px solid silver;width:"+this.options.iconsize+"px;height:"+this.options.iconsize+"px;margin-right:10px;"},
      [Builder.node('div',
        {style:"top:-"+((127/2)-this.options.iconsize/2)+"px;left:-"+((190/2)-this.options.iconsize/2)+"px;position:relative;background:url(http://core.myfil.es/get_file/social/q.png);width:190px;height:127px;"},[])
      ]);
      //return this.icon;
    }else{
      this.icon = Builder.node('div',{style:s+"position:relative;overflow:hidden;border:4px solid silver;width:"+this.options.iconsize+"px;height:"+this.options.iconsize+"px;margin-right:10px;"},
      [Builder.node('div',
        {style:"top:-"+((127/2)-this.options.iconsize/2)+"px;left:-"+((190/2)-this.options.iconsize/2)+"px;position:relative;background:url("+this.options.usermodel.userimage.gsub("get_file","get_thumbnail")+");width:190px;height:127px;"},[])
      ]);    
    }
    return this.icon;
  },  
  makeStatus:function(){
    if(this.options.status){
      return Builder.node('div',{style:"height:15px;width:"+((this.options.width*1)/2)+"px;overflow:hidden;font-weight:normal;font-size:10px;"},[TN(this.options.usermodel.status_message)]);
    }else{
      return EMPTY();
    }
  },
  makeInfo:function(s){
    var uname = Builder.node('a',
      {href:"http://"+this.options.usermodel.username+".mysites.com",
      style:"text-decoration:none;color:black;cursor:pointer;font-weight:bolder;font-size:"+this.options.fontsize+";"},
        [
TN(this.options.usermodel.username)
//,(this.options.usermodel.status_message ? this.makeStatus() : EMPTY())
]);

    this.info = Builder.node('div',
      {style:s+"line-height:20px;font-size:14px;overflow:hidden;"},
        [uname]);    

    return this.info;
  },
  makeWidgetContent: function(){
    var c = Builder.node('div',{style:"clear:both;"});
    
    if(this.options.mode == "horizontal"){
      var badgearray = [this.makeIcon("float:left;"),this.makeInfo("float:left;"),c];
    }else{
      var badgearray = [this.makeIcon("margin 0 auto;"),this.makeInfo("")];
    }
    this.badge = Builder.node('div',
    {
     style:"position:relative;top:-3px;color:black;border:0px solid transparent;z-index:9980;width:"+this.options.width+"px;height:"+this.options.height+"px;"},
        badgearray);

    return Builder.node('a',{style:"overflow:hidden;width:"+this.options.width+"px;color:black;cursor:pointer;",href:"http://"+this.options.usermodel.username+".mysites.com"},[this.badge,Builder.node('div',{style:"clear:both;"})]);
  },
  rerender: function(){
    var nc = this.makeWidgetContent();
    this.replaceChild(this.content, this.widgetContent, nc);
    this.widgetContent = nc;
  }
}  
Object.extend(simpleBadgeWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <436809> simplebrowserdetect.js 

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

};
BrowserDetect.init();
;

// /8::/202::/core:js -> <426668> simplecarouselwidget.js 

simpleCarouselWidget = Class.create();
simpleCarouselWidget.prototype = {
	defaultOptions: function() {
		return {
			_widgetid:"simpleCarouselWidget",
			auto:false,
			id:"0",
			slidewidth:300,
			slideheight:150,
			slides:[
				{text:"",node:TN("Slide1")},
				{text:"",node:TN("Slide2")},
				{text:"",node:TN("Slide3")}
			],
			slidecount:0
		}
	},
	setup:function(){
		this.options.slidecount = this.options.slides.length;		
	},
	makeOneSlide:function(con,c){
		var innernode = Builder.node('div',{className:"slide_content",style:"padding:5px;margin:0 auto;width:"+(this.options.slidewidth-40)+"px;"},[con.node]);
		var slide = Builder.node('div',{className:"slide"+this.options.id,id:"slide-"+c+this.options.id,style:"font-size:120%;float: left;width:"+this.options.slidewidth+"px;height:"+this.options.slideheight+"px;"},[innernode]);
		return slide;
	},
	makeWidgetContent:function(){
		//border:1px solid silver;background: transparent url(../images/bit_bshine.png) -165px -165px no-repeat;"
		var s = Builder.node('div',{id:"scroller"+this.options.id,style:"text-align:left;width:"+this.options.slidewidth+"px;height:"+this.options.slideheight+"px;overflow: hidden;float:left;"},[]);
		this.cont = Builder.node('div',{id:"content"+this.options.id,style:"width:"+(this.options.slidecount * this.options.slidewidth)+"px"},[]);
		$(s).appendChild(this.cont);
	
		$(this.options.slides).each(function(slide,c){
			this.slidenode = this.makeOneSlide(slide,c);
			$(this.cont).appendChild(this.slidenode);
		}.bind(this));

		//this.borderw = BitCap.ShadedBorder.create({ corner:6,border:2});	
		//this.borderw.render($$("div.slide_content"));
		var icon1 = Builder.node('div',[TN("IXO")]);//BitCap.imageSlice({x:7,y:1},{x:8,y:5});
		$(icon1).setStyle({position:"relative",top:(( this.options.slideheight / 2 )-29)+"px"});
		this.controlnext =  Builder.node('div',{style:"border-left:1px solid #3B3C3F;position:relative;float:left;height:"+this.options.slideheight+"px"},[Builder.node('a',{href:"javascript:void(0);",rel:"next",className:"carousel-control"+this.options.id,style:""},[icon1])]);
		$(this.controlnext).setOpacity(0.5);
		Event.observe($(this.controlnext),'mouseover',function(e){
			$(this.controlnext).setOpacity(0.9);
		}.bind(this));
		Event.observe($(this.controlnext),'mouseout',function(e){
			$(this.controlnext).setOpacity(0.5);
		}.bind(this));
		var icon2 = Builder.node('div',[TN("IXO")]);//BitCap.imageSlice({x:5,y:1},{x:6,y:5});
		$(icon2).setStyle({position:"relative",top:(( this.options.slideheight / 2 )-29)+"px"});
		this.controlprev = Builder.node('div',{style:"border-right:1px solid #3B3C3F;position:relative;float:left;height:"+this.options.slideheight+"px"},[Builder.node('a',{href:"javascript:void(0);",rel:"prev",className:"carousel-control"+this.options.id,style:""},[icon2])]);
		$(this.controlprev).setOpacity(0.5);
		Event.observe($(this.controlprev),'mouseover',function(e){
			$(this.controlprev).setOpacity(0.9);
		}.bind(this));
		Event.observe($(this.controlprev),'mouseout',function(e){
			$(this.controlprev).setOpacity(0.5);
		}.bind(this));
	
		$(document.body).appendChild(Builder.node('div',{id:"carousel"+this.options.id,style:"position:relative;overflow:hidden;text-align:center;margin:0 auto;width:"+(60+this.options.slidewidth)+"px;height:"+(this.options.slideheight+20)+"px;"},[this.controlprev,s,this.controlnext,Builder.node('div',{className:"clearer"})]));
	
		window.setTimeout(function(e){
			this.carousel = this.initCarousel($('scroller'+this.options.id), $$('.slide'+this.options.id), $$('a.carousel-jumper'+this.options.id, 'a.carousel-control'+this.options.id), {auto:this.options.auto,duration:1,beforeMove:function(){$("content"+this.options.id).setOpacity(0.5);return;}.bind(this),afterMove:function(){$("content"+this.options.id).setOpacity(1);return;}.bind(this)});
		}.bind(this),100);
	
		this.finalnode = $("carousel"+this.options.id);	
		return this.finalnode;
	},
	initCarousel: function (scroller, slides, controls, options) {

		this.scrolling	= false;
		this.scroller	= scroller;
		this.slides		= slides;
		this.controls	= controls;

		this.options2    = Object.extend({ duration: 1.0, frequency: 3, controlClassName: 'carousel-control'+this.options.id, jumperClassName: 'carousel-jumper'+this.options.id }, options || {});

		this.slides.each(function(slide, index) {
			slide._index = index; 
		});

		if (this.controls) {
			this.controls.invoke('observe', 'click', this.click.bind(this));
		}

		if (this.options2.auto) {
			this.start();
			this.slides.invoke('observe', 'mouseover', this.pause.bind(this));
			this.slides.invoke('observe', 'mouseout', this.resume.bind(this));
		}

	},	
	click: function (event) {

		this.stop();

		var element = event.findElement('a');

		if (!element.hasClassName('disabled')) {
			this.deactivateControls();
			if (element.hasClassName(this.options2.controlClassName)) {
				eval("this." + element.rel + "()");
			} else if (element.hasClassName(this.options2.jumperClassName)) {
				this.moveTo(element, element.rel);
			}
		}
		event.stop();

	},
	moveTo: function (trigger, element) {

		this.notifyObservers("SlideScrollStart");

		if (this.options2.beforeMove && (typeof this.options2.beforeMove == 'function')) {
			this.options2.beforeMove();
		}

		if (this.controls && this.options2.selectedClassName) {
			this.controls.each((function (elm) { elm.removeClassName(this.options2.selectedClassName); }).bind(this));
			trigger.addClassName(this.options2.selectedClassName);
		}

		this.previous= this.current ? this.current : this.slides[0];
		this.current = $(element);

		var scrollerOffset = this.scroller.cumulativeOffset();
		var elementOffset = this.current.cumulativeOffset();
		
		if (this.scrolling) {
			this.scrolling.cancel();
		}

		this.scrolling = new Effect.SmoothScroll(this.scroller, {
				transition:Effect.Transitions.SwingTo,
				duration: this.options2.duration, 
				x: (elementOffset[0] - scrollerOffset[0]), 
				y: (elementOffset[1] - scrollerOffset[1]), 
				queue: {position: 'end', limit: 1, scope: this.scroller.id}, 
				afterFinish: (function () { 
					if (this.controls) {
						this.activateControls(); 
					}
					if (this.options2.afterMove && (typeof this.options2.afterMove == 'function')) {
						this.options2.afterMove();	
					}
					this.notifyObservers("SlideScrollEnd");
				}).bind(this)});



		return false;

	},
	prev: function () {
		if (this.current) {
			var currentIndex = this.current._index;
			var prevIndex = (currentIndex == 0) ? this.slides.length - 1 : currentIndex - 1;
		} else { 
			var prevIndex = this.slides.length - 1;
		}
		this.moveTo(this.controls ? this.controls[prevIndex] : false, this.slides[prevIndex]);
	},
	next: function () {
		if (this.current) {
			var currentIndex = this.current._index;
			var nextIndex = (this.slides.length - 1 == currentIndex) ? 0 : currentIndex + 1;      
		} else {
			var nextIndex = 1;
		}		
		this.moveTo(this.controls ? this.controls[nextIndex] : false, this.slides[nextIndex]);
	},
	first: function () {
		var firstIndex = 0;
		if (this.current) {
			var currentIndex = this.current._index;
		}
		this.moveTo(this.controls[firstIndex], this.slides[firstIndex]);	
	},
	last: function () {
		var lastIndex = (this.slides.length - 1);
		if (this.current) {
			var currentIndex = this.current._index;
		}

		this.moveTo(this.controls[lastIndex], this.slides[lastIndex]);
	},	
	toggle: function () {
		if (this.previous) {
			this.moveTo(this.controls[this.previous._index], this.slides[this.previous._index]);
		} else {
			return false;
		}
	},
	stop: function () { clearTimeout(this.timer); },
	start: function () { this.periodicallyUpdate(); },		
	pause: function (event) {
		this.stop();
		this.activateControls();
	},
	resume: function (event) {
		if (event) {
			var related = event.relatedTarget || event.toElement;	
			if (!related || (!this.slides.include(related) && !this.slides.any(function (slide) { return related.descendantOf(slide); }))) {
				this.start();
			}
		} else {
			this.start();
		}
	},	
	periodicallyUpdate: function () {
		if (this.timer != null) {
			clearTimeout(this.timer);
			this.next();
		}
		this.timer = setTimeout(this.periodicallyUpdate.bind(this), this.options2.frequency * 1000);
	},
	deactivateControls: function () {
		this.controls.invoke('addClassName', 'disabled');
	},
	activateControls: function () {
		this.controls.invoke('removeClassName', 'disabled');
	}	
}
Object.extend(simpleCarouselWidget.prototype, WidgetCommon);
Object.extend(simpleCarouselWidget.prototype, Observable);


Effect.SmoothScroll = Class.create();

Object.extend(Object.extend(Effect.SmoothScroll.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;
			}
		},

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

	});


    /*
    transitions.js

    Based on Easing Equations v2.0
    (c) 2003 Robert Penner, all rights reserved.
    This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html

    Adapted for Scriptaculous by Ken Snyder (kendsnyder ~at~ gmail ~dot~ com) June 2006
    */

    /*
    Overshooting Transitions
    */
    // Elastic (adapted from “EaseOutElastic”)
    Effect.Transitions.Elastic = function(pos) {
    return -1*Math.pow(4,-8*pos) * Math.sin((pos*6-1)*(2*Math.PI)/2) + 1;
    };
    // SwingFromTo (adapted from “BackEaseInOut”)
    Effect.Transitions.SwingFromTo = function(pos) {
    var s = 1.70158;
    if ((pos/=0.5) < 1) return 0.5*(pos*pos*(((s*=(1.525))+1)*pos - s));
    return 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos + s) + 2);
    };
    // SwingFrom (adapted from “BackEaseIn”)
    Effect.Transitions.SwingFrom = function(pos) {
    var s = 1.70158;
    return pos*pos*((s+1)*pos - s);
    };
    // SwingTo (adapted from “BackEaseOut”)
    Effect.Transitions.SwingTo = function(pos) {
    var s = 1.70158;
    return (pos-=1)*pos*((s+1)*pos + s) + 1;
    };

    /*
    Bouncing Transitions
    */
    // Bounce (adapted from “EaseOutBounce”)
    Effect.Transitions.Bounce = function(pos) {
    if (pos < (1/2.75)) {
    return (7.5625*pos*pos);
    } else if (pos < (2/2.75)) {
    return (7.5625*(pos-=(1.5/2.75))*pos + .75);
    } else if (pos < (2.5/2.75)) {
    return (7.5625*(pos-=(2.25/2.75))*pos + .9375);
    } else {
    return (7.5625*(pos-=(2.625/2.75))*pos + .984375);
    }
    };
    // BouncePast (new creation based on “EaseOutBounce”)
    Effect.Transitions.BouncePast = function(pos) {
    if (pos < (1/2.75)) {
    return (7.5625*pos*pos);
    } else if (pos < (2/2.75)) {
    return 2 - (7.5625*(pos-=(1.5/2.75))*pos + .75);
    } else if (pos < (2.5/2.75)) {
    return 2 - (7.5625*(pos-=(2.25/2.75))*pos + .9375);
    } else {
    return 2 - (7.5625*(pos-=(2.625/2.75))*pos + .984375);
    }
    };

    /*
    Gradual Transitions
    */
    // EaseFromTo (adapted from “Quart.EaseInOut”)
    Effect.Transitions.EaseFromTo = function(pos) {
    if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4);
    return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2);
    };
    // EaseFrom (adapted from “Quart.EaseIn”)
    Effect.Transitions.EaseFrom = function(pos) {
    return Math.pow(pos,4);
    };
    // EaseTo (adapted from “Quart.EaseOut”)
    Effect.Transitions.EaseTo = function(pos) {
    return Math.pow(pos,0.25);
    };
;

// /8::/202::/core:js -> <195588> simplecommentswidget.js 


;

// /8::/202::/core:js -> <214708> simpledataloaderwidget.js 

simpleDataLoaderWidget = Class.create();
simpleDataLoaderWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({opts:{
service:"main",
reverse:false,
sortByColumn:"added_at",
itemsPerPage:100,
user:read_user_model_data.username
}},arguments[0]);
  },
  setup:function(){

    //write_username if we are logged in and on www
    if(document.location.toString().match("http://www.") && logged_in){
      this.options.opts.user = write_user_model_data.username
    }
    this.items = null;
    var obs = {
      update:function(){
        this.itms = this.loader.items();
window.setTimeout(function(){
        this.notifyObservers("loadedItems");
}.bind(this),500);

      }.bind(this)
    };

    this.loader = new DisplayModel(this.options.opts);
    this.loader.addObserver(obs);

  },
  makeWidgetContent: function(){  

  }, 
  rerender: function(){
   // this.redrawCompletely()
  }
}  
Object.extend(simpleDataLoaderWidget.prototype, WidgetCommon);
Object.extend(simpleDataLoaderWidget.prototype, Observable);
;

// /8::/202::/core:js -> <215569> simpledazzboardwidget.js 

simpleDazzboardWidget = Class.create();
simpleDazzboardWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({mode:"iframe",link:null,m:null,style:"normal"},arguments[0]);
  },
  initIt:function(){
    html = 'Copy files from your mobile and other sites (Windows only)<br/><iframe src="http://widget.dazzboard.com/MySites/gadget.html" width="300" height="360" scrolling="no" frameborder="0"></iframe>';

//remove for core
if(write_user_model_data.username == "core"){
html = "";
}
    this.b.innerHTML = html;
  },
  makeWidgetContent: function(){    
    if(OSName != "Windows"){ 
      return EMPTY();
    }
    this.b = Builder.node('div',{style:""},[Builder.node('img', {src: "/images/spinner.gif"})]);    
    this.wrapper = this.b;
    window.setTimeout(function(){
      this.initIt();
    }.bind(this),3000);
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleDazzboardWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <218260> simpleemphasizewidget.js 

simpleEmphasizeWidget = Class.create();
simpleEmphasizeWidget.prototype = {
  defaultOptions: function(){
    return {
      width:100,
      height:50,
      target:null
    }
  },
  setup:function(){
   this.options.width = $(this.options.target).getWidth();
   this.options.height = $(this.options.target).getHeight();
   var node = Builder.node('div',{});
   this.options.margin = $(this.options.target).getStyle("marginBottom");
   $(node).setStyle({marginBottom:this.options.margin});
   var elm = $(this.options.target).replace(node);
   $(node).wrap(this.makeBox(elm))

  },
  makeBox:function(d){

//Builder.node('div',{},[]);

return Builder.node('div',{style:"margin-bottom:"+this.options.margin+";width:"+this.options.width+"px;height:"+(this.options.height)+"px;"},[

Builder.node('div',{style:"width:"+this.options.width+"px;"},[
Builder.node('div',{style:"float:left;width:8px;height:8px;background:url(http://core.myfil.es/get_file/social/etl.png);"},[]),
Builder.node('div',{style:"float:left;width:"+((this.options.width)-2*8)+"px;height:8px;background:url(http://core.myfil.es/get_file/social/etm.png) repeat-x;"},[NBSP()]),
Builder.node('div',{style:"float:left;width:8px;height:8px;background:url(http://core.myfil.es/get_file/social/etr.png);"},[]),
Builder.node('div',{style:"clear:both;"})
]),

Builder.node('div',{style:"width:"+this.options.width+"px;height:"+(this.options.height*1 )+"px;"},[
Builder.node('div',{style:"float:left;width:8px;height:"+(this.options.height*1 )+"px;background:url(http://core.myfil.es/get_file/social/eml.png) repeat-y;"},[NBSP()]),
Builder.node('div',{style:"float:left;width:"+((this.options.width)-2*8)+"px;height:"+(this.options.height*1)+"px;"},[
d
]),
Builder.node('div',{style:"float:left;width:8px;height:"+(this.options.height*1 )+"px;background:url(http://core.myfil.es/get_file/social/emr.png) repeat-y;"},[NBSP()]),
Builder.node('div',{style:"clear:both;"})
]),

Builder.node('div',{style:"width:"+this.options.width+"px;height:"+(this.options.height*1 - (2*8))+"px;"},[
Builder.node('div',{style:"float:left;width:8px;height:8px;background:url(http://core.myfil.es/get_file/social/ebl.png);"},[]),
Builder.node('div',{style:"float:left;width:"+((this.options.width)-2*8)+"px;height:8px;background:url(http://core.myfil.es/get_file/social/ebm.png) repeat-x;"},[NBSP()]),
Builder.node('div',{style:"float:left;width:8px;height:8px;background:url(http://core.myfil.es/get_file/social/ebr.png);"},[]),
Builder.node('div',{style:"clear:both;"})
])

]);

  },
  makeWidgetContent: function(){
   // return 
  }
}  
Object.extend(simpleEmphasizeWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <204255> simpleexploreuserswidget.js 

simpleExploreUsersWidget = Class.create();
simpleExploreUsersWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({inlinetxt:"Enter Mysites Username"},arguments[0]);
  },
  setup:function(){
    
  },
  validateUsername: function(field, event) {
   if (!field.value.match(/^[a-z0-9][a-z0-9-]+$/)) {
      field.style.border = "2px solid red"         
    }
    else {
      var sidm = new SingleItemDisplayModel({
        item_path: "/",
        pretty_name: "",
        user: field.value,
        onErroneousSubmit: function(inst, error) {
          if (error.error_type == "UnknownUser") {
            $(field).setStyle({border:"1px solid red"});
          }          
        }.bind(this)
      })

      sidm.addObserver({afterPathChanged:function(){
        $(field).setStyle({border:"1px solid silver"});
      }.bind(this)})
    }
  },
  makeWidgetContent: function(){  
    var userinput = Builder.node('input',{type:"text",style:"",value:this.options.inlinetxt},[]);
    Event.observe($(userinput),'keyup',function(e){
      this.validateUsername(userinput,e);
    }.bind(this));
    $(userinput).setStyle({border:"1px solid silver"});

    var gotobtn = Builder.node('input',{type:"button",style:"",value:"Visit"},[]);
    Event.observe($(gotobtn),'click',function(e){
    var d = $F(userinput);
    if(d == "" || d == this.options.inlinetxt){
          $(userinput).select();
          $(userinput).focus();
    }else{
      document.location = "http://"+d+".mysites.com";
    }
    }.bind(this));
    this.wrapper = Builder.node('div',{style:"height:100%;"},[
      TN("Find MySites users:"),BR(),
      userinput,NBSP(),gotobtn
    ]);
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleExploreUsersWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <207966> simplefacebookfanpagewidget.js 

simpleFacebookFanpageWidget = Class.create();
simpleFacebookFanpageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({buddies:[],height:200},arguments[0]);
  },
  setup:function(){
    
  },
  makeWidgetContent: function(){ 
    var fbdiv = Builder.node('div',{style:"height:320px;width:100%;overflow:hidden;"},[]);
    fbhtml = '<iframe scrolling="no" frameborder="0" src="http://www.facebook.com/connect/connect.php?id=115813272488&connections=15&stream=0&css=115813272488" allowtransparency="true" style="border: none; width: 100%; height: 100%;"></iframe>';
    fbhtml += '<div style="font-size:8px; padding-left:10px"><a href="http://facebook.com/mysites">MySites Fanpage</a> on Facebook</div>';
    fbdiv.innerHTML = fbhtml;
    var c = Builder.node('div',{style:"clear:both;"},[]);
    this.wrapper = Builder.node('div',{style:"height:100%;"},[
        fbdiv
    ]);
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFacebookFanpageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <218131> simplefavicon.js 

      var simplefavicon = {
      change: function(iconURL) {
        if (arguments.length==2) {
          document.title = optionalDocTitle;
        }
        this.addLink(iconURL, "icon");
        this.addLink(iconURL, "shortcut icon");
      },
      addLink: function(iconURL, relValue) {
        var link = document.createElement("link");
        link.type = "image/x-icon";
        link.rel = relValue;
        link.href = iconURL;
        this.removeLinkIfExists(relValue);
        this.docHead.appendChild(link);
      },
      removeLinkIfExists: function(relValue) {
        var links = this.docHead.getElementsByTagName("link");
        for (var i=0; i<links .length; i++) {
          var link = links[i];
          if (link.type=="image/x-icon" && link.rel==relValue) {
            this.docHead.removeChild(link);
            return; // Assuming only one match at most.
          }
        }
      },
      docHead:document.getElementsByTagName("head")[0]
      } 

;

// /8::/202::/core:js -> <217744> simplefbapiwidget.js 

var sequencer = null;
var pendingFriendsResult = null;

simpleFBApiWidget = Class.create();
simpleFBApiWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeApi:function(){
   this.api = FB.Facebook.apiClient;    
   this.getFriends();
   //alert(this.api.get_session().uid);   
  },
  getFriends:function(){
    sequencer = new FB.BatchSequencer();
    pendingFriendsResult = this.api.friends_get(null, sequencer);
    sequencer.execute(function() {
      //window.alert(pendingFriendsResult.result);
    }.bind(this));
  },
  makeWidgetContent: function(){ 
    //window.setTimeout(function(){
      this.makeApi();
    //}.bind(this),3000);

    return EMPTY();
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFBApiWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <217448> simplefbcommentswidget.js 

simpleFBCommentsWidget = Class.create();
simpleFBCommentsWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeFMBL:function(){
    var fbcomm = Builder.node('div',[]);
    fbcomm.innerHTML = '<fb:comments title="'+this.options.title+'" width="490" simple="true"></fb:comments>';
    return fbcomm;
  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeFMBL();

window.setTimeout(function(){
FB.XFBML.Host.parseDomTree();
}.bind(this),3000);

    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFBCommentsWidget.prototype, WidgetCommon);

FBCommentsWidget = Class.create();
FBCommentsWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeFMBL:function(){
    var fbcomm = Builder.node('div',[]);
    fbcomm.innerHTML = '<fb:comments title="'+this.options.title+'" width="700" simple="true"></fb:comments>';
    return fbcomm;
  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeFMBL();

window.setTimeout(function(){
FB.XFBML.Host.parseDomTree();
}.bind(this),3000);

    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(FBCommentsWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <217743> simplefbinvitewidget-js.js 

simpleFBInviteWidget = Class.create();
simpleFBInviteWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeFMBL:function(){
    var fbcomm = Builder.node('div',[]);

    var fbml ='<fb:serverfbml><script type="text/fbml"><fb:fbml><fb:request-form action="http://www.mysites.com" method="POST" invite="true" type="MySites" content="MySites lets you share files with your friends easily <fb:req-choice url=\'http://www.mysites.com\' label=\'Visit Mysites\' />" style="width:550px"><fb:multi-friend-selector showborder="false" style="width:550px;" cols="3"  email_invite="false" actiontext="Invite your friends to use MySites" /></script></fb:request-form></fb:fbml></fb:serverfbml>';

    fbcomm.innerHTML = fbml;
    return fbcomm;
  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeFMBL();

window.setTimeout(function(){
FB.XFBML.Host.parseDomTree();
}.bind(this),3000);


    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFBInviteWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <217682> simplefblivestreamwidget.js 

simpleFBLiveStreamWidget = Class.create();
simpleFBLiveStreamWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeFMBL:function(){
    var fbcomm = Builder.node('div',[]);

    var fbml ='<fb:live-stream width="480" height="400"></fb:live-stream>';

    fbcomm.innerHTML = fbml;
    return fbcomm;
  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeFMBL();

window.setTimeout(function(){
FB.XFBML.Host.parseDomTree();
}.bind(this),3000);

    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFBLiveStreamWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <221719> simplefbloginwidget.js 

simpleFBLoginWidget = Class.create();
simpleFBLoginWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeFMBL:function(){
    var fbcomm = Builder.node('div',{style:"width:200px;margin:0 auto;height:30px;"},[]);

    var fbml ='<fb:login-button show-faces="true" width="200" max-rows="1" size="large" background="dark" length="long" onlogin="facebook_onlogin();"></fb:login-button>';

    fbcomm.innerHTML = fbml;
    return fbcomm;
  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeFMBL();

window.setTimeout(function(){
FB.XFBML.Host.parseDomTree();
}.bind(this),3000);

    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFBLoginWidget.prototype, WidgetCommon);


function facebook_onlogin() {

  document.location = "http://www.mysites.com/authenticate_external";

}
;

// /8::/202::/core:js -> <217679> simplefbpublishstreamwidget.js 

simpleFBPublishStreamWidget = Class.create();
simpleFBPublishStreamWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({style:"font-family:Trebuchet MS;font-weight:normal;",caption:"Share all Items in Folder",name:"MySites Item",captionnode:null,href:document.location.href,items:itemModel.items()},arguments[0]);
  },
  setup:function(){
    this.media = this.parseAllMedia();
  },
  getType:function(m){
    var type = "file";
    var mime = "";

    try{
      var mime = mimeTypeCategory(m);
      switch(mime){
        case "Audio":
          type = "tune";
          mime = "audio";
          break;
        case "Video":
          type = "movie";
          break;
        case "Image":
          type = "picture";
          break;
        case "File":
          type = "file";
          mime = "image"
          break;
        default:
      }
    }catch(e){
      //alert("mime error")
    }
   
    return {mime:mime,type:type};
  },
  getMediaForItem:function(m){
    var mime =  this.getType(m);
    var mimetype = mime.mime.toLowerCase();
    var href = document.location.href;
    var src = document.location.href;

    var media = null;

    switch(mimetype){
      case "image":
        href = document.location.href
        src = m.full_item_url ? m.full_item_url : "http://core.myfil.es/get_file/hlogo.png";
        media = {'type':mimetype,'href':href,'src':src};   
        break;     
      case "audio":
        media = {'type':'flash','width':'100','height':'30','expanded_width':'420','expanded_height':'30','imgsrc':'http://core.myfil.es/get_file/social/myplay.png','swfsrc':'http://core.myfil.es/get_file/social/flowplayer-3-1-2.swf?config={"clip":{"provider":"pseudo","url":"'+m.flv_url+'","autoPlay":true,"autoBuffering":true},"plugins":{"pseudo":{"url":"http://core.myfil.es/get_file/social/flowplayer-pseudostreaming-3-1.swf"},"controls":{"url":"http://core.myfil.es/get_file/social/flowplayer-controls-3-1-2.swf","playlist":false,"fullscreen":false}},"playlist":[{"provider":"pseudo","url":"'+m.flv_url+'","autoPlay":true,"autoBuffering":true}]}'};
      break; 
      case "video":
        media = {'type':mimetype,'preview_img':m.thumbnail_image_url,'video_src':'http://core.myfil.es/get_file/social/flowplayer-3-1-2.swf?config={"clip":{"provider":"pseudo","url":"'+m.flv_url+'","autoPlay":true,"autoBuffering":true},"plugins":{"pseudo":{"url":"http://core.myfil.es/get_file/social/flowplayer-pseudostreaming-3-1.swf"},"controls":{"url":"http://core.myfil.es/get_file/social/flowplayer-controls-3-1-2.swf","playlist":false,"fullscreen":true}},"playlist":[{"provider":"pseudo","url":"'+m.flv_url+'","autoPlay":true,"autoBuffering":true}]}','video_link':m.full_item_url,'video_title':m.name};
      break;
      default:
        href = "http://core.myfil.es/get_file/hlogo.png";
        src = "http://core.myfil.es/get_file/hlogo.png";
        //media = {'type':'image','href':href,'src':src};    
    }
    var media = media;
    return media;
  },
  parseAllMedia:function(){
    var media = [];
    $(this.options.items).each(function(item){
      var mediaitem = this.getMediaForItem(item);
      if(mediaitem != null){
        media.push(mediaitem);
      }
    }.bind(this));
    return media;
  },
  streamPublish:function(){
    var name = this.options.name;
    var href = this.options.href;    
    var media = this.media;
    var xid = document.location.href;

    var attachment = {
      'comments_xid':xid,
      'caption':'Publish this MySites-Item',
      'name':name,
      'href':href,
      'media': media
    }; 

    FB.Connect.streamPublish('', attachment);

  },
  makeWidgetContent: function(){ 
    var nodee = TN(this.options.caption);
    if(this.options.captionnode != null){
      nodee = this.options.captionnode;
    }
    
    this.wrapper = Builder.node('div',{style:this.options.style},[nodee]);
    Event.observe($(this.wrapper),'click',function(e){
      this.streamPublish();
    }.bind(this));
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFBPublishStreamWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <199223> simplefeaturedaccountswidget.js 

simpleFeaturedAccountsWidget = Class.create();
simpleFeaturedAccountsWidget.prototype = {
  defaultOptions: function(){
    return {
      faturedusermodels : [
{"city":"Piła","user_age_day":"--","fullname":"Shem Herman","country":"Poland","website":"http://www.myspace.com/shemassault","user_age_month":"--","e":"1","backgroundimage":"http://www.designmyprofile.com/images/graphics/other/backgrounds/myspace_bg_48.jpg","user_age_year":"--","status_message":"Shem: 25 year-old DnB & Dubstep producer from Poland. Making music since the age of 10 hes been recognized as Polish Spor. Shem released tracks on CARecs Trident Music BF Recs so far. Also a DJ: both locally and Internationally with gigs booked in Italy Germany & Russia.","userimage":"http://shem.mysites.com/get_file/2009-week-34/avatar-2.jpg","username":"shem","id":10,"group":false},
{"userimage":"http://villelope.mysites.com/get_file/2009-week-32/villelopepromopic-2008.jpg","full_name":"Ville Lope","username":"villelope","id":10289,"group":false},
{"userimage":"http://subtraxx.mysites.com/get_file/2009-week-34/subtraxx-logo.jpg","full_name":"Subtraxx Records","username":"subtraxx","id":10290,"group":false},
{"city":"versailles","user_age_day":"14","country":"france","e":"1","user_age_month":"3","user_age_year":"1984","userimage":"http://mind.myprofil.es/get_file?path=/minizoom.jpg","username":"mind","id":32,"group":false},
{"city":"paris","user_age_day":"18","country":"france","e":"1","user_age_month":"1","user_age_year":"1986","userimage":"http://nono.myprofil.es/get_file?path=/normal-bleach-kon-png.jpg","username":"nono","id":108,"group":false},
{"city":"Helsinki","user_age_day":"29","country":"Finland","website":"http://www.samipaju.com","e":"1","user_age_month":"8","user_age_year":"1984","userimage":"http://sami.mysites.com/get_file/2009-week-34/mirrored.jpg","username":"sami","id":39,"group":false}
      ]
    }
  },
  makeFeaturedAccount:function(acc){
    var badge = new simpleBadgeWidget({mode:"vertical",tooltip:true,iconsize:64,usermodel:acc,width:180}).htmlNode();

new simpleTooltipWidget({targetnode:badge,content:Builder.node('div',{style:""},[
      TN("Click here visit "+ acc.username.reflexive()+" site")
    ])})

    var rbadge = Builder.node('div',{style:"width:150px;float:left;height:100px;margin-bottom:10px;"},[badge]);
    return rbadge;
  },
  makeAllFeaturedAccounts:function(){
    var accs = [];
    accs.push(BR());
    accs.push(Builder.node('div',{style:"clear:both;"}));

    $(this.options.faturedusermodels).each(function(acc){
      accs.push(this.makeFeaturedAccount(acc));
    }.bind(this));
      accs.push(Builder.node('div',{style:"clear:both;"}));
    return accs;
  },
  makeWidgetContent: function(){

    return Builder.node('div',
      {style:"width:500px;height:240px;margin:0 auto;text-align:left;clear:both;"},
        this.makeAllFeaturedAccounts());
  }
}  
Object.extend(simpleFeaturedAccountsWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <202994> simpleflagswidget.js 

simpleFlagsWidget = Class.create();
simpleFlagsWidget.prototype = {
defaultOptions: function() {
    return {};
},
setup: function() {
    this.ar = [];
instance = this;
    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"})
            })

this.notifyObservers("languageChanged",lang);

	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)          
                }
            }
        }.bind(this))
        this.ar.push(flg)
    }.bind(this))
    this.s = Builder.node('div', {style:"margin-top:2px;"}, 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(simpleFlagsWidget.prototype, WidgetCommon); 
Object.extend(simpleFlagsWidget.prototype, Observable); 
  
;

// /8::/202::/core:js -> <208056> simplefolderpagewidget.js 

var folderpage = null
simpleFolderPageWidget = Class.create();
simpleFolderPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({album_name:"",m:null,model:itemModel},arguments[0]);
  },
  setup:function(){
    folderpage = this;
    window.setTimeout(function(){
      $(document).title = "MySites";
    },210);
    this.m = this.options.m;

//this.m = itemModel.findItemByPrettyName(itemModel.currentPath());
    if(this.options.m != null){
        this.options.album_name = this.m.name;//this.options.model.currentPath() == "/" ? this.options.model.currentPath() : this.options.model.currentPath().replace("/","");
    }

    this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({onuserpage:true,widget:this.albumcontrols,model:this.options.model});    
  },
  makeUserBadgeWidget:function(){
    this.userinfo = Builder.node('div',[]);
    var thenode = Builder.node('div',{style:"height:100px;"},[
      new simpleBadgeWidget({iconsize:64,usermodel:read_user_model_data}).htmlNode(),
      this.userinfo
    ])
    return {boxed:true,node:thenode,head:translateText({path: ".nm-supw", id: "User"})};
  },
  makeExploreAlbumsWidget:function(){
     var thenode = Builder.node('div',{style:""},[
        new simpleAlbumNavigationWidget({}).htmlNode()
      ])
      var o = {boxed:true,node:thenode,head:Builder.node('span',[TN(read_user_model_data.username.reflexive()),NBSP(),translateText({path: ".nm-supw", id: "albums"})])};   
    return o;
  },
 // makeUploadButtonWidget:function(){
 //   var thenode = new simpleUploadButtonWidget({targetnode:this.itemlist.htmlNode(),album_name:this.options.album_name,mode:"flash",text:"Upload your files"}).htmlNode();
 //   return {node:thenode,head:EMPTY()};
 // },
  makeAlbumControlsWidget:function(){     
    var thenode = Builder.node('div',{style:"height:30px;"},[
       this.albumcontrols.htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  makePathInfo:function(){
    var thenode = Builder.node('div',{style:"height:30px;font-weight:bolder;font-size:180%;"},[
       TN(this.options.album_name != "" ? this.options.album_name : "HOME")
    ])
    return {node:thenode,head:translateText({path: ".nm-supw", id: "Current Album"}),boxed:true};
  },
  makeShareWidget:function(){
    var thenode = Builder.node('div',[
      new simpleEmbedWidget({item:this.options.m}).htmlNode()
    ])
    return {boxed:true,node:thenode,head:translateText({path: ".nm-supw", id: "Share This"})};
  },
  makeWidgetContent: function(){  

    var left = [
      this.makeUserBadgeWidget(),    
      this.makeShareWidget()
    ];
    if(logged_in){
      left.push(this.makeExploreAlbumsWidget());
    }
    var right = [
      this.makePathInfo(),
      this.makeAlbumControlsWidget(),
      {boxed:true,node:this.itemlist.htmlNode(),head:EMPTY()}
    ];

    var close = Builder.node('div',{style:"position:relative;top:0px;float:right;top:-80px;cursor:pointer;background:url(http://core.myfil.es/get_file/social/infoclose.png);width:17px;height:16px;"},[]);
    Event.observe($(close),'click',function(e){
        Effect.Fade($(notification),{afterFinish:function(){
          Effect.SlideUp($(layoutwidget.contenthead));
        }});        
    }.bind(this));

    var guestinfo = "";
    guestinfo += "You can share these files with anyone.<br/>";
    guestinfo += "Simply send the link to this page to your contacts.<br/><br/>";
    guestinfo += "We\'ve encrypted this page link, so that others can\'t find your files.<br/>";
    guestinfo += "Do not lose this link! If you lose it, you won't be able to find this page again!<br/>";

    var info = Builder.node('div',{style:"font-size:10px;"},[]);
    info.innerHTML = guestinfo;

    var notification = Builder.node('div',{style:"position:absolute;width:858px;height:88px;background:#FFF1AF;border:1px solid #FFC62F;"},[Builder.node('div',{style:"position:relative;margin:10px;width:auto;"},[info,close])])
    notification.hide();
    window.setTimeout(function(){
      Effect.Appear($(notification));
    }.bind(this),1000);

    var layout = {left:left,right:right};
    if(!logged_in && read_user_model_data.username == "guest"){
      layout.top = [{boxed:false,node:notification,head:EMPTY()}];
    }
    var layoutwidget = new simpleLayoutWidget(layout);
    if(!logged_in && read_user_model_data.username == "guest"){
      layoutwidget.contenthead.setStyle({height:"90px",marginBottom:"20px"});
    }
    return layoutwidget.htmlNode();

  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFolderPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <207967> simplefooterwidget.js 

simpleFooterWidget = Class.create();
simpleFooterWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({},arguments[0]);
  },
  setup:function(){
    
  },
  makeLinks:function(){
    return Builder.node('div',{style:"width:600px;margin-left:20px;margin-top:10px;height:30px;color:black;"},[
      //Builder.node('a',{style:"height:20px;color:black;",href:"javascript:void(0);"},[

/*
Builder.node('div',{style:"margin-top:10px;margin-right:20px;height:20px;width:100px;float:left;"},[
Builder.node('a',{style:"color:black;",href:"javascript:void(0);"},[TN("About")])
]),
*/

Builder.node('div',{style:"margin-top:10px;margin-right:20px;height:20px;width:100px;float:left;"},[
Builder.node('a',{style:"color:black;",href:"http://core.mysites.com/get_file/2009-week-35/media.html"},[TN("Media")])
]),

/*
Builder.node('div',{style:"margin-top:10px;margin-right:20px;height:20px;width:100px;float:left;"},[
Builder.node('a',{style:"color:black;",href:"javascript:void(0);"},[TN("Partners")])
]),
*/

Builder.node('div',{style:"margin-top:10px;margin-right:20px;height:20px;width:100px;float:left;"},[
Builder.node('a',{style:"color:black;",href:"http://core.mysites.com/get_file/2009-week-39/mysites-api.html"},[TN("API")])
]),

Builder.node('div',{style:"margin-top:10px;margin-right:20px;height:20px;width:100px;float:left;"},[
Builder.node('a',{style:"color:black;",href:"http://core.myarticl.es/get_file/terms"},[TN("Terms")])
]),

Builder.node('div',{style:"clear:both;"})
      //])
    ]);
  },
  makeWidgetContent: function(){ 
    return Builder.node('div',{id:"myfooter",style:"width:100%;height:40px;background:#DCDCDC;"},[this.makeLinks()]);
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFooterWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <208780> simpleformuploadwidget.js 

var fc = 0;
simpleFormUploadWidget = Class.create();
simpleFormUploadWidget.prototype = {
  defaultOptions: function() {
    return {
      maxfiles:5,
      width:500,
      cloud:false,
      album_name:"",
      mode:"flash"
    };
  },
  setup:function(){
    if(this.options.cloud){this.options.width = 300;}
  },
 makeCloudBg:function(){
    var c = Builder.node('div',{style:"left:-135px;top:-80px;z-index:-2;background:url(http://core.myfil.es/get_file/social/mycloud.png);position:absolute;width:600px;height:344px;"},[]);
    return c;
  },
  makeCloudTexts:function(){
    var t1 = Builder.node('div',{style:"z-index:-2;top:-110px;left:0px;background:url(http://core.myfil.es/get_file/social/t-1.png);position:absolute;width:228px;height:112px;"},[]);
    var t2 = Builder.node('div',{style:"z-index:-2;top:260px;left:-150px;background:url(http://core.myfil.es/get_file/social/t-2.png);position:absolute;width:159px;height:72px;"},[]);
    var t3 = Builder.node('div',{style:"z-index:-2;top:280px;left:20px;background:url(http://core.myfil.es/get_file/social/t-3.png);position:absolute;width:187px;height:235px;"},[]);
    var t4 = Builder.node('div',{style:"z-index:-2;top:280px;left:220px;background:url(http://core.myfil.es/get_file/social/t-4.png);position:absolute;width:221px;height:151px;"},[]);
    var t5 = Builder.node('div',{style:"z-index:-2;top:250px;left:350px;background:url(http://core.myfil.es/get_file/social/t-5.png);position:absolute;width:128px;height:77px;"},[]);

$(t1).hide();
$(t2).hide();
$(t3).hide();
$(t4).hide();
$(t5).hide();

new Effect.Appear($(t1),{delay:0});
new Effect.Appear($(t2),{delay:1*0.6});
new Effect.Appear($(t3),{delay:2*0.6});
new Effect.Appear($(t4),{delay:3*0.6});
new Effect.Appear($(t5),{delay:4*0.6});

 return Builder.node('div',{style:"z-index:-1;position:absolute;"},[t1,t2,t3,t4,t5]);
  },
  expand:function(){
    if(!this.moving && !this.expanded){
      this.moving = true;
      new Effect.SlideDown($("selectalbums"),{duration:0.3,afterFinish:function(){
        this.moving = false;
        this.expanded = true;
        $(this.arrow).setOpacity(0.2);
      }.bind(this)});
    }
  },
  collapse:function(){
   if(!this.moving && this.expanded){
        this.sendToSwf($F("album_name"));
        this.moving = true;
        new Effect.SlideUp($("selectalbums"),{duration:0.3,afterFinish:function(){
          this.moving = false;
          this.expanded = false
          $(this.arrow).setOpacity(1);
        }.bind(this)});
      } 
  }, 
  makeAlbumSelection:function(){
    this.albumnavi = new simpleAlbumNavigationWidget({uploadmode:true,displayItemClicked:function(f){
      $("album_name").setAttribute("value","");
      $("album_name").value = "";
      $("album_name").value = f.name;
      $("album_name").setAttribute("value",f.name);
      this.options.album_name = f.name;

     this.collapse();
    }.bind(this),model:sdloader.loader});


    return this.albumnavi.htmlNode();
  },
  makeFileSelect:function(id){   
    var fi = Builder.node('input',{style:"z-index:1;width:"+(this.options.width+2)+"px;",type:"file",id:"file_"+id,name:"file_"+id},[]);
    Event.observe($(fi),'change',function(e){
      fc++;
      if(fc <= this.options.maxfiles){
        $(fi).setStyle({position:"absolute",left:"-1000px"});
        $("filebox").appendChild(this.makeFileSelect(fc));
        this.makeFileText($F(fi),id)
      }else{
        alert("too many");
       }
    }.bind(this));
    return fi;
  },
  makeFileText:function(txt,id){
    $("allfilebox").setStyle({background:"transparent"});

    var btn = Builder.node('div',{
style:"cursor:pointer;float:left;text-align:center;line-height:8px;width:30px;height:10px;background:#EDEDED;border:1px solid #888888;"
},[TN("x")]);

    btn.id = id;
    var filename = Builder.node('div',{style:"float:left;margin-right:10px;width:80%;"},[TN(txt)]);
    var c = Builder.node('div',{style:"clear:both;"});
    var delfile = Builder.node('div',{style:"font-size:10px;"},[filename,btn,c]);
    Event.observe($(btn),'click',function(){
      $(delfile).remove();
      $("file_"+btn.id).remove();
      fc--;
    });
    $("allfilebox").appendChild(delfile);
  },
  makeAlbumSelector:function(){
//no albums for guest
if(!logged_in){
return EMPTY();
}

   //var albumselector = Builder.node('div',{style:"cursor:pointer;"},[TN("select album")]);
    //Event.observe($(albumselector),'click',function(e){
      
    //}.bind(this));

var inp = Builder.node('input',{id:"album_name",style:"color:silver;width:100%;",type:"text",name:"album_name",value:this.options.album_name != "" ? this.options.album_name : "Enter an album name"},[]);

var albuminputnode = Builder.node('div',{style:"float:left;width:350px;margin-right:20px;"},[
inp
]);

var albumtxt = Builder.node('div',{style:"text-align:right;height:30px;float:left;width:95px;margin-right:5px;"},[
Builder.node('div',{style:"height:20px;margin-top:2px;"},[
Builder.node('a',{href:"javascript:void(0);",style:"font-size:17px;font-weight:bolder;"},[TN("My Albums")])
])
]);

Event.observe($(albumtxt),'click',function(e){
  this.expand();
}.bind(this));


this.arrow = Builder.node('div',{style:"cursor:pointer;border:1px solid silver;float:left;width:29px;height:29px;background:white;"},[
Builder.node('div',{style:"margin-top:5px;margin-left:5px;width:18px;height:16px;background:url(http://core.myfil.es/get_file/social/arrowdown.png);"})
]);

Event.observe($(this.arrow),'click',function(e){
  this.expand();
}.bind(this));

var cl = Builder.node('div',{style:"clear:both;"},[]);
var albuminput = Builder.node('div',{style:""},[Builder.node('div',{style:"width:150px;"},[            Builder.node('label',{"for":"album_name",style:"width:200px;"},[TN("Album:"),NBSP(),Builder.node('span',{style:"color:grey;"},[TN("(optional)")])])
]),albuminputnode,albumtxt,this.arrow,cl]);

if(this.options.album_name == ""){
$(albuminput).hide();
}

    Event.observe($(inp),'focus',function(){
      $("album_name").setStyle({color:"black"});
      if($F("album_name") == "Enter an album name"){
        $("album_name").value = "";
        $("album_name").setAttribute("value","");
      }
    }.bind(this));
    Event.observe($(inp),'blur',function(){
      this.collapse();
      if($F("album_name") == ""){
        $("album_name").setStyle({color:"silver"});
        $("album_name").value = "Enter an album name";
        $("album_name").setAttribute("value","Enter an album name");
      }
    }.bind(this));

    //send typed data to flash.. needs fix for IE
    Event.observe($(inp),'keyup',function(){

      this.suggest($F("album_name"));
      if(this.options.mode == "flash"){
        this.sendToSwf($F("album_name"));
      }

    }.bind(this));

    var albumnodes = Builder.node('div',[BR(),albuminput])

window.setTimeout(function(){
    Event.observe($(document.body),'click',function(){
      this.collapse();
    }.bind(this));

try{
$(albuminput).show();
$("selectalbums").hide();
$("selectalbums").firstChild.innerHTML = "";
$("selectalbums").firstChild.appendChild(this.makeAlbumSelection());
}catch(e){}

}.bind(this),150);

    return albumnodes;
  },
  suggest:function(d){

     var arr = [];
     $(sdloader.loader.items()).each(function(item){
       var r = new RegExp(d, "gi")
       if(item.name.match(r)){
         arr.push(item);
       }
     }.bind(this));
     this.albumnavi.setItems(arr);
     window.setTimeout(function(){
       if(arr.length >0){
          this.expand();
       }
     }.bind(this),500);
  },
  makePermissionSelector:function(){

//no permissions for guest
if(!logged_in){
return EMPTY();
}
    var sel = Builder.node('select',{id:"permission",style:"width:100%;",name:"permission"});
    sel.appendChild(Builder.node('option',{name:"",value:"onlyme"},[TN("Private")]));
      sel.appendChild(Builder.node('option',{name:"",value:"everyone"},[TN("Public")]));
    return sel;
  },
  makeHtmlForm:function(){
    var sel = this.makePermissionSelector();
    var albumselector = this.makeAlbumSelector();
var permissiontext = TN("Permission:");
//other label for guest
if(!logged_in){
permissiontext = EMPTY()
}

var submitbtn = Builder.node('input',{className:"bigbutton",style:"width:300px;font-family:Trebuchet MS;font-size:24px;font-weight:bolder;height:50px;",
            type:"submit",name:"",
            value:"Upload"},[])

Event.observe($(submitbtn),'click',function(e){

}.bind(this));

    var theform = Builder.node('form',{enctype:"multipart/form-data",action:"/upload",method:"post"},[
        Builder.node('div',{style:"margin-bottom:5px;width:"+(this.options.width+2)+"px;"},[
          Builder.node('div',{style:"width:200px;"},[
            Builder.node('label',{"for":"file",style:"width:200px;"},[TN("Select Files:")]),
          ]),
          Builder.node('div',{id:"filebox",style:""},[this.makeFileSelect(fc)])
        ]),
          Builder.node('div',{style:"margin-bottom:5px;width:"+(this.options.width+2)+"px;"},[
            Builder.node('div',{},[TN("Files:")]),
            Builder.node('div',
              {id:"allfilebox",style:"position:relative;padding:5px;height:auto;width:100%;"},
                []),
        ]), 
        Builder.node('div',{style:"margin-bottom:5px;width:"+(this.options.width+2)+"px;"},[
          Builder.node('div',{style:"width:200px;"},[
            Builder.node('label',{"for":"permission",style:"width:200px;"},[permissiontext]),
          ]),
          sel
        ]),
        Builder.node('div',{style:"width:"+(this.options.width+2)+"px;"},[
          submitbtn
        ]),
Builder.node('div',{style:"margin-bottom:5px;width:"+(this.options.width+2)+"px;"},[
this.makeAlbumSelector()
        ])
    ]);

    Event.observe($(theform),'submit',function(e){

if(logged_in){
       if($F("album_name")== "Enter an album name"){
          //$("album_name").setAttribute("value","");
          $("album_name").value = "";
       }
}
       if($("allfilebox").innerHTML  == ""){
         Event.stop(e);
$("allfilebox").setStyle({background:"#FF7F7F"});
         $$("#filebox input")[0].setStyle({border:"1px solid #888888"});         
         return false;
       }else{
         //alert("uploading");
       }
    }.bind(this));

    return theform;
  },
  sendToSwf:function(data){
if(this.options.mode == "flash"){
    $("myuploader").simpleJSEvent(data);
}
  },
  makeFlashUploader: function() {
      var swfdiv = Builder.node("div");
      this.getSwfObject().write(swfdiv);

      return Builder.node('div',{style:"border:1px solid silver;",id:"uploaderWidget"},[swfdiv]);
  },
  getSwfObject:function(){  
        var inst = this; 
        var so = new SWFObject('http://www.mysites.com/core-services/multipleuploader_15.swf?cookie='+document.cookie.split("; ").inject({}, function(h, v) { vv = v.split("=", 2); h[vv[0]] = vv[1]; return h})["mysites"]+'&album_name='+this.options.album_name, "myuploader", "500", "210", "8", "#FFFFFF");
        so.addParam('allowScriptAccess', 'always');
        so.addParam('wmode', 'opaque'); 
  
        return so;   
  },
  makeFlashForm:function(){
 
    var albuminput = Builder.node('div',{style:"margin-bottom:5px;width:"+(this.options.width+2)+"px;"},[
this.makeAlbumSelector()
]) 
    return Builder.node('form',{style:"width:100%;"},[this.makeFlashUploader(),albuminput]);
  },

  makeSwitchTabs:function(){
    var tab1 = Builder.node('div',{id:"uptab1",style:"margin-top:1px;margin-right:5px;font-size:10px;float:left;font-weight:normal;width:80px;height:17px;border:1px solid #888888;border-bottom:1px solid #EDEDED;"},[Builder.node('a',{style:"font-weight:bolder;top:5px;margin-left:15px;color:black;text-decoration:none;",href:"javascript:void(0);"},[TN("Send Files")])]);

Event.observe($(tab1),'click',function(e){
this.options.mode = "flash";
this.rerender();
}.bind(this));

Event.observe($(tab1),'mouseover',function(e){
$(tab1).setStyle({background:"white"});
}.bind(this));
Event.observe($(tab1),'mouseout',function(e){
$(tab1).setStyle({background:"transparent"});
}.bind(this));


    var tab2 = Builder.node('div',{id:"uptab2",style:"margin-left:-1px;margin-top:1px;font-size:10px;font-weight:normal;float:left;width:80px;height:17px;border:1px solid #888888;border-bottom:1px solid transparent;"},[Builder.node('a',{style:"font-weight:bolder;top:5px;margin-left:29px;color:black;text-decoration:none;",href:"javascript:void(0);"},[TN("Text")])]);

Event.observe($(tab2),'click',function(e){
this.options.mode = "paste";
this.rerender();
}.bind(this));
Event.observe($(tab2),'mouseover',function(e){
$(tab2).setStyle({background:"white"});
}.bind(this));
Event.observe($(tab2),'mouseout',function(e){
$(tab2).setStyle({background:"transparent"});
}.bind(this));
    
    var thetabs = Builder.node('div',{style:"position:relative;width:500px;position:relative;border-bottom:1px solid black;margin-bottom:-40px;"},[
Builder.node('div',{style:"margin-left:20px;position:relative;margin-bottom:-1px;width:450px;"},[
tab1,
(is_developer ? tab2 : EMPTY()),
Builder.node('div',{style:"clear:both;"},[])
])
]);

    return thetabs;
  },
  makePasteForm:function(){
    return Builder.node('div',{style:"margin-bottom:20px;"},[new simpleArticleWidget({model:sdloader.loader}).htmlNode()]);
  },
  makeWidgetContent: function() {
    //no flash for guest
    //also atm not for IE, until extInt ist fixed 
    if(!logged_in || Prototype.Browser.IE && this.options.mode != "paste"){
      this.options.mode = "html";
    }
    
    if(this.options.mode == "html"){
      var theform = this.makeHtmlForm();
    }else if(this.options.mode == "flash"){
      var theform = this.makeFlashForm();
    }else if(this.options.mode == "paste"){
      window.setTimeout(function(){
        $("uptab1").setStyle({borderBottom:"1px solid transparent"});
        $("uptab2").setStyle({borderBottom:"1px solid #EDEDED"});
      }.bind(this),300);
      var theform = this.makePasteForm();
    }

this.notifyObservers("uploaderStarted");

var switchc = Builder.node('div',{style:"position:relative;top:0px;text-align:right;cursor:pointer;float:right;width:200px;font-size:10px;"},[TN("switch to "+(this.options.mode == "html" ? "flash" : "html") + " version")]);
Event.observe($(switchc),'click',function(e){
this.options.mode = (this.options.mode == "html" ? "flash" : "html");
this.rerender();
}.bind(this)); 


//no switch for guest
//if(!logged_in){
//var reg = Builder.node('a',{href:"",style:"color:black;"},[TN("Register")]);
//var switchc = //Builder.node('div',{style:"font-size:80%;width:300px;float:left;"},[reg,TN(" to use //the flash uploader")]);
//}

var headtxt = this.makeSwitchTabs();

var c = Builder.node('div',{style:"clear:both;"});
var head = Builder.node('div',{style:"padding:10px;width:"+this.options.width+"px;background:transparent;z-index:99;font-weight:bolder;font-size:120%;"},[headtxt,switchc,c]);

var alb = Builder.node('div',{id:"selectalbums",style:"padding:5px;background:transparent;"},[
Builder.node('div',{id:"albums",style:""},[])
]);

var cloud = EMPTY();
var cloudtxt = EMPTY();
var st = "";

if(this.options.cloud){
  head = EMPTY();
  switchc = EMPTY();
  alb = EMPTY();
  cloud = this.makeCloudBg();
  cloudtxt = this.makeCloudTexts();

//$(theform).disable();
//$(theform).appendChild(TN("Guest-Server maintenance!"));

  st = "font-size:90%;margin-left:80px;position:absolute;top:350px;;width:500px;height:400px;z-index:3;";
}

    return Builder.node('div',{style:"width:"+(this.options.width+2)+"px;margin-bottom:10px;"+st},[cloud,cloudtxt,head,BR(),Builder.node('div',{style:"z-index:999;"},[theform,alb])]);
  }, 
  rerender: function(){
    var nc = this.makeWidgetContent()
    this.replaceChild(this.content, this.widgetContent, nc)
    this.widgetContent = nc  
  }
}

Object.extend(simpleFormUploadWidget.prototype, WidgetCommon);
Object.extend(simpleFormUploadWidget.prototype, Observable);




;

// /8::/202::/core:js -> <217876> simpleformwidget.js 

simpleFormWidget = Class.create();
simpleFormWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      params:[
        {label:"label1",kk:"sdas",vv:"1"},
        {label:"label2",kk:"another label",vv:"2"},
        {label:"label3",kk:"asaas",vv:"3"}
      ]
    },arguments[0]);
  },
  setup:function(){
    this.fields = {};
  },
  makeInput:function(x){
    var inpno = Builder.node('input',{type:x.type,style:"",value:x.vv,name:x.kk,id:x.kk});
    var hidden = Builder.node('input',{type:"hidden",value:x.vv,name:x.kk,id:x.kk});
    if(Object.isString(x.label)){
      var lbl = translateText({path: ".nm-sfw", id: x.label});
    }else{
      var lbl = x.label;
    }

    var label = Builder.node('label',{'for':x.kk,style:"margin-right:30px;font-size:120%;"},[lbl]);

    var thetext = Builder.node('div',{style:"padding:3px;background:#fbfbfa;height:20px;"},[
      Builder.node('div',{id:"i"+x.kk},[TN(x.vv)]),hidden
    ]);

    if(x.type == "node"){
      thetext = x.node;
      inpno = x.node;
    }

//  var inp = Builder.node('div',{style:"margin-bottom:5px;"},[thetext]);
    var inp = Builder.node('div',{style:"margin-bottom:5px;"},[inpno]);

/*
    $(inp).thetext = thetext
    Event.observe($(inp),'click',function(e){
      $(inp).innerHTML = '';
      $(inp).appendChild(inpno);
      $(inp).stopObserving('click');
      Event.stop(e);
    }.bind(this));

    Event.observe($(inpno),'blur',function(e){
      $(inp).innerHTML = '';
      $(inp).appendChild($(inp).thetext);
      $(inp).thetext.down().innerHTML =  (x.type == "password" ? "<i>[hidden]</i>" : $F(inpno));

      $(hidden).value = $F(inpno);

      Event.observe($(inp),'click',function(e){
        $(inp).innerHTML = '';
        $(inp).appendChild(inpno);
        $(inp).stopObserving('click');
        Event.stop(e);
      }.bind(this));

    }.bind(this));

*/

    if(x.type == "node"){
      $(inp).stopObserving('click');
    }

    return Builder.node('div',{style:"padding:5px;background:#EFEFEF;margin-right:0px;margin-bottom:10px;border-bottom:1px solid #CFCFCF;"},[label,BR(),inp]);
  },
  parseData:function(){
    var inputs = [];
    $(this.options.params).each(function(paramm){
       var defparam = Object.extend({type:"text"},paramm);
        inputs.push(this.makeInput(defparam));
    }.bind(this));
    return inputs;
  },
  makeWidgetContent: function(){ 
     this.form = Builder.node('form',{id:"f",name:"f",method:"POST"},this.parseData());
     Event.observe($(this.form),'submit',function(e){
       Event.stop(e);
       return false;
     }.bind(this));
     return Builder.node('div',{style:""},this.form);
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleFormWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <193602> simplefrontboxwidget.js 


SimpleFrontBoxWidget = Class.create();
SimpleFrontBoxWidget.prototype = {
    defaultOptions: function() {
        return Object.extend({className:"greybox",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,height:"100%",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_"+this.options.className,width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td12 = Builder.node('td',{className:"bTF2_"+this.options.className,width:"100%"},[Builder.node('div',{className:"bTM_"+this.options.className},[this.options.title])]);
        //var td13 = Builder.node('td',{className:"bTF_"+this.options.className,width:"100%"},[Builder.node('div')]);
        var td14 = Builder.node('td',{className:"bTR_"+this.options.className,width:10},[Builder.node('div')]); 
 
        var td21 = Builder.node('td',{className:"bML_"+this.options.className,width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td22 = Builder.node('td',{className:"bMF_"+this.options.className,valign:"top"},[Builder.node('div',{style:"width:100%;overflow:hidden;text-align:left;",id:this.options.id+"_content",className:"bContent_"+this.options.className},[this.options.node])]);
        //var td23 = Builder.node('td',{className:"bMF_"+this.options.className,width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td24 = Builder.node('td',{className:"bMR_"+this.options.className,width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
 
        var td31 = Builder.node('td',{className:"bBL_"+this.options.className,width:10},[Builder.node('div',{style:"width:10px;height:10px;"})]);
        var td32 = Builder.node('td',{className:"bBM_"+this.options.className,width:"100%"},[]);
        //var td33 = Builder.node('td',{className:"bBF_"+this.options.className,width:"100%"},[]);
        var td34 = Builder.node('td',{className:"bBR_"+this.options.className,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:"+this.options.height+";text-align:left;"},[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(SimpleFrontBoxWidget.prototype, WidgetCommon);    
 
;

// /8::/202::/core:js -> <207751> simplefrontpagewidget.js 

function checkForUpdates(){
var rm = new RecentDisplayModel({itemsPerPage:5});
rm.observeOnce({update:function(){
  var lastitem = itemlist.options.model.items()[0];
  var newitems = [];
  $(rm.items()).each(function(item){
    if(item.added_at > lastitem.added_at){
      newitems.push(item);
    }
  });
  if($("loadnotifier")){
    $("loadnotifier").remove();
  }
  var noti = Builder.node('div',{id:"loadnotifier",style:"height:28px:width:523px;background:#FFF1AF;border:1px solid #FFC62F;"},[
Builder.node('div',{style:"width:auto;padding:5px;width:500px;"},[
TN(newitems.length +" new public items."),NBSP(),Builder.node('a',{href:document.location},[
TN("click to reload")
])
])
]);
  itemlist.htmlNode().firstChild.firstChild.appendChild(noti);
  $(noti).hide();
  new Effect.SlideDown($(noti),{afterFinish:function(){
    new Effect.SlideUp($(noti),{delay:10})
  }.bind(this)});
  
rm = null;
//itemlist.options.model = rm;
//alert(itemlist.options.model.items().length)
//itemlist.rerender()

}});

}

simpleFrontPageWidget = Class.create();
simpleFrontPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({checkforupdates:true,m:null},arguments[0]);
  },
  setup:function(){
    this.m = this.options.m;
    //if(this.options.checkforupdates){
    //  new PeriodicalExecuter(checkForUpdates, 60);
    //}
    this.uarea = Builder.node('div',{style:"height:30px;"});

    //this.uploadw = new simpleUploadButtonWidget({
    //  targetnode:this.uarea,
    //  album_name:"",
    //  mode:"html",
    //  text:"Upload content to mysites.com:"
    //});

    this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({widget:this.albumcontrols,model:itemModel});    

  }, 
  //makeExploreAlbumsWidget:function(){
  //  if(logged_in){
  //    var thenode = Builder.node('div',{style:""},[
  //      new simpleAlbumNavigationWidget({}).htmlNode()
  //    ])
  //    var o = {node:thenode,head:EMPTY()};
  //  }else{
  //    var o = {node:EMPTY(),head:EMPTY(),boxed:false};
  //  }
  //  return o;
  //},
  makeLinksWidget:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleLinksWidget({links:[        
{ico:Builder.node('img',{src:"http://core.myfil.es/get_file/social/trans.png"}),name:translateText({path: ".nm-sfpw", id: "My Site"}),link:"http://"+write_user_model_data.username+".mysites.com"},
{ico:Builder.node('img',{src:"http://core.myfil.es/get_file/social/trans.png"}),name:translateText({path: ".nm-sfpw", id: "My Albums"}),link:"http://"+write_user_model_data.username+".mysites.com/-"}
      ]}).htmlNode()
    ])
    return {node:thenode,head:translateText({path: ".nm-sfpw", id: "Navigation"}),boxed:true};
  },
  makeRSSBox:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleLinksWidget({links:[         {ico:Builder.node('img',{src:"http://core.myfil.es/get_file/feed.png"}),name:translateText({path: ".nm-sfpw", id: "Recent public files"}),link:"http://www.mysites.com/recent_rss"}
      ]}).htmlNode()
    ])
    return {node:thenode,head:translateText({path: ".nm-sfpw", id: "Navigation"}),boxed:false};
  },
  makeFanpageWidget:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleFacebookFanpageWidget({}).htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  makeDazzboardWidget:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleDazzboardWidget({}).htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  //makeUploadButtonWidget:function(){   
  //  var thenode = this.uploadw.htmlNode();
  //  return {node:thenode,head:EMPTY()};
  //},
  makeAlbumControlsWidget:function(){     
    var thenode = Builder.node('div',{style:"height:35px;"},[
       this.albumcontrols.htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  afterInitWidget:function(){
    this.uploadw.showUploader();
  },
  makeWidgetContent: function(){  
    var left = [
      (logged_in ? this.makeLinksWidget() : {node:EMPTY(),head:EMPTY()}),
      this.makeDazzboardWidget(),
      this.makeRSSBox()
    ];
  

    var right = [
      this.makeAlbumControlsWidget(),
      {node:this.itemlist.htmlNode(),head:translateText({path: ".nm-sfpw", id: "Latest Additions"}),boxed:true}      
    ];
    
    layoutwidget = new simpleLayoutWidget({left:left,right:right});
    return layoutwidget.htmlNode();

  }, 
  rerender: function(){
    //this.redrawCompletely()
  }
}  
Object.extend(simpleFrontPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <202908> simplega.js 

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

//console = {};
//console.log = function(a){
//document.body.appendChild(Builder.node('div',{id:"log"},[TN(a)]));
//document.body.appendChild(BR());
//}

Event.observe($(window),"load", function() {
window.setTimeout(function(){
    //if(is_developer){
      var breeze = "http://breezetags-test.s3.amazonaws.com/ssss/loader/"
      breeze += "ssss.js?pid=724712892";
      breeze += "&init_time=nowait";
      //breeze += "&callback=attach_share_widget";
      add_breeze(breeze);
    //}
},10);

  try {
    var pageTracker = _gat._getTracker("UA-9134043-1");
    pageTracker._trackPageview();
  } catch(err) {

  }
  window.setTimeout(function(){
        try {
            _uacct = "UA-9134043-1";
            urchinTracker();
        } catch(err) {}
  }.bind(this),1000);

});



function add_gajs(url, bDefer){    
    var scrptElement = document.createElement("script");
    scrptElement.setAttribute("type", "text/javascript");
    scrptElement.setAttribute("language", "JavaScript");
    scrptElement.setAttribute("src", url);
    if (bDefer){
        scrptElement.setAttribute("defer", true);
    }
    document.getElementsByTagName("head")[0].appendChild(scrptElement);    
};

function add_breeze(url, bDefer){    
    var scrptElement = document.createElement("script");
    scrptElement.setAttribute("type", "text/javascript");
    scrptElement.setAttribute("language", "JavaScript");
    scrptElement.setAttribute("src", url);
    if (bDefer){
        scrptElement.setAttribute("defer", true);
    }
    document.getElementsByTagName("head")[0].appendChild(scrptElement);    
};
;

// /8::/202::/core:js -> <213986> simpleguestpagewidget.js 

var guestpage = null;
simpleGuestPageWidget = Class.create();
simpleGuestPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null},arguments[0]);
  },
  setup:function(){

   guestpage = this;

   this.CUPLOAD = EMPTY(); //Builder.node('div',{id:"CUPLOAD",style:"position:abolute;top:290px;"},[NBSP()]);

    //this.m = this.options.m;
    this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({items:[],widget:this.albumcontrols,model:itemModel});    

  }, 
  makeUploadButtonWidget:function(){

    this.uploadw = new simpleUploadButtonWidget({cloud:true,targetnode:this.CUPLOAD,album_name:"",mode:"html",text:"Upload content to mysites.com:"});

    this.uploadbtn = this.uploadw.htmlNode();
    return {node:this.uploadbtn,head:EMPTY(),boxed:false};
  },
  makeRegisterWidget:function(){
    //if(!logged_in){
      var thenode = Builder.node('div',{style:""},[
        new simpleRegisterWidget({}).htmlNode()        
      ])
      var o = {node:thenode,head:translateText({path: ".nm-sgpw", id:"Join MySites now!"}),boxed:true};
    //}else{
    //  var o = {node:EMPTY(),head:EMPTY(),boxed:false}
    //}
    return o;
  },  
  makePartnersBox:function(){
var btbdiv = Builder.node('a',{style:"color:black;border:0px;",href:"http://www.nforce.nl"},[Builder.node('div',{style:"cursor:pointer;margin:0 auto;width:171px;height:51px;background:url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px 0px"},[])]);

//Event.observe($(btbdiv),'click',function(e){
//window.open("http://www.nforce.nl");
//}.bind(this));

Event.observe($(btbdiv).down(),'mouseover',function(e){
$(btbdiv).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) 0px 0px"});
}.bind(this));
Event.observe($(btbdiv).down(),'mouseout',function(e){
$(btbdiv).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px 0px"});
}.bind(this));

var btbdiv2 = Builder.node('a',{style:"color:black;border:0px;",href:"http://www.dazzboard.com"},[Builder.node('div',{style:"cursor:pointer;margin:0 auto;width:171px;height:51px;background:url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px -51px"},[])]);

Event.observe($(btbdiv2),'click',function(e){
window.open("http://www.dazzboard.com");
}.bind(this));

Event.observe($(btbdiv2).down(),'mouseover',function(e){
$(btbdiv2).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) 0px -51px"});
}.bind(this));

Event.observe($(btbdiv2).down(),'mouseout',function(e){
$(btbdiv2).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px -51px"});
}.bind(this));


    var thenode = Builder.node('div',{style:""},[
BR(),
btbdiv,
BR(),
BR(),
btbdiv2,
BR(),
Builder.node('div',{style:"width:100%;text-align:right;"},[
      Builder.node('a',{style:"color:black;",href:""},[translateText({path: ".nm-sgpw", id:"Become a partner"})])
])
    ])
    var o = {node:thenode,head:translateText({path: ".nm-sgpw", id:"Partner Sites"}),boxed:true};
    return o;
  },  
  afterInitWidget:function(){
     var params = parameters();
     $("myright").setStyle({paddingTop:"200px"}); 
     uploadItem(false);    
  },
  makeFanpageWidget:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleFacebookFanpageWidget({}).htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  makeWidgetContent: function(){  
    uplbtn = this.makeUploadButtonWidget();
    var left = [
      //{node:new simpleRegisterInfoWidget().htmlNode(),head:translateText({path: ".nm-sgpw", id:"Why Register?"}),boxed:true},
      this.makeRegisterWidget(),
      this.makeFanpageWidget(),
      this.makePartnersBox(),
      {node:Builder.node('div',{style:"height:450px;"}),head:EMPTY(),boxed:false}
    ];

    var feat = Builder.node('div',{style:"position:relative;top:320px;"},[
simpleLayoutWidget.prototype.makeSimplebox(
new simpleFeaturedAccountsWidget().htmlNode(),
TN("Featured Users"))
]);

    var right = [      
      {node:feat,head:EMPTY(),boxed:false}
    ];

    right.push({node:Builder.node('div',{style:"height:600px;position:relative;top:320px;width:100%;margin:0 auto;"},[new simpleFBInviteWidget().htmlNode()]),head:EMPTY(),boxed:false});

    window.setTimeout(function(){
      this.afterInitWidget();
    }.bind(this),150);

    var top = [      {node:Builder.node('div',{style:"font-weight:bolder;height:90px;bolder;font-size:200%;margin-bottom:10px;"},[
translateText({path: ".nmsgpw", id:"head"})
]),head:EMPTY(),boxed:false}
    ];

    layoutwidget = new simpleLayoutWidget({top:top,left:left,right:right});

    layoutwidget.contenthead.setStyle({height:"90px"});

    return layoutwidget.htmlNode();
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleGuestPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <199074> simpleheaderwidget.js 

simpleHeaderWidget = Class.create();
simpleHeaderWidget.prototype = {
  defaultOptions: function(){
    return {
mode:"slim"//"slim"
    }
  },
  makeHeaderIcons:function(){  

    if(logged_in){
      var badge = Builder.node('div',{style:"width:150px;margin-top:2px;float:left;height:100%;"},
      [new simpleBadgeWidget({height:45,width:150,iconsize:32}).htmlNode()]);
      $(badge).setStyle({float:"left",marginRight:"10px"});

new simpleTooltipWidget({targetnode:badge,content:Builder.node('div',{style:""},[
      TN("Click here visit your site")
    ])
    })
    

    }else{
      var badge = EMPTY();
    }
var uploadnow = EMPTY();

if(logged_in){
var uploadnow = Builder.node('div',{className:"bigbutton",style:"font-weight:bolder;font-size:18px;width:120px;margin-top:3px;float:left;height:100%;margin-left:20;"},[
Builder.node('div',{style:"width:auto;margin: 0 auto;"},[
Builder.node('div',{style:"margin-left:5px;margin-top:5px;width:24px;height:24px;margin-right:10px;float:left;"},[
Builder.node('img',{src:"http://core.myfil.es/get_file/add-item.png"})
]),
Builder.node('div',{style:"width:auto;float:left;margin-left:0px;"},[TN("Upload")]),
Builder.node('div',{style:"clear:both;"},[])
])
]);

new simpleTooltipWidget({targetnode:uploadnow,content:Builder.node('div',{style:""},[
      TN("Click here to add files to MySites")
    ])
    })
    Event.observe($(uploadnow),'click',function(){
      uploadItem();
    });
}

    var c = Builder.node('div',{style:"clear:both;"},[]);
var w = 510;
if(logged_in){
    w = 100;
}

var logout = Builder.node('div',{id:"logout",style:"float:right;margin-top:3px;width:"+w+"px;height:30px;"},[new simpleLoginLogoutWidget().htmlNode()]);

var flags = EMPTY();

//Builder.node('div',{style:"float:left;margin-top:5px;width:100px;height:20px;"},[new simpleFlagsWidget().htmlNode()]);

    this.homeimage = serviceLink({
	user: "core",
	service: "files@core",
	action:"get_file/gohome.gif"
    });

var searchnow = EMPTY();
if(logged_in){
  var searchw = new simpleSearchFormWidget();
  var searchnow = searchw.makeSearchField();
  Event.observe($(searchnow),'click',function(){
    searchItems(searchw);
  });
  $(searchnow).setStyle({marginLeft:"20px",marginTop:"3px"});
}

this.homeicon = Builder.node('div',{style:"position:relative;left:-40px;top:0px;float:left;margin-right:10px;width:24px;height:24px;overflow:hidden;background:url("+this.homeimage+") -24px 0px;"},[]);

        this.divheadericons = Builder.node('div',            {id:"topiconsdiv",style:"position:relative;line-height:30px;padding:1px;float:left;width:79%;left:185px;"}
          ,[Builder.node('div',{style:"margin-top:0px;"},[this.homeicon,badge,uploadnow,searchnow,flags,logout,c])]);

        return this.divheadericons;
    },
  makeWidgetContent: function(){


    if(this.options.mode == "normal"){
    var l1 = serviceLink({
	user: "core",
	service: "files@core",
	action:"get_file?path=/headtopfill.png"
    });
    var l2 = serviceLink({
	user: "core",
	service: "files@core",
	action:"get_file?path=/headtopleft.png"
    });
    var l3 = serviceLink({
	user: "core",
	service: "files@core",
	action:"get_file?path=/headtopright.png"
    });

    var logo = Builder.node('a',    {href:"http://www.mysites.com",style:"float:left;cursor:pointer;width:230px;height:100%;background:url("+l2+")"},[]);

    var headericons = this.makeHeaderIcons();

    var c = Builder.node('div',{style:"clear:both;"},[]);
    var headd = Builder.node('div',
      {style:"width:100%;height:81px;background:url("+l1+")"},
        [logo,headericons,c]);

    return Builder.node('div',{style:"width:100%;"},[headd,BR()]);

    }else{

      var l1 = serviceLink({
	user: "core",
	service: "files@core",
	action:"get_file/hbg.png"
      });
      var l2 = serviceLink({
	user: "core",
	service: "files@core",
	action:"get_file/hlogo.png"
      });

      var logo = Builder.node('a',{href:"http://www.mysites.com",style:"z-index:99;position:absolute;cursor:pointer;margin-top:5px;width:187px;height:78px;background:url("+l2+")"},[]);

    Event.observe($(logo),'mouseover',function(e){
      $(this.homeicon).setStyle({background:"url("+this.homeimage+") 0px 0px"});
    }.bind(this));
    Event.observe($(logo),'mouseout',function(e){
      $(this.homeicon).setStyle({background:"url("+this.homeimage+") -24px 0px"});
    }.bind(this));

      var headericons = this.makeHeaderIcons();

      var headd = Builder.node('div',
      {style:"z-index:2;position:relative;top:20px;width:100%;height:40px;background:url("+l1+") repeat-x;"},
        [headericons]);

      return Builder.node('div',{id:"pageheader",style:"position:relative;width:100%;"},[logo,headd,BR(),BR()]);
    }       
  }
}  
Object.extend(simpleHeaderWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <217742> simpleitemactionswidget.js 

function saveToProfile(d){
  var p = {userimage:d};
  writeUserModel.editAccountSettings(p);
  writeUserModel.observeOnce({update:function(d){
    writeUserModel.notifyObservers("profileChanged",p);
  }});
}

var editornode = null;
function editItem(){
  if(editornode != null){
    $(editornode).remove();
  }
  if(itempage != null || folderpage != null){
    if(itempage != null){
      var m = itempage.options.m;
    }else if(folderpage != null){
      var m = folderpage.options.m;
    }
    if(logged_in && itemModel.canWrite()){
      editornode = simpleLayoutWidget.prototype.makeSimplebox(new simpleItemEditorWidget({m:m}).htmlNode(), translateText({path: ".nm-sia", id: "Edit item"}));
      Element.insert($("myright"),{top:editornode});
    }
   
  }else{

  }
}

var uploadernode = null;
function uploadItem(){
  if(uploadernode != null){
    $(uploadernode).remove();
    swfu.destroy();
  }
  //if(logged_in){
    var album = "";
    if(folderpage != null){
      album = folderpage.options.m.name;
    }

if(arguments[0] == false){
    var swfupl = Builder.node('div',{style:"margin-right:30px;height:150px;"},[new simpleSWFUploadWidget({style:"top:0;position:relative;left:40px;",width:300,album_name:album}).htmlNode()]);
    uploadernode = swfupl;
}else{
    var swfupl = Builder.node('div',{style:"height:150px;"},[new simpleSWFUploadWidget({album_name:album}).htmlNode()]);

   uploadernode = simpleLayoutWidget.prototype.makeSimplebox(swfupl, translateText({path: ".nm-sia", id: "Upload Files"}));
}

    Element.insert($("myright"),{top:uploadernode});
 // }
}


var searchnode;

function searchItems(w){
  if(searchnode != null){
    $(searchnode).remove();
  } 
  var search = w.htmlNode();
  searchnode = simpleLayoutWidget.prototype.makeSimplebox(search, TN("Search"));
  Element.insert($("myright"),{top:searchnode});
}


simpleItemActionsWidget = Class.create();
simpleItemActionsWidget.prototype = {
  defaultOptions: function(){
    return Object.extend(
    {
      tooltip:false,
      style:"",
      profile:true,
      edit:true,
      icon:true,
      iconsize:24,
      maxwidth:90,
      tipped:false,
      rt:"compact",
      corr:-5,
      gap:20,
      height:16,
      width:50
    },arguments[0]);
  },
  setup:function(){

  },
  makeActionButton:function(o){

    var s = "font-weight:normal;overflow:hidden;text-align:center;width:"+this.options.width+"px;float:left;height:"+this.options.height+"px;line-height:"+(this.options.height+1)+"px;";
    var sub = "position:absolute;top:40px;clear:both;left:0px;margin-top:0px;line-height:11px;font-size:10px;font-weight:normal;";
    var sub2 = "margin-top:5px;margin-top:0px;padding-top:5px;font-size:10px;";
    var as = "-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;color:black;text-decoration:none;font-size:11px;margin-right:"+this.options.gap+"px;float:left;width:"+this.options.maxwidth+"px;height:"+this.options.height+"px;";


    var btnbtn = Builder.node('div',{style:s},[Builder.node('div',{style:s},[o.text])]);      
    var icobtn = this.makeIcon(o.icon);
    var btn =  Builder.node('a',{href:o.href,className:"bigbutton",style:as},[icobtn,btnbtn]); 

    if(this.options.tipped){
      $(btn).setStyle({position:"relative"});
      $(btn).appendChild(this.makeTip());
      $(btn).appendChild(Builder.node('div',{style:sub},[
        Builder.node('div',{style:sub2},[o.sub])
      ]));
    }
 
    if(this.options.tooltip){
      new simpleTooltipWidget({
        color:"dgrey",
        targetnode:btn,
        content:Builder.node('div',{style:""},[
          o.tt
        ])
      })
    }

    return btn;
  },
  makeToolTip:function(){
    var tt = EMPTY();
    return tt;
  },
  makeIcon:function(s){
    var ico = EMPTY();
    if(this.options.icon){
      var ico = Builder.node('div',{style:"margin-top:"+this.options.corr+"px;margin-left:0px;width:"+this.options.iconsize+"px;margin-left:5px;float:left;"},[
        Builder.node('img',{src:s,border:"0"},[])
      ]);
    return ico;
    }
  },
  makeTip:function(){
    var s = "left:10px;position:absolute;top:"+this.options.height+"px;width:9px;height:5px;background:url(http://core.myfil.es/get_file/social/smltip.png);";
    var tip1 = Builder.node('div',{style:s},[])
    return tip1;
  },
  makeActions:function(){
   
    this.publish = EMPTY();
    this.download =  EMPTY();
    this.profile = EMPTY();
    this.edit = EMPTY();

    this.publish = this.makeActionButton({
      tt:translateText({path: ".nm-sia", id: "Publish this item to your Facebook-Account."}),      
      sub:translateText({path: ".nm-sia", id: "Publish to your wall"}),
      text:new simpleFBPublishStreamWidget({
        style:"height:"+this.options.height+"px;",
        name:this.options.m.name,
        caption:translateText({path: ".nm-sia", id: "Share this"}).innerHTML,
        items:[this.options.m]
      }).htmlNode(),
      href:"javascript:void(0);",
      icon:"http://core.myfil.es/get_file/social/fbico.png"
    });


    if(this.options.m.type != "folder"){
      this.download = this.makeActionButton({
        tt:translateText({path: ".nm-sia", id: "Download this item to your Harddrive"}),
        sub:translateText({path: ".nm-sia", id: "Save to your computer"}), 
        text:translateText({path: ".nm-sia", id: "Save"}), href:this.options.m.full_item_url,
        icon:"http://core.myfil.es/images/icons/turquoise/22x22/download.gif"
      }); 
    }

    if(logged_in && itemModel.canWrite() && this.options.edit){
 
      this.edit = this.makeActionButton({
        tt:translateText({path: ".nm-sia", id: "Edit this Item"}), 
        sub:translateText({path: ".nm-sia", id: "Edit or delete this item"}), 
        text:translateText({path: ".nm-sia", id:"Edit"}), 
        href:"javascript:editItem();",
        icon:"http://core.myfil.es/images/icons/turquoise/22x22/edit.gif"
      }); 
    }


    if(mimeTypeCategory(this.options.m) == "Image" 
      && logged_in && this.options.m.permission == "everyone"){
if(this.options.profile){
      this.profile = this.makeActionButton({tt:translateText({path: ".nm-sia", id: "Set this picture as your MySites Profile-Photo"}), sub:translateText({path: ".nm-sia", id: "Set this as your Photo"}), text:translateText({path: ".nm-sia", id:"Profile" }), href:"javascript:saveToProfile(\'"+this.options.m.full_item_url+"\');",icon:"http://core.myfil.es/images/icons/mycons/24x24/play.png"});

}

    }

    var surl = (this.options.m.full_item_url ? this.options.m.full_item_url : document.location);
    var rt = Builder.node('div',{style:"width:auto;float:left;"},[new simpleRetweetWidget({link:document.location+"/?static-only=1",style:this.options.rt}).htmlNode()]);
   

   var c = Builder.node('div',{style:"clear:both;"},[]);

   return Builder.node('div',{style:this.options.style},[this.edit,this.download,this.profile,this.publish,rt,c]);

  },
  saveToProfile:function(){

  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeActions();
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleItemActionsWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <218400> simpleitemeditorwidget.js 

simpleItemEditorWidget = Class.create();
simpleItemEditorWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null,model:itemModel},arguments[0]);
  },
  setup:function(){
    this.formwidget = null;
  },
  makeItemEdit:function(){
    if(this.options.m.type == "folder"){
      this.type = this.options.m.type;  
    }else{
      this.type = mimeTypeCategory(this.options.m);
    }

    var src = "";
    var text = "this is a ";

    switch(this.type){
      case "Image":
        var text = "this is an ";
        src = "http://core.myfil.es/get_file/social/edit-pictures.png";
        break;

      case "Movie":
        src = "http://core.myfil.es/get_file/social/edit-movies.png";
        break;

      case "Tune":
        src = "http://core.myfil.es/get_file/social/edit-tunes.png";
        break;

      case "File":
        src = "http://core.myfil.es/get_file/social/edit-files.png";
        break;

      case "folder":
        src = "http://core.myfil.es/get_file/social/edit-settings.png";
        break;

      default:
      src = "http://core.myfil.es/get_file/social/edit-settings.png";
    }

    var head = Builder.node('div',{},[translateText({path: ".nm-siew", id:text}),NBSP(),translateText({path: ".nm-siew", id:this.type})]);
    var ico = Builder.node('div',{style:"height:50px;"},[      Builder.node('div',{style:"float:left;margin-right:20px;background:url("+src+");width:45px;height:45px;"},[]),
      Builder.node('div',{style:"float:left;width:200px;height:45px;font-size:160%;font-weight:bolder;"},[head]),
      Builder.node('div',{style:"clear:both;"},[])
    ])
   

    var p = {};
    var m = this.options.m;   

    var everyone = Builder.node('div',{style:"float:left;background:url(http://core.myfil.es/get_file/social/001-40.png);width:24px;height:24px;margin-right:10px;"},[]);
    var everyonetxt = Builder.node('div',{style:"float:left;height:24px;margin-right:10px;"},[translateText({path: ".nm-siew", id:"Public"})]);

    var onlyme = Builder.node('div',{style:"float:left;background:url(http://core.myfil.es/get_file/social/001-42.png);width:24px;height:24px;margin-right:10px;"},[]);
    var onlymetxt = Builder.node('div',{style:"float:left;height:24px;margin-right:10px;"},[translateText({path: ".nm-siew", id:"Private"})]);

    var s = "font-size:14px;font-weight:bolder;border:2px solid transparent;cursor:pointer;float:left;margin-right:10px;padding:10px;";

    this.ppublic = Builder.node('input',{style:"display:none;",type:"radio",name:"permission",value:"everyone"});
    this.pprivate = Builder.node('input',{style:"display:none;",type:"radio",name:"permission",value:"onlyme"});

    var c = Builder.node('div',{style:"clear:both;"},[]);
    var perms = Builder.node('div',{},[
      Builder.node('div',{id:"perm_public",style:s},[this.ppublic,everyone,everyonetxt]),
      Builder.node('div',{id:"perm_private",style:s},[this.pprivate,onlyme,onlymetxt]),
      c
    ]);

    this.delinner = Builder.node('input',{type:"button",className:"bigbutton",value:"delete",style:"background:#FF6F6F;text-decoration:underline;color:#AF0A0A;height:50px;width:200px;"},[]);

    this.delbtn = Builder.node('div',{style:"text-decoration:underline;color:red;height:50px;"},[
this.delinner
    ])
  
    Event.observe($(this.delbtn),'click',function(e){
      //this.options.model.moveItemToTrashOrRemoveFromModel(this.options.m);
      this.deleteItem();
    }.bind(this));

    p.params = [
      {type:"node",node:ico,label:"Info:",kk:"",vv:""},
      {type:"text",label:"Name:",kk:"name",vv:(m.name ? m.name : "no name")},
      {type:"node",node:perms,label:"Permission:",kk:"permission",vv:""},
      {type:"text",label:Builder.node('span',{style:""},[translateText({path: ".nm-siew", id:"Description:"}),Builder.node('span',{style:"color:silver;"},[translateText({path: ".nm-siew", id:"*optional"})])]),kk:"description",vv:(m.description?m.description :"")},
      {type:"text",label:Builder.node('span',{style:""},[translateText({path: ".nm-siew", id:"Tags:"}),Builder.node('span',{style:"color:silver;"},[translateText({path: ".nm-siew", id:"*optional"})])]),kk:"tags",vv:(m.tags ? m.tags : "")},
      {type:"node",node:Builder.node('div',{},[this.delbtn]),label:"Delete:",kk:"delete",vv:""}
    ];

    this.formwidget = new simpleFormWidget(p);
    return Builder.node('div',{},[this.formwidget.htmlNode()]);
  },  
  deleteItem:function(){

    $(this.delinner).value = "Really?";
    $(this.delinner).setAttribute("value","Really?");
    window.setTimeout(function(){
      $(this.delinner).value = "Really!";
      $(this.delinner).setAttribute("value","Really!");
    }.bind(this),1000);

    $(this.delbtn).stopObserving('click');

    Event.observe($(this.delbtn),'click',function(e){
      this.reallyDeleteItem();
    }.bind(this));

  },
  reallyDeleteItem:function(){

    var path = this.options.model.currentPath();
    if(this.type == "folder"){
      path = "/";
    }
    this.options.model.ajaxRequest({
      action: "move_to_trash",
      onSuccess: function(success) { 
        this.options.model.removeItem(this.options.m);
        this.notification.showNotification(translateText({path: ".nm-siew", id:"This item has been deleted."}));
        this.options.model.update();
        $(this.content).up().remove();
      }.bind(this)
    }, {
      form_path: path,
      form_name: this.options.m.pretty_name
    })

  },
  saveItem:function(p){
    if(p != {}){
      //writeUserModel.editAccountSettings(p);

      var m = Object.extend(this.options.m,p);
      var path = this.options.model.currentPath();
      if(this.type == "folder"){
        path = "/";
      }


   if (!this.options.model.canWrite()) { return }

    var options = Object.extend({
      afterStore: function() {}
    }, arguments[1] || {})
    var instance = this.options.model;
    var fields = this.options.model.storeRequestFieldsForItem(m)
    var action = (m.id == -1 ? "create_item" : "edit")
    if (isFolder(m) || m.generic_folder) {
      action = (m.id == -1 ? "create_folder" : "edit")
    }
    if (__patch_ajax_action) { action = __patch_ajax_action }
    new AjaxFormBuilder({
      user: this.options.model.user(),
      service: this.options.model.service(),
      action: action,
      onSuccessfulSubmit: function(afb, success) {
        hash_merge(m, success.item_info)
        m.edit = false
        m.increation = false
        instance.update()
        instance.notifyObservers("afterStore")
        options.afterStore(m)
      }
    }).performAjaxRequest(fields.merge({
      form_path: path,
      form_username_override: this.options.model.user()
    }))

      //this.options.model.storeItem(item);

        this.options.model.observeOnce({update:function(d){
        this.notification.showNotification(translateText({path: ".nm-siew", id:"Your changes have been saved."}));
        this.options.model.notifyObservers("itemChanged",p);
        window.setTimeout(function(){
          this.rerender();
        }.bind(this),3000);
      }.bind(this)});
    }
  },
  validateForm:function(){

  },
  clickSave:function(){
    if(this.formwidget != null){
      var f = Form.serialize(this.formwidget.form,{hash:true});
      this.saveItem(f);
    }
  },
  makeWidgetContent: function(){ 
    this.notification = new simpleNotificationWidget({s:"",width:250,height:50,icon:true});
  
    var savebtn = Builder.node('div',{style:"width:100px;margin-right:20px;float:left;"},[Builder.node('input',{type:"button",className:"bigbutton",value:"save",style:"height:50px;width:100px;"},[])])

    var cancelbtn = Builder.node('div',{style:"width:100px;margin-right:20px;float:left;"},[Builder.node('input',{type:"button",className:"bigbutton",value:"cancel",style:"height:50px;width:100px;"},[])])

    var notifierarea = Builder.node('div',{
      id:"notifierarea",
      style:"margin-top:-5px;width:200px;margin-right:20px;float:left;"
    },[
      this.notification.htmlNode()
    ])

    var cl = Builder.node('div',{style:"clear:both;"});
   

    Event.observe($(savebtn),'click',function(e){
      this.clickSave();
    }.bind(this));

    Event.observe($(cancelbtn),'click',function(e){
      //this.redrawCompletely();
      $(this.content).up().remove();
    }.bind(this));

    this.controls = Builder.node('div',{},[cancelbtn,savebtn,notifierarea,cl]);

    this.editbox = Builder.node('div',{id:"editbox",style:"height:10px;overflow:hidden;"},[]);
   
    this.wrapper = Builder.node('div',{style:"height:630px;"},[
      Builder.node('div',{},[this.makeItemEdit()]),      
      Builder.node('div',{style:"clear:both;"},[]),BR(),
      this.editbox,
      this.controls
    ]);

    this.initf = function(){
      Event.observe($("perm_public"),'click',function(e){
        this.selectPublic();
      }.bind(this));

      Event.observe($("perm_private"),'click',function(e){
        this.selectPrivate();
      }.bind(this));

      if(this.options.m.permission == "onlyme"){
        this.selectPrivate();
      }else if(this.options.m.permission == "everyone"){
        this.selectPublic();
      }
    }
    
    if(!this.options.model.canWrite()){
      this.wrapper = Builder.node('div',[translateText({path: ".nm-siew", id:"NO PERMISSION TO EDIT ITEM"})]);
      this.initf = function(){};
    }
    if(this.type == "folder" && this.options.model.currentPath() == "/"){
      this.wrapper = Builder.node('div',[translateText({path: ".nm-siew", id:"NO PERMISSION TO EDIT ROOT"})]);
      this.initf = function(){};
    }

    window.setTimeout(function(){
      this.initf();
    }.bind(this),200);

    return this.wrapper;
  }, 
  selectPublic:function(){

$(this.ppublic).checked = "checked";
$(this.pprivate).checked = "";

    $("perm_private").setStyle({fontStyle:"normal",color:"black",border:"2px solid transparent"});
    $("perm_public").setStyle({border:"2px dotted silver"});       
    $("perm_public").setStyle({
      color:"black",fontStyle:"italic",fontWeight:"bolder"
//,background:"url(http://core.myfil.es/get_file/social/q.png)"
    });
    $("perm_private").setStyle({background:"transparent"});
    $("perm_private").setOpacity(0.3);
    $("perm_public").setOpacity(1);
  },
  selectPrivate:function(){

$(this.ppublic).checked = "";
$(this.pprivate).checked = "checked";

    $("perm_public").setStyle({fontStyle:"normal",color:"black",border:"2px solid transparent"});
    $("perm_public").setStyle({background:"transparent"});
    $("perm_private").setStyle({border:"2px dotted silver"});
    $("perm_private").setStyle({
      color:"black",fontStyle:"italic",fontWeight:"bolder"
//,background:"url(http://core.myfil.es/get_file/social/q.png)"
    });
    $("perm_public").setOpacity(0.3);
    $("perm_private").setOpacity(1);
  },
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleItemEditorWidget.prototype, WidgetCommon);


;

// /8::/202::/core:js -> <203601> simpleitemlist.js 

//NEEDS CLEANUP
var itemlist;

simpleItemListWidget = Class.create();
simpleItemListWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      onuserpage:false,
      icon:true,
      widget:null,
      model:null,
      albumlistmode:false,
      pagination:true,
      items:null,
      iconsize:64,
      spacing:40,
      displayItemClicked:null,
      font:"font-size:100%;",
      share:true,
      info:true,
      txt:TN(read_user_model_data.username+" has no public files"),
      borderstyle:"border:4px solid silver;border-radius:6px;-moz-border-radius:6px"
     },arguments[0]);
  },
  setup:function(){
    itemlist = this;
    this.filter = null;

    //no items given
    if(this.options.items == null){

//this.options.model.options.reverse = false;
//this.options.model.options.sorted = true;
this.options.model.options.itemsPerPage = 5;
//this.options.model.setSortByColumn("added_at");

      if(!this.options.albumlistmode){
        this.options.model.addObserver(this);
      }
      this.options.items = this.options.model.getModel()
      if(this.options.widget){
        this.options.widget.addObserver(this);
      }      
    }
  },
  loadedItems:function(d){
    this.options.model = d.loader;
    this.rerender();
  },
 getType:function(m,b){
   var type = "file";
    var mime = "";
    try{
      var mime = mimeTypeCategory(m);
      switch(mime){
        case "Audio":
          type = "tune";
          break;
        case "Video":
          type = "movie";
          break;
        case "Image":
          type = "picture";
          break;
        case "File":
          type = "file";
          break;
        default:
      }
    }catch(e){
      return (m.type != undefined ? m.type : "file");
    }
    if(b){
      type = (mime != undefined ? mime : m.type);
    }
    return type;
  },
  sortBy:function(n,reverse){   
      if(n == "oldest"){
        n = "added_at";
        this.options.model.options.reverse = reverse;
      }else if(n == "newest"){
        this.options.model.options.reverse = !reverse;
        n = "added_at";
      }
      this.options.model.setSortByColumn(n); 
  },
  filterBy:function(s){
    if(s != ""){  
      this.filter = s;
    }else{
      this.filter = null;
    }
    this.rerender();
  },
  getFilteredModel:function(r){

if(this.options.model != null){

    if(this.filter){
var fm = this.options.model.options.filter(this.options.model.sortedModel().select(function(m) {
      return this.getType(m) == this.filter.toLowerCase()
      }.bind(this)));
     if(r) fm.reverse();
      return fm;
    }else{
     var fm = this.options.model.getModel();
     //if(r) fm.reverse();
     return fm;
    }
}else{
return this.options.items;
}
  },
  sortingChanged:function(s,d){
   //alert("sortingChanged Event: "+d);
   this.sortBy(d.split(";")[0],d.split(";")[1]);
  },
  serviceChanged:function(s,d){
   this.filterBy(d.split(";")[0]);
   //alert("serviceChanged Event: "+d);
  },
  setItems:function(itms){
    this.options.items = itms;
  },
  makeSingleItem:function(m){
    var cuser = this.options.model.users()[(m.account_id ? m.account_id : 0)];


    var infow = "75%";
    if(this.options.icon == false || this.getType(m) == "folder"){
        icon = EMPTY();
        itemtype = Builder.node('div',
      {style:"float:left;height:24px;width:24px;margin-right:5px;"},
        [TN("/")]);
        spacer = EMPTY();
        infow = "95%";
var badge =  EMPTY();

    }else{

    var badge = Builder.node('div',{style:"z-index:55;overflow:hidden;padding:10px;float:left;width:20%;"},[
      new simpleBadgeWidget({width:100,mode:"vertical",usermodel:cuser,iconsize:this.options.iconsize}).htmlNode()
    ]);

new simpleTooltipWidget({color:"dgrey",targetnode:badge,content:Builder.node('div',{style:"width:150px;"},[
      TN("Click here to visit "+cuser.username.reflexive()+" site")
    ])})

    var icon = Builder.node('div',{style:"border-radius:6px;-moz-border-radius:6px;border:1px solid #888888; float:left;width:"+this.options.iconsize+"px;height:"+this.options.iconsize+"px;background:url("+m.thumbnail_image_url+") -"+((190/2) - (this.options.iconsize/2))+"px -"+((127/2) - (this.options.iconsize/2) )+"px;"},
      []);

    var spacer = Builder.node('div',{style:"float:left;width:10px;"},[NBSP()]);
    var imgurl = "http://www.mysites.com/images/my"+this.getType(m)+"s.png";
    var itemtype = Builder.node('div',
      {style:"background:url("+imgurl+");float:left;width:24px;height:24px;margin-right:10px;"},
        []
    );

}


    var info = Builder.node('div',
      {style:"width:"+infow+";float:left;overflow:hidden;font-size:130%;font-weight:normal;"},
        [itemtype,
        Builder.node('div',{style:"width:235px;float:left;height:60px;overflow:hidden;float:left;"},[TN(m.name)]),
        //Builder.node('div',{style:"clear:both;"}), 
        
        Builder.node('div',{style:"clear:both;"})]
    );

    var item = Builder.node('a',
      {style:"width:100%;height:"+(this.options.iconsize+30)+"px;letter-spacing:-2px;font-size:14px;line-height:20px;position:relative;color:grey;",
      href:this.options.model.currentPathPermalink(m)},[
      Builder.node('div',{style:"z-index:85;width:100%;height:100%;"},[
        icon,
        spacer,
        info,
        Builder.node('div',{style:"clear:both;"})      
      ])
    ]);

    if(this.options.displayItemClicked != null){
      $(item).setAttribute("href","javascript:void(0);");
      Event.observe($(item),'click',function(e){
          this.options.displayItemClicked(m);
      }.bind(this));
    }

    var ico = ico = serviceLink({
      service: "files",
      user: "core",
      action: "get_file/tip.gif"
    });

    var tip = Builder.node('div',{style:"position:absolute;top:"+(this.options.iconsize/2 -14 +8)+"px;left:-15px;width:15px;height:29px;background:url("+ico+");"},[]);

    var addedat = Builder.node('div',{style:"font-weight:bolder;font-size:13px;float:left;margin-right:2px;height:20px;width:100px;overflow:hidden;"},
      [makeNiceDate(m.added_at)]);

    var wrapperw = "70%";
    var sharew = "71%";

    if(cuser.username == write_user_model_data.username 
      || this.options.onuserpage || this.getType(m) == "folder"){

        badge = EMPTY();
        tip = EMPTY();
        wrapperw = "96%";
        sharew = "75%";
    }

var share = EMPTY();
if(this.options.share){

    var share = Builder.node('div',{style:"float:right;padding-top:2px;margin-right:0px;height:20px;width:"+sharew+";text-align:right;overflow:hidden;"},
      [this.simpleactionswidget = new simpleItemActionsWidget({edit:false,profile:false,tooltip:true,style:"float:right;",icon:false,maxwidth:55,corr:-3,gap:5,height:16,width:55,m:m}).htmlNode()]);
}

    var moreinfo = Builder.node('div',{style:"margin-left:5px;width:100%;"},[
      addedat,share,Builder.node('div',{style:"clear:both;"})
    ]);

if(!this.options.info){
moreinfo = EMPTY();
}

var roundbox = Builder.node('div',{style:"position:relative;"+this.options.borderstyle+";padding:6px;background:white;float:left;width:100%;height:"+(this.options.iconsize+0)+"px;"},[tip,item])


    var itemwrapper = Builder.node('div',{style:"float:left;width:"+wrapperw+";"},[
      roundbox,
      Builder.node('div',{style:"clear:both;"}),
      moreinfo
    ]);

    return Builder.node('div',{id:"box"+m.id,style:this.options.font+";position:relative;width:100%;height:auto;margin-bottom:"+this.options.spacing+"px;"},[
      badge,itemwrapper,Builder.node('div',{style:"clear:both;"})
    ]);
  },
  makeAllItems:function(){
    var arr = [];
    if(this.options.pagination){
      arr.push(new simplePaginationWidget({model:this.options.model}).htmlNode())
      arr.push(BR())
    }
    this.options.items.each(function(m){
      var itm = this.makeSingleItem(m);
      arr.push(itm)
    }.bind(this));
    if(this.options.items.length == 0){
      arr.push(this.options.txt);
    }
    return arr;
  },
  makeWidgetContent: function(){  
    this.wrapper = Builder.node('div',{style:"font-weight:bolder;font-size:14px;"},
      this.makeAllItems()
    );
    return this.wrapper;
  }, 
  rerender: function(r){
    this.options.items = this.getFilteredModel(r);//
    var nc = this.makeWidgetContent()
    this.replaceChild(this.content, this.widgetContent, nc)
    this.widgetContent = nc  
  }
}  
Object.extend(simpleItemListWidget.prototype, WidgetCommon); 
;

// /8::/202::/core:js -> <193576> simpleitemrenderer.js 

var itempage = null;
simpleItemPageWidget = Class.create();
simpleItemPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null,model:itemModel},arguments[0]);
  },
  setup:function(){
    itempage = this;
    window.setTimeout(function(){
      $(document).title = "MySites";
    },210);
    this.m = this.options.m;
  this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({onuserpage:true,widget:this.albumcontrols,model:this.options.model});    
 
  }, 
  makeUserBadgeWidget:function(){
    var thenode = Builder.node('div',{style:"height:80px;"},[
      new simpleBadgeWidget({iconsize:64,usermodel:read_user_model_data}).htmlNode()
    ])
    return {node:thenode,head:translateText({path: ".nm-supw", id: "User"}),boxed:true};
  },
  makeDownloadThisButton:function(){
    this.simpleactionswidget = new simpleItemActionsWidget({tipped:true,rt:"normal",corr:5,gap:20,height:36,m:this.options.m});
    this.wrapper = Builder.node('div',{style:"margin-bottom:30px;"},[
      this.simpleactionswidget.htmlNode()
    ]);

    return this.wrapper;
  },
  makeShareWidget:function(){
    var thenode = Builder.node('div',[
new simpleEmbedWidget({item:this.m}).htmlNode()
    ])

    return {node:thenode,head:translateText({path: ".nm-supw", id: "Share this"})};
  }, 
  makeHeader:function(){
    var thenode = Builder.node('div',{style:"font-size:160%;font-weight:bolder;"},[
        TN(this.m.name)
    ]);
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  makeWidgetContent: function(){  

    var left = [
      this.makeUserBadgeWidget(),
      {node:Builder.node('div',{id:"sharebox"},[Builder.node('img', {src: "/images/spinner.gif"})]),head:translateText({path: ".nm-supw", id: "Share"}),boxed:true}
    ];

window.setTimeout(function(){
$("sharebox").innerHTML = "";
$("sharebox").appendChild(this.makeShareWidget().node);
}.bind(this),300);

    var s = {style:"width:100%;height:400px;background:white;border:2px solid white;overflow:hidden;z-index:0;"};

    var ic = Builder.node('div',{style:"z-index:10;overflow:auto;cursor:pointer;width:100%;height:405px;color:black;border:2px solid black;"},[]);

    Event.observe($(ic),'click',function(){
      window.open(this.options.m.full_item_url);
    }.bind(this));
    this.itemcontent = {node:ic,head:EMPTY(),boxed:false};

    var right = [
      this.makeHeader(),
      this.itemcontent,
      {node:Builder.node('div',{},[NBSP()]),head:EMPTY(),boxed:false},
      {node:this.makeDownloadThisButton(),head:EMPTY(),boxed:false},
      {node:(new simpleFBCommentsWidget({title:this.options.m.name}).htmlNode()),head:translateText({path: ".nm-supw", id: "Comments"}),boxed:true},
      {node:this.itemlist.htmlNode(),head:EMPTY(),boxed:true}
    ];

    var close = Builder.node('div',{style:"position:relative;top:0px;float:right;top:-80px;cursor:pointer;background:url(http://core.myfil.es/get_file/social/infoclose.png);width:17px;height:16px;"},[]);
    Event.observe($(close),'click',function(e){
        Effect.Fade($(notification),{afterFinish:function(){
          Effect.SlideUp($(layoutwidget.contenthead));
        }});        
    }.bind(this));

    var guestinfo = "";
    guestinfo += "You can share these files with anyone.<br/>";
    guestinfo += "Simply send the link to this page to your contacts.<br/><br/>";
    guestinfo += "We\'ve encrypted this page link, so that others can\'t find your files.<br/>";
    guestinfo += "Do not lose this link! If you lose it, you won't be able to find this page again!<br/>";

    var info = Builder.node('div',{style:"font-size:10px;"},[]);
    info.innerHTML = guestinfo;

    var notification = Builder.node('div',{style:"position:absolute;width:858px;height:88px;background:#FFF1AF;border:1px solid #FFC62F;"},[Builder.node('div',{style:"position:relative;margin:10px;width:auto;"},[info,close])])
    notification.hide();
    window.setTimeout(function(){
      Effect.Appear($(notification));
    }.bind(this),1000);

    var layout = {left:left,right:right};
    if(!logged_in && read_user_model_data.username == "guest"){
      layout.top = [{boxed:false,node:notification,head:EMPTY()}];
    }
    var layoutwidget = new simpleLayoutWidget(layout);
    if(!logged_in && read_user_model_data.username == "guest"){
      layoutwidget.contenthead.setStyle({height:"90px",marginBottom:"20px"});
    }
    return layoutwidget.htmlNode();

  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleItemPageWidget.prototype, WidgetCommon);

;

// /8::/202::/core:js -> <215207> simplelanguageswidget.js 

simpleLanguagesWidget = Class.create();
simpleLanguagesWidget.prototype = {
defaultOptions: function() {
    return {};
},
setup: function() {
    this.ar = [];
    this.s = Builder.node('div', {style:"margin-top:2px;"},[]) 
    this.supportedLanguages().each(function(l,c) {         

       var imglnk = Builder.node('div',{},[TN(l)]);
       var flg = Builder.node('div',{id:l,style:"cursor:pointer;"},[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.s).appendChild(flg);

    }.bind(this))

      

    if (logged_in) {
        this.dm = new DisplayModel({
            user: write_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({background:"#5EB1DC"});
    }catch(e){}
  },
  supportedLanguages: function() {
    return ["English", "German","Finnish"]
  },
  makeWidgetContent: function() {
    return [this.s];
  }
}

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

// /8::/202::/core:js -> <203453> simplelayoutwidget.js 

function is_iphone(){
  var agent = navigator.userAgent.toLowerCase();
  var isiphone = ( agent.indexOf('iphone') != -1 );
  return isiphone
}

var ichecked = false;
simpleLayoutWidget = Class.create();

simpleLayoutWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({tabs:true,top:null,bottom:null,left:[],right:[]},arguments[0]);
  },
  setup:function(){
    if(is_iphone() && !ichecked){
      ichecked =  true;
      alert("iphone..niiice");
      this.is_iphone = is_iphone();
    }
  },
  makeSimplebox:function(c,t){
    var h = Builder.node('div',{style:"padding-top:3px;padding-bottom:3px;margin-bottom:10px;width:100%;background:white;font-size:150%;font-weight:bolder;"},[
Builder.node('div',{style:"margin-left:5px;"},[
t
])
]);
    if(t == EMPTY()){
      h = EMPTY();
    }
    if(c == ""){
      return EMPTY();
    }else{
       return Builder.node('div',{
            style:"margin-bottom:20px;"},[             Builder.node('div',{style:"padding:10px;font-size:12px;font-family:Trebuchet MS;background:#cfdff0 url(http://core.myfil.es/get_file/social/bbg.png) repeat-x -8px 0px; -webkit-border-radius: 6px;-moz-border-radius: 6px;border:1px solid #AFAFAF;"},[
   h,
   c
])
       ]);
    }
  },  
  wrapInBoxes:function(boxes){
    var wrappedboxes = [];
    $(boxes).each(function(box){
      if(box.boxed == false){
        wrappedboxes.push(box.node);
      }else{
        wrappedboxes.push(this.makeSimplebox(box.node,box.head));
      }
    }.bind(this));
    return wrappedboxes;
  },
  makeContentHolder:function(){  

    this.contenthead = EMPTY();
    if(this.options.top != null){
      this.contenthead = Builder.node('div',
        {id:"myhead",style:"overflow:hidden;height:0px;width:860px;background:transparent;"},
          this.wrapInBoxes(this.options.top));
    }

    this.contentleft = Builder.node('div',
      {id:"myleft",style:"overflow:hidden;float:left;height:100%;width:300px;background:transparent;"},
        this.wrapInBoxes(this.options.left));

    this.contentspace = Builder.node('div',{style:"float:left;width:20px"},[NBSP()]);

    this.contentright = Builder.node('div',
      {id:"myright",style:"height:100%;float:left;width:540px;background:transparent;"},
        this.wrapInBoxes(this.options.right));

    this.contentbottom = EMPTY();
    if(this.options.bottom != null){
      this.contentbottom = Builder.node('div',
        {id:"mybottom",style:"height:1px;width:860px;background:transparent;"},
          this.wrapInBoxes(this.options.bottom));
    }

    return Builder.node('div',{style:"height:auto;width:860px;"},[
        this.contenthead,
        this.contentleft,this.contentspace,this.contentright,
        Builder.node('div',{style:"clear:both;"}),
        this.contentbottom
    ]);

  },
  makeWidgetContent: function(){  
    if(this.options.tabs){
      var tabs = new simpleWhereYouAreWidget().htmlNode()
    }else{
      var tabs = EMPTY();
    }
    this.wrapper = Builder.node('div',{style:"width:100%;"},[
Builder.node('div',{style:"width:860px;padding:10px;padding-bottom:0px;margin:0 auto;clear:both;"},[  
tabs
]),
                        Builder.node('div',{style:"border:1px solid #AFAFAF;border-radius:6px;-moz-border-radius:6px;background:white url(http://core.myfil.es/get_file/social/mysitesbg-2.jpg) no-repeat;width:860px;padding:10px;margin:0 auto;clear:both;margin-top:-1px;margin-bottom:20px;padding:20px;"},[                          
                          this.makeContentHolder(),
                          new simpleFooterWidget().htmlNode()
                        ]),BR()
                    ]); 
    return this.wrapper 
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleLayoutWidget.prototype, WidgetCommon); 
;

// /8::/202::/core:js -> <216947> simplelinkswidget.js 

simpleLinksWidget = Class.create();
simpleLinksWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      links:[],
      style:"vertical" //horizontal
    },arguments[0]);
  },
  setup:function(){
 
  },
  makeSingleLink:function(lnk){
   var ico = Builder.node('div',{style:"margin-right:10px;height:25px;width:25px;overflow:hidden;float:left;"},[lnk.ico]);  
   var l = Builder.node('div',{style:"height:25px;width:150px;overflow:hidden;float:left;"},[     Builder.node('a',{style:"font-size:16px;color:black;font-weight:bolder;",href:lnk.link},[lnk.name])
   ]);
   var c = Builder.node('div',{style:"clear:both;"});
   return Builder.node('div',{style:"height:25px;margin-bottom:5px;"},[ico,l,c]);
  },
  makeAllLinks:function(){
    var links = []
    $(this.options.links).each(function(lnk){
      links.push(this.makeSingleLink(lnk));
    }.bind(this));
    this.linkwrapper = Builder.node('div',{},links);
    return this.linkwrapper;
  },
  makeWidgetContent: function(){    

    this.b = Builder.node('div',{style:""},[
      this.makeAllLinks()
      //Builder.node('img', {src: "/images/spinner.gif"})
    ]);    
    this.wrapper = this.b;
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleLinksWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <207076> simpleloginlogoutwidget.js 

simpleLoginLogoutWidget = Class.create();
simpleLoginLogoutWidget.prototype = {
  defaultOptions: function() {
    return {};
  },
  makeLoginForm:function(){

var username_box = Builder.node('input',{id:"username_box",style:"font-size:130%;width:100%;height:100%;font-family:Trebuchet MS;",value:"Username",name:"username",type:"text"},[]);

    var username = Builder.node('div',{style:"margin-top:0px;width:100px;float:left;margin-right:10px;"},[username_box]);
Event.observe($(username_box),'focus',function(){
if($F(username_box) == "Username"){
$(username_box).setAttribute("value","");
}
}.bind(this));
Event.observe($(username_box),'blur',function(){
if($F(username_box) == ""){
$(username_box).setAttribute("value","Username");
}
}.bind(this));

var password_box = Builder.node('input',{id:"password_box",style:"font-family:Trebuchet MS;font-size:130%;width:100%;height:100%;",value:"@@@@@",name:"password",type:"password"},[]);

    var password = Builder.node('div',{style:"margin-top:0px;width:100px;float:left;margin-right:10px;"},[password_box]);

Event.observe($(password_box),'focus',function(){
if($F(password_box) == "@@@@@"){
$(password_box).setAttribute("value","");
}
}.bind(this));

Event.observe($(password_box),'blur',function(){
if($F(password_box) == ""){
$(password_box).setAttribute("value","@@@@@");
}
}.bind(this));

    var sub = Builder.node('div',{style:"width:80px;float:left;height:100%;"},[Builder.node('input',{className:"bigbutton",type:"submit",value:"login",style:"width:80px;height:32px;font-size:20px;background-position:-10px;"},[])]);
var c = Builder.node('div',{style:"clear:both;"},[]);
var f = Builder.node('div',{},[username,password,sub,c]);

    var theform = Builder.node('form',{action:"http://www.mysites.com/login",method:"post"},[f]);
    Event.observe($(theform),'submit',function(e){
      if($F(password_box) == "" || $F(password_box) == "@@@@@" 
        || $F(username_box) == "" || $F(username_box) == "Username"){

        Event.stop(e);
        $(password_box).setStyle({border:"1px solid red"});
        $(username_box).setStyle({border:"1px solid red"});
        return false;
      }
    }.bind(this));
var formdiv = Builder.node('div',{style:"width:300px;overflow:hidden;float:right;"},[theform]);
var fbdiv = Builder.node('div',{style:"width:200px;float:right;"},[this.makeSimpleFBLogin()]);
var sep = Builder.node('div',{style:"color:white;text-align:center;width:10px;overflow:hidden;float:right;"},[TN("|")]);
var c2 = Builder.node('div',{style:"clear:both;"},[]);

    return Builder.node('div',{},[fbdiv,sep,formdiv,c2]);
  },
  makeSimpleFBLogin:function(){

    var fbc = Builder.node('div',{style:"height:30px;margin-top:5px;"},[
new simpleFBLoginWidget().htmlNode()
]);

return fbc;
//Builder.node('a',{href:"http://www.mysites.com/facebook",style:"line-height:16px;color:black;text-decoration:none;"},[fbc]);
  },
  makeLogoutForm:function(){
    var lof = Builder.node('div', {style:"float:right;width:100px;height:40px;background:transparent;"},[
      Builder.node('form', {style:"background:transparent;width:120px;",
        action: serviceLink({
          user: "www",
          service: "sites",
          controllerName: "account",
          action: "logout"
        }),
        method: "POST"
      }, [
        Builder.node('input', {type: "hidden", name: "desired_service", 
            value: itemModel.serviceName() }), 
        Builder.node('input', {type: "hidden", name: "desired_url", 
            value: window.location.href }), 
Builder.node('input',{className:"bigbutton",type:"submit",value:"Logout",style:"width:100px;height:32px;background-position:-10px;font-size:20px;"},[])
        //translateButton({id: "logout",className:"bigbutton",style:"width:100px;"})
      ])
    ])
return lof;
  },
  makeWidgetContent: function() {
    return logged_in ? this.makeLogoutForm() : this.makeLoginForm()
  }
}

Object.extend(simpleLoginLogoutWidget.prototype, WidgetCommon)
;

// /8::/202::/core:js -> <218330> simplemeebowidget.js 

simpleMeeboWidget = Class.create();
simpleMeeboWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  makeWidgetContent: function(){ 
    var div = Builder.node('div',{style:"position:relative;"});
    div.innerHTML = '<div id="meebo" style="display:none"><iframe id="meebo-iframe" src="/core-services/meebo.html?network=mysites"></iframe></div>';
    $(document.body).appendChild(div.firstChild);
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleMeeboWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <425788> simplenewguestpagewidget.js 

var guestpage = null;
simpleNewGuestPageWidget = Class.create();
simpleNewGuestPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null},arguments[0]);
  },
  setup:function(){

$(document.body).setStyle({fontSize:"12px",background:"red"});
   guestpage = this;

   this.CUPLOAD = EMPTY(); //Builder.node('div',{id:"CUPLOAD",style:"position:abolute;top:290px;"},[NBSP()]);

    //this.m = this.options.m;
    this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({widget:this.albumcontrols,model:itemModel});    

  }, 
  makeUploadButtonWidget:function(){

    this.uploadw = new simpleUploadButtonWidget({cloud:true,targetnode:this.CUPLOAD,album_name:"",mode:"html",text:"Upload content to mysites.com:"});

    this.uploadbtn = this.uploadw.htmlNode();
    return {node:this.uploadbtn,head:EMPTY(),boxed:false};
  },
  makeRegisterWidget:function(){
    //if(!logged_in){
      var thenode = Builder.node('div',{style:""},[
        new simpleRegisterWidget({}).htmlNode()        
      ])
      var o = {node:thenode,head:translateText({path: ".nm-sgpw", id:"Join MySites now!"}),boxed:false};
    //}else{
    //  var o = {node:EMPTY(),head:EMPTY(),boxed:false}
    //}
    return o;
  },  
  makePartnersBox:function(){
var btbdiv = Builder.node('a',{style:"color:black;border:0px;",href:"http://www.nforce.nl"},[Builder.node('div',{style:"cursor:pointer;margin:0 auto;width:171px;height:51px;background:url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px 0px"},[])]);

//Event.observe($(btbdiv),'click',function(e){
//window.open("http://www.nforce.nl");
//}.bind(this));

Event.observe($(btbdiv).down(),'mouseover',function(e){
$(btbdiv).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) 0px 0px"});
}.bind(this));
Event.observe($(btbdiv).down(),'mouseout',function(e){
$(btbdiv).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px 0px"});
}.bind(this));

var btbdiv2 = Builder.node('a',{style:"color:black;border:0px;",href:"http://www.dazzboard.com"},[Builder.node('div',{style:"cursor:pointer;margin:0 auto;width:171px;height:51px;background:url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px -51px"},[])]);

Event.observe($(btbdiv2),'click',function(e){
window.open("http://www.dazzboard.com");
}.bind(this));

Event.observe($(btbdiv2).down(),'mouseover',function(e){
$(btbdiv2).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) 0px -51px"});
}.bind(this));

Event.observe($(btbdiv2).down(),'mouseout',function(e){
$(btbdiv2).down().setStyle({background:"url(http://core.myfil.es/get_file/social/slicedpartners.png) -171px -51px"});
}.bind(this));


    var thenode = Builder.node('div',{style:""},[
BR(),
btbdiv,
BR(),
BR(),
btbdiv2,
BR(),
Builder.node('div',{style:"width:100%;text-align:right;"},[
      Builder.node('a',{style:"color:black;",href:""},[translateText({path: ".nm-sgpw", id:"Become a partner"})])
])
    ])
    var o = {node:thenode,head:translateText({path: ".nm-sgpw", id:"Partner Sites"}),boxed:false};
    return o;
  },  
  //afterInitWidget:function(){
  //   var params = parameters();
  //   $("myright").setStyle({paddingTop:"200px"}); 
  //   uploadItem(false);    
  //},
  makeFanpageWidget:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleFacebookFanpageWidget({}).htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  makeWidgetContent: function(){ 
 
   // uplbtn = this.makeUploadButtonWidget();

    var left = [
      //{node:new simpleRegisterInfoWidget().htmlNode(),head:translateText({path: ".nm-sgpw", id:"Why Register?"}),boxed:true},
      this.makeRegisterWidget(),
      {node:Builder.node('div',{style:"height:20px;margin-bottom:20px;"}),head:EMPTY(),boxed:false},
      this.makeFanpageWidget(),
      {node:Builder.node('div',{style:"height:20px;"}),head:EMPTY(),boxed:false},
      this.makePartnersBox()
      //,{node:Builder.node('div',{style:"height:250px;"}),head:EMPTY(),boxed:false}
    ];
/*
    var feat = Builder.node('div',{style:"position:relative;top:320px;"},[
simpleLayoutWidget.prototype.makeSimplebox(
new simpleFeaturedAccountsWidget().htmlNode(),
TN("Featured Users"))
]);
*/
    var right = [      
      {node:Builder.node('div',[BR(),BR(),TN("SLIDES")]),head:TN("About Mysites"),boxed:false},
      {node:this.itemlist.htmlNode(),head:TN("Latest uploads"),boxed:false}
    ];
/*    right.push({node:Builder.node('div',{style:"height:600px;position:relative;top:320px;width:100%;margin:0 auto;"},[new simpleFBInviteWidget().htmlNode()]),head:EMPTY(),boxed:false});
*/

    //window.setTimeout(function(){
    //  this.afterInitWidget();
    //}.bind(this),150);

    var top = [   
/*   {node:Builder.node('div',{style:"font-weight:bolder;height:90px;bolder;font-size:200%;margin-bottom:10px;"},[
translateText({path: ".nmsgpw", id:"head"})
]),head:EMPTY(),boxed:false}
*/
    ];

    var layoutwidget = new simpleLayoutWidget({tabs:false,top:top,left:left,right:right});

    //layoutwidget.contenthead.setStyle({height:"90px"});

    return layoutwidget.htmlNode();
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleNewGuestPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <217920> simplenotificationwidget.js 

simpleNotificationWidget = Class.create();
simpleNotificationWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({mode:"info",icon:false,width:490,height:88},arguments[0]);
  },
  setup:function(){
    this.setMode(this.options.mode);
  },
  setMode:function(m){
    this.iconimage = "";
    if(m == "info"){
      this.options.stylex = "color:black;background:#FFF1AF;border:1px solid #FFC62F;";
      this.iconimage = "http://core.myfil.es/get_file/social/001-06.png"
    }
    if(m == "error"){
      this.options.stylex = "color:white;background:#f64c4c;border:1px solid #cd0b0b;";
      this.iconimage = "http://core.myfil.es/get_file/social/001-05.png"      
    }
    if(this.options.icon){
      this.options.stylex = "color:black;background:transparent;border:1px solid transparent;";
    }
  },
  makeNotification:function(){

    var close = Builder.node('div',{style:"position:absolute;top:0px;float:right;top:-5px;right:-5px;cursor:pointer;background:url(http://core.myfil.es/get_file/social/icloser.png);width:17px;height:16px;"},[]);

    Event.observe($(close),'click',function(e){
        this.hideNotification();      
    }.bind(this));

    this.info = Builder.node('div',{style:"font-size:12px;"},[]); 
    this.icon = EMPTY();   
    if(this.options.icon){
      this.icon =  Builder.node('div',{style:"position:absolute;left:0px;top:0px;width:24px;height:24px;background:url("+this.iconimage+");"},[]);
      this.info = Builder.node('div',{style:"position:absolute;left:30px;font-size:12px;"},[]); 
    }

    this.notification = Builder.node('div',{style:"margin:5px;position:absolute;width:"+this.options.width+"px;height:"+this.options.height+"px;"+this.options.stylex},[Builder.node('div',{style:"position:relative;margin:10px;width:auto;font-size:130%;"},[this.icon,this.info,close])])
    $(this.notification).hide();

    return this.notification;
  },
  showNotification:function(d){
    $(this.notification).setStyle(this.options.stylex);
    $(this.icon).setStyle({background:"url("+this.iconimage+")"});
    this.info.innerHTML = "";
    this.info.appendChild(d);
    Effect.Appear($(this.notification),{afterFinish:function(){
      window.setTimeout(function(){
        this.hideNotification()
      }.bind(this),2000);
    }.bind(this)});
  },
  hideNotification:function(){
    Effect.Fade($(this.notification),{afterFinish:function(){
      //Effect.SlideUp($(layoutwidget.contenthead));
      this.setMode(this.options.mode);
    }.bind(this)});  
  },
  makeWidgetContent: function(){ 
    this.wrapper = this.makeNotification();
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleNotificationWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <208193> simplepaginationwidget.js 

simplePaginationWidget = Class.create();
simplePaginationWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
    model:itemModel
    },arguments[0]);
  },
  setup:function(){
  },
  makeWidgetContent: function(){  
    var prev = Builder.node('div',{style:"height:100%;cursor:pointer;float:left;width:33%;"},[
Builder.node('div',{style:"margin-top:5px;height:40px;color:black;text-decoration:none;"},[
TN("< "),translateText({path: ".nm-spw", id:"previous"}), NBSP(),TN(this.options.model.itemsPerPage()),NBSP(),
translateText({path: ".nm-spw", id:"items"})
])
]);
    Event.observe($(prev),'click',function(e){
      this.options.model.previousPage();
    }.bind(this));
    Event.observe($(prev),'mouseover',function(e){
      $(prev).setStyle({background:"white"});
    }.bind(this));
    Event.observe($(prev),'mouseout',function(e){
      $(prev).setStyle({background:"transparent"});
    }.bind(this));


    var next = Builder.node('div',{style:"height:100%;text-align:right;cursor:pointer;float:left;width:33%;"},[
Builder.node('div',{style:"margin-top:5px;height:40px;color:black;text-decoration:none;"},[
translateText({path: ".nm-spw", id:"next"}), NBSP(),TN(this.options.model.itemsPerPage()),NBSP(),
translateText({path: ".nm-spw", id:"items"}),NBSP(),TN(">")
])
]);

    Event.observe($(next),'click',function(e){
      this.options.model.nextPage();
    }.bind(this));
    Event.observe($(next),'mouseover',function(e){
      $(next).setStyle({background:"white"});
    }.bind(this));
    Event.observe($(next),'mouseout',function(e){
      $(next).setStyle({background:"transparent"});
    }.bind(this));

    if(this.options.model.currentPage() == 1){
      prev = Builder.node('div',{style:"height:100%;text-align:right;float:left;width:33%;"},[]);
    }else if(this.options.model.pageCount() == this.options.model.currentPage()){
      next = Builder.node('div',{style:"height:100%;text-align:right;float:left;width:33%;"},[]);
    }

    if(this.options.model.pageCount() <= 1){

return EMPTY();

       var curr = Builder.node('div',{style:"height:100%;text-align:center;float:left;width:100%;"},[
Builder.node('div',{style:"margin-top:5px;height:40px;color:black;text-decoration:none;"},[
TN(this.options.model.currentPage()+" / "+this.options.model.pageCount()),NBSP(),
translateText({path: ".nm-spw", id:"Pages"})
])
]);

      this.wrapper = Builder.node('div',{style:"margin-top:5px;height:30px;background:silver;font-weight:bolder;font-size:110%;"},[curr,Builder.node('div',{style:"clear:both;"})]);
    }else{

      var curr = Builder.node('div',{style:"height:100%;text-align:center;float:left;width:33%;"},[
Builder.node('div',{style:"margin-top:5px;height:40px;color:black;text-decoration:none;"},[
TN(this.options.model.currentPage()+" / "+this.options.model.pageCount()),NBSP(),
translateText({path: ".nm-spw", id:"Pages"})
])
]);

      this.wrapper = Builder.node('div',{style:"margin-top:5px;height:30px;background:transparent;font-weight:bolder;font-size:110%;"},[prev,curr,next,Builder.node('div',{style:"clear:both;"})]);
    }

    return this.wrapper;
  },
  rerender: function(){ 
    this.redrawCompletely()
  }
}  
Object.extend(simplePaginationWidget.prototype, WidgetCommon); 
;

// /8::/202::/core:js -> <217865> simpleprofilewidget.js 

simpleProfileWidget = Class.create();
simpleProfileWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null},arguments[0]);
  },
  setup:function(){
    this.formwidget = null;
    this.panel = null;
  },
  makeSwitchTabs:function(){

    var tab2 = Builder.node('div',{id:"ptab2",style:"cursor:pointer;margin-right:5px;margin-top:1px;font-size:10px;font-weight:normal;float:left;width:100px;height:17px;border:1px solid #888888;border-bottom:1px solid transparent;"},[Builder.node('div',{style:"margin:0 auto;width:80px;top:5px;align:center;color:black;text-decoration:none;"},[TN("Change profile")])]);

new simpleTooltipWidget({targetnode:tab2,content:Builder.node('div',{style:"width:200px;"},[
      TN("Change your personal information.")
    ])
    })

Event.observe($(tab2),'click',function(e){
this.setPanel(this.makeChangeProfile(),2);
}.bind(this));
Event.observe($(tab2),'mouseover',function(e){
$(tab2).setStyle({background:"white"});
}.bind(this));
Event.observe($(tab2),'mouseout',function(e){
$(tab2).setStyle({background:"transparent"});
}.bind(this));

   var tab3 = Builder.node('div',{id:"ptab3",style:"cursor:pointer;margin-right:5px;margin-top:1px;font-size:10px;font-weight:normal;float:left;width:100px;height:17px;border:1px solid #888888;border-bottom:1px solid transparent;"},[Builder.node('div',{style:"margin:0 auto;width:80px;top:5px;align:center;color:black;text-decoration:none;"},[TN("Change Password")])]);

new simpleTooltipWidget({targetnode:tab3,content:Builder.node('div',{style:"width:200px;"},[
      TN("Change your password")
    ])
    })

Event.observe($(tab3),'click',function(e){
this.setPanel(this.makeChangePassword(),3);
}.bind(this));
Event.observe($(tab3),'mouseover',function(e){
$(tab3).setStyle({background:"white"});
}.bind(this));
Event.observe($(tab3),'mouseout',function(e){
$(tab3).setStyle({background:"transparent"});
}.bind(this));


    var tab4 = Builder.node('div',{id:"ptab4",style:"cursor:pointer;margin-right:5px;margin-top:1px;font-size:10px;font-weight:normal;float:left;width:100px;height:17px;border:1px solid #888888;border-bottom:1px solid transparent;"},[Builder.node('div',{style:"margin:0 auto;width:65px;top:5px;align:center;color:black;text-decoration:none;"},[TN("Change design")])]);

new simpleTooltipWidget({targetnode:tab4,content:Builder.node('div',{style:"width:200px;"},[
      TN("Change your site-design.")
    ])
    })

Event.observe($(tab4),'click',function(e){
this.setPanel(this.makeChangeDesign(),4);
}.bind(this));
Event.observe($(tab4),'mouseover',function(e){
$(tab4).setStyle({background:"white"});
}.bind(this));
Event.observe($(tab4),'mouseout',function(e){
$(tab4).setStyle({background:"transparent"});
}.bind(this));
 
    var thetabs = Builder.node('div',{style:"position:relative;width:500px;position:relative;border-bottom:1px solid black;margin-bottom:0px;"},[
Builder.node('div',{style:"margin-left:20px;position:relative;margin-bottom:-1px;width:450px;"},[
tab2,
tab3,
tab4,
Builder.node('div',{style:"clear:both;"},[])
])
]);

    return thetabs;
  },
  languageChanged:function(o,l){
    this.notifyObservers("languageChanged",l)
  },
  makeChangeProfile:function(){
    var head = Builder.node('div',{},[TN("Profile")]);
    var p = {};
    var lw = new simpleFlagsWidget();
    lw.addObserver(this);
    var langw = Builder.node('div',{style:"width:100px;height:20px;"},[lw.htmlNode()]);

//new simpleBadgeWidget({iconsize:64}).htmlNode()

/* 
var u = Builder.node('a',{href:"#",style:"color:black;font-size:12px;"},[TN("Upload")]) ;
Event.observe(u,'click',function(e){
uploadItem();
}.bind(this));

var badge = Builder.node('div',{style:""},[
u,NBSP(),TN("a picture you would like to use for your profile, then click \"Set Profile Picture\"")
]);
*/

instance = this;

badge = Builder.node('div',{style:"height:150px;"},[new simpleSWFUploadWidget({
  status:false,
  afterUpload:function(){
    
    var url = "http://";
    url += write_user_model_data.username;
    url += ".mysites.com/-";
    url += uploadpath;
    //document.location = url ;

    //we set profile pic directly;
    //check permission and type
    if(uploaditem != null && uploaditem.permission == "everyone"){
      saveToProfile(uploaditem.full_item_url);
      //instance.notification.showNotification(TN("Profile photo updated!"));
    }else{
        //problem
        //instance.notification.setMode("error");
        //instance.notification.showNotification(TN("Error!"));
    }
  },
  permission:"everyone",
  width:400
}).htmlNode()]);

Event.observe($(badge),'click',function(e){
Event.stop(e);
}.bind(this));

    p.params = [
        {label:"Full name:",kk:"fullname",vv:(writeUserModel.data.fullname ? writeUserModel.data.fullname : "")},
        {type:"node",node:badge,label:"Picture:",kk:"userimage",vv:""},
       
// {type:"node",node:langw,label:"Language:",kk:"language",vv:""},
        
        {label:"Short description about yourself:",kk:"status_message",vv:(writeUserModel.data.status_message ? writeUserModel.data.status_message : "")},
        {label:"Web:",kk:"website",vv:(writeUserModel.data.website ? writeUserModel.data.website : "")},
        {label:"Country:",kk:"country",vv:(writeUserModel.data.country ? writeUserModel.data.country : "")},
        {label:"City:",kk:"city",vv:(writeUserModel.data.city ? writeUserModel.data.city : "")}
    ];

    this.formwidget = new simpleFormWidget(p);
    return Builder.node('div',{},[head,BR(),this.formwidget.htmlNode()]);
  },  
  makeChangePassword:function(){
    var head = Builder.node('div',{},[TN("Change password")]);
    var p = {};
   
    p.params = [
        {type:"password",label:"Old password:",kk:"old_password",vv:""},
        {type:"password",label:"New password:",kk:"new_password",vv:""},
        {type:"password",label:"Repeat new password:",kk:"new_confirmation",vv:""}
    ];

    this.formwidget = new simpleFormWidget(p);
    return Builder.node('div',{},[head,BR(),this.formwidget.htmlNode()]);
  },  
  makeChangeDesign:function(){
    var head = Builder.node('div',{},[TN("Design")]);
    var p = {};
    p.params = [
        {label:"Background-Image: (URL)",kk:"backgroundimage",vv:(writeUserModel.data.backgroundimage ? writeUserModel.data.backgroundimage : "")}
        //{type:"node",node:TN("XX"),label:"Preview:",kk:"language",vv:""},
        //{label:"Box-Color",kk:"boxcolor",vv:"#EDEDED"}
    ];

    this.formwidget = new simpleFormWidget(p);
    return Builder.node('div',{},[head,BR(),this.formwidget.htmlNode()]);
  },
  setPanel:function(p,nid){
    try{
      window.setTimeout(function(){
        $("ptab2").setStyle({borderBottom:"1px solid transparent"});
        $("ptab3").setStyle({borderBottom:"1px solid transparent"});
        $("ptab4").setStyle({borderBottom:"1px solid transparent"});
        $("ptab"+nid).setStyle({borderBottom:"1px solid #EDEDED"});  
        this.panel = nid;      
      }.bind(this),40);
    }catch(e){}

    $(this.profilebox).innerHTML = "";
    $(this.profilebox).appendChild(p);
  },
  saveProfile:function(p){
if(p != {}){
    writeUserModel.editAccountSettings(p);
    writeUserModel.observeOnce({update:function(d){
      this.notification.showNotification(TN("Your changes have been saved."));
      writeUserModel.notifyObservers("profileChanged",p);
    }.bind(this)});
}
  },
  savePassword:function(){
    new AjaxFormBuilder({
          user: readUserModel.data.username,
          action: "change_password",
          onSuccessfulSubmit: function(afb, success) {
            this.notification.showNotification(TN("Your password has been changed."));           
          }.bind(this),
          onErroneousSubmit: function(afb, error) {

            switch(error.error_type) {
              case "Master::PasswordEmpty": case "Master::PasswordTooShort":
this.notification.setMode("error");
this.notification.showNotification(TN("The passwords are too short"));
                break;
              case "PasswordsDontMatch":
this.notification.setMode("error");
this.notification.showNotification(TN("The passwords do not match"));
                break;
              case "Master::InvalidUserOrPassword":
this.notification.setMode("error");
this.notification.showNotification(TN("Invalid user or password specified"));
                break;
            }          
          }.bind(this) 
        }).performAjaxRequest({
          'old': $F("old_password"),
          'new': $F("new_password"),
          'new_confirmation': $F("new_confirmation")
        })
  },
  validateForm:function(){

  },
  clickSave:function(){
    if(this.formwidget != null){
      var s = Form.serialize(this.formwidget.form);
      var elms = this.formwidget.form.getInputs();
      var p = {};
      $(elms).each(function(elem){
        var k = $(elem).name;
        var v = $F(elem);
        if(v != "" && v != writeUserModel.data[k]){
          p[k] = v;
        }
      }.bind(this));
      //alert(Object.toJSON(p));

      if(p.old_password && p.old_password != ""){
        this.savePassword();
      }else if(this.panel == 2){
        this.saveProfile(p);
      }      
    }
  },
  makeWidgetContent: function(){ 


    this.notification = new simpleNotificationWidget({s:"",width:250,height:50,icon:true});
    
//window.setTimeout(function(){
//    new simpleFBApiWidget();
//},3000);

    var savebtn = Builder.node('div',{style:"width:100px;margin-right:20px;float:left;"},[Builder.node('input',{type:"button",className:"bigbutton",value:"save",style:"height:50px;width:100px;"},[])])

    var cancelbtn = Builder.node('div',{style:"width:100px;margin-right:20px;float:left;"},[Builder.node('input',{type:"button",className:"bigbutton",value:"cancel",style:"height:50px;width:100px;"},[])])

    var notifierarea = Builder.node('div',{id:"notifierarea",style:"margin-top:-5px;width:200px;margin-right:20px;float:left;"},[
this.notification.htmlNode()
])


    var cl = Builder.node('div',{style:"clear:both;"})

    Event.observe($(savebtn),'click',function(e){
      this.clickSave();
    }.bind(this));


Event.observe($(cancelbtn),'click',function(e){
//this.redrawCompletely();
$(this.content).up().remove();
}.bind(this));

    this.controls = Builder.node('div',{},[cancelbtn,savebtn,notifierarea,cl]);

    this.profilebox = Builder.node('div',{id:"profilebox",style:"height:650px;overflow:hidden;"},[]);
   
    this.wrapper = Builder.node('div',{style:"height:750px;"},[
      Builder.node('div',{},[this.makeSwitchTabs()]),      
      Builder.node('div',{style:"clear:both;"},[]),BR(),
      this.profilebox,
      this.controls
    ]);

    window.setTimeout(function(){
      this.setPanel(this.makeChangeProfile(),2);
    }.bind(this),200);

    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleProfileWidget.prototype, WidgetCommon);
Object.extend(simpleProfileWidget.prototype, Observable);


;

// /8::/202::/core:js -> <214020> simpleregisterinfowidget.js 

//var englishtxt1 = '';
//englishtxt1 += 'MySites lets you upload and share content with the people you want.<br/>';

var senglishtxt2 = '';
senglishtxt2 += '- Your own site (yourname.mysites.com)<br/>';
senglishtxt2 += '- Multiple file upload<br/>';
senglishtxt2 += '- Upload from your mobile<br/>';
senglishtxt2 += '- Privacy control: public / private files<br/>';
senglishtxt2 += '- RSS feed<br/>';


simpleRegisterInfoWidget = Class.create();
simpleRegisterInfoWidget.prototype = {
    defaultOptions: function() {
        return {
            texts:[
                senglishtxt2
            ],
            peoplethink:[
                {quote:"One of the best Web desktops available today",quoter:"Mashable",link:"http:\/\/mashable.com/2008/09/25/mysites/"},
                {quote:"MySites has it all and getting more!",quoter:"StartupMeme",link:"http:\/\/startupmeme.com/watch-out-mobile-me-and-mesh-mysites-has-it-all-getting-more/"},
                {quote:"There is certainly potential here",quoter:"Drama 2.0",link:"http:\/\/www.drama20show.com/2008/07/14/sponsor-mysites-launches-drama-20-reviews/"},
                {quote:"This is an ideal solution for artists",quoter:"KillerStartups",link:"http:\/\/www.drama20show.com/2008/07/14/sponsor-mysites-launches-drama-20-reviews/"},
                {quote:"I like it!",quoter:"Andrea Vascellari",link:"http:\/\/www.andreavascellari.com/?tag=mysitescom"},
                {quote:"The system looks promising",quoter:"WebBriefcase",link:"http:\/\/www.webbriefcase.com.au/2008-07/create-free-websites-with-mysites/"}            
            ]
         }
    },
    setup: function() {
    },
    makeRegTeaser:function(){
      var regt = Builder.node('div',{style:"z-index:10;position:absolute;top:280px;left:-20px;background:url(http://core.myfil.es/get_file/social/regtease.png);width:391px;height:286px;"},[]);
      $(regt).hide();
      new Effect.Appear($(regt),{duration:2,delay:5,afterFinish:function(){
        new Effect.Fade($(regt),{delay:1});
      }});
      return regt;
    },
    peopleThinkBox:function(o){
        var peopleboxArr = [] ;
        var usethisarr,fs; 
        usethisarr = this.options.peoplethink.slice(0,2)
        fs = "100%"; 
        if(o.extended){
            usethisarr = this.options.peoplethink
            fs = "100%";
        }
        usethisarr.each(function(peep){
            var quoterdiv = Builder.node('a',{href:peep.link,target:"_blank",style:"color:#5EB1E8;font-style:italic;"},[TN(" - "+peep.quoter)]);
            var pb = Builder.node('div',{style:"border-bottom:1px solid silver;"},[
                Builder.node('div',{style:"width:97%;font-size:"+fs+";margin:5px;"},[
                    Builder.node('div',{style:"width:100%;float:left;font-size:100%;"},[TN(peep.quote)]),                    
                    quoterdiv
                ])
            ]) 
            peopleboxArr.push(pb)
        });
        var morepeople = Builder.node("div",{style:"cursor:pointer;width:100%;text-align:right;color:#5EB1E8;"},[translateText({path: ".frontpage", id: "more-reviews"})]);
        //Event.observe(morepeople,"click",function(){
        //    this.overlayWindow(this.peopleThinkBox({extended:true}),translateText({path: ".frontpage", id: "people-think"}))
        //}.bind(this)); 
        
        if(o.extended != true){
            //peopleboxArr.push(morepeople)
        }else{
            peopleboxArr.push(BR());
            peopleboxArr.push(BR());
        }
        return Builder.node('div',{style:"float:left;text-align:left;margin:10px;;width:250px;"},peopleboxArr);
    }, 
    makeSingleInfoText:function(tt){  
        var nodee = Builder.node('div',{style:"margin:10px;float:left;width:250px;"},[]);
        $(nodee).innerHTML = tt;
        return nodee;
    },
    makeInfoTexts:function(){
        var it = Builder.node('div',{style:""},[]);
        $(this.options.texts).each(function(tx){
            var txt = this.makeSingleInfoText(tx);
            $(it).appendChild(txt);
        }.bind(this));
        $(it).appendChild(this.peopleThinkBox({extended:false}));
        $(it).appendChild(Builder.node('div',{style:"clear:both;"}));
        return it;
    },
    makeWidgetContent: function() { 
        this.wrapper = Builder.node('div',{style:"position:relative;width:280px;text-align:left;margin:0 auto;"},[this.makeRegTeaser(),this.makeInfoTexts()]); 
        return this.wrapper;
    }
}
Object.extend(simpleRegisterInfoWidget.prototype, WidgetCommon);

 
;

// /8::/202::/core:js -> <207968> simpleregisterwidget.js 

var from_site;

simpleRegisterWidget = Class.create();
simpleRegisterWidget.prototype = {
  defaultOptions: function() {
    return {
      username: "",
      tipped:true,
      id: "registration"
    }
  },
setup:function(){
from_site = "";
},

    makeTip:function(){

        var bg = serviceLink({
            user: "core",
            service: "files@core",
            action:"get_file?path=/white-20.png"
        }); 

        this.tip = Builder.node('div',{
style:"font-size:100%;text-align:left;position:absolute;padding:5px;z-index:999;overflow:auto;left:0px;width:auto;background:url("+bg+");border:2px solid silver;height:auto;"},[
          Builder.node('div',{style:"height:100%;width:98%;background:white;"},[
            Builder.node('div',{style:"height:100%;width:98%;background:white;"},[
              Builder.node('div',{style:"height:100%;width:98%;background:white;"},[
                TN("TIP")
              ])
            ])
          ])
        ]);
        $(this.tip).hide();

        $(document.body).appendChild(this.tip); 
    },
    showTip:function(n){  
        //var arrow = Builder.node('div',{style:"margin-bottom:-24px;width:24px;height:24px;background:url(/images/icons/mycons/24x24/previous.png);position:relative;top:0px;left:-30px;"},[]);
        this.tip.show(); 
        this.tip.down(2).innerHTML = '';
        //this.tip.appendChild(arrow);
        this.tip.down(2).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-20+"px"});
    }, 

  makeWidgetContent: function() {
    //added by mike
    this.makeTip();
    window.setTimeout(function(){
        this.notifyObservers("registerLoaded");
    }.bind(this));
    return (logged_in ? this.logoutNotice() : this.registrationPage())
  },
  replaceContent: function(newContent) {
    this.content.parentNode.replaceChild(newContent, this.content)
    this.content = newContent
  },
  logoutNotice: function() {
    return Builder.node('div', [
      translateText({path: ".registration", id: "logout-first"})
    ])
  },
  translateInput: function(id, name) {
    if (!name) name = id
    return translate({
      path: ".registration",
      id: id,
      node: Builder.node('input', {
        name: name,
        type: "text",
        style: "width:100%;",
        id: this.options.id + "_" + name
      }),
      setText: (function() {
        var previousDefault;
        return function(n, t) {
          var val = n.value
          if ($A(["", previousDefault]).include(val)) {
            n.value = t
          }
          previousDefault = t
        }
      })()
    })    
  },
  registrationPage: function(token) {
    var regBtn = translateButton({
      path: ".registration",
      id: "register",
      node: Builder.node('input', {className:"bigbutton",
style:"font-family:Trebuchet MS;width:270px;height:50px;font-weight:bolder;font-size:24px;",
        type: 'submit',
        value: '',
        id: this.options.id + "_button"
      })
    })
    var form = Builder.node('form', {
      id: "registration-form",
      style: "font-size:14px;text-align:right;"
    }, [

Builder.node('div',{id:"reg_fbconnect"},[
Builder.node('div',{style:"width:200px;margin:0 auto;margin-top:10px;"},[new simpleFBLoginWidget().htmlNode()]),
Builder.node('div',{style:"width:200px;margin:0 auto;text-align:center;"},[Builder.node('span',{style:"font-weight:bolder;font-size:110%;"},[TN("or")]),BR(),BR(),TN("register your MySites-account:")])
]),
BR(),

      table({cellpadding: "5",style:"font-size:10px;"}, [
        Builder.node('span', {style:"white-space:nowrap;"}, [
          Builder.node('input', {
            name: "username",
            type: "text",
            size: 10,
            value: this.options.username,
            id: this.options.id + "_username"
          }),
          TN(".mysites.com")
        ])
      ],[
        this.translateInput("full-name", "full_name")
      ],[
        this.translateInput("password")
      ], [
        this.translateInput("password_confirmation")
      ], [
        this.translateInput("email")
      ],[[
        Builder.node('input', {
            type: "checkbox",
            name: "terms",
            id: this.options.id + "_terms"
          }),
          translate({
            path: ".registration",
            id: "terms",
            args: [serviceLink({service: "articles", user: "core", action: "get_file/terms"})],
            node: Builder.node('span'),
            setText: function(n, t) {
              n.innerHTML = t
            }
          })
      ],[EMPTY()]],[
        regBtn
      ])
    ])
    // The submit events gets trapped somewhere else
    Event.observe(regBtn, 'click', function(event) {
      this.register(event, form, token)
    }.bindAsEventListener(this))
    Element.observe(form, 'submit', this.register.bindAsEventListener(this,token))
    this.clearErrorMarks(form)
    var showHelp = function(inputField) {
      this.setHelp(
        translateText({path: ".registration .help", id: inputField.name}),
        inputField
      )
      inputField.select()
    }.bind(this)
    var fields = $A(["username", "full_name", "password", "password_confirmation",
      "email"])
    fields.each(function(field) {
      Event.observe(form[field], 'focus', function(event) {
        showHelp(form[field])
      }.bindAsEventListener(this))
      Event.observe(form[field], 'keyup', function(event) {
        this.validateField(form[field], event)
      }.bindAsEventListener(this))
    }.bind(this))
    $(["password", "password_confirmation"]).each(function(field) {
      Event.observe(form[field], 'focus', function(event) {
        // This gets called only once as the tpye=text field gets replaced
        // by the type=password field.
        var el = form[field]
        var pn = el.parentNode
        var style = el.getAttribute('style')
        if (Prototype.Browser.IE) {
          style = style.cssText
        }
        var pwdField = Builder.node('input', {
          type: "password",
          style: style,
          name: el.name,
          value: el.value,
          id: el.id
        })
        Element.remove(el)
        pn.appendChild(pwdField)
        pwdField.select()
        Event.observe(pwdField, 'focus', function(event) {
          showHelp(pwdField)
        })
        Event.observe(pwdField, 'keyup', function(event) {
          this.validateField(pwdField, event)
        }.bindAsEventListener(this))
      }.bindAsEventListener(this))
    }.bind(this))
    var t = table({width: "100%"},[form],[this.getHelpElement()])
    //Element.down(t, 'td').nextSibling.style.verticalAlign = "top"
    return t
  },
  validateField: function(field, event) {
    var fn = field.name.split("_").map(function(t) { return t.capitalize()}).join("")
    return this["validate"+fn](field, event)
  },
  validateUsername: function(field, event) {
    if (field.value.length < 4) {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "UsernameTooShort"}),
        field
      )
    }
    else if (!field.value.match(/^[a-z0-9][a-z0-9-]+$/)) {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "InvalidUsername"}),
        field
      )      
    }
    else {
      var sidm = new SingleItemDisplayModel({
        item_path: "/",
        pretty_name: "",
        user: field.value,
        onErroneousSubmit: function(inst, error) {
          if (error.error_type == "UnknownUser") {
            field.style.border = "1px solid black"
            this.setHelp(
              translateText({path: ".registration .help", id: "username"}),
              field
            )        
          }
          else {
            console.log(error)
          }
        }.bind(this)
      })
      sidm.addObserver({afterPathChanged: function() {
        field.style.border = "2px solid red"
        this.setError(
          translateText({path: ".registration .errors", id: "UsernameAlreadyTaken"}),
          field
        )
      }.bind(this)})
    }
  },
  validateFullName: function(field, event) {
    if (field.value.length < 4) {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "FullNameTooShort"}),
        field
      )
    }
    else if (!field.value.match(/^\S+\s+\S+/)) {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "FullNameIncomplete"}),
        field
      )      
    }
    else {
      field.style.border = "1px solid black"
      this.setHelp(
        translateText({path: ".registration .help", id: "full_name"}),
        field
      )
    }
  },
  validatePassword: function(field, event) {
    if (field.value.length < 6) {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "PasswordTooShort"}),
        field
      )
    }
    else {
      field.style.border = "1px solid black"
      this.setHelp(
        translateText({path: ".registration .help", id: "password"}),
        field
      )
    }
  },
  validatePasswordConfirmation: function(field, event) {
    if (field.value != $(field).up('form').password.value) {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "PasswordsDontMatch"}),
        field
      )
    }
    else {
      field.style.border = "1px solid black"
      this.setHelp(
        translateText({path: ".registration .help", id: "password_confirmation"}),
        field
      )      
    }
  },
  validateEmail: function(field, event) {
    if (field.value.length >= 5 && field.value.match(/.+@.+\..+/)) {
      field.style.border = "1px solid black"
      this.setHelp(
        translateText({path: ".registration .help", id: "email"}),
        field
      )
    }
    else {
      field.style.border = "2px solid red"
      this.setError(
        translateText({path: ".registration .errors", id: "InvalidEmailAddress"}),
        field
      )
    }
  },
  getHelpElement: function() {
    this.help = Builder.node('span', [
      translateText({path: ".registration .help", id: "start"})
    ])
    this.helpDiv = Builder.node('div', {
      style: "display:block;position:relative;font-size:12px;top:0px;font-style:italic;"
    }, [BR(),
      this.help
    ])
    return this.helpDiv
  },
  setHelp: function(content, element, _o) {

//    if (!is_developer)  { return }


     var options = Object.extend({
      containerTag: 'table',
      imgSize: 24
    }, _o || {})

 
    this.help.innerHTML = ""

    var top = getTop(element) - getTop(Element.up(element, options.containerTag)) -
      Math.round(0.5 *(options.imgSize - element.offsetHeight))


//this.helpDiv.style.top = top + "px"
$(this.help).appendChild(content)


//added by mike

/*
e = Element.up(element, options.containerTag)
Element.makePositioned(e)
alert(e.style.left);

 */

//this.showTip(content);


    //added by mike
    //if(from_site == ""){
        this.tip.setStyle({left:"35%",top:getTop(element)+"px"}); 
    //}

 
 return; 
 
  },
  setError: function(content, element) {
    this.setHelp(Builder.node('span', {style: "color:red;"}, [content]), element)
  },
  clearErrorMarks: function(form) {
    $A(["username", "password", "password_confirmation", "email",
         "full_name"]).each(function(e) {
          form[e].style.border = "1px solid black"
        })
  },
  register: function(event, form, token) {
    Event.stop(event)
    var errorEl = Element.down(form, '.error')
    this.clearErrorMarks(form)
    if (!form.terms.checked) {
      this.setError(translateText({
        path: ".registration .errors",
        id: "accept-terms"
      }), form.terms)
      return;
    }
    new AjaxFormBuilder({
      user: itemModel.user(),
      service: itemModel.service(),
      action: "create_account",
      onSuccessfulSubmit: function(afb, success) {
        var loginForm = Builder.node('form', {
          style: 'display:none;',
          method: "post", 
          action: serviceLink({
            user: "www",
            service: "sites",
            controllerName: "account",
            action: "login"
          })
        }, $H({
            desired_url: serviceLink({
              user: "everyone",
              service: "main"/*,
              action: "?reload=true"*/
            }),
            desired_service: "main@core",
            username: form.username.value,
            password: form.password.value
          }).map(function(pair) {
            return Builder.node('input', {
              type: "hidden",
              name: pair.key,
              value: pair.value
            })
          })
        )
        this.content.appendChild(loginForm)
        loginForm.submit()
      }.bind(this),
      onErroneousSubmit: function(afb, error) {
        this.clearErrorMarks(form)
        var fields = [];
        var error_type = error.error_type.gsub(/Master::/, "")
        switch(error_type) {
          case "UsernameTooShort": case "UsernameAlreadyTaken": case "InvalidUsername":
            fields.push("username")
            break;
          case "InvalidEmailAddress": case "EmailAddressAlreadyUsed":
            fields.push("email")
            break;
          case "PasswordsDontMatch": case "PasswordTooShort":
            fields.push("password")
            fields.push("password_confirmation")
            break;
          case "FullNameTooShort":
            fields.push("full_name")
            break;
          default:
            break;
        }
        this.setError(translateText({
          path: ".registration .errors",
          id: error_type,
          revert: error.message
        }), form[fields[0]])
        fields.each(function(f) {
          form[f].style.border = "2px solid red"
        })
      }.bind(this)
    }).performAjaxRequest(Form.serialize(form) + "&from_site=" + from_site)      
    return false
  }
}

Object.extend(simpleRegisterWidget.prototype, WidgetCommon)
Object.extend(simpleRegisterWidget.prototype, Observable)




;

// /8::/202::/core:js -> <203999> simpleretweetwidget.js 

simpleRetweetWidget = Class.create();
simpleRetweetWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({mode:"iframe",link:null,m:null,style:"normal"},arguments[0]);
  },
  makeRetweet:function(){
    //fix for permalink withjout item
    if(this.options.link == null){
      var url = itemModel.currentPathPermalink(this.options.m)+"?static-only=1";
    }else{
      var url = this.options.link;
    }
    var urlE = url;//encodeURIComponent(url);
    var thesrc = 'http://api.tweetmeme.com/button.js?url='+urlE+'&style='+this.options.style;
    var html = '<iframe src="'+thesrc+'" scrolling="no" frameborder="0"></iframe>';

    if(this.options.style == "compact"){
        var w = "70";
        var h = "20";
    }else{
        var w = "60";
        var h = "65";
    }
    switch(this.options.mode){
      case "iframe":     
        thesrc = 'http://api.tweetmeme.com/button.js?url='+urlE+'&style='+this.options.style;
        html = '<iframe src="'+thesrc+'" width="'+w+'" height="'+h+'" scrolling="no" frameborder="0"></iframe>';
        break;
      case "image":
        html = '<a href="http://api.tweetmeme.com/share?url='+urlE+'"><img src="http://api.tweetmeme.com/imagebutton.gif?url='+urlE+'" border="0"/></a>';
        break;
      default:
      break;
    }

    var b = Builder.node('div',{style:""},[]);
    b.innerHTML = html;
    return b;
  },
  makeWidgetContent: function(){  
    this.wrapper = this.makeRetweet();
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleRetweetWidget.prototype, WidgetCommon); 
;

// /8::/202::/core:js -> <207964> simplersswidget.js 

simpleRSSWidget = Class.create();
simpleRSSWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null},arguments[0]);
  },
  setup:function(){
    var headrss = Builder.node('link',{rel:"alternate",href:"http://www.mysites.com/recent_rss",title:"Public Timeline",type:"application/rss+xml"},[]);
    document.getElementsByTagName("head")[0].appendChild(headrss); 
  },
  makeRSSButton:function(){
//http://www.mysites.com/recent_rss?path=/&target_user=mike&any_item=1&n=40&service=main
  },
  makeWidgetContent: function(){  

  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleRSSWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <228544> simplesearchformwidget.js 

var sdm;
simpleSearchFormWidget = Class.create();
simpleSearchFormWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({

    },arguments[0]);
  },
  setup:function(){
    this.spinner = Builder.node('div',{id:"spinner",style:"margin-right:20px;width:20px;float:left;"},[
      Builder.node('img', {src: "/images/spinner.gif"})
    ]);  

    this.searchFor("");
    this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({
      txt:TN("no items found"),
      widget:this.albumcontrols,
      items:[],
      model:sdm
    }); 
  },
  makeButton:function(){
    var ico = Builder.node('div',{style:"position:relative;width:25px;height:25px;margin-right:10px;top:2px;left:5px;background:url(http://core.myfil.es/get_file/social/mysrch.png);float:left;"},[]);

    var searchsubmit =  Builder.node('div',{style:"width:60px;height:35px;font-size:18px;float:left;",id:"srchbtn"},[TN("Search")]);

//,searchsubmit

     var inpbtn =  Builder.node('div',{className:"bigbutton",style:"position:relative;margin-right:10px;height:30px;width:35px;float:left;"},[ico]);

    return inpbtn;
  },
  searchFor:function(q){
    $(this.spinner).show();
    sdm = new SearchDisplayModel({n:1000,q:q,service:"main"});
    var obs = {update:function(){
      $(this.spinner).hide();
      this.itemlist.options.model = sdm;
      this.itemlist.rerender();      
    }.bind(this)};
    sdm.addObserver(obs);
  },
  makeSearchField:function(){
     this.searchinput =  Builder.node('input',{type:"text",style:"margin-top:-1px;color:silver;width:100%;",value:"Search",id:"srchform"},[]);

     Event.observe(this.searchinput,'focus',function(e){
       $(this.searchinput).setStyle({color:"black"});
       if($F("srchform") == "Search"){
         $("srchform").value = "";
         $("srchform").setAttribute("value","");
       }
     }.bind(this)); 
     Event.observe(this.searchinput,'blur',function(e){
       $(this.searchinput).setStyle({color:"silver"});
       if($F("srchform") == ""){
         $("srchform").value = "Search";
         $("srchform").setAttribute("value","Search");
       }
     }.bind(this)); 
 
     this.searchsubmit = this.makeButton();
     Event.observe(this.searchsubmit,'click',function(e){
        Event.stop(e);
        this.searchFor($F("srchform"));
     }.bind(this)); 

     var inp = Builder.node('div',{style:"margin-right:10px;width:160px;float:left;"},[
       this.searchinput
     ]);

     var c = Builder.node('div',{style:"clear:both;"},[]);

     var srch = Builder.node('form',{},[
        inp,this.searchsubmit,this.spinner,c
     ]);
     this.spinner.hide();

     Event.observe($(srch),'submit',function(e){
        Event.stop(e);
        this.searchFor($F("srchform"));
     }.bind(this));

     return Builder.node('div',{style:"float:left;"},[srch]);
  },
  makeWidgetContent: function(){ 
    var sep = Builder.node('div',{style:"width:100%;height:2px;border-bottom:1px dashed silver;"},[
      NBSP()
    ]);
    this.wrapper = Builder.node('div',{},[
      /*BR(),BR(),this.makeSearchField(),BR(),BR(),sep,*/this.itemlist.htmlNode()
    ]);
    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleSearchFormWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <197258> simpleserviceselectionwidget.js 


;

// /8::/202::/core:js -> <195587> simplesharewidget.js 

simpleEmbedWidget = Class.create();
simpleEmbedWidget.prototype = {
  defaultOptions: function(){
    return {
      item: null
    }
  },
  getType:function(m,b){

    var type = "file";
    var mime = "";
    try{
      var mime = mimeTypeCategory(m);
      switch(mime){
        case "Audio":
          type = "tune";
          break;
        case "Video":
          type = "movie";
          break;
        case "Image":
          type = "picture";
          break;
        case "File":
          type = "file";
          break;
        default:
      }
    }catch(e){
      return (m.type != undefined ? m.type : "file");
    }
    if(b){
      type = (mime != undefined ? mime : m.type);
    }
    return type;
  },
  permissionInfoBox:function(){

if(read_user_model_data.username == "guest" && !logged_in){
return EMPTY();
}

    var changebtn = Builder.node('a',{style:"color:black;",href:"javascript:void(0);"},[translateText({path: ".nm-sew", id: "change"})]);
Event.observe($(changebtn),'click',function(e){
editItem();
}.bind(this));

    var txt = "";
    switch(this.options.item.permission){
      case "everyone":
        var ico = Builder.node('img',{width:"24",src:"http://core.myfil.es/get_file/social/001-40.png"});
        var headtxt = 'This file is public.'
        txt = '<br/>Anyone can find the file if they come to your site.<br/><br/>Use the following links to share it:';

        break;
      case "onlyme":
        var ico = Builder.node('img',{width:"24",src:"http://core.myfil.es/get_file/social/001-42.png"});
        var headtxt = 'This file is private.'
        txt = '<br/>Only the people who have the link to this page can see the file.<br/><br/>Use the following link if you would like to share it:';

        break;
      default:
    }
    var headnode = Builder.node('span',{},[translateText({path: ".nm-sew", id: headtxt}),NBSP()]);
    //make editable
    if(itemModel.canWrite()){
      $(headnode).appendChild(changebtn);
    }
    var txtnode = Builder.node('span',{},[]);
    $(txtnode).innerHTML = txt;//translateText({path: ".nm-sew", id: txt}).innerHTML;

var thenode = Builder.node('div',[translateText({path: ".nm-sew", id: "added"}), NBSP(),NBSP(),makeNiceDate(this.options.item.added_at)]);
    var perminfo = Builder.node('div',{style:"font-size:120%;"},[thenode,BR(),ico,NBSP(),NBSP(),NBSP(),headnode,BR(),txtnode]);
    return perminfo;
  },  
  embedInfoBox:function(){

        var e = [];
        var m = this.options.item;
        var type = this.getType(m);

        if(m.type == "folder"){
          type = m.type;
        }

        //we clean up embed
        embedcode = embedcode.gsub("'","\\'");
        embedcode = embedcode.gsub("\"","'");

        switch(type){
            case "movie":
                var flv_url = m.flv_url;
                var embedtext = embedcode;
                e.push({embed:embedtext,text:"Embed code"});
                e.push({embed:m.full_item_url,text:"Original file"});
                e.push({embed:itemModel.currentPathPermalink(m),text:"This page"});
                break;
            case "picture":
                var embedtext = "[URL="+itemModel.currentPathPermalink(m)+"][IMG]"+m.full_item_url+"[/IMG][/URL]";
                e.push({embed:embedtext,text:"Forum code"});
                e.push({embed:m.full_item_url,text:"Original file"});
                e.push({embed:itemModel.currentPathPermalink(m),text:"This page"});
                break;
            case "tune":

                var flv_url = m.flv_url;
                var embedtext = embedcode;
                e.push({embed:embedtext,text:"Embed code"});
                e.push({embed:m.full_item_url,text:"Original file"});
                e.push({embed:itemModel.currentPathPermalink(m),text:"This page"});
                break; 
            case "file": 
                e.push({embed:m.full_item_url,text:"Original file"});
                break; 
            case "folder":

                var folder = itemModel.currentPath();
                var user = read_user_model_data.username;

                var jsembed = "<script src='http://static.mysites.com/get_file/embed/embed.js?v=1.0.0&user="
+user 
+"&folder="
+folder
+"' type='text/javascript' id='mysites-embed'></script>";

                e.push({embed:jsembed,text:"Embed this album"});
                e.push({embed:document.location.href,text:"This album"});
                break; 
            default:
                e.push({embed:"---",text:"no embed code"}); 
        } 
 
        var embeds = [];
        $(e).each(function(itm){
          var s1 = {style:"float:left;width:30%;overflow:hidden;"};
          var s2 = {style:"float:left;width:68%;overflow:hidden;"};
          var s3 = {type:"text",style:"padding:3px;margin:2px;font-size:120%;background:#FFF3D0;color:black;width:100%;width:98%;font-family:Trebuchet MS;",value:itm.embed};

            var embedtext = Builder.node('div',s1,[translateText({path: ".nm-sew", id:itm.text})]); 
            var embednode = Builder.node('div',s2,[Builder.node('input',s3)]);  
            embeds.push(Builder.node('div',[embedtext,embednode,Builder.node('div',
              {style:"clear:both;"}),BR()]));
        }.bind(this));
       
        return Builder.node('div',embeds);
    },
  makeSocial:function(){
    if(this.options.item.type == "folder"){
      var st = Builder.node('span',[translateText({path: ".nm-sew", id:"Share this"}), NBSP(),TN(this.getType(this.options.item,true))]);

    }else{
      var st = translateText({path: ".nm-sew", id:"Share this album"});
    }
    var social = Builder.node('div',{style:"height:80px;"},[
      st,BR(),
Builder.node('div',{style:"float:left;width:255px;margin:0 auto;"},[
new simpleSocialShareWidget({m:this.options.item,url:document.location+"/?static-only=1"}).htmlNode()
]),
Builder.node('div',{style:"clear:both;"})
    ]);
    return social;
  },
  makeMobile:function(){
    var desc = '';
    desc += 'QR codes are barcodes you can scan with your mobile.<br/>';
    desc += 'The barcode contains a web link. For example, everything you upload to MySites has its own QR code!<br/><br/>';
    desc += '<br/>';
    desc += 'How it works:<br/>';
    desc += '<ul>';
    desc += '<li>You just take a photo of the QR code with your phone.</li>';
    desc += '<li>It uploads the link to your phone! No need to type anything.</li>';
    desc += '</ul>';
    desc += '<br/><br/>';
    desc += 'QR codes work on almost every phone!<br/><br/>';
    desc += '<b>For iPhone click <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=297104013&mt=8">here</a></b> (iTunes link)<br/>';
    desc += '<b>For Android click <a href="http://www.androidtapp.com/barcode-scanner/">here</a></b><br/>';
    desc += '<b>For Nokia, Sony Ericsson or Motorola click <a href="http://reader.kaywa.com/">here</a></b><br/><br/><br/>';
    
    var whatisthis = Builder.node('a',{href:"javascript:void(0);",style:"font-weight:normal;font-size:12px;color:black;cursor:pointer;"},[translateText({path: ".nm-sew", id:"What is this?"})]);
    Event.observe($(whatisthis),'click',function(e){
$(this.qrcontainer).setStyle({height:"450px"});
      this.qrcontainer.innerHTML = desc;
      var redraw = Builder.node('div',{style:"cursor:pointer;font-weight:bolder;"},[translateText({path: ".nm-sew", id:"Ok"})]);
      Event.observe($(redraw),'click',function(){
        this.redrawCompletely();
      }.bind(this));
      this.qrcontainer.appendChild(redraw);
    }.bind(this));

    this.qrdescnode = Builder.node('div',{style:"width:100px;overflow:hidden;height:auto;float:left;font-weight:bolder;font-size:12px;"},[BR(),BR(),translateText({path: ".nm-sew", id:"mobile QR-Code"}),BR(),BR(),whatisthis]);

    this.qrimg = Builder.node('div',{style:"float:left;width:155px;"},[Builder.node('img',{src:'http:\/\/chart.apis.google.com/chart?chs=150x150&cht=qr&chl='+document.location.href+'&chld=L|0'})]);

this.qrnode = Builder.node('div',{style:""},[]);

    //this.showQR();
this.qrcontainer = Builder.node('div',{style:"height:170px;width:100%;"},[this.qrdescnode,this.qrimg,Builder.node('div',{style:"clear:both;"})]);
if(this.options.item.type == "folder"){
this.qrcontainer = EMPTY();
}
    return this.qrcontainer;
  },
  hideQR:function(){
    this.qrvisible = false;
    //this.toggleqr.innerHTML = "show";
    $(this.qrimg).hide();
  },
  showQR:function(){
    this.qrvisible = true;
    //this.toggleqr.innerHTML = "hide";
    $(this.qrimg).show();
  },
  makeWidgetContent: function(){
    window.setTimeout(function(e){
      $$("input").each(function(elm){
        Event.observe($(elm),'click',function(){
         $(elm).select();
          $(elm).focus();
        })
      }.bind(this))
    },1000);
    return Builder.node('div',{style:"overflow:hidden;width:280px;"},[this.permissionInfoBox(),BR(),this.embedInfoBox(),BR(),this.makeSocial(),BR(),Builder.node('div',{style:"clear:both;"}),this.makeMobile()]);
  }
}  
Object.extend(simpleEmbedWidget.prototype, WidgetCommon);

;

// /8::/202::/core:js -> <202971> simplesocialsharewidget.js 

simpleSocialShareWidget = Class.create();
simpleSocialShareWidget.prototype = {
    defaultOptions: function() {
        return Object.extend({
            m:null,
            model:null,
            url:"",
            iconsize:60,            wanted_sites:[{name:"reddit"},{name:"digg"},{name:"delicious"},{name:"google"}],
            known_sites:[]
        },arguments[0]||{});
  }, 
  setup:function(){
    shareModel.observeOnce(this);
if(shareModel != null){
this.options.model = shareModel
}
  },
  loaded:function(){
    this.options.model = shareModel;
    this.rerender();
  },
  makeWidgetContent:function(){
        if(this.options.m == null || this.options.model == null ){
            return EMPTY();
        }
        var d1 = Builder.node('div',{className:"socialshare",style:"height:auto;width:100%;"},[]);       
        this.wantedsites = [];
       this.options.known_sites = this.options.model.displayItems();


        //$(this.options.wanted_sites).each(function(wanted){
        //    $(this.options.known_sites).each(function(site){
        //        if(site.name.toLowerCase() == wanted.name.toLowerCase()){
        //            this.wantedsites.push(site);
        //        }
        //    }.bind(this))
        //}.bind(this));
  
        $(this.options.known_sites).each(function(site){ 

if(site.name.toLowerCase() != this.options.wanted_sites[0].name &&
site.name.toLowerCase() != this.options.wanted_sites[1].name &&
site.name.toLowerCase() != this.options.wanted_sites[2].name &&
site.name.toLowerCase() != this.options.wanted_sites[3].name){
   return;
}


            if(this.options.url != ""){
              var u = this.options.url;
              var t = this.options.url;
            }else{
              var u = this.options.m.full_item_url;
              var t = escape(this.options.m.name);
            }

            var url = site.social_url.replace("PERMALINK",u).replace("TITLE",t);
            var favicon = site.full_item_url; 
            var sitea = Builder.node('a',{id:"",target:"_blank",className:"socialshare-hover",href:url},[
              Builder.node('img',                {width:this.options.iconsize,height:this.options.iconsize,src:favicon,title:"",alt:"",border:0})
            ]);
        
if(this.options.iconsize >= 32){
            Event.observe($(sitea),'mouseover',function(){
                this.selectedService = site.name;
                $(this.options.m.id+"ssinfobx").innerHTML = ""; 
                $(this.options.m.id+"ssinfobx").appendChild(TN(this.selectedService));
            }.bind(this));

            Event.observe($(sitea),'mouseout',function(){
                this.selectedService = site.name;
                $(this.options.m.id+"ssinfobx").innerHTML = "";
            }.bind(this));
}

            d1.appendChild(sitea);
        }.bind(this));

/*
        this.more = Builder.node('a',{style:"cursor:pointer;width:15px;color:black;text-decoration:none;",href:"javascript:void(0);"},[TN("...")]);
        Event.observe($(this.more),'click',function(e){ 
            //alert("more");  
            this.rerender();
        }.bind(this));
        d1.appendChild(this.more);
*/
        d1.appendChild(Builder.node('div',{id:this.options.m.id+"ssinfobx"},[TN(" ")]));

        return d1;
    },
    rerender: function(){
        var nc = this.makeWidgetContent()
        this.replaceChild(this.content, this.widgetContent, nc)
        this.widgetContent = nc;
    }
}
Object.extend(simpleSocialShareWidget.prototype, WidgetCommon); 


;

// /8::/202::/core:js -> <218547> simpleswfuploadwidget.js 

function fileQueued(file) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus("Waiting...");
		progress.toggleCancel(true, swfu);

		this.customSettings.tdFilesQueued.innerHTML = this.getStats().files_queued;	

	} catch (ex) {
		this.debug(ex);
	}
}

function fileQueueError(file, errorCode, message) {
	try {
		if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
			alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
			return;
		}

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
			progress.setStatus("File is too big.");
			this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
			progress.setStatus("Cannot upload Zero Byte files.");
			this.debug("Error Code: Zero byte file, File name: " + file.name + ", File                 size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
			progress.setStatus("Invalid File Type.");
			this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		default:
			if (file !== null) {
				progress.setStatus("Unhandled Error");
			}
}
  }catch(ex){
        this.debug(ex);
    }
}

function fileDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		if (numFilesSelected > 0) {
			$(this.customSettings.cancelButtonId).disabled = false;
		}
		
		/* I want auto start the upload and I can do that here */
		//this.startUpload();

                if (numFilesQueued > 0) {
try{
                 $("albumselection").hide();
}catch(e){}
  $("uploadbtns").setStyle({top:"-1000px"});
  $("permissionselect").show();

                }                

	} catch (ex)  {

        this.debug(ex);

	}
}


function uploadStart(file) {
	try {
	
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus("Uploading...");
		progress.toggleCancel(true, swfu);
                updateDisplay.call(this, file);
	}
	catch (ex) {}
	
	return true;
}

function uploadProgress(file, bytesLoaded, bytesTotal) {
	try {
		var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setProgress(percent);
		progress.setStatus("Uploading...");
                updateDisplay.call(this, file);
	} catch (ex) {
		this.debug(ex);
	}
}

var uploadpath = document.location.href;
var uploadmodel = null;
var uploaditem = null;

function parseServerData(serverData){
  try{
    var bits = serverData.split("var model_data = ");
    var bits2 = bits[1].split("var write_username = ");
    var modeldata = bits2[0];
    uploadmodel = (modeldata).evalJSON();
    uploaditem = uploadmodel.items[0];
    uploadpath =  uploadmodel.path.gsub("/","");
    if(uploadpath.length < 3 && uploadpath.match(/http:/) != null){
      uploadpath = "";
    }

  }catch(e){};
}

function uploadSuccess(file, serverData) {

        parseServerData(serverData);

	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setComplete();
		progress.setStatus("Complete.");
		progress.toggleCancel(false);
                updateDisplay.call(this, file);
	} catch (ex) {
		this.debug(ex);
	}
}

function uploadError(file, errorCode, message) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
			progress.setStatus("Upload Error: " + message);
			this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
			progress.setStatus("Upload Failed.");
			this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.IO_ERROR:
			progress.setStatus("Server (IO) Error");
			this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
			progress.setStatus("Security Error");
			this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
			progress.setStatus("Upload limit exceeded.");
			this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
			progress.setStatus("Failed Validation.  Upload skipped.");
			this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
			// If there aren't any files left (they were all cancelled) disable the cancel button
			if (this.getStats().files_queued === 0) {
				$(this.customSettings.cancelButtonId).disabled = true;
			}
			progress.setStatus("Cancelled");
			progress.setCancelled();
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
			progress.setStatus("Stopped");
			break;
		default:
			progress.setStatus("Unhandled Error: " + errorCode);
			this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}

var lastuploadedfile = null;

function uploadComplete(file) {
	this.customSettings.tdFilesQueued.innerHTML = this.getStats().files_queued;
	//this.customSettings.tdFilesUploaded.innerHTML = this.getStats().successful_uploads;
	//this.customSettings.tdErrors.innerHTML = this.getStats().upload_errors;

	if (this.getStats().files_queued === 0) {
		$(this.customSettings.cancelButtonId).disabled = true;
	}else {
            this.startUpload();
        }
        lastuploadedfile = file;
}

// This event comes from the Queue Plugin
function queueComplete(numFilesUploaded) {
	//var status = $("divStatus");
	//status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded.";

  window.setTimeout(function(){
    ssuw.notification.showNotification(TN("Your Files have been uploaded."));
    window.setTimeout(function(){
      if(ssuw.options.afterUpload != null){
        ssuw.options.afterUpload();
      }else{

  var url = "http://";

if(BrowserDetect.OS == "Mac"){
  url = document.location.href
}else{
  url = "http://";
  url += write_user_model_data.username;
  url += ".mysites.com/-";
  url += uploadpath;
}
           document.location = url ;

      }
    }.bind(this),2000)
  }.bind(this),2000);

  ssuw.options.model.update();
}

function updateDisplay(file) {

if(ssuw.options.status){

	this.customSettings.tdCurrentSpeed.innerHTML = SWFUpload.speed.formatBPS(file.currentSpeed);
	//this.customSettings.tdAverageSpeed.innerHTML = SWFUpload.speed.formatBPS(file.averageSpeed);
	//this.customSettings.tdMovingAverageSpeed.innerHTML = SWFUpload.speed.formatBPS(file.movingAverageSpeed);
	this.customSettings.tdTimeRemaining.innerHTML = SWFUpload.speed.formatTime(file.timeRemaining);
	//this.customSettings.tdTimeElapsed.innerHTML = SWFUpload.speed.formatTime(file.timeElapsed);
	this.customSettings.tdPercentUploaded.innerHTML = SWFUpload.speed.formatPercent(file.percentUploaded);
	//this.customSettings.tdSizeUploaded.innerHTML = SWFUpload.speed.formatBytes(file.sizeUploaded);
	//this.customSettings.tdProgressEventCount.innerHTML = this.customSettings.progressCount;

}

}


function FileProgress(file, targetID) {
	this.fileProgressID = file.id;

	this.opacity = 100;
	this.height = 0;

	this.fileProgressWrapper = $(this.fileProgressID);

	if (!this.fileProgressWrapper) {
		this.fileProgressWrapper = Builder.node("div",{
                                             id:this.fileProgressID,
                                             className:"progressWrapper"
                                           });
	
		this.fileProgressElement = Builder.node("div",{className:"progressContainer"});

		var progressCancel = Builder.node("a",{
                                       style:"",
                                       href:"#",
                                       className:"progressCancel"},[TN(" ")]);		

		var progressText = Builder.node("div",{className:"progressName"},[
                                     TN(file.name)
                                   ]);		

		var progressBar = Builder.node("div",{className:"progressBarInProgress"});		

		var progressStatus = Builder.node("div",{className:"progressBarStatus"});		
		progressStatus.innerHTML = "&nbsp;";

		this.fileProgressElement.appendChild(progressCancel);
		this.fileProgressElement.appendChild(progressText);
		this.fileProgressElement.appendChild(progressStatus);
		this.fileProgressElement.appendChild(progressBar);

		this.fileProgressWrapper.appendChild(this.fileProgressElement);

		$(targetID).appendChild(this.fileProgressWrapper);
	} else {
		this.fileProgressElement = this.fileProgressWrapper.firstChild;
		this.reset();
	}

	this.height = this.fileProgressWrapper.offsetHeight;
	this.setTimer(null);


}

FileProgress.prototype.setTimer = function (timer) {
	this.fileProgressElement["FP_TIMER"] = timer;
};
FileProgress.prototype.getTimer = function (timer) {
	return this.fileProgressElement["FP_TIMER"] || null;
};
FileProgress.prototype.reset = function () {
	this.fileProgressElement.className = "progressContainer";

	this.fileProgressElement.childNodes[2].innerHTML = "&nbsp;";
	this.fileProgressElement.childNodes[2].className = "progressBarStatus";
	
	this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
	this.fileProgressElement.childNodes[3].style.width = "0%";
	
	this.appear();	
};
FileProgress.prototype.setProgress = function (percentage) {
	this.fileProgressElement.className = "progressContainer green";
	this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
	this.fileProgressElement.childNodes[3].style.width = percentage + "%";

	this.appear();	
};
FileProgress.prototype.setComplete = function () {
	this.fileProgressElement.className = "progressContainer blue";
	this.fileProgressElement.childNodes[3].className = "progressBarComplete";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	this.setTimer(setTimeout(function () {
                Effect.SlideUp($(oSelf.fileProgressElement));
                Effect.Fade($(oSelf.fileProgressElement));
	}, 800));
};
FileProgress.prototype.setError = function () {
	this.fileProgressElement.className = "progressContainer red";
	this.fileProgressElement.childNodes[3].className = "progressBarError";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	this.setTimer(setTimeout(function () {
                Effect.SlideUp($(oSelf.fileProgressElement));
		Effect.Fade($(oSelf.fileProgressElement));
	}, 2000));
};
FileProgress.prototype.setCancelled = function () {
	this.fileProgressElement.className = "progressContainer";
	this.fileProgressElement.childNodes[3].className = "progressBarError";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	this.setTimer(setTimeout(function () {
                Effect.SlideUp($(oSelf.fileProgressElement));
		Effect.Fade($(oSelf.fileProgressElement));
	}, 1000));
};
FileProgress.prototype.setStatus = function (status) {
	this.fileProgressElement.childNodes[2].innerHTML = status;
};

// Show/Hide the cancel button
FileProgress.prototype.toggleCancel = function (show, swfUploadInstance) {
	this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
	if (swfUploadInstance) {
		var fileID = this.fileProgressID;
		this.fileProgressElement.childNodes[0].onclick = function () {
			swfUploadInstance.cancelUpload(fileID);
			return false;
		};
	}
};

FileProgress.prototype.appear = function () {
	if (this.getTimer() !== null) {
		clearTimeout(this.getTimer());
		this.setTimer(null);
	}
	
	$(this.fileProgressWrapper).setOpacity(1);
		
	this.fileProgressWrapper.style.height = "";
	
	this.height = this.fileProgressWrapper.offsetHeight;
	this.opacity = 100;
	this.fileProgressWrapper.style.display = "";
	
};

var swfu;
var ssuw = null;

simpleSWFUploadWidget = Class.create();
simpleSWFUploadWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      afterUpload:null,
      width:500,
      permission:"onlyme",
      status:true,
      album_name:"",
      model:itemModel,
      style:"position:relative;padding:5px;margin-bottom:5px;background:white;"
    },arguments[0]);
  },
  setup:function(){
    this.notification = new simpleNotificationWidget({s:"",width:250,height:50,icon:true});
   
this.options.style = this.options.style+"width:"+(this.options.width)+"px";
    ssuw = this;
    //this.permission = this.options.permission;
  },
  updateUrl:function(p){
    var perms = "?permission="+p;
    var album = "&album_name="+this.options.album_name;
    var url = "http://www.mysites.com/upload"+perms+album;



    swfu.setUploadURL(url);
  },
  startUploader:function(){
    this.updateUrl(this.options.permission);

if(this.options.status){
    $("uploadstats").show();
}
    window.setTimeout(function(){
       swfu.startUpload();
    }.bind(this),200);
  },
  expand:function(){
    if(!this.moving && !this.expanded){
      this.moving = true;
      $("selectalbums").show();
      new Effect.Appear($("selectalbums"),{duration:0.00001,afterFinish:function(){
        this.moving = false;
        this.expanded = true;
        $(this.arrow).setOpacity(0.2);
      }.bind(this)});
    }
  },
  collapse:function(){
   if(!this.moving && this.expanded){
       // this.sendToSwf($F("album_name"));
        this.moving = true;
       //$("selectalbums").show();
        new Effect.Fade($("selectalbums"),{duration:0.00001,afterFinish:function(){
          this.moving = false;
          this.expanded = false
          $(this.arrow).setOpacity(1);
        }.bind(this)});
      } 
  }, 
  makeAlbumSelection:function(){
    this.albumnavi = new simpleAlbumNavigationWidget({
      uploadmode:true,displayItemClicked:function(f){
        $("album_name").setAttribute("value","");
        $("album_name").value = "";
        $("album_name").value = f.name;
        $("album_name").setAttribute("value",f.name);
        this.options.album_name = f.pretty_name;
        this.collapse();
      }.bind(this),
      model:sdloader.loader
    });

    return this.albumnavi.htmlNode();
  },
  makeAlbumSelector:function(){

  //no albums for guest
  if(!logged_in){
    return EMPTY();
  }
  
  var inp = Builder.node('input',{id:"album_name",style:"color:silver;width:100%;",type:"text",name:"album_name",value:this.options.album_name != "" ? this.options.album_name : "Enter an album name"},[]);

  var albuminputnode = Builder.node('div',
    {style:"float:left;width:"+(this.options.width-150)+"px;margin-right:20px;"},[
      inp
  ]);

  var albumtxt = Builder.node('div',{style:"text-align:right;height:30px;float:left;width:95px;margin-right:5px;"},[
Builder.node('div',{style:"height:20px;margin-top:2px;"},[
Builder.node('a',{href:"javascript:void(0);",style:"font-size:17px;font-weight:bolder;"},[TN("My Albums")])
])
]);

  Event.observe($(albumtxt),'click',function(e){
    this.expand();
  }.bind(this));


  this.arrow = Builder.node('div',{style:"cursor:pointer;border:1px solid silver;float:left;width:29px;height:29px;background:white;"},[
Builder.node('div',{style:"margin-top:5px;margin-left:5px;width:18px;height:16px;background:url(http://core.myfil.es/get_file/social/arrowdown.png);"})
  ]);

  Event.observe($(this.arrow),'click',function(e){
    this.expand();
  }.bind(this));

  var cl = Builder.node('div',{style:"clear:both;"},[]);
  var albuminput = Builder.node('div',{style:""},[
    Builder.node('div',{style:"width:150px;"},[             
      Builder.node('label',{"for":"album_name",style:"width:200px;"},[
        TN("Album:"),NBSP(),Builder.node('span',{style:"color:grey;"},[TN("(optional)")
      ])
    ])
  ]),albuminputnode,albumtxt,this.arrow,cl]);

  if(this.options.album_name == ""){
   // $(albuminput).hide();
  }

    Event.observe($(inp),'focus',function(){
      $("album_name").setStyle({color:"black"});
      if($F("album_name") == "Enter an album name"){
        $("album_name").value = "";
        $("album_name").setAttribute("value","");
      }
    }.bind(this));

    Event.observe($(inp),'blur',function(){
      this.collapse();
      if($F("album_name") == ""){
        $("album_name").setStyle({color:"silver"});
        $("album_name").value = "Enter an album name";
        $("album_name").setAttribute("value","Enter an album name");
      }
    }.bind(this));

    //send typed data to flash.. needs fix for IE
    Event.observe($(inp),'keyup',function(){

      this.suggest($F("album_name"));
      //if(this.options.mode == "flash"){
        //this.sendToSwf($F("album_name"));
        this.options.album_name = $F("album_name");
        this.updateUrl(this.options.permission);
      //}

    }.bind(this));

    var albumnodes = Builder.node('div',{id:"albumselection",style:"margin-bottom:10px;"},[albuminput])

window.setTimeout(function(){
    Event.observe($(document.body),'click',function(){
      this.collapse();
    }.bind(this));


try{
//$(albuminput).show();
$("selectalbums").hide();
$("selectalbums").firstChild.innerHTML = "";
$("selectalbums").firstChild.appendChild(this.makeAlbumSelection());
}catch(e){}

}.bind(this),150);

    return albumnodes;
  },
  suggest:function(d){

     var arr = [];
     $(sdloader.loader.items()).each(function(item){
       var r = new RegExp(d, "gi")
       if(item.name.match(r)){
         arr.push(item);
       }
     }.bind(this));
     this.albumnavi.setItems(arr);
     window.setTimeout(function(){
       if(arr.length >0){
          this.expand();
       }
     }.bind(this),500);
  },
  makePermissionDialog:function(){
    
    var everyone = Builder.node('div',{style:"float:left;background:url(http://core.myfil.es/get_file/social/001-40.png);width:24px;height:24px;margin-right:10px;"},[]);
    var everyonetxt = Builder.node('div',{style:"float:left;height:24px;margin-right:10px;"},[TN("Public")]);

    var onlyme = Builder.node('div',{style:"float:left;background:url(http://core.myfil.es/get_file/social/001-42.png);width:24px;height:24px;margin-right:10px;"},[]);
    var onlymetxt = Builder.node('div',{style:"float:left;height:24px;margin-right:10px;"},[TN("Private")]);

    var s = "font-size:14px;font-weight:bolder;border:2px solid transparent;cursor:pointer;float:left;margin-right:10px;padding:10px;";

    this.ppublic = Builder.node('input',{style:"display:none;",type:"radio",name:"permission",value:"everyone"});
    this.pprivate = Builder.node('input',{style:"display:none;",type:"radio",name:"permission",value:"onlyme"});

    var c = Builder.node('div',{style:"clear:both;"},[]);

    var perms = Builder.node('div',{style:"width:320px;margin:0 auto;"},[
Builder.node('div',{style:""},[
      
      Builder.node('div',{id:"perm_public",style:s},[this.ppublic,everyone,everyonetxt]),
      Builder.node('div',{id:"perm_private",style:s},[this.pprivate,onlyme,onlymetxt]),
      c
])
    ]);  

    var pdinner = Builder.node('div',{style:""},[
Builder.node('div',{style:""},[
BR(),BR(),BR(),
        perms
])
      ]);

    this.pd = Builder.node('div',{id:"permissionselect",style:""},[
      pdinner
    ]);

    window.setTimeout(function(){
      Event.observe($("perm_public"),'click',function(e){
this.options.permission = "everyone";
        this.selectPublic();
        $(this.pd).hide();        
        $("fsUploadProgress").show();
        this.startUploader();
      }.bind(this));

      Event.observe($("perm_private"),'click',function(e){
this.options.permission = "onlyme";
        this.selectPrivate();
        $(this.pd).hide();        
        $("fsUploadProgress").show();
        this.startUploader();
      }.bind(this));
  
if(this.options.permission == "onlyme"){
      this.selectPrivate();
}else{
      this.selectPublic();
}

    }.bind(this),300);

    $(this.pd).hide();

    return this.pd;
  },
  selectPublic:function(){

   // this.permission = "everyone";

    $(this.ppublic).checked = "checked";
    $(this.pprivate).checked = "";

    $("perm_private").setStyle({fontStyle:"normal",color:"black",border:"2px solid transparent"});
    $("perm_public").setStyle({border:"2px dotted silver"});       
    $("perm_public").setStyle({color:"black",fontStyle:"italic",fontWeight:"bolder"});
    $("perm_private").setStyle({background:"transparent"});
    $("perm_private").setOpacity(0.3);
    $("perm_public").setOpacity(1);
  },
  selectPrivate:function(){
   // this.permission = "onlyme";

    $(this.ppublic).checked = "";
    $(this.pprivate).checked = "checked";

    $("perm_public").setStyle({fontStyle:"normal",color:"black",border:"2px solid transparent"});
    $("perm_public").setStyle({background:"transparent"});
    $("perm_private").setStyle({border:"2px dotted silver"});
    $("perm_private").setStyle({color:"black",fontStyle:"italic",fontWeight:"bolder"});
    $("perm_public").setOpacity(0.3);
    $("perm_private").setOpacity(1);
  },
  initUploader:function(){
    var furl = "http://www.mysites.com/core-services/swfupload.swf";

    this.settings = {
      upload_url : "http://www.mysites.com/upload"+"?permission=everyone", 
      flash_url : furl,
      file_post_name:"Filedata",
      post_params: {"mysites" : document.cookie.split("; ").inject({}, function(h, v) { vv = v.split("=", 2); h[vv[0]] = vv[1]; return h})["mysites"]},
      file_size_limit : "4096 MB",
      file_types : "*.*",
      file_types_description : "All Files",
      file_upload_limit : 100,
      file_queue_limit : 0,
      moving_average_history_size: 40,
      custom_settings : {
        progressTarget : "fsUploadProgress",
        cancelButtonId : "upcancel",
        tdFilesQueued : document.getElementById("tdFilesQueued"),
        //tdFilesUploaded : document.getElementById("tdFilesUploaded"),
        //tdErrors : document.getElementById("tdErrors"),
        tdCurrentSpeed : document.getElementById("tdCurrentSpeed"),
        //tdAverageSpeed : document.getElementById("tdAverageSpeed"),
        //tdMovingAverageSpeed : document.getElementById("tdMovingAverageSpeed"),
        tdTimeRemaining : document.getElementById("tdTimeRemaining"),
        //tdTimeElapsed : document.getElementById("tdTimeElapsed"),
        tdPercentUploaded : document.getElementById("tdPercentUploaded")
        //tdSizeUploaded : document.getElementById("tdSizeUploaded"),
        //tdProgressEventCount : document.getElementById("tdProgressEventCount")
      },
      debug: false,
      button_image_url: "http://core.myfil.es/get_file/social/ubtnbg.png",
      button_width: "130",
      button_height: "30",
      button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
      button_cursor: SWFUpload.CURSOR.HAND,
      button_placeholder_id : "upselect",
      button_text: '<span class="theFont">Select Files</span>',
      button_text_style: ".theFont { font-size: 16; text-align:center; font-family: \"Trebuchet MS\"}",
      button_text_left_padding: 0,
      button_text_top_padding: 3,
  
      file_queued_handler : fileQueued,
      file_queue_error_handler : fileQueueError,
      file_dialog_complete_handler : fileDialogComplete,
      upload_start_handler : uploadStart,
      upload_progress_handler : uploadProgress,
      upload_error_handler : uploadError,
      upload_success_handler : uploadSuccess,
      upload_complete_handler : uploadComplete,
      queue_complete_handler : queueComplete
    };

    swfu = new SWFUpload(this.settings); 

  },
  updateDynamicSettings: function () {
    var params = this.getParamsObject();
    swfu.setPostParams(params);
  },
  getParamsObject: function () {
    var params = {};
    //for (var i = 0; i < this.selParams.options.length; i++) {
    //  var name =  this.selParams.options[i].text;
    //  var value =  this.selParams.options[i].value;
    //  params[name] = value;
    //}
    return this.settings;
  },
  makeUploader:function(){
/*

//Builder.node('div',{},[TN("Files Uploaded:"),Builder.node('div',{id:"tdFilesUploaded"},[])]),
      //Builder.node('div',{},[TN("Errors:"),Builder.node('div',{id:"tdErrors"},[])]),
      //Builder.node('div',{},[TN("Average Speed:"),Builder.node('div',{id:"tdAverageSpeed"},[])]),
      //Builder.node('div',{},[TN("Moving Average Speed:"),Builder.node('div',{id:"tdMovingAverageSpeed"},[])]),
      //Builder.node('div',{},[TN("Time Elapsed:"),Builder.node('div',{id:"tdTimeElapsed"},[])]),
      //Builder.node('div',{},[TN("Size Uploaded:"),Builder.node('div',{id:"tdSizeUploaded"},[])]),
      //Builder.node('div',{},[Builder.node('div',{id:"tdProgressEventCount"},[])])
*/

    var stat = Builder.node('div',{id:"uploadstats",style:"position:relative;top:-30px;clear:both;width:"+(this.options.width)+"px;height:40px;font-size:12px;"},[

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Files Queued:"),NBSP(),Builder.node('span',{id:"tdFilesQueued"},[])]),

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Current Speed:"),NBSP(),Builder.node('span',{id:"tdCurrentSpeed"},[])]),

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Time Remaining:"),NBSP(),Builder.node('span',{id:"tdTimeRemaining"},[])]),

      Builder.node('div',{style:"width:200px;float:left;margin-right:10px;"},[TN("Percent Uploaded:"),NBSP(),Builder.node('span',{id:"tdPercentUploaded"},[])]),

Builder.node('div',{style:"clear:both;"},[])
    ]);

$(stat).hide();

    var uform = Builder.node('form',{style:"width:"+(this.options.width)+"px;height:100px;",action:"",height:"100",enctype:"multipart/form-data"},[]);

var fsup = Builder.node('div',{id:"fsUploadProgress",style:"height:100px;"});
$(fsup).hide();

    $(uform).appendChild(Builder.node('div',{id:"divStatus",style:"font-style:italic;"},[]));
    $(uform).appendChild(fsup);

    var upl = Builder.node('div',{id:"uploadbtns",style:this.options.style},[  Builder.node('div',{style:"float:left;margin-right:20px;width:130px;background:url(http://core.myfil.es/get_file/social/ubtnbg.png);"},[
Builder.node('span',{style:"",id:"upselect"},[])
]),

Builder.node('div',{id:"upcancel",style:"display:none;float:left;margin-right_20px;background:url(http://core.myfil.es/get_file/social/ubtnbg.png);width:130px;height:30px;"},[
Builder.node('input',{value:"cancel",disabled:"disabled",className:"bigbutton",type:"button",style:"margin:0 auto;margin-top:0px;font-weight:normal;height:20px;width:130px;font-size:15px;height:30px;background:transparent:border:0px solid transparent;"})
]),

Builder.node('div',{style:"clear:both;"})
    ]);

    $(uform).appendChild(this.makePermissionDialog());
    $(uform).appendChild(upl);    
    

var alb = Builder.node('div',{id:"selectalbums",style:"background:#EDEDED;width:"+(this.options.width)+"px;height:200px;border:1px solid silver;position:absolute;z-index:9999;padding:5px;"},[
Builder.node('div',{style:"position:relative;height:200px;overflow:auto;"},[
Builder.node('div',{id:"albums",style:""},[])
])
]);

$(alb).hide();

    this.uploader = Builder.node('div',{style:"position:absolute;z-index:888;height:100px;"},[]);
    $(this.uploader).appendChild(uform);
    $(this.uploader).appendChild(this.makeAlbumSelector());
    $(this.uploader).appendChild(alb);
        $(this.uploader).appendChild(Builder.node('div',{style:"position:relative;top:-80px;z-index:888;width:300px;margin:0 auto;height:50px;"},[
this.notification.htmlNode()
]));

    $(this.uploader).appendChild(Builder.node('div',{style:"clear:both;"}));
    $(this.uploader).appendChild(stat);

    //$(this.uploader).appendChild();

    return this.uploader;   
  },
  makeWidgetContent: function(){    
    this.wrapper = this.makeUploader();

    window.setTimeout(function(){
      this.initUploader();
      if(guestpage != null){
          this.makeCloudBg();
          this.makeCloudTexts();
      }
    }.bind(this),150);

    return this.wrapper;
  }, 
makeCloudBg:function(){
    var c = Builder.node('div',{style:"left:-65px;top:-120px;z-index:-2;background:url(http://core.myfil.es/get_file/social/mycloud.png);position:absolute;width:600px;height:344px;"},[]);
    this.wrapper.appendChild(c);
  },
  makeCloudTexts:function(){
    var t1 = Builder.node('div',{style:"z-index:-2;top:-270px;left:0px;background:url(http://core.myfil.es/get_file/social/t-1.png);position:absolute;width:228px;height:112px;"},[]);
    var t2 = Builder.node('div',{style:"z-index:-2;top:60px;left:-150px;background:url(http://core.myfil.es/get_file/social/t-2.png);position:absolute;width:159px;height:72px;"},[]);
    var t3 = Builder.node('div',{style:"z-index:-2;top:80px;left:20px;background:url(http://core.myfil.es/get_file/social/t-3.png);position:absolute;width:187px;height:235px;"},[]);
    var t4 = Builder.node('div',{style:"z-index:-2;top:80px;left:220px;background:url(http://core.myfil.es/get_file/social/t-4.png);position:absolute;width:221px;height:151px;"},[]);
    var t5 = Builder.node('div',{style:"z-index:-2;top:50px;left:350px;background:url(http://core.myfil.es/get_file/social/t-5.png);position:absolute;width:128px;height:77px;"},[]);

$(t1).hide();
$(t2).hide();
$(t3).hide();
$(t4).hide();
$(t5).hide();

new Effect.Appear($(t1),{delay:0});
new Effect.Appear($(t2),{delay:1*0.6});
new Effect.Appear($(t3),{delay:2*0.6});
new Effect.Appear($(t4),{delay:3*0.6});
new Effect.Appear($(t5),{delay:4*0.6});
 this.wrapper.appendChild(Builder.node('div',{style:"z-index:-1;position:relative;top:-50px;left:80px;"},[t1,t2,t3,t4,t5]));
  },
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleSWFUploadWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <216925> simpletooltipwidget.js 

simpleTooltipWidget = Class.create();
simpleTooltipWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({width:100,color:"dgrey",targetnode:null,content:TN("X")},arguments[0]);
  },
  setup:function(){
    
  },
  setContent:function(c){
//    this.innertip.innerHTML = '';
    $(this.innertip).update(c);
  },
  makeTip:function(){

    var tipg = "";
    var st = "";

    if(this.options.color == "grey"){
      tipg = "http://core.myfil.es/get_file/social/greytip.png";
      st = "border:5px solid silver;";
    }else if(this.options.color == "dgrey"){
      tipg = "http://core.myfil.es/get_file/social/dgreytip.png";
      st = "border:5px solid #888888;";
    }else{

    }

    this.innertip = Builder.node('div',{style:"font-size:10px;font-weight:normal;position:relative;top:0px;z-index:9999;width:"+(this.options.width-10)+"px;height:100%;overflow:hidden;"},[]);

    this.liltip = Builder.node('div',{style:"position:absolute;z-index:9998;top:-12px;background:url("+tipg+");width:9px;height:10px;"},[]);
      
    this.tip = Builder.node('div',{style:st+"-webkit-border-radius: 6px;-moz-border-radius: 6px;font-weight:bolder;position:absolute;z-index:9997;top:0px;left:0px;width:100px;height:40px;text-align:left;padding:5px;background:white;font-size:90%;"},[
this.liltip,Builder.node('div',{style:"position:absolute;height:40px;z-index:8889;width:100px"},[this.innertip])]);
      $(this.tip).hide();
      $(document.body).appendChild(this.tip); 
  },
  showTip:function(){      
    $(this.tip).show(); 
  },
  hideTip:function(){
    $(this.tip).hide(); 
  },
  moveTip:function(e){
    //this.showTip(this.options.content)
    var mouseX = Event.pointerX(e);
    var mouseY = Event.pointerY(e);
    this.tip.setStyle({left:mouseX+8+"px",top:mouseY+30+"px"});
  },
  registerTipListeners:function(node){
    this.setContent(this.options.content);
    Event.observe($(node),'mouseover',function(e){
      this.showTip();
      this.moveTip(e);
    }.bind(this));
    Event.observe($(node),'mouseout',function(e){
      this.hideTip(e);
    }.bind(this));
    Event.observe($(node),'mousemove',function(e){
      this.moveTip(e);
    }.bind(this));
  }, 
  makeWidgetContent: function(){
    this.makeTip();
    this.registerTipListeners(this.options.targetnode);  
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleTooltipWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <209189> simpleuploadbuttonwidget.js 

var UPLOADBUTTON = null;

//var current_uploader = null;
var theuploadernode;

simpleUploadButtonWidget = Class.create();
simpleUploadButtonWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({cloud:false,targetnode:null,album_name:"",mode:"flash",text:"Upload your files to mysites.com:"},arguments[0]);
  },
  setup:function(){
this.visible = false;
UPLOADBUTTON = this;
  },
  makeUploadButtonWidget:function(){
   this.buttonnode = Builder.node('div',{style:"height:80px;"},[
TN(this.options.text),BR(),BR(),
      Builder.node('div',{style:"height:40px;width:100px;margin:0 auto;"},[makeSimpleButton(TN("add content"))])
    ])
/*
    this.cancel = Builder.node('div',{style:"z-index:9999;position:relative;cursor:pointer;height:50px;"},[
      TN("<< back to item-list")
    ])
    Event.observe($(this.cancel),'click',function(e){
      $(this.options.targetnode).show();
      this.visible = false;
      $(this.theuploadernodex).remove();

      this.cancel.remove();
      this.rerender();
    }.bind(this));
*/

//if(!logged_in){
this.cancel = EMPTY();
//}
   // if(itemModel.canWrite()){
      Event.observe($(this.buttonnode),'click',function(e){
if(!this.visible){
         this.showUploader();
}
      }.bind(this));
  //  }else{
  //    Event.observe($(this.buttonnode),'click',function(e){
  //      document.location = "http://"+write_username+".mysites.com/?upload=1";
  //    }.bind(this));
  //  }

    return this.buttonnode;
  },
  uploaderStarted:function(){
    this.visible = true;
    //$(this.buttonnode).setOpacity(0.2);
    Event.stopObserving($(this.buttonnode));
  },
  showUploader:function(){
try{
$(this.options.targetnode).hide();
}catch(e){};

       this.theuploader = new simpleFormUploadWidget({cloud:this.options.cloud,mode:"flash",album_name:this.options.album_name});
       //global uploader var

       uploader = this.theuploader;
this.theuploader.addObserver(this);

       //$(this.options.targetnode).parentNode.appendChild(this.cancel);
//window.setTimeout(function(){
    this.theuploader.rerender();
//}.bind(this),200);

    this.theuploadernodex = this.theuploader.htmlNode();
theuploadernode = this.uploadernodex;
var nn = $(this.options.targetnode).parentNode
if(arguments[0] == true){
nn = $(this.options.targetnode).up();
}
    nn.appendChild(this.theuploadernodex);
  },
  makeWidgetContent: function(){  
    return this.makeUploadButtonWidget();
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleUploadButtonWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <218132> simpleuserinfowidget.js 

simpleUserInfoWidget = Class.create();
simpleUserInfoWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({height:200},arguments[0]);
  },
  setup:function(){
     writeUserModel.addObserver({profileChanged:function(d,data){
      readUserModel.data = Object.extend(readUserModel.data,data);
      this.rerender();    
    }.bind(this)});

  },
  makeWidgetContent: function(){  
    var params = [
        {label:"Full name:",kk:"fullname",vv:(readUserModel.data.fullname ? readUserModel.data.fullname : "")},
        {label:"Short description about yourself:",kk:"status_message",vv:(readUserModel.data.status_message ? readUserModel.data.status_message : "")},
        {label:"Web:",kk:"website",vv:(readUserModel.data.website ? readUserModel.data.website : "")},
        {label:"Country:",kk:"country",vv:(readUserModel.data.country ? readUserModel.data.country : "")},
        {label:"City:",kk:"city",vv:(readUserModel.data.city ? readUserModel.data.city : "")}
    ];

    this.userinfo = Builder.node('div',{style:"margin-top:10px;width:200px;height:180px;overflow:hidden;"},[]);
 
    $(params).each(function(p){
      if(p.vv != ""){
        var lbl = Builder.node('span',{style:"font-weight:bolder;"},[translateText({path: ".nm-sprow", id: p.label})]);
        var href = "javascript:void(0);";
        var lnk = Builder.node('span',{style:"font-size:10px;"},[TN(p.vv)]);
        var b = NBSP();
        if(p.vv.match(/http:/)){
          href = p.vv;
          lnk = Builder.node('a',{href:href,style:"font-size:10px;"},[TN(p.vv)]);
        }
        if(p.label.match(/Short/)){
          b = BR();
        }
        var uinfo = Builder.node('div',{style:"font-size:10px;width:100%;margin-bottom:5px;"},[lbl,b,lnk])

        $(this.userinfo).appendChild(uinfo);
      }
    }.bind(this));

    return this.userinfo;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleUserInfoWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <204105> simpleuserpagewidget.js 

var userpage = null;
simpleUserPageWidget = Class.create();
simpleUserPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({m:null,model:itemModel},arguments[0]);
  },
  setup:function(){
    writeUserModel.addObserver({profileChanged:function(d,data){
      read_user_model_data = Object.extend(read_user_model_data,data);
      this.initDesign();
     // this.rerender();
    }.bind(this)});

    this.initDesign();
    userpage = this;

    this.m = this.options.m;
    this.albumcontrols = new simpleAlbumControlsWidget({});
    this.itemlist = new simpleItemListWidget({onuserpage:true,widget:this.albumcontrols,model:this.options.model});   

this.albumlist =  new simpleAlbumNavigationWidget({});

    //sdloader.addObserver(this.albumlist);
    //sdloader.addObserver(this.itemlist);
  },
  initDesign:function(){
    var ubg = (read_user_model_data.backgroundimage ? read_user_model_data.backgroundimage : "");
    if(ubg.match(/http/)){
      $(document.body).setStyle({background:'#EDEDED url('+ubg+')'});
    }
  },
  languageChanged:function(o,l){
    this.suiw.rerender();
  },
  makeUserBadgeWidget:function(){
    this.suiw = new simpleUserInfoWidget();
    this.userinfo = this.suiw.htmlNode();

    this.profileedit = EMPTY();
    if(itemModel.canWrite()){
      this.profileedit = Builder.node('div',{style:"cursor:pointer;"},[]);
      $(this.profileedit).appendChild(translateText({path: ".nm-supw", id: "Edit my profile"}));
      Event.observe($(this.profileedit),'click',function(e){
        this.makeProfileWidget();
      }.bind(this));
    }
    var thenode = Builder.node('div',{style:"height:250px;"},[
      new simpleBadgeWidget({status:true,iconsize:64,usermodel:read_user_model_data}).htmlNode(),
      this.profileedit,
      this.userinfo
    ])
    return {node:thenode,head:translateText({path: ".nm-supw", id: "User"}),boxed:true};
  },
  makeProfileWidget:function(){
    if(this.profilewidget != null){
try{
      $(this.profilewidget).remove();
}catch(e){}
    }
var spw = new simpleProfileWidget();

spw.addObserver(this);

    this.profilewidget = simpleLayoutWidget.prototype.makeSimplebox(spw.htmlNode(),translateText({path: ".nm-supw", id: "Edit Profile"}));
    Element.insert($("myright"), {top:this.profilewidget}) 
  },
  makeExploreAlbumsWidget:function(){
    //if(logged_in){
      var thenode = Builder.node('div',{style:""},[
       this.albumlist.htmlNode()
      ])
      var o = {boxed:true,node:thenode,head:Builder.node('span',[
TN(read_user_model_data.username.reflexive()),
NBSP(),
translateText({path: ".nm-supw", id: "albums"})
])
};

    //}else{
    //  var o = {node:EMPTY(),head:EMPTY(),boxed:true};
    //}
    return o;
  },
  makeRSSBox:function(){
    var thenode = Builder.node('div',{style:"margin-bottom:10px;"},[
      new simpleLinksWidget({links:[         {ico:Builder.node('img',{src:"http://core.myfil.es/get_file/feed.png"}),name:Builder.node('span',[
TN(read_user_model_data.username.reflexive()),
NBSP(),
translateText({path: ".nm-supw", id: "RSS"})
]), 
link:"http://"+read_user_model_data.username+".mysites.com/recent_rss"}
      ]}).htmlNode()
    ])
    return {node:thenode,head:translateText({path: ".nm-supw", id: "Navigation"}),boxed:false};
  },
//  makeUploadButtonWidget:function(){
//
//    this.uploadw = new simpleUploadButtonWidget({
//      targetnode:this.itemlist.htmlNode(),
//      album_name:"",
//      mode:"html",
//      text:"Upload content to mysites.com:"
//    });
//    this.uploadbtn = this.uploadw.htmlNode();
//    return {node:this.uploadbtn,head:EMPTY()};
//  },
  makeAlbumControlsWidget:function(){     
    var thenode = Builder.node('div',{style:"height:35px;"},[
       this.albumcontrols.htmlNode()
    ])
    return {node:thenode,head:EMPTY(),boxed:false};
  },
  afterInitWidget:function(){
     var params = parameters();
     if(params.upload){
        this.uploadw.showUploader();
     }
  },
  makeWidgetContent: function(){  
    var left = [
      this.makeUserBadgeWidget()      
    ];

    if(!this.isFirsttime()){
      left.push(this.makeExploreAlbumsWidget());
      left.push(this.makeRSSBox());
    }

    var right = [];

    if(!this.isFirsttime()){
      right.push({node:this.itemlist.htmlNode(),head:Builder.node('span',[
TN(read_user_model_data.username.reflexive()),NBSP(),
translateText({path: ".nm-supw", id: "recent public files"})
]),boxed:true});

      right.push(this.makeAlbumControlsWidget());
    }

    if(this.isFirsttime()){
      right.splice(0,0,{node:new simpleWelcomeWidget().htmlNode(),head:TN("Welcome to your site!"),boxed:true});
    }

    window.setTimeout(function(){
      this.afterInitWidget();
    }.bind(this),100);

    return new simpleLayoutWidget({left:left,right:right}).htmlNode();
  }, 
  isFirsttime:function(){
    return (this.options.model.items().length <= 0 && itemModel.canWrite());
  },
  rerender: function(){
    var nc = this.makeWidgetContent();
    this.replaceChild(this.content, this.widgetContent, nc);
    this.widgetContent = nc;  
  }
}  
Object.extend(simpleUserPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <217904> simplewelcomewidget.js 

simpleWelcomeWidget = Class.create();
simpleWelcomeWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({title:document.location.href},arguments[0]);
  },
  setup:function(){
  
  },
  getText:function(){
    var welcometext = '';
    //welcometext += '<b>Welcome to your site!</b><br/>';
    welcometext += '<br/>';
    welcometext += 'This <a href="http://'+write_user_model_data.username+'.mysites.com" style="font-size:16px;font-weight:bolder;">('+write_user_model_data.username+'.mysites.com)</a> is where people will be able to see your latest     public files.<br/>';
    welcometext += '<br/>';
    welcometext += 'You can also upload private files, but they will not appear in here.<br/>';
    welcometext += '<br/>';
    welcometext += '<br/>';
    welcometext += '<b>What to do now:</b><br/>';
    welcometext += '<br/>';
    welcometext += '1. Add your <a href="javascript:userpage.makeProfileWidget();" style="font-size:16px;font-weight:bolder;">photo</a> (you can always do this later, by clicking <a href="javascript:userpage.makeProfileWidget();" style="font-size:16px;font-weight:bolder;">\'edit my profile\'</a>.<br/>';
    welcometext += '<br/>';
    welcometext += '2. <a href="javascript:uploadItem();" style="font-size:16px;font-weight:bolder;">Upload some files</a> (you can do this later, by clicking "Upload" on the top of the page).<br/>';
    welcometext += '<br/>';
    welcometext += '3. <a href="http://www.mysites.com" style="font-size:16px;font-weight:bolder;">View the latest public uploads or transfer files</a> from your mobile phone (you can do this later, by clicking "Home")<br/>';
    welcometext += '<br/>';
    welcometext += '4. Learn more about MySites<br/>';
    return welcometext;
  },
  makeWidgetContent: function(){ 
    this.textnode = Builder.node('div',{},[]);
    this.textnode.innerHTML = this.getText();
    this.wrapper = Builder.node('div',{style:"font-size:16px;margin-bottom:20px;"},[this.textnode]);

//this.wrapperx = simpleLayoutWidget.prototype.makeSimplebox(this.wrapper, TN("Welcome"))

    return this.wrapper;
  }, 
  rerender: function(){
    this.redrawCompletely()
  }
}  
Object.extend(simpleWelcomeWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <216885> simplewhereyouarewidget.js 

simpleWhereYouAreWidget = Class.create();
simpleWhereYouAreWidget.prototype = {
  defaultOptions: function() {
    return {};
  },
  setup: function() {
  
  },
  makeLink:function(d){
    var s = "width:150px;-webkit-border-radius: 6px 6px 0px 0px;-moz-border-radius: 6px 6px 0px 0px;position:relative;cursor:pointer;margin-right:10px;background:#ededed;font-weight:bolder;overflow:hidden;height:30px;float:left;border:1px solid white;border-bottom:1px solid transparent;";

      var nitem = 
        Builder.node('a',{
          href:this.buildLinkUrl(d),style:s+"font-size:16px;color:black;text-decoration:none;"},[
         Builder.node('div',{style:"left:5px;top:3px;position:relative;height:20px;width:auto;"},[ TN(d.text)])        
      ]);

      //Event.observe($(nitem),'click',function(e){
      //  alert("read: "+this.readuser+"\nwrite: "+this.writeuser+"\n"+d.text);
      //}.bind(this));
      Event.observe($(nitem),'mouseover',function(e){
        $(nitem).setStyle({border:"1px solid #AFAFAF",borderBottom:"1px solid transparent"});
      }.bind(this));
      Event.observe($(nitem),'mouseout',function(e){
        $(nitem).setStyle({border:"1px solid white",borderBottom:"1px solid transparent"});
      }.bind(this));
    return nitem;
  },
  buildLinkUrl:function(d){
if(d.link != ""){
    return d.link;//serviceLink({user:this.user,action:d});
}else{
    arr = d.loc.slice(0,d.count);

    return "http://"+this.readuser+".mysites.com/"+arr.join("/");
}
  },
  makeWidgetContent: function() {
    var navitems = [];
    var loc = document.location.href;
    loc = loc.gsub(".mysit.es","").gsub(".mysites.com","").gsub("http://","").split("/");
    loc = $(loc).without("");

    this.readuser = loc[0];
    this.writeuser = write_user_model_data.username;

    loc[0] = "";
    loc = $(loc).without("");     

    $(loc).each(function(el,i){  

    var data = el;      
    if(data.indexOf("-") === 0){
      data = data.substr(1,data.length);
      if(loc[0] == "-"){
        data = "/"  
      }
    };

      var nitem = this.makeLink({text:data,link:"",loc:loc,count:i+1});
      navitems.push(nitem);

      var gap = Builder.node('div',{style:"margin-right:10px;float:left;position:relative;top:8px;width:20px;height:25px;background:url(http://core.myfil.es/get_file/social/naviarr.png);"},[]);
      navitems.push(gap);

    }.bind(this));

    //here we insert non-path data

    //we are on www
    if(this.readuser == "www" || this.readuser == "guest" && logged_in){

       
    }else{
    //normal userpage

      var userpage = this.makeLink({text:this.readuser,link:"http://"+this.readuser+".mysites.com/",loc:loc});
    var gap3 = Builder.node('div',{style:"margin-right:10px;float:left;position:relative;top:8px;width:20px;height:25px;background:url(http://core.myfil.es/get_file/social/naviarr.png);"},[]);
$(navitems).splice(0,0,gap3);
$(navitems).splice(0,0,userpage);

    }

    //we are on userpage
    if(this.readuser == this.writeuser && logged_in){
      //we are on FOLDER ROOT
      if(loc[0] = "-"){
          
      }
    }
var txt = (logged_in ?  translateText({path: ".nm-sia", id: "Home"}): translateText({path: ".nm-sia", id: "Welcome"}));

  var home = this.makeLink({text:txt.innerHTML,link:"http://www.mysites.com/",loc:loc});
    var gap2 = Builder.node('div',{style:"margin-right:10px;float:left;position:relative;top:8px;width:20px;height:25px;background:url(http://core.myfil.es/get_file/social/naviarr.png);"},[]);
$(navitems).splice(0,0,gap2);
$(navitems).splice(0,0,home);

    //clean empty gap
    navitems.pop();
    navitems.push(Builder.node('div',{style:"clear:both;"}));

//margin-bottom:10px;
    return Builder.node('div',{id:"topnavi",style:"margin-top:10px;border-bottom:1px solid #AFAFAF;width:100%;overflow:hidden;"},navitems);
  }
}

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

// /8::/202::/core:js -> <906> standarditemadditionsoverride.js 


var __actionsFolderTemplate = null
var __actionsFileTemplate = null
var __actionsFileInTrashTemplate = null

function verify(f, msg, _o) {
  var options = Object.extend({
    cancelButton: true
  }, _o || {})
  hideAllTooltips();
  var confirmw = new Window({
    destroyOnClose:true,
    zindex:9999,
    draggable:false,
    minimizable:false,
    maximizable:false,
    closable:false,
    showEffect:Element.show,
    hideEffect:Element.hide,
    className: "tooltip",
    onClose:function() { endIdle(); },
    onMove:function() {},
    onShow:function() {}
  }) 
  var ok = translateButton({
    path: "",
    id: "ok",
    node: Builder.node('input',{
      type:"button",
      value:"",
className:"bigbutton",
      style:"width:100px;margin-right:10px;font-size:130%;font-weight:bolder;font-family:Trebuchet MS;"
    })
  })
  Event.observe(ok,'click',function(){ 
    confirmw.close();
    f();
    return true;
  });
  var cancel = translateButton({
    path: "",
    id: "cancel",
    node: Builder.node('input',{
      type:"button",
className:"bigbutton",
      value:"",
      style:"font-size:130%;width:100px;margin-right:10px;font-weight:bolder;font-family:Trebuchet MS;"
    })
  })
  Event.observe(cancel,'click',function(){ 
    confirmw.close();
    return false;
  });
  var head = table({width:300},[
    {columnOptions:{width:50},columnData:[
      Builder.node('img',{src:"/images/help.png"})
    ]},
    {columnOptions:{},columnData:[
      Builder.node('div', {style:"font-size:180%;font-weight:bolder;"},[
        TN("Oops!")
      ])
    ]}
  ])
  var msgbox = Builder.node('div',{
    style:"font-size:130%;font-weight:bolder;width:90%;"
  },[typeof msg == "string" ? TN(msg) : msg]);
  var c = Builder.node('div',{
    style:"padding:20px;overflow:hidden;width:80%;height:70%;",
    id:"bmbox"
  },[
    msgbox,
    BR(),
    ok,
    (options.cancelButton ? cancel : NBSP())
  ]);
  confirmw.setContent(c, true, true);
  var w = 360
  var h = 160
  if (options.big) {
    w *= 2
    h *= 2
  }
  confirmw.setSize(w, h);
  confirmw.setZIndex(9999);
  confirmw.showCenter(true);
  if (Prototype.Browser.WebKit || Prototype.Browser.Opera) {
    confirmw.element.setStyle({opacity: "1"})
  }
}

StandardItemAdditions = Class.create();
StandardItemAdditions.prototype = {
  inTrash: function(m) { 
    var cp = this.model.currentPath()
    return cp.startsWith("/trash/") || cp == "/trash"
  },
  isFolder: function(m) { return isFolder(m) },
  checkIgnoreShow: function(o) { 
    if (o.ignoreShow) {
      this.ignoreShowClick = true;
    }
  },
  actionsForItemTemplate: function(o) {
    var o = Object.extend({
      inTrash:  false,
      isFolder: false
    }, arguments[0])
    var r = Builder.node('span', {},[])
    if (o.inTrash) {
      r.appendChild(writeImageActionLink({
        onclick: "template:value_of restore_action",
        fullImageName: iconPath(22, "restore"),
        title: "restore"
      })) 
    } else {
      if (!o.isFolder) {
        r.appendChild(imageActionLink({
          onclick: "template:value_of download_action",
          fullImageName: iconPath(22, "download"),
          title: "download",
          href: "template:value_of m.full_item_url"
        }))
      }
      r.appendChild(writeImageActionLink({
        onclick: "template:value_of delete_action",
        fullImageName: iconPath(22, "trash"),
        title: "move to trash"
      }))
      r.appendChild(writeImageActionLink({
        onclick: "template:value_of edit_action",
        fullImageName: iconPath(22, "edit"),
        title: "edit"
      }))
    }
    return new MSTemplate({create: function() { return r }});
  }, 
  actionsTemplateForItem: function(m) {
    if (!__actionsFolderTemplate) {
      __actionsFolderTemplate = this.actionsForItemTemplate({
        isFolder: true
      })
      __actionsFileTemplate = this.actionsForItemTemplate()
      __actionsFileInTrashTemplate = this.actionsForItemTemplate({
        inTrash: true
      })
    }
    return (this.inTrash(m) ? __actionsFileInTrashTemplate : 
          ( this.isFolder(m) ? 
            __actionsFolderTemplate :
            __actionsFileTemplate ))
  },
  actionsForItem: function() {
    var o = Object.extend({
      m: null,
      ignoreShow: false,
      itemElement: null
    }, arguments[0])
    var actionsTemplate = this.actionsTemplateForItem(o.m)
    var instance = this
    var actions = actionsTemplate.makeNode({
      m: o.m,
      download_action: function(event) {
        instance.checkIgnoreShow(o); 
        return true; 
      },
      restore_action: function(event) {
        instance.checkIgnoreShow(o)
        instance.restoreItem(o.m, o.itemElement)
        return false
      },
      delete_action: function(event) {
        instance.checkIgnoreShow(o)
        instance.moveToTrash(o.m, o.itemElement)
        return false
      },
      edit_action: function(event) {
        instance.checkIgnoreShow(o)
        itemDialog().withItem(o.m, instance.model).editItem()
        return false
      }
    })
    if (this.model.service() != "files@core") {
      var files = $(actions).down("img[title=download]")
      if (files) Element.hide(files.parentNode)
    }
    return actions
  }, 
  itemFade: function(e) {
    if (e != undefined) {
      Effect.Fade(e);
    }
  },
  restoreItem: function(m, e) {
    var itemPath = normalizePath(this.model.currentPath() + "/" + m.name)
    var u = this.model.user(m.pretty_name)
    this.ajaxRequest({
      action: "move_to_path_json",
      service: m.service || this.model.service(),
      user: u,
      onSuccess: function(success) { this.model.removeItem(m) }.bind(this)
    }, {
      form_from_path: itemPath, 
      form_from_item_id: m.id,
      form_to_path: "/",
      form_username_override: u
    })
  },
  moveToTrash: function(m) {
    var options = Object.extend({
      ask: true,
      username_override: this.model.user(m.pretty_name)
    }, arguments[1] || {})
    var f = function() {
      var u = options.username_override
      this.ajaxRequest({
        action: "move_to_trash",
        service: m.service || this.model.service(),
        user: u,
        onSuccess: function(success) { this.model.removeItem(m) }.bind(this)
      }, {
        form_path: this.model.currentPath(),
        form_name: m.pretty_name,
        form_username_override: u
      })
    }.bind(this)
    if (options.ask) {
       this.verifyDelete(f,m);
    }
    else {
      f()
    }
  },
  selectableTags: function(o) {
    var ta = searchWidget.tagsArray(o.m.tags)
    var sensitive = o.sensitive
    var instance = this;
    return Builder.node('span', {}, [ta.map(function(tag) { 
      var n = Builder.node('a', {
        href: 'javascript:void(0)',
        className: 'tag'
      }, [TN(tag)])
      var s = Builder.node('span', {}, [n, TN(" ")]);
      if (sensitive) {
        var match = searchWidget.tagInFilter(tag)
        s.style.backgroundColor = match ? "#ccc" : null;
        n.onclick = function() {
          var match = searchWidget.tagInFilter(tag);
          (searchWidget[(match ? "removeFrom" : "addTo") + "SearchFilter"])(tag);
          s.style.backgroundColor = match ? "#ccc" : null;
          return false;
        }
      } else {
        n.onclick = function() {
          standardExplorer.options.tooltip.hideTotally();
          instance.checkIgnoreShow(o)
          searchWidget.addToSearchFilter(tag);
          return false;
        }
      }
      return s
    })])
  },
  addItem: function() {
    var options = arguments[1] || {}
    itemDialog().withItem(this.model.addItem(options), this.model).
        showAddItemForm()
  },
  addFolder: function() {
    itemDialog().withItem(this.model.addFolder(), this.model).
        showAddFolderForm();
  },
   verifyDelete:function(f,o) {
     var msg = translateText({path: "", id: "verify-delete", args: [o.name]})
     verify(f, msg)
    }, 
  displayItemDetail: function(o) {
    var r = Builder.node('span', {}, [
      this.actionsForItem(o), BR()
    ])
    if (!this.isFolder(o.m) && o.m.tags != undefined) {
      r.appendChild(translateText({path: "", id: "tags"}))
      r.appendChild(this.selectableTags(o))
    }
    return r
  }.memoize({dependencies: function(o) { 
    return o.m.name + ":" + o.m.changed 
  }})
}

Object.extend(StandardItemAdditions.prototype, ItemCommon);
Object.extend(StandardItemAdditions.prototype, AjaxRequestMixin); 

;

// /8::/202::/core:js -> <451953> toptabswidget.js 

TopTabsWidget = Class.create();
TopTabsWidget.prototype = {
  defaultOptions: function(){
    return {
      mode:null,
      singletab:false,
      tabs:[
        {id:"recenttab",mode:"active",text:"Recent"},
        {id:"explorertab",mode:"inactive",text:"Explorer"}
      ]
    }
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  setActive:function(tab,txt){
    if(tab.mode == "active"){
      $(txt).setStyle({color:"#1D94D8"});
    }
  },
  makeTab:function(o){
    var m = o.mode;
    var s = "height:32px;float:left;";
    var w = "width:146px;";
    var w2 = "width:2px;";
    var wrapstyle = "cursor:pointer;width:150px;height:32px;";
    wrapstyle += "margin:0px;margin-right:1px;float:left;";

    var ts = "font-weight:bolder;font-size:14px;position:relative;top:7px;width:72px;height:16px;margin:0 auto;";
    var txt = Builder.node('div',{style:ts},[TN(o.text.toUpperCase())]);

//if(m == "active"){
//$(txt).setStyle({color:"#1D94D8"});
//}
this.setActive(o,txt);

    var tab = Builder.node('div',{id:o.id,style:wrapstyle},[
      Builder.node('div',{style:s+w2+"background:url("+this.imageurl("tab-"+m+"-l.png")+");"},[]),
      Builder.node('div',{style:s+w+"background:url("+ this.imageurl("tab-"+m+"-m.png")+");"},[txt]),
      Builder.node('div',{style:s+w2+"background:url("+this.imageurl("tab-"+m+"-r.png")+");"},[]),
      Builder.node('div',{style:"clear:both;"})
    ]);
    tab.o = o;
    Event.observe($(tab),'mouseover',function(e){
      $(tab).descendants().each(function(n){
        $(n).setStyle({color:"#1D94D8"});
      });
    });
    Event.observe($(tab),'mouseout',function(e){
      $(tab).descendants().each(function(n){
        $(n).setStyle({color:"black"});
      });
    });

    Event.observe($(tab),'click',function(e){
     this.tabs.each(function(t,i){
       if(t !== tab){
         this.tabs[i] = this.makeTab(Object.extend(t.o,{mode:"inactive"}));
         t.replace(this.tabs[i]);
         this.notifyObservers(tab.o.text);
       }else{
         this.tabs[i] = this.makeTab(Object.extend(t.o,{mode:"active"}));
         t.replace(this.tabs[i]);
       }
     }.bind(this));
    }.bind(this));

    return tab;
  }, 
  makeWidgetContent: function(){
    this.tabs = [];
//this.options.tabs.reverse()
    if(this.options.singletab){
      this.options.tabs.pop()
    }
    this.options.tabs.each(function(tt){
      var tabb = this.makeTab(tt);
      this.tabs.push(tabb);
    }.bind(this));

    return Builder.node('div',{},[
      this.tabs[0],
      this.tabs[1],
      Builder.node('div',{style:"clear:both;"})
    ]);
  }
}  
Object.extend(TopTabsWidget.prototype, WidgetCommon);
Object.extend(TopTabsWidget.prototype, Observable);
;

// /8::/202::/core:js -> <90259> translations-core.js 

//moved to system
;

// /8::/202::/core:js -> <459590> uploadwidget.js 

var fc = 0;
var uplw = null
UploadWidget = Class.create();
UploadWidget.prototype = {
  defaultOptions: function(){
    return {
      model:itemModel,
      maxfiles:99
    }
  },
  setup:function(){
    uplw = this;
    this.albumoverlay = new AlbumSelectOverlayWidget();
    $(document.body).appendChild(this.albumoverlay.htmlNode())
  },
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  over:function(e){
    $(e).setStyle({backgroundPosition:"0px -26px"});
  },
  out:function(e){
    $(e).setStyle({backgroundPosition:"0px 0px"});
  },
  makeUploadFrame:function(){
    this.frame = Builder.node('iframe',{id:'hiddentarget',name:'hiddentarget'});
    return this.frame;
  },
  makeFileSelect:function(id){  
    window.setTimeout(function(){
//      $("filebox").setStyle({height:(120+(id*30))+'px'}); 
    },100);
    var fi = Builder.node('input',{
      style:"z-index:1;width:100%;",
      type:"file",
      id:"file_"+id,
      name:"file_"+id
    },[]);
    Event.observe($(fi),'change',function(e){
      fc++;
      if(fc <= this.options.maxfiles){
        $(fi).setStyle({position:"absolute",left:"-1000px"});
        //$("filebox").appendChild(this.makeFileSelect(fc));
        this.makeFileText($F(fi),id)
      }else{
        alert("too many");
       }
    }.bind(this));
    return fi;
  },
  makeFileText:function(txt,id){
    $("allfilebox").setStyle({background:"transparent"});
    var s= "cursor:pointer;float:right;margin-right:20px;text-align:center;line-height:30px;";
    s += "padding-top:6px;width:78px;height:26px;";

    var ss = "margin-left:-15px;margin-right:-10px;padding-left:15px;font-size:12px;height:40px;border-bottom:1px solid silver;";

    var btn = Builder.node('div',{style:s},[this.makeButton("upl-btn-remove.png",78)]);

    btn.id = id;
    var fnstyle = "padding-top:10px;float:left;margin-right:10px;width:80%;";
    fnstyle += "";
    var fnmid = "background:url("+this.imageurl("upl-text-mid.png")+") repeat-x;"
    var rlstyle = "width:2px;height:23px;float:left;";
    var rstyle = "background:url("+this.imageurl("upl-text-right.png")+");";
    var lstyle = "background:url("+this.imageurl("upl-text-left.png")+");";
    var filenamebox = Builder.node('div',{style:"height:23px;width:98%;float:left;"+fnmid},[TN(txt)]);
    var l = Builder.node('div',{style:rlstyle+lstyle},[]);
    var r = Builder.node('div',{style:rlstyle+rstyle},[]);

    var filename = Builder.node('div',{style:fnstyle},[
      l,
      filenamebox,
      r,
      Builder.node('div',{style:"clear:both;"})
    ]);
    var c = Builder.node('div',{style:"clear:both;"});
    var delfile = Builder.node('div',{style:ss},[filename,btn,c]);
    Event.observe($(btn),'click',function(){
      $(delfile).remove();
      $("file_"+btn.id).remove();
      fc--;
    });
    $("allfilebox").appendChild(delfile);
  },
  makeHtmlForm:function(){
    var albumselector = EMPTY();
    var substyle= "width:300px;font-family:Trebuchet MS;font-size:24px;font-weight:bolder;height:50px;";


    this.theform = Builder.node('form',{enctype:"multipart/form-data",action:"/upload",method:"post"},[
        Builder.node('div',{style:"margin-bottom:5px;width:100%;"},[
          Builder.node('div',{
              id:"allfilebox",
             style:"position:relative;padding:5px;height:auto;width:100%;"
          },[])
        ]), 
        Builder.node('div',{style:"margin-bottom:5px;width:100%;"},[
          Builder.node('div',{id:"filebox",style:"height:auto;"},[this.makeFileSelect(fc)])
        ]),
        Builder.node('input',{type:"hidden",name:"permission",value:"everyone",id:"permission"}),
Builder.node('input',{type:"hidden",name:"album_name",value:"/",id:"path"})
    ]);

    Event.observe($(this.theform),'submit',function(e){

       if($("allfilebox").innerHTML  == ""){
         Event.stop(e);
         $("allfilebox").setStyle({background:"#FF7F7F"});
         $$("#filebox input")[0].setStyle({border:"1px solid #888888"});         
         return false;
       }else{
         //alert("uploading");
       }
    }.bind(this));
    return this.theform;
  },
  makeButton:function(t,w){
    var btnstyle= "cursor:pointer;width:"+w+"px;height:26px;";
    btnstyle += "background:url("+this.imageurl(t)+");"
    var btn = Builder.node('div',{style:btnstyle},[]);
    Event.observe($(btn),'mouseover',function(e){
      this.over($(btn))
    }.bind(this));
    Event.observe($(btn),'mouseout',function(e){
      this.out($(btn))
    }.bind(this));
    return btn;
  },
  makeBlankButton:function(txt){
    var btnstyle= "cursor:pointer;width:66px;height:26px;";
    btnstyle += "background:url("+this.imageurl("blank-btn.png")+");"
    var btn = Builder.node('div',{style:btnstyle},[txt||NBSP()]);
    Event.observe($(btn),'mouseover',function(e){
      this.over($(btn))
    }.bind(this));
    Event.observe($(btn),'mouseout',function(e){
      this.out($(btn))
    }.bind(this));
    return btn;
  },
  makeUploadButton:function(){
    var btnstyle= "cursor:pointer;width:83px;height:26px;";
    btnstyle += "background:url("+this.imageurl("upl-btn-upload.png")+");"
    var btn = Builder.node('div',{style:btnstyle},[]);

    Event.observe($(btn),'click',function(e){
      this.uploadFiles()
    }.bind(this));
    Event.observe($(btn),'mouseover',function(e){
      this.over($(btn))
    }.bind(this));
    Event.observe($(btn),'mouseout',function(e){
      this.out($(btn))
    }.bind(this));
    return btn;
  },
  uploadFiles:function(){
    if(fc > 0){
      this.albumoverlay.showModal();
    }
  },
  finallyUpload:function(p){
    if(p == ""){
     p = itemModel.currentPath();
    }
    $('path').value = p;
    $('path').setAttribute('value',p);
    $(this.theform).submit()
  },
  makeLower:function(){
    var lowerstyle= "margin-left:-10px;padding-right:20px;margin-bottom:-10px;overflow:hidden;width:100%;height:38px;";
    lowerstyle += "background:url("+this.imageurl("upl-lower.png")+") repeat-x;";
    var btnstyle = "float:right;margin-right:-10px;text-align:right;width:400px;height:26px;padding-top:7px;";
    var visstyle = "float:left;width:400px;height:26px;";
    visstyle += "line-height:38px;font-weight:bolder;margin-left:10px;"
    var btnstyle2 = "float:right;width:90px;"
    var cancel = this.makeBlankButton(Builder.node('div',{style:"color:#9e0b0f;width:66px;text-align:center;font-size:16px;font-weight:bolder;"},[TN("Cancel")]));
    Event.observe($(cancel),'click',function(e){
      $(this.content).up().hide()
    }.bind(this))
    var btndiv = Builder.node('div',{style:btnstyle},[      
        Builder.node('div',{style:btnstyle2+"width:70px"},[ cancel ]),
        Builder.node('div',{style:btnstyle2},[ this.makeUploadButton()]),
        Builder.node('div',{style:"clear:both"},[])
    ]);
    var radiostyle = "width:17px;height:17px;float:left;margin-top:10px;margin-right:5px;";
    radiostyle += "background:url("+this.imageurl("upl-radio.png")+") 0 0;";

    var publicradio = Builder.node('div',{style:radiostyle},[]);
    var publictext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Normal")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var public = Builder.node('div',{style:"cursor:pointer;width:120px;float:left;"},[
      publicradio,publictext,c
    ]);
    
    window.setTimeout(function(){
      $(public).addClassName('selected');
      $(publicradio).setStyle({backgroundPosition:"0px 17px"});
      $('permission').value = 'everyone';
      $('permission').setAttribute('value','everyone');
    },200);

    Event.observe($(public),'click',function(){
      //if($(public).hasClassName('selected')){
      //  $(public).removeClassName('selected');
      //  $(private).addClassName('selected');
      //  $(publicradio).setStyle({backgroundPosition:"0px 0px"});
      //  $(privateradio).setStyle({backgroundPosition:"0px 17px"});
      //  $('permission').value = 'onlyme';
      //  $('permission').setAttribute('value','onlyme');
      //}else{
      //  $(public).addClassName('selected');
      //  $(private).removeClassName('selected');
        $(publicradio).setStyle({backgroundPosition:"0px 17px"});
        $(privateradio).setStyle({backgroundPosition:"0px 0px"});
        $('permission').value = 'everyone';
        $('permission').setAttribute('value','everyone');
      //}
    }.bind(this))

    var privateradio = Builder.node('div',{style:radiostyle},[]);
    var privatetext = Builder.node('div',{style:"width:80px;float:left;"},[TN("Private")]);
    var c = Builder.node('div',{style:"clear:both;"});
    var private = Builder.node('div',{style:"cursor:pointer;width:120px;float:left;"},[
      privateradio,privatetext,c
    ]);
    Event.observe($(private),'click',function(){
      //if($(private).hasClassName('selected')){
      //  $(private).removeClassName('selected');
      //  $(public).addClassName('selected');
      //  $(publicradio).setStyle({backgroundPosition:"0px 17px"});
      //  $(privateradio).setStyle({backgroundPosition:"0px 0px"});
      //  $('permission').value = 'everyone';
      //  $('permission').setAttribute('value','everyone');
      //}else{
      //  $(private).addClassName('selected');
      //  $(public).removeClassName('selected');
        $(publicradio).setStyle({backgroundPosition:"0px 0px"});
        $(privateradio).setStyle({backgroundPosition:"0px 17px"});
        $('permission').value = 'onlyme';
        $('permission').setAttribute('value','onlyme');
      //}
    }.bind(this))
   
    var visibilitydiv = Builder.node('div',{style:visstyle},[
      Builder.node('div',{style:"width:70px;float:left;"},[TN("VISIBILITY:")]),
      public, private, Builder.node('div',{style:"clear:both;"})
    ])
    var c = Builder.node('div',{style:"clear:both;"},[])
    return Builder.node('div',{style:lowerstyle},[visibilitydiv,btndiv,c])
  },
 makeLower2:function(){
    var lowerstyle= "margin-left:-10px;overflow:hidden;width:100%;height:38px;padding-right:20px;";
    var visstyle = "width:100%;height:26px;";
    visstyle += "line-height:38px;font-weight:bolder;"
    var btnstyle= "padding-left:10px;width:110px;";
    var add = Builder.node('div',{style:btnstyle},[this.makeButton("upl-btn-add.png",107)]);
    Event.observe($(add),'click',function(e){
      $("filebox").appendChild(this.makeFileSelect(fc))
    }.bind(this))
 
//makeUploadFrame
    var sepstyle = "padding-right:30px;margin-left:-10px;width:100%;height:2px;margin-bottom:5px;";
    sepstyle += "background:url("+this.imageurl("upl-doublesep.png")+") repeat-x;";

    var sep = Builder.node('div',{style:sepstyle},[NBSP()]);
    var adddiv = Builder.node('div',{style:visstyle},[sep,add])
    return Builder.node('div',{style:lowerstyle},[adddiv])
  },
  makeUploadField:function(){
    var theform = this.makeHtmlForm();   
    this.notifyObservers("uploaderStarted");
    return Builder.node('div',{style:"width:100%;margin-bottom:10px;height:auto;"},[theform]);
  },
  makeWidgetContent: function(){
    var wrapstyle= "height:auto;background:#fffbcc;clear:both;color:black;font-size:11px;";
    wrapstyle += "position:relative;"
    var wrapper = Builder.node('div',{style:wrapstyle},[
      Builder.node('div',{style:"padding:10px;"},[
        Builder.node('div',{style:"width:100%;font-weight:bolder;"},[TN("FILE:")]),
        this.makeUploadField(),
        this.makeLower2(),
        this.makeLower()
      ])
    ]);
    return wrapper;
  }
}  
Object.extend(UploadWidget.prototype, WidgetCommon);
Object.extend(UploadWidget.prototype, Observable);

;

// /8::/202::/core:js -> <455955> userpagewidget.js 

UserPageWidget = Class.create();
UserPageWidget.prototype = {
  defaultOptions: function(){
    return Object.extend({
      checkforupdates:true,
      m:null,
      captions:[
        
      ]
    },arguments[0]);
  },
  setup:function(){
    this.m = this.options.m;    
  }, 
  imageurl:function(img){
    return "http://core.myfil.es/get_file/design/"+img
  },
  makeWidgetContent: function(){  
    var left = [

    ];   

    var right = [
      (new ItemListWidget().htmlNode())
    ];   
 
    layoutwidget = new LayoutWidget({left:left,right:right});

    return layoutwidget.htmlNode();
  }, 
  rerender: function(){
    //this.redrawCompletely()
  }
}  
Object.extend(UserPageWidget.prototype, WidgetCommon);
;

// /8::/202::/core:js -> <218759> z-translations.js 


;

