var wordWait = "wait...";

function trim(zeichenkette) {
	/*fuehrende und abschliessende leerzeichen entfernen*/	
	return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

var Community = function(){
	this.componentidentifier = 'cmp.cst.community';

	//werte zwischenspeichern
	this.contact = {};
	this.contact.listtype = 0;
	this.contact.site = 0;
	
	this.messaging = {};
	this.messaging.folder = 0;
	this.messaging.site = 0;
	this.messaging.sortfield = 0;
	this.messaging.sortorder = 0;
	this.messaging.filter = "";
	
	this.messaging.lastmessageid = 0;
	
	this.action = '';
	
	//struktur fuer wordings
	this.wording = {};
	
	var that = this;

	this.setWording = function(w){
		this.wording = w;
	}
	
	
	this.showContactlist = function(listtype,p){
		/*kontaktliste anzeigen*/
		this.action = 'contactlist';
		
		
		if(typeof listtype == "undefined"){
			listtype = 0;
		}
		if(typeof p == "undefined"){
			p = 0;
		}
		
		this.contact.listtype = listtype;
		this.contact.site = p;
		
		var container = Ext.get('cmp.cst.community.contacts.list');
		
		container.getUpdater().update({
			url: 'index.cfm',
		    method: 'GET',
		    params: {
				'event': 'cmp.cst.community.contacts.list',
				'cmp.cst.community.contact.listtype' : this.contact.listtype,
				'cmp.cst.community.contact.site' : this.contact.site
			},
		    text: wordWait,
		    scripts: true
		});
				
		
	};
	
	this.deleteContact = function(id){
		/*kontakt loeschen*/
		var that = this;
		
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

				that.showContactlist(that.contact.listtype,that.contact.site);				
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.contacts.delete',
				'cmp.cst.community.contact.id' : id
			}
		});		
	};
	
	this.rejectContact = function(id){
		/*kontakt ablehnen*/
		var that = this;
		
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

                if(jsonData.ERRORCODE > 0){
                	Ext.Msg.alert(that.wording['error'], that.wording[jsonData.ERRORMESSAGE]);
                }
                else{                
	                if(that.action == 'messagedetail'){
	                	that.showMessage(that.messaging.lastmessageid);
	                }
	                else if(that.action == 'contactlist'){
	                	that.showContactlist(that.contact.listtype,that.contact.site);            	
	                }
                }
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.contacts.decline',
				'cmp.cst.community.contact.id' : id
			}
		});		
	};
	
	this.acceptContact = function(id){		
		/*kontakt annehmen*/
		var that = this;
		
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);
                
                if(jsonData.ERRORCODE > 0){
                	Ext.Msg.alert(that.wording['error'], that.wording[jsonData.ERRORMESSAGE]);
                }
                else{                
	                if(that.action == 'messagedetail'){
	                	that.showMessage(that.messaging.lastmessageid);
	                }
	                else if(that.action == 'contactlist'){
	                	that.showContactlist(that.contact.listtype,that.contact.site);            	
	                }	
                }
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.contacts.confirm',
				'cmp.cst.community.contact.id' : id
			}
		});		
	};

	this.addContact = function(id){	
		/*kontakt anfragen*/
		var that = this;
		
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

                
                if(that.action == 'messagedetail'){
                	that.showMessage(that.messaging.lastmessageid);
                }
                else if(that.action == 'contactlist'){
                	that.showContactlist(that.contact.listtype,that.contact.site);            	
                }
                else{
                	Ext.get('cmp.cst.community.contacts.addcontactlink').update(that.wording['messaging.detail.contactallreadyadded']);
                	
                	Ext.Msg.alert(that.wording['contacts.add.popup.title'], that.wording['contacts.add.popup.text']);
                }
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.contacts.add',
				'cmp.cst.community.contact.id' : id
			}
		});		
	};
	
	/*messaging*/
	
	this.showMessagingFolder = function(folder,sortfield,sortorder,filter,p){
		/*nachrichtenordner anzeigen*/
		this.action = 'messagingfolder';
		
		
		if(typeof folder == "undefined"){
			folder = 0;
		}
		if(typeof sortfield == "undefined"){
			sortfield = 0;
		}
		if(typeof sortorder == "undefined"){
			sortorder = 0;
		}
		if(typeof filter == "undefined"){
			filter = "";
		}
		if(typeof p == "undefined"){
			p = 0;
		}
		
		this.messaging.folder = folder;
		this.messaging.sortfield = sortfield;
		this.messaging.sortorder = sortorder;
		this.messaging.filter = filter;
		this.messaging.site = p;
		
		var container = Ext.get('cmp.cst.community.messaging.folder');
		
		container.getUpdater().update({
			url: 'index.cfm',
		    method: 'GET',
		    params: {
				'event': 'cmp.cst.community.messaging.folder',
				'cmp.cst.community.messaging.folder.id' : this.messaging.folder,
				'cmp.cst.community.messaging.folder.sortfield' : this.messaging.sortfield,
				'cmp.cst.community.messaging.folder.sortorder' : this.messaging.sortorder,
				'cmp.cst.community.messaging.folder.filter' : this.messaging.filter,
				'cmp.cst.community.messaging.site' : this.messaging.site
			},
		    text: wordWait,
		    scripts: true
		});
				
		
	};
	
	this.sortMessagingFolder = function(sortfield,sortorder){
		/*sortierung fuer nachrichtenordner aufrufen*/
		
		if(typeof sortfield == "undefined"){
			sortfield = 0;
		}
		if(typeof sortorder == "undefined"){
			sortorder = "";
		}
		
		this.messaging.sortfield = sortfield;
		this.messaging.sortorder = sortorder;
		
		var that = this;
		
		that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);
	}
	
	this.pageMessagingFolder = function(p){
		/*blaetterfunktion fuer nachrichtenordner ausfuehren*/
		if(typeof p == "undefined"){
			p = 0;
		}
				
		this.messaging.site = p;
				
		var that = this;
		
		that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);
	}
	
	this.filterMessagingFolder = function(filter){
		/*filterfunktion fuer nachrichtenordner ausfuehren*/
		if(typeof filter == "undefined"){
			filter = 0;
		}
				
		this.messaging.filter = filter;
				
		var that = this;
		
		that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);
	}
	
	this.selectall = function(objname){
		/*alle listenelemente auswaehlen*/
		var keys = document.getElementById('frmselect');
		if (keys) {
			var inputs = keys.getElementsByTagName('input');
			if (inputs) {
				for (var i = 0; i < inputs.length; ++i) {
	    			if(inputs[i].type == "checkbox" && inputs[i].name == objname){
	    				inputs[i].checked = true;
	    			}
	    		}
	  		}
		};
	}	

	this.deselectall = function(objname){
		/*alle listenelemente abwaehlen*/
		var keys = document.getElementById('frmselect');
		if (keys) {
			var inputs = keys.getElementsByTagName('input');
			if (inputs) {
				for (var i = 0; i < inputs.length; ++i) {
					if(inputs[i].type == "checkbox" && inputs[i].name == objname){
						inputs[i].checked = false;					
					}				
				}
			}
		};
	}
	
	this.checkAll = function(as){
		/*alle listenelemente ab-/auswaehlen*/
		if(document.getElementById("assign" + as).checked)
		{
			document.getElementById("assign1").checked = 1;
			document.getElementById("assign2").checked = 1;
		}
		else
		{
			document.getElementById("assign1").checked = 0;
			document.getElementById("assign2").checked = 0;
		}

		var c1 = document.getElementById('assign' + as);

		if(c1.checked == false){
			this.deselectall('selection');
		}
		else{
			this.selectall('selection');
		}
	}
	
	this.getSelectedMessages = function(){
		/* alle selektierten elemente ermitteln*/
		var pks = '';
		var objname = 'selection';
		var keys = document.getElementById('frmselect');
		if (keys) {
			var inputs = keys.getElementsByTagName('input');
			if (inputs) {
				for (var i = 0; i < inputs.length; ++i) {
					if(inputs[i].type == "checkbox" && inputs[i].name == objname){
						if(inputs[i].checked == true){
							pks = pks + ',' + inputs[i].value;
						}
					}		
				}
			}
		};
		
		pks = pks.substr(1,pks.length);
		
		return pks;
	}
	
	this.unreadMessages = function(){
		/*status der selektierten elemente auf ungelesen setzen*/
		var pks = this.getSelectedMessages();
		
		var that = this;
				
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

                that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);				
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.messaging.markunread',
				'cmp.cst.community.messaging.message.ids' : pks
			}
		});		
		
	}
	
	this.markMessages = function(mark){
		/*selektierte elemente markieren / demarkieren */
		var pks = this.getSelectedMessages();
		
		var that = this;
				
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

                that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);				
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.messaging.mark',
				'cmp.cst.community.messaging.mark.ids' : pks,
				'cmp.cst.community.messaging.mark' : mark
			}
		});		
		
	}
	

	this.deleteMessages = function(ids){
		/*selektierte elemente loeschen*/
		if(typeof ids == "undefined"){
			ids = 0;
		}
		
		if(ids == 0){
			var pks = this.getSelectedMessages();
		}
		else{
			pks = ids;
		}
		
		var that = this;
				
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

                that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);				
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.messaging.delete',
				'cmp.cst.community.messaging.message.ids' : pks
			}
		});		
		
	}
	
	this.notifySpam = function(pks,text){
		/*selektierte nachrichten als spam melden*/
		//var pks = this.getSelectedMessages();
		
		var that = this;
				
		Ext.Ajax.request({
			url: 'index.cfm',
			success: function( result, request ) {
                var jsonData = Ext.util.JSON.decode(result.responseText);

                
                if(that.action == 'messagedetail'){
                	that.showMessage(that.messaging.lastmessageid);
                }
                else if(that.action == 'messagingfolder'){
                	that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);            	
                }
                				
			},
			failure: function(){
				//nix gefunden
			},
			params: {
				'event': 'cmp.cst.community.messaging.reportspam',
				'cmp.cst.community.messaging.spam.ids' : pks,
				'cmp.cst.community.messaging.spam.message' : text
			}
		});		
		
	}
	
	this.showSpamPopup = function(ids){
		/*spam melden popup oeffnen*/
		
		if(typeof ids == "undefined"){
			ids = 0;
		}
		
		if(ids == 0){
			var pks = this.getSelectedMessages();
		}
		else{
			pks = ids;
		}
		
		
		nid = pks.toString();
		
		if(nid.length > 0){
			Ext.MessageBox.show({
		           title: that.wording['spam.popup.title'],
		           msg: that.wording['spam.popup.text'],
		           width		: 400,
			       height		: 300,
		           buttons: Ext.MessageBox.OKCANCEL,
		           multiline: true,
		           fn: function(btn, text) 
				   		{
							if(btn == "ok")
							{
								that.notifySpam(pks, text);
							}
						} ,
		           animEl: 'mb3'
		       });	
		}
		else{
			Ext.Msg.alert(that.wording['spam.error.title'], that.wording['spam.error.text']);
		}
		
	}
	
	this.showMessageForm = function(member,forward,replyto,replytoall){
		/*formular fuer nachrichtenerstellung anzeigen*/
		
		if(typeof replyto == "undefined"){
			replyto = 0;
		}
		if(typeof forward == "undefined"){
			forward = 0;
		}
		if(typeof member == "undefined"){
			member = 0;
		}
		
		if(typeof replytoall == "undefined"){
			replytoall = 0;
		}
		
		
		var container = Ext.get('cmp.cst.community.messaging.folder');
		
		container.getUpdater().update({
			url: 'index.cfm',
		    method: 'GET',
		    params: {
				'event': 'cmp.cst.community.messaging.writemessage',
				'cmp.cst.community.messaging.writemessage.replyto' : replyto,
				'cmp.cst.community.messaging.writemessage.replytoall' : replytoall,
				'cmp.cst.community.messaging.writemessage.forward' : forward,
				'cmp.cst.community.messaging.writemessage.member' : member				
			},
		    text: wordWait,
		    scripts: true
		});
				
		
	};
	
	this.sendMessage = function(){
		/*nachricht verschicken*/
		/*subject,message,recipients,replyto,forward,idlist*/		
		
		var that = this;
		
		recipients = Ext.get('cmp.cst.community.messaging.write.recipient').getValue();		
		subject = Ext.get('cmp.cst.community.messaging.write.subject').getValue();		
		message = Ext.get('cmp.cst.community.messaging.write.message').getValue();		
		replyto = Ext.get('cmp.cst.community.messaging.write.replyto').getValue();;
		forward = Ext.get('cmp.cst.community.messaging.write.forward').getValue();;
		idlist = false;

		//validierung...
		var sErr = "";
		var bErr = false;
		
		if(recipients.length == 0){
			sErr = sErr + that.wording['send.error.norecipient'];
			bErr = true;
		}
		
		if(subject.length == 0){
			sErr = sErr + that.wording['send.error.nosubject'];
			bErr = true;
		}
		
		if(message.length == 0){
			sErr = sErr + that.wording['send.error.nomessage'];
			bErr = true;
		}

		if(bErr){
			Ext.Msg.alert(that.wording['send.error.title'], sErr);
		}
		else{				
			Ext.Ajax.request({
				url: 'index.cfm',
				success: function( result, request ) {
	                var jsonData = Ext.util.JSON.decode(result.responseText);
	                
	                Ext.Msg.alert(that.wording['send.success.title'], that.wording['send.success.text']);
	                that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);				
				},
				failure: function(){					
					//nix gefunden
				},
				params: {
					'event': 'cmp.cst.community.messaging.send',
					'cmp.cst.community.messaging.send.subject' : subject,
					'cmp.cst.community.messaging.send.message' : message,
					'cmp.cst.community.messaging.send.recipientslist' : recipients,
					'cmp.cst.community.messaging.send.idlist' : idlist,
					'cmp.cst.community.messaging.send.replyto' : replyto,
					'cmp.cst.community.messaging.send.forward' : forward				
				}
			});	
		}
	}
	
	
	this.showMessage = function(id){
		/*nachrichten detail anzeigen*/
		this.action = 'messagedetail';
		
		if(typeof id == "undefined"){
			id = 0;
		}
		
		this.messaging.lastmessageid = id;
		
		var container = Ext.get('cmp.cst.community.messaging.folder');
		
		container.getUpdater().update({
			url: 'index.cfm',
		    method: 'GET',
		    params: {
				'event': 'cmp.cst.community.messaging.getmessages',
				'cmp.cst.community.messaging.message.id' : id
					
			},
		    text: wordWait,
		    scripts: true
		});
				
		
	};
	
	
	
	this.showContactlistPopup = function(){
		/*popup fuer auswahl der kontakte anzeigen*/
		
		var that = this;
		
		win = new Ext.Window({       
			title 		: '<a href="javascript:void(0);" onclick="win.destroy();">' + that.wording['close'] + '</a>',
						
			closable	: false,
			renderTo: Ext.getBody(),
	        closeAction : 'hide',
	        plain       : true,
	        modal		: true,
	        border		: false,
	        width		: 400,
	        height		: 300,
	        cls			: '',
	        items: [
	        {                	
	        	xtype: 'panel',
	 			border: false,
	 			cls: '',
	 			html:'<div id="popupcontentdiv"><!--leer--></div>'
	 		
	 					
	        }	 		
	 		]
	    });
		
		Ext.get('popupcontentdiv').getUpdater().update({
			url: 'index.cfm',
		    method: 'GET',
		    params: {
				'event': 'cmp.cst.community.contacts.getContacts'		
			},
		    text: wordWait,
		    scripts: true
		});
		
		//win.setPosition(200,40);
		win.center();
		
		
		
		win.show();
		
		
	}
	
	this.setRecipients = function(){
		/*ausgewaehlte kontakte als empfaenger setzen*/
		
		var sRecipients = '';
		
		var aRecipients = document.getElementsByName('cmp.cst.community.messaging.contactselection');
		
		sRecipients = Ext.get("cmp.cst.community.messaging.write.recipient").getValue();
		
		var names = Ext.get("cmp.cst.community.messaging.write.recipient").getValue().split(",");
		
		
		
		for(i=0;i<aRecipients.length;i++){
			sR = aRecipients[i].value;
			bChecked = aRecipients[i].checked;
			
			if(bChecked){
				
				bDouble = 0;
				for(j=0;j<names.length;j++){
					if(trim(names[j]) == sR){
						bDouble = 1;
						break;
					}					
				}
				
				if(!bDouble){

					
					if(trim(sRecipients).length > 0){
						sRecipients = sRecipients + ', ';
					}
					sRecipients = sRecipients + sR;
					
				}
				
			}
		}
		
		
		
		Ext.get("cmp.cst.community.messaging.write.recipient").dom.value = sRecipients;
		win.destroy();
		
	}
	
	this.showArchivePopup = function(ids){
		/*popup fuer das verschieben in andere ordner anzeigen*/
		
		if(typeof ids == "undefined"){
			ids = 0;
		}
		
		if(ids == 0){
			var pks = this.getSelectedMessages();
		}
		else{
			pks = ids;
		}
		
		
		var that = this;
		
		var sErr = '';
		var bErr = false;
		
		if(pks.toString().length == 0){
			sErr = that.wording['archive.error.nomessage'];
			bErr = true;
		}
		
		
		if(bErr){
			Ext.Msg.alert(that.wording['archive.error.title'], sErr);
		}
		else{
		
			win = new Ext.Window({       
				title 		: '<a href="javascript:void(0);" onclick="win.destroy();">' + that.wording['close'] + '</a>',
							
				closable	: false,
				renderTo: Ext.getBody(),
		        closeAction : 'hide',
		        plain       : true,
		        modal		: true,
		        border		: false,
		        width		: 400,
		        height		: 300,
		        cls			: '',
		        items: [
		        {                	
		        	xtype: 'panel',
		 			border: false,
		 			cls: '',
		 			html:'<div id="popupcontentdiv"><!--leer--></div>'
		 		
		 					
		        }	 		
		 		]
		    });
			
			Ext.get('popupcontentdiv').getUpdater().update({
				url: 'index.cfm',
			    method: 'GET',
			    params: {
					'event': 'cmp.cst.community.messaging.getfolderlist',
					'cmp.cst.community.messaging.getfolderlist.message.ids': pks	
				},
			    text: wordWait,
			    scripts: true
			});
			
			//win.setPosition(200,40);
			win.center();
			
			
			
			win.show();
		}
		
	}
	
	this.archiveMessages = function(ids){
		/*selektierte nachrichten in den selektierten ordner verschieben*/
		
		var folder = 0;
		
		var aFolders = document.getElementsByName('cmp.cst.community.messaging.folderselection');
		
		for(i=0;i<aFolders.length;i++){
			sF = aFolders[i].value;
			bChecked = aFolders[i].checked;
			
			if(bChecked){
				folder = sF;
				break;
			}
		}
		
		var that = this;
		
		var sErr = '';
		var bErr = false;
		
		if(folder == 0){
			sErr = that.wording['archive.error.nofolder'];
			bErr = true;
		}
		
		if(bErr){
			Ext.Msg.alert(that.wording['archive.error.title'], sErr);
		}
		else{
			Ext.Ajax.request({
				url: 'index.cfm',
				success: function( result, request ) {
	                var jsonData = Ext.util.JSON.decode(result.responseText);

	                
	                win.destroy();
	                
	                if(that.action == 'messagedetail'){
	                	that.showMessage(that.messaging.lastmessageid);
	                }
	                else if(that.action == 'messagingfolder'){
	                	that.showMessagingFolder(that.messaging.folder, that.messaging.sortfield, that.messaging.sortorder, that.messaging.filter, that.messaging.site);            	
	                }	                
	               				
				},
				failure: function(){
					//nix gefunden
				},
				params: {
					'event': 'cmp.cst.community.messaging.archive',
					'cmp.cst.community.messaging.archive.message.ids' : ids,
					'cmp.cst.community.messaging.archive.folder' : folder			
				}
			});
		}
			
	}
	
	
	this.showPreviewPopup = function(){
		/*vorschau popup anzeigen*/
		
		win = new Ext.Window({       
			title 		: '<a href="javascript:void(0);" onclick="win.destroy();">' + that.wording['close'] + '</a>',
						
			closable	: false,
			renderTo: Ext.getBody(),
	        closeAction : 'hide',
	        plain       : true,
	        modal		: true,
	        border		: false,
	        width		: 400,
	        height		: 300,
	        cls			: '',
	        items: [
	        {                	
	        	xtype: 'panel',
	 			border: false,
	 			cls: '',
	 			html:'<div id="popupcontentdiv"><!--leer--></div>'
	 		
	 					
	        }	 		
	 		]
	    });
		
		
		
		recipient = Ext.get('cmp.cst.community.messaging.write.recipient').getValue();
		subject = Ext.get('cmp.cst.community.messaging.write.subject').getValue();
		message = Ext.get('cmp.cst.community.messaging.write.message').getValue();
		
		
		
		
		
		Ext.get('popupcontentdiv').getUpdater().update({
			url: 'index.cfm',
		    method: 'GET',
		    params: {
				'event': 'cmp.cst.community.messaging.getpreview',
				'cmp.cst.community.messaging.preview.subject': subject,
				'cmp.cst.community.messaging.preview.message': message,
				'cmp.cst.community.messaging.preview.recipient': recipient
				
			},
		    text: wordWait,
		    scripts: true
		});
		
		//win.setPosition(200,40);
		win.center();
		
		
		
		win.show();
		
	}
	
	
	this.printMessage = function(id){
		/*nachricht drucken*/
		window.open('/index.cfm?event=cmp.cst.community.messaging.print&cmp.cst.community.messaging.message.id=' + id,'print_popup');
	}
	
	
	this.deleteAvatar = function(id){
		/*avatar loeschen*/
		
		var f = Ext.getDom('cmp.cst.community.Form.avataraction')
		
		if(typeof f != "undefined"){
			var aid = f['cmp.cst.community.avatar.id'];
			aid.value = id;
			
			var action = f['cmp.cst.community.avatar.action'];
			action.value = 'del';
			
			f.submit();
		}		
	}
	
	this.makeMasterAvatar = function(id){
		/*bild zum hauptbild machen*/
		
		var f = Ext.getDom('cmp.cst.community.Form.avataraction')
		
		if(typeof f != "undefined"){
			var aid = f['cmp.cst.community.avatar.id'];
			aid.value = id;
			
			var action = f['cmp.cst.community.avatar.action'];
			action.value = 'master';
			
			f.submit();
		}		
	}
	
	this.editAvatar = function(b){
		/*avatare bearbeiten*/
		
		var f = Ext.getDom('cmp.cst.community.Form.avataraction')
		
		if(typeof f != "undefined"){
			var aid = f['cmp.cst.community.avatar.id'];
			aid.value = 0;
			
			var action = f['cmp.cst.community.avatar.action'];
			action.value = 'master';
			
			var edit = f['cmp.cst.community.avatar.edit'];
			edit.value = b;
			
			f.submit();
		}		
	}
	
};

/*instanz des community-objects erzeugen*/
myCommunity = new Community();






