<?php
defined('_JEXEC') or die('Direct Access to this location is not allowed.');

class QuickModeHtml{
	
	public static function showApplication($formId = 0, $formName, $formTitle, $formDesc, $formEmailntf, $formEmailadr, $dataObjectString, $elementScripts, $themes){
		JHTML::_('behavior.keepalive');
		JHTML::_('behavior.modal');
		$iconBase = '../administrator/components/com_facileforms/libraries/jquery/themes/quickmode/i/';
?>
	<style>
	<!--
	#menutab { float: left; width: 500px; height: 100%; }
	-->
	</style>
	
	<link rel="stylesheet" href="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/themes/quickmode/quickmode.all.css' ;?>" type="text/css" media="screen" title="Flora (Default)">
	<link rel="stylesheet" type="text/css" href="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/jtree/' ;?>tree_component.css" />
	<script type="text/javascript" src="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/jtree/' ;?>_lib.js"></script>	
	<script type="text/javascript" src="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/jtree/' ;?>tree_component.js"></script>

	<script
	type="text/javascript"
	src="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/' ;?>jquery-ui.min.js"></script>
	<script
	type="text/javascript"
	src="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/plugins/' ;?>base64.js"></script>
	<script
	type="text/javascript"
	src="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/plugins/' ;?>json.js"></script>
	<script
	type="text/javascript"
	src="<?php echo JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/plugins/' ;?>md5.js"></script>

	<script type="text/javascript">
	var $jq = jQuery.noConflict();
	var app = null;
	
	function BF_QuickModeApp(){
		
		var selectedTreeElement = null;
		var appScope = this;
		this.elementScripts = <?php echo Zend_Json::encode($elementScripts)?>;	      
		this.dataObject = <?php echo $dataObjectString ?>;
		
		<?php require_once(JPATH_SITE . '/administrator/components/com_facileforms/admin/quickmode-elements-js.php'); ?>
		
		/**
			Helper methods
		*/
		this.getNodeClass = function(node){
			if($jq(node).attr('class')){
				var splitted = $jq(appScope.selectedTreeElement).attr('class').split(' ');
				if(splitted.length != 0){
					return splitted[0]; 
				}
			}
			return '';
		};
		
		this.setProperties = function(node, props){
			var item = this.findDataObjectItem($jq(node).attr('id'), appScope.dataObject);
			item.properties = props;
		};
		
		this.getProperties = function(node){
			
			var item = this.findDataObjectItem($jq(node).attr('id'), appScope.dataObject)
			return item.properties;
		};
		
		/**
			searches for the id in a given object item.
		*/
		this.findDataObjectItem = function(id, startObj){
			if( id && startObj && startObj.attributes && startObj.attributes.id ){
				if( startObj.attributes.id == id ){
					return startObj;
				} else { 
					if(startObj.children){
						var child = null;
						for(var i = 0; i < startObj.children.length; i++){
							child = appScope.findDataObjectItem(id, startObj.children[i]);
							if(child){
								return child;
							}
						}
					}
				}
				return null;
			}
			return null;
		};
		
		this.replaceDataObjectItem = function(id, replacement, startObj){
			if( id && startObj && startObj.attributes && startObj.attributes.id ){
				if(startObj.children){
					var child = null;
					for(var i = 0; i < startObj.children.length; i++){
						if(startObj.children[i].attributes.id == id){
							startObj.children[i] = replacement;
							break;
						}
						appScope.replaceDataObjectItem(id, replacement, startObj.children[i]);
					}
				}
			}
		}
		
		/**
			searches for the id in a given object item and deletes it.
			returns the deleted child.
		*/
		this.deleteDataObjectItem = function(id, startObj, previous){
			if( id && startObj && startObj.attributes && startObj.attributes.id ){
				if( startObj.attributes.id == id ){
					if(previous){
						var newChildren = new Array();
						for(var j = 0; j < previous.children.length; j++){
							if(previous.children[j].attributes.id != startObj.attributes.id){
								newChildren.push(previous.children[j]);
							}
						}
						previous.children = newChildren;
					}
					return startObj;
				} else { 
					if(startObj.children){
						var child = null;
						for(var i = 0; i < startObj.children.length; i++){
							child = appScope.deleteDataObjectItem(id, startObj.children[i], startObj);
							if(child){
								return child;
							}
						}
					}
				}
				return null;
			}
			return null;
		};
		
		this.moveDataObjectItem = function( sourceId, targetId, index, obj ){
			var source = appScope.deleteDataObjectItem(sourceId, obj);
			var target = appScope.findDataObjectItem( targetId, obj );
			if(target && !target.children && ( target.attributes['class'] == 'bfQuickModePageClass' || target.attributes['class'] == 'bfQuickModeSectionClass' || target.attributes['class'] == 'bfQuickModeRootClass' )){
				target.children = new Array();
			}
			if(target && target.children){
				target.children.splice(index,0,source);
				if(target.attributes['class'] == 'bfQuickModeRootClass'){
					for(var i = 0; i < target.children.length; i++){
						var mdata = appScope.getProperties($jq('#'+target.children[i].attributes.id));
						if(mdata){
							if(target.children[i].attributes['class'] == 'bfQuickModePageClass'){
								target.children[i].attributes.id = 'bfQuickModePage' + (i+1);
								target.children[i].data.title = "<?php echo addslashes( BFText::_('PAGE') ) ?> " + (i+1);
								target.children[i].properties.pageNumber = i + 1;
							}
						}
					}
				}
				return true;
			}
			return false;
		}
		
		/**
			Element properties
		*/
		
		// TEXTFIELD
		this.saveTextProperties = function(mdata, item){
			mdata.value = $jq('#bfElementTypeTextValue').val();
			mdata.bfName = $jq('#bfElementName').val();
			mdata.logging = $jq('#bfElementAdvancedLogging').attr('checked');
			mdata.label = $jq('#bfElementLabel').val();
			mdata.maxLength = $jq('#bfElementTypeTextMaxLength').val();
			mdata.hint = $jq('#bfElementTypeTextHint').val();
			mdata.password = $jq('#bfElementAdvancedPassword').attr('checked');
			mdata.readonly = $jq('#bfElementAdvancedReadOnly').attr('checked');
			mdata.mailback = $jq('#bfElementAdvancedMailback').attr('checked');
			mdata.mailbackAsSender = $jq('#bfElementAdvancedMailbackAsSender').attr('checked');
			mdata.mailbackfile = $jq('#bfElementAdvancedMailbackfile').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.hideLabel = $jq('#bfElementAdvancedHideLabel').attr('checked');
			mdata.size = $jq('#bfElementTypeTextSize').val();
			mdata.orderNumber = $jq('#bfElementOrderNumber').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			item.properties = mdata;
		};
		
		this.populateTextProperties = function(mdata){
			$jq('#bfElementTypeTextValue').val(mdata.value);
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementTypeTextMaxLength').val(mdata.maxLength);
			$jq('#bfElementTypeTextHint').val(mdata.hint);
			$jq('#bfElementAdvancedPassword').attr('checked', mdata.password);
			$jq('#bfElementAdvancedReadOnly').attr('checked', mdata.readonly);
			$jq('#bfElementAdvancedMailback').attr('checked', mdata.mailback);
			$jq('#bfElementAdvancedMailbackAsSender').attr('checked', mdata.mailbackAsSender);
			$jq('#bfElementAdvancedMailbackfile').val(mdata.mailbackfile);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementTypeTextSize').val(mdata.size);
			$jq('#bfElementOrderNumber').val(mdata.orderNumber);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};
		
		// TEXTAREA
		this.saveTextareaProperties = function(mdata, item){
			mdata.value = $jq('#bfElementTypeTextareaValue').val();
			mdata.bfName = $jq('#bfElementName').val();
			mdata.logging = $jq('#bfElementTextareaAdvancedLogging').attr('checked');
			mdata.label = $jq('#bfElementLabel').val();
			mdata.hint = $jq('#bfElementTypeTextareaHint').val();
			mdata.width = $jq('#bfElementTypeTextareaWidth').val();
			mdata.height = $jq('#bfElementTypeTextareaHeight').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.hideLabel = $jq('#bfElementTextareaAdvancedHideLabel').attr('checked');
			mdata.orderNumber = $jq('#bfElementTextareaAdvancedOrderNumber').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			item.properties = mdata;
		};
		
		this.populateTextareaProperties = function(mdata){
			$jq('#bfElementTypeTextareaValue').val(mdata.value);
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementTextareaAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementTypeTextareaHint').val(mdata.hint);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementTextareaAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementTypeTextareaWidth').val(mdata.width);
			$jq('#bfElementTypeTextareaHeight').val(mdata.height);
			$jq('#bfElementTextareaAdvancedOrderNumber').val(mdata.orderNumber);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};
		
		// RADIOS
		this.saveRadioGroupProperties = function(mdata, item){
			// dynamic properties
			mdata.group = $jq('#bfElementTypeRadioGroupGroups').val();
			mdata.readonly = $jq('#bfElementTypeRadioGroupReadonly').attr('checked');
			mdata.wrap = $jq('#bfElementTypeRadioGroupWrap').attr('checked');
			mdata.hint = $jq('#bfElementTypeRadioGroupHint').val();
			mdata.hideLabel = $jq('#bfElementRadioGroupAdvancedHideLabel').attr('checked');
			mdata.logging = $jq('#bfElementRadioGroupAdvancedLogging').attr('checked');
			mdata.orderNumber = $jq('#bfElementRadioGroupAdvancedOrderNumber').val();
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			
			item.properties = mdata;
		};
		
		this.populateRadioGroupProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeRadioGroupGroups').val(mdata.group);
			$jq('#bfElementTypeRadioGroupReadonly').attr('checked', mdata.readonly);
			$jq('#bfElementTypeRadioGroupWrap').attr('checked', mdata.wrap);
			$jq('#bfElementTypeRadioGroupHint').val(mdata.hint);
			$jq('#bfElementRadioGroupAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementRadioGroupAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementRadioGroupAdvancedOrderNumber').val(mdata.orderNumber);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};
		
		// Checkboxgroup
		this.saveCheckboxGroupProperties = function(mdata, item){
			// dynamic properties
			mdata.group = $jq('#bfElementTypeCheckboxGroupGroups').val();
			mdata.readonly = $jq('#bfElementTypeCheckboxGroupReadonly').attr('checked');
			mdata.wrap = $jq('#bfElementTypeCheckboxGroupWrap').attr('checked');
			mdata.hint = $jq('#bfElementTypeCheckboxGroupHint').val();
			mdata.hideLabel = $jq('#bfElementCheckboxGroupAdvancedHideLabel').attr('checked');
			mdata.logging = $jq('#bfElementCheckboxGroupAdvancedLogging').attr('checked');
			mdata.orderNumber = $jq('#bfElementCheckboxGroupAdvancedOrderNumber').val();
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			
			item.properties = mdata;
		};
		
		this.populateCheckboxGroupProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeCheckboxGroupGroups').val(mdata.group);
			$jq('#bfElementTypeCheckboxGroupReadonly').attr('checked', mdata.readonly);
			$jq('#bfElementTypeCheckboxGroupWrap').attr('checked', mdata.wrap);
			$jq('#bfElementTypeCheckboxGroupHint').val(mdata.hint);
			$jq('#bfElementCheckboxGroupAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementCheckboxGroupAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementCheckboxGroupAdvancedOrderNumber').val(mdata.orderNumber);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};
		
		// Checkbox
		this.saveCheckboxProperties = function(mdata, item){
			// dynamic properties
			mdata.value = $jq('#bfElementTypeCheckboxValue').val();
			mdata.checked = $jq('#bfElementTypeCheckboxChecked').attr('checked');
			mdata.readonly = $jq('#bfElementTypeCheckboxReadonly').attr('checked');
			mdata.mailbackAccept = $jq('#bfElementCheckboxAdvancedMailbackAccept').attr('checked');
			mdata.mailbackConnectWith = $jq('#bfElementCheckboxAdvancedMailbackConnectWith').val();
			mdata.hint = $jq('#bfElementTypeCheckboxHint').val();
			mdata.hideLabel = $jq('#bfElementCheckboxAdvancedHideLabel').attr('checked');
			mdata.logging = $jq('#bfElementCheckboxAdvancedLogging').attr('checked');
			mdata.orderNumber = $jq('#bfElementCheckboxAdvancedOrderNumber').val();
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			
			item.properties = mdata;
		};
		
		this.populateCheckboxProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeCheckboxValue').val(mdata.value);
			$jq('#bfElementTypeCheckboxChecked').attr('checked', mdata.checked);
			$jq('#bfElementCheckboxAdvancedMailbackAccept').attr('checked', mdata.mailbackAccept);
			$jq('#bfElementCheckboxAdvancedMailbackConnectWith').val(mdata.mailbackConnectWith);
			$jq('#bfElementTypeCheckboxReadonly').attr('checked', mdata.readonly);
			$jq('#bfElementTypeCheckboxHint').val(mdata.hint);
			$jq('#bfElementCheckboxAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementCheckboxAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementCheckboxAdvancedOrderNumber').val(mdata.orderNumber);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};
		
		// Select
		this.saveSelectProperties = function(mdata, item){
			// dynamic properties
			mdata.list = $jq('#bfElementTypeSelectList').val();
			mdata.readonly = $jq('#bfElementTypeSelectReadonly').attr('checked');
			mdata.multiple = $jq('#bfElementTypeSelectMultiple').attr('checked');
			mdata.mailback = $jq('#bfElementSelectAdvancedMailback').attr('checked');
			mdata.hint = $jq('#bfElementTypeSelectHint').val();
			mdata.hideLabel = $jq('#bfElementSelectAdvancedHideLabel').attr('checked');
			mdata.logging = $jq('#bfElementSelectAdvancedLogging').attr('checked');
			mdata.orderNumber = $jq('#bfElementSelectAdvancedOrderNumber').val();
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			
			item.properties = mdata;
		};
		
		this.populateSelectProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeSelectList').val(mdata.list);
			$jq('#bfElementTypeSelectReadonly').attr('checked', mdata.readonly);
			$jq('#bfElementTypeSelectMultiple').attr('checked', mdata.multiple);
			$jq('#bfElementSelectAdvancedMailback').attr('checked', mdata.mailback);
			$jq('#bfElementTypeSelectHint').val(mdata.hint);
			$jq('#bfElementSelectAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementSelectAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementSelectAdvancedOrderNumber').val(mdata.orderNumber);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};	
		
		// File
		this.saveFileProperties = function(mdata, item){
			// dynamic properties
			mdata.uploadDirectory = $jq('#bfElementFileAdvancedUploadDirectory').val();
			mdata.timestamp = $jq('#bfElementFileAdvancedTimestamp').attr('checked');
			mdata.allowedFileExtensions = $jq('#bfElementFileAdvancedAllowedFileExtensions').val();
			mdata.attachToUserMail = $jq('#bfElementFileAdvancedAttachToUserMail').attr('checked');
			mdata.attachToAdminMail = $jq('#bfElementFileAdvancedAttachToAdminMail').attr('checked');
			
			mdata.readonly = $jq('#bfElementTypeFileReadonly').attr('checked');
			mdata.hint = $jq('#bfElementTypeFileHint').val();
			mdata.hideLabel = $jq('#bfElementFileAdvancedHideLabel').attr('checked');
			mdata.logging = $jq('#bfElementFileAdvancedLogging').attr('checked');
			mdata.orderNumber = $jq('#bfElementFileAdvancedOrderNumber').val();
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			
			item.properties = mdata;
		};
		
		this.populateFileProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementFileAdvancedUploadDirectory').val(mdata.uploadDirectory);
			$jq('#bfElementFileAdvancedTimestamp').attr('checked', mdata.timestamp);
			$jq('#bfElementFileAdvancedAllowedFileExtensions').val(mdata.allowedFileExtensions);
			$jq('#bfElementFileAdvancedAttachToUserMail').attr('checked', mdata.attachToUserMail);
			$jq('#bfElementFileAdvancedAttachToAdminMail').attr('checked', mdata.attachToAdminMail);
			
			$jq('#bfElementTypeFileReadonly').attr('checked', mdata.readonly);
			$jq('#bfElementTypeFileHint').val(mdata.hint);
			$jq('#bfElementFileAdvancedHideLabel').attr('checked', mdata.hideLabel);
			$jq('#bfElementFileAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementFileAdvancedOrderNumber').val(mdata.orderNumber);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};

		// SUBMIT BUTTON
		this.saveSubmitButtonProperties = function(mdata, item){
			// dynamic properties
			mdata.src = $jq('#bfElementSubmitButtonAdvancedSrc').val();
			mdata.value = $jq('#bfElementTypeSubmitButtonValue').val();
			mdata.hint = $jq('#bfElementTypeSubmitButtonHint').val();
			mdata.hideLabel = $jq('#bfElementSubmitButtonAdvancedHideLabel').attr('checked');
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			
			item.properties = mdata;
		};
		
		this.populateSubmitButtonProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementSubmitButtonAdvancedSrc').val(mdata.src);
			$jq('#bfElementTypeSubmitButtonValue').val(mdata.value);
			$jq('#bfElementTypeSubmitButtonHint').val(mdata.hint);
			$jq('#bfElementSubmitButtonAdvancedHideLabel').attr('checked', mdata.hideLabel);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
		};
			
		// CAPTCHA
		this.saveCaptchaProperties = function(mdata, item){
			// dynamic properties
			mdata.hint = $jq('#bfElementTypeCaptchaHint').val();
			mdata.hideLabel = $jq('#bfElementCaptchaAdvancedHideLabel').attr('checked');
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			
			item.properties = mdata;
		};
		
		this.populateCaptchaProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeCaptchaHint').val(mdata.hint);
			$jq('#bfElementCaptchaAdvancedHideLabel').attr('checked', mdata.hideLabel);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
		};
		
		// CALENDAR
		this.saveCalendarProperties = function(mdata, item){
			// dynamic properties
			mdata.format = $jq('#bfElementTypeCalendarFormat').val();
			mdata.value = $jq('#bfElementTypeCalendarValue').val();
			mdata.size = $jq('#bfElementTypeCalendarSize').val();
			mdata.hint = $jq('#bfElementTypeCalendarHint').val();
			mdata.hideLabel = $jq('#bfElementCalendarAdvancedHideLabel').attr('checked');
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			mdata.required = $jq('#bfElementValidationRequired').attr('checked');
			
			item.properties = mdata;
		};
		
		this.populateCalendarProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeCalendarFormat').val(mdata.format);
			$jq('#bfElementTypeCalendarValue').val(mdata.value);
			$jq('#bfElementTypeCalendarSize').val(mdata.size);
			$jq('#bfElementTypeCalendarHint').val(mdata.hint);
			$jq('#bfElementCalendarAdvancedHideLabel').attr('checked', mdata.hideLabel);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
			$jq('#bfElementValidationRequired').attr('checked', mdata.required);
		};
			
		// Hidden
		this.saveHiddenProperties = function(mdata, item){
			// dynamic properties
			mdata.value = $jq('#bfElementTypeHiddenValue').val();
			mdata.logging = $jq('#bfElementHiddenAdvancedLogging').attr('checked');
			mdata.orderNumber = $jq('#bfElementHiddenAdvancedOrderNumber').val();
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			
			item.properties = mdata;
		};
		
		this.populateHiddenProperties = function(mdata){
			// dynamic properties
			$jq('#bfElementTypeHiddenValue').val(mdata.value);
			$jq('#bfElementHiddenAdvancedLogging').attr('checked', mdata.logging);
			$jq('#bfElementHiddenAdvancedOrderNumber').val(mdata.orderNumber);
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
		};
		
		// PAYPAL BUTTON
		this.savePayPalProperties = function(mdata, item){
			// dynamic properties
			
			// DEFAULT
			
			// account
			mdata.business = $jq('#bfElementTypePayPalBusiness').val();
			mdata.token = $jq('#bfElementTypePayPalToken').val();
			
			mdata.itemname = $jq('#bfElementTypePayPalItemname').val();
			mdata.itemnumber = $jq('#bfElementTypePayPalItemnumber').val();
			mdata.amount = $jq('#bfElementTypePayPalAmount').val();
			mdata.tax = $jq('#bfElementTypePayPalTax').val();
			mdata.thankYouPage = $jq('#bfElementTypePayPalThankYouPage').val();
			mdata.locale = $jq('#bfElementTypePayPalLocale').val();
			mdata.currencyCode = $jq('#bfElementTypePayPalCurrencyCode').val();
			
			// ADVANCED
			
			mdata.image = $jq('#bfElementPayPalAdvancedImage').val();
			
			// testaccount
			mdata.testaccount = $jq('#bfElementPayPalAdvancedTestaccount').attr('checked');
			mdata.testBusiness = $jq('#bfElementPayPalAdvancedTestBusiness').val();
			mdata.testToken = $jq('#bfElementPayPalAdvancedTestToken').val();
			
			// file
			mdata.downloadableFile = $jq('#bfElementPayPalAdvancedDownloadableFile').attr('checked');
			mdata.filepath = $jq('#bfElementPayPalAdvancedFilepath').val();
			mdata.downloadTries = $jq('#bfElementPayPalAdvancedDownloadTries').val();
			
			// OTHER ADVANCED
			mdata.hint = $jq('#bfElementTypePayPalHint').val();
			mdata.hideLabel = $jq('#bfElementPayPalAdvancedHideLabel').attr('checked');
			
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			
			item.properties = mdata;
		};
		
		this.populatePayPalProperties = function(mdata){
			// dynamic properties
			
			// DEFAULT
			
			// account
			$jq('#bfElementTypePayPalBusiness').val(mdata.business);
			$jq('#bfElementTypePayPalToken').val(mdata.token);
			
			$jq('#bfElementTypePayPalItemname').val(mdata.itemname);
			$jq('#bfElementTypePayPalItemnumber').val(mdata.itemnumber);
			$jq('#bfElementTypePayPalAmount').val(mdata.amount);
			$jq('#bfElementTypePayPalTax').val(mdata.tax);
			$jq('#bfElementTypePayPalThankYouPage').val(mdata.thankYouPage);
			$jq('#bfElementTypePayPalLocale').val(mdata.locale);
			$jq('#bfElementTypePayPalCurrencyCode').val(mdata.currencyCode);
			
			// ADVANCED
			
			$jq('#bfElementPayPalAdvancedImage').val(mdata.image);
			
			// testaccount
			$jq('#bfElementPayPalAdvancedTestaccount').attr('checked', mdata.testaccount);
			$jq('#bfElementPayPalAdvancedTestBusiness').val(mdata.testBusiness);
			$jq('#bfElementPayPalAdvancedTestToken').val(mdata.testToken);
			
			// file
			$jq('#bfElementPayPalAdvancedDownloadableFile').attr('checked', mdata.downloadableFile);
			$jq('#bfElementPayPalAdvancedFilepath').val(mdata.filepath);
			$jq('#bfElementPayPalAdvancedDownloadTries').val(mdata.downloadTries);
			
			// OTHER ADVANCED
			$jq('#bfElementTypePayPalHint').val(mdata.hint);
			$jq('#bfElementPayPalAdvancedHideLabel').attr('checked', mdata.hideLabel);
			
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
		};
		
		// SOFORTUEBERWEISUNG BUTTON
		this.saveSofortueberweisungProperties = function(mdata, item){
			// dynamic properties
			
			// DEFAULT

			// account
			mdata.user_id = $jq('#bfElementTypeSofortueberweisungUserId').val();
			mdata.project_id = $jq('#bfElementTypeSofortueberweisungProjectId').val();
			mdata.project_password = $jq('#bfElementTypeSofortueberweisungProjectPassword').val();
			
			mdata.reason_1 = $jq('#bfElementTypeSofortueberweisungReason1').val();
			mdata.reason_2 = $jq('#bfElementTypeSofortueberweisungReason2').val();
			mdata.amount = $jq('#bfElementTypeSofortueberweisungAmount').val();
			mdata.thankYouPage = $jq('#bfElementTypeSofortueberweisungThankYouPage').val();
			mdata.language_id = $jq('#bfElementTypeSofortueberweisungLanguageId').val();
			mdata.currency_id = $jq('#bfElementTypeSofortueberweisungCurrencyId').val();
			mdata.mailback = $jq('#bfElementTypeSofortueberweisungMailback').attr('checked');
			
			// ADVANCED
			
			mdata.image = $jq('#bfElementSofortueberweisungAdvancedImage').val();
			
			// file
			mdata.downloadableFile = $jq('#bfElementSofortueberweisungAdvancedDownloadableFile').attr('checked');
			mdata.filepath = $jq('#bfElementSofortueberweisungAdvancedFilepath').val();
			mdata.downloadTries = $jq('#bfElementSofortueberweisungAdvancedDownloadTries').val();
			
			// OTHER ADVANCED
			mdata.hint = $jq('#bfElementTypeSofortueberweisungHint').val();
			mdata.hideLabel = $jq('#bfElementSofortueberweisungAdvancedHideLabel').attr('checked');
			
			// static properties
			mdata.bfName = $jq('#bfElementName').val();
			mdata.label = $jq('#bfElementLabel').val();
			mdata.labelPosition = $jq('#bfElementAdvancedLabelPosition').val();
			mdata.tabIndex = $jq('#bfElementAdvancedTabIndex').val();
			
			item.properties = mdata;
		};
		
		this.populateSofortueberweisungProperties = function(mdata){
			// dynamic properties
			
			// DEFAULT
			
			// account
			$jq('#bfElementTypeSofortueberweisungUserId').val(mdata.user_id);
			$jq('#bfElementTypeSofortueberweisungProjectId').val(mdata.project_id);
			$jq('#bfElementTypeSofortueberweisungProjectPassword').val(mdata.project_password);
			
			$jq('#bfElementTypeSofortueberweisungReason1').val(mdata.reason_1);
			$jq('#bfElementTypeSofortueberweisungReason2').val(mdata.reason_2);
			$jq('#bfElementTypeSofortueberweisungAmount').val(mdata.amount);
			$jq('#bfElementTypeSofortueberweisungThankYouPage').val(mdata.thankYouPage);
			$jq('#bfElementTypeSofortueberweisungLanguageId').val(mdata.language_id);
			$jq('#bfElementTypeSofortueberweisungCurrencyId').val(mdata.currency_id);
			$jq('#bfElementTypeSofortueberweisungMailback').attr('checked', mdata.mailback);
			
			// ADVANCED
			
			$jq('#bfElementSofortueberweisungAdvancedImage').val(mdata.image);
			
			// file
			$jq('#bfElementSofortueberweisungAdvancedDownloadableFile').attr('checked', mdata.downloadableFile);
			$jq('#bfElementSofortueberweisungAdvancedFilepath').val(mdata.filepath);
			$jq('#bfElementSofortueberweisungAdvancedDownloadTries').val(mdata.downloadTries);
			
			// OTHER ADVANCED
			$jq('#bfElementTypeSofortueberweisungHint').val(mdata.hint);
			$jq('#bfElementSofortueberweisungAdvancedHideLabel').attr('checked', mdata.hideLabel);
			
			// static properties
			$jq('#bfElementName').val(mdata.bfName);
			$jq('#bfElementLabel').val(mdata.label);
			$jq('#bfElementAdvancedTabIndex').val(mdata.tabIndex);
			$jq('#bfElementAdvancedLabelPosition').val(mdata.labelPosition);
		};
			
		this.saveSelectedElementProperties = function(){
			if(appScope.selectedTreeElement){
				var mdata = appScope.getProperties(appScope.selectedTreeElement);
				if(mdata){
					var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
					if(item){
						switch(mdata.bfType){
							case 'bfHidden':
								appScope.saveHiddenProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
							break;
							case 'bfTextfield':
								appScope.saveTextProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfTextarea':
								appScope.saveTextareaProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfRadioGroup':
								appScope.saveRadioGroupProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfSubmitButton':
								appScope.saveSubmitButtonProperties(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfPayPal':
								appScope.savePayPalProperties(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfSofortueberweisung':
								appScope.saveSofortueberweisungProperties(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfCaptcha':
								appScope.saveCaptchaProperties(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfCalendar':
								appScope.saveCalendarProperties(mdata, item);
								appScope.saveValidation(mdata, item);
							break;
							case 'bfCheckboxGroup':
								appScope.saveCheckboxGroupProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfCheckbox':
								appScope.saveCheckboxProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfSelect':
								appScope.saveSelectProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
							case 'bfFile':
								appScope.saveFileProperties(mdata, item);
								appScope.saveValidation(mdata, item);
								appScope.saveInit(mdata, item);
								appScope.saveAction(mdata, item);
							break;
						}
					}
				}
			}
		};
		
		this.saveValidation = function(mdata, item){
			mdata.validationId = $jq('#bfValidationScriptSelection').val();
			mdata.validationCode = $jq('#bfValidationCode').val();
			mdata.validationMessage = $jq('#bfValidationMessage').val();
				
			if($jq('#bfValidationTypeLibrary').get(0).checked){
				mdata.validationCondition = 1;
				for(var i = 0; i < appScope.elementScripts.validation.length;i++){
					if(appScope.elementScripts.validation[i].id == $jq('#bfValidationScriptSelection').val()){
						mdata.validationFunctionName = appScope.elementScripts.validation[i].name;
						break;
					}
				}
				
			} else if($jq('#bfValidationTypeCustom').get(0).checked){
				mdata.validationCondition = 2;
				mdata.validationFunctionName = 'ff_' + mdata.bfName + '_validation';
			} else {
				mdata.validationCondition = 0;
			}
			item.properties = mdata;
		};
		
		this.saveInit = function(mdata, item){
			if($jq('#bfInitFormEntry').get(0).checked){
				mdata.initFormEntry = 1;
			} else {
				mdata.initFormEntry = 0;
			}
				
			if($jq('#bfInitPageEntry').get(0).checked){
				mdata.initPageEntry = 1;
			} else {
				mdata.initPageEntry = 0;
			}
				
			mdata.initId = $jq('#bfInitScriptSelection').val();
			mdata.initCode = $jq('#bfInitCode').val();
				
			if($jq('#bfInitTypeLibrary').get(0).checked){
				mdata.initCondition = 1;
				for(var i = 0; i < appScope.elementScripts.init.length;i++){
					if(appScope.elementScripts.init[i].id == $jq('#bfInitScriptSelection').val()){
						mdata.initScript = appScope.elementScripts.init[i].name;
						break;
					}
				}
				
			} else if($jq('#bfInitTypeCustom').get(0).checked){
				mdata.initCondition = 2;
				mdata.initFunctionName = 'ff_' + mdata.bfName + '_init';
			} else {
				mdata.initCondition = 0;
			}
			item.properties = mdata;
		};
		
		this.saveAction = function(mdata, item){
				
				if($jq('#bfActionClick').get(0).checked){
					mdata.actionClick = 1;
				} else {
					mdata.actionClick = 0;
				}
				
				if($jq('#bfActionBlur').get(0).checked){
					mdata.actionBlur = 1;
				} else {
					mdata.actionBlur = 0;
				}
				
				if($jq('#bfActionChange').get(0).checked){
					mdata.actionChange = 1;
				} else {
					mdata.actionChange = 0;
				}
				
				if($jq('#bfActionFocus').get(0).checked){
					mdata.actionFocus = 1;
				} else {
					mdata.actionFocus = 0;
				}
				
				if($jq('#bfActionSelect').get(0).checked){
					mdata.actionSelect = 1;
				} else {
					mdata.actionSelect = 0;
				}
				
				mdata.actionId = $jq('#bfActionsScriptSelection').val();
				mdata.actionCode = $jq('#bfActionCode').val();
				
				if($jq('#bfActionTypeLibrary').get(0).checked){
					mdata.actionCondition = 1;
					for(var i = 0; i < appScope.elementScripts.action.length;i++){
						if(appScope.elementScripts.action[i].id == $jq('#bfActionsScriptSelection').val()){
							mdata.actionFunctionName = appScope.elementScripts.action[i].name;
							break;
						}
					}
				} else if($jq('#bfActionTypeCustom').get(0).checked){
					mdata.actionCondition = 2;
					mdata.actionFunctionName = 'ff_' + mdata.bfName + '_action';
				} else {
					mdata.actionCondition = 0;
				}
				
				item.properties = mdata;
		};
		
		this.populateSelectedElementProperties = function(){
			if(appScope.selectedTreeElement){
				var mdata = appScope.getProperties(appScope.selectedTreeElement);
				
				if(mdata){
					var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
					if(item){
						item.data.title = mdata.label;
						$jq('#bfValidationScript').css('display','none');
						$jq('#bfInitScript').css('display','none');
						$jq('#bfActionScript').css('display','none');
						
						$jq('#bfElementTypeText').css('display','none');
						$jq('#bfElementTypeTextarea').css('display','none');
						$jq('#bfElementTypeRadioGroup').css('display','none');
						$jq('#bfElementTypeSubmitButton').css('display','none');
						$jq('#bfElementTypePayPal').css('display','none');
						$jq('#bfElementTypeSofortueberweisung').css('display','none');
						$jq('#bfElementTypeCaptcha').css('display','none');
						$jq('#bfElementTypeCalendar').css('display','none');
						$jq('#bfElementTypeCheckboxGroup').css('display','none');
						$jq('#bfElementTypeCheckbox').css('display','none');
						$jq('#bfElementTypeSelect').css('display','none');
						$jq('#bfElementTypeFile').css('display','none');
						$jq('#bfElementTypeHidden').css('display','none');
						
						$jq('#bfElementTypeTextAdvanced').css('display','none');
						$jq('#bfElementTypeTextareaAdvanced').css('display','none');
						$jq('#bfElementTypeRadioGroupAdvanced').css('display','none');
						$jq('#bfElementTypeSubmitButtonAdvanced').css('display','none');
						$jq('#bfElementTypePayPalAdvanced').css('display','none');
						$jq('#bfElementTypeSofortueberweisungAdvanced').css('display','none');
						$jq('#bfElementTypeCaptchaAdvanced').css('display','none');
						$jq('#bfElementTypeCalendarAdvanced').css('display','none');
						$jq('#bfElementTypeCheckboxGroupAdvanced').css('display','none');
						$jq('#bfElementTypeCheckboxAdvanced').css('display','none');
						$jq('#bfElementTypeSelectAdvanced').css('display','none');
						$jq('#bfElementTypeFileAdvanced').css('display','none');
						$jq('#bfElementTypeHiddenAdvanced').css('display','none');
						$jq('#bfElementValidationRequiredSet').css('display','none');
						
						$jq('#bfAdvancedLeaf').css('display','');
						
						switch(mdata.bfType){
							case 'bfHidden':
								$jq('#bfElementType').val('bfElementTypeHidden');
								$jq('#bfAdvancedLeaf').css('display','none');
								appScope.populateHiddenProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
							break;
							case 'bfTextfield':
								$jq('#bfElementType').val('bfElementTypeText');
								appScope.populateTextProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
							case 'bfTextarea':
								$jq('#bfElementType').val('bfElementTypeTextarea');
								appScope.populateTextareaProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
							case 'bfRadioGroup':
								$jq('#bfElementType').val('bfElementTypeRadioGroup');
								appScope.populateRadioGroupProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
							case 'bfSubmitButton':
								$jq('#bfElementType').val('bfElementTypeSubmitButton');
								appScope.populateSubmitButtonProperties(mdata);
								appScope.populateElementActionScript();
							break;
							case 'bfPayPal':
								$jq('#bfElementType').val('bfElementTypePayPal');
								appScope.populatePayPalProperties(mdata);
								appScope.populateElementActionScript();
							break;
							case 'bfSofortueberweisung':
								$jq('#bfElementType').val('bfElementTypeSofortueberweisung');
								appScope.populateSofortueberweisungProperties(mdata);
								appScope.populateElementActionScript();
							break;
							case 'bfCaptcha':
								$jq('#bfElementType').val('bfElementTypeCaptcha');
								appScope.populateCaptchaProperties(mdata);
							break;
							case 'bfCalendar':
								$jq('#bfElementType').val('bfElementTypeCalendar');
								appScope.populateCalendarProperties(mdata);
								appScope.populateElementValidationScript();
							break;
							case 'bfCheckboxGroup':
								$jq('#bfElementType').val('bfElementTypeCheckboxGroup');
								appScope.populateCheckboxGroupProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
							case 'bfCheckbox':
								$jq('#bfElementType').val('bfElementTypeCheckbox');
								appScope.populateCheckboxProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
							case 'bfSelect':
								$jq('#bfElementType').val('bfElementTypeSelect');
								appScope.populateSelectProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
							case 'bfFile':
								$jq('#bfElementType').val('bfElementTypeFile');
								appScope.populateFileProperties(mdata);
								appScope.populateElementValidationScript();
								appScope.populateElementInitScript();
								appScope.populateElementActionScript();
							break;
						}
						
						if($jq('#bfElementType').val() != ''){
							$jq('#bfElementTypeClass').css('display','none');
							$jq('#'+$jq('#bfElementType').val()).css('display','');
							$jq('#'+$jq('#bfElementType').val()+"Advanced").css('display','');
							if(mdata.bfType != 'bfHidden'){
								$jq('#bfElementValidationRequiredSet').css('display','');
							}
						}
					}
				}
			}
		};
		
		this.populateElementValidationScript = function(){
			
			var mdata = appScope.getProperties(appScope.selectedTreeElement);
			if(mdata){
			
				$jq('#bfValidationScript').css('display','');
	
				$jq('#bfValidationScriptSelection').empty();
				for(var i = 0; i < appScope.elementScripts.validation.length;i++){
					var option = document.createElement('option');
					$jq(option).val(appScope.elementScripts.validation[i].id);
					$jq(option).text(appScope.elementScripts.validation[i].package + '::' + appScope.elementScripts.validation[i].name); 
					if(appScope.elementScripts.validation[i].id == mdata.validationId){
						$jq(option).get(0).setAttribute('selected', true);
					}
					$jq('#bfValidationScriptSelection').append(option);
				}
				
				$jq('#bfValidationMessage').val(mdata.validationMessage);
				$jq('#bfValidationCode').val(mdata.validationCode);
				
				switch(mdata.validationCondition){
					case 1:
						$jq('.bfValidationType').attr('checked','');
						$jq('#bfValidationTypeLibrary').attr('checked',true);
						$jq('#bfValidationScriptLibrary').css('display','');
						$jq('#bfValidationScriptCustom').css('display','none');
						$jq('#bfValidationScriptFlags').css('display','');
						$jq('#bfValidationScriptLibrary').css('display','');
						$jq('#bfValidationScriptCustom').css('display','none');
						appScope.setValidationScriptDescription();
						break;
					case 2:
						$jq('.bfValidationType').attr('checked','');
						$jq('#bfValidationTypeCustom').attr('checked',true);
						$jq('#bfValidationScriptFlags').css('display','');
						$jq('#bfValidationScriptLibrary').css('display','none');
						$jq('#bfValidationScriptCustom').css('display','');
						break;
					default:
						$jq('.bfValidationType').attr('checked','');
						$jq('#bfValidationTypeNone').attr('checked',true);
						$jq('#bfValidationScriptFlags').css('display','none');
						$jq('#bfValidationScriptLibrary').css('display','none');
						$jq('#bfValidationScriptCustom').css('display','none');
				}
			}
			
		};
		
		this.populateElementInitScript = function(){
			
			var mdata = appScope.getProperties(appScope.selectedTreeElement);
			if(mdata){
			
				$jq('#bfInitScript').css('display','');
	
				$jq('#bfInitScriptSelection').empty();
				for(var i = 0; i < appScope.elementScripts.init.length;i++){
					var option = document.createElement('option');
					$jq(option).val(appScope.elementScripts.init[i].id);
					$jq(option).text(appScope.elementScripts.init[i].package + '::' + appScope.elementScripts.init[i].name); 
					if(appScope.elementScripts.init[i].id == mdata.initId){
						$jq(option).get(0).setAttribute('selected', true);
					}
					$jq('#bfInitScriptSelection').append(option);
				}
				
				if(mdata.initFormEntry == 1){
					$jq('#bfInitFormEntry').get(0).checked = true;
				} else {
					$jq('#bfInitFormEntry').get(0).checked = false;
				}
				
				if(mdata.initPageEntry == 1){
					$jq('#bfInitPageEntry').get(0).checked = true;
				} else {
					$jq('#bfInitPageEntry').get(0).checked = false;
				}
				
				$jq('#bfInitCode').val(mdata.initCode);
				
				switch(mdata.initCondition){
					case 1:
						$jq('.bfInitType').attr('checked','');
						$jq('#bfInitTypeLibrary').attr('checked',true);
						$jq('#bfInitScriptLibrary').css('display','');
						$jq('#bfInitScriptCustom').css('display','none');
						$jq('#bfInitScriptFlags').css('display','');
						$jq('#bfInitScriptLibrary').css('display','');
						$jq('#bfInitScriptCustom').css('display','none');
						appScope.setInitScriptDescription();
						break;
					case 2:
						$jq('.bfInitType').attr('checked','');
						$jq('#bfInitTypeCustom').attr('checked',true);
						$jq('#bfInitScriptFlags').css('display','');
						$jq('#bfInitScriptLibrary').css('display','none');
						$jq('#bfInitScriptCustom').css('display','');
						break;
					default:
						$jq('.bfInitType').attr('checked','');
						$jq('#bfInitTypeNone').attr('checked',true);
						$jq('#bfInitScriptFlags').css('display','none');
						$jq('#bfInitScriptLibrary').css('display','none');
						$jq('#bfInitScriptCustom').css('display','none');
				}
			
			}
		};
		
		this.populateElementActionScript = function(){
			
			var mdata = appScope.getProperties(appScope.selectedTreeElement);
			if(mdata){
				
				$jq('#bfActionScript').css('display','');
				
				if(mdata.bfType == 'bfSofortueberweisung' || mdata.bfType == 'bfPayPal' || mdata.bfType == 'bfIcon' || mdata.bfType == 'bfImageButton' || mdata.bfType == 'bfSubmitButton'){
					$jq('.bfAction').css('display','none');
					$jq('.bfActionLabel').css('display','none');
					$jq('#bfActionClick').css('display','');
					$jq('#bfActionClickLabel').css('display','');
				} else {
					$jq('.bfAction').css('display','');
					$jq('.bfActionLabel').css('display','');
				}
				
				$jq('#bfActionsScriptSelection').empty();
				
				for(var i = 0; i < appScope.elementScripts.action.length;i++){
				
					var option = document.createElement('option');
					
					$jq(option).val(appScope.elementScripts.action[i].id);
					$jq(option).text(appScope.elementScripts.action[i].package + '::' + appScope.elementScripts.action[i].name); 
					
					if(appScope.elementScripts.action[i].id == mdata.actionId){
						
						$jq(option).get(0).setAttribute('selected', true);
					}
					
					$jq('#bfActionsScriptSelection').append(option);
				}
				
				if(mdata.actionClick == 1){
					$jq('#bfActionClick').get(0).checked = true;
				} else {
					$jq('#bfActionClick').get(0).checked = false;
				}
				
				if(mdata.actionBlur == 1){
					$jq('#bfActionBlur').get(0).checked = true;
				} else {
					$jq('#bfActionBlur').get(0).checked = false;
				}
				
				if(mdata.actionChange == 1){
					$jq('#bfActionChange').get(0).checked = true;
				} else {
					$jq('#bfActionChange').get(0).checked = false;
				}
				
				if(mdata.actionFocus == 1){
					$jq('#bfActionFocus').get(0).checked = true;
				} else {
					$jq('#bfActionFocus').get(0).checked = false;
				}
				
				if(mdata.actionSelect == 1){
					$jq('#bfActionSelect').get(0).checked = true;
				} else {
					$jq('#bfActionSelect').get(0).checked = false;
				}
				
				$jq('#bfActionCode').val(mdata.actionCode);
				
				switch(mdata.actionCondition){
					case 1:
						$jq('.bfActionType').attr('checked','');
						$jq('#bfActionTypeLibrary').attr('checked',true);
						$jq('#bfActionScriptLibrary').css('display','');
						$jq('#bfActionScriptCustom').css('display','none');
						$jq('#bfActionScriptFlags').css('display','');
						$jq('#bfActionScriptLibrary').css('display','');
						$jq('#bfActionScriptCustom').css('display','none');
						appScope.setActionScriptDescription();
						break;
					case 2:
						$jq('.bfActionType').attr('checked','');
						$jq('#bfActionTypeCustom').attr('checked',true);
						$jq('#bfActionScriptFlags').css('display','');
						$jq('#bfActionScriptLibrary').css('display','none');
						$jq('#bfActionScriptCustom').css('display','');
						break;
					default:
						$jq('.bfActionType').attr('checked','');
						$jq('#bfActionTypeNone').attr('checked',true);
						$jq('#bfActionScriptFlags').css('display','none');
						$jq('#bfActionScriptLibrary').css('display','none');
						$jq('#bfActionScriptCustom').css('display','none');
				}
			
			}
		};
		
		this.createTreeItem = function(obj){
				if(appScope.selectedTreeElement){
					switch(appScope.getNodeClass(appScope.selectedTreeElement)){
						case 'bfQuickModePageClass':
						case 'bfQuickModeSectionClass':
							if(obj.attributes['class'] != 'bfQuickModePageClass'){
								var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
								if(item){
						      		if(item.children){
						      			item.children[item.children.length] = obj;
						      		} else {
						      			alert("<?php echo addslashes(BFText::_('NO_CHILDREN_ERROR')); ?>");
						      		}
								}
							} else {
								alert("<?php echo addslashes(BFText::_('NEW_SECTION_ERROR')); ?>");
							}
						break;
						case 'bfQuickModeRootClass':
							if(obj.attributes['class'] == 'bfQuickModePageClass' && appScope.dataObject && appScope.dataObject.children){
					      		appScope.dataObject.children[appScope.dataObject.children.length] = obj;
							} else {
								alert("<?php echo addslashes(BFText::_('NEW_SECTION_ERROR')); ?>");
							}
						break;
						default: alert("<?php echo addslashes(BFText::_('NEW_SECTION_ERROR')); ?>");
					}
					$jq.tree_reference('bfElementExplorer').refresh();
				}
		};
		
		/**
			Section properties
		*/
		this.saveSectionProperties = function(){
			var mdata = appScope.getProperties(appScope.selectedTreeElement);
			if(mdata){
				var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
				if(item){
					mdata.bfType = $jq('#bfSectionType').val();
					mdata.displayType = $jq('#bfSectionDisplayType').val();
					mdata.title = $jq('#bfSectionTitle').val();

					item.properties = mdata;
					item.data.title = $jq('#bfSectionTitle').val();
				}
			}
		};
		
		this.populateSectionProperties = function(){
			if(appScope.selectedTreeElement){
				var mdata = appScope.getProperties(appScope.selectedTreeElement);
				if(mdata){
					var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
					if(item){
						item.data.title = mdata.title;
						$jq('#bfSectionType').val( mdata.bfType );
						$jq('#bfSectionDisplayType').val( mdata.displayType );
						$jq('#bfSectionTitle').val( mdata.title );
					}	
				}
			}
		};
		
		/**
			Form properties
		*/
		this.saveFormProperties = function(){
			var mdata = appScope.getProperties(appScope.selectedTreeElement);
			if(mdata){
				var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
				if(item){
					mdata.title = $jq('#bfFormTitle').val();
					mdata.name  = $jq('#bfFormName').val();
					mdata.description = $jq('#bfFormDescription').val();
					mdata.mailRecipient = $jq('#bfFormMailRecipient').val();
					mdata.mailNotification = $jq('#bfFormMailNotification').attr('checked'); 
					mdata.submitInclude = $jq('#bfSubmitIncludeYes').attr('checked'); 
					mdata.submitLabel = $jq('#bfFormSubmitLabel').val();
					mdata.cancelInclude = $jq('#bfCancelIncludeYes').attr('checked'); 
					mdata.cancelLabel = $jq('#bfFormCancelLabel').val();
					mdata.pagingInclude = $jq('#bfPagingIncludeYes').attr('checked'); 
					mdata.pagingNextLabel = $jq('#bfFormPagingNextLabel').val();
					mdata.pagingPrevLabel = $jq('#bfFormPagingPrevLabel').val();
					mdata.theme = $jq('#bfTheme').val();
					mdata.fadeIn = $jq('#bfElementAdvancedFadeIn').attr('checked');
					mdata.useErrorAlerts = $jq('#bfElementAdvancedUseErrorAlerts').attr('checked');
					mdata.lastPageThankYou = $jq('#bfFormLastPageThankYou').attr('checked');
					mdata.rollover = $jq('#bfElementAdvancedRollover').attr('checked');
					mdata.rolloverColor = $jq('#bfElementAdvancedRolloverColor').val();
					var pagesSize = $jq('#bfQuickModeRoot').children("ul").children("li").size();
					if(mdata.lastPageThankYou && pagesSize > 1){
						mdata.submittedScriptCondidtion = 2;
						mdata.submittedScriptCode = 'function ff_'+mdata.name+'_submitted(status, message){ff_switchpage('+pagesSize+');}';
					} else {
						mdata.submittedScriptCondidtion = 0;
						mdata.submittedScriptCode = '';
					}
					item.properties = mdata;
				}
			}
		};
		
		this.populateFormProperties = function(){
			if(appScope.selectedTreeElement){
				var mdata = appScope.getProperties(appScope.selectedTreeElement);
				if(mdata){
					// setting the node's data
					var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
					if(item){
						item.data.title = mdata.title;
						$jq('#bfElementAdvancedFadeIn').attr('checked', mdata.fadeIn);
						$jq('#bfFormLastPageThankYou').attr('checked', mdata.lastPageThankYou);
						$jq('#bfElementAdvancedUseErrorAlerts').attr('checked', mdata.useErrorAlerts);
						if(mdata.submitInclude){
							$jq('#bfSubmitIncludeYes').attr('checked', true);
							$jq('#bfSubmitIncludeNo').attr('checked', false);
						}else{
							$jq('#bfSubmitIncludeYes').attr('checked', false);
							$jq('#bfSubmitIncludeNo').attr('checked', true);
						}
						$jq('#bfFormSubmitLabel').val( mdata.submitLabel );
						if(mdata.cancelInclude){
							$jq('#bfCancelIncludeYes').attr('checked', true);
							$jq('#bfCancelIncludeNo').attr('checked', false);
						}else{
							$jq('#bfCancelIncludeYes').attr('checked', false);
							$jq('#bfCancelIncludeNo').attr('checked', true);
						}
						$jq('#bfFormCancelLabel').val( mdata.cancelLabel );
						if(mdata.pagingInclude){
							$jq('#bfPagingIncludeYes').attr('checked', true);
							$jq('#bfPagingIncludeNo').attr('checked', false);
						}else{
							$jq('#bfPagingIncludeYes').attr('checked', false);
							$jq('#bfPagingIncludeNo').attr('checked', true);
						}
						$jq('#bfFormPagingNextLabel').val( mdata.pagingNextLabel );
						$jq('#bfFormPagingPrevLabel').val( mdata.pagingPrevLabel );
						$jq('#bfTheme').val( mdata.theme );
						$jq('#bfElementAdvancedRollover').attr('checked', mdata.rollover);
					 	$jq('#bfElementAdvancedRolloverColor').val(mdata.rolloverColor);
						/*
						$jq('#bfFormTitle').val( mdata.title );
						$jq('#bfFormName').val( mdata.bfName );
						$jq('#bfFormDescription').val( mdata.description );
						$jq('#bfFormMailRecipient').val( mdata.mailRecipient );
						if(mdata.mailNotification){
							$jq('#bfFormMailNotification').attr('checked', true);
						}else{
							$jq('#bfFormMailNotification').attr('checked', false);
						}*/
					}
				}
			}
		};
		
		/**
			Page Properties
		*/
		this.savePageProperties = function(){
			var mdata = appScope.getProperties(appScope.selectedTreeElement);
			if(mdata){
				var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
				if(item){
					item.properties = mdata;
				}
			}
		};
		
		this.populatePageProperties = function(){
			if(appScope.selectedTreeElement){
				var mdata = appScope.getProperties(appScope.selectedTreeElement);
				if(mdata){
					// setting the node's data
					var item = appScope.findDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), appScope.dataObject);
					if(item){
						// no properties yet to set
					}
				}
			}
		};
		
		/**
			Main application
		*/
		this.toggleProperties = function (property){
			$jq('.bfProperties').css('display', 'none');
			$jq('#'+property).css('display', '');
		};
		
		this.toggleAdvanced = function (property){
			$jq('.bfAdvanced').css('display', 'none');
			$jq('#'+property).css('display', '');
		};
		
		$jq('#bfElementExplorer').tree(
			{
			  ui : {
			    theme_name : "apple"
			  },
			  selected : 'bfQuickModeRoot',
			  callback: {
			  	onselect : function(node,obj) {
			  		appScope.selectedTreeElement = node;
			  		$jq('#bfPropertySaveButton').css('display','');
			  		$jq('#bfPropertySaveButtonTop').css('display','');
			  		$jq('#bfAdvancedSaveButton').css('display','');
			  		$jq('#bfAdvancedSaveButtonTop').css('display','');
			  		switch( appScope.getNodeClass(node) ) {
			  			case 'bfQuickModeRootClass':
			  				appScope.toggleProperties('bfFormProperties');
			  				appScope.toggleAdvanced('bfFormAdvanced');
			  				appScope.populateFormProperties();
							break;
				  		case 'bfQuickModeSectionClass':
				  			appScope.toggleProperties('bfSectionProperties');
				  			appScope.toggleAdvanced('bfSectionAdvanced');
				  			appScope.populateSectionProperties();
				  			$jq('#bfAdvancedSaveButton').css('display','none');
				  			$jq('#bfAdvancedSaveButtonTop').css('display','none');
				  			break;
				  		case 'bfQuickModeElementClass':
				  			appScope.toggleProperties('bfElementProperties');
				  			appScope.toggleAdvanced('bfElementAdvanced');
				  			appScope.populateSelectedElementProperties();
				  			break;
				  		case 'bfQuickModePageClass':
				  			appScope.toggleProperties('bfPageProperties');
				  			appScope.toggleAdvanced('bfPageAdvanced');
				  			appScope.populatePageProperties();
				  			$jq('#bfAdvancedSaveButton').css('display','none');
				  			$jq('#bfAdvancedSaveButtonTop').css('display','none');
				  			break;
				  	}
			  	},
			  	onload : function(obj) {
			  		
			  	},
			  	ondelete : function(NODE, TREE_OBJ,RB) {
			  		appScope.selectedTreeElement = null;
			  		appScope.deleteDataObjectItem( $jq(NODE).attr('id'), appScope.dataObject );
			  		var target = appScope.findDataObjectItem( $jq('#bfQuickModeRoot').attr('id'), appScope.dataObject );
					if(target && !target.children){
						target.children = new Array();
					}
					// restoring page numbers
					if(target && target.children){
						if(target.attributes['class'] == 'bfQuickModeRootClass'){
							for(var i = 0; i < target.children.length; i++){
								if(target.children[i].attributes['class'] == 'bfQuickModePageClass'){
									var mdata = appScope.getProperties($jq('#'+target.children[i].attributes.id));
									if(mdata){
										target.children[i].attributes.id = 'bfQuickModePage' + (i+1);
										target.children[i].data.title = "<?php echo addslashes( BFText::_('PAGE') ) ?> " + (i+1);
										target.children[i].properties.pageNumber = i + 1;
									}
								}
							}
							// taking care of last page as thank you page
							var pagesSize = target.children.length;
							if(target.properties.lastPageThankYou && pagesSize > 1){
								target.properties.submittedScriptCondidtion = 2;
								target.properties.submittedScriptCode = 'function ff_'+target.properties.name+'_submitted(status, message){ff_switchpage('+pagesSize+');}';
							} else {
								target.properties.submittedScriptCondidtion = 0;
								target.properties.submittedScriptCode = '';
							}
						}
					}
			  		setTimeout("$jq.tree_reference('bfElementExplorer').refresh()", 10); // give it time to close the context menu 
			  	},
			  	onmove : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB){
			  		var parent = $jq.tree_reference('bfElementExplorer').parent(NODE);
			  		if(!parent){
			  			parent = '#bfQuickModeRoot';
			  		}
			  		children = parent.children("ul").children("li");
				  	if( children && children.length && children.length > 0 ){
				  		for(var i = 0; i < children.length; i++){
				  			if($jq(NODE).attr('id') == children[i].id){
				  				appScope.moveDataObjectItem( $jq(NODE).attr('id'), $jq(parent).attr('id'), i, appScope.dataObject );
				  				break;
				  			}
				  		}
				  	} 
			  		$jq.tree_reference('bfElementExplorer').refresh(); 
			  	}
			  },
			  rules : {
			  	metadata   : 'mdata',
			  	use_inline : true,
			  	deletable : 'none',
			  	creatable : 'none',
			  	renameable : 'none',
			  	draggable : ['section', 'element', 'page'],
			  	dragrules : [ 
			  					'element inside section', 
			  					'section inside section', 
			  					'element inside page', 
			  					'section inside page',
			  					'element after element',
			  					'element before element',
			  					'element after section',
			  					'element before section',
			  					'section after element',
			  					'section before element',
			  					'section after section',
			  					'section before section',
			  					'page before page',
			  					'page after page'
			  				]
			  },
			  data  : {
			    type  : "json",
			    json  : [appScope.dataObject]
			  }
			}
		
		);
		
		this.saveButton = function(){
			
			if(appScope.selectedTreeElement){
				var error = false;
				switch( appScope.getNodeClass(appScope.selectedTreeElement) ) {
			  		case 'bfQuickModeRootClass':
			  			if($jq.trim($jq('#bfFormTitle').val()) == ''){
							alert("<?php echo addslashes(BFText::_('ERROR_ENTER_TITLE')) ?>");
							error = true;
						} 
						if($jq.trim($jq('#bfFormName').val()) == ''){
							alert("<?php echo addslashes(BFText::_('ERROR_ENTER_NAME')) ?>");
							error = true;
						}
						var myRegxp = /^([a-zA-Z0-9_]+)$/;
						if(!myRegxp.test($jq('#bfFormName').val())){
							alert("<?php echo addslashes(BFText::_('ERROR_ENTER_NAME_CHARACTERS')) ?>");
							error = true;
						}
						if(!error) {
			  				appScope.saveFormProperties();
			  			}
					break;
			  		case 'bfQuickModeSectionClass':
			  			appScope.saveSectionProperties();
				  	break;
			  		case 'bfQuickModeElementClass':
						if($jq.trim($jq('#bfElementLabel').val()) == ''){
							alert("<?php echo addslashes(BFText::_('ERROR_ENTER_LABEL')) ?>");
							error = true;
						} 
						if($jq.trim($jq('#bfElementName').val()) == ''){
							alert("<?php echo addslashes(BFText::_('ERROR_ENTER_NAME')) ?>");
							error = true;
						}
						var myRegxp = /^([a-zA-Z0-9_]+)$/;
						if(!myRegxp.test($jq('#bfElementName').val())){
							alert("<?php echo addslashes(BFText::_('ERROR_ENTER_NAME_CHARACTERS')) ?>");
							error = true;
						}
						if(!error) {
			  				appScope.saveSelectedElementProperties();
			  			}
			  		case 'bfQuickModePageClass':
			  			appScope.savePageProperties();
			 		break;
				}
				if(!error){
					// TODO: remove the 2nd refresh if found out why this works only on the 2nd
					$jq.tree_reference('bfElementExplorer').refresh();
					$jq.tree_reference('bfElementExplorer').refresh();
					
					$jq(".bfFadingMessage").html("<?php echo addslashes(BFText::_('SETTINGS_UPDATED')) ?>");
					$jq(".bfFadingMessage").fadeIn(1000);
					setTimeout('$jq(".bfFadingMessage").fadeOut(1000);',1500);
				}
			}
		};
		
		$jq('#bfPropertySaveButton').click(
			appScope.saveButton
		);

		$jq('#bfPropertySaveButtonTop').click(
			appScope.saveButton
		);

		$jq('#bfAdvancedSaveButton').click(
			appScope.saveButton
		);

		$jq('#bfAdvancedSaveButtonTop').click(
			appScope.saveButton
		);

		$jq('#bfNewSectionButton').click(
			function(){
				var id = "bfQuickModeSection" + ( Math.floor(Math.random() * 100000) );
				var obj = {
			      			attributes : {
			      				"class" : 'bfQuickModeSectionClass', 
			      				id : id, 
			      				mdata : $jq.toJSON( { deletable : true, type: 'section' } ) 
			      			},
			      			properties :
			      			{ bfType : 'normal', type: 'section', displayType: 'breaks', title: "untitled section", description: '' }
				      		, 
			      			state: "open", 
			      			data: { title: "untitled section", icon : '<?php echo $iconBase . 'icon_section.png'?>'},
			      			children : []
			      		};
				appScope.createTreeItem(obj);
				$jq.tree_reference('bfElementExplorer').select_branch($jq('#'+id));
			}
		);
		
		$jq('#bfElementType').change(
			function(){
				var obj = null;
				var id = "bfQuickMode" + ( Math.floor(Math.random() * 10000000) );
				var selected = $jq('#bfElementType').val();
				switch(selected){
					case 'bfElementTypeText': obj = appScope.createTextfield(id); break;
					case 'bfElementTypeRadioGroup': obj = appScope.createRadioGroup(id); break;
					case 'bfElementTypeCheckboxGroup': obj = appScope.createCheckboxGroup(id); break;
					case 'bfElementTypeCheckbox': obj = appScope.createCheckbox(id); break;
					case 'bfElementTypeSelect': obj = appScope.createSelect(id); break;
					case 'bfElementTypeTextarea': obj = appScope.createTextarea(id); break;
					case 'bfElementTypeFile': obj = appScope.createFile(id); break;
					case 'bfElementTypeSubmitButton': obj = appScope.createSubmitButton(id); break;
					case 'bfElementTypeHidden': obj = appScope.createHidden(id); break;
					case 'bfElementTypeCaptcha': obj = appScope.createCaptcha(id); break;
					case 'bfElementTypeCalendar': obj = appScope.createCalendar(id); break;
					case 'bfElementTypePayPal': obj = appScope.createPayPal(id); break;
					case 'bfElementTypeSofortueberweisung': obj = appScope.createSofortueberweisung(id); break;
				}
				if(obj){
					appScope.replaceDataObjectItem($jq(appScope.selectedTreeElement).attr('id'), obj, appScope.dataObject);
					$jq.tree_reference('bfElementExplorer').refresh();
					$jq.tree_reference('bfElementExplorer').select_branch($jq('#'+id));
				}
			}
		);
		
		this.setActionScriptDescription = function(){
				for(var i = 0; i < appScope.elementScripts.action.length;i++){
					if($jq('#bfActionsScriptSelection').val() == appScope.elementScripts.action[i].id){
						$jq('#bfActionsScriptSelectionDescription').text(appScope.elementScripts.action[i].description);
					}
				}
		};
		
		$jq('#bfActionsScriptSelection').change(
			function(){
				appScope.setActionScriptDescription();
			}
		);
		
		this.setInitScriptDescription = function(){
				for(var i = 0; i < appScope.elementScripts.init.length;i++){
					if($jq('#bfInitScriptSelection').val() == appScope.elementScripts.init[i].id){
						$jq('#bfInitSelectionDescription').text(appScope.elementScripts.init[i].description);
					}
				}
		};
		
		$jq('#bfInitScriptSelection').change(
			function(){
				appScope.setInitScriptDescription();
			}
		);
		
		this.setValidationScriptDescription = function(){
				for(var i = 0; i < appScope.elementScripts.validation.length;i++){
					if($jq('#bfValidationScriptSelection').val() == appScope.elementScripts.validation[i].id){
						$jq('#bfValidationScriptSelectionDescription').text(appScope.elementScripts.validation[i].description);
					}
				}
		};
		
		$jq('#bfValidationScriptSelection').change(
			function(){
				appScope.setValidationScriptDescription();
			}
		);
		
		$jq('#bfNewElementButton').click(
			function(){
				var id = "bfQuickMode" + ( Math.floor(Math.random() * 10000000) );
				var obj = appScope.createTextfield(id);
				appScope.createTreeItem(obj);
				$jq.tree_reference('bfElementExplorer').select_branch($jq('#'+id));
			}
		);
		
		$jq('#bfNewPageButton').click(
			function(){
				var pageNumber = $jq('#bfQuickModeRoot').children("ul").children("li").size() == 0 ? 1 : $jq('#bfQuickModeRoot').children("ul").children("li").size() + 1;
				var id = "bfQuickModePage" + pageNumber;
				
				// taking care of thank you page if a new page is added
				var item = appScope.findDataObjectItem('bfQuickModeRoot', appScope.dataObject);	
				var pagesSize = $jq('#bfQuickModeRoot').children("ul").children("li").size();
				if(item.properties.lastPageThankYou && pagesSize > 0){
					item.properties.submittedScriptCondidtion = 2;
					item.properties.submittedScriptCode = 'function ff_'+item.properties.name+'_submitted(status, message){ff_switchpage('+(pagesSize+1)+');}';
				} else {
					item.properties.submittedScriptCondidtion = 0;
					item.properties.submittedScriptCode = '';
				}
				
				var obj = {
				  attributes : {
				      	"class" : 'bfQuickModePageClass', 
				      	id : id,
				      	mdata : $jq.toJSON( { deletable : true, type : 'page'  } ) 
				  }, 
				  properties: { type : 'page', pageNumber : pageNumber, pageIntro : '' },
				  state: "open", 
				  data: { title: "<?php echo addslashes( BFText::_('PAGE') ) ?> " + pageNumber, icon: '<?php echo $iconBase . 'icon_page.png'?>'},
			      children : []
				};
				appScope.createTreeItem(obj);
				$jq.tree_reference('bfElementExplorer').select_branch($jq('#'+id));
			}
		);
		
		$jq('#menutab').tabs( { select: function(e, ui){  } } );
	}
	
	$jq(document).ready(function() {
		app = new BF_QuickModeApp();
		var mdata = app.getProperties(app.selectedTreeElement);
		if(mdata){
			var item = app.findDataObjectItem('bfQuickModeRoot', app.dataObject);
			if(item){
				mdata.title = "<?php echo addslashes($formTitle) ?>";
				mdata.name  = "<?php echo addslashes($formName) ?>";
				mdata.description = "<?php echo addslashes($formDesc) ?>";
				mdata.mailRecipient = "<?php echo addslashes($formEmailadr) ?>";
				mdata.mailNotification = "<?php echo addslashes($formEmailntf) == 2 ? true : false ?>"; 
				item.properties = mdata;
			}
		}
	});
	
	function createInitCode()
	{
		var mdata = app.getProperties(app.selectedTreeElement);
		if(mdata){
			form = document.bfForm;
			name = mdata.bfName;
			if (name=='') {
				alert('Please enter the element name first.');
				return;
			} // if
			if (!confirm("<?php echo BFText::_('ELEMENTS_CREAINIT'); ?>\n<?php echo BFText::_('ELEMENTS_EXISTAPP'); ?>")) return;
			code =
				"function ff_"+name+"_init(element, condition)\n"+
				"{\n"+
				"    switch (condition) {\n";
			if (form.bfInitFormEntry.checked)
				code +=
					"        case 'formentry':\n"+
					"            break;\n";
			if (form.bfInitPageEntry.checked)
				code +=
					"        case 'pageentry':\n"+
					"            break;\n";
			code +=
				"        default:;\n"+
				"    } // switch\n"+
				"} // ff_"+name+"_init\n";
			oldcode = form.bfInitCode.value;
			if (oldcode != '')
				form.bfInitCode.value =
					code+
					"\n// -------------- <?php echo BFText::_('ELEMENTS_OLDBELOW'); ?> --------------\n\n"+
					oldcode;
			else
				form.bfInitCode.value = code;
		}
	} // createInitCode
	
	function createValidationCode()
	{
		var mdata = app.getProperties(app.selectedTreeElement);
		if(mdata){
			form = document.bfForm;
			name = mdata.bfName;
			if (name=='') {
				alert('Please enter the element name first.');
				return;
			} // if
			if (!confirm("<?php echo BFText::_('ELEMENTS_CREAVALID'); ?>\n<?php echo BFText::_('ELEMENTS_EXISTAPP'); ?>")) return;
			code =
				"function ff_"+name+"_validation(element, message)\n"+
				"{\n"+
				"    if (element_fails_my_test) {\n"+
				"        if (message=='') message = element.name+\" faild in my test.\\n\"\n"+
				"        ff_validationFocus(element.name);\n"+
				"        return message;\n"+
				"    } // if\n"+
				"    return '';\n"+
				"} // ff_"+name+"_validation\n";
			oldcode = form.bfValidationCode.value;
			if (oldcode != '')
				form.bfValidationCode.value =
					code+
					"\n// -------------- <?php echo BFText::_('ELEMENTS_OLDBELOW'); ?> --------------\n\n"+
					oldcode;
			else
				form.bfValidationCode.value = code;
		}
	} // createValidationCode
	
	function createActionCode(element)
	{
		var mdata = app.getProperties(app.selectedTreeElement);
		if(mdata){
			form = document.bfForm;
			name = mdata.bfName;
			if (name=='') {
				alert('Please enter the element name first.');
				return;
			} // if
			if (!confirm("<?php echo BFText::_('ELEMENTS_CREAACTION'); ?>\n<?php echo BFText::_('ELEMENTS_EXISTAPP'); ?>")) return;
			code =
				"function ff_"+name+"_action(element, action)\n"+
				"{\n"+
				"    switch (action) {\n";
			if (form.bfActionClick)
				if (form.bfActionClick.checked)
					code +=
						"        case 'click':\n"+
						"            break;\n";
			if (form.bfActionBlur)
				if (form.bfActionBlur.checked)
					code +=
						"        case 'blur':\n"+
						"            break;\n";
			if (form.bfActionChange)
				if (form.bfActionChange.checked)
					code +=
						"        case 'change':\n"+
						"            break;\n";
			if (form.bfActionFocus)
				if (form.bfActionFocus.checked)
					code +=
						"        case 'focus':\n"+
						"            break;\n";
			if (form.bfActionSelect)
				if (form.bfActionSelect.checked)
					code +=
						"        case 'select':\n"+
						"            break;\n";
			code +=
				"        default:;\n"+
				"    } // switch\n"+
				"} // ff_"+name+"_action\n";
				
			oldcode = form.bfActionCode.value;
			if (oldcode != '')
				form.bfActionCode.value =
					code+
					"\n// -------------- <?php echo BFText::_('ELEMENTS_OLDBELOW'); ?> --------------\n\n"+
					oldcode;
			else
				form.bfActionCode.value = code;
		}
	} // createActionCode
	
	function submitbutton(pressbutton)
	{
		var form = document.adminForm;
		
		switch (pressbutton) {
			case 'save':
				form.task.value = 'save';
				form.act.value = 'quickmode';
				form.templateCode.value = $jq.base64Encode( $jq.toJSON( app.dataObject ) );
				submitform(pressbutton);
				break;
			case 'preview':
				SqueezeBox.initialize({});               
			         
			    SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
			    		this.initialize();      
			      		var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));      
						this.setOptions(this.presets, options);
						this.assignOptions();
						this.setContent(handler,modalUrl);
			   	};
			         
			    SqueezeBox.loadModal("<?php echo JURI::root()?>index2.php?option=com_facileforms&ff_form=<?php echo $formId ?>&ff_page=1","iframe",820,400);
				break; 
			case 'preview_site':
				SqueezeBox.initialize({});               
			         
			    SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
			    		this.initialize();      
			      		var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));      
						this.setOptions(this.presets, options);
						this.assignOptions();
						this.setContent(handler,modalUrl);
			   	};
			         
			    SqueezeBox.loadModal("<?php echo JURI::root()?>index.php?option=com_facileforms&ff_form=<?php echo $formId ?>&ff_page=1","iframe",820,400);
				break; 
		}
	}
	
	function loadFormSettings(){
		SqueezeBox.initialize({});               
			         
		SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
			this.initialize();      
			var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));      
			this.setOptions(this.presets, options);
			this.assignOptions();
			this.setContent(handler,modalUrl);
		};
			         
		SqueezeBox.loadModal("index3.php?option=com_facileforms&task=editform&act=editpage&form=<?php echo $formId ?>&pkg=QuickModeForms","iframe",820,400);
	}

	function loadEditor(){
		SqueezeBox.initialize({});               
        
		SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
			this.initialize();      
			var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));      
			this.setOptions(this.presets, options);
			this.assignOptions();
			this.setContent(handler,modalUrl);
		};
			         
		SqueezeBox.loadModal("index3.php?option=com_facileforms&act=quickmode_editor","iframe",640,380);
	}
	
	function addslashes( str ) {
    	return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
	}
	
	</script>
	
	<div style="float:left; margin-right: 3px;">
		<?php echo JToolBarHelper::custom('save', 'save.png', 'save_f2.png', BFText::_('TOOLBAR_QUICKMODE_SAVE'), false); ?>
		<?php
			
			if($formId != 0){
				echo JToolBarHelper::custom('preview', 'publish.png', 'save_f2.png', BFText::_('TOOLBAR_QUICKMODE_PREVIEW'), false);
				echo JToolBarHelper::custom('preview_site', 'publish.png', 'save_f2.png', BFText::_('SITE_PREVIEW'), false);
			}
		?>
		<?php echo JToolBarHelper::title('<img src="'. JURI::root() . 'administrator/components/com_facileforms/libraries/jquery/themes/easymode/i/logo-breezingforms.png'.'" />'); ?>
		<form action="index2.php" method="post" name="adminForm">
			<input type="hidden" name="option" value="com_facileforms" />
			<input type="hidden" name="act" value="quickmode" />
			<input type="hidden" name="templateCode" value="" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="form" value="<?php echo $formId;?>" />
		</form>
	</div>
	
	<!-- ####### CSS ######## -->
	<!-- ####### CSS ######## -->
	<!-- ####### CSS ######## -->
	<!-- ####### CSS ######## -->
	
<style tyle="text/css">

#bfQuickModeWrapper {
	width: 100%;
}

#bfQuickModeLeft {
	float: left;
	width: 240px;
}

#bfQuickModeRight {
	padding-left: 250px;
}

#bfElementExplorer {
	width: auto;
	overflow: auto;
}

#bfQuickModeRight #menutab {
	width: 100%;
}

/* ##### hr ##### */

#bfQuickModeWrapper hr {
	color:#ccc;
	background-color:#ccc;
	height:1px;
	border:none;
	margin: 10px 0px 10px 0px;
}

/* ##### inputs ##### */

#bfQuickModeWrapper fieldset {
	padding: 10px;
}

#bfQuickModeWrapper label.bfPropertyLabel {
	float: left;
	width: 20%;
	margin-right: 10px;
}

#bfQuickModeWrapper textarea {
	height: 100px;
}

#bfQuickModeWrapper input[type=text], #bfQuickModeWrapper input[type=password], #bfQuickModeWrapper textarea, #bfQuickModeWrapper select {
    border: 1px solid #bbb;
    padding: 2px;
    line-height: normal;
    background: #f8f8f8;
    font-size: 100%;
    width: 50%;
}

#bfQuickModeWrapper textarea:hover, #bfQuickModeWrapper input[type='text']:hover, #bfQuickModeWrapper input[type='password']:hover, #bfQuickModeWrapper select:hover {
    border-color: #92c1ff;
}

#bfQuickModeWrapper textarea:focus, #bfQuickModeWrapper input[type='text']:focus, #bfQuickModeWrapper input[type='password']:focus, #bfQuickModeWrapper select:focus {
    border-color: #0071bc; outline: 2px solid #92c1ff;
}

#bfQuickModeWrapper input[type='button'], #bfQuickModeWrapper input[type='submit'], #bfQuickModeWrapper input[type='checkbox'], #bfQuickModeWrapper input[type='image'], #bfQuickModeWrapper input[type='radio'], #bfQuickModeWrapper input[type='reset'], #bfQuickModeWrapper select, #bfQuickModeWrapper button {
    cursor: pointer;
}

#bfQuickModeWrapper input[type='hidden'] { display: none; }

.bfClearfix:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}


</style>

	<!-- ####### CSS ######## -->
	<!-- ####### CSS ######## -->
	<!-- ####### CSS ######## -->
	<!-- ####### CSS ######## -->

<div id="bfQuickModeWrapper" class="bfClearfix">
	
	<div id="bfQuickModeLeft" class="bfClearfix">
		
	<div style="float:left">
		<form onsubmit="return false;">
			<input id="bfNewPageButton" type="submit" value="<?php echo BFText::_('NEW_PAGE'); ?>"/>
			<input id="bfNewSectionButton" type="submit" value="<?php echo BFText::_('NEW_SECTION'); ?>"/>
			<input id="bfNewElementButton" type="submit" value="<?php echo BFText::_('NEW_ELEMENT'); ?>"/>
			<span class="bfFadingMessage" style="display:none"></span>
		</form>
	</div>
	<div style="clear:both"></div>
	<br/>
	<div id="bfElementExplorer"></div>
	
	</div> <!-- ##### bfQuickModeLeft end ##### -->
	
	
	<div id="bfQuickModeRight" class="bfClearfix">
		
	<form name="bfForm" onsubmit="return false">
	
	<div id="menutab" class="flora">
            <ul>
                <li><a onclick="$jq('.bfFadingMessage').css('display','none')" href="#fragment-1"><span><div class="tab-items"><?php echo BFText::_('PROPERTIES') ?></div></span></a></li>
                <li><a onclick="$jq('.bfFadingMessage').css('display','none')" href="#fragment-2"><span><div class="tab-element"><?php echo BFText::_('ADVANCED') ?></div></span></a></li>
            </ul>

			<div class="t">

				<div class="t">
					<div class="t"></div>
		 		</div>
	 		</div>

			<div class="m">

	            <div id="fragment-1">
		            <div>
		            	<div class="bfFadingMessage" style="display:none"></div>
		            	<input type="submit" value="<?php echo BFText::_('PROPERTIES_SAVE'); ?>" id="bfPropertySaveButtonTop"/>
		            	<!-- FORM PROPERTIES BEGIN -->
		            	<div class="bfProperties" id="bfFormProperties" style="display:none">
		            		<br/>
		            		<fieldset>
		            			<legend><?php echo BFText::_('FORM_PROPERTIES'); ?></legend>
		            			<label class="bfPropertyLabel" for="bfFormTitle"><?php echo BFText::_('FORM_TITLE'); ?></label>
		            			<input type="text" value="<?php echo htmlentities($formTitle,ENT_QUOTES,'UTF-8') ?>" id="bfFormTitle"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormName"><?php echo BFText::_('FORM_NAME'); ?></label>
		            			<input type="text" value="<?php echo htmlentities($formName,ENT_QUOTES,'UTF-8') ?>" id="bfFormName"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormDescription"><?php echo BFText::_('FORM_DESC'); ?></label>
		            			<textarea id="bfFormDescription"><?php echo htmlentities($formDesc,ENT_QUOTES,'UTF-8') ?></textarea>
		            			<br/>
			            		<br/>
			            		<label class="bfPropertyLabel" for="bfFormLastPageThankYou"><?php echo BFText::_('LAST_PAGE_THANK_YOU'); ?></label>
			            		<input type="checkbox" value="" id="bfFormLastPageThankYou"/>
		            			<hr/>
		            			<label class="bfPropertyLabel" for="bfFormMailNotification"><?php echo BFText::_('MAIL_NOTIFICATION'); ?></label>
		            			<input <?php echo $formEmailntf == 2 ? 'checked="checked"' : '' ?> type="checkbox" value="<?php echo htmlentities($formEmailntf,ENT_QUOTES,'UTF-8') ?>" id="bfFormMailNotification"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormMailRecipient"><?php echo BFText::_('MAIL_RECIPIENT'); ?></label>
		            			<input type="text" value="<?php echo htmlentities($formEmailadr,ENT_QUOTES,'UTF-8') ?>" id="bfFormMailRecipient"/>
		            			<hr/>
		            			<label class="bfPropertyLabel" for="bfSubmitIncludeYes"><?php echo BFText::_('FORM_SUBMIT_INCLUDE'); ?></label>
		            			<?php echo BFText::_('YES'); ?> <input checked="checked" type="radio" name="bfSubmitInclude" value="" id="bfSubmitIncludeYes"/>
		            			<?php echo BFText::_('NO'); ?> <input type="radio" name="bfSubmitInclude" value="" id="bfSubmitIncludeNo"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormSubmitLabel"><?php echo BFText::_('FORM_SUBMIT_LABEL'); ?></label>
		            			<input type="text" value="save" id="bfFormSubmitLabel"/>
		            			<hr/>
		            			<label class="bfPropertyLabel" for="bfPagingIncludeYes"><?php echo BFText::_('FORM_PAGING_INCLUDE'); ?></label>
		            			<?php echo BFText::_('YES'); ?> <input checked="checked" type="radio" name="bfPagingInclude" value="" id="bfPagingIncludeYes"/>
		            			<?php echo BFText::_('NO'); ?> <input type="radio" name="bfPagingInclude" value="" id="bfPagingIncludeNo"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormPagingNextLabel"><?php echo BFText::_('FORM_PAGING_NEXT_LABEL'); ?></label>
		            			<input type="text" value="next" id="bfFormPagingNextLabel"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormPagingPrevLabel"><?php echo BFText::_('FORM_PAGING_PREV_LABEL'); ?></label>
		            			<input type="text" value="back" id="bfFormPagingPrevLabel"/>
		            			<hr/>
		            			<label class="bfPropertyLabel" for="bfCancelIncludeYes"><?php echo BFText::_('FORM_CANCEL_INCLUDE'); ?></label>
		            			<?php echo BFText::_('YES'); ?> <input checked="checked" type="radio" name="bfCancelInclude" value="" id="bfCancelIncludeYes"/>
		            			<?php echo BFText::_('NO'); ?> <input type="radio" name="bfCancelInclude" value="" id="bfCancelIncludeNo"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfFormCancelLabel"><?php echo BFText::_('FORM_CANCEL_LABEL'); ?></label>
		            			<input type="text" value="reset" id="bfFormCancelLabel"/>
		            		</fieldset>
		            	</div>
		            	<!-- FORM PROPERTIES END -->
		            	
		            	<!-- PAGE PROPERTIES BEGIN -->
		            	<div class="bfProperties" id="bfPageProperties" style="display:none">
		            		<br/>
		            		<fieldset>
		            		<legend><?php echo BFText::_('PAGE_PROPERTIES'); ?></legend>
		            		<label class="bfPropertyLabel" for="bfPageIntro"><?php echo BFText::_('PAGE_INTRO'); ?></label>
		            		<!-- <textarea id="bfPageIntro"></textarea>-->
		            		<a href="javascript:loadEditor()"><?php echo BFText::_('EDIT_INTRO'); ?></a>
		            		</fieldset>
		            	</div>
		            	<!-- PAGE PROPERTIES END -->
		            	
		            	<!-- SECTION PROPERTIES BEGIN -->
		            	<div class="bfProperties" id="bfSectionProperties" style="display:none">
		            		<br/>
		            		<fieldset>
		            			<legend><?php echo BFText::_('SECTION_PROPERTIES'); ?></legend>
		            			<label class="bfPropertyLabel" for="bfSectionType"><?php echo BFText::_('SECTION_TYPE'); ?></label>
		            			<select id="bfSectionType">
		            				<option value="normal"><?php echo BFText::_('NORMAL'); ?></option>
		            				<option value="section"><?php echo BFText::_('FIELDSET'); ?></option>
		            			</select>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfSectionDisplayType"><?php echo BFText::_('SECTION_DISPLAY_TYPE'); ?></label>
		            			<select id="bfSectionDisplayType">
		            				<option value="inline"><?php echo BFText::_('INLINE'); ?></option>
		            				<option value="breaks"><?php echo BFText::_('BREAKS'); ?></option>
		            			</select>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfSectionTitle"><?php echo BFText::_('SECTION_TITLE'); ?></label>
		            			<input type="text" value="" id="bfSectionTitle"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfSectionDescription"><?php echo BFText::_('SECTION_DESCRIPTION'); ?></label>
		            			<a href="javascript:loadEditor()"><?php echo BFText::_('EDIT_DESCRIPTION'); ?></a>
		            		</fieldset>
		            	</div>
		            	<!-- SECTION PROPERTIES END -->
		            	
		            	<!-- ELEMENT PROPERTIES BEGIN -->
		            	<div class="bfProperties" id="bfElementProperties" style="display:none">
		            		<br/>
		            		<fieldset>
		            			<legend><?php echo BFText::_('ELEMENT_PROPERTIES'); ?></legend>
		            			<label class="bfPropertyLabel" for="bfElementLabel"><?php echo BFText::_('ELEMENT_LABEL'); ?></label>
		            			<input type="text" value="" id="bfElementLabel"/>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfElementType"><?php echo BFText::_('ELEMENT_TYPE'); ?></label>
		            			<select id="bfElementType">
		            				<option value=""><?php echo BFText::_('CHOOSE_ONE'); ?></option>
		            				<option value="bfElementTypeText"><?php echo BFText::_('TEXTFIELD'); ?></option>
		            				<option value="bfElementTypeTextarea"><?php echo BFText::_('TEXTAREA'); ?></option>
		            				<option value="bfElementTypeRadioGroup"><?php echo BFText::_('RADIO_GROUP'); ?></option>
		            				<option value="bfElementTypeCheckboxGroup"><?php echo BFText::_('CHECKBOX_GROUP'); ?></option>
		            				<option value="bfElementTypeCheckbox"><?php echo BFText::_('CHECKBOX'); ?></option>
		            				<option value="bfElementTypeSelect"><?php echo BFText::_('SELECT'); ?></option>
		            				<option value="bfElementTypeFile"><?php echo BFText::_('FILE'); ?></option>
		            				<option value="bfElementTypeSubmitButton"><?php echo BFText::_('SUBMIT_BUTTON'); ?></option>
		            				<option value="bfElementTypeHidden"><?php echo BFText::_('HIDDEN'); ?></option>
		            				<option value="bfElementTypeCaptcha"><?php echo BFText::_('CAPTCHA'); ?></option>
		            				<option value="bfElementTypeCalendar"><?php echo BFText::_('CALENDAR'); ?></option>
		            				<option value="bfElementTypePayPal"><?php echo BFText::_('PAYPAL'); ?></option>
		            				<option value="bfElementTypeSofortueberweisung"><?php echo BFText::_('SOFORTUEBERWEISUNG'); ?></option>
		            			</select>
		            			<br/>
		            			<br/>
		            			<label class="bfPropertyLabel" for="bfElementName"><?php echo BFText::_('ELEMENT_NAME'); ?></label>
			            		<input type="text" value="" id="bfElementName"/>
			            		<!-- HIDDEN BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeHidden" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeHiddenValue"><?php echo BFText::_('ELEMENT_VALUE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeHiddenValue"/>
		            			</div>
		            			<!-- HIDDEN END -->
			            		<!-- TEXTFIELD BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeText" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextValue"><?php echo BFText::_('ELEMENT_VALUE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeTextValue"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextSize"><?php echo BFText::_('ELEMENT_SIZE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeTextSize"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextMaxLength"><?php echo BFText::_('ELEMENT_MAX_LENGTH'); ?></label>
			            			<input type="text" value="" id="bfElementTypeTextMaxLength"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeTextHint"></textarea>
		            			</div>
		            			<!-- TEXTFIELD END -->
		            			<!-- TEXTAREA BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeTextarea" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextareaValue"><?php echo BFText::_('ELEMENT_VALUE'); ?></label>
			            			<textarea id="bfElementTypeTextareaValue"></textarea>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextareaWidth"><?php echo BFText::_('ELEMENT_WIDTH'); ?></label>
			            			<input type="text" value="" id="bfElementTypeTextareaWidth"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextareaHeight"><?php echo BFText::_('ELEMENT_HEIGHT'); ?></label>
			            			<input type="text" value="" id="bfElementTypeTextareaHeight"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeTextareaHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeTextareaHint"></textarea>
		            			</div>
		            			<!-- TEXTAREA END -->
		            			<!-- RADIOGROUP BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeRadioGroup" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeRadioGroupGroups"><?php echo BFText::_('ELEMENT_GROUP'); ?></label>
			            			<textarea id="bfElementTypeRadioGroupGroups"></textarea>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeRadioGroupReadonly"><?php echo BFText::_('ELEMENT_READONLY'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeRadioGroupReadonly"/>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeRadioGroupWrap"><?php echo BFText::_('ELEMENT_WRAP'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeRadioGroupWrap"/>
				            		<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeRadioGroupHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeRadioGroupHint"></textarea>
		            			</div>
		            			<!-- RADIOGROUP END -->
		            			<!-- SUBMITBUTTON BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeSubmitButton" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSubmitButtonValue"><?php echo BFText::_('ELEMENT_VALUE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSubmitButtonValue"/>
				            		<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSubmitButtonHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeSubmitButtonHint"></textarea>
		            			</div>
		            			<!-- SUBMITBUTTON END -->
								<!-- PAYPAL BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypePayPal" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalBusiness"><?php echo BFText::_('ELEMENT_BUSINESS'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalBusiness"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalToken"><?php echo BFText::_('ELEMENT_TOKEN'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalToken"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalItemname"><?php echo BFText::_('ELEMENT_ITEMNAME'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalItemname"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalItemnumber"><?php echo BFText::_('ELEMENT_ITEMNUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalItemnumber"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalAmount"><?php echo BFText::_('ELEMENT_AMOUNT'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalAmount"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalTax"><?php echo BFText::_('ELEMENT_TAX'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalTax"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalThankYouPage"><?php echo BFText::_('ELEMENT_THANKYOU_PAGE'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalThankYouPage"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalLocale"><?php echo BFText::_('ELEMENT_LOCALE'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalLocale"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalCurrencyCode"><?php echo BFText::_('ELEMENT_CURRENCY_CODE'); ?></label>
			            			<input type="text" value="" id="bfElementTypePayPalCurrencyCode"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypePayPalHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypePayPalHint"></textarea>
		            			</div>
		            			<!-- PAYPAL END -->
								<!-- SOFORTUEBERWEISUNG BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeSofortueberweisung" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungUserId"><?php echo BFText::_('ELEMENT_USERID'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungUserId"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungProjectId"><?php echo BFText::_('ELEMENT_PROJECTID'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungProjectId"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungProjectPassword"><?php echo BFText::_('ELEMENT_PROJECT_PASSWORD'); ?></label>
			            			<input type="password" value="" id="bfElementTypeSofortueberweisungProjectPassword"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungReason1"><?php echo BFText::_('ELEMENT_REASON1'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungReason1"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungReason2"><?php echo BFText::_('ELEMENT_REASON2'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungReason2"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungAmount"><?php echo BFText::_('ELEMENT_AMOUNT'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungAmount"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungThankYouPage"><?php echo BFText::_('ELEMENT_THANKYOU_PAGE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungThankYouPage"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungLanguageId"><?php echo BFText::_('ELEMENT_LANGUAGE_ID'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungLanguageId"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungCurrencyId"><?php echo BFText::_('ELEMENT_CURRENCY_ID'); ?></label>
			            			<input type="text" value="" id="bfElementTypeSofortueberweisungCurrencyId"/>
			            			<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for=bfElementTypeSofortueberweisungMailback><?php echo BFText::_('ELEMENT_MAILBACK'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeSofortueberweisungMailback"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSofortueberweisungHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeSofortueberweisungHint"></textarea>
		            			</div>
		            			<!-- SOFORTUEBERWEISUNG END -->
		            			<!-- CAPTCHA BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeCaptcha" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCaptchaHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeCaptchaHint"></textarea>
		            			</div>
		            			<!-- CAPTCHA END -->
		            			<!-- CALENDAR BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeCalendar" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCalendarFormat"><?php echo BFText::_('ELEMENT_FORMAT'); ?></label>
			            			<input type="text" value="" id="bfElementTypeCalendarFormat"/>
		            				<br/>
		            				<br/>
		            				<label class="bfPropertyLabel" for="bfElementTypeCalendarValue"><?php echo BFText::_('ELEMENT_VALUE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeCalendarValue"/>
			            			<br/>
		            				<br/>
		            				<label class="bfPropertyLabel" for="bfElementTypeCalendarSize"><?php echo BFText::_('ELEMENT_SIZE'); ?></label>
			            			<input type="text" value="" id="bfElementTypeCalendarSize"/>
			            			<br/>
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCalendarHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeCalendarHint"></textarea>
		            			</div>
		            			<!-- CALENDAR END -->
		            			<!-- CHECKBOXGROUP BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeCheckboxGroup" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCheckboxGroupGroups"><?php echo BFText::_('ELEMENT_GROUP'); ?></label>
			            			<textarea id="bfElementTypeCheckboxGroupGroups"></textarea>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeCheckboxGroupReadonly"><?php echo BFText::_('ELEMENT_READONLY'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeCheckboxGroupReadonly"/>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeCheckboxGroupWrap"><?php echo BFText::_('ELEMENT_WRAP'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeCheckboxGroupWrap"/>
				            		<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCheckboxGroupHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeCheckboxGroupHint"></textarea>
		            			</div>
		            			<!-- CHECKBOXGROUP END -->
		            			<!-- CHECKBOX BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeCheckbox" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCheckboxValue"><?php echo BFText::_('ELEMENT_VALUE'); ?></label>
			            			<textarea id="bfElementTypeCheckboxValue"></textarea>
			            			<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeCheckboxChecked"><?php echo BFText::_('ELEMENT_CHECKED'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeCheckboxChecked"/>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeCheckboxReadonly"><?php echo BFText::_('ELEMENT_READONLY'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeCheckboxReadonly"/>
				            		<br/>
				            		<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeCheckboxHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeCheckboxHint"></textarea>
		            			</div>
		            			<!-- CHECKBOX END -->
		            			<!-- SELECT BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeSelect" style="display:none">
		            				<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSelectList"><?php echo BFText::_('ELEMENT_LIST'); ?></label>
			            			<textarea id="bfElementTypeSelectList"></textarea>
			            			<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeSelectMultiple"><?php echo BFText::_('ELEMENT_MULTIPLE'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeSelectMultiple"/>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeSelectReadonly"><?php echo BFText::_('ELEMENT_READONLY'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeSelectReadonly"/>
				            		<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeSelectHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeSelectHint"></textarea>
		            			</div>
		            			<!-- SELECT END -->
		            			<!-- FILE BEGIN -->
		            			<div class="bfElementTypeClass" id="bfElementTypeFile" style="display:none">
		            				<br/>
				            		<label class="bfPropertyLabel" for="bfElementTypeFileReadonly"><?php echo BFText::_('ELEMENT_READONLY'); ?></label>
				            		<input type="checkbox" value="" id="bfElementTypeFileReadonly"/>
				            		<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTypeFileHint"><?php echo BFText::_('ELEMENT_HINT'); ?></label>
			            			<textarea id="bfElementTypeFileHint"></textarea>
		            			</div>
		            			<!-- FILE END -->
		            		</fieldset>
		            		<fieldset id="bfValidationScript" style="display:none">
		            			<legend><?php echo BFText::_('ELEMENT_VALIDATION'); ?></legend>
		            			<span id="bfElementValidationRequiredSet" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementValidationRequired"><?php echo BFText::_('ELEMENT_VALIDATION_REQUIRED'); ?></label>
				            		<input type="checkbox" value="" id="bfElementValidationRequired"/>
				            		<br/>
				            		<br/>
			            		</span>
		            			<label class="bfPropertyLabel" for="bfElementValidation"><?php echo BFText::_('ELEMENT_VALIDATION_LABEL'); ?></label>
		            			<div>
								
									<?php echo BFText::_('TYPE') ?>:
									<?php echo BFText::_('NONE') ?> <input onclick="$jq('#bfValidationScriptFlags').css('display','none');$jq('#bfValidationScriptLibrary').css('display','none');$jq('#bfValidationScriptCustom').css('display','none');" type="radio" name="validationType" id="bfValidationTypeNone" class="bfValidationType" value="0"/>
									<?php echo BFText::_('LIBRARY') ?> <input onclick="$jq('#bfValidationScriptFlags').css('display','');$jq('#bfValidationScriptLibrary').css('display','');$jq('#bfValidationScriptCustom').css('display','none');" type="radio" name="validationType" id="bfValidationTypeLibrary" class="bfValidationType" value="1"/>
									<?php echo BFText::_('CUSTOM') ?> <input onclick="$jq('#bfValidationScriptFlags').css('display','');$jq('#bfValidationScriptLibrary').css('display','none');$jq('#bfValidationScriptCustom').css('display','');" type="radio" name="validationType" id="bfValidationTypeCustom" class="bfValidationType" value="2"/>
									
									<div id="bfValidationScriptFlags" style="display:none">
										<hr/>
										<?php echo BFText::_('ERROR_MESSAGE') ?>: <input type="text" style="width:100%" maxlength="255" class="bfValidationMessage" id="bfValidationMessage" name="bfValidationMessage" value="" class="inputbox"/>
									</div>
									
									<div id="bfValidationScriptLibrary" style="display:none">
										<hr/>
										<?php echo BFText::_('SCRIPT') ?>: <select id="bfValidationScriptSelection"></select>
										<div id="bfValidationScriptSelectionDescription"></div>
									</div>
									
									<div id="bfValidationScriptCustom" style="display:none">
										<hr/>
										<div style="cursor: pointer;" onclick="createValidationCode()"><?php echo BFText::_('CREATE_CODE_FRAMEWORK') ?></div>
										<textarea name="bfValidationCode" id="bfValidationCode" rows="10" style="width:100%" wrap="off"></textarea>
									</div>
								</div>
		            		</fieldset>
		            	</div>
		            	<!-- ELEMENT PROPERTIES END -->
		            	<div class="bfFadingMessage" style="display:none"></div>
		            	<input type="submit" value="<?php echo BFText::_('PROPERTIES_SAVE'); ?>" id="bfPropertySaveButton"/>
		            </div>
	            </div>
	            
	            <div id="fragment-2">
	            	<div>
	            		<div class="bfFadingMessage" style="display:none"></div>
			            <input type="submit" value="<?php echo BFText::_('PROPERTIES_SAVE'); ?>" id="bfAdvancedSaveButtonTop"/>
		            	<div class="bfAdvanced" id="bfFormAdvanced" style="display:none">
		            		<br/>
			            	<fieldset>
			            		<legend><?php echo BFText::_('ADVANCED_FORM_OPTIONS'); ?></legend>
			            		<?php if($formId != 0){ ?>
			            		<a href="javascript:loadFormSettings()"><?php echo htmlentities( BFText::_('MORE_OPTIONS'), ENT_QUOTES, 'UTF-8' ) ?></a>
			            		<?php } ?>
			            	</fieldset>
			            	<fieldset>
			            		<legend><?php echo BFText::_('ADVANCED_FORM_OTHER'); ?></legend>
			            		<label class="bfPropertyLabel" for="bfTheme"><?php echo BFText::_('THEME'); ?></label>
			            		<select id="bfTheme">
			            		<?php
								$tCount = count($themes);
								for($i = 0; $i < $tCount; $i++){
									echo '<option value="'.$themes[$i].'">'.$themes[$i].'</option>'."\n";
								}
			            		?>
			            		</select>
			            		<br/>
			            		<br/>
			            		<label class="bfPropertyLabel" for="bfElementAdvancedUseErrorAlerts"><?php echo BFText::_('USE_ERROR_ALERTS'); ?></label>
			            		<input type="checkbox" value="" id="bfElementAdvancedUseErrorAlerts"/>
			            		<br/>
			            		<br/>
			            		<label class="bfPropertyLabel" for="bfElementAdvancedFadeIn"><?php echo BFText::_('FADE_IN'); ?></label>
			            		<input type="checkbox" value="" id="bfElementAdvancedFadeIn"/>
			            		<br/>
			            		<br/>
			            		<label class="bfPropertyLabel" for="bfElementAdvancedRollover"><?php echo BFText::_('ROLLOVER'); ?></label>
			            		<input type="checkbox" value="" id="bfElementAdvancedRollover"/>
			            		<br/>
			            		<br/>
			            		<label class="bfPropertyLabel" for="bfElementAdvancedRolloverColor"><?php echo BFText::_('ROLLOVER_COLOR'); ?></label>
			            			<input type="text" value="" id="bfElementAdvancedRolloverColor"/>
			            	</fieldset>
			            </div>
			            <div class="bfAdvanced" id="bfElementAdvanced" style="display:none">
			            	<br/>
			            	<fieldset>
			            		<legend><?php echo BFText::_('ADVANCED_ELEMENT_OPTIONS'); ?></legend>
			            		<!-- HIDDEN BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeHiddenAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementHiddenAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementHiddenAdvancedOrderNumber"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementHiddenAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input type="checkbox" value="" id="bfElementHiddenAdvancedLogging"/>
			            		</div>
			            		<!-- HIDDEN END -->
			            		<!-- TEXTFIELD BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeTextAdvanced" style="display:none">
				            		<label class="bfPropertyLabel" for="bfElementAdvancedPassword"><?php echo BFText::_('PASSWORD'); ?></label>
			            			<input type="checkbox" value="" id="bfElementAdvancedPassword"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementAdvancedReadOnly"><?php echo BFText::_('READONLY'); ?></label>
			            			<input type="checkbox" value="" id="bfElementAdvancedReadOnly"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementAdvancedMailback"><?php echo BFText::_('MAILBACK'); ?></label>
			            			<input type="checkbox" value="" id="bfElementAdvancedMailback"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementAdvancedMailbackAsSender"><?php echo BFText::_('MAILBACK_AS_SENDER'); ?></label>
			            			<input type="checkbox" value="" id="bfElementAdvancedMailbackAsSender"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementAdvancedMailbackfile"><?php echo BFText::_('MAILBACKFILE'); ?></label>
			            			<input type="text" value="" id="bfElementAdvancedMailbackfile"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementOrderNumber"/>
			            		</div>
			            		<!-- TEXTFIELD END -->
			            		<!-- TEXTAREA BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeTextareaAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementTextareaAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementTextareaAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTextareaAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementTextareaAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementTextareaAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementTextareaAdvancedOrderNumber"/>
			            		</div>
			            		<!-- TEXTAREA END -->
			            		<!-- RADIOGROUP BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeRadioGroupAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementRadioGroupAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementRadioGroupAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementRadioGroupAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementRadioGroupAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementRadioGroupAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementRadioGroupAdvancedOrderNumber"/>
			            		</div>
			            		<!-- RADIOGROUP END -->
			            		<!-- SUBMITBUTTON BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeSubmitButtonAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementSubmitButtonAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementSubmitButtonAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSubmitButtonAdvancedSrc"><?php echo BFText::_('SOURCE'); ?></label>
			            			<input type="text" value="" id="bfElementSubmitButtonAdvancedSrc"/>
			            		</div>
			            		<!-- SUBMITBUTTON END -->
								<!-- PAYPAL BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypePayPalAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementPayPalAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedImage"><?php echo BFText::_('IMAGE'); ?></label>
			            			<input type="text" value="" id="bfElementPayPalAdvancedImage"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedTestaccount"><?php echo BFText::_('TESTACCOUNT'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementPayPalAdvancedTestaccount"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedTestBusiness"><?php echo BFText::_('TESTBUSINESS'); ?></label>
			            			<input type="text" value="" id="bfElementPayPalAdvancedTestBusiness"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedTestToken"><?php echo BFText::_('TESTTOKEN'); ?></label>
			            			<input type="text" value="" id="bfElementPayPalAdvancedTestToken"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedDownloadableFile"><?php echo BFText::_('DOWNLOADABLE_FILE'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementPayPalAdvancedDownloadableFile"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedFilepath"><?php echo BFText::_('FILEPATH'); ?></label>
			            			<input type="text" value="" id="bfElementPayPalAdvancedFilepath"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementPayPalAdvancedDownloadTries"><?php echo BFText::_('DOWNLOAD_TRIES'); ?></label>
			            			<input type="text" value="" id="bfElementPayPalAdvancedDownloadTries"/>
			            		</div>
			            		<!-- PAYPAL END -->
								<!-- SOFORTUEBERWEISUNG BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeSofortueberweisungAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementSofortueberweisungAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementSofortueberweisungAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSofortueberweisungAdvancedImage"><?php echo BFText::_('IMAGE'); ?></label>
			            			<input type="text" value="" id="bfElementSofortueberweisungAdvancedImage"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSofortueberweisungAdvancedDownloadableFile"><?php echo BFText::_('DOWNLOADABLE_FILE'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementSofortueberweisungAdvancedDownloadableFile"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSofortueberweisungAdvancedFilepath"><?php echo BFText::_('FILEPATH'); ?></label>
			            			<input type="text" value="" id="bfElementSofortueberweisungAdvancedFilepath"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSofortueberweisungAdvancedDownloadTries"><?php echo BFText::_('DOWNLOAD_TRIES'); ?></label>
			            			<input type="text" value="" id="bfElementSofortueberweisungAdvancedDownloadTries"/>
			            		</div>
			            		<!-- SOFORTUEBERWEISUNG END -->
			            		<!-- CAPTCHA BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeCaptchaAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementCaptchaAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCaptchaAdvancedHideLabel"/>
			            		</div>
			            		<!-- CAPTCHA END -->
			            		<!-- CALENDAR BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeCalendarAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementCalendarAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCalendarAdvancedHideLabel"/>
			            		</div>
			            		<!-- CALENDAR END -->
			            		<!-- CHECKBOXGROUP BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeCheckboxGroupAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementCheckboxGroupAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCheckboxGroupAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementCheckboxGroupAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCheckboxGroupAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementCheckboxGroupAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementCheckboxGroupAdvancedOrderNumber"/>
			            		</div>
			            		<!-- CHECKBOXGROUP END -->
			            		<!-- CHECKBOX BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeCheckboxAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementCheckboxAdvancedMailbackAccept"><?php echo BFText::_('MAILBACK_ACCEPT'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCheckboxAdvancedMailbackAccept"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementCheckboxAdvancedMailbackConnectWith"><?php echo BFText::_('MAILBACK_CONNECT_WITH'); ?></label>
			            			<input type="text" value="" id="bfElementCheckboxAdvancedMailbackConnectWith"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementCheckboxAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCheckboxAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementCheckboxAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementCheckboxAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementCheckboxAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementCheckboxAdvancedOrderNumber"/>
			            		</div>
			            		<!-- CHECKBOX END -->
			            		<!-- CHECKBOXGROUP BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeSelectAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementSelectAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementSelectAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSelectAdvancedMailback"><?php echo BFText::_('MAILBACK'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementSelectAdvancedMailback"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSelectAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementSelectAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementSelectAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementSelectAdvancedOrderNumber"/>
			            		</div>
			            		<!-- CHECKBOXGROUP END -->
								<!-- FILE BEGIN -->
			            		<div class="bfElementTypeClass" id="bfElementTypeFileAdvanced" style="display:none">
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedUploadDirectory"><?php echo BFText::_('UPLOAD_DIRECTORY'); ?></label>
			            			<input type="text" value="" id="bfElementFileAdvancedUploadDirectory"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedTimestamp"><?php echo BFText::_('TIMESTAMP'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementFileAdvancedTimestamp"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedAllowedFileExtensions"><?php echo BFText::_('ALLOWED_FILE_EXTENSIONS'); ?></label>
			            			<input type="text" value="" id="bfElementFileAdvancedAllowedFileExtensions"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedAttachToUserMail"><?php echo BFText::_('ATTACH_TO_USERMAIL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementFileAdvancedAttachToUserMail"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedAttachToAdminMail"><?php echo BFText::_('ATTACH_TO_ADMINMAIL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementFileAdvancedAttachToAdminMail"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedHideLabel"><?php echo BFText::_('HIDE_LABEL'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementFileAdvancedHideLabel"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedLogging"><?php echo BFText::_('LOGGING'); ?></label>
			            			<input checked="checked" type="checkbox" value="" id="bfElementFileAdvancedLogging"/>
			            			<br/>
			            			<br/>
			            			<label class="bfPropertyLabel" for="bfElementFileAdvancedOrderNumber"><?php echo BFText::_('ORDER_NUMBER'); ?></label>
			            			<input type="text" value="" id="bfElementFileAdvancedOrderNumber"/>
			            		</div>
			            		<!-- FILE END -->
			            		<div id="bfAdvancedLeaf">
				            		<br/>
				            		<label class="bfPropertyLabel" id="bfElementAdvancedTabIndexLabel" for="bfElementAdvancedTabIndex"><?php echo BFText::_('TAB_INDEX'); ?></label>
				            		<input type="text" value="" id="bfElementAdvancedTabIndex"/>
				            		<br/>
				            		<br/>
				            		<label class="bfPropertyLabel" id="bfElementAdvancedLabelPositionLabel" for="bfElementAdvancedLabelPosition"><?php echo BFText::_('LABEL_POSITION'); ?></label>
				            		<select id="bfElementAdvancedLabelPosition">
				            			<option value="left"><?php echo BFText::_('LEFT'); ?></option>
				            			<option value="top"><?php echo BFText::_('TOP'); ?></option>
				            			<option value="right"><?php echo BFText::_('RIGHT'); ?></option>
				            			<option value="bottom"><?php echo BFText::_('BOTTOM'); ?></option>
				            		</select>
			            		</div>
			            	</fieldset>
			            	
			            	<fieldset id="bfInitScript" style="display:none">
			            		<br/>
			            		<legend><?php echo BFText::_('ADVANCED_ELEMENT_INITSCRIPT'); ?></legend>
			            		<?php echo BFText::_('TYPE') ?>:
								<?php echo BFText::_('NONE') ?> <input onclick="$jq('#bfInitScriptFlags').css('display','none');$jq('#bfInitScriptLibrary').css('display','none');$jq('#bfInitScriptCustom').css('display','none');" type="radio" name="initType" id="bfInitTypeNone" class="bfInitType" value="0"/>
								<?php echo BFText::_('LIBRARY') ?> <input onclick="$jq('#bfInitScriptFlags').css('display','');$jq('#bfInitScriptLibrary').css('display','');$jq('#bfInitScriptCustom').css('display','none');" type="radio" name="initType" id="bfInitTypeLibrary" class="bfInitType" value="1"/>
								<?php echo BFText::_('CUSTOM') ?> <input onclick="$jq('#bfInitScriptFlags').css('display','');$jq('#bfInitScriptLibrary').css('display','none');$jq('#bfInitScriptCustom').css('display','');" type="radio" name="initType" id="bfInitTypeCustom" class="bfInitType" value="2"/>
									
								<div id="bfInitScriptFlags" style="display:none">
									<hr/>
									<input type="checkbox" id="bfInitFormEntry" class="bfInitFormEntry" name="bfInitFormEntry" value="1"/><label for="bfInitFormEntry"> <?php echo BFText::_('ELEMENTS_FORMENTRY'); ?></label>
									<input type="checkbox" id="bfInitPageEntry" class="bfInitPageEntry" name="bfInitPageEntry" value="1"/><label for="bfInitPageEntry"> <?php echo BFText::_('ELEMENTS_PAGEENTRY'); ?></label>
								</div>
									
								<div id="bfInitScriptLibrary" style="display:none">
									<hr/>
									<?php echo BFText::_('SCRIPT') ?>: <select id="bfInitScriptSelection"></select>
									<div id="bfInitSelectionDescription"></div>
								</div>
									
								<div id="bfInitScriptCustom" style="display:none">
									<hr/>
									<div style="cursor: pointer;" onclick="createInitCode()"><?php echo BFText::_('CREATE_CODE_FRAMEWORK') ?></div>
									<textarea name="bfInitCode" id="bfInitCode" rows="10" style="width:100%" wrap="off"></textarea>
								</div>
			            	</fieldset>
			            	
			            	<fieldset id="bfActionScript" style="display:none">
			            		<br/>
			            		<legend><?php echo BFText::_('ADVANCED_ELEMENT_ACTIONSCRIPT'); ?></legend>
			            		
			            		<?php echo BFText::_('TYPE') ?>:
								<?php echo BFText::_('NONE') ?> <input onclick="$jq('#bfActionScriptFlags').css('display','none');$jq('#bfActionScriptLibrary').css('display','none');$jq('#bfActionScriptCustom').css('display','none');" type="radio" name="actionType" name="actionType" id="bfActionTypeNone" class="bfActionType" value="0"/>
								<?php echo BFText::_('LIBRARY') ?> <input onclick="$jq('#bfActionScriptFlags').css('display','');$jq('#bfActionScriptLibrary').css('display','');$jq('#bfActionScriptCustom').css('display','none');" type="radio" name="actionType" id="bfActionTypeLibrary" class="bfActionType" value="1"/>
								<?php echo BFText::_('CUSTOM') ?> <input onclick="$jq('#bfActionScriptFlags').css('display','');$jq('#bfActionScriptLibrary').css('display','none');$jq('#bfActionScriptCustom').css('display','');" type="radio" name="actionType" id="bfActionTypeCustom" class="bfActionType" value="2"/>
									
								<div id="bfActionScriptFlags" style="display:none">
									<hr/>
										
									<?php echo BFText::_('ACTIONS') ?>:
									<input style="display:none" type="checkbox" class="bfAction" id="bfActionClick" name="bfActionClick" value="1"/><label style="display:none" class="bfActionLabel" id="bfActionClickLabel"> <?php echo BFText::_('ELEMENTS_CLICK'); ?></label>
									<input style="display:none" type="checkbox" class="bfAction" id="bfActionBlur" name="bfActionBlur" value="1"/><label style="display:none" class="bfActionLabel" id="bfActionBlurLabel"> <?php echo BFText::_('ELEMENTS_BLUR'); ?></label>
									<input style="display:none" type="checkbox" class="bfAction" id="bfActionChange" name="bfActionChange" value="1"/><label style="display:none" class="bfActionLabel" id="bfActionChangeLabel"> <?php echo BFText::_('ELEMENTS_CHANGE'); ?></label>
									<input style="display:none" type="checkbox" class="bfAction" id="bfActionFocus" name="bfActionFocus" value="1"/><label style="display:none" class="bfActionLabel" id="bfActionFocusLabel"> <?php echo BFText::_('ELEMENTS_FOCUS'); ?></label>
									<input style="display:none" type="checkbox" class="bfAction" id="bfActionSelect" name="bfActionSelect" value="1"/><label style="display:none" class="bfActionLabel" id="bfActionSelectLabel"> <?php echo BFText::_('ELEMENTS_SELECTION'); ?></label>
								</div>
									
								<div id="bfActionScriptLibrary" style="display:none">
									<hr/>
									<?php echo BFText::_('SCRIPT') ?>: <select id="bfActionsScriptSelection"></select>
									<div id="bfActionsScriptSelectionDescription"></div>
								</div>
									
								<div id="bfActionScriptCustom" style="display:none">
									<hr/>
									<div style="cursor: pointer;" onclick="createActionCode()"><?php echo BFText::_('CREATE_CODE_FRAMEWORK') ?></div>
									<textarea name="bfActionCode" id="bfActionCode" rows="10" style="width:100%" wrap="off"></textarea>
								</div>
			            		
			            	</fieldset>
			            	
			            </div>
			            <div class="bfFadingMessage" style="display:none"></div>
			            <input type="submit" value="<?php echo BFText::_('PROPERTIES_SAVE'); ?>" id="bfAdvancedSaveButton"/>
	            	</div>
	            </div>
            </div>
            
            
            <div class="b">
				<div class="b">
		 			<div class="b"></div>
				</div>
			</div>
  </div>
  
  </form>
  
	</div> <!-- ##### bfQuickModeRight end ##### -->
	
	</div> <!-- ##### bfQuickModeWrapper end ##### -->
<?php
	}
}