function cnxs_highlight_text(name) { 
	xajax.$(name).className="inputText_Hightlight";
}

function cnxs_ErrorOn(sID) {
  xajax.$(sID).style.background='#FF0000';
}

function cnxs_ErrorOff(sID) {
  xajax.$(sID).style.background='';
}

function cnxs_setBorderColor(sElementID,sNewColor) {
	xajax.$(sElementID).style.borderColor=sNewColor;
}

// Link zu Liste: http://www.useragentstring.com/pages/useragentstring.php
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},

	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

var menuTimerID=null;

function closeMenu() {
  //cx_server({target: 'blockTitleOne',module: 'elementMainMenu', action: 'close'});
}

function startMenuTimer() {
  menuTimerID=setTimeout('closeMenu()',2000);
}

function stopMenuTimer() {
  if (menuTimerID != null) {
    clearTimeout(menuTimerID);
    menuTimerID=null;
  }
}

function restartMenuTimer() {
  stopMenuTimer();
  startMenuTimer();
}

function sendJavaData(actionString,paramArg) { 
  cx_server({special: actionString,param: paramArg});
}

function killHelptext(divID) {
  element=xajax.$(divID);
  element.innerHTML='';
  element.style.display='none';
}

function stopEvent(ev) {
  ev.stopPropagation();
}

function NoButtonOnZero(elementID,visibleID) {
  var visDing=document.getElementById(visibleID);
  if (document.getElementById(elementID).value != '0') {
    visDing.style.display='';
  } else {
    visDing.style.display='none';
  }
}

function callHelpSystem(divID,aliasName,targetName) {
/*
  cx_server({curDisplayStyle: (document.getElementById(divID).innerHTML==''),special: 'helptext',divID: divID,aliasName: aliasName, target: targetName});
*/
	var curStyleDisp=document.getElementById(divID).style.display;
	cx_server({curDisplayStyle: (curStyleDisp=='none'),special: 'helptext',divID: divID,aliasName: aliasName, target: targetName});
}

function saveFormValsAsDefault() {
	return;
	var anzForms=document.forms.length;
	
	for (var f=0; f<anzForms; f++) {
		var formular=document.forms[f];
		var anzahl=formular.length;
		for (var e=0; e<anzahl; e++) {
			formele=formular.elements[e];
			formele.defaultValue=formular.elements[e].value;
			if (formele.type=='select-one') {
				var anzOpts=formele.options.length;
				for (var o=0; o<anzOpts; o++) {
					if (formele.options[o].selected==true) {
						formele.options[o].defaultSelected=true;
					} else {
						formele.options[o].defaultSelected=false;
					}
				}
			} else {
        if ((formele.type=='radio') |(formele.type=='checkbox')) {
        	formele.defaultChecked=formele.checked;
        }
			}
		}
	}
}


function toggleDisplayList(picid,id) {
  picElement=document.getElementById(picid);
  element=document.getElementById(id);
  
  if (element) {
    if (element.style.display == 'none') {
      element.style.display='';
      picElement.src='./webelements/images/site/icons/fieldDropUp.gif';
    } else {
      element.style.display='none';
      picElement.src='./webelements/images/site/icons/fieldDropDown.gif';
    }
  }
}

function toggleDisplay(picid,id) {
  picElement=document.getElementById(picid);
  element=document.getElementById(id);
  
  if (element) {
    if (element.style.display == 'none') {
      element.style.display='';
      picElement.src='./webelements/images/site/menuEditor/minus.gif';
    } else {
      element.style.display='none';
      picElement.src='./webelements/images/site/menuEditor/plus.gif';
    }
  }
}

function openDisplay(sPicID,sID) {
	element=document.getElementById(sID);
	if (element) {
	  if (element.style.display == 'none') {
	    toggleDisplay(sPicID,sID);
	  }
	}
}

function toggleDiv(divId) {
  element=document.getElementById(divId);
  
  if (element) {
    if (element.style.display == 'none') {
      element.style.display='';
    } else {
      element.style.display='none';
    }
  }
}

function toggleInputClass(divId) {
  element=xajax.$(divId);
 
  if (element) {
    if (element.className == 'input_editable') {
      element.className='input_readonly';
    } else {
      element.className='input_editable';
    }
  }
}

function setInputEditable(divId) {
  element=xajax.$(divId);
  if (element) {
    element.className = 'input_editable';
    element.readOnly=false;
  }
  element=xajax.$(divId+'_okay');
  if (element) {
    element.style.display = '';
  }
}

function setInputReadonly(divId) {
  element=xajax.$(divId);
  if (element) {
    element.className = 'input_readonly';
    element.readOnly=true;
  }
  element=xajax.$(divId+'_okay');
  if (element) {
    element.style.display = 'none';
  }
}


function setInputEditableArray(sDivID,aExtNames) {
	var iCount=aExtNames.length;
	for (i=0; i<iCount; i++) {
		var element=xajax.$(sDivID+'_'+aExtNames[i]);
		if (element) {
    	element.className = 'input_editable';
    	element.readOnly=false;
		}
	}
	element=xajax.$(sDivID+'_okay');
	if (element) {
		element.style.visibility='visible';
	}
}

function setInputReadonlyArray(sDivID,aExtNames) {
	var iCount=aExtNames.length;
	var elem,ent;
	for (i=0; i<iCount; i++) {
		var element=xajax.$(sDivID+'_'+aExtNames[i]);
		if (element) {
    	element.className = 'input_readonly';
    	element.readOnly=true;
		}
	}
	element=xajax.$(sDivID+'_okay');
	if (element) {
		element.style.visibility='hidden';
	}
}

function setDisplayVisible(divId,isVisible) {
	if (isVisible)
		document.getElementById(divId).style.display='';
	else
		document.getElementById(divId).style.display='none';
}

function setDisabled(divId,isDisabled) {
	if (isDisabled)
		document.getElementById(divId).disabled='';
	else
		document.getElementById(divId).disabled='disabled';
}

function openDisplay(picid,id) {
  picElement=document.getElementById(picid);
  element=document.getElementById(id);
    if (element) {
      element.style.display='block';
      picElement.src='./webelements/images/site/menuEditor/minus.gif';
    }
}

function closeDisplay(picid,id) {
  picElement=document.getElementById(picid);
  element=document.getElementById(id);
  if (element) {
      element.style.display='none';
      picElement.src='./webelements/images/site/menuEditor/plus.gif';
  }
}

function callFilebrowser(textfieldID,exeModuleName,sTargetName,type,bSendSize) {
	if (bSendSize == undefined) {
		bSendSize=false;
	}
	cx_server({module: 'TreeViewRequesterBrowser', 
							target: sTargetName, 
							action: 'loadImageBrowser', 
							param: textfieldID,
							type: type,
							sendSize: bSendSize});

}

function resetFilebrowser(sBaseFieldID) {
	xajax.$(sBaseFieldID+'_filename').value='';
	xajax.$(sBaseFieldID).value=0;
}

/*
ursprünglicher Aufruf:
<a onclick="javascript:cx_server({module: 'adminMenuEditor', fromModule: 'adminMenuEditor',
target: 'generalCenter', targetId: 'generalCenter_fontColor_div_fontColor',
action: 'showColorPicker',
color: document.getElementById('generalCenter_fontColor').value });">
	<img alt="ColorPicker" src="./webelements/images/site/menuEditor/color_wheel.png"/>
</a>
*/
function callColorPicker(sTargetName,sGetColorTargetID,sShowColorTargetID,sColorKind) {
	cx_server({
						target: sTargetName,
						module: 'colorChooserEvents',
						colorValueElementID: sGetColorTargetID,
						color: document.getElementById(sGetColorTargetID).value,
						targetId: sShowColorTargetID,
						colorKind: sColorKind,
						action: 'showColorPicker'
						});
}

var AutoCompleteBuffer =  {
	bufferTime: 500,
	autoDivID: false,
	activeDetailsID: false,
 	aDataArray: {},

/*
 Initalisiert einen Autocomplete-Buffer, falls er noch nicht initalisiert war
 iDetailsID: (int) ID des zugehörigen Datensatzes (cx_serachform_details.ID)
 sTargetName: (string) Name des Targets
 sTargetModule: (string) Names des Moduls, welches die ID des Eingabefeldes vergeben hat
 sSendTargetModule: (string) Name des Modules, an den der Request geschickt werden soll.
 Wird wohl eine von searchFormBase abgeleitete sein. 
 
 <sTargetName>_<sTargetModule>_element_<iDetailsID> muss die ID des
 Eingabefeldes entsprechen!!!!
*/
 init : function (iDetailsID,sTargetName,sTargetModule,sSendTargetModule) {
 this.closeSuggest();
 	if (this.aDataArray[iDetailsID] == undefined) {
 		this.aDataArray[iDetailsID]={	targetName: sTargetName, 
		 															targetModule: sTargetModule,
																	sendTargetModule: sSendTargetModule,
																	bufferText: false};
 	} else {
 		this.aDataArray[iDetailsID]['bufferText']='';
 	}
 	this.activeDetailsID=iDetailsID;
 },

 getInputID : function(iDetailsID) {
		var aData=this.aDataArray[iDetailsID];
		return aData['targetName']+'_'+aData['targetModule']+'_element_'+iDetailsID;
 },
 
/*
 Diese Methode wird vom Eingabefeld, welches Autocomplete unterstützen soll,
 immer bei Änderungen aufgerufen.
*/
	modified : function(iDetailsID) {
		var strId=AutoCompleteBuffer.getInputID(iDetailsID);
		setTimeout('AutoCompleteBuffer.compareBuffer('+iDetailsID+',"'+strId+'","'+xajax.$(strId).value+'");', this.bufferTime);
 },

 compareBuffer : function(iDetailsID,strId, strText) {
	 if (strText == xajax.$(strId).value && strText != this.aDataArray[iDetailsID]['bufferText']) {
		 this.aDataArray[iDetailsID]['bufferText'] = strText;
		 AutoCompleteBuffer.makeRequest(iDetailsID);
	 }
 },

 makeRequest : function(iDetailsID) {
	 var newData=xajax.$(AutoCompleteBuffer.getInputID(iDetailsID)).value;
	 var aData=this.aDataArray[iDetailsID];
	 if (this.activeDetailsID == iDetailsID) {
	 cx_server({
								target: aData['targetName'],
								module: aData['sendTargetModule'],
								action: 'autocomplete',
								search: newData,
								detailsID: iDetailsID});
		this.autoDivID=aData['targetName']+'_'+aData['targetModule']+'_suggestDiv_'+iDetailsID;
	} else {
		this.closeSuggest();
	}
 },
 
 closeSuggest : function() {
 	if (this.autoDivID) {
 		if (xajax.$(this.autoDivID)) {
 			xajax.$(this.autoDivID).style.display='none';

 		}
 		//edited by PB 			this.autoDivID=false; 
 	}
 	this.activeDetailsID=false;
 }
}

// Funktion für Steuerung vom tinyMCE V3.x
function submitMCE(form_name) {
	if (tinyMCE) {
  	tinyMCE.triggerSave();
  }
}

function killMCE(element_id) {
  tinyMCE.execCommand('mceRemoveControl',false,element_id);
}

function saveMCEContent(form_id,form_name) {
  var content=tinyMCE.activeEditor.getContent();
  document.getElementById(form_id).textContent=content;
}
// Ende Funktion für Steuerung vom tinyMCE V3.x


function centerElement(elementID) {
  var el=document.getElementById(elementID);

  el.style.visibility='visible';
  return;

  var height=0;
  var width=0;
  var scrW=0;
  var scrH=0;
  var offX=0;
  var offY=0;
  
  if (self.innerHeight) {
    scrW=self.innerWidth;
    scrH=self.innerHeight;
  } else {
    if (document.documentElement && document.documentElement.clientHeight) {
      scrW=document.documentElement.clientWidth;
	    scrH=document.documentElement.clientHeight;
    } else {
      if (document.body) {
        scrW=document.body.clientWidth;
	      scrH=document.body.clientHeight;
      }
    }
  }

  width=el.offsetWidth;
  height=el.offsetHeight;

  var left=(scrW - parseInt(width)) /2;
  var top=(scrH - parseInt(height)) /2;
  //alert('left/top: '+left+'/'+top+' w/h'+width+'/'+height+' scrW/scrHei: '+scrW+'/'+scrH)

  offX=document.body.scrollWidth - document.body.scrollLeft;
  offY=document.body.scrollHeight - document.body.scrollTop;
  //alert('offX/offY: '+offX+'/'+offY);
  
  el.style.left=left+'px';
  el.style.top=top+'px';
  //el.offsetLeft=offX;
  //el.offsetTop=offY;
  el.style.visibility='visible';
}
//  Tiny Config Standard
function getTinyStandardConfig(element_id,iLangID,sTinyLang,sConaxisURL) {
  return {mode: "none",
  		    language: sTinyLang,
  		    conaxisURL: sConaxisURL,
  		    langID: iLangID,
  		    isAbs: false,
				 	window: window,
				 	cleanup : true,
					element_id: element_id,
				  theme: "advanced",
				  plugins : "style,table,save,advhr,advimage,advlink,contextmenu,paste,emotions,iespell,insertdatetime,searchreplace,print,fullscreen,media,inlinepopups,visualchars,preview,layer,style",
				  theme_advanced_buttons1_add_before: "cut,copy,paste,pastetext,pasteword,separator",
					theme_advanced_buttons1_add : "styleselect,separator",
					theme_advanced_buttons2_add_before: "",
				  theme_advanced_buttons2_add : "separator,forecolor,backcolor,print,fullscreen,media",
					theme_advanced_buttons3_add_before : "tablecontrols,advlink,visualchars,preview",
					theme_advanced_buttons3_add : "emotions,iespell,advhr,insertlayer,moveforward,movebackward,absolute,styleprops",
					
	//				theme_advanced_disable : "fontselect,fontsizeselect,help,charmap,newdocument,split_cells,merge_cells,sub,sup",				
					
					theme_advanced_toolbar_location : "top",
					theme_advanced_toolbar_align : "left",
					theme_advanced_path_location : "bottom",
					theme_advanced_resizing : true,
					theme_advanced_resize_horizontal : true,
					content_css : "webelements/styles/tiny.css",
					nonbreaking_force_tab : true,
					paste_auto_cleanup_on_paste : true,
					paste_remove_styles : true,
					apply_source_formatting : true,
					plugin_insertdate_dateFormat : "%Y-%m-%d",
					plugin_insertdate_timeFormat : "%H:%M:%S",
          auto_resize : false,
					
					fullscreen_new_window : false,
					fullscreen_settings : { theme_advanced_path_location : "top"},
					extended_valid_elements : "a[name|class|href|target|title|onclick|style|text-decoration],"
                                  + "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|style|margin|padding|onclick|onmouseover|onmouseout|name],"
                                  + "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],"
                                  + "iframe[align<bottom?left?middle?right?top|class|frameborder|height|id"
                                  + "|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style"
                                  + "|title|width],",
				  width: '100%',
				  height: '400px',
				  debug: false,
					relative_urls : false,
					convert_urls : false,
				    //flash_external_list_url : "./flashlist.php?siteID=<?php echo SITEID; ?>", // Optional URL to a list of SWF movies
					flash_wmode : "transparent",
					flash_quality : "high",
					flash_menu : "false",
				  
				  dialog_type : "modal",
				  
				  file_browser_callback : "fileBrowserCallBack"
  			}
};

tinymce.create('tinymce.plugins.userVariables', {
	createControl: function(n, cm) {
		switch (n) {
			case 'userVariables':
					var mlb = cm.createListBox('userVariables', {
					title : 'User Variables',
					onselect : function(v) {
						tinyMCE.execCommand('mceInsertContent', false, v)
					}
					});

					// Add some values to the list box
					mlb.add('Anrede', '{{_Anrede_}}');
					mlb.add('URL', '{{_url_}}');
					mlb.add('heutiges Datum', '{{_current_date_}}');
					mlb.add('Abmeldelink', '{{_deregisterLink_}}');
					// Return the new listbox instance

					return mlb;
				// Return the new splitbutton instance
				return c;
				} // End switch
	return null;
	}
	});

tinymce.PluginManager.add('userVariables', tinymce.plugins.userVariables);
//  Tiny Config für Newsletter
function getTinyNewsletterConfig(element_id,iLangID,sTinyLang,sConaxisURL) {
	return {mode : "none",
  		    language: sTinyLang,
  		    conaxisURL: sConaxisURL,
  		    langID: iLangID,
  		    isAbs: true,
				 	window: window,
				 	element_id: element_id,
					theme : "advanced",
					plugins : "-userVariables,table,save,advhr,advimage,advlink,preview,media,contextmenu,paste,inlinepopups,noneditable,visualchars",
					theme_advanced_disable: "anchor,help,cleanup,styleselect,formatselect",
					theme_advanced_buttons1_add : "fontselect,fontsizeselect,separator",
					theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator",
					theme_advanced_buttons3_add : "iespell,media,advhr,separator,forecolor,backcolor,separator,cleanup,removeformat,preview",
					theme_advanced_buttons4 : "userVariables,separator,tablecontrols",
					theme_advanced_toolbar_location : "top",
					theme_advanced_toolbar_align : "left",
					theme_advanced_path_location : "bottom",
					theme_advanced_fonts : "Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Verdana=Verdana, sans-serif;",
					theme_advanced_font_sizes : "1,2,3,4,5,6,7",
					convert_fonts_to_spans : false,
					paste_auto_cleanup_on_paste : true,
          paste_remove_styles : true,
					inline_styles : false ,
					plugin_insertdate_dateFormat : "%Y-%m-%d",
					plugin_insertdate_timeFormat : "%H:%M:%S",
					extended_valid_elements : "a[name|class|href|target|title|onclick|style|text-decoration],hr[width|size|noshade],span[align],font[color|size|face]",
					file_browser_callback : "fileBrowserCallBackAbsUrl",
					relative_urls : false,
					convert_urls : false,
					theme_advanced_resize_horizontal : true,
					theme_advanced_resizing : true,
					nonbreaking_force_tab : true,
					apply_source_formatting : true,
			  	width: '100%',
			  	height: '450px',
			  	dialog_type: 'modal',
			  	debug: false
				}
};
//  Tiny Config für User Biografie
function getTinyAboutMeConfig(element_id,iLangID,sTinyLang,sConaxisURL) {
  return {mode: "none",
  		    language: sTinyLang,
  		    conaxisURL: sConaxisURL,
  		    langID: iLangID,
  		    isAbs: false,
				 	window: window,
					element_id: element_id,
				  theme: "advanced",
				  plugins : "paste,style,save,contextmenu,emotions,iespell,insertdatetime",
				  theme_advanced_buttons1_add_before: "cut,copy,pastetext,separator",
					theme_advanced_buttons1_add : "styleselect",
					theme_advanced_buttons2_add_before: "",
//				  theme_advanced_buttons2_add : "separator,forecolor,backcolor,print,",
					theme_advanced_buttons3_add : "emotions,iespell,advhr",
					
					theme_advanced_disable : "fontselect,fontsizeselect,advlink,help,charmap,newdocument,split_cells,merge_cells,sub,sup,image,code,advhr,link,anchor,styleselect",				
					
					theme_advanced_toolbar_location : "top",
					theme_advanced_toolbar_align : "left",
					theme_advanced_path_location : "bottom",
					theme_advanced_resizing : true,
					theme_advanced_resize_horizontal : true,
//					content_css : "webelements/styles/tiny.css",
          paste_auto_cleanup_on_paste : true,
					paste_remove_styles : true,
					nonbreaking_force_tab : true,
					apply_source_formatting : true,
					plugin_insertdate_dateFormat : "%Y-%m-%d",
					plugin_insertdate_timeFormat : "%H:%M:%S",
					auto_resize : false,	
					fullscreen_new_window : false,
					fullscreen_settings : { theme_advanced_path_location : "top"},
					extended_valid_elements : "a[name|class|href|target|title|onclick|style|text-decoration],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|style|margin|padding|onclick|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
				  width: '100%',
				  height: '400px',
				  debug: false,
					relative_urls : true,
					convert_urls : true,
				  dialog_type : "modal"
					//,file_browser_callback : "fileBrowserCallBack"
  			}
};
//  Tiny Config für UserTexte E-Mail Bausteine
function getTinyConfigtextsEmailConfig(element_id,iLangID,sTinyLang,sConaxisURL) {
	return {mode : "none",
  		    language: sTinyLang,
  		    conaxisURL: sConaxisURL,
  		    langID: iLangID,
  		    isAbs: true,
				 	window: window,
				 	element_id: element_id,
					theme : "advanced",
					plugins : "table,save,advhr,advimage,advlink,preview,media,contextmenu,paste,noneditable,visualchars",
					theme_advanced_disable: "anchor,help,cleanup,preview,styleselect,formatselect",
					theme_advanced_buttons1_add : "fontselect,fontsizeselect,separator",
					theme_advanced_buttons2_add_before: "cut,copy,pastetext,pasteword,separator",
					theme_advanced_buttons3_add : "iespell,media,advhr,separator,forecolor,backcolor,separator,cleanup,removeformat",
					theme_advanced_buttons4 : "separator,tablecontrols,visualchars",
					theme_advanced_toolbar_location : "top",
					theme_advanced_toolbar_align : "left",
					theme_advanced_path_location : "bottom",
					theme_advanced_fonts : "Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Verdana=Verdana, sans-serif;",
					theme_advanced_font_sizes : "1,2,3,4,5,6,7",
					convert_fonts_to_spans : false,
					paste_auto_cleanup_on_paste : true,
					paste_remove_styles : true,
					inline_styles : false ,
					plugin_insertdate_dateFormat : "%Y-%m-%d",
					plugin_insertdate_timeFormat : "%H:%M:%S",
					extended_valid_elements : "a[name|class|href|target|title|onclick|style|text-decoration],hr[width|size|noshade],span[align],font[color|size|face]",
					file_browser_callback : "fileBrowserCallBackAbsUrl",
					relative_urls : false,
					convert_urls : false,
					theme_advanced_resize_horizontal : true,
					theme_advanced_resizing : true,
					nonbreaking_force_tab : true,
					apply_source_formatting : true,
			  	width: '100%',
			  	height: '450px',
			  	dialog_type: 'modal',
			  	debug: false
				}
};

function cnxAjaxSendForm(sFormID,sNewAction,aAdditionalArgs) {
	var aData=xajax.getFormValues(sFormID);
	
	if (sNewAction !== undefined) {
		aData['action']=sNewAction;
	}
	if (aAdditionalArgs !== undefined) {
		for (sName in aAdditionalArgs) {
			aData[sName]=aAdditionalArgs[sName];
		}
	}
	cx_server(aData);
};


function triggerTimerEvent(sObjectName,sIdentifier) {
	cx_server({special: 'TimerEvent',
							objectName: sObjectName,
							identifier: sIdentifier});
}

function handleMasterEvent() {
	for (var key in aRegisteredObjects) {
		var oRegObject=aRegisteredObjects[key];
		if ((oRegObject['current']-1000) <= 0) {
			oRegObject['current']=oRegObject['reload'];
			triggerTimerEvent(oRegObject['ObjectName'],oRegObject['Identifier']);
		} else {
			oRegObject['current']-=1000;
		}
	}
}

function addObserver(sObjectName,sIdentifier,sAnimDivID,iDelay) {
	var sUniqueKey=sObjectName+'->'+sIdentifier;
  var aNewArray={nameID: sUniqueKey,
								ObjectName: sObjectName,
								Identifier: sIdentifier,
								AnimDivID: sAnimDivID,
								reload: iDelay,
								current: 0,
								isStopped: false};
  aRegisteredObjects[sUniqueKey]=aNewArray;
}
	
function remObserver(sObjectName,sIdentifier) {
	var sUniqueKey=sObjectName+'->'+sIdentifier;
	
  if (undefined != aRegisteredObjects[sUniqueKey]) {
  	aRegisteredObjects[sUniqueKey]['current']=20000;
  	var sAnimDivID=aRegisteredObjects[sUniqueKey]['AnimDivID'];
  	jQuery('#'+sAnimDivID).stop(true,true);
  	delete(aRegisteredObjects[sUniqueKey]);
  }
}

var aRegisteredObjects=new Array();
var iIntervalID=window.setInterval(handleMasterEvent,1000);


function cnxStartEffect(sDivID,sContent,iEffectID,iDuration) {
	switch(iEffectID) {
	  case 0:
	  case '0':
				jQuery('#'+sDivID).hide(iDuration,
					function() {
						xajax.$(sDivID).innerHTML=sContent;
						jQuery('#'+sDivID).show(iDuration);
					}
				);
			break;
	  case 1:
	  case '1':
	  	jQuery('#'+sDivID).slideUp(iDuration,
							function() {
								xajax.$(sDivID).innerHTML=sContent;
								jQuery('#'+sDivID).slideDown(iDuration);
							}	
						);
	    break;
	 case 2:
	 case '2':
	 		jQuery('#'+sDivID).fadeTo(iDuration,0.0,
					function() {
						xajax.$(sDivID).innerHTML=sContent;
						jQuery('#'+sDivID).fadeTo(iDuration,1.0);
					}
			);
	 		break;
	 case 3:
	 case '3':
	 		jQuery('#'+sDivID).animate({width: '0%'},iDuration,'swing',
	 			function() {
	 				xajax.$(sDivID).innerHTML=sContent;
	 				xajax.$(sDivID).style.width='0%';
	 				jQuery('#'+sDivID).animate({width: '100%'},iDuration);
	 			}
			);
	    break;
	 default:
			break;
	}
}

function cnxCenterOverlay(sDivID,iWidth,iHeight) {
	var element=xajax.$(sDivID);
	var iFullWidth=0;
	var iFullHeight=0;
	var offx=0;
	var offy=0;

	if (window.innerWidth) {
		iFullWidth=window.innerWidth;
	} else {
		if (document.documentElement.clientWidth) {
			iFullWidth=document.documentElement.clientWidth;
		} else {
			iFullWidth=document.body.clientWidth;
		}
	}
	
	if (window.innerHeight) {
		iFullHeight=window.innerHeight;
	} else {
		if (document.documentElement.clientHeight) {
			iFullHeight=document.documentElement.clientHeight;
		} else {
			iFullHeight=document.body.clientHeight;
		}
	}

	if (iWidth < iFullWidth) {
		offx=(iFullWidth - iWidth) / 2;
	}
	if (iHeight < iFullHeight) {
		offy=(iFullHeight - iHeight) / 2;
	}

	element.style.left=parseInt(offx)+'px';
	element.style.top=parseInt(offy)+'px';
	element.style.display='';
}


function showWaitMessage() {
	xajax.$('root_wait').style.display='';
}

function hideWaitMessage() {
	xajax.$('root_wait').style.display='none';
}

function miniModuleCalendarSendData(sTarget,sModule,iHtmlElementID,iDay,sAction) {
	var aArgs={target: sTarget, module: sModule, htmlElementID: iHtmlElementID,day: iDay, action: sAction};
	var sBaseDiv=sTarget+'_'+sModule+'_'+iHtmlElementID;
	var checkboxIsTime=xajax.$(sBaseDiv+'_isTimeActive');
	if (checkboxIsTime != undefined) {
		aArgs['isTimeActive']=xajax.$(sBaseDiv+'_isTimeActive').checked;
		if (aArgs['isTimeActive']) {
			aArgs['hour']=xajax.$(sBaseDiv+'_hour').value;
			aArgs['minute']=xajax.$(sBaseDiv+'_minute').value;
		}
	}
	cx_server(aArgs);
	return false;
}

function fileBrowserCallBack(field_name, url, type, win) {
	//alert("fileBrowserCallBack("+field_name+",url="+url+", type="+type+" win="+win);
	site=getFilepoolUrlQuery(field_name,url,type,false,tinyMCE.activeEditor.settings.langID);
	site+='&onclick='+tinyMCE.activeEditor.settings['onclick'];

  tinyMCE.activeEditor.windowManager.open({
        file : site,
        title : 'Mediapool',
        width : 640,  // Your dimensions may differ - toy around with them!
        height : 320,
        resizable : "yes",
        inline : 1,  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "yes"
    }, {
        window : win,
        input : field_name
    })
};
	
function fileBrowserCallBackAbsUrl(field_name, url, type, win) {
	//alert("fileBrowserCallBackAbsUrl("+field_name+","+url+", type="+type+" win="+win);
	site=getFilepoolUrlQuery(field_name,url,type,true,tinyMCE.activeEditor.settings.langID);
	site+='&onclick='+tinyMCE.activeEditor.settings['onclick'];

  tinyMCE.activeEditor.windowManager.open({
        file : site,
        title : 'Mediapool',
        width : 640,  // Your dimensions may differ - toy around with them!
        height : 320,
        resizable : "yes",
        inline : 1,  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "yes"
    }, {
        window : win,
        input : field_name
    })
};

/*
function getCurrentStyle (element, cssPropertyName) {
   if (window.getComputedStyle) {
     return window.getComputedStyle(element,'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g,"-$1").toLowerCase());
   } else if (element.currentStyle) {
     return element.currentStyle[cssPropertyName];
   }
   else {
     return '';
   }
}
http://groups.google.de/group/de.comp.lang.javascript/msg/dc4d5d2edb515d98?dmode=source&hl=de

window.getComputedStyle(document.getElementById('blockGeneralContent_inner'),'borderWidth')
window.getComputedStyle(document.getElementById('blockGeneralContent_inner'),'').getPropertyValue('padding')

window.getComputedStyle(document.getElementById('blockGeneralContent'),'').width
*/

function getIEStyleWidth(oCurrentStyle,sPropName) {
  if (oCurrentStyle[sPropName] == undefined) {
    return 0;
  }
  var value=oCurrentStyle[sPropName];
  switch(value) {
  	case 'thin':
  		return 1;
  	case 'medium':
  		return 5;
  	case 'thick':
  		return 10;	  		
  }
  return parseInt(value);
}

function getInnerWidthIE(oElement) {
  var innerWidth=oElement.offsetWidth;
  var curStyle=oElement.currentStyle;
  return innerWidth - getIEStyleWidth(curStyle,'borderLeftWidth') - getIEStyleWidth(curStyle,'borderRightWidth') - getIEStyleWidth(curStyle,'paddingLeft') - getIEStyleWidth(curStyle,'paddingRight');
}

function updateWidthGeneralCenter() {
  var generalMain=document.getElementById('blockGeneralContent_inner');
  var blockLeft=document.getElementById('blockLeft');
  var blockRightOne=document.getElementById('blockRightOne');
  var blockRightTwo=document.getElementById('blockRightTwo');
  
  var genMainWidth=0;
  if (window.getComputedStyle) {
	  var width1=parseInt(window.getComputedStyle(blockLeft,'').width);
	  var width2=parseInt(window.getComputedStyle(blockRightOne,'').width);
	  var width3=parseInt(window.getComputedStyle(blockRightTwo,'').width);
	  
    genMainWidth=window.parseInt(window.getComputedStyle(generalMain,'').width);
  } else {
    var width1=blockLeft.offsetWidth;
    var width2=blockRightOne.offsetWidth;
    var width3=blockRightTwo.offsetWidth;
    
  	genMainWidth=getInnerWidthIE(generalMain);
  }
  
  var blockWidth=width1+width2+width3;
  var centerWidth=genMainWidth - blockWidth;

  document.getElementById('Center').style.width=centerWidth+'px';
  window.scrollTo(0,0);
  cx_server({special: 'setGeneralWidth',width: centerWidth});
	}

function getDivInnerWidth(sDivID) {
	var divElement=document.getElementById(sDivID);
	var innerWidth=400;

	if (window.getComputedStyle) {
		innerWidth=parseInt(window.getComputedStyle(divElement,'').width);
	} else {
		innerWidth=getInnerWidthIE(divElement);
	}
	return innerWidth;
}

function configLayoutTargetClick(sBaseDivID,sPicExtension,sCloseExtension,sScrollToExtension) {
	openDisplay(sBaseDivID+sPicExtension,sBaseDivID+sCloseExtension);
	xajax.$(sBaseDivID+sScrollToExtension).scrollIntoView();
	return false;
}

function configLayoutCloseTargetDetails(sBaseDivID,sPicExtension,sCloseExtension,sTableDivID) {
	if (xajax.$(sBaseDivID+sCloseExtension).style.display != 'none') {
		closeDisplay(sBaseDivID+sPicExtension,sBaseDivID+sCloseExtension);
		xajax.$(sTableDivID).scrollIntoView();
	} else {
		openDisplay(sBaseDivID+sPicExtension,sBaseDivID+sCloseExtension);
	}
	return false;
}

/**
 * 
 */
function getQueryCallShowPrintPreviewPDF(sAction,iDispWidth,sTargetName,sModuleName,sEntryParamName,sEntryParamValue) {
	return './pdf.php?module='+sModuleName+'&target='+sTargetName+'&action='+sAction+'&displayWidth='+iDispWidth+'&'+sEntryParamName+'='+sEntryParamValue;
}

function callShowPDF(sTargetName,sModuleName,sEntryParamName,sEntryParamValue) {
	var iDispWidth=getDivInnerWidth(sTargetName+'_inner');
	var url=getQueryCallShowPrintPreviewPDF('showPDF',iDispWidth,sTargetName,sModuleName,sEntryParamName,sEntryParamValue);
	javascript:window.open(url,'showPDF','left=0,top=0,width=800,height=600,location=no,menubar=yes,resizeable=yes,scrollbars=yes');
}

function callShowPrintPreview(sTargetName,sModuleName,sEntryParamName,sEntryParamValue) {
	var iDispWidth=getDivInnerWidth(sTargetName+'_inner')+10;
	var url=getQueryCallShowPrintPreviewPDF('printPreview',iDispWidth,sTargetName,sModuleName,sEntryParamName,sEntryParamValue);
	javascript:window.open(url,'printPreview','left=0,top=0,innerWidth='+iDispWidth+',innerHeight=600,location=no,menubar=yes,resizeable=yes,scrollbars=yes');
}

function callShowVersionView(sFullEditModule,sTargetName,iEntryID,sFieldName,sFieldID) {
	javascript:cx_server({module: sFullEditModule,
												target: sTargetName,
												EntryID: iEntryID,
												fieldname: sFieldName,
												fieldid: sFieldID,
												action: 'showVersionView'});
}

function HideDivOnValueZero(oElement,sVisibleID) {
  var visDing=document.getElementById(sVisibleID);
  if ((oElement.value=='0') | (oElement.value==false)) {
    visDing.style.display='none';
  } else {
    visDing.style.display='';
  }
}

function HideDivOnUnchecked(oElement,sVisibleID) {
  var visDing=document.getElementById(sVisibleID);
  if (visDing) {
	  if ((oElement.checked)) {
	    visDing.style.display='';
	  } else {
	    visDing.style.display='none';
	  }
	}
}


var myHistory=null;
var historyDataArray={};


function theHistory() {
	this.nextUniqueID=0;

	this.historyListener = function(iID) {
		if (historyDataArray[iID] != undefined) {
			cx_server(historyDataArray[iID]);
		}
	};

	this.addEvent=function(aServerArgs,sPermaLink) {
		if (sPermaLink == '') {
			var sID=this.nextUniqueID;
			this.nextUniqueID++;
		} else {
			var sID=sPermaLink;
		}
		window.location.hash=sID;
		updateBrowserPageInfo(sID,'','');
		
		historyDataArray[sID]=aServerArgs;

		unFocus.History.addHistory(sID);
		
		historyDataArray[sID]['TargetAction']='HISTORY';
	};

	this.addNoEvent=function(aServerArgs) {
		window.location.hash='#';
		cx_server(aServerArgs);
	};

	this.addEventT=function(aServerArgs,sPermaLink) {
		this.addEvent(aServerArgs,sPermaLink);

	};
	
	this.addEventALink=function(aServerArgs,refA) {
	  var sPermaLink='';
	  if (refA.title) {
	  	sPermaLink=refA.title;
	  }
	  this.addEvent(aServerArgs,sPermaLink);
	};
	
	this.init=function() {
		this.historyListener(unFocus.History.getCurrent());
	};

	unFocus.History.addEventListener('historyChange',this.historyListener);
}


function updateBrowserPageInfo(sTitle,sDescription,sKeywords) {
	document.title=sTitle;
	var aMetaArray=document.getElementsByTagName('meta');
	var count=aMetaArray.length;
	for (var i=0; i<count; i++) {
		if (aMetaArray[i].name=='description'){
			aMetaArray[i].content=sDescription;
		}
		if (aMetaArray[i].name=='keywords') {
			aMetaArray[i].content=sKeywords;
		}		
	}
}

function callPrivacyPopup(sTarget,sModule,sFieldName) {
	cx_server({target: sTarget, module: sModule,fieldName: sFieldName,action: 'showPrivacyPopup'});	
}

privacyImgages={0: 'lock.png',1: 'lock_break.png',2: 'error.png',3: 'lock_open.png'};

function callPrivacyHandler(sTarget,sModule,sFieldName,iStatus) {
	var sBaseDiv=sTarget+'_'+sModule+'_'+sFieldName;
	var element=document.getElementById(sBaseDiv+'_value');
	if (element) element.value=iStatus;
	
	element=document.getElementById(sBaseDiv+'_privacyImg');
	element.src='./webelements/images/site/icons/'+privacyImgages[iStatus];
	cx_server({target: sTarget, module: sModule,fieldName: sFieldName,action: 'privacyChanged'});
}

function callShopItemShowPictures(iIndex,iShopItemID) {
	alert("veralteter Bildanzeiger!");
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShopItemShowPictures',index: iIndex,ShopItemID: iShopItemID});
}

function clearInputFields(sBaseDiv,aFieldNames) {
	var count=aFieldNames.length;
	for (var i=0; i<count; i++) {
		document.getElementById(sBaseDiv+'_'+aFieldNames[i]).value='';
	}
}

function selectMassInputs(sElementName,bIsChecked) {
	var aElementArray=document.getElementsByName(sElementName);
	var count=aElementArray.length;
	for (var i=0; i<count; i++) {
		aElementArray[i].checked=bIsChecked;
	}
}

function callWriteEmail(iUserID) {
	cx_server({ target: 'generalCenter', module: 'sharedDisplayAnimatedOverlayMessageEditor',UserID: iUserID});
}

function callAddContact(iUserID) {
	cx_server({ target: 'generalCenter', module: 'sharedDisplayAnimatedOverlayAddToContacts',UserID: iUserID});	
}

function callAddWatchlist(iItemID) {
	cx_server({ target: 'generalCenter', module: 'sharedDisplayAnimatedOverlayShopItemAddToWatchlist',ItemID: iItemID});

}

function callShowAGB() {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShowAGB'});
}

function callShowShopAGB(iShopOwnerID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShowShopAGB',ShopOwnerID: iShopOwnerID});
}

function callShowShopDispatchConditions(iShopOwnerID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShowShopDispatchConditions',ShopOwnerID: iShopOwnerID});
}

function callShowShopNoticeOfRescission(iShopOwnerID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShowShopNoticeOfRescission',ShopOwnerID: iShopOwnerID});
}

function callShowShopPortalImprint(iShopOwnerID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShowShopPortalImprint',ShopOwnerID: iShopOwnerID});
}

function callShowDataPrivacyStatement(iShopOwnerID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayShowDataPrivacyStatement',ShopOwnerID: iShopOwnerID});
}

function callShowUserProfileByNick(sNickname,sPermaLink) {
	myHistory.addEvent({target: 'generalCenter',module: 'generalModule',loadModule: 'pageShowUserProfile',Nickname: sNickname},sPermaLink);
}

function callCommentSystemReportComment(iCommentID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayReportComment',CommentID: iCommentID});
}

function callCommentSystemEditComment(iCommentID) {
	cx_server({target: 'generalCenter',module: 'sharedDisplayAnimatedOverlayEditComment',CommentID: iCommentID});
}

function toggleShopPortalPatternPic(oImgElement,sBaseDiv,iAttributeDefID) {
	var oInputElement=document.getElementById(sBaseDiv+'_hid'+iAttributeDefID);
	if (oInputElement.value == 0) {
		oInputElement.value=iAttributeDefID;
		oImgElement.style.opacity=1.0;
	} else {
		oInputElement.value=0;
		oImgElement.style.opacity=0.5;
	}
	if (oInputElement.onchange) {
	  oInputElement.onchange();
	}
}

function toggleShopPortalColorPic(oImgElement,sBaseDiv,iAttributeDefID) {
	var oInputElement=document.getElementById(sBaseDiv+'_hid'+iAttributeDefID);
	if (oInputElement.value == 0) {
		oInputElement.value=iAttributeDefID;
		oImgElement.style.borderColor='#346E6F';
	} else {
		oInputElement.value=0;
		oImgElement.style.borderColor='transparent';
	}
	if (oInputElement.onchange) {
	  oInputElement.onchange();
	}
}

function setShopPortalColorPic(sBaseDiv,iAttrTopicID,iAttributeDefID,bOn) {
	var oInputElement=document.getElementById(sBaseDiv+'_hid'+iAttributeDefID);
	var oImgElement=document.getElementById(sBaseDiv+'_set'+iAttrTopicID+'_'+iAttributeDefID);
	if (bOn) {
		oInputElement.value=iAttributeDefID;
		oImgElement.style.borderColor='#346E6F';
	} else {
		oInputElement.value=0;
		oImgElement.style.borderColor='transparent';
	}
}

function setShopPortalPatternPic(sBaseDiv,iAttrTopicID,iAttributeDefID,bOn) {
	var oInputElement=document.getElementById(sBaseDiv+'_hid'+iAttributeDefID);
	var oImgElement=document.getElementById(sBaseDiv+'_set'+iAttrTopicID+'_'+iAttributeDefID);
	if (bOn) {
		oInputElement.value=iAttributeDefID;
		oImgElement.style.opacity=1.0;
	} else {
		oInputElement.value=0;
		oImgElement.style.opacity=0.5;
	}
	if (oInputElement.onclick) {
	  oInputElement.onclick();
	}
	if (oInputElement.value == 0) {
		oInputElement.value=iAttrTopicID;
		oImgElement.style.borderColor='#346E6F';
	} else {
		oInputElement.value=0;
		oImgElement.style.borderColor='transparent';
	}
	if (oInputElement.onclick) {
	  oInputElement.onclick();
	}
}

function toggleShopPortalOpenClose(sBaseDiv,sIdentifier) {
	var oDivElement=document.getElementById(sBaseDiv+'_div'+sIdentifier);
	if (oDivElement) {
		var picName='';
		if (oDivElement.style.display == 'none') {
			picName='ausgeklappt.png';
			newDisplay='';
		} else {
			picName='eingeklappt.png';
			newDisplay='none';
		}
		oDivElement.style.display=newDisplay;
		var oImgElement=document.getElementById(sBaseDiv+'_img'+sIdentifier);
		if (oImgElement) {
			oImgElement.src='./webelements/images/site/icons/'+picName;
		}
	}
}

function getOpenCloseStat(sBaseDiv,sIdentifier) {
	var oDivElement=document.getElementById(sBaseDiv+'_tr'+sIdentifier);
	if (oDivElement.style.display == 'none') {
		return false;
	}
	return true;
}

function selectMultiDropDown(sDivID,aSelectedValues) {
	var ele=document.getElementById(sDivID);
  var cOptions=ele.length;
  var cSelected=aSelectedValues.length;
  var value=null;
  var IsSelected=false;
  
  for (var i=0; i<cOptions; i++) {
    value=ele.options[i].value;
    IsSelected=false;
    for (var j=0; j<cSelected; j++) {
      if (aSelectedValues[j] == value) {
				IsSelected=true;
      }
    }
    ele.options[i].selected=IsSelected;
  }
}

var MapManager =  {
	MapArray: [],
	geocoder: undefined,

	init: function (oGClientGeocoder) {
		this.MapArray=[];
		this.geocoder=undefined;
	},

	geocodeAddress: function(sAddress,aResponseData) {
		var myGeocoder=new google.maps.Geocoder();

    myGeocoder.geocode( { 'address': sAddress}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        //map.setCenter(results[0].geometry.location);
        aResponseData['action']='geocodeOK';
        aResponseData['geocodeResults']=JSON.stringify(results[0]);
      } else {
        alert("Geocode was not successful for the following reason: "+ status);
        aResponseData['action']='geocodeFailed';
      }
      cx_server(aResponseData);
    });
	},
	
	addMap: function(sIdentifier,sDivID) {
	  if (this.MapArray[sIdentifier] == undefined) {
		  var oDiv=document.getElementById(sDivID);
		  if (oDiv == undefined) alert('nix gut div!');
			var oNewMap=new google.maps.Map(oDiv);
	  	
	  	oNewMap.setCenter(new google.maps.LatLng(51.437475,7.337293), 13);
	  	//oNewMap.addControl(new GSmallMapControl());
	  	//var svOverlay=new GStreetviewOverlay();
			//oNewMap.addOverlay(svOverlay);
			this.MapArray[sIdentifier]=oNewMap;
	  }
	},
	
	addMapAt: function(sIdentifier,sDivID,fLat,fLong,sConfigString) {
	  //if (this.MapArray[sIdentifier] == undefined)
	  var point=new google.maps.LatLng(fLat,fLong);
	  
	  if (sConfigString == null) {
		  var aConfigData = {
			  zoom: 12,
			  center: point,
			  mapTypeId: google.maps.MapTypeId.ROADMAP,
		    navigationControl: true,
		    navigationControlOptions: {style: google.maps.NavigationControlStyle.ZOOM_PAN},
		    mapTypeControl: true,
		    mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
	  		scaleControl: true
			};
			} else {
				eval("var allConfigData="+sConfigString);
				var aConfigData=allConfigData['map'];
				aConfigData['center']=point;
				aConfigData['mapTypeId']=google.maps.MapTypeId.ROADMAP;
			}
		  var oDiv=document.getElementById(sDivID);
		  if (oDiv == undefined) alert('nix gut div!');
			var oNewMap=new google.maps.Map(oDiv,aConfigData);

			if (allConfigData['marker'] != undefined) {
				var markerConfig=allConfigData['marker'];
				markerConfig['position']=point;
				markerConfig['map']=oNewMap;
				var marker=new google.maps.Marker(markerConfig);
			}
			
			//http://maps.google.com/maps/place?cid=3672251040130206662

			var infowindow=new google.maps.InfoWindow({
			    content: allConfigData['marker']['InfoWindowHTML']});

			google.maps.event.addListener(marker, 'click', function() {
				infowindow.open(oNewMap,marker);
  		});

			this.MapArray[sIdentifier]=oNewMap;

	},

	remMap: function (sIdentifier) {
		this.MapArray[sIdentifier]=undefined;
	},
	
	setCenter: function (sIdentifier,GLatLng) {
		if (this.MapArray[sIdentifier] != undefined) {
			this.MapArray[sIdentifier].setCenter(GLatLng);
		}
	},
	
	setMapType: function (sIdentifier,newType) {
		if (this.MapArray[sIdentifier] != undefined) {
			this.MapArray[sIdentifier].setMapType(newType);
		}
	},

	showAddress: function(sIdentifier,address) {
	  if (this.geocoder == undefined) {
			this.geocoder=new GClientGeocoder();
	  }
	  this.geocoder.getLatLng(
		    address,
		    function(point) {
		      if (!point) {
		        alert(address +" not found");
		      } else {
		        MapManager.setCenter(sIdentifier,point);
/*
		        var marker = new GMarker(point);
		        this.MapArray[sIdentifier].addOverlay(marker);
		        marker.openInfoWindowHtml(address);
*/
		      }
		    }
	  );
	}
}
 	
MapManager.init();
/*
	function sendAllOptions(sSelectElement,aSendArgs) {
	  var aSelectedValues=[];
	  if ('string' == typeof sSelectElement) {
	  	sSelectElement=document.getElementById(sSelectElement);
	  }
	  if (!sSelectElement) {
	    alert("sendAllOptions: element nicht gefunden!");
	  } else {
	    var iCount=sSelectElement.options.length;
	    alert("sendAllOptions: iCount="+iCount);
	    for (i=0; i<iCount; i++) {
	      theOption=sSelectElement.options[i];
			  aSelectedValues[aSelectedValues.length]=theOption.value;
			}
	  }
	  aSendArgs['selectedIDs']=aSelectedValues;
	  cx_server(aSendArgs);
	}
*/
	function moveSelectedOptions(sFromElement,sToElement,aSendArgs) {
	  if ('string'== typeof sFromElement) {
	  	sFromElement=document.getElementById(sFromElement);
	  }
	  if ('string'== typeof sToElement) {
	  	sToElement=document.getElementById(sToElement);
	  }
	  
	  var bReady=false;
	  var aSelectedValues=[];
		while (!bReady) {
		  bReady=true;
	  	var iCount=sFromElement.options.length;
	    for (var i=0; i<iCount; i++) {
	      var theOption=sFromElement.options[i];
			  if (theOption.selected) {
			  	aSelectedValues[theOption.value]=theOption.value;
			  	bReady=false;
			  	//oOption=sFromElement.options[i];
			  	sFromElement.remove(i);
			  	try {
						sToElement.add(theOption,null);
					}
					catch (ex) {
						sToElement.add(theOption);
					}
					break;
			  }
	 		}
	 	}
	  aSendArgs['changedIDs']=aSelectedValues;
	  cx_server(aSendArgs);
	}

	function sendTextAsPermaTo(sText,sPermaID) {
		sText=sText.toLowerCase();
		// Konsole: "hal      lo".replace(/ +/gi,"z")
		sText=sText.replace(/ +/gi,"-");
		sText=sText.replace(/[:|\.|\,|;|!|\"|§|$|%|&|/|(|)|=|?|*|+|#|\[|\]|\'|{|}|~|³|²|´|`|>|<]+/g,"");
		sText=replaceGermanUmlauts(sText);
    document.getElementById(sPermaID).value=sText;
	}

	function replaceGermanUmlauts(sText) {
		sText=sText.replace(/ä/g,'ae');
		sText=sText.replace(/ö/g,'oe');
		sText=sText.replace(/ü/g,'ue');
		sText=sText.replace(/Ä/g,'Ae');
		sText=sText.replace(/Ö/g,'Oe');
		sText=sText.replace(/Ü/g,'Ue');
		sText=sText.replace(/ß/g,'ss');
		return sText;
	}

	function callUpdateRestCounter(oInputElement,iMaxCount) {
	  var spanID=document.getElementById(oInputElement.id+'_restCounter');
	  if (spanID) {
			if (oInputElement.value.length > iMaxCount) {
				oInputElement.value=oInputElement.value.substr(0,iMaxCount);
			}
	    spanID.innerHTML=iMaxCount - oInputElement.value.length;
	  }
	}

/*
	function magicRadioButtonDisplayManager(sBaseDiv,iActiveIndex) {
	  for (var i=0; i<3; i++) {
	    if (i == iActiveIndex) {
	    	xajax.$(sBaseDiv+i+'_p').style.display='';
	    } else {
	    	xajax.$(sBaseDiv+i+'_p').style.display='none';
	    }
	  }
	}
*/

	function copyClassOptionToSelect(rElement) {
	  var iSelected=rElement.selectedIndex;
	  var sClassName=rElement.options[iSelected].className;
	  rElement.className=sClassName;
	}

var oUploadifyLocalization={
		iLangID: 44,
		locTexts: {44: {'fileDesc': 'image files','buttonText': 'browse','uploadText': 'browse','msgQueueFull': 'queue is full!'},
													49: {'fileDesc': 'Grafikdateien','buttonText': 'Durchsuchen','uploadText': 'Durchsuchen','msgQueueFull': 'So viele Bilder können nicht hochgeladen werden!'}
							},

		selectLang: function(iLangID) {
		  this.iLangID=parseInt(iLangID);
		},
		
		getText: function(sName) {
		  return this.locTexts[this.iLangID][sName];
		}
};

	function createSWFUploadInst(sTarget,sFileInputExtID,iLangID,sUploadPath,iMaxCountFiles,aOnCompleteArgs,aOnErrorArgs,sAllowExts) {
		oUploadifyLocalization.selectLang(iLangID);

	  if (aOnErrorArgs == undefined) {
			var aOnErrorArgs=[];
		}
	  if (sAllowExts == undefined) var sAllowExts='*.*;';
	  if (iMaxCountFiles == undefined) var iMaxCountFiles=1;

		var aScriptData={'uploadPath': sUploadPath};
		if (aOnCompleteArgs['destFilename'] != undefined) {
			aScriptData['destFilename']=aOnCompleteArgs['destFilename'];
		}
		if (aOnCompleteArgs['prefix'] != undefined) {
			aScriptData['prefix']=aOnCompleteArgs['prefix'];
		}
		var sFileInputID=sTarget+'_'+sFileInputExtID;
		var settings_object={	//upload_url: 'http://www.peperblom.de/swfupload.php',
													//upload_url: 'http://192.168.178.243/conaxisTRUNK/swfupload.php',
													upload_url: aOnCompleteArgs['uploadUrlPHP'],
		 											flash_url: "./webelements/scripts/swfupload/swfupload_fp10/swfupload.swf",
													flash9_url: "./webelements/scripts/swfupload/swfupload_fp9/swfupload_fp9.swf",
													file_post_name : "Filedata",
													use_query_string: false,

													prevent_swf_caching: true,
													post_params: aScriptData,
													file_size_limit: "100 MB",
													file_types: sAllowExts,
													file_types_description: oUploadifyLocalization.getText('fileDesc'),
													file_upload_limit: 100,
													file_queue_limit: iMaxCountFiles,
													file_queued_handler: swfupload_fileQueued,
													file_queue_error_handler: swfupload_fileQueueError,
													file_dialog_complete_handler: swfupload_fileDialogComplete,
													
													custom_settings: {
													          sTarget: sTarget,
													        	sFileInputExtID: sFileInputExtID,
																		cancelButtonId: sFileInputID+'_CancelButton',
																		sFileInputID: sFileInputID,
																		aOnCompleteArgs: aOnCompleteArgs,
																		aScriptData: aScriptData,
																		aOnErrorArgs: aOnErrorArgs,
																		aUploadedFiles: [],
																		isFlashLoaded: false,
																		flash_command_queue: {}
																		},
													upload_success_handler: swfupload_uploadSuccess,
													upload_complete_handler: swfupload_uploadCompleteHandler,
													upload_progress_handler: swfupload_uploadProgress,
													upload_error_handler: swfupload_uploadError,
													upload_start_handler: swfupload_uploadStart,

													swfupload_loaded_handler: swfupload_flashReady,

                          button_placeholder_id: sFileInputID,
													button_image_url: "",
													button_width: "120",
													button_height: "23",
													button_text: '<span class="theFont">'+oUploadifyLocalization.getText('uploadText')+'</span>',
													button_text_style: ".theFont {font-family: verdana; font-size: 12px;}",
													button_text_left_padding: 10,
                          button_text_right_padding: 10,
													button_text_top_padding: 2,
													button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
													button_cursor: SWFUpload.CURSOR.HAND,
													
													queue_complete_handler: swfupload_queueCompleteHandler,
													debug: false
													};
	return new SWFUpload(settings_object);
	};

	function swfupload_fileDialogComplete(numFilesSelected, numFilesQueued) {
		try {
			if (numFilesSelected > 0) {
				jQuery('#'+this.customSettings.cancelButtonId).attr('disabled','');
			}
		} catch (ex) {
		}
	}

	function swfupload_fileQueued(oFile) {
	  try {
	  	jQuery('#'+this.customSettings.cancelButtonId).attr('disabled','');
			var sID='#'+this.customSettings.sFileInputID+'_FileQueue';
			var sInnerID=this.customSettings.sFileInputID+'_queue_'+oFile.id;
			var sCancelButtonDivID=sInnerID+'_cancel';
			var sContent='<div class="uploadQueueOuter" id="'+sInnerID+'"><div id="'+sCancelButtonDivID+'"class="btnCancel"><img onclick="SwfUploadManager.cancelUpload(\''+this.customSettings.sTarget+'\',\''+this.customSettings.sFileInputExtID+'\',\''+oFile.id+'\',true);" src="./webelements/images/site/icons/delete.png" alt=""></div><span>'+oFile.name+'</span>';
			sContent+='<div class="uploadProgress" id="'+sInnerID+'progOuter'+'"><div class="uploadProgressBar" id="'+sInnerID+'prog'+'" style="width: 1px;"></div><div style="clear: both;"></div></div></div>';
			jQuery(sID).append(sContent);
		}
		catch(ex) {
		  this.debug(ex);
		}
	};

	function swfupload_fileQueueError(oFile,errorCode,message) {
		  try {
		    if (errorCode==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
		    	alert(oUploadifyLocalization.getText('msgQueueFull'));
		    } else {
			    alert("fileQueueError: msg="+message);
			    if (oFile) {
			  		swfupload_removeFileFromQueue(this.customSettings.sFileInputID,oFile.id);
					}
				}
			}
			catch(ex) {
			  this.debug(ex);
			}
	};

	function swfupload_uploadProgress(oFileObject,iBytesComplete,iTotalBytes) {
	  try {
			var sInnerID='#'+this.customSettings.sFileInputID+'_queue_'+oFileObject.id+'prog';
			var percent=Math.ceil((iBytesComplete / iTotalBytes) * 100);
			jQuery(sInnerID).css({width: percent+'%'});
		}
		catch(ex) {
		  this.debug(ex);
		}
	};

	function swfupload_removeFileFromQueue(sFileInputID,iId) {
		var sInnerID='#'+sFileInputID+'_queue_'+iId;
		jQuery(sInnerID).remove();
		jQuery(sInnerID+'progOuter').remove();
	}

	function swfupload_uploadSuccess(oFile) {
	  try {
			swfupload_removeFileFromQueue(this.customSettings.sFileInputID,oFile.id);
		}
		catch(ex) {
		  this.debug(ex);
		}
	};

	function swfupload_uploadError(oFile,iErrorCode,sMessage) {
			try {
			  switch(iErrorCode) {
					case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
						swfupload_removeFileFromQueue(this.customSettings.sFileInputID,oFile.id);
						if (this.getStats().files_queued === 0) {
							jQuery('#'+this.customSettings.cancelButtonId).attr('disabled','disabled');
						}
					  break;
		  		default:
						alert("uploadError: error code="+iErrorCode+' message='+sMessage);
						break;
				}
		  }
			catch(ex) {
			  this.debug(ex);
			}
	};

	function swfupload_uploadCompleteHandler(oFile) {
		try {
			if (this.getStats().files_queued === 0) {
				jQuery('#'+this.customSettings.cancelButtonId).attr('disabled','disabled');
			}
			var sUploadedFilename;
			if (this.customSettings.aOnCompleteArgs['destFilename'] != undefined) {
					sUploadedFilename=this.customSettings.aOnCompleteArgs['destFilename']+replaceGermanUmlauts(oFile.name);
			} else {
			  if (this.customSettings.aOnCompleteArgs['prefix'] != undefined) {
			  	sUploadedFilename=this.customSettings.aOnCompleteArgs['prefix']+replaceGermanUmlauts(oFile.name);
			  } else {
					sUploadedFilename=replaceGermanUmlauts(oFile.name);
				}
			}
			this.customSettings.aUploadedFiles[this.customSettings.aUploadedFiles.length]={
							uploadPath: this.customSettings.aScriptData['uploadPath'],
							uploadedFilename: sUploadedFilename,
							fileSize: oFile.size
							};
		}
		catch(ex) {
		  this.debug(ex);
		}
	};

	function swfupload_uploadStart(oFile) {
		var sCancelButtonDivID=this.customSettings.sFileInputID+'_queue_'+oFile.id+'_cancel';
		jQuery('#'+sCancelButtonDivID).css('display','none');
		jQuery('#'+this.customSettings.cancelButtonId).attr('disabled','disabled');
		return true;
	};

	function swfupload_queueCompleteHandler(numFilesUploaded) {
	  try {
			var tempArgs=new Object();
			for (var key in this.customSettings.aOnCompleteArgs) {
				tempArgs[key]=this.customSettings.aOnCompleteArgs[key];
			}
			tempArgs['action']='uploadAllComplete';
			//tempArgs['filesUploaded']=data.filesUploaded;
			tempArgs['aUploadedFiles']=this.customSettings.aUploadedFiles;
			cx_server(tempArgs);
			this.customSettings.aUploadedFiles=[];
		}
		catch(ex) {
		  this.debug(ex);
		  return false;
		}
		return true;
	};
	
	function swfupload_flashReady() {
		this.customSettings.isFlashLoaded=true;
		for (var flashCmd in this.customSettings.flash_command_queue) {
		  if (flashCmd == 'setFileQueueLimit') {
		    this.setFileQueueLimit(this.customSettings.flash_command_queue['setFileQueueLimit']);
		  }
		  if (flashCmd == 'setFileSizeLimit') {
		    this.setFileSizeLimit(this.customSettings.flash_command_queue['setFileSizeLimit']);
		  }
		}
		this.customSettings.flash_command_queue={};
	}

var SwfUploadManager={
	instances: {},

	getInstance: function(sTarget,sFileInputExtID) {
		if (this.instances[sTarget][sFileInputExtID] != undefined) {
		  return this.instances[sTarget][sFileInputExtID];
		}
		return undefined;
	},

	updatePrefix: function(sTarget,sFileInputExtID,sPrefix) {
	  var inst=this.getInstance(sTarget,sFileInputExtID);
	  if (inst) {
	  	inst.customSettings.aOnCompleteArgs['prefix']=sPrefix;
	  	inst.customSettings.aScriptData['prefix']=sPrefix;
	  	//inst.customSettings.post_params['prefix']=sPrefix;
	  	inst.addPostParam('prefix',sPrefix);
	  }
	},

	createInstance: function(sTarget,sFileInputExtID,iLangID,sUploadPath,iMaxCountFiles,aOnCompleteArgs,aOnErrorArgs,sAllowExts) {
	  if (this.instances[sTarget] == undefined) {
	  	this.instances[sTarget]={};
	  }
	  this.instances[sTarget][sFileInputExtID]=createSWFUploadInst(sTarget,sFileInputExtID,iLangID,sUploadPath,iMaxCountFiles,aOnCompleteArgs,aOnErrorArgs,sAllowExts);
	},

	removeInstance: function(sTarget,sFileInputExtID) {
		if (this.instances[sTarget] != undefined) {
			if (this.instances[sTarget][sFileInputExtID] != undefined) {
				this.instances[sTarget][sFileInputExtID].destroy();
			  delete(this.instances[sTarget][sFileInputExtID]);
			  var eleFileQueue=document.getElementById(sTarget+'_'+sFileInputExtID+'_FileQueue');
			  if (eleFileQueue) eleFileQueue.innerHTML='';
			}
		}
	},

	removeTargetInstances: function(sTarget) {
		if (this.instances[sTarget] !== undefined) {
		  for (var sFileInputExtID in this.instances[sTarget]) {
				this.instances[sTarget][sFileInputExtID].destroy();
			  delete(this.instances[sTarget][sFileInputExtID]);
			  var eleFileQueue=document.getElementById(sTarget+'_'+sFileInputExtID+'_FileQueue');
			  if (eleFileQueue) eleFileQueue.innerHTML='';
		  }
		}
	},

	setFileQueueLimit: function(sTarget,sFileInputExtID,iMaxCountFiles) {
	  var instance=this.getInstance(sTarget,sFileInputExtID);
		if (instance != undefined) {
		  if (instance.customSettings.isFlashLoaded) {
		  	instance.setFileQueueLimit(iMaxCountFiles);
		  } else {
				instance.customSettings.flash_command_queue['setFileQueueLimit']=iMaxCountFiles;
			}
		} else {
		  alert("setFileQueueLimit: instance not found!");
		}
	},
	
	setFileSizeLimit: function(sTarget,sFileInputExtID,mSizeLimit) {
	  var instance=this.getInstance(sTarget,sFileInputExtID);
		if (instance != undefined) {
		  if (instance.customSettings.isFlashLoaded) {
		  	instance.setFileSizeLimit(mSizeLimit);
		  } else {
				instance.customSettings.flash_command_queue['setFileSizeLimit']=iMaxCountFiles;
			}
		}
	},

	startUpload: function(sTarget,sFileInputExtID) {
	  var instance=this.getInstance(sTarget,sFileInputExtID);
		if (instance != undefined) {
			instance.startUpload();
		}
	},
	cancelUpload: function(sTarget,sFileInputExtID,sQueueID,bTriggerErrorEvent) {
		var instance=this.getInstance(sTarget,sFileInputExtID);
		if (instance != undefined) {
			instance.cancelUpload(sQueueID,bTriggerErrorEvent);
		}
	},

	cancelQueue: function(sTarget,sFileInputExtID) {
	  var instance=this.getInstance(sTarget,sFileInputExtID);
		if (instance != undefined) {
			instance.cancelQueue();
		}
	}
};


/* Klassen/Funktionen für Bildanzeige im Overlay */
function animImageOverblending(sBaseDiv,sModule,sNewImage,iWidth,iHeight,iDeltaWidth,iDeltaHeight) {
	var contentEle=document.getElementById(sBaseDiv+'_contentDiv');
	contentEle.style.width='auto';
	contentEle.style.height='auto';
	jQuery('#'+sBaseDiv+'_contentDiv').animate(
		{opacity: 0.0},
		{complete: function() {
				var image=document.getElementById(sBaseDiv+'_img');
				image.src=sNewImage;
				jQuery('#'+sBaseDiv+'_innerDiv').animate(
				{width: iWidth+'px',height: iHeight+'px',left: '+='+iDeltaWidth+'px',top: '+='+iDeltaHeight+'px'},
				{complete: function () {
									var contentEleStyle=document.getElementById(sBaseDiv+'_contentDiv').style;

											//contentEleStyle.width=iWidth+'px';
											//contentEleStyle.height=iHeight+'px';
											jQuery('#'+sBaseDiv+'_contentDiv').animate({opacity: 1.0});
															} });
			}
		}
		);
}

function animContentFadeOut(sBaseDiv,sModule,aAddArgs) {
	jQuery('#'+sBaseDiv+'_contentDiv').animate(
		{opacity: 0.0},
		{complete: function() {
			aAddArgs['target']='generalCenter';
			aAddArgs['module']=sModule;
			aAddArgs['action']='fadeOutCompleted';
			cx_server(aAddArgs);
			}});
}

function animContentFadeIn(sBaseDiv) {
	jQuery('#'+sBaseDiv+'_contentDiv').animate({opacity: 1.0});
}

function animKillContentAndSend(sBaseDiv,sModule,aAddArgs) {
	var element=document.getElementById(sBaseDiv+'_contentDiv');
	element.innerHTML='';
	element.style.width='auto';
	element.style.height='auto';
	//cx_server({target: 'generalCenter',module: sModule,action: 'contentKilled'});
	aAddArgs['target']='generalCenter';
	aAddArgs['module']=sModule;
	aAddArgs['action']='closeEnded';
	cx_server(aAddArgs);
}

function animFadeOutAndKillContent(sBaseDiv,sModule,aAddArgs) {
	jQuery('#'+sBaseDiv+'_contentDiv').animate(
		{opacity: 0.0},
		{complete: function() {animKillContentAndSend(sBaseDiv,sModule,aAddArgs);} }
		);
}

function animOverlayInit(sBaseDiv,sModule,iDestWidth,iDestHeight,iOldWidth,iOldHeight,iOffW,iOffH) {
	var element=document.getElementById(sBaseDiv+'_innerDiv');
	element.style.width=iOldWidth;
	element.style.height=iOldHeight;
	cnxCenterOverlay(sBaseDiv+'_innerDiv',iOldWidth,iOldHeight);

	jQuery('#'+sBaseDiv).animate({opacity: 0.7},{queue: false});

	var deltaw=((iOldWidth - iDestWidth) /2);
	var deltah=((iOldHeight - iDestHeight) /2);

	jQuery('#'+sBaseDiv+'_innerDiv').animate(
	{width: iDestWidth+'px',height: iDestHeight+'px',left: '+='+deltaw+'px',top: '+='+deltah+'px'},
	{complete: function() {
			var element=document.getElementById(sBaseDiv+'_contentDiv');
			element.style.width=(iDestWidth-iOffW)+'px';
			element.style.height=(iDestHeight-iOffH)+'px';
			element.style.opacity=0.0;
			element.style.display='';
			jQuery('#'+sBaseDiv+'_contentDiv').animate({opacity: 1.0});
			cx_server({module: sModule,target: 'generalCenter',action: 'showNext'})
		}});
}

function animOverlayExit(sBaseDiv,sModule,iDestWidth,iDestHeight,iOldWidth,iOldHeight) {
	var anim_duration=1000;

	jQuery('#'+sBaseDiv+'_contentDiv').animate({opacity: 0.0},
		{complete:
		function () {
			var element=document.getElementById(sBaseDiv+'_contentDiv');
			element.style.width='auto';
			element.style.height='auto';
		  element.innerHTML='';

			var deltaw=((iOldWidth - iDestWidth) /2);
			var deltah=((iOldHeight - iDestHeight) /2);

			jQuery('#'+sBaseDiv).animate({opacity: 0.0},{duration: anim_duration});
			jQuery('#'+sBaseDiv+'_innerDiv').animate(
				{width: iDestWidth+'px',height: iDestHeight+'px',left: '+='+deltaw+'px',top: '+='+deltah+'px'},
				{duration: anim_duration,complete: function() {
					cx_server({module: sModule,target: 'generalCenter',action: 'closeEnded'});
					}});
		}
	});
};

//var oPictureShow=new PictureShow();
function PictureShowDimension(iWidth,iHeight) {
	//this.iAddWidth=20;
	this.iAddWidth=0;
	//this.iAddHeight=45;
	this.iAddHeight=25;
	this.iWidth=iWidth;
	this.iHeight=iHeight;

	//this.debug("construct set: "+this.iWidth+","+this.iHeight);

	this.set=function(iWidth,iHeight) {
	  //this.debug("set: "+iWidth+","+iHeight);
		this.iWidth=iWidth;
		this.iHeight=iHeight;
		//this.debug("call getDimensionsInner");
		var oDimInner=getDimensionsInner();
		//var maxW=oDimInner.getWidth() - this.iAddWidth;
		//var maxH=oDimInner.getHeight() - this.iAddHeight;
		var maxW=oDimInner.getWidth();
		var maxH=oDimInner.getHeight();
		//this.debug("max is: "+maxW+","+maxH);

		if (iWidth >maxW) {
		  var fak=maxW/iWidth;
		  this.iWidth=parseInt(iWidth/fak);
		  this.iHeight=parseInt(iHeight/fak);
		  //this.debug("setting (width) to: "+this.iWidth+","+this.iHeight+" fak="+fak);
		}
		
		if (iHeight>maxH) {
		  var fak=maxH/iHeight;
		  this.iWidth=parseInt(iWidth/fak);
		  this.iHeight=parseInt(iHeight/fak);
		  //this.debug("setting (height) to: "+this.iWidth+","+this.iHeight+" fak="+fak);
		}
	};

	this.getWidth=function() {
	  return this.iWidth;
	};

	this.getHeight=function() {
	  return this.iHeight;
	};

	this.getTotalWidth=function() {
	  return this.iWidth + this.iAddWidth;
	};

	this.getTotalHeight=function() {
	  return this.iHeight + this.iAddHeight;
	};

	this.getMaxPicWidth=function() {
	  return parseInt((this.iWidth - this.iAddWidth - 10) * 0.9);  // 5px Border je links und rechts
	}

	this.getMaxPicHeight=function() {
	  return parseInt((this.iHeight - this.iAddHeight - 10) * 0.9);  // 5px Border je oben und unten
	}

	this.debug=function(sText) {
/*
	  if (console) {
		  if (console.log) {
		    console.log(sText);
		  }
	  }
*/
	};
};


function getDimensionsInner() {
  if( typeof( window.innerWidth ) =='number') {
    //Non-IE
    //return new PictureShowDimension(window.innerWidth,window.innerHeight);
    return new PictureShowDimension(document.documentElement.clientWidth,document.documentElement.clientHeight);
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return new PictureShowDimension(document.documentElement.clientWidth,document.documentElement.clientHeight);
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return new PictureShowDimension(document.body.clientWidth,document.body.clientHeight);
  }
	return new PictureShowDimension(0,0);
}

function PictureShow(sBaseDir,aFilenames,iIndex,sTitle) {
	this.sBaseDir=sBaseDir;
	this.aFilenames=aFilenames;
	this.iIndex=parseInt(iIndex);
	this.sTitle=sTitle;
	this.oDimensionInner=getDimensionsInner();
	this.iCenterX=parseInt(this.oDimensionInner.getWidth()/2);
	this.iCenterY=parseInt(this.oDimensionInner.getHeight()/2);
	this.oDimension=new PictureShowDimension(0,0);
	this.iSeconds=0;
	this.iInterval=0;
	this.aImages=[];
	this.isAnimRunning=false;
	this.isClosing=false;
	this.settings={};

PictureShow.prototype.preloadImage=function(iIndex) {
	this.debug("preloadImage("+iIndex+")");
	
	if (this.aImages[iIndex] == undefined) {
		this.debug("initiated preloadImage("+iIndex+")");
		this.aImages[iIndex]=new Image();
		this.aImages[iIndex].src=this.getMyImage(iIndex);
	}
};

PictureShow.prototype.set=function(sSettingName,mData) {
	this.settings[sSettingName]=mData;
}

PictureShow.prototype.startAnim=function(iSeconds) {
		if (iSeconds != 'undefined') {
			this.iSeconds=parseInt(iSeconds,10);
		}
		// Preload aktuelles Image und nächsten und vorheriges, in dieser Reihenfolge
		this.preloadImage(this.iIndex);
		this.preloadImage(this.getNextIndex(+1));
		this.preloadImage(this.getNextIndex(-1));
		// alle anderen Images laden, falls noch nicht geschehen
		var iCount=this.aFilenames.length;
		for (var i=0; i<iCount; i++) {
			this.preloadImage(i);
		}
	  this.initLayout();
	};

	this.goNext=function() {
	  if (!this.isAnimRunning) {
		  this.iTimeout=0;
			this.overblendImage(+1);
		}
	};
	
	this.goPrev=function() {
		if (!this.isAnimRunning) {
			this.overblendImage(-1);
		}
	};

	return true;
};


PictureShow.prototype.debug=function(sText) {
	try {
		console.log(sText);
	} catch(ex) {
	}
};

PictureShow.prototype.getNextIndex=function(iDeltaIndex) {
	if (iDeltaIndex < 0) iDeltaIndex=this.aFilenames.length+iDeltaIndex;
	return ((this.iIndex+iDeltaIndex) % this.aFilenames.length);
};

PictureShow.prototype.changeIndex=function(iDeltaIndex) {
	this.iIndex=this.getNextIndex(iDeltaIndex);
	this.debug("changeIndex: deltaIndex="+iDeltaIndex+" iIndex="+this.iIndex);
};

PictureShow.prototype.getCurrentIndex=function() {
	return this.iIndex;
}

PictureShow.prototype.hasDescription=function() {
	if (oPictureShow.settings['desc']) {
		if (oPictureShow.settings['desc'].length > 0) return true;
	}
	return false;
}

PictureShow.prototype.getCurrentDescription=function() {
	if (oPictureShow.settings['desc']) {
		if (oPictureShow.settings['desc'][this.iIndex] != 'undefined') {
			return oPictureShow.settings['desc'][oPictureShow.iIndex];
		}
	}
	return '';
}

PictureShow.prototype.onAnimationFinished=function() {
	this.isAnimRunning=false;
	if (this.isClosing) {
	  this.executeClose();
	}
}

PictureShow.prototype.close=function() {
	this.isClosing=true;
	jQuery('#PictureShow_contentDiv').stop(true,true);
	jQuery('#PictureShow_innerDiv').stop(true,true);
	jQuery('#PictureShow_img').stop(true,true);
	if (this.isAnimRunning) {
	} else {
		this.executeClose();
	}
}

PictureShow.prototype.executeClose=function() {
	if (this.iTimeout > 0) {
		clearTimeout(this.iTimeout);
		this.iTimeout=0;
	}

	var anim_duration=1000;
	var oMyDimension=this.oDimension;
	//jQuery('#PictureShowPopup').animate({opacity: 0},{queue: false});
	this.isAnimRunning=true;
	jQuery('#PictureShow_contentDiv').animate({opacity: 0.0},
		{complete:
		function () {
			var element=document.getElementById('PictureShow_contentDiv');
			element.style.width='auto';
			element.style.height='auto';
		  element.innerHTML='';

		var iDestWidth=0;
		var iDestHeight=0;

		var iOldWidth=oMyDimension.getTotalWidth();
		var iOldHeight=oMyDimension.getTotalHeight();
		var deltaw=((iOldWidth - iDestWidth) /2);
		var deltah=((iOldHeight - iDestHeight) /2);

		jQuery('#PictureShow').animate({opacity: 0.0},{duration: anim_duration});
		jQuery('#PictureShow_innerDiv').animate(
			{width: iDestWidth+'px',height: iDestHeight+'px',left: '+='+deltaw+'px',top: '+='+deltah+'px'},
			{duration: anim_duration,complete: function() {
				jQuery('#PictureShow_innerDiv').remove();
				jQuery('#PictureShowBG').remove();
				oPictureShow.onAnimationFinished();
				}});
		}
	});
};

PictureShow.prototype.getMyImage=function(iTheIndex) {
	  return this.sBaseDir+this.aFilenames[iTheIndex];
	};

PictureShow.prototype.getTitle=function() {
	return this.sTitle;
};

PictureShow.prototype.getBaseDir=function() {
	return this.sBaseDir;
};

PictureShow.prototype.getHTML=function() {
	  var sControlButton='<div class="PictureShowControlDiv" style="">'+
													'<div class="PictureShowControlPrevDiv">'+
														'<div class="PictureShowControlPrev" onclick="oPictureShow.goPrev();"></div>'+
													'</div>'+
													'<div class="PictureShowControlNextDiv">'+
														'<div class="PictureShowControlNext" onclick="oPictureShow.goNext();"></div>'+
													'</div>'+
												'</div>';
		var left=(this.iCenterX - 5);
		var top=(this.iCenterY - 17);

		var width=this.oDimension.getTotalWidth();
		var height=this.oDimension.getTotalHeight();

		var sDescDivDisplayStyle=(this.hasDescription()) ? '' : 'none';
		return	'<div class="PictureShowBG" style="" id="PictureShowBG">'+
							'<div class="PictureShowPopup" style="" id="PictureShowPopup"></div>'+
						'</div>'+
			'<div class="PictureShowInner" style="width: '+width+'px; height: '+height+'px; left: '+left+'px; top: '+top+'px;" id="PictureShow_innerDiv">'+
				'<div class="PictureShowTitleBar" style="">'+
					'<div class="PictureShowTitle" style=""><b>'+this.getTitle()+'</b></div>'+
					'<div class="PictureShowCloseButton" onclick="oPictureShow.close();"></div>'+
					'<div style="clear: both; height: 0px;"></div>'+
				'</div>'+
		    '<div class="PictureShowContentDiv" style="" id="PictureShow_contentDiv">'+
		      sControlButton+
					'<img class="PictureShowImg" alt="" src="'+this.getMyImage(this.getCurrentIndex())+'" style="" id="PictureShow_img">'+
					//'<div id="PictureShowDescDiv" style="display: '+sDescDivDisplayStyle+';"><div id="PictureShowDesc"></div></div>'+
				'</div>'+
				'<div id="PictureShowDescDiv" style="display: '+sDescDivDisplayStyle+';"><div id="PictureShowDesc"></div></div>'+
			'</div>';
	};

PictureShow.prototype.initLayout=function() {
	  var temp='';
	  var iCount=this.aFilenames.length;
	  for (var i=0; i<iCount; i++) {
	    temp=temp+this.aFilenames[i]+"\n";
	  }
	  this.debug("initLayout sBaseDir="+this.getBaseDir()+"\ntitle="+this.getTitle()+" files are:\n"+temp);

		jQuery('#root').append(this.getHTML());

		this.debug("initLayout iIndex="+this.iIndex);
		var oImage=this.aImages[this.iIndex];

		oImage.onload=function() {oPictureShow.exeStartInit(oImage,true);};
		oImage.onerror=function() {oPictureShow.exeStartInit(oImage,false);};
		if (oImage.complete == true) {
			oPictureShow.exeStartInit(oImage,true);
		}
		this.debug("waiting for Image: "+oImage.src);
};


PictureShow.prototype.exeStartInit=function(oImage,bIsLoaded) {
		var iOldWidth=this.oDimension.getTotalWidth();
		var iOldHeight=this.oDimension.getTotalHeight();

		this.isAnimRunning=true;
		jQuery('#PictureShowBG').animate({opacity: 0.65},{queue: false});
		//jQuery('#PictureShowPopup').animate({opacity: 0.7},{queue: false});

		var realWidth=oImage.width;
		var realHeight=oImage.height;

		if (realWidth > this.oDimensionInner.getMaxPicWidth()) {
			this.debug("exeStartInit: clipping from: "+realWidth+","+realHeight);
		  var fak=this.oDimensionInner.getMaxPicWidth() / realWidth;
		  realWidth=parseInt(realWidth * fak);
		  realHeight=parseInt(realHeight * fak);
		  this.debug("exeStartInit: clipping to: "+realWidth+","+realHeight);
		}

		if (realHeight > this.oDimensionInner.getMaxPicHeight()) {
			this.debug("exeStartInit: clipping from: "+realWidth+","+realHeight);
			var fak=this.oDimensionInner.getMaxPicHeight() / realHeight;
		  realWidth=parseInt(realWidth * fak);
		  realHeight=parseInt(realHeight * fak);
		  this.debug("exeStartInit: clipping to: "+realWidth+","+realHeight);
		}

		this.oDimension.set(realWidth,realHeight); // später die Breite des nächsten Bildes!

		var iDestWidth=this.oDimension.getTotalWidth();
		var iDestHeight=this.oDimension.getTotalHeight();

		var deltaw=parseInt((iOldWidth - iDestWidth) /2);
		var deltah=parseInt((iOldHeight - iDestHeight ) /2);

	jQuery('#PictureShow_innerDiv').animate(
	{width: iDestWidth+'px',height: iDestHeight+'px',left: '+='+deltaw+'px',top: '+='+deltah+'px'},
	{complete: function() {
			var image=document.getElementById('PictureShow_img');
			image.src=oImage.src;
			
			document.getElementById('PictureShowDescDiv').innerHTML=oPictureShow.getCurrentDescription();
			//image.title=oPictureShow.getCurrentDescription();

			var element=document.getElementById('PictureShow_contentDiv');
			element.style.opacity=0.0;
			jQuery('#PictureShow_contentDiv').animate({opacity: 1.0});
			oPictureShow.onAnimationFinished();
		}});
		
		if (this.iSeconds > 0) {
		  if (!this.isClosing) {
		  	this.iTimeout=setTimeout("oPictureShow.goNext()",this.iSeconds * 1000);
		  }
		}
};

PictureShow.prototype.overblendImage=function(iDeltaIndex) {

	this.changeIndex(iDeltaIndex);
	var oImage=this.aImages[this.iIndex];


	oImage.onload=function() {oPictureShow.exeOverblendingImage(oImage,true);};
	oImage.onerror=function() {oPictureShow.exeOverblendingImage(oImage,false);};
	if (oImage.complete == true) {
		oPictureShow.exeOverblendingImage(oImage,true);
	}
};

PictureShow.prototype.exeOverblendingImage=function(oImage,bIsLoaded) {
	var contentEle=document.getElementById('PictureShow_contentDiv');
	contentEle.style.width='auto';
	contentEle.style.height='auto';

	var iOldWidth=this.oDimension.getWidth();
	var iOldHeight=this.oDimension.getHeight();


	var realWidth=oImage.width;
	var realHeight=oImage.height;

	if (realWidth > this.oDimensionInner.getMaxPicWidth()) {
		this.debug("exeOverblendingImage: clipping from: "+realWidth+","+realHeight);
	  var fak=this.oDimensionInner.getMaxPicWidth() / realWidth;
	  realWidth=parseInt(realWidth * fak);
	  realHeight=parseInt(realHeight * fak);
	  this.debug("exeOverblendingImage: clipping to: "+realWidth+","+realHeight);
	}

	if (realHeight > this.oDimensionInner.getMaxPicHeight()) {
		this.debug("exeOverblendingImage: clipping from: "+realWidth+","+realHeight);
		var fak=this.oDimensionInner.getMaxPicHeight() / realHeight;
	  realWidth=parseInt(realWidth * fak);
	  realHeight=parseInt(realHeight * fak);
	  this.debug("exeOverblendingImage: clipping to: "+realWidth+","+realHeight);
	}

	this.oDimension.set(realWidth,realHeight);

	var iDestWidth=this.oDimension.getTotalWidth();
	var iDestHeight=this.oDimension.getTotalHeight();

	var iDeltaWidth=parseInt((iOldWidth - this.oDimension.getWidth()) /2);
	var iDeltaHeight=parseInt((iOldHeight - this.oDimension.getHeight()) /2);

	this.isAnimRunning=true;
	jQuery('#PictureShow_contentDiv').animate(
		{opacity: 0.0},
		{complete: function() {
				var image=document.getElementById('PictureShow_img');
				image.src=oImage.src;
				document.getElementById('PictureShowDescDiv').innerHTML=oPictureShow.getCurrentDescription();
				//image.title=oPictureShow.getCurrentDescription();

				jQuery('#PictureShow_innerDiv').animate(
				{width: iDestWidth+'px',height: iDestHeight+'px',left: '+='+iDeltaWidth+'px',top: '+='+iDeltaHeight+'px'},
				{complete: function () {
									var contentEleStyle=document.getElementById('PictureShow_contentDiv').style;

											//contentEleStyle.width=iWidth+'px';
											//contentEleStyle.height=iHeight+'px';
											jQuery('#PictureShow_contentDiv').animate(
												{	opacity: 1.0},
												{	complete: function() {
																				if (oPictureShow.iSeconds > 0) {
																				  if (!oPictureShow.isClosing) {
																						oPictureShow.iTimeout=setTimeout("oPictureShow.goNext()",oPictureShow.iSeconds * 1000);
																					}
												  							}
												  							oPictureShow.onAnimationFinished();
												  							}
												});
															} });
			}
		}
		);
};

function sortableUpdate(event,ui) {
	window.dataUI=ui;
	console.log("event "+ui.item[0].parentNode);
	var jEle=jQuery(ui.item[0].parentNode);
	var sortDataID=jEle.sortable("toArray");
	console.log("sortData="+sortDataID.toString());
	var iCount=sortDataID.length;
	for (var iDir=0; iDir<iCount; iDir++) {
	  jQuery('#'+sortDataID[iDir]+'_Dir').val(iDir);
	}
	//var sortArray=ui.item.toArray();
	//console.log("event "+sortArray.toString());
}
