/**
* deskJS-Functions
*
*  Parameters:
*    verzDebug: Debugstatus für den JSON-Output (bolean)
*    verzLocal: Request auf lokale/externe Daten (bolean)
*    verzUser: DBName des Benutzer (string)
*
*  Methods:
*    _loadStatus: Aufruf bei jeder Interaktion - Load, Request, usw (bereich, json-aktion)
*    _directLink: Aufruf durch direktlink Verz-Verz und Internen Seiten (mode = verz/site)
*    _afterRendering: Aufruf nach Einbindung der Plugins und Rendering des Templates
*/
var deskJS;
window.addEvent('domready',function(){

	deskJS = new deskJS();
	
});

deskJS = new Class({
	
        // Implements
        Implements: addDeskJS
	
	// options
        ,options: {
		verzDebug: 1
		,verzLocal: 0
		,verzUser: 'acorus'
		,nameVal: []
        }
	
	// initialization
        ,initialize: function(options){
		
		//set options
		this.setOptions(options);
		
		// pluginload
		this._jsPreload({
			templating: true
			,historymanager: false
			,menu: true
			,slider: false
			,scrollspy: false
			,popup: false
			,sortOn: false
			,tabs: false
		});
		
	}
	
	// Ladestatus der Plugins oder des Request
        ,_loadStatus: function(part, action){
		
        }
	
	// Aufruf durch Verzeichnisverlinkung
        ,_directLink: function(mode, DBstr, lrID, ldID){
		
        }
	
	,_afterRendering: function(){
	
		this.colorbold();
		this.AccordionOpen();
		
	}
	
	// Standard Request Dummy welcher für jede Funktion verwendet werden kann
	,getDummy: function(){
		
		//standard Req Dummy
		var dummy = {
			type: 'all'
			,user: this.options.verzUser
			,table: {
				listingdatas: 'ld'
				,listingrows: 'lr'
				,listings: 'l'
			}
			,condition:{
				
			}
			,fields: 'ld.*'
			,order: ''
			,language: LANG
		}
		
		return dummy;
	}
	,colorbold: function(){
		$$('.colorbold b').setStyle('color', '#fff');
	}
	,AccordionOpen: function(){
		
		if($defined($$('.toggles.close')[0]))$$('.toggles.close').getLast('div').setStyle('border-bottom', '1px solid #666666');
	}
})
if(!$defined($$('.remooz-element'))) {
	//extend go4webdesk popup
	ReMooz.implement({
		open: function(e){
			
			if (!$defined($('BoxOverlay'))) {
				overlay = new Element('div', {
					'id': 'BoxOverlay',
					'styles': {
						'display': 'block',
						'z-index': '998',
						'position': 'absolute',
						'top': '0',
						'left': '0',
						'background-color': '#004e95',
						'opacity': 0
					}
				}).inject(document.body);
				
				$('BoxOverlay').setStyles({
					width: window.getScrollWidth() + 'px',
					height: window.getScrollHeight() + 'px'
				});
			}
			
			
			mO = new Fx.Morph($('BoxOverlay'), {
				duration: 350
			});
			mO.start({
				'opacity': 0.85
			});
			
			if (this.opened) return (e) ? this.close() : this;
			this.opened = this.loading = true;
			if (!this.box) this.build();
			this.coords = this.getOriginCoordinates();
			this.coords.opacity = this.options.opacityLoad;
			this.coords.display = '';
			this.tweens.box.set(this.coords);
			this.box.addClass('remooz-loading');
			ReMooz.open(this.fireEvent('onLoad'));
			this['open' + this.options.type.capitalize()]();
			return this;
			
		},
		
		close: function(){
			
			mO = new Fx.Morph($('BoxOverlay'), {
				duration: 350
			});
			mO.start({
				'opacity': 0
			});
			
			if (!this.opened) return this;
			this.opened = false;
			ReMooz.close(this.fireEvent('onClose'));
			if (this.loading) {
				this.box.setStyle('display', 'none');
				return this;
			}
			this.drag.detach();
			this.tweens.fade.cancel().set(0).fireEvent('onComplete');
			if (this.tweens.box.timer) this.tweens.box.clearChain();
			var vars = this.getOriginCoordinates();
			if (this.options.opacityResize != 1) vars.opacity = this.options.opacityResize;
			this.tweens.box.start(vars).chain(this.closeEnd.bind(this));
			return this;
		}
	});	
}
	
