function cnxs_highlight_text(name) { 
	xajax.$(name).className = "inputText_Hightlight";
	// new Effect.Highlight(xajax.$(name)); 
}

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;
}

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() {
	var anzForms=document.forms.length;
	
	for (f=0; f<anzForms; f++) {
		var formular=document.forms[f];
		var anzahl=formular.length;
		for (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 (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';
}  

function getTinyStandardConfig(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 : "style,table,save,advhr,advimage,advlink,contextmenu,paste,emotions,iespell,insertdatetime,preview,searchreplace,print,fullscreen,media,inlinepopups",
				  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",
					theme_advanced_buttons3_add : "emotions,iespell,advhr",
					
					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,
					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 : 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);

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,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,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,
					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 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 : "style,save,contextmenu,emotions,iespell,insertdatetime,preview",
//				  theme_advanced_buttons1_add_before: "cut,copy,paste,pastetext,pasteword,separator",
					theme_advanced_buttons1_add : "styleselect",
					theme_advanced_buttons2_add_before: "",
//				  theme_advanced_buttons2_add : "separator,forecolor,backcolor,print,",
//					theme_advanced_buttons3_add_before : "tablecontrols",
					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",
					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 : false,
					convert_urls : false,
				  dialog_type : "modal"
					//,file_browser_callback : "fileBrowserCallBack"
  			}
};

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,paste,pastetext,pasteword,separator",
					theme_advanced_buttons3_add : "iespell,media,advhr,separator,forecolor,backcolor,separator,cleanup,removeformat,preview",
					theme_advanced_buttons4 : "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,
					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;
  /* delete aRegisteredObjectsStopped[sAnimDivID]; */
}
	
function remObserver(sObjectName,sIdentifier) {
/*
	window.clearInterval(window.iIntervalID);
	iIntervalID=0;
*/
	var sUniqueKey=sObjectName+'->'+sIdentifier;
	
  if (undefined !== aRegisteredObjects[sUniqueKey]) {
  	aRegisteredObjects[sUniqueKey]['current']=20000;
  	var sAnimDivID=aRegisteredObjects[sUniqueKey]['AnimDivID'];
  	/* aRegisteredObjectsStopped[sAnimDivID]=true; */
  	jQuery('#'+sAnimDivID).stop(true,true);
  	delete aRegisteredObjects[sUniqueKey];
  }
/*
  window.iIntervalID=window.setInterval(handleMasterEvent,1000);
*/
}

var aRegisteredObjects=new Array();
/* var aRegisteredObjectsStopped=new Array(); */
var iIntervalID=window.setInterval(handleMasterEvent,1000);


function cnxStartEffect(sDivID,sContent,iEffectID,iDuration) {
	switch(iEffectID) {
	  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:
			jQuery('#'+sDivID).hide(iDuration,
				function() {
					xajax.$(sDivID).innerHTML=sContent;
					jQuery('#'+sDivID).show(iDuration);
				}
			);
			break;
	}
}

function cnxCenterOverlay(sDivID,iWidth,iHeight) {
	var element=$(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);
	}

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);
	$(sBaseDivID+sScrollToExtension).scrollIntoView();
	return false;
}

function configLayoutCloseTargetDetails(sBaseDivID,sPicExtension,sCloseExtension,sTableDivID) {
	if ($(sBaseDivID+sCloseExtension).style.display != 'none') {
		closeDisplay(sBaseDivID+sPicExtension,sBaseDivID+sCloseExtension);
		$(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';
/*
		if (console.log) {
			console.log("addEvent("+aServerArgs+","+sPermaLink+") location: "+location);
		}
*/
	};

	this.addNoEvent=function(aServerArgs) {
		window.location.hash='#';
		cx_server(aServerArgs);
	};

	this.addEventT=function(aServerArgs,sPermaLink) {
/*
		if (console.log) {
			console.log("addEventT("+aServerArgs+","+sPermaLink+") location: "+location);
		}
*/
	
		this.addEvent(aServerArgs,sPermaLink);

	};
	
	this.addEventALink=function(aServerArgs,refA) {
	  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 i,count=aMetaArray.length;
	for (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 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'});
					}});
		}
	});
}

function callShopItemShowPictures(iIndex,iShopItemID) {
	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;
  
  //console.log("selectMultiDropDown");
  for (var i=0; i<cOptions; i++) {
    value=ele.options[i].value;
    console.log("selectMultiDropDown value="+value);
    IsSelected=false;
    for (var j=0; j<cSelected; j++) {
      if (aSelectedValues[j] == value) {
				IsSelected=true;
      	console.log("selectMultiDropDown value="+value);
      }
    }
    ele.options[i].selected=IsSelected;
  }
}

var MapManager =  {
	MapArray: [],
	geocoder: undefined,

	init: function (oGClientGeocoder) {
		this.MapArray=[];
		this.geocoder=undefined;
	},

	addMap: function(sIdentifier,sDivID) {
	  if (this.MapArray[sIdentifier] == undefined) {
			var oNewMap=new GMap2(document.getElementById(sDivID));
	  	
	  	oNewMap.setCenter(new GLatLng(51.437475,7.337293), 13);
	  	oNewMap.addControl(new GSmallMapControl());
	  	var svOverlay=new GStreetviewOverlay();
			oNewMap.addOverlay(svOverlay);
			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();
