

/*************** GENERIC WINDOW *****************/

var GenericWindow = $.Class.create({
	_el:null,
	_currentClass:null,
	
	initialize: function(properties){
		this._el = properties.el;
		this._el.find('.close > a').bind('click', {self: this}, function(evt){
			evt.data.self.hide();
		});
		this.forceHide();
	},
	
	showURL: function(url, className){
		show_loading();
		var self = this;
		
		if(className)
		{
			if(this._currentClass) this._el.removeClass(this._currentClass);
			this._currentClass = className;
			this._el.addClass(this._currentClass);
		}
			
		$.ajax({
			url			: url,
			success		: function(resp){
				self.show(resp);
				hide_loading();
			}
		});
	},
	
	show: function(message){
		this._el.trigger('show');
		this._el.stop();
		this._el.find('.window_contents').html(message);
		this._el.css('display', 'block');
		var self = this;
		this._el.css('left', -1 * this._el.innerWidth());
		this._el.animate({
			left		: 0
		}, 500, function(){
			self._el.css('left', 0);
			$('.scrollable .viewport').css('height', $(window).height() - 100);
			
			$('.scrollable').tinyscrollbar();
		});
	},
	
	hide: function(){
		this._el.stop();
		var self = this;
		
		this._el.animate({
			left		: -1 * this._el.innerWidth()
		}, 500, function(){
			self.forceHide();
		});
	},
	
	forceHide: function(){
		this._el.stop();
		this._el.css('left', '0');
		this._el.css('display', 'none');
		this._el.trigger('hideComplete');
	},
	
	getEl: function(){
		return this._el;
	}
});
