Ext.namespace('mm.pageview.uploader.tmpl.base');
mm.pageview.uploader.tmpl.base = '<div></div>';
Ext.namespace('mm.pageview.uploader.tmpl.window');
mm.pageview.uploader.tmpl.window = '<div class="window"> <div class="content"> <div class="downloaddescription">To synchronize local music with your My-Musix-library, please download our uploamanager!</div> <div class="title">Upload</div> <div class="softwaredescription"> This software is free of use. It requires Java. Java is available for download for free right <a target="_blank" href="http://www.java.com/de/download/">here</a>!<br/> To register you music, please login and add all the folders containing the music you wish to listen from everywhere.</div> <div class="button">Download</div> </div> <div class="close"></div> </div>';
Ext.namespace('mm.pageview.uploader.base');
mm.pageview.uploader.base.construct = function(autoconstruct){
	this.templates = {base:mm.pageview.uploader.tmpl.base,window:mm.pageview.uploader.tmpl.window};
	this.isactive = false;
	this.constructor = function()
	{
		var template = new Ext.XTemplate(this.templates.base);
		this.el = $(template.apply()).addClass(this.domname);
		$('body div.center div.innerappendix').append(this.el);
	
		mm.base.obj.addEventListener('opendownloadwindow', {
			fire:function(eventobject){
				if (!this.isactive)
				{
					this.isactive = true;
					this.openwindow();
					if (typeof eventobject != 'undefined' && typeof eventobject.callback == 'function')
					{
						eventobject.callback();
					}
				}
			}.createDelegate(this)
		});
	};

	this.openwindow = function()
	{
		var position = $('.mm-toppanel-library-base').position();
		this.el.css({
			top: position.top,
			left: position.left,
			width: $('.mm-toppanel-library-base').width(),
			height: $('.mm-toppanel-library-base').height()
		});
		this.el.show('slow',this.buildwindowcontent.createDelegate(this));
	};

	this.buildwindowcontent = function()
	{
		var template = new Ext.XTemplate(this.templates.window);
		var win = $(template.apply());
		win.css({
			display: 'none',
			width:this.el.width(),
			height:this.el.height()
		});
		this.el.html('').append(win);
		win.find('.close').bind('click', function(){
			this.el.find('.window').hide(0,function(){
				this.el.find('.window').remove();
				this.el.hide('slow',function(){
					this.isactive = false;
				}.createDelegate(this));
			}.createDelegate(this))
		}.createDelegate(this));
		win.find('.content').css({
			width:this.el.width(),
			height:this.el.height()
		});
		win.find('.button').click(function(event){
			event.preventDefault();
			document.location.href = 'http://www.my-musix.com/download/MyMusixClient.jar';
		}.createDelegate(this));
		win.show();
	};

	if (typeof autoconstruct != 'undefined' && autoconstruct)
	{
		this.constructor();
	}
};
mm.pageview.uploader.base.construct.prototype.domname = 'mm-pageview-uploader-base';
mm.pageview.uploader.base.construct.prototype.namespace = mm.pageview.uploader.base;

mm.pageview.uploader.base.obj = new mm.pageview.uploader.base.construct(true);
