 
//****************************************
//* Initalize Variables                  *
//****************************************


// Commandbar
// var DSExplorer=new Object();
// top.DSExplorer='test';
// if (top.DSExplorer.GUIPlaces==undefined)
//	top.stylebase=new Array();
DSExplorer = new Object()
DSExplorer.GUIPlace=new Object();
DSExplorer.Workflow=new Object();
//DSExplorer.GUIPlace.CommandBar='';
//DSExplorer.GUIPlace.ContextMenu='';
//DSExplorer.GUIPlace.Paging='';
// alert(Object.keys(DSExplorer.GUIPlace));
//alert(top.DSExplorer.GUIPlaces.CommandBar);

// Set GUI Object
var dsnavname='undefined';
DSGUIObject_Active=new Object();

// 2008-09-27 [Ap]
var DS= {};

// Set Language Variables
function DSLang(variable) {
	var thisvariable=DSJS.LCase(variable);
	var returnvariable=DSLangArray['lang_'+thisvariable];
	if (returnvariable==undefined)
		returnvariable='undefined: '+thisvariable;

	return returnvariable;
}

//****************************************
//* END Initalize Variables              *
//****************************************

var dcbe = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null;
var naviuser = navigator.userAgent.toLowerCase();
var opera = !!(window.opera && document.getElementById);
var opera6 = opera && !document.defaultView;
var opera7 = opera && !opera6;
var ie = (navigator.appName == "Microsoft Internet Explorer");
var ns6 = !opera && !document.all && document.documentElement;
//ns6 = (!opera && document.defaultView && typeof document.defaultView.getComputedStyle != 'undefined');
var w3c = !ie && !ns6 && !opera && document.getElementById;


function DSInit(){
	dcbe = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null;
	naviuser = navigator.userAgent.toLowerCase();
	opera = !!(window.opera && document.getElementById);
	opera6 = opera && !document.defaultView;
	opera7 = opera && !opera6;
	ie = naviuser.indexOf("msie") != -1 && document.all && dcbe && !opera;
	ns6 = !opera && !document.all && document.documentElement;
	//ns6 = (!opera && document.defaultView && typeof document.defaultView.getComputedStyle != 'undefined');
	w3c = !ie && !ns6 && !opera && document.getElementById;	
}


if(window.name==null || window.name=='')
	window.name='ds';

var Engine = {
  detect: function() {
    var UA = navigator.userAgent;
    this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
    this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
    this.isOpera = /Opera/.test(UA);
    this.isMSIE  = (/MSIE/.test(UA) && !this.isOpera);
		this.isMSIE7 = this.isMSIE && (UA.indexOf('MSIE 7') != -1);
  }
}

Engine.detect();



Position.getPageSize = function() {
  var xScroll, yScroll;

  if (window.innerHeight && window.scrollMaxY) {  
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }

  var windowWidth, windowHeight;
  if (self.innerHeight) { // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  } 

  // for small pages with total height less then height of the viewport
  pageHeight = Math.max(windowHeight, yScroll);

  // for small pages with total width less then width of the viewport
  pageWidth = Math.max(windowWidth, xScroll);

  return { page: { width: pageWidth, height: pageHeight }, window: { width: windowWidth, height: windowHeight } };
}


function NiftyCheck(){
	if(!document.getElementById || !document.createElement)
		return(false);
	var b=navigator.userAgent.toLowerCase();
	if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
		return(false);
	return(true);
}



/* DSJS - ColdFusion Functions for JavaScript
	Methods: 	
		Abs(number)
		ArrayAppend(array, value)
		ArrayLen(array)
		ArraySort(array, sort_type [, sort_order ])
		ArrayToList(array [, delimiter ])
		Ceiling(number)
		Compare(string1, string2)
		CompareNoCase(string1, string2)		
		DateDiff(datepart, date1, date2)
		DecimalFormat(number)
		DollarFormat(number)
		Find(substring, string)
		FindNoCase(substring, string)
		Insert(substring, string, position)
		IsDate(date)
		IsNumeric(string)
		LCase(string)
		Left(string, count)
		Len(sting)
		ListAppend(list, value, [, delimiters])
		ListDeleteAt(list, position [, delimiters ])
		ListFind(list, value [, delimiters ]))
		ListFindNoCase(list, value [, delimiters ]))
		ListGetAt(list, position [, delimiters ]))
		ListLen(list [, delimiters])
		ListSetAt
		ListToArray(list [, delimiters])
		LTrim(string)
		Mid(string, start, count)
		Replace(string, substring1, substring2 [, scope ])
		ReplaceNoCase(string, substring1, substring2 [, scope ])
		Reverse(string)
		Right(string, count)
		Round(number [, number of decimal places])
		RTrim(string)
		Trim(string)
		UCase(string)
		URLDecode(string)
		URLEncodedFormat(string)		
		
	Usage:
		
		DSJS.Len("returns the length of a sting");
		DSJS.ListGetAt('andy,tim,katrin',3);
		
	Code Variable Abbreviations:
		a 		= array
		c 		= count
		d 		= delimiters
		d1,d2 	= date one, date two
		dp 		= date part
		i 		= index
		l 		= list
		n 		= number
		p 		= position
		r 		= return value/string/etc 
		s 		= string
		s1,s2 	= string one, string two
		sb 		= substring
		sb1,sb2	= substring one, substring two
		so 		= sort order
		st 		= sort type
		sc 		= scope
		v 		= value
*/
var DSJS = {
	_CommaForThousands: function(n){
			var r = n.slice(0, n.indexOf('.'));
			for (var i = 0; i < Math.floor((r.length-(1+i))/3); i++){
				r = n.substring(0,n.length-(4*i+3)) + ',' + n.substring(n.length-(4*i+3));
			}
			return r;
	},
	Abs: function(n){
		return Math.abs(n);
	},	
	ArrayAppend: function(a, v){
		a[a.length] = v;
		return a;
	},
	ArraySort: function(a,st,so){
		var _so;
		if (st.toUpperCase() == 'TEXTNOCASE'){ 
			if(!so || so.toUpperCase() != "DESC"){
				_so = function(a, b) {a = a.toUpperCase(); b = b.toUpperCase(); if (a < b){return -1;} else if(a > b){return 1;} else {return 0;}};
			} else {
				_so = function(a, b) {a = a.toUpperCase(); b = b.toUpperCase(); if (a > b){return -1;} else if(a < b){return 1;} else {return 0;}};
			}		
		} else if (st.toUpperCase() == 'TEXT'){ 
			if(!so || so.toUpperCase() != "DESC"){
				_so = function(a, b) {if (a < b){return -1;} else if(a > b){return 1;} else {return 0;}};
			} else {
				_so = function(a, b) {if (a > b){return -1;} else if(a < b){return 1;} else {return 0;}};
			}		
		} else if (st.toUpperCase() == 'NUMERIC'){
			if(!so || so.toUpperCase() != "DESC"){
				_so = function(a,b) {return a - b;};
			} else {
				_so = function(a,b) {return b - a;};
			}			
		}
		return a.sort(_so);
	},
	ArrayToList: function(a,d){
		if(!d){d = ",";}
		var re = /[,]/gi;
		return a.toString().replace(re, d);
	},
	ArrayLen: function(a){		
		return a.length;		
	},	
	Ceiling: function(n){
		return Math.ceil(n);
	},
	Compare: function(s1,s2){
		if (s1 == s2) {return 0;}
		if (s1 > s2) {return 1;}	
		else {return -1;}
	},
	CompareNoCase: function(s1,s2){
		return this.Compare(s1.toUpperCase(),s2.toUpperCase());
	},
	DateDiff: function(dp,d1,d2){
		var dt1 = new Date(d1);
		var dt2 = new Date(d2);
		var iDiffMS = dt2.valueOf() - dt1.valueOf();
		var dtDiff = new Date(iDiffMS);
		var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
		var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!==0 ? nYears*12 : 0);
		var nQuarters = nMonths / 3;		
		var nMilliseconds = iDiffMS;
		var nSeconds = iDiffMS / 1000;
		var nMinutes = nSeconds / 60;
		var nHours = nMinutes / 60;
		var nDays  = nHours / 24;
		var nWeeks = nDays / 7;
		var iDiff = 0;		
		switch(dp.toLowerCase()){
			case "yyyy": return nYears;
			case "q": return nQuarters;
			case "m": return nMonths;
			case "y": return nDays;
			case "d": return nDays;
			case "w": return nDays;
			case "ww":return nWeeks;		
			case "h": return nHours;
			case "n": return nMinutes;
			case "s": return nSeconds;
			case "ms":return nMilliseconds;
			default: return "invalid interval: '" + dp + "'";
		}
	},
	DecimalFormat: function(n){ 
		var r = n.toFixed(2);
		var bp = this._CommaForThousands(r.slice(0, r.indexOf('.') + 1));
		var ap = this.Right(r,2);
		r = bp + '.' + ap;
		return r;
	},
	DollarFormat: function(n) {
		var _n = n.toString().replace(/\$|\,/g,'');
		_n = _n.toString().replace('(','-');
		_n = _n.toString().replace(')','');
		if(isNaN(_n)){
			_n = 0;
		}
		var	sign = (_n == (_n = Math.abs(n)));
			_n = Math.floor(_n*100+0.50000000001);
		var	cents = _n%100;
			_n = Math.floor(_n/100).toString();		
		if(cents < 10){
			cents = "0" + cents;
		}
		_n = this._CommaForThousands(_n);
		return (((sign)?'':'(') + '$' + _n + '.' + cents + ((sign)?'':')'));
	},
	Find: function(sb,s){
		 return s.toString().indexOf(sb) + 1;
	},
	FindNoCase: function(sb,s){		
		return this.Find(sb.toUpperCase(),s.toUpperCase());
	},
	Insert: function(sb,s,p){
		return s.slice(0, p) + sb + s.slice(p, s.length);
	},
	IsDate: function(d){
		var datePat 	= /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var matchArray 	= d.toString().match(datePat);	
		if (matchArray === null) {
			return false;
		}	
		var month 	= matchArray[1];
		var day 	= matchArray[3];
		var year 	= matchArray[5];	
		if (month < 1 || month > 12) { 
			return false;
		}	
		if (day < 1 || day > 31) {
			return false;
		}	
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			return false;
		}	
		if (month == 2) { 
			var isleap = (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0));
				if (day > 29 || (day==29 && !isleap)) {
					return false;
				}
		}
		return true; 
	},
	IsNumeric: function(s){
		if (isNaN(s)){
			return false;
		} else {
			return true;
		}
	},
	LCase: function(s){		
		return s.toLowerCase();			
	},
	Left: function(s,c){
		return s.slice(0, c);
	},	
	Len: function(s){		
		return s.length;
	},
	ListAppend: function(l, v, d){
		if(!d){d = ",";}
		var r = ""; 
		if (this.ListLen(l)){
			r = l + d + v;
		} else {
			r = v;
		}
		return r;
	},
	ListDeleteAt: function(l, p, d){
		if(!d){d = ",";}
		var i,posInList;
		var posInArray = p - 1;
		var thisD 	= "";
		var r = ""; 
		for(i = 0; i < l.split(d).length; i++){
			if (i != posInArray){
				posInList = i + 1;
				if (r.length){
					thisD 	= d;
				}
				r += thisD + this.ListGetAt(l, posInList, d);
			}
		}
		return r;
	},
	ListFind: function (l,v,d){
		if(!d){d = ",";}
		var r = 0;
		var listToArray = l.split(d);
		for (var i=0; i < listToArray.length; i++){		
			if (listToArray[i] == v){
				r = i + 1;
				break;
			}
		}
		return r;
	},
	ListFindNoCase: function(l,v,d){
		if(!d){d = ",";}
		return this.ListFind(l.toUpperCase(), v.toUpperCase(), d);
	},
	ListFirst: function(l,d) {
		if(!d){var d=','}
		_TempListFirstSplitArray = l.split(d)
		return _TempListFirstSplitArray[0]
	},
	ListGetAt: function (l, p, d){
		if(!d){d = ",";}
		return l.split(d)[p - 1];
	},	


	ListLast: function(l,d) {
		if(!d){var d=','}
		_TempListFirstSplitArray = l.split(d)
		return _TempListFirstSplitArray[_TempListFirstSplitArray.length-1]
	},
	ListLen: function(l,d){	
		if(!d){d = ",";}		
		return l.split(d).length;
	},	
	ListSetAt: function(l,p,v,d) {
		if(!d){d = ",";}
		_TempListFirstSplitArray = l.split(d);
		_TempListFirstSplitArray[p-1]=v;
		_TempStringToReturn = _TempListFirstSplitArray.join(d);
		return _TempStringToReturn;
	},
	ListToArray: function(l,d){		
		var r,a,i;			
		if(!d){d = ",";}		
		r = [];

		a = l.split(d);			
		for(i=1; i <= a.length; i++){
			r[i] = a[i - 1];
		}			
		return r;	
	},
	LTrim: function(s){
		return s.toString().replace(/^\s*/, '');
	},	
	Mid: function(s, start, c){
		start -= 1;
		return s.slice(start,start + c);
	},
	Replace: function(s,sb1,sb2,sc){
		if(!sc || sc.toUpperCase() != "ALL"){
			sc = "";
		} else {
			sc ="g";
		} 	
		var re = new RegExp(sb1,sc);
		return s.replace(re,sb2);
	},

	ReplaceNoCase: function(s,sb1,sb2,sc){
		if(!sc || sc.toUpperCase() != "ALL"){
			sc = "i";
		} else {
			sc ="gi";
		} 	
		var re = new RegExp(sb1,sc);
		return s.replace(re,sb2);
	},
	Reverse: function(s){
		var i = s.length;
		var r = "";	
		for (i; 0 <= i; i--){	
			r += s.charAt(i);	
		}	
		return r;
	},
	Right: function(s,c){
		return s.slice(s.length - c, s.length);
	},
	Round: function(n,p) {
		if (!isNaN(n.toFixed(p))){
			return n.toFixed(p);
		} else {
			return n;
		}
	},
	RTrim: function(s){
		return s.toString().replace(/\s*$/, '');
	},
	Trim: function(s){
		return s.replace(/^\s*|\s*$/g,'');
	},
	UCase: function(s){		
		return s.toUpperCase();			
	},
	URLDecode: function(s){
		return unescape(s);
	},	
	URLEncodedFormat: function(s){
		return encodeURI(s);
	},
	Year: function (mydate) {
		_newDate = new Date(mydate)
		return _newDate.getYear();
	},
	// 2008-07-16 [AP] Added LSCurrencyFormat	
	LSCurrencyFormat: function (num) {
		currency=''; // € oder $
		num = num.toString().replace(/\$|\,/g,'');		
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+'.'+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + currency + num + ',' + cents);
	}		
	

};


/* END DSJS - ColdFusion Functions for JavaScript */


function DSIsDefined( variable){
    return (typeof(window[variable]) == "undefined")?  false: true;
}
function isdefined( variable){
    return (typeof(window[variable]) == "undefined")?  false: true;
}



function DSGetVarFromURL(url,variable) {
	variable = variable.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+variable+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec(url);
	if(results==null)
		return "";
	else
		return results[1];
}

// Start
function DSSnippetSelect (e,type,field,optionlist) {
	this.contentdiv='fff';	
	DSOptionList(optionlist);	
	
	top.DSSnippetSelect_type=type;
	top.DSSnippetSelect_field=field;
	DSContextShow(e,contentdiv);
}


function DSSnippetInsert(theSelect) {
	if(theSelect.selectedIndex>=0) {
		theContentObject=theSelect.options[theSelect.selectedIndex].value;
		content=$(theContentObject).innerHTML;
		if($(theSelect.options[theSelect.selectedIndex].value+'_replacelist')) {
			thelist=$(theSelect.options[theSelect.selectedIndex].value+'_replacelist').value;
			for(replacevar=0;replacevar < DSJS.ListLen(thelist,',');replacevar++) {
				Item=DSJS.ListGetAt(thelist,replacevar+1,',');
				if(DSJS.ListLen(Item,':')==2) {
					content=DSJS.ReplaceNoCase(content,DSJS.ListGetAt(Item,1,':'),DSJS.ListGetAt(Item,2,':'));
				}
			}
		}
	}
	if(top.DSSnippetSelect_type=='field')
		$(top.DSSnippetSelect_field).value=$(top.DSSnippetSelect_field).value+content;
	else if(top.DSSnippetSelect_type=='dseditor'){
		tinyMCE.get(top.DSSnippetSelect_field).selection.setContent(content);
		if(top.DSSnippetSelect_field=='messagebody')
			tinyMCE.get(top.DSSnippetSelect_field).dom.setHTML('dssenderemail', $('email_from').options[$('email_from').selectedIndex].value);		
	}
	//tinyMCE.setContent(tinyMCE.getContent(top.DSSnippetSelect_field)+content);

	theSelect.selectedIndex=0;
}

ds_selected_obj_to_insert='';
function ds_selected_obj_insert(tvs,tve){
	if (ds_selected_obj_to_insert=='')
		return;
	ds_selected_obj_to_insert.focus();
	if(typeof document.selection != 'undefined'){
		thisSelection=document.selection.createRange();
		range_text_length = thisSelection.text.length;
		thisSelection.text = tvs+thisSelection.text+tve;
		if (range_text_length==0)
			thisSelection.move('character', -tve.length);
		thisSelection.select();
	}
	else if(typeof ds_selected_obj_to_insert.selectionStart != 'undefined'){
		sec_start = ds_selected_obj_to_insert.selectionStart;
		sec_end = ds_selected_obj_to_insert.selectionEnd;
		sec_insText = ds_selected_obj_to_insert.value.substring(sec_start,sec_end);
		ds_selected_obj_to_insert.value = ds_selected_obj_to_insert.value.substr(0, sec_start) + tvs + sec_insText + tve + ds_selected_obj_to_insert.value.substr(sec_end);
		new_pos=0;
		if (sec_insText.length==0)
			new_pos = sec_start + tvs.length;
		else
			new_pos = sec_start+tvs.length+sec_insText.length+tve.length;
		ds_selected_obj_to_insert.selectionStart=new_pos;
		ds_selected_obj_to_insert.selectionEnd=new_pos;
	}
	else{
		ds_selected_obj_to_insert.value+=tvs + tve;
	}
}
// End


// readAttribute('active'));
// ***************************
// * START DSLoader          *
// ***************************

var dsloaderid=0;
function dsgetloaderid() {
	dsloaderid++;
	if (dsloaderid>5)
		dsloaderid=1;
}

function DSLoader_getWindowObject(theCommand) {
	pos=top.DSFindLoader_Loaded(theCommand);
	if (pos>-1)
		return top.DSLoader_Loaded[pos][0];
	else
		return this.window
} 

xhrcounter=0;

function dsloader(url,target,element,optionlist) {
	//alert('window.name:'+window.name+'url:'+url+' target:'+target);
		
	type='load';
	popupwarning=1;
	postform='';
	theelement=url;
	cancelalert=0;
	xhr=0;
	dspopup1_loader_width=20;
	dspopup2_loader_width=30;
	dspopup3_loader_width=40;	
	dspopup1_width=20;
	dspopup2_width=30;
	dspopup3_width=40;	
	DSOptionList(optionlist);
	if(target==null)
		target='dspopup1';
	url=url+'&dscaller='+window.name+'&dsreceiver='+target;
	if(typeof top.DSLoader_URLAdd != 'undefined' && top.DSLoader_URLAdd!='')
		url=url+top.DSLoader_URLAdd;

	// 2009-02-07 [AP] Multiple Sorting
	// Das Attributre mulitplesorting wird in der DSMultipleSort() Funktion gesetzt
	if ($(element) && $(element).readAttribute('multiplesorting')) {
		url+='&dssorting='+$(element).readAttribute('multiplesorting');	
	}
	if(cancelalert==1)
		url=url+'&cancelalert=1';
	//if (DSCAID==2260) {
	//	alert('url:'+url+'\ndselement:'+DSJS.FindNoCase('&dselement=',url)+'\nelement:'+DSJS.FindNoCase('='+element,url));
	//}
	if (DSJS.FindNoCase('&dselement=',url)==0 && DSJS.FindNoCase('='+element,url)==0 && element)
		url+='&dselement='+element;
	//2008-07-01 [AP]
	//if (DSCAID=2260)
	//	alert('each:'+s+'\nurl:'+url+'\ncommand:'+DSJS.FindNoCase('cmd='+s,url)+'\nCommandbarElement:'+DSJS.FindNoCase('DSCommandBarElement',url))
	if (typeof DSExplorer.GUIPlace.CommandBar=='object' && DSJS.FindNoCase('DSCommandBarElement',url)==0) {
		DSExplorer.GUIPlace.CommandBar.Element.each(function(s) { 
			//if (DSJS.FindNoCase('cmd='+s,url)){
			if (s==element) {	
				url=url+'&dscommandbarelement='+DSExplorer.GUIPlace.CommandBar.Name;
				$break;
			}
		}); 
	}		
	if (element!=null)
		theelement=element;
	//if (DSCAID==2260)
	//	alert(url);
	if(DSLeft(target,7)=='dspopup') {
		if(DSIsBackEnd==1) {
			MAINWIndow='top.MAIN.';
			if(dsviewcheck()=='dsmanager')
				MAINWIndow='top.dsmanager.';
		}
		else
			MAINWIndow='top.';
		
		TargetWindowObject=eval(MAINWIndow+target+'_loader');
		if(type=='load') {
			if(eval(MAINWIndow+'$(\''+target+'\').style.display')=='block' && TargetWindowObject.DSPopUp_RefreshAlert && TargetWindowObject.DSPopUp_RefreshAlert==1) {
				editor_warning=confirm(DSLang('alertdicardpopupcontent'));
				if(editor_warning==false)
					return
			}
			if(xhr==0)
				TargetWindowObject.location.href=url;
			else
				new Ajax.Updater(theelement, url+'&dsxhr=1',{parameters: { text: $(theelement) }}); 
				
		}
		if (dcbe==null)
			DSInit();
		if((parent.document.getElementById(target) || $(target)) && type=='load'){
			if($(target)){
				$(target).style.left = 20+eval(target+'_width') + "px";
				$(target).style.top = DSInt(dcbe.scrollTop+20+eval(target+'_width')) + "px";
			}
			else{
				parent.$(target).style.left = 20+eval(target+'_width') + "px";
				parent.$(target).style.top = DSInt(parent.dcbe.scrollTop+20+eval(target+'_width')) + "px";
			}
		}
	}
	else if(target=='dsmanager') {
		TargetWindowObject=eval(top.dsmanager);
	}
	else if(target=='dssidebar') {
		TargetWindowObject=eval(top.dssidebar);
	}	
	else if(target=='MAIN' || target=='ds' || target=='dsfront') {
		if(DSIsBackEnd==1)
			TargetWindowObject=eval(top.MAIN);
		else
			TargetWindowObject=eval(top);
	}
	else if(target=='dsloader') {
		if($('dsformwaitcode') && url.indexOf('unlock') == -1)
			$('dsformwaitcode').style.display='block';
		dsgetloaderid();
		// 2006-07-27 [AP] Postform
		if(postform!='' && $(postform)) {	
			$(postform).action=url;
			$(postform).target='dsloader'+dsloaderid;		
			$(postform).submit();
		}
		else {			
			if(DSIsBackEnd==1)
				TargetWindowObject=eval('top.dsloader_action.'+target+dsloaderid);
			else
				TargetWindowObject=eval('top.'+target+dsloaderid);
			if(xhr==0){
				TargetWindowObject.location.href=url;
			}
			else{
				/*this.transport=new Ajax.Request(url+'&dsxhr=1', {method:'post',onComplete:function(transport) {
						$(theelement).innerHTML = transport.responseText.stripScripts();
					    setTimeout(function() {transport.responseText.evalScripts()}, 10);
					}
				});*/
				new Ajax.Updater(theelement, url+'&dsxhr=1',{evalScripts:true}); 
			}
		}
	}
	else if(target=='_self')
		self.location.href=url;
	else if(target=='this.window'){
		TargetWindowObject=this.window;
	}
	else {
		// 2007-03-24 [AP]
		if (type!='add')
			dsnav_open_win(url,target);
	}

	// LoaderArray Settings
	if(target=='dsloader')
		thetarget='dsloader'+dsloaderid;
	else
		thetarget=target;
	help_array=[];
	if(type=='load')
		help_array[0]=this.window;
	else if (type=='add') {
		if(DSLeft(target,7)=='dspopup')
			TargetWindowObject=eval(MAINWIndow+target);
		help_array[0]=TargetWindowObject;
	}
	help_array[1]=theelement;
	if(typeof TargetWindowObject!='undefined')
		help_array[2]=TargetWindowObject;
	else
		help_array[2]=this.window;
	help_array[3]=type;
	help_array[4]=url;
	top.DSLoader_Loaded[top.DSLoader_Loaded.length]=help_array;
}

// Clear top.DSLoader_Loaded Commands for this.window
DSLoader_Loaded=new Array();
if(top.DSLoader_Loaded!=null) {
	for(i=0;i<top.DSLoader_Loaded.length;i++)
		if(top.DSLoader_Loaded[i][0]==this.window) {
			top.DSLoader_Loaded[i][0]=-1;
			top.DSLoader_Loaded[i][1]=-1;
			top.DSLoader_Loaded[i][2]=-1;
			top.DSLoader_Loaded[i][3]=-1;
			top.DSLoader_Loaded[i][4]=-1;
			top.DSLoader_Loaded[i]=-1;
		}
}


function DSLoader_ShowLoaded() {
	msg='';
	theloaderaction='';
		for (i=top.DSLoader_Loaded.length-1;i>=0;i--) {
			if(top.DSLoader_Loaded[i][0]!=null) {
				if(top.DSLoader_Loaded[i][3]=='load')
					theloaderaction='<a href="javascript:dynasite();" onclick="window.open(\''+top.DSLoader_Loaded[i][4]+'\',\'dsloadertop\');">'+top.DSLoader_Loaded[i][1]+'</a>';
				else
					theloaderaction=top.DSLoader_Loaded[i][1];
				msg+='<tr style="background-color:#eeeeee"><td>'+i+'</td><td>'+top.DSLoader_Loaded[i][3]+'</td><td>'+theloaderaction+'</td><td>'+top.DSLoader_Loaded[i][0].name+'</td><td>'+top.DSLoader_Loaded[i][2].name+'</td><td nowrap="nowrap">'+top.DSLoader_Loaded[i][4]+'</td></tr>';
			}
		}
		if(msg.length==0)
			msg='<table><tr><td>Nothing loaded</td></tr></table>';
		else
			msg='<table cellspacing="1" style="padding:2px;width:100%"><tr><td class="dshead">ID</td><td class="dshead">Type</td><td class="dshead">Command/Element</td><td class="dshead">Caller</td><td class="dshead">Receiver</td><td class="dshead">URL</td></tr>'+msg+'<tr><td colspan="6">&nbsp;</td></tr></table>';
		if(top.DSManagerLoaded==1) 
			top.dsmanager.$('loaderloadeddiv').innerHTML=msg+'&nbsp;';
		else
			$('loaderloadeddiv').innerHTML=msg+'&nbsp;';
// alert(msg);

}

function DSFindLoader_Loaded(cmd,thewindow){
	//top.DSLoader_Loaded[i][0]=window (frame oder iframe)
	//top.DSLoader_Loaded[i][1]=command
	var i=0;
	var cmdcode='';
	if (top.DSLoader_Loaded.length > 0){
		for (i=top.DSLoader_Loaded.length-1;i>=0;i--){
			if(cmd=='lastcmd' && top.DSLoader_Loaded[i][3]=='load' && DSJS.Find('unlock',top.DSLoader_Loaded[i][1])==0 && DSJS.Find('command_edit',top.DSLoader_Loaded[i][1])==0) {
				return i;
				break;					
			}
			cmdcode=top.DSLoader_Loaded[i][1];
			if(typeof cmdcode != 'undefined') {
				// alert('Index:'+i+'CMDCode:'+cmdcode+' CMD:'+cmd);
				if(thewindow!=null) {
					// if(cmd.indexOf(cmdcode) != -1 &&  top.DSLoader_Loaded[i][0]==thewindow) {
					if(cmd==cmdcode &&  top.DSLoader_Loaded[i][0]==thewindow) {
						return i;
						break;
					}
				}
				else if(cmd==cmdcode) {
					 //alert('i:'+i+' len:'+top.DSLoader_Loaded.length+'code'+cmdcode+'cmd:'+cmd);
					return i;
					break;					
				}
			}
		}
	}
	return -1;
}

function dsdisable(thisvalue,disablevalue,operator,fieldlist,additional) {
	// 2006-10-24 [AP] new option, Operator != 
	var i=0;
	thisdisabled=0;
	additionaldisable='';
	if (additional!=null) {
		additional =additional.split(",");	
		for (i=0; i < additional.length; ++i) {
			//Element[0] = Formfield, Element[1] = Disable Value 
			element=additional[i].split(":");				
			selecttype=$(element[0]).type;							
			if (selecttype=="select-one" && $(element[0]).options[$(element[0]).selectedIndex].value==element[1]) 		
				additionaldisable=1;
			else if (selecttype=='radio' && $(element[0]).checked==true && $(element[0]).value==element[1])
				additionaldisable=1;
			else
				additionaldisable=0;		
		}
		if (thisvalue==disablevalue && additionaldisable==1)
			thisdisabled=1;	
	}
	else {
		if (operator=="!=") {
			if (thisvalue!=disablevalue)
				thisdisabled=1;
		}
		else {
			if (thisvalue==disablevalue || thisvalue=='')
				thisdisabled=1;
		}
	}	
	fieldlist=fieldlist.split(",");	
	for(i=0; i<fieldlist.length; i++){		
		if ($(fieldlist[i])) {
			if ($(fieldlist[i]).type!=undefined)// Ungleich Form-Felder
				$(fieldlist[i]).disabled=thisdisabled;
			else {
				if (thisdisabled==1) {
					$(fieldlist[i]).style.display='none';
					if ($(fieldlist[i]).nodeName=="TD")
						$(fieldlist[i]).setAttribute("style","display:none")
				}
				else {
					$(fieldlist[i]).style.display='block';	
					if ($(fieldlist[i]).nodeName=="TD")
						$(fieldlist[i]).setAttribute("style","display:table-cell !important;display:block")				
				}
			}
		}
	}
	DSPopUpResize();
}

function dsnav_open_win(url, target, scroll){
	if (url.length==0)
		return false;
	Ausdruck=/&target=(\w.+)&.+&/;
	if (Ausdruck.test(url)){
		Ausdruck.exec(url);
		target=RegExp.$1;
		Ausdruck=/&width=(\d.+)&/;
		Ausdruck.exec(url);
		width=RegExp.$1;
		Ausdruck=/&height=(\d.+)/;
		Ausdruck.exec(url);
		height=RegExp.$1;
		Ausdruck=/(\w.+)&target=/;
		Ausdruck.exec(url);
		url=RegExp.$1;

eval(target+"=window.open('"+url+"','"+target+"','width="+width+",height="+height+",left="+Math.ceil(screen.width/2-width/2)+", top="+Math.ceil((screen.height-height)/2)+",screenx=0,scrollbars="+scroll+",screeny=0,dependent=yes,resizable=yes')");
		eval(target+".focus()");
	}
	else
		window.open(url, target);
}

// ***************************
// * END DSLoader            *
// ***************************


function dsnonselect(event,thisElement){
	if(event.altKey){
		thisElement.onselectstart='return false';
		thisElement.unselectable='on';
		thisElement.style.cssText=thisElement.style.cssText+';-moz-user-select:none !important';
	}
	else{
		thisElement.onselectstart='';
		thisElement.unselectable='off';
		thisElement.style.cssText=thisElement.style.cssText.replace(';-moz-user-select:none !important','');
	}
}

function DSFindParnetNodeByName(element,nodename){
	parentnode=element.parentNode;
	returnnode='';
	nodename=nodename.toLowerCase();
	while (returnnode=='') {
		parnetnodename=parentnode.nodeName.toLowerCase();
		if (parnetnodename==nodename || parnetnodename=='html')
			returnnode=parentnode;
		parentnode=parentnode.parentNode;
	}
	return returnnode;
}


// ***************************
// * START Global functions  *
// ***************************

function DSAddBodyOnLoad(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
		window.onload = func;
	else {
		window.onload = function() {
			oldonload();
			isfullfunction=func.search(/\(/gi);0
			if (isfullfunction!=-1)
				eval(func);
			else
				func();
		}
	}
}

function DSBlank(){
	return;
}

function DSSetFocus(element) {
	$(element).activate();
}

function DSArrayFind(array,value) {
	found=false;
	for(afi=0;afi<array.length;afi++) {
		if(array[afi]==value) {
			found=true;
			break
		}
	}
	return found;
}
function DSArrayFindPos(array,value) {
	found=-1;
	for(afi=0;afi<array.length;afi++) {
		if(array[afi]==value) {
			found=afi;
			break
		}
	}
	return found;
}

function DSArrayDeleteElement(this_array,this_pos){
	var help_array=new Array();
	var i=0;
	for(i=0;i<this_array.length;i++){

		if (this_pos!=i){
			help_array[help_array.length]=this_array[i];
		}
	}
	return help_array;
}

function DSArrayToList(array,delimitter){
	var i=0;
	var list='';
	for (i=0;i<array.length;i++){
		if (list=='')
			list+=array[i];
		else
			list+=delimitter+array[i];
	}
	return list;
}

function DSTrim(this_value){
	return this_value.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

function DSLeft(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function DSRight(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function DSInt(to_integer){
	to_integer=parseInt(to_integer);
	if (isNaN(to_integer))
		to_integer=0;
	return to_integer;
}

function DSNumChk(this_number){
	this_number=DSTrim(this_number)
	punkt=this_number.indexOf(".");
	komma=this_number.indexOf(",");
	if (komma > -1){
		if (punkt==-1)
			this_number=this_number.replace(',','.');
		else if(komma<punkt)
			this_number=this_number.replace(',','');
		else if(punkt<komma){
			this_number=this_number.replace('.','');
			this_number=this_number.replace(',','.');
		}
	}
	return this_number;
}

function DSIsNum(this_number){
	this_number=DSNumChk(this_number);
	if (this_number=='' || isNaN(this_number))
		return false;
	else
		return true;
}

function dswinopen(url,width,height,rzb,sb,target){
	eval(target+"=window.open('"+url+"','"+target+"','width="+width+", height="+height+", left="+Math.ceil(screen.width/2-width/2)+", top="+Math.ceil((screen.height-height)/2)+", dependent=1, resizable="+rzb+", scrollbars="+sb+"')");
	eval(target+".focus()");
}

function DSOptionList(OptionList,Delimiter) {
	var i=0;
	if(OptionList!=null) {	
		theDelimiter=':';
		if(Delimiter!=null)
			theDelimiter=Delimiter;
		function_list= OptionList.split(",");
		for (i=0; i<function_list.length; i++) {
			//alert(function_list[i]);
			this_function=function_list[i].split(theDelimiter);
			this[this_function[0]]=this_function[1];
			//eval(this_function[0]+"='"+this_function[1]+"'");
		}
	}
}


var listclass='';
function DSonMouseOverOut(OverOut,thiselement,optionlist) {
	classname='dslist1';
	hoverclass='dslist_hover';
	if (optionlist!=null)
		DSOptionList(optionlist);
	if(OverOut=='over' && DSJS.ListFindNoCase(thiselement.className,'dslist_selected',' ')==0 && DSJS.ListFindNoCase(thiselement.className,'trprintno',' ')==0) {
		listclass=thiselement.className;
		thiselement.className=hoverclass;
	}
	if(OverOut=='out' && DSJS.ListFindNoCase(thiselement.className,'dslist_selected',' ')==0 && DSJS.ListFindNoCase(thiselement.className,'trprintno',' ')==0) {
		thiselement.className=classname;
	}
}




// ***************************
// * END Global functions    *
// ***************************


// ***************************
// * START Layout - Colors   *
// ***************************
function DSColorSchemeBar(height,type) {
	colorschemebar='<table cellpadding="0" cellspacing="0" width="100%"><tr><td style="height:'+height+'px;width:20%;background:#d70026;"></td><td style="width:20%;background:#3399cc;"></td><td style="width:20%;background:#99cc33;"></td><td style="width:20%;background:#ff6600;"></td><td style="width:20%;background:#FFCC33;"></td></tr></table>'
	if(type=='document.write')
		document.write(colorschemebar);
	else
		return colorschemebar;
}

var colors=new Array('#D70026','#3399CC','#99CC33','#FF6600','#FFCC33');
var trcolors=new Array('#FFFFFF','#f1f5fa');

function DSChildLoop(theElement,theTagName,theAction) {
	var i=0;
	var index=0;
	var theElement = $(theElement);
	for (var i = 0; i < theElement.childNodes.length; ++i) {
		if (theElement.childNodes.item(i).nodeName == theTagName) {
			if(theAction=='dscoloring') {
				theElement.childNodes.item(i).style.color=colors[index];
				index=index+1;
				if(index==colors.length)
					index=0;
			}
			else if(theAction=='trcoloring') {
				theElement.childNodes.item(i).style.backgroundColor=trcolors[index];
				index=index+1;
				if(index==trcolors.length)
					index=0;					
			}
		}
	}
}


function DSSetTRColor (table) { 
    $$('table#'+table+' tbody > tr:nth-child(odd)').each(function(s) {
		s.addClassName('dslist1');
    });
    $$('table#'+table+' tbody > tr:nth-child(even)').each(function(s) {
		s.addClassName('dslist2');																   
   });
}
function dsulloop(theElement) {
	var index=0; 
	var ul = $(theElement);
	for (var i = 0; i < ul.childNodes.length; ++i) {

		if (ul.childNodes.item(i).nodeName == "LI") {
			ul.childNodes.item(i).style.color=colors[index];
			index=index+1;
			if(index==colors.length)
				index=0;
		}
	}
}

function dswrite_bgcolor(formular,feld) {
	$(feld+'color').style.backgroundColor=$(feld).value;
}

// ***************************
// * END Layout - Colors     *
// ***************************

// Start
function DSPageRowSelect(theElement,theCMD,option) {
	//2008-07-01 [AP] URL.Variable DSPageRowAction hinzugefügt
	var page=theElement.options[theElement.selectedIndex].value;
	postform='';
	element='';
	if(option!=null){
		DSOptionList(option);
	}
	if(postform!='' && $(postform)!=null)
		dsloader(dsxpath+'dynasite.cfm?'+theCMD+'&dspagerows='+page+'&dspagerowsaction='+page,'dsloader',element,'postform:'+postform);
	else
		dsloader(dsxpath+'dynasite.cfm?'+theCMD+'&dspagerows='+page+'&dspagerowsaction='+page,'dsloader',element);
}
// End

//Start
function dscheckticketmessage(dsctid){
	checkmessageconfirm=true;
	if($('messagebody_'+dsctid) && $('messagebody_'+dsctid).value.length>0 && $('messagebody_'+dsctid).value.length<20){
		checkmessageconfirm=false;
		alert('Es wird keine Email verschickt weil die Nachricht zu kurz ist!\nSie benötigt mindestens 20 Zeichen.');
	}
	else if($('messagebody_'+dsctid) && $('messagebody_'+dsctid).value.length>20)
		checkmessageconfirm=confirm('Achtung es wird eine eMail an den Kunden verschickt!');
	if(checkmessageconfirm==true)
		dsform_submit('form:form_'+dsctid)
	else
		$('dsbutton_submit').disabled=false;
}

//End

//Start
function dsWidgetSetAction(action,widgetset,defaultset,dselement){
	if(action=='new' || action=='edit')
		$(dselement+'_widgetsetform').setStyle({display:'block'});
	else
		$(dselement+'_widgetsetform').setStyle({display:'none'});
		
	if(action=='new'){
		dswsid=0;		
		dsaction='insert';
		$(dselement+'_widgetsetname').value='';
		$(dselement+'_widgetsetdefault').checked=false;
	}
	else if(action=='edit'){
		dswsid=widgetset;
		dsaction='update';
		$(dselement+'_widgetsetname').value=$('widgset_'+widgetset).innerHTML;
		if(defaultset){
			$(dselement+'_widgetsetdefault').disabled=true;			
			$(dselement+'_widgetsetdefault').checked=true;
		}
		else
			$(dselement+'_widgetsetdefault').checked=false;
	}
	else if(action=='delete'){
		widgetdelete=confirm('Sind Sie sich sicher?');
		if(widgetdelete==false)
			return;
		dswsid=widgetset;
		action='submit';
		dsaction='delete';
	}
	else if(action=='cancel'){
		dswsid=0;
		$(dselement+'_widgetsetname').value='';
		$(dselement+'_widgetsetdefault').disabled=false;
		$(dselement+'_widgetsetdefault').checked=false;
	}
	else if(action=='set'){
		dswsid=widgetset;		
		action='submit';
		dsaction='set';
	}
	else if(action=='reset'){
		dswsid=0;		
		action='submit';
		dsaction='reset';
	}
	if(action=='submit'){
		var postbodycontent='';
		var sortables = $(dselement).select('.dswidget_column');
		var counter=1;
		var isdef=$(dselement+'_widgetsetdefault').checked ? 1: 0;		
		sortables.each(function (sortable) {
			if(counter==1)		
				postbodycontent+='columnvalue='+sortable.id+'='+$(sortable.id).select('.dswidget').pluck('id').join(',');
			else
				postbodycontent+='|'+sortable.id+'='+$(sortable.id).select('.dswidget').pluck('id').join(',');
			counter+=1;
		});
		
		postbodycontent+='&name='+encodeURIComponent($(dselement+'_widgetsetname').value)+'&isDefault='+isdef;
		
		new Ajax.Updater(dselement+'_widgetsets',dsxpath+'dynasite.cfm?dscmd=widget_widget_sort_'+dsaction+'&dselement='+dselement+'&dswsid='+dswsid+'&dsxhr=1',{
			method: 'post', 
			postBody: postbodycontent,
			onSuccess:function(request){
				request.responseText.evalScripts();
			}
		});
		
		$(dselement+'_widgetsetname').value='';
		$(dselement+'_widgetsetdefault').disabled=false;
		$(dselement+'_widgetsetdefault').checked=false;
	}
}
function BuildCommandSelect(thiselement,thisid) {
	$(thisid).disabled=true;
	if ($(thiselement).readAttribute('element')=='dscid' && $(thisid+'_application'))
		$(thisid+'_application').disabled=true;
			
	var url=dsxpath+'dynasite.cfm?dsmid='+DSMID+'&dscmd=command_command_command_select';
	var dscid=DSCID;
	var multiple=0;
	var name=$(thisid).name;
	var firstoption=$(thisid).readAttribute('firstoption');
	var type=$(thisid).readAttribute('type');
	var preselect=$(thisid).readAttribute('preselect');
	var application=$(thisid).readAttribute('application');
	var global=$(thisid).readAttribute('global');
	
	if ($(thisid+'_dscid'))
		dscid=$(thisid+'_dscid').value;
	if ($(thisid+'_application'))
		application=$(thisid+'_application').value;
	
	//alert(application+' dscid:'+dscid)
	if ($(thisid).multiple==true)
		multiple=1;
	new Ajax.Updater(thisid+'_container', url+'&dsxhr=1',{
		postBody:'command_dscid='+dscid+'&command_multiple='+multiple+'&command_name='+name+'&command_id='+thisid+'&command_firstoption='+firstoption+'&command_type='+type+'&command_preselect='+preselect+'&command_application='+application+'&command_global='+global,
		evalScripts:true
	}); 

}
//2009-01-15 [AP] Die Funktion wird im DS Framework app/_layout.cfm verwendet 
function DSLoadContextMenu() {
	new Proto.Menu({selector: '#DSTree_dsmenutree_'+DSSID+' a',className: 'menu desktop',menuItems: 'treeMenuItems'})
}
var treeMenuItems = [
	{check:'menu==1',name: DSLang('Edit'),className: 'edit',callback: function(e,element) {tempdsmid=element.id.split('_');dsloader(dsxpath+'dynasite.cfm?dscmd=content_menu_menu_edit&dsmid='+tempdsmid[4]+'&dssid='+tempdsmid[2],'dspopup1','content_menu_menu_edit');}},
	{check:'menu==1',name: DSLang('Delete'),className: 'delete',callback: function(e,element) {tempdsmid=element.id.split('_');dsloader(dsxpath+'dynasite.cfm?dscmd=content_delete_menu_delconf&dsmid='+tempdsmid[4]+'&dssid='+tempdsmid[2],'dspopup1','content_delete_menu_delconf');}},
	{check:'menu==1',separator: true},	
	{check:'menu==1',name: DSLang('New'),className: 'new',callback: function(e,element) {tempdsmid=element.id.split('_');dsloader(dsxpath+'dynasite.cfm?dscmd=content_menu_menu_new&dsmid=0&dssid='+tempdsmid[2],'dspopup1','content_menu_menu_new');}},	
	{check:'menu==1',name: 'Menu []',disabled:'1'},
	{check:'menu==0',className: 'delete',name: 'System Menu',disabled:'1'}	
];

//End
function dsdialog(e,url){
	new Ajax.Request(url, {
		method: 'post',
		evalScripts: true,
		onComplete: function(transport) {
			Dialog.setMsg(transport.responseText);
			Dialog.info(e);
		  }
	});
}

function dsxobject_searchaction(e,element,action){
	$('xobjectsearchphrase').value=action;
	$('xobjectsearchphrase').focus();								
	if($('system_search_search_search_dstagfilter')){
		if(action=='d:')
			$('system_search_search_search_dstagfilter').style.display='block';
		else
			$('system_search_search_search_dstagfilter').style.display='none';
	}
		

}

function dsxobjectshowtag(event,element){
	if($('system_search_search_search_dstagfilter')){
		if(DSJS.Left(element.value,2)=='d:' || DSJS.Left(element.value,2)=='D:')
			$('system_search_search_search_dstagfilter').style.display='block';
		else
			$('system_search_search_search_dstagfilter').style.display='none';
	}
}

var DSXObject={
	ElementBox:'SelectedXObject',
	JSON:{
		JSONArray:[],
		JSONString:'',
		BuildArray:function() {
			if ($(DSXObject.ElementBox).value.isJSON()==1)
				DSXObject.JSON.JSONArray=$(DSXObject.ElementBox).value.evalJSON([sanitize=false]);														
		},
		BuildString:function() {
			//DSXObject.JSON.BuildArray();
			//$(DSXObject.ElementBox).value=DSXObject.JSON.JSONArray.toJSON();
			DSXObject.JSON.JSONString=DSJS.Trim($(DSXObject.ElementBox).value);							
		}
	},			
	SubmitSearch:function(QueryString,optionlist) {
		var url=dsxpath+'dynasite.cfm?dsmid='+DSMID+'&'+QueryString+'&dsxhr=1&dscaller='+window.name;
		var tagging="";
		presearchstring="";
		presearchstringseparator="";
		searchresultelement="system_search_search_search";
		searchelement="";		
		if (optionlist!=null)
			DSOptionList(optionlist);
		if (presearchstringseparator=='colon' && presearchstring!='')
			presearchstring+=':';
		tempsearchphrase=presearchstring+$(searchelement+'xobjectsearchphrase').value;
		if(DSJS.Left(tempsearchphrase,2)=='d:' || DSJS.Left(tempsearchphrase,2)=='D:' )
			var tagging="&system_search_search_search_dsttidlist="+$('system_search_search_search_dsttidlist').value;
		new Ajax.Updater(searchresultelement, url,{
			evalScripts:true,
			postBody:"xObjectSearchphrase="+encodeURIComponent(tempsearchphrase)+tagging,
			onComplete: function(){
				DSXObject.Check();
			}					
		}); 
	},				
	BuildOutput:function() {
		var url=dsxpath+'dynasite.cfm?dsmid='+DSMID+'&dscmd=system_xobject_xobject_view&dsxhr=1&dscaller='+window.name;
		var GetString=encodeURIComponent($(DSXObject.ElementBox).value);		
		GetString=encodeURIComponent(GetString);
		new Ajax.Updater('system_xobject_xobject_view', url,{
			evalScripts:true,
			postBody:"DSXObject="+GetString				
		}); 						
	},
	Check:function (){
		DSXObject.JSON.BuildArray();
		DSXObject.JSON.JSONArray.each(function(data) {	
			if ($(data.LinkIDType+':'+data.LinkID))
				$(data.LinkIDType+':'+data.LinkID).checked=true;
				if (data.Unselect==0)
					$(data.LinkIDType+':'+data.LinkID).disabled=true;
																		
		});							
	},
	Get:function (thiselement,optionlist) {
		type='grid';
		nolink=0;
		elementbox='';
		if (optionlist!=null)
			DSOptionList(optionlist);
		if (elementbox!='')
			DSXObject.ElementBox=elementbox;
		//alert(DSXObject.JSON.JSONArray.toJSON())
		if ($(DSXObject.ElementBox).value.isJSON()==1) {
			DSXObject.JSON.BuildArray();
			DSXObject.JSON.JSONArray.each(function(data,index) {	
				var currentValue='';				
				if ($(thiselement).readAttribute('objectvalue'))
					currentValue=$(thiselement).readAttribute('objectvalue');
				else if ($(thiselement).value)					
					currentValue=$(thiselement).value;		
				if (currentValue==data.LinkIDType+':'+data.LinkID) {
					if (data.Unselect==0) {
						alert("You cannot unselect this link!");
						if ($(thiselement).type=='checkbox')
							$(thiselement).checked=true;
					}
					else {
						if (type=='grid') {												
							if (data.Selected==1 || data.Selected==null) {								
								if(nolink==0 && (data.Emaillinked==null || data.Emaillinked==1) && $('DS_Selected_Email')!=null) {									
									DSSelectNameRemove(data.Email,0);
								}
								data.Selected=0;
								$(thiselement).removeClassName('dspanel_shaded_blue');
								$(thiselement).addClassName('dspanel_shaded_gray');	
								checked=0;													
							}
							else {
								
								if(data.Email!='' && $('DS_Selected_Email')!=null){
									var bool=true;
									if(DSArrayFind(DSTypeAHead.selected_email_list,data.Email))
										bool=false;
									if(bool){
										DSTypeAHead.selected_id_list[DSTypeAHead.selected_id_list.length]=data.Email;
										DSTypeAHead.selected_name_list[DSTypeAHead.selected_name_list.length]=data.Email;
										DSTypeAHead.selected_email_list[DSTypeAHead.selected_email_list.length]=data.Email;
										DSTypeAHead.selected_receiver_list[DSTypeAHead.selected_receiver_list.length]=DSTypeAHead.current_selected_receiver;
										DSWriteSelectedToForm();
									}
								}
								
								data.Selected=1;
								$(thiselement).removeClassName('dspanel_shaded_gray');
								$(thiselement).addClassName('dspanel_shaded_blue');	
								checked=1;										
							}				
							if ($(data.LinkIDType+':'+data.LinkID) && $(data.LinkIDType+':'+data.LinkID).type=='checkbox')
								$(data.LinkIDType+':'+data.LinkID).checked=checked;
						}
					}		
					$break;			
				}			
			});
			$(DSXObject.ElementBox).value=DSXObject.JSON.JSONArray.toJSON();
			DSXObject.JSON.BuildString();										
		}				
	},
	Add:function(thiselement) {
		if ($(thiselement).checked==true) {
			//this.JSON.BuildArray();
			if ($('XObject_'+thiselement.id)) {
				var NewEntry=1;
				if (thiselement.type=='radio')
					$(DSXObject.ElementBox).value='';
				DSXObject.JSON.BuildArray();
				DSXObject.JSON.BuildString();				
				DSXObject.JSON.JSONArray.each(function(data) {	
					if ($(data.LinkIDType+':'+data.LinkID) && thiselement.value==data.LinkIDType+':'+data.LinkID) {
						data.Selected=1;
						NewEntry=0;
						$break;										
					}																								
				});
				
				if (NewEntry==1) {
					if ($('XObject_'+thiselement.id)) {																			
						var NewValue=DSJS.Trim($('XObject_'+thiselement.id).value);
						NewValue=NewValue.substring(1,NewValue.length);						
						NewValue=NewValue.substring(0,NewValue.length-1);									
						var CheckStruc=NewValue.evalJSON([sanitize=false]);	
						if (CheckStruc.Selected==null)
							NewValue=NewValue.substring(0, NewValue.length-1)+',"Selected":"1"}';
					}
					else
						alert('Expecting an textarea with the ID: XObject_+thiselement.id')
					
					if (DSXObject.JSON.JSONString=='[]' || DSXObject.JSON.JSONString=='')
						$(DSXObject.ElementBox).value='['+NewValue+']';
					else {						
						DSXObject.JSON.JSONString=DSXObject.JSON.JSONString.substring(0, DSXObject.JSON.JSONString.length-1);
						$(DSXObject.ElementBox).value=DSXObject.JSON.JSONString+','+NewValue+']';
					}
					DSXObject.BuildOutput();
				}
				else {
					DSXObject.JSON.BuildString();
					DSXObject.BuildOutput();
				}
										
			}							
		}
		else {								
			DSXObject.JSON.BuildArray();
			DSXObject.JSON.JSONArray.each(function(data) {	
				if (thiselement.value==data.LinkIDType+':'+data.LinkID) {
					data.Selected=0;										
					$break;										
				}																								
			});	
			$(DSXObject.ElementBox).value=DSXObject.JSON.JSONArray.toJSON();
			DSXObject.JSON.BuildString();
			DSXObject.BuildOutput();								
		}						
	}
};

var DSAttachment={
	SubmitSearch:function(QueryString) {
		var url=dsxpath+'dynasite.cfm?dsmid='+DSMID+'&'+QueryString+'&dsxhr=1&dscaller='+window.name;
		new Ajax.Updater('message_message_attachment_search', url,{
			evalScripts:true,
			postBody:"message_message_attachment_search_dsttidlist="+$('message_message_attachment_search_dsttidlist').value+"&attachmentSearchphrase="+encodeURIComponent($('attachmentSearchphrase').value)
		}); 
	}
};	


function DSContactAction(theElement,theAction,theCommand,theDSCAIDListElement,theDSTTIDListElement) {
	// alert('Element:'+theElement.options[theElement.selectedIndex].value+'theAtcion:'+theAction+'theCOmmand:'+theCommand+'theDSCAIDElement:'+theDSCAIDListElement.value+'theDSTTIDListElement'+theDSTTIDListElement);
	if(theAction=='selectedindex')
		theAction=theElement.options[theElement.selectedIndex].value;
	theList=theDSCAIDListElement.value;
	if(DSJS.Len(theList)==0) {
		theElement.selectedIndex=0;
		return;
	}
	if(theAction=='action_message') {
		dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_message_new&cancelalert=1&dscaid_to='+theList,'dspopup2','message_message_message_new');
	}
	else if(theAction=='action_event') {
		dsloader(dsxpath+'dynasite.cfm?dscmd=calendar_calendar_event_new&dscaid_foreign='+theList,'dspopup2','calendar_calendar_event_new');
		
	}	
	else if(theAction=='action_task') {
		dsloader(dsxpath+'dynasite.cfm?dscmd=calendar_calendar_task_new&dscaid_foreign='+theList,'dspopup2','calendar_calendar_task_new');
		
	}	
	else if(theAction=='action_export') {
		dsloader(dsxpath+'dynasite.cfm?dscmd=contact_contact_contact_exportconf&dscaidlist='+theList,'dspopup2','contact_contact_contact_exportconf');
		
	}	
	else if(theAction=='action_print') {
		dsloader(dsxpath+'dynasite.cfm?dscmd=contact_contact_contact_printconf&dscaidlist='+theList,'dspopup2','contact_contact_contact_printconf');
		
	}	
	else if(theAction=='action_delete') {
		conf=confirm(DSLang('alertdeletecontacts'))
		if(conf==1)
			dsloader(dsxpath+'dynasite.cfm?dscmd=contact_contact_contact_delete&dscaidlist='+theList,'dsloader','contact_contact_contact_delete');
	}	
	else if(DSJS.ListGetAt(theAction,1,'_')=='tagadd') {
		theDSTTIDListElement.value=DSJS.ListGetAt(theAction,2,'_');
		$(theCommand+'_formaction').value='tagadd'
		DSDispatchEvent(theCommand+'_tagfilterbutton');
	}	
	else if(DSJS.ListGetAt(theAction,1,'_')=='tagdelete') {
		theDSTTIDListElement.value=DSJS.ListGetAt(theAction,2,'_');
		$(theCommand+'_formaction').value='tagdelete'
		DSDispatchEvent(theCommand+'_tagfilterbutton');
	}	
	theElement.selectedIndex=0;

}

function dsmanagermenu(type) {
	if(type=='show') {	
		document.getElementById('dsmanagermenu').style.display='block';	
		document.getElementById('dsmanagermenu_hide').style.display='none';	
	}
	else {
		document.getElementById('dsmanagermenu').style.display='none';
		document.getElementById('dsmanagermenu_hide').style.display='block';	
	}
}



function DSCheckboxFilter(thiscmd,thispage,prefix,selector,optionlist){
	var i=0;
	var listelement=0;
	var statuslist=0;
	idlistelement='';
	DSOptionList(optionlist);
	if($(thiscmd+'_dsttidlist')) {
		listelement=$(thiscmd+'_dstagobjectidlist');
		theList=listelement.value;
	}
	if(idlistelement!='')
		messagetable=$(idlistelement);
	else	
		messagetable=$(thiscmd+'_'+$(thiscmd).readAttribute('page')+'_table');



	//messageids=messagetable.messageids.split(','); falsch da Firefox das nicht erkennt!
	messageids=messagetable.attributes["idlist"].nodeValue.split(',');
	//alert(messageids.length)
	//<tr dsmessageinfo="#DSGetMessages.MessageStatus[i]#,#DSGetMessages.IsMarked[i]#" id="dsmessage_#DSGetMessages.ID[i]#">
		//<td style="width:1em;"><input type="checkbox" id="dsmessage_chk_#DSGetMessages.ID[i]#"></td> 
		//<td style="width:0.5em;text-align:center"><img src="#Request.DSImagePath#icon/email_#DSGetMessages.MessageStatus[i]#.gif" / style="padding:0 0.3em 0 0.3em;">#PriorityCode#</td>
		//<td onclick="DSSelectRow($(''tr_#DSGetMessages.ID[i]#''),#DSGetMessages.DSCAID_From[i]#);#TheAccordionCode#">#Message_Username#</td>
		//<td onclick="DSSelectRow($(''tr_#DSGetMessages.ID[i]#''),#DSGetMessages.DSCAID_From[i]#);#TheAccordionCode#" nowrap="nowrap">#Message_Title#</td>
		//<td onclick="DSSelectRow($(''tr_#DSGetMessages.ID[i]#''),#DSGetMessages.DSCAID_From[i]#);#TheAccordionCode#" nowrap="nowrap">#Message_Date#</td>
		//<td><a #TheDelConfirm# href="#DSLoader('dscmd=message_message_#Box#_#TheDelAction#&dsmmid=#DSGetMessages.ID[i]#&dsbox=#Box#','element:#element#,target:dsloader')#">Del</a></td>
	//</tr>
	//selector: all, none, read, unread, marked, unmarked
	for (i=0;i<messageids.length;i++){
		theid=messageids[i];
		chk_box=$(thiscmd+'_checkbox_'+theid)
		if(chk_box!=null) {

			//info=$('dsmessage_'+messageids[i]).dsmessageinfo.split(',');
			if($(prefix+'_'+messageids[i])) {
				statuslist=1;
				info=$(prefix+'_'+messageids[i]).attributes["statuslist"].nodeValue.split(',');
			}
			//alert(info[0]+'...'+info[1])
			tocheck=false;
			if (selector=='all') {
				tocheck=true;
			}
			else if (selector=='none')
				tocheck=false;

			else if (statuslist && (selector=='opened' || selector=='open') && info[0]==selector){
				tocheck=true;
			}

			else if (statuslist && selector=='read' && info[0]==selector){
				tocheck=true;
			}
			else if (statuslist && selector=='unread' && info[0]==selector){
				tocheck=true;
			}
			else if (statuslist && selector=='YES' && info[0]==selector){
				tocheck=true;
			}
			else if (statuslist && selector=='NO' && info[0]==selector){
				tocheck=true;
			}			
			else if (statuslist && selector=='marked' && info[1]=='1'){
				tocheck=true;
			}
			else if (statuslist && selector=='unmarked' && info[1]=='0'){
				tocheck=true;
			}
			else if (statuslist && selector=='owner_'+DSCAID && info[2]=='owner_'+DSCAID) {
				tocheck=true;
			}
			else if (statuslist) {
				findValue=DSJS.ListFind($(prefix+'_'+messageids[i]).attributes["statuslist"].nodeValue,selector);
				if(findValue!=0)
					tocheck=true;
			}
			chk_box.checked=tocheck;
			if($(thiscmd+'_dstagobjectidlist')) {
				thePosition=DSJS.ListFind(theList,theid);
				if(tocheck==true && thePosition==0) {
					if(DSJS.Len(theList)==0)
						theList=theid;
					else
						theList=DSJS.ListAppend(theList,theid);
				}
				else if(tocheck==false) {
					thePosition=DSJS.ListFind(theList,theid);
					if(thePosition)
						theList=DSJS.ListDeleteAt(theList,thePosition);
				}
			}
		}
	}
	if($(thiscmd+'_dstagobjectidlist')) {
		listelement.value=theList;
	}
	if($(thiscmd+'_actionselect')) {
		if(theList.length) {
			$(thiscmd+'_actionselect').disabled=false;
		}
		else {
			$(thiscmd+'_actionselect').disabled=true;
		}
	}
}



function DSElementSelect(idlistorelement,selector,optionlist) {
	var i=0;
	var listelement=0;
	var statuslist=0;
	var selectortype='checkbox';
	var selectorprefix='';
	var idprefix='';
	var cmd='';
	
	DSOptionList(optionlist);
// tagging form field
	if($(cmd+'_dsttidlist')) {
		listelement=$(cmd+'_dstagobjectidlist');
		theList=listelement.value;
	}
	idlistelement=$(idlistorelement);
	//messageids=messagetable.messageids.split(','); falsch da Firefox das nicht erkennt!
	idlist=idlistelement.attributes["idlist"].nodeValue.split(',');
	for (i=0;i<idlist.length;i++){
		theid=idlist[i];
		chk_box=$(idprefix+theid)
		if(chk_box!=null) {
			//info=$('dsmessage_'+messageids[i]).dsmessageinfo.split(',');
			if($(prefix+'_'+messageids[i])) {
				statuslist=1;
				info=$(idprefix+'_'+idlist[i]).attributes["statuslist"].nodeValue.split(',');
			}
			//alert(info[0]+'...'+info[1])
			tocheck=false;
			if (selector=='all') {
				tocheck=true;
			}
			else if (selector=='none')
				tocheck=false;
			else if (statuslist) {
				findValue=DSJS.ListFind(info,selector);
				if(findValue==1)
					tocheck=true;
			}
			chk_box.checked=tocheck;
			if($(cmd+'_dstagobjectidlist')) {
				thePosition=DSJS.ListFind(theList,theid);
				if(tocheck==true && thePosition==0) {
					if(DSJS.Len(theList)==0)
						theList=theid;
					else
						theList=DSJS.ListAppend(theList,theid);
				}
				else if(tocheck==false) {
					thePosition=DSJS.ListFind(theList,theid);
					if(thePosition)
						theList=DSJS.ListDeleteAt(theList,thePosition);
				}
			}
		}
	}
	if($(cmd+'_dstagobjectidlist')) {
		listelement.value=theList;
	}
	if($(cmd+'_actionselect')) {
		if(theList.length) {
			$(thiscmd+'_actionselect').disabled=false;
		}
		else {
			$(cmd+'_actionselect').disabled=true;
		}
	}	
	
	
}



function DSCheckboxFilter_GetChecked(thiselement){
	var i=0;
	var m_ids=[];
	messagetable=$(thiselement+'_'+$(thiselement).readAttribute('page')+'_table');
	messageids=messagetable.attributes["idlist"].nodeValue.split(',');
	if(messageids != '') {
		for (i=0;i<messageids.length;i++){
			if($(thiselement+'_checkbox_'+messageids[i])){
				chk_box=$(thiselement+'_checkbox_'+messageids[i])
				if ($(thiselement+'_checkbox_'+messageids[i]).checked==true)
					m_ids[m_ids.length]=messageids[i];
			}
		}
	}
	return m_ids;
// alert(action+' : '+m_ids.join(','));
}


//Start
function DSMessage_Action(thiscmd,optionlist){
	thispage='';
	action='';
	box='';
	dspagerows='';
	ajax=1;
	messageid=0;
	urladd='';
	element='';
	idarray=[];
	DSOptionList(optionlist);
	if(element=='')
		element=thiscmd;
	if (action=='options')
		action=$(element+'_actionselect').value;
	
	tempidarray=DSCheckboxFilter_GetChecked(element);
	if(tempidarray.length!=0 && messageid==0)
		idarray=tempidarray;
	else
		idarray[idarray.length]=messageid;	
	
	/*if(action!='' && ajax==0) {	
		conf=1;
		if((box=='trash' && action=='setasdeleted') || action=='exchangedelete')
			conf=confirm(DSLang('alertdeleterecords'))
		if(conf==1 && action!='exchangeassign')
			dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_'+box+'_update&dselement='+element+'&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsaction='+action+'&dsmmidlist='+idarray.join(',')+urladd,'dsloader',thiscmd);
		else if (action=='exchangeassign')
			dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_'+box+'_copyconf&dselement='+element+'&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsmmidlist='+idarray.join(',')+urladd,'dspopup2','message_message_'+box+'_copyconf');
	}*/
	
	if(action!='' && ajax==1 && action!='exchangeassign'){
		conf=1;
		if(messageid==0 && (action=='setastrash' || action=='setasdeleted' || action=='exchangedelete'))
			conf=confirm(DSLang('alertdeleterecords'))		
		if(conf==1){		
			new Ajax.Request(dsxpath+'dynasite.cfm?dscmd=message_message_'+box+'_update&dselement='+element+'&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsaction='+action+'&dsmmidlist='+encodeURIComponent(idarray.join(','))+urladd, {method: 'get'});
			for(i=0;i<idarray.length;i++){
				if(action=='setasmarked' || action=='setasunmarked'){
					var imgsrc=action=='setasmarked' ? '/dsglobal/image/icon/award_star_gold_3.gif' : '/dsglobal/image/icon/award_star_silver_3.gif';
					$$('table.dsmessage span[name="dsmessage_'+idarray[i]+'_marked"] img').each(function(img){$(img).src=imgsrc});
					tempaction=(action=="setasmarked") ? "setasunmarked" : "setasmarked";
					status=(action=="setasmarked") ? 0 : 1;
					var cmdstr='DSMessage_Action(\''+thiscmd+'\',\'thispage:'+thispage+',action:'+tempaction+',urladd:'+urladd+',box:'+box+',dspagerows:'+dspagerows+',ajax:1,messageid:'+idarray[i]+'\')';
					$$('table.dsmessage span[name="dsmessage_'+idarray[i]+'_marked"]').each(function(span){$(span).onclick=function(){eval(cmdstr)}});			
					$$('table.dsmessage tr[name="dsmessage_'+idarray[i]+'"]').each(function(tr){$(tr).attributes.statuslist.value=DSJS.ListFirst($(tr).attributes.statuslist.value,',')+','+status});
				}
				else if(action=='setasred' || action=='setasunred'){
					var imgsrc=action=='setasred' ? '/dsglobal/image/icon/email_opened.gif' : '/dsglobal/image/icon/email_unread.gif';
					$$('table.dsmessage span[name="dsmessage_'+idarray[i]+'_statusicon"] img').each(function(img){$(img).src=imgsrc});
					tempaction=(action=="setasred") ? "setasunred" : "setasred";
					boldcode=(action=="setasred") ? "normal" : "bold";
					var cmdstr='DSMessage_Action(\''+thiscmd+'\',\'element:'+element+',thispage:'+thispage+',action:'+tempaction+',urladd:'+urladd+',box:'+box+',dspagerows:'+dspagerows+',ajax:1,messageid:'+idarray[i]+'\')';
					$$('table.dsmessage span[name="dsmessage_'+idarray[i]+'_statusicon"]').each(function(span){$(span).onclick=function(){eval(cmdstr)}});
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_name"]').each(function(td){$(td).setStyle({fontWeight:boldcode});});
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_title"]').each(function(td){$(td).setStyle({fontWeight:boldcode});});
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_date"]').each(function(td){$(td).setStyle({fontWeight:boldcode});});  
					
					status=(action=="setasred") ? "opened" : "unread";
					$$('table.dsmessage tr[name="dsmessage_'+idarray[i]+'"]').each(function(tr){$(tr).attributes.statuslist.value=status+','+DSJS.ListLast($(tr).attributes.statuslist.value,',')});
				}
				else if(action=='exchangesetasunred' || action=='exchangesetasred'){
					var imgsrc=action=='exchangesetasred' ? '/dsglobal/image/icon/email_opened.gif' : '/dsglobal/image/icon/email_unread.gif';
					$$('table.dsmessage span[name="dsmessage_'+idarray[i]+'_statusicon"] img').each(function(img){$(img).src=imgsrc});
					tempaction=(action=="exchangesetasred") ? "exchangesetasunred" : "exchangesetasred";
					boldcode=(action=="exchangesetasred") ? "normal" : "bold";
					var cmdstr='DSMessage_Action(\''+thiscmd+'\',\'element:'+element+',thispage:'+thispage+',action:'+tempaction+',urladd:'+urladd+',box:'+box+',dspagerows:'+dspagerows+',ajax:1,messageid:'+idarray[i]+'\')';
					$$('table.dsmessage span[name="dsmessage_'+idarray[i]+'_statusicon"]').each(function(span){$(span).onclick=function(){eval(cmdstr)}});
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_name"]').each(function(td){$(td).setStyle({fontWeight:boldcode});});
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_title"]').each(function(td){$(td).setStyle({fontWeight:boldcode});});
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_date"]').each(function(td){$(td).setStyle({fontWeight:boldcode});});  
					
					status=(action=="exchangesetasred") ? "opened" : "unread";
					$$('table.dsmessage tr[name="dsmessage_'+idarray[i]+'"]').each(function(tr){$(tr).attributes.statuslist.value=status+','+DSJS.ListLast($(tr).attributes.statuslist.value,',')});
				}
				
				else if(action=='setastrash' || action=='setasdeleted'){
					$$('table.dsmessage tr[name="dsmessage_'+idarray[i]+'"]').each(function(tr){$(tr).next(0).setStyle({display:"none"});$(tr).setStyle({display:"none"});});
				}		
				else if(action=='exchangedelete'){
					$('dsmessage_'+idarray[i]).next(0).remove();
					$('dsmessage_'+idarray[i]).remove();
				}
				else if(DSJS.ListFindNoCase('flag,flag_red,flag_orange,flag_yellow,flag_green,flag_blue,flag_purple',action))
					$$('table.dsmessage td[name="dsmessage_'+idarray[i]+'_flag"]').each(function(img){$(img).innerHTML='<img src="'+dsgifpath+'icon/'+action+'.png"  alt="'+action+'" title="'+action+'" class="#class#" style="height:16px;width:16px;" />'});
			}
		}
	}
	else if(action!='' && ajax==1 && action=='exchangeassign' && idarray[0]!=0)
		dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_'+box+'_copyconf&dselement='+element+'&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsmmidlist='+encodeURIComponent(idarray.join(','))+urladd,'dspopup2','message_message_'+box+'_copyconf');
	$(element+'_actionselect').selectedIndex=0;
}
//End


//Start
function DSTicket_Action(thiscmd,thispage,action,box,dspagerows){
	if (action=='options'){
		action=$(thiscmd+'_'+thispage+'_options').value;
	}
	idarray=DSCheckboxFilter_GetChecked(thiscmd);
	if(action!='' && idarray.length>= 1) {
		conf=1;
		if(box=='trash' && action=='setasdeleted')
			conf=confirm(DSLang('alertdeleterecords'))
		if(conf==1) 
			dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_ticket_update&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsaction='+action+'&dsidlist='+idarray.join(','),'dsloader');
	}
	else {
		if(DSJS.ListGetAt(action,1,'_')=='filter') {
				dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_ticket_view&dscentral=project&dscaidview='+DSJS.ListGetAt(action,2,'_')+'&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsaction='+action+'&dsidlist='+idarray.join(','),'dsloader');
		}	
	}
	$(thiscmd+'_'+thispage+'_options').selectedIndex=0;
}
//End

//Start

function DSAsset_Action(thiselement,thispage,action,dspagerows){
	var disallowedaction='';  // 2009-01-02 [AP] Disallowed Action List hinzugefügt
	if (action=='options')
		action=$(thiselement+'_actionselect').value;	
	currentstep='';
	idarray=DSCheckboxFilter_GetChecked(thiselement);
	idlist=idarray.join(',');
	if(action!='' && idarray.length>= 1) {
		conf=1;
		if(action=='delete') {
			conf=confirm(DSLang('alertdeleteassets'));
			if(conf==1) {
				for(listitem=1;listitem<=idarray.length;listitem++) {					
					ID=DSJS.ListGetAt(idlist,listitem,',');
					disallowedaction=$($(thiselement+'_dsrid_'+ID)).readAttribute('disallowedaction');					
					if (disallowedaction==null || DSJS.ListFindNoCase(disallowedaction,'asset_delete')==false)
						$(thiselement+'_dsrid_'+ID).style.display='none';
					$(thiselement+'_checkbox_'+ID).checked=false;
				}	
			}
			if(conf==1) {
				dsloader(dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_action&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsaction='+action+'&dsridlist='+idlist,'dsloader',thiselement+'_message');
				$(thiselement+'_actionselect').disabled=true;
			}
		}
		else if(action=='clipboardadd') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=contact_clipboard_clipboard_insert&LinkIDType=dsrid&LinkID='+idlist,'dsloader','contact_clipboard_clipboard_insert');
		}
		else if(action=='clipboardremove') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=contact_clipboard_clipboard_delete&LinkIDType=dsrid&LinkID='+idlist,'dsloader','contact_clipboard_clipboard_delete');
		}		
		else if(action=='read') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=object_log_user_insert&LinkIDType=dsrid&LinkID='+idlist,'dsloader',thiselement+'_message');
		}
		else if(action=='unread') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=object_log_user_delete&LinkIDType=dsrid&LinkID='+idlist,'dsloader',thiselement+'_message');
		}
		else if(action=='download') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_action&dspagerows='+dspagerows+'&dspageaction='+thispage+'&dspage='+thispage+'&dsaction='+action+'&dsridlist='+idlist,'dsloader','asset_asset_asset_action');
		}				
		else if(action=='share') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_message_new&cancelalert=1&DSRIDList='+idlist,'dspopup1','message_message_message_new');
		}
		else if(action=='attachemail') {
			dsloader(dsxpath+'dynasite.cfm?dscmd=message_message_message_new&cancelalert=1&DSRIDList='+idlist,'dspopup1','message_message_message_new');
		}		
	}
	$(thiselement+'_actionselect').selectedIndex=0;	
}
//END

//Start
function dsviewcheck () {
	// Explorer=Full
	theloaderheight=100;
	if(top.DSLoaderDisplay.indexOf('dsloader')==-1)
		theloaderheight=0;
	// Manager/Explorer
	viewmode='split';
	if(DSSplitMode=='horizontal') {
		if(top.$('dsadminset').rows==DSNavBarHeight+',0,*,'+theloaderheight)
			viewmode='MAIN';
		// Mnanager=Full
		else if(top.$('dsadminset').rows==DSNavBarHeight+',*,0,'+theloaderheight)
			viewmode='dsmanager';
	}
	else {
		if(top.$('dsframeset_vertical').cols=='*,0')
			viewmode='MAIN';
		// Mnanager=Full
		else if(top.$('dsframeset_vertical').cols=='0,*')
			viewmode='dsmanager';
		
	}
return viewmode;
}
//END

//Start
dsasset_contextmenutag='<a class="dsconmenu" href="javascript: dynasite();" onclick="';

function DSAsset_ContextMenu(e,dsrid,optionlist) {
	var menutext='';	
	resetcommand='';
	DSSortBy='';
	DSSortDirection='';
	clipboard=0;
	querystring='';
	preview=1;
	download_role='dsdefault';
	version_role='dsdefault';
	attachment_role='dsdefault';
	delete_role='dsdefault';
	imageedit_role='dsdefault';
	disallowedaction=''; //2009-01-02 [AP] added
	asset_dscaid=DSCAID;
	per=28; // Permissiong: Editor	
	isversioning=0;
	isattachment=0;
	isattachmentset=0; // 2008-12-09 [AP] Added, war vorher die Variable "isattachment". isattachment bezieht sich jetzt direkt auf das Asset und nicht mehr auf das Asset Set
	isimageedit=0;	
	DSOptionList(optionlist);
	QueryString='&amp;dsrandom='+DSRandom+querystring;
	if(contenttype==null)
		contenttype='';
	if (DSSortBy!='')
		DSSortBy='&DSSortBy='+DSSortBy;
	if (DSSortDirection!='')
		DSSortBy+='&DSSortDirection='+DSSortDirection;	
	QueryString+=DSSortBy;
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	// Menu Items
	menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_detail'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'asset_asset_asset_detail\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('details')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('details')+'</a>';
	
	if (preview==1) {
		if(DSJS.FindNoCase('image',contenttype) && (DSJS.FindNoCase('jpg',contenttype)  || DSJS.FindNoCase('jpeg',contenttype)  || DSJS.FindNoCase('png',contenttype) || DSJS.FindNoCase('gif',contenttype) || DSJS.FindNoCase('pjpeg',contenttype)))
			menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_preview'+QueryString+'&amp;dspopup_refreshalert=0&amp;dsrid='+dsrid+'\',\'dspopup2\',\'asset_asset_asset_preview\',\'popupwarning:0,cancelalert:0\')" onmouseover="window.status=\''+DSLang('preview')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('preview')+'</a>';
	}
	if(DSArrayFind(DSRoleNames,download_role))
		menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_action'+QueryString+'&amp;dsaction=download&amp;dsridlist='+dsrid+'\',\'dspopup2\',\'asset_asset_asset_action\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('download')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('download')+'</a>';
	if((per==27 && asset_dscaid==DSCAID) || per==28)
		menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_edit'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'asset_asset_asset_edit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'</a>';
	/*
	if(clipboard==1)
		menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=contact_clipboard_clipboard_delete'+QueryString+'&amp;dsrid='+dsrid+'&amp;linkidtype=dsrid&amp;linkid='+dsrid+'\',\'dsloader\',\'contact_clipboard_clipboard_delete\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('remove')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('remove')+'</a>';
	else
		menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=contact_clipboard_clipboard_insert'+QueryString+'&amp;dsrid='+dsrid+'&amp;linkidType=dsrid&amp;linkid='+dsrid+'\',\'dsloader\',\'contact_clipboard_clipboard_insert\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('bookmark')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('bookmark')+'</a>';		
	*/
	if(DSJS.FindNoCase('image',contenttype) && ((per==27 && asset_dscaid==DSCAID) || per==28) && DSArrayFind(DSRoleNames,imageedit_role) && isimageedit)
		menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_edit'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'asset_asset_asset_edit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;Bildbearbeitung</a>';
	if (isattachment==0) {
		if(per==28 && isversioning==1 && DSArrayFind(DSRoleNames,version_role))
			menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_upload_upload_new'+QueryString+'&amp;dsprid='+dsrid+'&newversion=1\',\'dspopup2\',\'asset_upload_upload_new\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('newversion')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('newversion')+'</a>';
		if(((per==27 && asset_dscaid==DSCAID) || per==28) && isattachmentset==1 && DSArrayFind(DSRoleNames,attachment_role))
			menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_upload_upload_new'+QueryString+'&amp;dsprid='+dsrid+'&newattachment=1\',\'dspopup2\',\'asset_upload_upload_new\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('newattachement')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('newattachement')+'</a>';
	}
	if(DSJS.FindNoCase('image',contenttype) && isimageedit==1)
		menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_article_new'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'content_article_article_new\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('newarticle')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('newarticle')+'</a>';
	//menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_edit'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'asset_asset_asset_edit\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;Drucken</a>';
	//menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_edit'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'asset_asset_asset_edit\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;RSS</a>';
	if(DSJS.ListFindNoCase(disallowedaction,'asset_delete','|')==false && ((per==27 && asset_dscaid==DSCAID) || per==28)){
		// 2008-02-13 [AP] das gehört hier nicht hin menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_edit'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup1\',\'asset_asset_asset_edit\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;Verteilen</a>';
		if(DSArrayFind(DSRoleNames,delete_role)){
			menutext+=dsasset_contextmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_delconf'+QueryString+'&amp;dsrid='+dsrid+'\',\'dspopup2\',\'asset_asset_asset_delconf\',\'cancelalert:0\')" onmouseover="window.status=\''+DSLang('delete')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('delete')+'</a>';
		}
	}

	DSColorSchemeBar(3,'variable');
	menutext+='<div class="dscontextmenutitle" style="cursor:pointer">Asset ['+dsrid+']</div>'+colorschemebar+'</div>';
	DSContextShow(e,menutext);
}



function DSAsset(thiselem,activeelement,optionlist) {
	onclick='display';
	reloadtype='display';
	trigger='cmd';
	cmd='';
	IsLoaded=0;
	dsrid=0;
	caller='dynasite.cfm';
	qs='';
	dscatid='';
	DSOptionList(optionlist);
	if (qs=='dscatid') {
		thisvalue=thiselem.value;
		thiselement='asset_asset_asset_assetselect_'+thisvalue;
		activeelement='asset_asset_asset_assetselect';
		cmd+='&'+qs+'='+thisvalue;
		if(cmd!='')
			IsLoaded=top.DSFindLoader_Loaded(thiselement,this.window);
		if(cmd!='' && $(thiselement) && $(thiselement).innerHTML.length==0 && IsLoaded<=0)
			onclick='load';
		if($(thiselement).innerHTML.length==0)
			IsLoaded=-1;
		//alert('Element:'+thiselement+' IsLoaded:'+IsLoaded+' Onclick:'+onclick+' dsrid:'+dsrid+' cmd:'+cmd);
		if((IsLoaded<=0 && onclick=='load') || (IsLoaded>=0 && reloadtype=='reload' && $(thiselement).style.display=='none'))
			dsloader(caller+'?'+trigger+'='+cmd+'&dsrid='+dsrid,'dsloader',thiselement);		
			//new Ajax.Updater(thiselement,caller+'?'+trigger+'='+cmd+'&dsrid='+dsrid);

		DSStyle(thiselement,'dsresize:0,display,dsnavname:'+activeelement);
		thiselem.disabled=false;
	}
	else if (qs=='dsrid') {
		thisvalue=thiselem.options[thiselem.selectedIndex].value;
		thiselement='asset_asset_asset_assetdefaults';
		activeelement='asset_asset_asset_assetdefaults';
		cmd+='&'+qs+'='+thisvalue;


		if(thiselem.options[thiselem.selectedIndex].value!=0)
			dsloader(caller+'?'+trigger+'='+cmd,'dsloader',thiselement);
	}
	else if (qs=='directory') {
		for (i=0;i<thiselem.length;i++){
			if(thiselem.options[i].value==dscatid){
				thiselem.selectedIndex=i;
				break;
			}
		}
		DSAsset(thiselem,activeelement,'trigger:dscmd,cmd:asset_asset_asset_assetselect,qs:dscatid,onclick:load,dsrid:'+dsrid);
	}	
}
//End

// Sortable Start


// settings array is written in the command template
// var settings = {};
/*
	this_window.settings = { 
		'dswidget-column-0': ['dswidget_searchview', 'dswidget_widget_widget_article_view'], 
		'dswidget-column-1': ['dswidget_widget_widget_statistic_view', 'dswidget_widget_widget_task_view', 'dswidget_widget_widget_event_view', 'dswidget_widget_widget_support_view']
	};
*/
// var DSSortable;
 // Event.observe(window, 'load', init, false);

function DSPaletteStyle(){
	container=$('dspalette_column');
	if (!DSSortable_Palette.options.saveurl)
		return;
	if (container.id == DSSortable_Palette.options.blocklist)
		return;
	var url = DSSortable_Palette.options.saveurl;
	var postBody = container.id + '=';
	var blocks = document.getElementsByClassName(DSSortable_Palette.options.block, container);					
	for(i=0; i<blocks.length;i++){
		commacode='';
		if(i!=blocks.length-1)
			commacode=',';
		if(blocks[i].getElementsByClassName('nix')[0].getStyle('display')=='block')
			styledisplay='block';
		else
			styledisplay='none';
		postBody+=blocks[i].id+':'+styledisplay+commacode;
	}
	postBody = '' + postBody;
	//alert(url);
	new Ajax.Request(url, {method: 'post', postBody: postBody});
}


DSDragDrop_Palette=0;
DSDragDrop_Explorer=0;
DSDragDrop_Manager=0;

function DSDragDropSwitch(sortable,element) {
	thissortablewindow=top.MAIN;
	if(top.MAIN==null)
		thissortablewindow=window;	
	if(sortable=='dsmanager' && top.MAIN!=null)
		thissortablewindow=window;	
	
	// thissortablewindow=window;	
	// alert(window.name);
	if (thissortablewindow.isCSS==1) {
		dropblock=thissortablewindow.$$('.dscolumn');
//		dropblock=thissortablewindow.$(element).select('[class="dscolumn"]');
		// dropblock=$('dscolumn1', 'dscolumn2', 'dscolumn3', 'dscolumn3', 'dscolumn4', 'dscolumn1', 'dscolumn1');
		if(sortable=='dsexplorer') {
			if(DSDragDrop_Explorer==1) {
				document.getElementById('dsdragdropmode_explorer_0').style.display='none';
				document.getElementById('dsdragdropmode_explorer_1').style.display='block';
				thissortablewindow.DSSortable_Explorer_Stop();
				DSDragDrop_Explorer=0;
				dropblock.each(function(s,i) {
					s.removeClassName('dsdropblock'+i);
				});
			}
			else {

				document.getElementById('dsdragdropmode_explorer_0').style.display='block';
				document.getElementById('dsdragdropmode_explorer_1').style.display='none';
				thissortablewindow.DSSortable_Explorer_Start();
				DSDragDrop_Explorer=1;
				dropblock.each(function(s,i) {
					s.addClassName('dsdropblock'+i);
				});
			}
					 
		}
		else if(sortable=='dspalette') {
			if(DSDragDrop_Palette==1) {
				document.getElementById('dsdragdropmode_palette_0').style.display='none';
				document.getElementById('dsdragdropmode_palette_1').style.display='block';
				thissortablewindow.DSSortable_Palette_Stop();
				DSDragDrop_Palette=0;
			}
			else {
				document.getElementById('dsdragdropmode_palette_0').style.display='block';
				document.getElementById('dsdragdropmode_palette_1').style.display='none';
				thissortablewindow.DSSortable_Palette_Start();
				DSDragDrop_Palette=1;
			}				
		}
	}
	if(sortable=='dsmanager') {
		dropblock=thissortablewindow.$(element).select('div.dswidget_column');
		if(eval(element+'_DSDragDrop_Manager==1')) {
			// document.getElementById('dsdragdropmode_palette_0').style.display='none';
			// document.getElementById('dsdragdropmode_palette_1').style.display='block';
			thissortablewindow.DSSortable_Manager_Stop(element);
			eval(element+'_DSDragDrop_Manager=0');
			dropblock.each(function(s,i) {
				s.removeClassName('dsdropblock'+i);
			});
		}
		else {
			// document.getElementById('dsdragdropmode_palette_0').style.display='block';
			// document.getElementById('dsdragdropmode_palette_1').style.display='none';
			thissortablewindow.DSSortable_Manager_Start(element);
			eval(element+'_DSDragDrop_Manager=1');
			dropblock.each(function(s,i) {
				s.addClassName('dsdropblock'+i);
			});
		}				
	}
}	




function DSSortable_Navigation_Start() {
	DSSortable_Navigation = new DSSortable({
		portal: 'dsmenu2',
		column: 'dsmenus',
		block: 'dsmenuxx',
		content: '',
		handle: 'dsmenubutton',
		tag: 'li',
		tree: true,
		treeTag: 'ul',
		ghosting: false,
		accordion:false,		
		hoverclass: 'block-hover',
		toggle: 'dsarticle_blocktoggle',
		blocklist: '',
		blocklistlink: '',
		blocklisthandle: '',
		blocklistdragging:0,
		saveurl: ''
	});
	// $('dscolumn1_2').style.border='1px dashed #dddddd';
}

function DSSortable_Navigation_Init() {
	DSSortable_Navigation_Start();
	// DSSortable_Navigation.applySettings(DSSortable_Palette_Settings);
}


// wenn palette da ist 		blocklist: 'dsarticle_list',blocklistlink: 'dsarticle_listlink',
function DSSortable_Explorer_Start() {
	DSSortable_Explorer = new DSSortable({
		portal: 'dssubbody',
		column: 'dscolumn',
		block: 'dsarticle',
		content: 'dsarticle_content',
		handle: 'dsarticlebutton',
		tag: 'div',
		tree: false,
		treeTag: 'ul',
		ghosting: false,
		accordion:false,		
		hoverclass: 'dsexplorer_block_hover',
		toggle: 'dsarticle_blocktoggle',
		blocklist: '',
		blocklistlink: '',
		blocklisthandle: '',
		blocklistdragging:0,
		saveurl: DSAdminURL+'/dynasite.cfm?dscmd=content_article_article_sort&dssid='+DSSID
	});
	if(DSServerCust=="tcdds" && DSServerAdmin==1){
		Sortable.create("dsmenus",{
			dropOnEmpty:true,
			tree:true,
			handle:'dsmenubutton',
			treeTag:'ul',
			tag:'li',
			constraint:false,
			onChange: function (thisid){thisidtest=thisid;},
			onUpdate: function (container) {
				//alert($(thisidtest).up('ul',0).id);
				var postBody ='menulist=';
				var menuid=$(thisidtest).id.split('_');
				var parentmenuid=$(thisidtest).up('ul',0).id;				
				var blocks = $A(container.getElementsByTagName('li'));					
				postBody += blocks.pluck('id').join(',');
				postBody = 'menudssid='+DSSID+'&parentmenuid='+parentmenuid+'&menuid='+menuid[1]+'&' + postBody;
				//alert(postBody);
				new Ajax.Request(DSAdminURL+'/dynasite.cfm?dscmd=content_menu_menu_sort&dssid='+DSSID, {method: 'post', postBody: postBody});
			}
		});
	}
	// $('dscolumn1_2').style.border='1px dashed #dddddd';
}

function DSSortable_Explorer_Init() {
	DSSortable_Explorer_Start();
	DSSortable_Explorer.applySettings(DSSortable_Palette_Settings);
}

function DSSortable_Explorer_Stop() {
	if($('dsmenuarticle')!=null)
		Sortable.destroy('dsmenuarticle');
	if($('dsarticleheader')!=null)
		Sortable.destroy('dsarticleheader');
	if($('dsarticlefooter')!=null)
		Sortable.destroy('dsarticlefooter');
	if($('dscolumn1_1')!=null)
		Sortable.destroy('dscolumn1_1');

	if($('dscolumn1_2')!=null)
		Sortable.destroy('dscolumn1_2');
	if($('dscolumn2_2')!=null)
		Sortable.destroy('dscolumn2_2');

	if($('dscolumn1_3')!=null)
		Sortable.destroy('dscolumn1_3');
	if($('dscolumn2_3')!=null)
		Sortable.destroy('dscolumn2_3');
	if($('dscolumn3_3')!=null)
		Sortable.destroy('dscolumn3_3');

	if($('dsarticle_list')!=null)
		Sortable.destroy('dsarticle_list');
	if($('dsmenus')!=null)
		Sortable.destroy('dsmenus');

}

function DSSortable_Palette_Start() {
	DSSortable_Palette = new DSSortable({
		portal: 'dspalette',
		column: 'dspalette_widgetcolumn',
		block: 'dswidget',
		content: 'dswidget_content',
		handle: 'dsaccordion',
		tag: 'div',
		tree: false,
		treeTag: 'ul',
		ghosting: false,
		accordion:true,
		hoverclass: 'block-hover',
		toggle: 'dswidget_blocktoggle',
		blocklist: 'dspalette_widget_list',
		blocklistlink: 'dspalette_listlink',
		blocklisthandle: '',
		blocklistdragging:0,
		saveurl:  dsxpath+'dynasite.cfm?dscmd=system_palette_palette_sort'
	});
}

function DSSortable_Palette_Init() {
	DSSortable_Palette_Start();
	DSSortable_Palette.applySettings(DSSortable_Palette_Settings);
	DSSortable_Palette_Stop();
}

function DSSortable_Palette_Stop() {
	Sortable.destroy('dspalette_column');
	Sortable.destroy('dspalette_widget_list');
}

function DSSortable_Manager_Stop(element) {
	$(element).select('.dswidget_column').each(function(theitem) {
		Sortable.destroy($(theitem));
	});
}

function DSSortable_Manager_Start(element) {
	theURL=dsxpath+'dynasite.cfm?dscmd=widget_widget_sort_sort&dselement='+element+'&dsxhr=1';	
	DSSortable_Manager = new DSSortable({
		portal: element,
		column: 'dswidget_column',
		dropOnEmpty:true,
		block: 'dswidget',
		content: 'dswidget_content',
		handle: 'dswidget_dragtoggle',
		tag: 'div',
		tree: false,
		treeTag: 'ul',
		ghosting: false,
		accordion:false,
		hoverclass: 'block-hover',
		toggle: 'dswidget_blocktoggle',
		blocklist: element+'_dswidget_list',
		blocklistlink: '',
		blocklisthandle: '',
		blocklistdragging:0,
		saveurl:theURL
	});
}

function DSSortable_Manager_Init(element) {
	if(this[element+'_DSDragDrop_Manager']==null)
		this[element+'_DSDragDrop_Manager']=0;	
	DSSortable_Manager_Start(element);
	DSSortable_Manager.applySettings(DSSortable_Manager_Settings);
	DSSortable_Manager_Start(element);
	
}
// END Sortable

// Start DSM_Upload
function dsupload_chk(){
	for(i=1;i<=ds_uploadcounter;i++){
		msg='';	
		text=$("filedata"+i).value.replace(/^\s+/g,'').replace(/\s+$/g,'')
		if (text.length==0)
			msg=msg+DSLang('alertnofile');
		else{
			if (text.indexOf("/")>=0){
				pfad=text.substring(0,text.lastIndexOf("/")+1)
				filename=text.substring(text.lastIndexOf("/")+1,text.length)
			}
			else if  (text.indexOf("\\")==-1) {
				pfad=text.substring(0,text.lastIndexOf(":")+1)
				filename=text.substring(text.lastIndexOf(":")+1,text.length)
			}
			else{
				pfad=text.substring(0,text.lastIndexOf("\\")+1)
				filename=text.substring(text.lastIndexOf("\\")+1,text.length)
			}			
			$('sendFiles').value=$('sendFiles').value+','+filename;		
		}
		/*else{
			if (text.indexOf("/")>=0){
				pfad=text.substring(0,text.lastIndexOf("/")+1)
				filename=text.substring(text.lastIndexOf("/")+1,text.length)
			}
			else if  (text.indexOf("\\")==-1) {
				pfad=text.substring(0,text.lastIndexOf(":")+1)
				filename=text.substring(text.lastIndexOf(":")+1,text.length)
			}
			else{
				pfad=text.substring(0,text.lastIndexOf("\\")+1)
				filename=text.substring(text.lastIndexOf("\\")+1,text.length)
			}
			extension = filename.substring(filename.lastIndexOf(".")+1,filename.length);
			filename=filename.substring(0,filename.lastIndexOf("."))
			filename_chk=filename.match(/([^A-Za-z0-9_\/-])/g,'');
			extension_chk=extension.match(/(\W)/g,'');
			if (filename.length==0)	
				msg+=DSLang('alertnofile');							
			if (filename.length>=81)
				msg+=DSLang('alertfilenametoolong');
			if (filename_chk!=null) {
				msg+=DSLang('alertinvalidfilename');
				msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",filename);
				msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",filename_chk);
			}
			if (extension.length==0)
				msg+=DSLang('alertnovalidfileextention');
			if (extension_chk!=null){				
				msg+=DSLang('alertinvalidextention');
				msg=DSJS.ReplaceNoCase(msg,"@@replace3@@",extension);
				msg=DSJS.ReplaceNoCase(msg,"@@replace4@@",extension_chk);
			}
		}*/
		if (msg.length>0){
			alert(msg);
			$('ds_uploadbutton').disabled=false;
			return false;
		}
		else{
			dsloader('none','dspopup2_loader','asset_upload_upload_check','type:add');
			$("uploadform"+i).submit();
		}
	}
}
//END DSM_Upload

// Start
function DSCheckInfos(which,allinfos,dscaid,elem){
	if(allinfos==1){
		if(elem.attributes["infochecked"].nodeValue==0){
			elem.firstChild.src=dsgifpath+'icon_checkbox_checked.gif';
			elem.attributes["infochecked"].nodeValue=1;
			if($(which).style.display=='none')
				DSDispatchEvent('dsacc_'+which+'_arrow');
		}
		else{
			elem.firstChild.src=dsgifpath+'icon_checkbox_unchecked.gif';
			elem.attributes["infochecked"].nodeValue=0;			
		}
		for(i=0; i<eval('document.contactsharing_'+dscaid+'.elements.length'); i++){
			if(elem.attributes["infochecked"].nodeValue==1 && eval('document.contactsharing_'+dscaid+'.elements[i].type')=='checkbox' && eval('document.contactsharing_'+dscaid+'.elements[i].checked')==false && eval('document.contactsharing_'+dscaid+'.elements[i].name.indexOf(which)')!=-1)
				eval('document.contactsharing_'+dscaid+'.elements[i].checked=true');
			else if(elem.attributes["infochecked"].nodeValue==0 && eval('document.contactsharing_'+dscaid+'.elements[i].type')=='checkbox' && eval('document.contactsharing_'+dscaid+'.elements[i].checked')==true && eval('document.contactsharing_'+dscaid+'.elements[i].name.indexOf(which)')!=-1)
				eval('document.contactsharing_'+dscaid+'.elements[i].checked=false');
		}
	}
	else{
		allchecked=1;
		for(i=0; i<eval('document.contactsharing_'+dscaid+'.elements.length'); i++){
			if(eval('document.contactsharing_'+dscaid+'.elements[i].type')=='checkbox' && eval('document.contactsharing_'+dscaid+'.elements[i].checked')==false && eval('document.contactsharing_'+dscaid+'.elements[i].name.indexOf(which)')!=-1){
				allchecked=0;
				if(i!=0 && eval('document.contactsharing_'+dscaid+'.elements[i-1].type')=='checkbox' && eval('document.contactsharing_'+dscaid+'.elements[i-1].checked')==true && eval('document.contactsharing_'+dscaid+'.elements[i-1].name.indexOf(which)')!=-1){				
					allchecked=2;
					break;
				}
			}
			else if(eval('document.contactsharing_'+dscaid+'.elements[i].type')=='checkbox' && eval('document.contactsharing_'+dscaid+'.elements[i].checked')==true && eval('document.contactsharing_'+dscaid+'.elements[i].name.indexOf(which)')!=-1){
				if(i!=0 && eval('document.contactsharing_'+dscaid+'.elements[i-1].type')=='checkbox' && eval('document.contactsharing_'+dscaid+'.elements[i-1].checked')==false && eval('document.contactsharing_'+dscaid+'.elements[i-1].name.indexOf(which)')!=-1){				
					allchecked=2;
					break;
				}
			}			
		}
		if(allchecked==1){
			$(which+'_all').firstChild.src=dsgifpath+'icon_checkbox_checked.gif';
			$(which+'_all').attributes["infochecked"].nodeValue=1;
		}
		else if(allchecked==2){
			$(which+'_all').firstChild.src=dsgifpath+'icon_checkbox_partialchecked.gif';
			$(which+'_all').attributes["infochecked"].nodeValue=2;
		}		
		else{
			$(which+'_all').firstChild.src=dsgifpath+'icon_checkbox_unchecked.gif';
			$(which+'_all').attributes["infochecked"].nodeValue=0;			
		}
	}
}
// End

// Start
function ds_write_rowselect(type){
	str='<table cellspacing="0" border="0" style="width:100%;padding:0;margin:0;border:0;"><tr>';
	str+='<td id="'+type+'_row_0" class="dscolumnselect" style="width:22%;height:68px" rowspan="3"><a id="'+type+'_arow_0" class="dscolumnselect" style="height:100%" href="javascript: rowselect(0,\''+type+'\');">'+DSLang('menu')+'</a></td>';
	str+='<td id="'+type+'_row_1" class="dscolumnselect" colspan="3"><a id="'+type+'_arow_1" class="dscolumnselect" style="height:15px;" href="javascript: rowselect(1,\''+type+'\');">'+DSLang('header')+'</a></td></tr>';
	str+='<tr style="height:25px"><td id="'+type+'_row_2" class="dscolumnselect" style="height:25px;width:22%"><a id="'+type+'_arow_2" class="dscolumnselect" style="height:25px;" href="javascript:rowselect(2,\''+type+'\');">'+DSLang('column')+' 1</a></td>';
	str+='<td id="'+type+'_row_3" class="dscolumnselect" style="height:25px;width:22%"><a id="'+type+'_arow_3" class="dscolumnselect" style="height:25px;" href="javascript:rowselect(3,\''+type+'\');">'+DSLang('column')+' 2</a></td>';
	str+='<td id="'+type+'_row_4" class="dscolumnselect" style="height:25px;width:22%"><a id="'+type+'_arow_4" class="dscolumnselect" style="height:25px;" href="javascript:rowselect(4,\''+type+'\');">'+DSLang('column')+' 3</a></td></tr><tr>';
	str+='<td id="'+type+'_row_6" class="dscolumnselect" colspan="3"><a id="'+type+'_arow_6" class="dscolumnselect" style="height:15px;" href="javascript: rowselect(6,\''+type+'\');">'+DSLang('footer')+'</a></td></tr></table>';}
function ds_write_imagepos(type,iscss){
	if(iscss)
		str='<table style="background: url(\''+dsgifpath+'imgpos2.gif\') no-repeat;width:234px;height:60px" cellpadding="0" cellspacing="0" border="0 "><tr>';
	else
		str='<table style="background: url(\''+dsgifpath+'imgpos.gif\') no-repeat;width:204px;height:60px" cellpadding="0" cellspacing="0" border="0"><tr>';			
	str+='<td id="'+type+'_pos1" class="ds_imagepos_inactive" onclick="dsimagepos(1,\''+type+'\');" title="'+DSLang('Titleleft')+'">&nbsp;</td>';
	str+='<td id="'+type+'_pos2" class="ds_imagepos_inactive" onclick="dsimagepos(2,\''+type+'\');" title="'+DSLang('Titleright')+'">&nbsp;</td>';
	str+='<td id="'+type+'_pos3" class="ds_imagepos_inactive" onclick="dsimagepos(3,\''+type+'\');" title="'+DSLang('Bodywrapleft')+'">&nbsp;</td>';
	str+='<td id="'+type+'_pos4" class="ds_imagepos_inactive" onclick="dsimagepos(4,\''+type+'\');" title="'+DSLang('Bodywrapright')+'">&nbsp;</td>';
	if(iscss){
		str+='<td id="'+type+'_pos11" class="ds_imagepos_inactive" onclick="dsimagepos(11,\''+type+'\');" title="'+DSLang('Titlebodywrapleft')+'">&nbsp;</td>';
		str+='<td id="'+type+'_pos12" class="ds_imagepos_inactive" onclick="dsimagepos(12,\''+type+'\');" title="'+DSLang('Titlebodywrapright')+'">&nbsp;</td>';
		str+='<td id="'+type+'_pos13" class="ds_imagepos_inactive" onclick="dsimagepos(13,\''+type+'\');" title="'+DSLang('Abovetitle')+'">&nbsp;</td>';
	}
	else{
		str+='<td id="'+type+'_pos5" class="ds_imagepos_inactive" onclick="dsimagepos(5,\''+type+'\');" title="'+DSLang('Bottomleft')+'">&nbsp;</td>';
		str+='<td id="'+type+'_pos6" class="ds_imagepos_inactive" onclick="dsimagepos(6,\''+type+'\');" title="'+DSLang('Bottomright')+'">&nbsp;</td>';
	}
	str+='</tr><tr><td id="'+type+'_pos7" class="ds_imagepos_inactive" onclick="dsimagepos(7,\''+type+'\');" title="'+DSLang('Titlebodynowrapleft')+'">&nbsp;</td>';
	str+='<td id="'+type+'_pos8" class="ds_imagepos_inactive" onclick="dsimagepos(8,\''+type+'\');" title="'+DSLang('Bodynowrapleft')+'">&nbsp;</td>';
	str+='<td id="'+type+'_pos9" class="ds_imagepos_inactive" onclick="dsimagepos(9,\''+type+'\');" title="'+DSLang('Titlebodynowrapright')+'">&nbsp;</td>';
	str+='<td id="'+type+'_pos10" class="ds_imagepos_inactive" onclick="dsimagepos(10,\''+type+'\');" title="'+DSLang('Bodynowrapright')+'t">&nbsp;</td>';
	if(iscss){
		str+='<td id="'+type+'_pos5" class="ds_imagepos_inactive" onclick="dsimagepos(5,\''+type+'\');" title="'+DSLang('Bottomleft')+'">&nbsp;</td>';
		str+='<td id="'+type+'_pos6" class="ds_imagepos_inactive" onclick="dsimagepos(6,\''+type+'\');" title="'+DSLang('Bottomright')+'">&nbsp;</td>';
		str+='<td id="'+type+'_pos14" class="ds_imagepos_inactive" onclick="dsimagepos(14,\''+type+'\');" title="'+DSLang('Abovebody')+'">&nbsp;</td>';
	}
	else
		str+='<td colspan="2"></td>';
	str+='</tr></table>';
}
function rowselect(thisid,type){
	if (type=='show' || type=='default' || type=='resultposition' || type=='categoryposition'){
		if(type=='default'){
			for (i=0;i<7;i++) {
				if(i!=5 && $('restricted_row_'+thisid).className=='dscolumnselect'){
					$(type+'_row_'+i).className='dscolumnselect';
					$(type+'_arow_'+i).className='dscolumnselect';
				}
			}
			if ($(type+'_row_'+thisid).className=='dscolumnselect' && $('restricted_row_'+thisid).className=='dscolumnselect'){
				$(type+'_row_'+thisid).className='dscolumnselecta';
				$(type+'_arow_'+thisid).className='dscolumnselecta';
			}
			$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value=thisid;
		}
		else {
			for (i=0;i<7;i++) {
				if(i!=5){
					$(type+'_row_'+i).className='dscolumnselect';
					$(type+'_arow_'+i).className='dscolumnselect';
				}
			}
			if ($(type+'_row_'+thisid).className=='dscolumnselect'){
				$(type+'_row_'+thisid).className='dscolumnselecta';
				$(type+'_arow_'+thisid).className='dscolumnselecta';
			}
			if(type=='resultposition' || type=='categoryposition')
				$(type).value=thisid;		
			else if(type=='show'){
				DSStyle('column_'+thisid,'display:1,dsnavname:column_2');
			}
		}
	}
	else if(type=='restricted'){
		if ($(type+'_row_'+thisid).className=='dscolumnselect' && $('default_row_'+thisid).className=='dscolumnselect'){
			$(type+'_row_'+thisid).className='dscolumnselecta';
			$(type+'_arow_'+thisid).className='dscolumnselecta';					
			if($(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value!='')
				$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value=$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value+','+thisid;
			else
				$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value+=thisid;			
		}
		else if($(type+'_row_'+thisid).className=='dscolumnselecta'){


			$(type+'_row_'+thisid).className='dscolumnselect';
			$(type+'_arow_'+thisid).className='dscolumnselect';					
			rowaligntemp=$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value.split(",");
			$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value='';
			for (x=0; x<rowaligntemp.length; x++){
				if (thisid!=rowaligntemp[x]){
					if($(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value!='')
						$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value=$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value+','+rowaligntemp[x];
					else
						$(type+'_'+$('set').options[$('set').selectedIndex].value+'_rowalign').value+=rowaligntemp[x];
				}
			}
		}
	}		
}
function ds_write(type,what,iscss){
	eval('ds_write_'+what+'(type,iscss)');
	document.write(str);
}
//End


//Start
function DSDisableSiteMenu(thiselement,optionlist) {
	var type=DSJS.ListFirst(thiselement.id,"_");	
	var thisID=DSJS.ListLast(thiselement.id,"_");
	var thisDSSIDList=$('sitemenu_dssidlist').value;
	var thisDSMIDList=$('sitemenu_dsmidlist').value;
	var singlemenu=0;
	var currentimage=DSJS.ListLast(thiselement.src,'/');
	insertreceiver='';
	display='onclick';
	DSOptionList(optionlist);
	
	//alert(type+' display:'+display);
	
	if (type=='dssid') {
		var disablestatus=1;
		if (display=='onclick') {			
			
			if (currentimage=='icon_checkbox_unchecked.gif') {
				thiselement.src=dsgifpath+'icon_checkbox_checked.gif';				
				$('sitemenu_dssidlist').value+=','+thisID;				
			}
			else if (currentimage=='icon_checkbox_checked.gif'){
				thiselement.src=dsgifpath+'icon_checkbox_unchecked.gif';
				thePosition=DSJS.ListFind(thisDSSIDList,thisID);
				if(thePosition) {
					thisDSSIDList=DSJS.ListDeleteAt(thisDSSIDList,thePosition);
					$('sitemenu_dssidlist').value=thisDSSIDList;
				}
				disablestatus=0;
			}
			else if (currentimage=='icon_checkbox_partialchecked.gif'){
				// DSDispatchEvent('dsacc_site_export_export_sitemenu_'+thisID+'_arrow');
				thiselement.src=dsgifpath+'icon_checkbox_unchecked.gif';
				disablestatus=0;
				if (thisDSMIDList!='') {
					thisDSMIDList=thisDSMIDList.split(",");
					newDSMIDList='';
					spacer='';
					for (i=0; i<thisDSMIDList.length; i++){
						if (DSJS.ListFirst(thisDSMIDList[i],":")!=thisID) {
							newDSMIDList+=spacer+thisDSMIDList[i];
							spacer=',';
						}						
					}
					$('sitemenu_dsmidlist').value=newDSMIDList;
					thisDSMIDList=newDSMIDList
				}				
			}
			DSSID_DSMIDList=$('dssid_image_'+thisID).readAttribute('dsmidlist');
			DSSID_DSMIDList=DSSID_DSMIDList.split(',');
			
			if (DSSID_DSMIDList!='') {
				for (i=0; i<DSSID_DSMIDList.length; i++){
					thePosition=DSJS.ListFind(thisDSMIDList,thisID+':'+DSSID_DSMIDList[i]);
					if(thePosition) {
						thisDSMIDList=DSJS.ListDeleteAt(thisDSMIDList,thePosition);
						$('sitemenu_dsmidlist').value=thisDSMIDList;
					}
					if ($('dsmid_'+DSSID_DSMIDList[i])!=null) {
						$('dsmid_'+DSSID_DSMIDList[i]).checked=false;
						$('dsmid_'+DSSID_DSMIDList[i]).disabled=disablestatus;					
					}
				}
			}	
		}
		else if (display=='onload') {
			thePosition=DSJS.ListFind(thisDSSIDList,thisID);
			if (thePosition==0)
				disablestatus=0;
			if (currentimage=='icon_checkbox_partialchecked.gif') {
				thisDSMIDList=thisDSMIDList.split(",");
				for (i=0; i<thisDSMIDList.length; i++){
					currentdsmid=DSJS.ListLast(thisDSMIDList[i],":");
					if ($('dsmid_'+currentdsmid)!=null) {
						$('dsmid_'+currentdsmid).checked=true;			
					}
				}			
			}
			else if (currentimage=='icon_checkbox_checked.gif') {
				menulist=$(insertreceiver).select('[dssid="'+DSJS.ListLast(insertreceiver,'_')+'"]');
				menulist.each(function(s) {
					s.disabled=true;
				});			
			}			
		}
	}
	else if (type=='dsmid') {
		currentdepth='';
		if (thiselement.checked==true)
			disablestatus=1;
		else
			disablestatus=0;	
		$('dssid_image_'+dssid).src=dsgifpath+'icon_checkbox_partialchecked.gif';
		thePosition=DSJS.ListFind(thisDSSIDList,dssid);
		if(thePosition) {
			thisDSSIDList=DSJS.ListDeleteAt(thisDSSIDList,thePosition);
			$('sitemenu_dssidlist').value=thisDSSIDList;
		}
		if (thiselement.checked==true) {
			if (thisDSMIDList=='') {
				thisDSMIDList=dssid+':'+thisID;
				$('sitemenu_dsmidlist').value+=thisDSMIDList;
			}
			else {
				thisDSMIDList=','+dssid+':'+thisID;
				$('sitemenu_dsmidlist').value+=thisDSMIDList;			
			}			
		}
		else {
			thePosition=DSJS.ListFind(thisDSMIDList,dssid+':'+thisID);
			if(thePosition) {
				thisDSMIDList=DSJS.ListDeleteAt(thisDSMIDList,thePosition);
				$('sitemenu_dsmidlist').value=thisDSMIDList;
			}
		}
		if (singlemenu==1) {
			dsmidListe=$('dsmid_'+dssid).readAttribute('dsmidlist');
			depthListe=$('dsmid_'+dssid).readAttribute('depthlist');		
			dsmidListe=dsmidListe.split(",");
			depthListe=depthListe.split(",");		
			
			//partialchecked=1;
			this_pos=-1;
			for (i=0; i<dsmidListe.length; i++){	
				if (thiselement.value==dsmidListe[i])
					this_pos=i;
				else {
					$('dsmid_'+dsmidListe[i]).checked=false;
					$('dsmid_'+dsmidListe[i]).disabled=false;
				}
			}
			if (thiselement.checked){				
				//thiselement.checked=true;
				if (this_pos>-1 && this_pos<dsmidListe.length-1){
					currentdepth=depthListe[this_pos];
					for (i=this_pos+1; i<dsmidListe.length; i++){
						if (depthListe[i]<=currentdepth)
							break;
						else
							$('dsmid_'+dsmidListe[i]).disabled=true;
					}
				}
			}
		}
		
	}	
}
// End


// ****************************************
// * Start System/ Category _category.cfm *
// ****************************************
function dsgetsub(formular,feld,itemid){
	df=eval('document.'+formular);
	si=df.ParentItemID.selectedIndex;
	regex = /(.+),(.+),(.+)/;
	if (itemid>0 && si>0){
		for (i=si; i>=0; i--){
			regex.exec(df.ParentItemID[i].value);
			if (RegExp.$1==itemid || RegExp.$2==itemid){
				alert(DSLang('alertmoveobject'));
				si=last_si;
				df.ParentItemID.selectedIndex=si;
				break;
			}
			if (RegExp.$2==0)
				break;
		}
	}
	last_si=si;
	new_si=-1;
	for(i=df.CatSort.length-1; i>=0; i--){
		df.CatSort[i]=null
	}
	if (si<df.ParentItemID.length-1){
		regex.exec(df.ParentItemID[si].value);
		pid=RegExp.$1
		df.NewCatSort.value='';
		for (i=si+1; i<df.ParentItemID.length; i++){
			regex.exec(df.ParentItemID[i].value);
			if (RegExp.$2 == pid){
				if (RegExp.$1==itemid){
					df.ParentItemID[i].text=df.ParentItemID[i].text.slice(0,RegExp.$3*2)+df.name.value
					new_si=df.CatSort.length;
				}
				text=df.ParentItemID[i].text.slice(RegExp.$3*2,df.ParentItemID[i].text.length);
				df.CatSort.options[df.CatSort.length] = new Option(text,RegExp.$1);
				df.NewCatSort.value=df.NewCatSort.value+RegExp.$1+',';
			}
		}
	}
	if (new_si<0){
		if (df.name.value.length > 3)
			text=df.name.value;
		else
			text=DSLang('newcategory');
		df.CatSort.options[df.CatSort.length] = new Option(text,itemid);
		df.CatSort.selectedIndex=df.CatSort.length-1;
		df.NewCatSort.value=df.NewCatSort.value+itemid+',';
	}
	else
		df.CatSort.selectedIndex=new_si;
}

// Kategorien Validierung eingebaut am 09.06.04 von Tim
function dscat_validate(){
	if(document.f1.Name.value==""){
		alert(DSLang('alertentercategoriename'));
		document.f1.Name.focus();
	}
	else if($('gallerysort')!=null && $('gallerysort').length==0)
		alert(DSLang('alertnoemptygallery'));
	else if($('gallery_resizeto')!=null && isNaN($('gallery_resizeto').value))
		alert(DSLang('alertresize'));	
	else
		$('f1').submit();
}

function ds_movecategory(von,nach,idname){
	parent0=$(von).options[$(von).selectedIndex].value.split("|");
	parent0=parent0[1];
	if(parent0!=0)
		alert(DSLang('alertselectcategory'));
	else{
		startindex=$(von).selectedIndex;
		endindex=$(von).length;
		for(i=startindex; i<endindex;i++){
			depth=$(von).options[startindex].value.split("|");
			depth=depth[1];
			if(depth==0 && startindex!=i)
				break;
			idfield=$(von).options[startindex].value;				
			textfield=$(von).options[startindex].text;	
			$(von).options[startindex]=null;
			position=$(nach).length;
			$(nach).options[position]=new Option(textfield,idfield);	
			if(depth==0)
				$(nach).options[position].style.background="#eeeeee";
		}
		bid='';				
		for (i=0; i < $(nach).length; ++i){
			bidvalue=$(nach).options[i].value.split("|");
			bidvalue=bidvalue[0]
			bid=bid+bidvalue+',';
		}
		$(idname).value=bid;
	}
}
// ****************************************
// * END System/ Category _category.cfm   *
// ****************************************

// ***************************
// * START Transfer          *
// ***************************
var dsdir_last='';


function dslgs_open(formular,feld,dsmmtyp){
	pos=top.DSFindLoader_Loaded('manager_directory_directory_view',this.window);
	if(dsdir_last!='' && $('dsdir_'+dsdir_last))
	   $('dsdir_'+dsdir_last).style.color='#00008b';
	dsdir_last=feld;
	dsformfield=$(feld);
	if($('dsdir_'+feld))
		$('dsdir_'+feld).style.color='#D70026';
	if (dcbe==null)
		DSInit();
	if(parent.$('dspopup3')){
		parent.$('dspopup3').style.left = 40 + "px";
		parent.$('dspopup3').style.top = DSInt(parent.dcbe.scrollTop+40) + "px";		
	}
	else{
		$('dspopup3').style.left = 40 + "px";
		$('dspopup3').style.top = DSInt(dcbe.scrollTop+40) + "px";		
	}
	if (pos>-1){
		if(parent.$('dspopup3')){
			parent.$('dspopup3').style.display='block';
			parent.dspopup_zindex('dspopup3');
		}
		else{
			$('dspopup3').style.display='block';
			dspopup_zindex('dspopup3');
		}
		this_window=top.DSLoader_Loaded[pos][0];
//		checkit('DSTree_dsdirectorytree',dsmmtyp);
		if(this_window.uebergabe_display!=null){
			for(i=0;i<this_window.uebergabe_display.length;i++){
				if(this_window.$('uebergabe_'+this_window.uebergabe_display[i])!=null)
					this_window.$('uebergabe_'+this_window.uebergabe_display[i]).style.visibility='visible';
			}
		}
		if(this_window.uebergabe_display_dspaid!=null){
			for(i=0;i<this_window.uebergabe_display_dspaid.length;i++){
				if(this_window.$('uebergabe_dspaid_'+this_window.uebergabe_display_dspaid[i])!=null)
					this_window.$('uebergabe_dspaid_'+this_window.uebergabe_display_dspaid[i]).style.visibility='visible';
			}
		}
		if(this_window.uebergabe_display_dsmid!=null){
			for(i=0;i<this_window.uebergabe_display_dsmid.length;i++){
				if(this_window.$('uebergabe_dsmid_'+this_window.uebergabe_display_dsmid[i])!=null)
					this_window.$('uebergabe_dsmid_'+this_window.uebergabe_display_dsmid[i]).style.visibility='visible';
			}
		}			
		if(this_window.uebergabe_display_dspaid!=null){
			for(i=0;i<this_window.uebergabe_display_dspaid2.length;i++){
				if(this_window.$('uebergabe_dspaid2_'+this_window.uebergabe_display_dspaid2[i])!=null)
					this_window.$('uebergabe_dspaid2_'+this_window.uebergabe_display_dspaid2[i]).style.visibility='visible';
			}
		}					
	}
	else
		dsloader(dsxpath+'dynasite.cfm?dscmd=manager_directory_directory_view&dsmmtyp='+dsmmtyp+'&dsform='+formular+'&dsfield='+feld,'dspopup3','manager_directory_directory_view');	

	parent.dsform=formular;
	parent.dsfield=feld;
	parent.dsmmtyp=dsmmtyp;		

}
// 2006-10-10 [AP] Funktion wird in der content/_article.cfm und content/_menu.cfm verwendet
function DSImageSelect(sivalue) {
	$('asset_asset_external_container').style.display='none';
	$('asset_asset_internal_container').style.display='none';
	$('asset_asset_asset_container').style.display='block';
	if ($('content_article_article_imagesetting')!=null)
		$('content_article_article_imagesetting').style.display='block';
	if ($('accordion_asset_asset_preview')!=null)
			$('accordion_asset_asset_preview').style.display='none';
	if(sivalue==1) {
		$('asset_asset_external_container').style.display='block';
		if ($('imagedescription_option_div')!=null) {
			if($('imagedescription_option_div').style.display=='inline' && $('imagedescription_option_div').innerHTML=='- &lt;'+DSLang('default')+'&gt;')
				imagedes_temp=$('imagedescription').value;
			if($('imagealt_option_div').style.display=='inline' && $('imagealt_option_div').innerHTML=='- &lt;'+DSLang('default')+'&gt;')
				keywords_temp2=$('imagealt').value;
			if($('imageheight_option_div').style.display=='inline' && $('imageheight_option_div').innerHTML=='- &lt;'+DSLang('default')+'&gt;')
				imageheight_temp=$('imageheight').value;
			if($('imagewidth_option_div').style.display=='inline' && $('imagewidth_option_div').innerHTML=='- &lt;'+DSLang('default')+'&gt;')
				imagewidth_temp=$('imagewidth').value;
			dsarticlegallery('offdir');
		}			
	}
	else if(sivalue==2){
		$('asset_asset_internal_container').style.display='block';		
		if ($('accordion_asset_asset_preview')!=null)
			$('accordion_asset_asset_preview').style.display='block';
		if ($('imagedescription_option_div')!=null) 
			dsarticlegallery('on');
	}
	else if(sivalue==0) { 
		$('asset_asset_asset_container').style.display='none';
		if ($('content_article_article_imagesetting')!=null)
			$('content_article_article_imagesetting').style.display='none';
	}
	DSPopUpResize();
}			

function dsuebergabe(inhalt,keywords,whichwindow){
	var output=1;
	var msg='';
	if(whichwindow)
		output=whichwindow;
	pos=top.DSFindLoader_Loaded('manager_directory_directory_view');
	if (pos>-1)
		this_window=top.DSLoader_Loaded[pos][0];	
	if (parent.TinyMCEInstance=='tinymce'){
		parent.TinyMCEWindow.document.getElementById(parent.dsfield).value=inhalt=inhalt;
		if(dsfield=='src'){
			keywords=keywords.split("|");
			if(keywords[2]==1){
				if(keywords[3]!=0)
					parent.TinyMCEWindow.document.getElementById('width').value=keywords[3];
				if(keywords[4]!=0)
					parent.TinyMCEWindow.document.getElementById('height').value=keywords[4];
				parent.TinyMCEWindow.document.getElementById('alt').value=keywords[0];
			}
		}
		parent.dspopup('close|dspopup3');
		if(parent.uebergabe_display!=null){
			for(i=0;i<parent.uebergabe_display.length;i++){
				if(parent.$('uebergabe_'+parent.uebergabe_display[i])!=null)
					parent.$('uebergabe_'+parent.uebergabe_display[i]).style.visibility='hidden';
			}
		}
		if(parent.uebergabe_display_dspaid!=null){
			for(i=0;i<parent.uebergabe_display_dspaid.length;i++){
				if(parent.$('uebergabe_dspaid_'+parent.uebergabe_display_dspaid[i])!=null)
					parent.$('uebergabe_dspaid_'+parent.uebergabe_display_dspaid[i]).style.visibility='hidden';
			}
		}
		if(parent.uebergabe_display_dsmid!=null){
			for(i=0;i<parent.uebergabe_display_dsmid.length;i++){
				if(parent.$('uebergabe_dsmid_'+parent.uebergabe_display_dsmid[i])!=null)
					parent.$('uebergabe_dsmid_'+parent.uebergabe_display_dsmid[i]).style.visibility='hidden';
			}
		}		
		if(parent.uebergabe_display_dspaid2!=null){
			for(i=0;i<parent.uebergabe_display_dspaid2.length;i++){
				if(parent.$('uebergabe_dspaid2_'+parent.uebergabe_display_dspaid2[i])!=null)
					parent.$('uebergabe_dspaid2_'+parent.uebergabe_display_dspaid2[i]).style.visibility='hidden';
			}
		}				
	}
	else {
		popupwindow='dspopup1';
		if(parent.dspopup1_loader.dsformfield==null && parent.dspopup2_loader.dsformfield==null && parent.dspopup3_loader.dsformfield==null)		
			popupwindow='dsmanager';		
		else if(parent.dspopup1_loader.dsformfield==null && parent.dspopup3_loader.dsformfield==null)
			popupwindow='dspopup2';
		else if(parent.dspopup2_loader.dsformfield==null && parent.dspopup1_loader.dsformfield==null)
			popupwindow='dspopup3';			
		if(popupwindow!='dsmanager' && eval("parent."+popupwindow+"_loader.dsformfield.id")=='gallerysort'){
			keywords=keywords.split("|");
			if(keywords[0]=='category'){
				parent.dsloader(dsxpath+'dynasite.cfm?dscmd=asset_asset_asset_gallery&unlock=unlock&gallerycat='+inhalt,'dspopup3');
			}
			else{
				extension = inhalt.substring(inhalt.lastIndexOf(".")+1,inhalt.length);
				error=0;
				for(i=0;i<parent.dspopup1_loader.$('gallerysort').length;i++){
					if(parent.dspopup1_loader.$('gallerysort').options[i].text==inhalt)
						error=1;
				}
				if((extension.toLowerCase()=='jpg' || extension.toLowerCase()=='gif' || extension.toLowerCase()=='png') && error==0){
					parent.dspopup1_loader.$('gallerysort').options[parent.dspopup1_loader.$('gallerysort').length]=new Option(inhalt, keywords[1], false, false);
					parent.dspopup1_loader.$('gallerysort').selectedIndex=parent.dspopup1_loader.$('gallerysort').length-1;
					if(parent.dspopup1_loader.$('gallerysort').length==1)
						parent.dspopup1_loader.$('position').value+=keywords[1];
					else
						parent.dspopup1_loader.$('position').value+=','+keywords[1];
					parent.dspopup1_loader.$('div_picture_options').innerHTML+='<div id="div_picture_options_'+keywords[1]+'"></div>';
					parent.dspopup1_loader.$('div_picture_options_'+keywords[1]).innerHTML='<input type="hidden" name="linkwidth_'+keywords[1]+'" id="linkwidth_'+keywords[1]+'" value="'+keywords[3]+'" /><input type="hidden" name="linkurl_'+keywords[1]+'" id="linkurl_'+keywords[1]+'" value="" /><input type="hidden" name="linktarget_'+keywords[1]+'" id="linktarget_'+keywords[1]+'" value="_top" /><textarea name="description_'+keywords[1]+'" id="description_'+keywords[1]+'" style="display:none;">'+$('imagedes_'+keywords[1]).innerHTML+'</textarea><input type="hidden" name="previewpic_'+keywords[1]+'" id="previewpic_'+keywords[1]+'" value="0" />';
					parent.dspopup1_loader.$('div_picture_options_'+keywords[1]).innerHTML+='<input type="hidden" name="linktype_'+keywords[1]+'" id="linktype_'+keywords[1]+'" value="disabled" /><input type="hidden" name="linkdssid_'+keywords[1]+'" id="linkdssid_'+keywords[1]+'" value="0" /><input type="hidden" name="linkdsmid_'+keywords[1]+'" id="linkdsmid_'+keywords[1]+'" value="0" /><input type="hidden" name="linkdspaid_'+keywords[1]+'" id="linkdspaid_'+keywords[1]+'" value="0" />';
					parent.dspopup1_loader.to_output();
				}
				else if(error==1 && keywords[0]!='folder')
					alert(DSLang('alertassetexistsgallery'));
				else if(keywords[0]!='folder')
					alert(DSLang('alertgalleryextention')+extension+"'\n\t");
			}
		}
		else{
			if(popupwindow!='dsmanager' && eval("parent."+popupwindow+"_loader.dsformfield.id")=='dsrid'){
				eval("parent."+popupwindow+"_loader.keywords=keywords");
				keywords=keywords.split("|");
				theobject=eval("parent."+popupwindow+"_loader.$('asset_category')");
				eval("parent."+popupwindow+"_loader.DSAsset(theobject,'asset_asset_asset_assetselect','trigger:dscmd,cmd:asset_asset_asset_assetselect,qs:directory,onclick:load,dsrid:'\+keywords[1]\+',dscatid:'\+keywords[5])");
				eval("parent."+popupwindow+"_loader.$('dsrid').value=keywords[1]");
//				eval("parent."+popupwindow+"_loader.dsarticlegallery('on')");
//				eval("parent."+popupwindow+"_loader.dsfill_select('imagewidth','unspecified|0%|0px|0pt|0cm|0in|0mm|0pc|0em|0ex',0)");
//				eval("parent."+popupwindow+"_loader.dsfill_select('imageheight','unspecified|0%|0px|0pt|0cm|0in|0mm|0pc|0em|0ex',0)");					
//				eval("parent."+popupwindow+"_loader.ds_css_write_value('imagewidth',keywords[3])");
//				eval("parent."+popupwindow+"_loader.ds_css_write_value('imageheight',keywords[4])");
//				eval("parent."+popupwindow+"_loader.$('imagedescription').value=$('imagedes_'+keywords[1]).innerHTML");
//				eval("parent."+popupwindow+"_loader.imagedes=$('imagedes_'+keywords[1]).innerHTML");					
//				eval("parent."+popupwindow+"_loader.$('imagealt').value=keywords[0]");
			}
			else if(popupwindow!='dsmanager' && eval("parent."+popupwindow+"_loader.dsformfield.id")=='bimage'){
				keywords=keywords.split("|");
				eval("parent."+popupwindow+"_loader.dsformfield.value=inhalt");				
				eval("parent."+popupwindow+"_loader.dsfill_select('imagewidth','unspecified|0%|0px|0pt|0cm|0in|0mm|0pc|0em|0ex',0)");
				eval("parent."+popupwindow+"_loader.dsfill_select('imageheight','unspecified|0%|0px|0pt|0cm|0in|0mm|0pc|0em|0ex',0)");					
				eval("parent."+popupwindow+"_loader.ds_css_write_value('imagewidth',keywords[3])");
				eval("parent."+popupwindow+"_loader.ds_css_write_value('imageheight',keywords[4])");
				if($('imagedes_'+keywords[1])){
					eval("parent."+popupwindow+"_loader.$('imagedescription').value=$('imagedes_'+keywords[1]).innerHTML");
					eval("parent."+popupwindow+"_loader.imagedes=$('imagedes_'+keywords[1]).innerHTML");					
					eval("parent."+popupwindow+"_loader.$('imagealt').value=keywords[0]");
				}
			}
			else if(popupwindow=='dsmanager' || eval("parent."+popupwindow+"_loader.dsformfield.id")=='attachments'){
				keywords=keywords.split("|");
				inhalt='<div id="attachment_'+keywords[1]+'"><div style="float:left;width:70%;"><span style="margin:0 5px 0 0"><img src="/dsglobal/image/icon/attach.png" alt="Undefined:attachment" title="Undefined:attachment" class="dscommandbar_button" style="height:16px;width:16px;" /></span><a href="javascript: dsloader(dsxpath+\'dynasite.cfm?dscmd=asset_asset_asset_action&dsaction=download&dsridlist='+keywords[1]+'\',\'dsloader\',\'asset_asset_asset_download\')">'+inhalt+'</a></div><div style="padding:0 0 0 15px;float:right;width:25%;"><input type="hidden" value="'+inhalt+'|'+keywords[1]+'" name="attachment" id="attachment_input_'+keywords[1]+'" /><a href="javascript:DSDoNothing();" onclick="$(\'attachment_'+keywords[1]+'\').remove();DSPopUpResize();"><img src="/dsglobal/image/icon/bin.gif" alt="Löschen" title="Löschen" class="dscommandbar_button" style="height:16px;width:16px;" /></a></div></div><div style="clear:both"></div>';
				if(popupwindow=='dsmanager'){
					if(!parent.$('attachment_'+keywords[1]))
						parent.dsformfield.insert({bottom:inhalt});
					else
						alert('Attachment ist schon vorhanden');
				}
				else{
					if(!eval("parent."+popupwindow+"_loader.$('attachment_"+keywords[1]+"')"))
						eval("parent."+popupwindow+"_loader.dsformfield.insert({bottom:inhalt})");
					else
						alert('Attachment ist schon vorhanden');
				}
				DSPopUpResize();
			}
			else
				eval("parent."+popupwindow+"_loader.dsformfield.value=inhalt");
		}
		parent.dspopup_zindex(popupwindow);
		var this_window=this_window;
		if(this_window){
			if(this_window.document.uebergabe_display!=null){
				for(i=0;i<this_window.document.uebergabe_display.length;i++){
					if($('uebergabe_'+this_window.document.uebergabe_display[i])!=null)
						$('uebergabe_'+this_window.document.uebergabe_display[i]).style.visibility='hidden';
				}
			}
			if(this_window.document.uebergabe_display_dspaid!=null){
				for(i=0;i<this_window.document.uebergabe_display_dspaid.length;i++){
					if($('uebergabe_dspaid_'+this_window.document.uebergabe_display_dspaid[i])!=null)
						$('uebergabe_dspaid_'+this_window.document.uebergabe_display_dspaid[i]).style.visibility='hidden';
				}
			}
			if(this_window.uebergabe_display_dsmid!=null){
				for(i=0;i<this_window.uebergabe_display_dsmid.length;i++){
					if(this_window.$('uebergabe_dsmid_'+this_window.uebergabe_display_dsmid[i])!=null)
						this_window.$('uebergabe_dsmid_'+this_window.uebergabe_display_dsmid[i]).style.visibility='hidden';
				}
			}		
			if(this_window.uebergabe_display_dspaid2!=null){
				for(i=0;i<this_window.uebergabe_display_dspaid2.length;i++){
					if(this_window.$('uebergabe_dspaid2_'+this_window.uebergabe_display_dspaid2[i])!=null)
						this_window.$('uebergabe_dspaid2_'+this_window.uebergabe_display_dspaid2[i]).style.visibility='hidden';
				}
			}		
		}
		parent.dspopup('close|dspopup3');
		
		if(eval('parent.'+popupwindow+'_loader.$("dsdir_'+dsfield+'")'))
			eval("parent."+popupwindow+"_loader.$('dsdir_'+dsfield).style.color='#00008b'");
		parent.dsform='';
		parent.dsfield='';
		parent.dsmmtyp='';			
	}
	if (msg==''){
		// top.opener.focus();
		// top.close();
	}
	else
		alert(msg);
}
// ***************************
// * END Transfer            *
// ***************************

//Start
function DSGallery(name,element,optionlist) {
	onclick='display';

	reloadtype='display'
	cmd='';
	IsLoaded=0;
	caller='dynasite.cfm?';
	DSOptionList(optionlist);
	// alert('Element:'+element+' IsLoaded:'+IsLoaded+' Onclick:'+onclick);
	//all
	if(cmd!='')
		IsLoaded=top.DSFindLoader_Loaded(element,this.window);
	if(cmd!='' && $(element) && $(element).innerHTML.length==0 && IsLoaded<=0)
		onclick='load';
	if($(element).innerHTML.length==0)
		IsLoaded=-1;
	// alert('Element:'+element+' IsLoaded:'+IsLoaded+' Onclick:'+onclick);
	if((IsLoaded<=0 && onclick=='load') || (IsLoaded>=0 && reloadtype=='reload' && $(element).style.display=='none'))
		dsloader(dsxpath+caller+'?'+cmd,'dsloader',element);
	DSStyle(element,'dsresize:0,display,dsnavname:'+name);
	DSStyle(textdiv,'dsresize:0,display,dsnavname:'+textdivactive);	
}
// End










// *************************************
// * START Copy Move Referenzieren     *
// *************************************

function DSCMRInsertInArray(menu_news,r,dsmid,dsaid){
	var this_pos=top.cmr_target_type.length;
	var text_m='';
	var text_a='';
	top.cmr_target_type[this_pos]=menu_news;
	top.cmr_target_row[this_pos]=r;
	top.cmr_target_dssid[this_pos]=$('cmr_siteselect').options[$('cmr_siteselect').selectedIndex].value;
	top.cmr_target_currentindb[this_pos]=0;
	top.right_mid[this_pos]=dsmid;
	
	if (menu_news=='Menu'){
		top.cmr_target_id[this_pos]=dsmid;
		text_a='';
	}
	else{
		top.cmr_target_id[this_pos]=dsaid;
		text_a=$("a_"+dsaid).innerHTML;
		text_a=' / News: '+text_a.replace(/\W/gi,'');
	}
	text_m=$("m_"+dsmid).innerHTML;
	text_m='Men\374: '+text_m.replace(/\W/gi,'');
	top.right_name[this_pos]=text_m+text_a;
}

function DSCMRDeleteFromArray(this_pos){
	top.cmr_target_type=DSArrayDeleteElement(top.cmr_target_type,this_pos);
	top.cmr_target_id=DSArrayDeleteElement(top.cmr_target_id,this_pos);
	top.cmr_target_row=DSArrayDeleteElement(top.cmr_target_row,this_pos);
	top.cmr_target_dssid=DSArrayDeleteElement(top.cmr_target_dssid,this_pos);
	top.cmr_target_currentindb=DSArrayDeleteElement(top.cmr_target_currentindb,this_pos);
	top.right_mid=DSArrayDeleteElement(top.right_mid,this_pos);
	top.right_name=DSArrayDeleteElement(top.right_name,this_pos);
}

function DSCMRIsInArray(menu_news,thisid){
	var pos=-1;
	var i=0;
	var currentsite=$('cmr_siteselect').options[$('cmr_siteselect').selectedIndex].value;
	if (menu_news=='MenuORNews'){
		for (i=0;i<top.cmr_target_type.length;i++){
			if (top.right_mid[i]==thisid && top.cmr_target_dssid[i]==currentsite){
				pos=i;
				break;
			}
		}
	}
	else{
		for (i=0;i<top.cmr_target_type.length;i++){
			if (top.cmr_target_id[i]==thisid && top.cmr_target_type[i]==menu_news && top.cmr_target_dssid[i]==currentsite){
				pos=i;
				break;
			}
		}
	}
	return pos;
}

function DSCMRShowMenuContent(dsmid){
	if (dscommand.split('_')[1]=='article'){
		if (dsmid != top.last_dsmid){
			DSCMRLoadMenuContent(dsmid);
			if ($("s_"+top.last_dsmid)!=null && $("s_"+top.last_dsmid).className=="dsmenua")
				$("s_"+top.last_dsmid).className="dsmenu";
		}
	}
	else{
		DSCMRMenuCHK(dsmid);
	}
	top.last_dsmid=dsmid;
}

function DSCMRMenuCHK(dsmid){
	if (dscommand.split('_')[1]=='article'){
		var pos=DSCMRIsInArray('MenuORNews',dsmid);
		if (pos==-1){
			if(dscommand.split('_')[2]=='move'){
				if($("MM_"+top.cmr_target_id[0])!=null){			
					$("s_"+top.cmr_target_id[0]).className='dsmenu';				
					$("MM_"+top.cmr_target_id[0]).checked=false;
				}			
				DSCMRDeleteFromArray(0);
			}
			DSCMRInsertInArray('Menu',top.objekt_row,dsmid,0)
			if (dsmid == top.last_dsmid)
				DSCMRSelectMenuNews(dsmid);
			$("MM_"+dsmid).checked=true;
		}
		else{
			if(dscommand.split('_')[2]=='reference'){
				var currentsite=$('cmr_siteselect').options[$('cmr_siteselect').selectedIndex].value;				
				ok=confirm(DSLang('alertdeletereference'));
				if(ok){
					top.last_dsmid=0;
					for (i=0;i<top.cmr_target_type.length;i++){
						if (top.right_mid[i]==dsmid && top.cmr_target_dssid[i]==currentsite){
							DSCMRDeleteFromArray(i);
							i=i-1;
						}
					}
				}
			}
		}
		DSCMRShowMenuContent(dsmid)
	}
	else{
		var pos=DSCMRIsInArray('Menu',dsmid);
		if (pos==-1){
			if(dscommand.split('_')[2]=='move' && top.cmr_target_id[0]!=null){
				if($("MM_"+top.cmr_target_id[0])!=null){			
					$("s_"+top.cmr_target_id[0]).className='dsmenu';				
					$("MM_"+top.cmr_target_id[0]).checked=false;
				}
				DSCMRDeleteFromArray(0);
			}
			DSCMRInsertInArray('Menu',0,dsmid,0);
			$("s_"+dsmid).className='dsmenu_highlight';
			$("MM_"+dsmid).checked=true;
		}
		else{
			$("s_"+dsmid).className='dsmenu';
			$("MM_"+dsmid).checked=false;
			DSCMRDeleteFromArray(pos);	
		}
	}
}

function DSCMRSelectMenuNews(dsmid){
	var foundit=0;
	var i=0;
	if ($('r_0')!=null){
		for (i=0;i<=6;i++){
			if (i!=5){
				$("r_"+i).className="dshead";
				$("rr_"+i).checked=false;
			}
		}
		for (i=0; i<top.dsaid_list.length; i++){
			if ($('A_'+top.dsaid_list[i]) != null)
				$('A_'+top.dsaid_list[i]).checked=false;
		}
	}	
	for (i=0;i<top.cmr_target_type.length;i++){
		if (top.right_mid[i]==dsmid){
			foundit=1;
			if (top.cmr_target_type[i]=='News'){
				$("A_"+top.cmr_target_id[i]).checked=true;
			}
			else{
				$("r_"+top.cmr_target_row[i]).className="dsheada";
				$("rr_"+top.cmr_target_row[i]).checked=true;
			}
		}
	}
	if (foundit==1){
		$("s_"+dsmid).className='dsmenu_highlight';
		$("MM_"+dsmid).checked=true;
	}
	else{
		$("s_"+dsmid).className='dsmenua';
		$("MM_"+dsmid).checked=false;
	}
}


function DSCMRSelectedSite(dssid){
	for (i=0;i<top.cmr_target_type.length;i++){
		if (top.cmr_target_dssid[i]==dssid){
			$("s_"+top.right_mid[i]).className='dsmenu_highlight';
			$("MM_"+top.right_mid[i]).checked=true;
		}
	}
}

function DSCMRSelectRow(r,dsmid){
	var pos=DSCMRIsInArray('Menu',dsmid);
	if (pos>-1){
		curr_r=top.cmr_target_row[pos];
		if (curr_r==r){
			var ok=true;
			if (top.cmr_target_currentindb[pos]==1){
				ok=confirm(DSLang('alertdeletereference'));
			}
			if (ok){
				DSCMRDeleteFromArray(pos);
			}
		}
		else
			top.cmr_target_row[pos]=r;
	}
	else{
		if(dscommand.split('_')[2]=='move'){
			DSCMRDeleteFromArray(0);
		}	
		DSCMRInsertInArray('Menu',r,dsmid,0)
	}
	DSCMRSelectMenuNews(dsmid);
}

function DSCMRNewsSelect(dsmid,dsaid){
	var pos=DSCMRIsInArray('News',dsaid);
	if (pos==-1){
		if(dscommand.split('_')[2]=='move'){
			DSCMRDeleteFromArray(0);
		}		
		DSCMRInsertInArray('News',1,dsmid,dsaid)
	}
	else{
		var ok=true;
		if (top.cmr_target_currentindb[pos]==1)
			ok=confirm(DSLang('alertdeletereference'));
		if (ok)
			DSCMRDeleteFromArray(pos);
	}
	DSCMRSelectMenuNews(dsmid);
}

function DSCMRSubmitCheck(act){
	error=0;
	if (top.cmr_target_type.length==0 && error==0 && (act=='move' || act=='copy')) {
		error=DSLang('alertchoosetargetmenusite');
	}
	if (error==0){
		if (act=='move') 
			was=DSLang('move');
		else if (act=='copy')
			was=DSLang('copy');	
		else 
			was=DSLang('reference');	
		if (top.cmr_target_type.length==1){
			if(top.cmr_target_currentindb[0]!=1){
				if (top.cmr_target_type[0]=='Menu'){
					if (dscommand.split('_')[1]=='article')
						cf_text=$('cmr_target_type').value+' in '+top.right_name[0]+DSCMRGetRowName(top.cmr_target_row[0])+' '+was+'?'
					else
						cf_text=$('cmr_target_type').value+' in '+top.right_name[0]+' '+was+'?';
				}
				else
					cf_text=$('cmr_target_type').value+' in '+top.right_name[0]+' '+was+'?';
			}
			else {
				cf_text=DSLang('alertnorefselected');
			}
		}
		else{
			cf_text=$('cmr_target_type').value+' '+DSLang('infollowingobjects')+' '+was+'?';
			for (i=0; i < top.cmr_target_id.length;i++){
				if(top.cmr_target_currentindb[i]!=1){
					cf_text+='\n\t'+top.right_name[i];
					if (dscommand.split('_')[1]=='article' && top.cmr_target_type[i]=='Menu'){
						cf_text+=DSCMRGetRowName(top.cmr_target_row[i]);
					}
				}
			}
		}
		
		
		if($('ncid')==null){		
			test=confirm(cf_text);
			if (test){
				$('cmr_target_type').value=DSArrayToList(top.cmr_target_type,',');
				$('cmr_target_id').value=DSArrayToList(top.cmr_target_id,',');
				$('cmr_target_row').value=DSArrayToList(top.cmr_target_row,',');
				$('cmr_target_dssid').value=DSArrayToList(top.cmr_target_dssid,',');
				$('dsformwaitcode').style.display='block';
				$('dsformcontent').style.display='none';
				document.f1.submit();
			}
			else
				document.getElementsByName('dsbutton_submit')[0].disabled=false;
				document.getElementsByName('dsbutton_submit')[1].disabled=false;
		}
		else{
			$('cmr_target_type').value=DSArrayToList(top.cmr_target_type,',');
			$('cmr_target_id').value=DSArrayToList(top.cmr_target_id,',');
			$('cmr_target_row').value=DSArrayToList(top.cmr_target_row,',');
			$('cmr_target_dssid').value=DSArrayToList(top.cmr_target_dssid,',');
		}
	}
	else {
		$('dsbutton_submit').disabled=false;
		alert(error);	
	}
}

function DSCMRGetRowName(r){
	rname=' (in Spalte: ';
	if (r==0)
		rname+=DSLang('Menu');
	else if (r==1)
		rname+=DSLang('Header');
	else if (r==2)
		rname+='1';
	else if (r==3)
		rname+='2';
	else if (r==4)
		rname+='3';
	else if (r==6)
		rname+=DSLang('Footer');
	rname+=')';
	return rname;
}

function DSCMRgetdscid(dscid){
	if (top.c_dscid.length >1){
		document.write('<select class="ds_select" name="Cust" onchange="DSCMRgetsites(this.options[this.selectedIndex].value)">');
		for (i=0; i < top.c_dscid.length; ++i){
			if (top.c_dscid[i]==dscid){
				selected=' selected="selected"';
			}
			else
				selected='';
			document.write('<option value="'+top.c_dscid[i]+'"'+selected+'>'+top.c_name[i].slice(0,18)+'</option>');
		}
		document.write('</select>');
	}
	else{
		document.write('<select class="ds_select" name="Cust" disabled="disabled">');
		for (i=0; i < top.c_dscid.length; ++i){
			if (top.c_dscid[i]==dscid){
				selected=' selected="selected"';
			}
			else
				selected='';
			document.write('<option value="'+top.c_dscid[i]+'"'+selected+'>'+top.c_name[i].slice(0,18)+'</option>');
		}
		document.write('</select>');
	}
}

function DSCMRgetsites(dscid){
	if (dscid > 0){
		var pos=1;
		var i=0;
		 //document.Testform.Auswahl.options[document.Testform.Auswahl.length - 1] = null;
		select_length=$('cmr_siteselect').length;
		if (select_length>1){
			for (i=select_length-1; i>=1; i--){
				$('cmr_siteselect').options[i]=null;
			}
			var eachGroup = $('cmr_siteselect').lastChild;
			while ('OPTGROUP' == eachGroup.tagName){
				lastGroup = eachGroup;
				$('cmr_siteselect').removeChild(lastGroup)
				eachGroup = $('cmr_siteselect').lastChild;				
			}
		}

		for (i=0; i < top.s_dscid.length; i++){
			if (dscid*1==top.s_dscid[i]){
				if(pos==1 || (top.s_language[i]!=top.s_language[i-1])){
					objOptgroup=document.createElement('optgroup');
					objOptgroup.label=top.s_language[i];
					$('cmr_siteselect').appendChild(objOptgroup);
				}
				$('cmr_siteselect').options[pos]=new Option(top.s_dssid[i]+' - '+top.s_names[i].slice(0,18),top.s_dssid[i]);
				if (top.s_dssid[i]==top.curr_site){
					$('cmr_siteselect').selectedIndex=pos
				}
				pos=pos+1;
			}
			else if (pos>1)
				break;
		}
	}
}

function DSCMRFindDSCIDfromDSSID(dssid){
	var i=0;
	for (i=0; i < top.s_dssid.length; i++){
			if (dssid==top.s_dssid[i]){
				return top.s_dscid[i];
			}
	}
	return -1
}


function DSCMRSiteChange(newdssid) {
	if($('cmrlive_1').checked==true)
		templive=$('cmrlive_1').value
	else
		templive=$('cmrlive_0').value
	if (newdssid>0)
		dsloader(dsxpath+'dynasite.cfm?dscmd='+top.cmcommand+'&dssid='+DSSID+'&dsaid='+top.dsaid+'&dscmrdsmid='+top.dscmrdsmid+'&newdssid='+newdssid+'&tempname='+$('name').value+'&templive='+templive+'&isloaded=1','dsloader',top.cmcommand);
}

function DSCMRLoadMenuContent(dsmid){
	dsloader(dsxpath+'dynasite.cfm?dscmd=content_cmrtarget_cmrtarget_cmrtarget&dssid='+top.curr_site+'&dsmid='+dsmid+'&show_news='+top.show_news+'&hasref_chk='+top.hasref_chk+'&dsaid='+top.dsaid,'dsloader','content_cmrtarget_cmrtarget_cmrtarget');
}
// *************************************
// * END Copy Move Referenzieren       *
// *************************************


// ***************************
// * Start MenuForm          *
// ***************************
function dsgetsub_menu(formular,feld,itemid){
	df=eval('document.'+formular);
	dff=eval('document.'+formular+'.'+feld)
	si=dff.selectedIndex;
	regex = /(.+),(.+),(.+),(.+)/;
	var i=0;
	var msg='';
	if (si>0){
		regex.exec(dff[si].value)
		if (RegExp.$1==itemid) {
			msg=DSLang('alertobjectmoveitself');
		}
		else if (RegExp.$3>=DSMaxMenuDepth) {
			msg=DSLang('alertmaxmenudepth');
			msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",DSMaxMenuDepth);
		}
		else{
			last_parentitemid=RegExp.$1;
			for (i=si; i>=0; i--){
				regex.exec(dff[i].value);
				if (RegExp.$2==0 || RegExp.$3==0)
					break;
				else if (last_parentitemid==RegExp.$1){
					last_parentitemid=RegExp.$2;
					if (RegExp.$2==itemid){						
						msg=DSLang('alertmenudependent');
						break;
					}
				}
			}
		}
	}
	if (msg!=''){
		alert(msg)
		si=last_si;
		dff.selectedIndex=si;
	}
	last_si=si;
	new_si=-1;
	for(i=df.newsort.length-1; i>=0; i--){
		df.newsort[i]=null
	}
	regex.exec(dff[si].value);
	if (RegExp.$4==2){
		message=DSLang('alertmenunofunction');
		message=DSJS.ReplaceNoCase(message,"@@replace1@@",dff[si].text,"All");
		dff.selectedIndex=0;
		si=0;
		regex.exec(dff[si].value);
	} 
	if (si<dff.length-1){
		pid=RegExp.$1
		df.position.value='';
		for (i=si+1; i<dff.length; i++){
			regex.exec(dff[i].value);
			if (RegExp.$2 == pid){
				if (RegExp.$1==itemid){
					dff[i].text=dff[i].text.slice(0,RegExp.$3*2)+MenuNumberation+df.menutext.value
					new_si=df.newsort.length;
				}
				text=dff[i].text.slice(RegExp.$3*2,dff[i].text.length);
				df.newsort.options[df.newsort.length] = new Option(text,RegExp.$1);
				df.position.value=df.position.value+RegExp.$1+',';
			}
		}
	}
	if (new_si<0){
		if (df.menutext.value.length > 3)
			text=MenuNumberation+df.menutext.value
		else {
			text=DSLang('newmenu');
		}
		df.newsort.options[df.newsort.length] = new Option(text,itemid);
		df.newsort.selectedIndex=df.newsort.length-1;
		df.position.value=df.position.value+itemid+',';
	}
	else
		df.newsort.selectedIndex=new_si;
}
// ***************************
// * END MenuForm            *
// ***************************

// *******************************
// * START DesignMenu _menu.cfm  *
// *******************************
var dsd_menu_last=new Array("dims");
var dsd_menu_divs=new Array("dims");
var dsd_menu_hu=0;
var dsd_menu_ourl=0;
var dsd_menu_hoehe=0;
function dsd_menu_output(){
	for (i=0; i < dsd_menu_last.length; ++i)
		eval('$("bg'+dsd_menu_last[i]+'").style.display="none"');
	if (dsd_menu_ourl=='dims'){
		dsd_menu_divs=new Array("dims");
		$("mnsubnav").style.display="none";
	}
	else{
		$("mnsubnav").style.display="block";
		bg=dsd_menu_hu+dsd_menu_ourl;
		for (i=0; i <= 1; ++i){
			dsd_menu_divs[i] = bg;
			bg=bg+10;
		}
	}
	for (i=0; i < dsd_menu_divs.length; ++i){
		eval('$("bg'+dsd_menu_divs[i]+'").style.display="block"');
		if (dsd_menu_hu==0) {
		eval('$("mainmenu").style.backgroundColor="#FFFFFF"');
		eval('$("amainmenu").style.fontWeight="bold"');
		eval('$("submenu").style.backgroundColor="#dddddd"');
		eval('$("asubmenu").style.fontWeight="normal"');
		}
		else {
		eval('$("submenu").style.backgroundColor="#FFFFFF"');
		eval('$("asubmenu").style.fontWeight="bold"');
		eval('$("mainmenu").style.backgroundColor="#dddddd"');
		eval('$("amainmenu").style.fontWeight="normal"');
			}
	}
	dsd_menu_last=dsd_menu_divs;
	$("hoehe").style.height=dsd_menu_hoehe;
}

function dsd_menu_h_u(uh){
	dsd_menu_hu=uh;
	dsd_menu_output();
}
dsd_menu_lastbold='Eigenschaften'
function dsd_menu_choice(was){
	eval('$("a'+dsd_menu_lastbold+'").style.fontWeight="normal"');
	eval('$("a'+dsd_menu_lastbold+'").style.color="blue"');
	eval('$("a'+was+'").style.fontWeight="bold"');
	eval('$("a'+was+'").style.color="darkred"');
	dsd_menu_hoehe=380;
	if (was=='Eigenschaften'){
		dsd_menu_ourl='dims'; dsd_menu_hoehe=380;
	}
	else if (was=='Text'){
		dsd_menu_ourl=6; dsd_menu_hoehe=720;
	}
	else if (was=='Spot')
		dsd_menu_ourl=5;
	else if (was=='Oben')
		dsd_menu_ourl=1;
	else if (was=='Unten')
		dsd_menu_ourl=2;
	else if (was=='Links')
		dsd_menu_ourl=3;
	else if (was=='Rechts')
		dsd_menu_ourl=4;
	dsd_menu_lastbold=was;
	dsd_menu_output();
}

function dsd_menu_calc() {
	var WidthMainMenu=document.f1.D7.value*1+document.f1.D8.value*1+document.f1.D2.value*1+document.f1.D3.value*1;
	var WidthSubMenu=document.f1.D15.value*1+document.f1.D16.value*1+document.f1.D10.value*1+document.f1.D11.value*1;
	document.f1.WidthMainMenu.value=WidthMainMenu;
	document.f1.WidthSubMenu.value=WidthSubMenu;
}
// *******************************
// * END DesignMenu _menu.cfm  *
// *******************************



// ***************************
// * Start NewsForm          *
// ***************************
function dsnewsform_chk(){
	if (document.f1.fieldtype_body.value=='dynamic' && $("snippetformview")){
		if ($("snippetformview").style.display=="block")
			insert();
		$('shortbody').value=$('snippetcode').value;
	}
	if($('cmr_target_type')!=null){
		DSCMRSubmitCheck('reference');
	}
}
function dsactivedit_open(obj, field,dssid){
	ActiveEdit=open("editor/activeedit/activedit.cfm?dssid="+DSSID+"&FI="+field+"&FN="+obj,"ActiveEdit","width=785,height=600,screenX=0,screenY=0,locationbar=no,resizable=yes,status=no,dependent=yes");
	ActiveEdit.focus();
}
function dschkdate(){
	if (document.f1.schedule.checked==true){
		startdate = new Date(document.f1.startdateyear[document.f1.startdateyear.selectedIndex].value,document.f1.startdatemonth[document.f1.startdatemonth.selectedIndex].value,document.f1.startdateday[document.f1.startdateday.selectedIndex].value);
		enddate = new Date(document.f1.enddateyear[document.f1.enddateyear.selectedIndex].value,document.f1.enddatemonth[document.f1.endatemonth.selectedIndex].value,document.f1.enddateday[document.f1.enddateday.selectedIndex].value);
		if (enddate<startdate){
			alert(DSLang('alertexpiredate'));
			return false
		}
		else
			return true
	}
	else
		return true
}
function dsmetaname_uebergabe(){
	$('metaname').value=$('metaname').value.replace(/[<>]*/g,"");
	for(t=0; t<$('newsort').length ;t++){
		if($('newsort').options[t].value == curr_id)
			if ($('metaname').value.length>0)
			$('newsort').options[t].text =$('metaname').value;
			else
			$('newsort').options[t].text = "this Article";
	}
}
function dschk_metaname(){
	if (DSTrim($('metaname').value).length==0){
		metaname=$('ssubject').value.replace(/<[^>]+>/g,"").substring(0,49);
		metaname=metaname.replace(/\r/g,"")
		metaname=metaname.replace(/\n/g,"")
		$('metaname').value=metaname;
		dsmetaname_uebergabe();
	}
}
function dsneue_auswahl(spalte){
	disabled=eval('default_'+curr_dsdid+'_'+selected_des+'.split("?")');	
	disabled_list=disabled[1].split(",");
	designer='';
	for(r=0; r<DSRoleNames.length;r++){
		if(DSRoleNames[r]=='dsdesign')		
			designer=1;
	}
	disabled2=0;
	for(d=0;d<disabled_list.length;d++){
		if((disabled_list[d]==spalte) && (disabled_list[d]!='') && (designer==0)){
			alert(DSLang('alertcolumnblocked'));
			disabled2=1;					
		}
	}
	if(disabled2==0){
		// l\366sche Select_Options
		for(t=$('newsort').length; t>=0 ;t--){
				$('newsort').options[t] = null;
		}
		// schreibe Select_Options neu
		chk=0;
		to_select=0;
		merke_pos=new Array();
		if (curr_id==curr_ncid && $('metaname').value.length>0)
			textvar=$('metaname').value;
		else
			textvar=curr_text;
		$('newsort').options[0] = new Option(' ',' ');
		merke_pos[0]=' ';
		// Artikel der ausgew\344hlten Spalte in Selectfeld schreiben
		for(t=0; t<row_row.length ;t++){
			if (row_row[t]==spalte){
				chk=chk+1;
				if (row_id[t]==curr_id){
					$('newsort').options[chk] = new Option(textvar,row_id[t])
					to_select=chk;
				}
				else
					$('newsort').options[chk] = new Option(row_text[t],row_id[t])
				merke_pos[merke_pos.length]=row_id[t];
			}
		}
		if (to_select==0){
			if ($('defaultarticlepos').value==0){
				$('newsort').options[0].text=textvar;
				$('newsort').options[0].value=curr_id;
				merke_pos[0]=curr_id;
			}
			else{
				$('newsort').options[0] = null;
				merke_pos = merke_pos.slice(1,merke_pos.length);
				$('newsort').options[$('newsort').length] = new Option(textvar,curr_id)
				merke_pos[merke_pos.length]=curr_id;
				to_select=merke_pos.length-1
			}
		}
		else{
			$('newsort').options[0] = null;
			to_select=to_select-1;
			merke_pos = merke_pos.slice(1,merke_pos.length);
		}
		$('newsort').selectedIndex=to_select;
		$('position').value=merke_pos.join(",");
		$('row').value=spalte;
		// Hintergrundfarbe der Spaltenauswahl aendern
		for (i=0;i<7;i++) {
			if($('arow_'+i)!=null){
				$('arow_'+i).className='dscolumnselect';
				$('arow_'+i).style.backgroundColor='';				
			}
		}			
		$('arow_'+spalte).className ='dscolumnselecta';
		selected_row=spalte;
		for(d=0;d<disabled_list.length;d++){
			if(disabled_list[d]!='' && disabled_list[d]!=spalte && $('arow_'+disabled_list[d])!=null)
				$('arow_'+disabled_list[d]).style.backgroundColor='E9C5C5';
		}
	}
}

function dsmenuchange_news(initalize){
	regex = /(.+),(.+)/;
	regex.exec($('dsmid').options[$('dsmid').selectedIndex].value)
	OptionText=DSLang('noedesign');
	if (RegExp.$2==0){
		if(initalize==0){
			defaultdsdid=1;
			for(i=0;i<menu_id.length;i++){
				if(menu_id[i]==RegExp.$1){
					curr_dsdid=menu_dsdid[i];
					defaultdsdid=0;
					for(s=$('des').length-1; s>=0; s--){
						$('des').options[s]=null;
					}
					for (y=0; y<eval('menudesign_name_'+menu_dsdid[i]+'.length'); y++){
						$('des').options[$('des').length] = new Option(eval('menudesign_name_'+menu_dsdid[i]+'[y]'),y+1);
					}
					for(r=0; r<DSRoleNames.length;r++){
						if(DSRoleNames[r]=='dsdesign')		
							$('des').options[$('des').length] = new Option(OptionText,0);
					}
				}
			}
			if (defaultdsdid==1){
				curr_dsdid=default_dsdid
				for(s=$('des').length-1; s>=0; s--){
					$('des').options[s]=null;
				}
				for (y=0; y<eval('menudesign_name_'+menu_dsdid[menu_dsdid.length-1]+'.length'); y++){
					$('des').options[$('des').length] = new Option(eval('menudesign_name_'+menu_dsdid[menu_dsdid.length-1]+'[y]'),y+1);
				}
				for(r=0; r<DSRoleNames.length;r++){
					if(DSRoleNames[r]=='dsdesign')		
						$('des').options[$('des').length] = new Option(OptionText,0);
				}
			}
		}
		if (RegExp.$1 == curr_dsmid){
			dsneue_auswahl(selected_row);
			$('artpos').style.display='block';
			$('artpostext').style.display='none';
		}
		else{
			ds_articledefault($('des').selectedIndex)
			document.f1.position.value="";
			$('artpos').style.display='none';
			$('artpostext').style.display='block';
		}
	}
	else{
		message=DSLang('alertmenufuntionexpand')
		message=DSJS.ReplaceNoCase(message,"@@replace1@@",document.f1.dsmid.options[document.f1.dsmid.selectedIndex].text,"All")
		alert(message);
		/*
		if (dslang=='de')
			alert('Dem Men\374 "'+document.f1.dsmid.options[document.f1.dsmid.selectedIndex].text+'" ist als Funktion "keine Funktion" oder "Expandieren" zugewiesen,\ndaher kann dieser Artikel kein Artikel von "'+document.f1.dsmid.options[document.f1.dsmid.selectedIndex].text+'" sein.')
		else
			alert('The function "No Function" or "Expand" is assigned to the menu "'+document.f1.dsmid.options[document.f1.dsmid.selectedIndex].text+'",\ntherefore this article cannot be an article of "'+document.f1.dsmid.options[document.f1.dsmid.selectedIndex].text+'".')
		*/
		document.f1.dsmid.selectedIndex=0;

		dsmenuchange_news(0);
	}
}

function dsnews_init(){
	if (curr_dspaid<=1){
		dsmenuchange_news(1);
	}
	else{
		dsneue_auswahl(selected_row);
	}	
}

// Script die aus der _article.cfm ausgelagert wurden [TR] 10.08.05;

function ds_articledefault(which){
	selected_des=which;
	designer='';
	for(r=0; r<DSRoleNames.length;r++){
		if(DSRoleNames[r]=='dsdesign')		
			designer=1;
	}
	default_value=eval('default_'+curr_dsdid+'_'+selected_des+'.split("?")');
	if(designer==1){
		dsneue_auswahl($('row').value);
		dsimagepos($('imagealign').value,'article_1_');
	}
	else{
		dsneue_auswahl(default_value[0]);
		dsimagepos(default_value[2],'article_1_');
	}
	for(i=0;i<4;i++){
		if($('balign')!=null && $('balign').options[i].value==default_value[4])
			$('balign').selectedIndex=i;
	}
	if($('btext')!=null && default_value[5]!=null && default_value[5]!='')
		$('btext').value=default_value[5];
	
}
function ds_dom_table_cellcontent_linklist(table,addupdate){
	if(($('linkurl').value=='' || $('linktext').value=='') && addupdate=='add'){
		alert(DSLang('alerttexturlnotempty'));
	}
	else{
		tempcounter=counter;
		counter=counter+1;
		$('linklist_counter').value=counter;			
		movedown="<span id='movedown_"+counter+"' style='cursor:pointer;' onclick='ds_dom_move(\"down\","+counter+");'><img src='"+dsgifpath+"adown.gif' class='dsarrowdown' alt='Arrow Down' /></span>";
		moveup="<span id='moveup_"+counter+"' style='cursor:pointer;' onclick='ds_dom_move(\"up\","+counter+");'><img src='"+dsgifpath+"aup.gif' class='dsarrowup' alt='Arrow Up' /></span>";
		movedown2="<span id='movedown_"+tempcounter+"' style='cursor:pointer;' onclick='ds_dom_move(\"down\","+tempcounter+");'><img src='"+dsgifpath+"adown.gif' class='dsarrowdown' alt='Arrow Down' /></span>";
		moveup2="<span id='moveup_"+tempcounter+"' style='cursor:pointer;' onclick='ds_dom_move(\"up\","+tempcounter+");'><img src='"+dsgifpath+"aup.gif' class='dsarrowup' alt='Arrow Up' /></span>";			
		moveupdown='';
		if(counter==2){
			moveupdown=moveup;
			$('moveupdown_'+tempcounter).innerHTML=movedown2;
		}
		else if (counter>2){
			moveupdown=moveup;
			$('moveupdown_'+tempcounter).innerHTML=movedown2+moveup2;
		}
		cellcontent_1 = "<span id='moveupdown_"+counter+"' style='float:left;width:25px;'>"+moveupdown+"</span><span id='linklist_item_"+counter+"' style='float:left;'><a href='"+$('linkurl').value+"' title='"+$('linktitle').value+"' target='"+$('linktarget').options[$('linktarget').selectedIndex].value+"'>"+$('linktext').value+"</a></span>";
		cellcontent_2 = "<span style='cursor:pointer;float:right;padding:0 4px 0 2px;' onclick='ds_dom_table_deleterow_linklist(event);'><img src='"+dsgifpath+"icon/bin.gif' border='0' width='16' height='16' /></span><span style='cursor:pointer;float:right;padding:0 2px 0 2px;' onclick='ds_dom_table_editrow(event,"+counter+");'><img src='"+dsgifpath+"icon/application_form_edit.gif' border='0' width='16' height='16' /></span><input type='hidden' name='linkurl_"+counter+"' id='linkurl_"+counter+"' value='"+$('linkurl').value+"'><input type='hidden' name='linktext_"+counter+"' id='linktext_"+counter+"' value='"+$('linktext').value+"'><input type='hidden' name='linktitle_"+counter+"' id='linktitle_"+counter+"' value='"+$('linktitle').value+"'><input type='hidden' name='linktarget_"+counter+"' id='linktarget_"+counter+"' value='"+$('linktarget').options[$('linktarget').selectedIndex].value+"'>";

		ds_dom_table_insertrow(table,2);
		$('linkurl').value='';
		$('linktitle').value='';
		$('linktext').value='';
		$('linktarget').selectedIndex=0;		
		DSPopUpResize();
	}
}
function ds_dom_table_deleterow_linklist(e) {
	var searchfortable=ns6? e.target : event.srcElement;
	while(searchfortable.tagName!="TABLE") {
		if(searchfortable.tagName=="TR")
			rowindex=searchfortable.rowIndex;
		searchfortable=ns6? searchfortable.parentNode : searchfortable.parentElement;
	}
	tempcounter2=counter;
	counter=0;
	$('linklist_counter').value=counter;						
	for(i=1;i<=tempcounter2;i++){
		if(i!=rowindex){
			$('linkurl').value=$('linkurl_'+i).value;
			$('linktext').value=$('linktext_'+i).value;
			$('linktitle').value=$('linktitle_'+i).value;
			for(x=0;x<$('linktarget').length;x++){
				if($('linktarget').options[x].value==$('linktarget_'+i).value)
					$('linktarget').selectedIndex=x;
			}					
		}
		searchfortable.deleteRow(1);
		if(i!=rowindex){
			ds_dom_table_cellcontent_linklist('ds_linklist','delete');
			ds_dom_table_cancel();
		}
	}
	DSPopUpResize();
}				


function ds_dom_table_editrow(e,row){
	var searchfortable=ns6? e.target : event.srcElement;
	while(searchfortable.tagName!="TABLE") {
		if(searchfortable.tagName=="TR")
			rowindex=searchfortable.rowIndex;
		searchfortable=ns6? searchfortable.parentNode : searchfortable.parentElement;
	}		
	$('linkurl').value=$('linkurl_'+row).value;
	$('linktitle').value=$('linktitle_'+row).value;
	$('linktext').value=$('linktext_'+row).value;
	for(x=0;x<$('linktarget').length;x++){
		if($('linktarget').options[x].value==$('linktarget_'+row).value)
			$('linktarget').selectedIndex=x;
	}
	$('linkaddupdate').innerHTML='<input type="button" class="ds_button" value="'+DSLang('Update')+'" name="hinzufuegen" id="hinzufuegen" onclick="ds_dom_table_updaterow(\'ds_linklist\');" />';
}
function ds_dom_table_cancel(){
	$('linkurl').value='';
	$('linktitle').value='';
	$('linktext').value='';
	$('linktarget').selectedIndex=0;
	ds_linkllistbutton_reset();
}
function ds_linkllistbutton_reset(){
	$('linkaddupdate').innerHTML='<input type="button" class="ds_button" value="'+DSLang('add')+'" name="hinzufuegen" id="hinzufuegen" onclick="ds_dom_table_cellcontent_linklist(\'ds_linklist\',\'add\');dsfx_object(\'\',\'\',\'dsloaderheight\');" />';
}
function ds_dom_table_updaterow(table) {
	movedown3="<span id='movedown_"+rowindex+"' style='cursor:pointer;' onclick='ds_dom_move(\"down\","+rowindex+");'><img src='"+dsgifpath+"adown.gif' class='dsarrowdown' alt='Arrow Down' /></span>";
	moveup3="<span id='moveup_"+rowindex+"' style='cursor:pointer;' onclick='ds_dom_move(\"up\","+rowindex+");'><img src='"+dsgifpath+"aup.gif' class='dsarrowup' alt='Arrow Up' /></span>";
	moveupdown3='';
	if(counter==2){
		if(rowindex==1)
			moveupdown3=movedown3;
		else if(rowindex==2)
			moveupdown3=moveup3;
	}
	else if (counter>2){
		if(rowindex==1)
			moveupdown3=movedown3;
		else if(rowindex==counter)
			moveupdown3=moveup3;
		else
			moveupdown3=movedown3+moveup3;
	}			
	cellcontent_1 = "<span style='float:left;width:25px;' id='moveupdown_"+rowindex+"'>"+moveupdown3+"</span><span id='linklist_item_"+rowindex+"' style='float:left;'><a href='"+$('linkurl').value+"' title='"+$('linktitle').value+"' target='"+$('linktarget').options[$('linktarget').selectedIndex].value+"'>"+$('linktext').value+"</a></span>";
	cellcontent_2 = "<span style='cursor:pointer;float:right;padding:0 4px 0 2px;' onclick='ds_dom_table_deleterow_linklist();'><img src='"+dsgifpath+"icon/bin.gif' border='0' width='16' height='16' /></span><span style='cursor:pointer;float:right;padding:0 2px 0 2px;' onclick='ds_dom_table_editrow(event,"+rowindex+");'><img src='"+dsgifpath+"icon/application_form_edit.gif' border='0' width='16' height='16' /></span><input type='hidden' name='linkurl_"+rowindex+"' id='linkurl_"+rowindex+"' value='"+$('linkurl').value+"'><input type='hidden' name='linktext_"+rowindex+"' id='linktext_"+rowindex+"' value='"+$('linktext').value+"'><input type='hidden' name='linktitle_"+rowindex+"' id='linktitle_"+rowindex+"' value='"+$('linktitle').value+"'><input type='hidden' name='linktarget_"+rowindex+"' id='linktarget_"+rowindex+"' value='"+$('linktarget').options[$('linktarget').selectedIndex].value+"'>";
	tbl = $(table);
	tbl.deleteRow(rowindex);		
	row=tbl.insertRow(rowindex);
	for (repeater=1;repeater<2+1;repeater++) {	
		td = row.insertCell(-1);
		if (typeof eval('cellcontent_'+repeater)=='object') {
			td.appendChild(eval('cellcontent_'+repeater));
		}
		else {
			td.innerHTML=eval('cellcontent_'+repeater);
		}
	}
	$('linkurl').value='';
	$('linktitle').value='';
	$('linktext').value='';
	$('linktarget').selectedIndex=0;	
	ds_linkllistbutton_reset();
}
function ds_dom_move(direction,row){
	if(direction=='down')
		moverow=row+1;
	else
		moverow=row-1;
		
	link_item_temp=$('linklist_item_'+moverow).innerHTML;
	linkurl_temp=$('linkurl_'+moverow).value;
	linktext_temp=$('linktext_'+moverow).value;
	linktitle_temp=$('linktitle_'+moverow).value;
	linktarget_temp=$('linktarget_'+moverow).value;
					
	$('linklist_item_'+moverow).innerHTML=$('linklist_item_'+row).innerHTML;
	$('linkurl_'+moverow).value=$('linkurl_'+row).value;
	$('linktext_'+moverow).value=$('linktext_'+row).value;
	$('linktitle_'+moverow).value=$('linktitle_'+row).value;
	$('linktarget_'+moverow).value=$('linktarget_'+row).value;
	
	$('linklist_item_'+row).innerHTML=link_item_temp;			
	$('linkurl_'+row).value=linkurl_temp;
	$('linktext_'+row).value=linktext_temp;
	$('linktitle_'+row).value=linktitle_temp;
	$('linktarget_'+row).value=linktarget_temp;
}

// 2005-04-11 [AP] New, Image Position - News Maske
function dsimagepos(thisid,type){
	if (type=='default'){
		for (i=1;i<15;i++){
			if ($(type+'_pos'+i)!=null && $('restricted_pos'+thisid).className=='ds_imagepos_inactive')
				$(type+'_pos'+i).className='ds_imagepos_inactive';
			if ($(type+'_pos'+thisid).className=='ds_imagepos_inactive' && $('restricted_pos'+thisid).className=='ds_imagepos_inactive')
				$(type+'_pos'+thisid).className='ds_imagepos_active';
		}
		if($('restricted_pos'+thisid).className=='ds_imagepos_inactive')
			$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value=thisid;
	}
	else if(type=='restricted'){
		if ($(type+'_pos'+thisid).className=='ds_imagepos_inactive' && $('default_pos'+thisid).className=='ds_imagepos_inactive'){
			$(type+'_pos'+thisid).className='ds_imagepos_active';
			if($(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value!='')
				$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value=$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value+','+thisid;
			else
				$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value+=thisid;			
		}
		else{
			$(type+'_pos'+thisid).className='ds_imagepos_inactive';
			imagealigntemp=$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value.split(",");
			$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value='';
			for (x=0; x<imagealigntemp.length; x++){
				if (thisid!=imagealigntemp[x]){
					if($(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value!='')
						$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value=$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value+','+imagealigntemp[x];
					else
						$(type+'_'+$('set').options[$('set').selectedIndex].value+'_imagealign').value+=imagealigntemp[x];
				}
			}
		}
	}
	else{
		disabled=eval('default_'+curr_dsdid+'_'+selected_des+'.split("?")');	
		disabled_list=disabled[3].split(",");
		disabled2=0;
		designer='';
		for(r=0; r<DSRoleNames.length;r++){
			if(DSRoleNames[r]=='dsdesign')		
				designer=1;
		}		
		for(e=0;e<disabled_list.length;e++){
			if(disabled_list[e]==thisid && designer==0){
				alert('Diese Bildposition ist gesperrt!');
				disabled2=1;					
			}
		}
		if(disabled2==0){		
			for (i=1;i<15;i++) {
				if ($(type+'pos'+i)!=null)
					$(type+'pos'+i).className='ds_imagepos_inactive';
				if ($(type+'pos'+i)!=null && $(type+'pos'+thisid).className=='ds_imagepos_inactive')
					$(type+'pos'+thisid).className='ds_imagepos_active';
			}
			for(d=0;d<disabled_list.length;d++){
				if(disabled_list[d]!='' && disabled_list[d]!=thisid)
					$(type+'pos'+disabled_list[d]).className='ds_imagepos_restricted';
			}			
			$('imagealign').value=thisid;
		}
	}
}

function DSSetArticleDesign(dsaid,design) {
	var newClass=design;
	oldClass=DSJS.ListGetAt(DSJS.ListFirst($('dsarticle_'+dsaid).className,' '),2,'_');

	$('dsarticle_'+dsaid).removeClassName('dsarticle_'+oldClass);
	$('dsarticle_'+dsaid).removeClassName('dsarticle');
	$('dsarticle_'+dsaid).addClassName('dsarticle_'+newClass);
	$('dsarticle_'+dsaid).addClassName('dsarticle');

	$('dstitlebox_'+dsaid).removeClassName('dstitle_'+oldClass);
	$('dstitlebox_'+dsaid).addClassName('dstitle_'+newClass);
	
	$('dsarticletitle_'+dsaid).removeClassName('dstitle_'+oldClass);
	$('dsarticletitle_'+dsaid).addClassName('dstitle_'+newClass);

	$('dsarticlebody_'+dsaid).removeClassName('dsbody_'+oldClass);
	$('dsarticlebody_'+dsaid).addClassName('dsbody_'+newClass);
}

function dsworkflow_disable(){
	var i=0;
	dswflids=$('tabworkflow').attributes["dswflids"].nodeValue.split(',');	
	dswflsorting=$('tabworkflow').attributes["dswflsorting"].nodeValue.split(',');
	
	this_sorting=10000;
	
	for (i=0;i<dswflids.length;i++){
		if ($('isconfirmed_1_'+dswflids[i]).checked==false && this_sorting==10000){
			this_sorting=dswflsorting[i];
		}
		if (dswflsorting[i]>this_sorting){
			$('isconfirmed_1_'+dswflids[i]).disabled=true;
			$('isconfirmed_0_'+dswflids[i]).disabled=true;
			if ($('workflow_live_'+dswflids[i])!=null)
				$('workflow_live_'+dswflids[i]).disabled=true;
			
		}	
	}
}

function dsworkflow_chk(tr){
	var i=0;
	tr_id=tr.id.split('_');
	this_id=tr_id[2];
	this_radio=tr_id[1]*1;
	dswflids=$('tabworkflow').attributes["dswflids"].nodeValue.split(',');	
	dswflsorting=$('tabworkflow').attributes["dswflsorting"].nodeValue.split(',');
	dswfldisabled=$('tabworkflow').attributes["dswfldisabled"].nodeValue.split(',');
	
	this_pos=DSArrayFindPos(dswflids,this_id);
	this_sorting=dswflsorting[this_pos];
	
	if (this_radio==1){
		for (i=0;i<dswflids.length;i++){
			if (dswflsorting[i]>this_sorting && dswfldisabled[i]==0){
				$('isconfirmed_1_'+dswflids[i]).disabled=false;
				$('isconfirmed_0_'+dswflids[i]).disabled=false;
				if ($('workflow_live_'+dswflids[i])!=null)
					$('workflow_live_'+dswflids[i]).disabled=false;
			}
		}
	}
	dsworkflow_disable();
}


// ***************************
// * END NewsForm            *
// ***************************

//********************************
//*    Article Dragging          *
//********************************

// Call in system/_udf.cfm line 274
function DSObjectDrag_Column(theObject,this_event) {
	
	if (ds_drop_obj=='1234'){
		if (this_event=='up'){
			theObject.innerHTML='<b>'+this_event+'</b><br>'+theObject.innerHTML;
			//alert(TheObject.id)
		
		}
		if (this_event=='move'){
			//TheObject.innerHTML=' '+this_event+' '+TheObject.innerHTML;
		}
		if (this_event=='over'){
			theObject.innerHTML=' '+this_event+' '+theObject.innerHTML;
		}
	}


}
var ds_to_drop_obj='';
var ds_drop_obj='';

// Call in output/_dsarticle_css.cfm line 95 and 112
function DSObjectDrag_Article(theEvent,theObject,startEnd) {
	if(startEnd=='start') {
		ds_drop_obj=theObject;
		DSObjectDrag_dsdrag(theEvent);
	}
	else if(startEnd=='end') {
		dsdragapproved=false;
		if (ds_drop_over_obj!=''){
			column=ds_drop_over_obj.parentNode;
			neuB = document.createElement("p");
			neuBText = document.createTextNode(ds_drop_over_obj.id+'....'+column.id);
			neuB.style.border='3px solid green';
			neuB.appendChild(neuBText);
			new_drop_obj=ds_drop_obj.cloneNode(true);
			
			//new_drop_obj.style.border='3px solid green';
			new_drop_obj.style.position='relative';
			new_drop_obj.style.left='0px';
			new_drop_obj.style.top='0px';
			ds_drop_obj.id=ds_drop_obj.id+'_del';
			ds_drop_obj.style.display='none';
			
			column.insertBefore(new_drop_obj,ds_drop_over_obj);
			
			new_innerhtml=column.innerHTML;
			//column.innerHTML='';
			//alert('ok')
			//column.innerHTML=new_innerhtml;
		}
		ds_drop_obj=''; 	
		ds_drop_over_obj='';
	}
}

var ds_drop_over_obj='';
var da_lastmouse_pos=0;

function DSObjectDrag_ArticleOver(theEvent,theObject) {
	if (ds_drop_obj!=''){
		ds_drop_over_obj=theObject;
	}
}

function DSObjectDrag_dsdrag(e) {
	if (ds_drop_obj.style.position!='relative')
		ds_drop_obj.style.position='relative';
	dsdragapproved=true;
	temp1=0;
	temp2=20;
	dsdrag_x=ns6? e.clientX : event.clientX;
	dsdrag_y=ns6? e.clientY : event.clientY;
	document.onmousemove=DSObjectDrag_move;
	//ds_drop_obj.style.border='3px solid #000000';	
	return false;
}

function DSObjectDrag_move(e) {
	if (dsdragapproved) {
		ds_drop_obj.style.left=ns6? temp1+e.clientX-dsdrag_x+'px' : temp1+event.clientX-dsdrag_x+'px';
		ds_drop_obj.style.top=ns6? temp2+e.clientY-dsdrag_y+'px' :  temp2+event.clientY-dsdrag_y+'px';
		return false;	
	}
}


//********************************
//*  END  Article Dragging       *
//********************************

// ***************************
// * START _udf.cfm          *
// ***************************
function dscategoryadd(thisid,element) {
	if(thisid=='category_1'){		
		$(element+'_'+thisid).checked=true;
		$(element+'_category_2').checked=false;
		$(element).disabled=true;
		$(element+'_category_new').disabled=false;
		}		
	else if (thisid=='category_2'){ 
		$(element+'_category_1').checked=false;
		$(element+'_'+thisid).checked=true;
		$(element).disabled=false;
		$(element+'_category_new').disabled=true;
	}
}

// 2005-04-21 [AP]
function dssnippetedit(element,optionlist){
	dszid='';
	dszfid='';
	type='dszid';
	thiswindow=self;
	if (optionlist!=null)
		DSOptionList(optionlist)
	if (type=="dszid")
		dszid=thiswindow.$(element).options[thiswindow.$(element).selectedIndex].value;
	else
		dszfid=dstool.$(element).options[dstool.$(element).selectedIndex].value;
	error_message='';
	if (dszid=='0' || dszfid=='0') {
		error_message=DSLang('alertselectsnipppet');
	}
	else if (dszid=='1') {
		if($(element+'_1').value==0) {
			error_message=DSLang('alertnosnippetdefined');
		}
		else
			dszid=$(element+'_1').value;
	}			
	if (error_message!='')
		alert(error_message);
	else {
		if (dszid=='')
			dszid=0;
		else 
			dszfid=0;
		dsloader(dsxpath+'dynasite.cfm?dscmd=snippet_snippet_snippet_edit&dssid='+DSSID+'&dsmid='+DSMID+'&dszid='+dszid+'&dszfid='+dszfid,'_self');
	}
		
}
// ***************************
// * END _udf.cfm            *
// ***************************

// ***************************
// * Start Navigator         *
// ***************************
function ToDELETEdsnav_getdscid(dscid){
	if (c_dscid.length >1){
		document.write('<select class="navsel" id="cust" name="cust" onchange="dsnav_chk_dscid(this.selectedIndex)">');
		document.write('<option value="">~ '+DSLang('projects')+' ~</option>');
		for (i=0; i < c_dscid.length; ++i){
			if (c_dscid[i]==dscid)
				selected=' selected="selected"';
			else
				selected='';
			document.write('<option value="'+c_dscid[i]+'"'+selected+'>'+c_name[i].slice(0,18)+'</option>');
		}
		document.write('</select>');
	}
}
function ToDELETEdsnav_chk_dscid(pos){
	dsnav_loadsite(c_start[pos-1]);
}


function ToDELETEdsnav_changer(formname, popupname, target, scroll) {
	var popup = document[formname].elements[popupname];
	if (popup.options[popup.selectedIndex].text.length==0){
		popup.selectedIndex=0;
		return false;
	}
	top.MAIN.dsloader(popup.options[popup.selectedIndex].value,'dsm');
	// dsnav_open_win(popup.options[popup.selectedIndex].value,target,scroll)
	popup.selectedIndex=0;
}

function DSButtonModeSwitch() {
	if(DSButtonMode==1) {
		$('dsbuttonmode_0').style.display='block';
		$('dsbuttonmode_1').style.display='none';
		DSButtonMode=0;
	}
	else {
		$('dsbuttonmode_0').style.display='none';
		$('dsbuttonmode_1').style.display='block';
		DSButtonMode=1;
	}			
	top.MAIN.location.href=dsxpath+'main.cfm?dsmid='+top.MAIN.DSMID+'&dsbuttonmode='+DSButtonMode;	
}


function DSInfoModeSwitch() {
	var DSDSAIDList='';
	if (top.MAIN.isCSS==1) {
		if(DSInfoMode==1) {
			$('dsinfomode_0').style.display='block';
			$('dsinfomode_1').style.display='none';
			DisplayModeaaaa='none';
			DSInfoMode=0;
		}
		else {
			$('dsinfomode_0').style.display='none';
			$('dsinfomode_1').style.display='block';
			DisplayModeaaaa='block';
			DSInfoMode=1;
		}	
		if (top.MAIN.DSDSAIDList!=null) {
			DSDSAIDList=top.MAIN.DSDSAIDList.split(",");
			for (i=0; i<DSDSAIDList.length; i++) {
				if (top.MAIN.$('DSAdvancedArticleInfo_Box_'+DSDSAIDList[i])!=null)
					top.MAIN.$('DSAdvancedArticleInfo_Box_'+DSDSAIDList[i]).style.display=DisplayModeaaaa;					
			}	
			top.MAIN.dsloader(dsxpath+'dynasite.cfm?dscmd=security_user_user_setsession&dsmid='+DSMID+'&dsinfomode='+DSInfoMode,'dsloader','security_user_user_setsession');		
		}
		if (top.MAIN.$('dsformwaitcode')!=null)
			top.MAIN.$('dsformwaitcode').style.display='none';
	}
	else {
		alert(DSLang('alertcsssitesonly'));
	}
}

function DSNavigatorInit() {
	theWindow=top.MAIN;
	if(top.dsnav.DSCID!=theWindow.DSCID) {
		if(top.dsnav.DSViewSwitch!=null) {
			top.dsnav.DSViewSwitch('dsexplorer');
			top.DSManagerLoaded=0;
			top.dsnav.location.href='dynasite.cfm?dscmd=system_dsxnavbar_dsxnavbar_view&amp;dscid='+theWindow.DSCID+'&dssid='+theWindow.DSSID+'&dsmid='+theWindow.DSMID;
		}

	}
	else {		
		if(top.dsnav.DSSID!=theWindow.DSSID || top.dsnav.DSCLang!=theWindow.DSCLang) {
			for(i=0;i<top.dsnav.$('changer0').length;i++){
				if(top.dsnav.$('changer0').options[i].value==theWindow.DSSID+','+theWindow.DSCLang)
					top.dsnav.$('changer0').selectedIndex=i;
			}
		}
		if(top.dsnav.$('newarticle')!=null) {
			if(DSPAID > 0)
				top.dsnav.$('newarticle').innerHTML=top.dsnav.articletext_story;
			else
				top.dsnav.$('newarticle').innerHTML=top.dsnav.articletext;
		}
		if(top.dsnav.DSDirectEditStatus=="active" && top.dsnav.$('dsdireceditbutton')!=null){
			DSDirectEdit('active');
			top.dsnav.$('dsdireceditbutton').onclick=new Function('', "top.MAIN.DSDirectEdit('inactive')");
			top.dsnav.$('dsdireceditimage').src=dsgifpath+'icon/page.png';			
		}
		else if(top.dsnav.$('dsdireceditbutton')!=null){
			DSDirectEdit('inactive');
			top.dsnav.$('dsdireceditbutton').onclick=new Function('', "top.MAIN.DSDirectEdit('active')");
			top.dsnav.$('dsdireceditimage').src=dsgifpath+'icon/page_edit.png';
		}
		// 2008-02-12 [AP]
		if (top.dsnav.DSExplorer.DSOTID && top.dsnav.DSExplorer.DSOTID!=0) {	
			showDSOTID='';			
			for (i=1; i<=DSJS.ListLen(top.dsnav.DSExplorer.DSOTID); i++){
				thisDSOTID=DSJS.ListGetAt(top.dsnav.DSExplorer.DSOTID,i);
				thisList=eval('top.dsnav.DSExplorer.DSOTID_'+thisDSOTID+'.DSSID');
				spacer='';
				if (showDSOTID!='')
					spacer=',';
				
				if (DSJS.ListFind(thisList,theWindow.DSSID))
					showDSOTID+=spacer+thisDSOTID;			
				else {
					thisList=eval('top.dsnav.DSExplorer.DSOTID_'+thisDSOTID+'.DSMID');
					// alert(thisList+' find:'+DSJS.ListFind(thisList,theWindow.DSMID)+' dmsid:'+theWindow.DSMID)
					if (DSJS.ListFind(thisList,theWindow.DSMID))
						showDSOTID+=spacer+thisDSOTID;
				}				
			}			
			var selectelement='changer2';
			var optionlen=top.dsnav.$(selectelement).options.length;
			var addNewArticle=0;
			var addNewObject=0;
			var skipArticle=0;
			for (i=0; i<optionlen; i++){
				if (top.dsnav.$(selectelement).options[i]!=null && top.dsnav.$(selectelement).options[i].id=='dsotid') {		
					top.dsnav.$(selectelement).options[i]=null;		
				}
				if (showDSOTID!='') {
					addNewObject=1;
					if (top.dsnav.$(selectelement).options[i]!=null && top.dsnav.$(selectelement).options[i].id=='newarticle') {			
						top.dsnav.$(selectelement).options[i]=null;					
						break;
					}
				}
				else {
					addNewArticle=1;
					if (top.dsnav.$(selectelement).options[i]!=null && top.dsnav.$(selectelement).options[i].id=='newarticle')
						skipArticle=1;										
				}
			}
			if (addNewArticle==1 && skipArticle==0) {
				thisValue=top.dsnav.articletext;
				option=top.dsnav.document.createElement('option');
				option.value=DSAdminURL+'/dynasite.cfm?dscmd=content_article_article_new|content_article_article_new';
				option.id='newarticle';
				option.appendChild(top.dsnav.document.createTextNode(thisValue));					
				top.dsnav.$('contentid').appendChild(option);				
			}
			if (addNewObject==1) {
				for (i=1; i<=DSJS.ListLen(showDSOTID); i++){
					thisDSOTID=DSJS.ListGetAt(showDSOTID,i);
					thisValue=eval('top.dsnav.DSExplorer.DSOTID_'+thisDSOTID+'.Name'); 
					option=top.dsnav.document.createElement('option');
					option.value=DSAdminURL+'/dynasite.cfm?dscmd=content_article_article_new&dsotid='+thisDSOTID+'|content_article_article_new';
					option.id='dsotid';
					option.appendChild(top.dsnav.document.createTextNode(thisValue));					
					top.dsnav.$('contentid').appendChild(option);		
				}			
			}		
			
		}
		
	}
	top.dsnav.DSCID=theWindow.DSCID;
	top.dsnav.DSSID=theWindow.DSSID;
	top.dsnav.DSCLang=theWindow.DSCLang;
	top.dsnav.DSMID=theWindow.DSMID;
	top.dsnav.DSPAID=theWindow.DSPAID;
	top.dsnav.StartDSMID=theWindow.StartDSMID;
}	

// ***************************
// * END Navigator           *
// ***************************

// ***************************
// * START Context HTML      *
// ***************************

function dsdelconfirm(msg,url){
	ok=confirm(msg);
	if(ok==true) {
		self.location.href=url;
	}
}
dsmenutag='<a class="dsconmenu" href="javascript: DSDoNothing();" onclick="';

function menu_dsaid_text(event,dsaid,langdsaid,dspaid,per,live,urlstep,hasref,dspncid,dsinclude,dstname,des,optionlist){
	// 2006-09-28 [AP] DSXRole gegen PER ausgetauscht
	resetcommand='';
	querystring='';
	DSSortBy='';
	DSSortDirection='';
	DSOptionList(optionlist);
	menutext='';
	if (typeof DSDID=='undefined')
		DSDID=0
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	QueryString='&amp;dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;dsrandom='+DSRandom+querystring;
	if(resetcommand!='') {
		if (DSSortBy!='')
			DSSortBy='&DSSortBy='+DSSortBy;
		if (DSSortDirection!='')
			DSSortBy+='&DSSortDirection='+DSSortDirection;
		QueryString='&amp;dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;dsresetcommand='+resetcommand+DSSortBy+'&amp;dsrandom='+DSRandom+querystring;
	}
	if(per=='dseditor' || per=='dsauthor' && live==1)
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_article_edit'+QueryString+'&amp;dsaid='+langdsaid+'&amp;dspaid='+dspaid+'\',\'dspopup1\',\'content_article_article_edit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'</a>';
	if(DSServerCust=='tcs' && DSServerAdmin==1)		
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=contact_clipboard_clipboard_insert'+QueryString+'&amp;dsaid='+dsaid+'&amp;linkidtype=dsaid&amp;linkid='+dsaid+'\',\'dsloader\',\'contact_clipboard_clipboard_insert\')" onmouseover="window.status=\''+DSLang('Bookmark')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('Bookmark')+'</a>';	
	if(per=='dseditor' || per=='dsauthor' && live==1){	
		if(DSEdition > 2) {
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_copy_view'+QueryString+'&amp;dsaid='+dsaid+'\',\'dspopup1\',\'content_article_copy_view\')" onmouseover="window.status=\''+DSLang('copy')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('copy')+'&nbsp;</a>';
			if (dspaid<=1 || (dspaid>1 & urlstep.indexOf("2") ==-1 & hasref<2))
				menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_move_view'+QueryString+'&amp;dsaid='+dsaid+'\',\'dspopup1\',\'content_article_move_view\')" onmouseover="window.status=\''+DSLang('move')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('move')+'&nbsp;</a>';
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_reference_view'+QueryString+'&amp;dsaid='+dsaid+'\',\'dspopup1\',\'content_article_reference_view\')" onmouseover="window.status=\''+DSLang('reference')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('reference')+'&nbsp;</a>';
		}
	}
	if (dspaid<=1){
		if (per=='dseditor' || per!='dseditor' && dspaid==1 || per=='dsauthor' && live==1){
			if (dspaid==1)
				menutext+=dsmenutag+'top.location.href=\''+dsxpath+'dynasite.cfm?dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;dsaid='+dsaid+'&amp;dspaid='+dsaid+'\'" onmouseover="window.status=\''+DSLang('viewstory')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('viewstory')+'&nbsp;</a>';
			else if (urlstep.indexOf("2") ==-1 & hasref<2)//Wenn Artikel keine Referenz und keine Referenz in einer Story
				menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_article_new'+QueryString+'&amp;dsaid='+dsaid+'&amp;dspaid='+dsaid+'\')" onmouseover="window.status=\''+DSLang('newstory')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('newstory')+'&nbsp;</a>';
		}
	}
	else
		menutext+=dsmenutag+'top.MAIN.location.href=\''+dsxpath+'main.cfm?dssid='+DSSID+'&amp;dsmid='+DSMID+'\'" onmouseover="window.status=\''+DSLang('exitstory')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('exitstory')+'&nbsp;</a>';
	
	if (per=='dseditor' && (dspaid<=1 || dspaid>1 && (urlstep.indexOf("2") ==-1 || urlstep.indexOf("2") && dspaid==dspncid)))
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_delete_article_delconf&amp;dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;dsaid='+langdsaid+'&amp;dspaid='+dspaid+'\',\'dspopup1\',\'content_delete_article_delconf\')" onmouseover="window.status=\''+DSLang('delete')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('delete')+'&nbsp;</a>';
	if(DSEditionLevel > 2  && DSArrayFind(DSContextMenuAction,'task') && DSServerAdmin==1)
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_task_new&amp;dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;dsaid='+dsaid+'&amp;dslinkidtype=dsaid&amp;dslinkid='+dsaid+'\',\'dspopup2\')" onmouseover="window.status=\''+DSLang('assigntask')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('assigntask')+'&nbsp;</a>';
	if(DSArrayFind(DSRoleNames,'dsdesign') && des != 0){
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_set_set_directedit'+QueryString+'&amp;dsaid='+dsaid+'&amp;dspaid='+dspaid+'&amp;newdsmdscid='+DSCID+'&amp;dsdid='+DSDID+'&amp;designtype=article\',\'dspopup1\',\'design_set_set_directedit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('editdesign')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('editdesign')+'&nbsp;</a>';
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_explorer_explorer_article&dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;dsaid='+dsaid+'&amp;dspaid='+dspaid+'&amp;newdsmdscid='+DSCID+'&amp;designtype=article\',\'dspopup3\')" onmouseover="window.status=\''+DSLang('DesignExplorer')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('DesignExplorer')+'&nbsp;</a>';
	}
	if (per=='dseditor'){
		// menutext+=dsmenutag+'dsloader(\'';
	if (live==1)
		windowtext=DSLang('activate');
	else
		windowtext=DSLang('deactivate');
	/*if (live==1)
		menutext+=lcakt;
	else
		menutext+=lcdeakt;
	*/
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_article_article_liveconf'+QueryString+'&amp;dsaid='+langdsaid+'&amp;dspaid='+dspaid+'\')" onmouseover="window.status=\''+windowtext+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;';
	if (live==1)
		menutext+=DSLang('activate');
	else
		menutext+=DSLang('deactivate');
	menutext+='&nbsp;</a>';
	}
	DSColorSchemeBar(3,'variable');
	if(DSXRole=='dseditor' && des != 0 && isCSS)
		menutext+='<div id="track_'+dsaid+'" style="text-align:left;background:#F4F4ED;border-bottom:1px solid  #C3C39C;height:17px;"><div id="handle_'+dsaid+'" style="padding:2 0 0 0;text-align:center;width:20%;height:15px;background-color:#d2cdba;cursor:move;"></div></div>';
	menutext+='<div class="dscontextmenutitle" style="cursor:pointer" onClick="$(\'DSAdvancedArticleInfo_Box_'+dsaid+'\').style.display=\'block\';">Article ['+dsaid+']</div>'+colorschemebar+'</div>';
	DSContextShow(event,menutext);
	if(per=='dseditor' && des != 0 && isCSS){
		new Control.Slider('handle_'+dsaid,'track_'+dsaid,{range:$R(1,5),
			sliderValue:des,
			values:[1,2,3,4,5],
			onSlide:function(v){
				DSSetArticleDesign(dsaid,v);
				if(v==1)
					vtext=v+' &raquo;';
				else if(v==5)
					vtext='&laquo; '+v;
				else
					vtext='&laquo; '+v+' &raquo;';			
				$('handle_'+dsaid).innerHTML=vtext;
				
			},
			onChange:function(v){
				if(v!=des){
					designconfirmtext=DSLang('alertapplynewdesign');
					designconfirm=confirm(designconfirmtext);
					if(designconfirm==true){
						url=DSAdminURL+'/dynasite.cfm?dscmd=content_article_article_design&design='+v+'&dsaid='+dsaid+'&dssid='+DSSID;
						new Ajax.Request(url, {method: 'get'});
						DSContextHide();
						$('dsarticlebutton_'+dsaid).onclick="";
						$('dsarticlebutton_'+dsaid).onclick=function (){eval('menu_dsaid_text(event,'+dsaid+','+langdsaid+','+dspaid+',\''+per+'\','+live+',\''+urlstep+'\','+hasref+','+dspncid+','+dsinclude+',\''+dstname+'\','+v+',\''+optionlist+'\')')};
					}
					else{
						DSSetArticleDesign(dsaid,des);
						DSContextHide();
					}
				}
			}
		});
		if(des==1)
			vtext=des+' &raquo;';
		else if(des==5)
			vtext='&laquo; '+des;
		else
			vtext='&laquo; '+des+' &raquo;';				
		$('handle_'+dsaid).innerHTML=vtext;
	}
}
function menu_dsmid_text(e,thisdsmid,dspmid,dsdid,per,live,langdsmid){
	menutext='';
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	if (per=='dseditor' || per=='dsauthor' && live==0)
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_menu_menu_edit&amp;dsmid='+langdsmid+'&amp;dsrandom='+DSRandom+'\',\'dspopup1\',\'content_menu_menu_edit\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'</a>';
	if(DSServerCust=='tcs' && DSServerAdmin==1)		
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=contact_clipboard_clipboard_insert&amp;dsmid='+thisdsmid+'&amp;linkidtype=dsmid&amp;linkid='+thisdsmid+'&amp;dsrandom='+DSRandom+'\',\'dsloader\',\'contact_clipboard_clipboard_insert\')" onmouseover="window.status=\''+DSLang('bookmark')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('bookmark')+'</a>';	
	if (per=='dseditor'){
		if(DSEditionLevel > 2) {
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_menu_copy_view&amp;dsmid='+thisdsmid+'&amp;dscmrdsmid='+thisdsmid+'\',\'dspopup1\',\'content_menu_copy_view\')" onmouseover="window.status=\''+DSLang('copy')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('copy')+'</a>';
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_menu_move_view&amp;dsmid='+thisdsmid+'&amp;dscmrdsmid='+thisdsmid+'\',\'dspopup1\',\'content_menu_move_view\')" onmouseover="window.status=\''+DSLang('move')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('move')+'</a>';
		}
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=content_delete_menu_delconf&amp;dsmid='+langdsmid+'&amp;dsaid=0&amp;sub='+dspmid+'\',\'dspopup1\',\'content_delete_menu_delconf\')" onmouseover="window.status=\''+DSLang('delete')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('delete')+'</a>';
		if(DSEditionLevel > 2 && DSServerCust=='tcs' && DSArrayFind(DSContextMenuAction,'task') && DSServerAdmin==1)
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_task_new&amp;dsmid='+thisdsmid+'&amp;dslinkidtype=dsmid&amp;dslinkid='+thisdsmid+'\',\'dspopup2\')" onmouseover="window.status=\''+DSLang('assigntask')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('assigntask')+'&nbsp;</a>';
		if(DSArrayFind(DSRoleNames,'dsdesign')){
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_set_set_directedit&amp;dsmid='+thisdsmid+'&amp;dsdid='+dsdid+'&amp;designtype=menu\',\'dspopup1\',\'design_set_set_directedit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('editdesign')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('editdesign')+'&nbsp;</a>';
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_explorer_explorer_menu&amp;dsmid='+DSMID+'&amp;designtype=menu\',\'dspopup3\')" onmouseover="window.status=\''+DSLang('designexplorer')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('designexplorer')+'&nbsp;</a>';
		}
		// Export-Berechtigung
		if (((per=='dsreader' || per=='dseditor' || per=='dsauthor') && DSEditionLevel > 2 && (DSArrayFind(DSRoleNames,'dsexport') && DSArrayFind(DSContextMenuAction,'export'))))
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=site_export_export_select&amp;dsexpdsmid='+thisdsmid+'&amp;dslinkidtype=dsmid&amp;dslinkid='+thisdsmid+'\',\'dspopup1\',\'site_export_export_select\')" onmouseover="window.status=\''+DSLang('printexport')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('printexport')+'&nbsp;</a>';

	}
	// menutext+=dsmenutag+'dsloader(\''+dsxpath+'dsm/dsm.cfm?dsm=dynasite&amp;do=tasks&amp;step=tasks&amp;dscid=0&amp;dssid='+DSSID+'&amp;dsmid='+thisdsmid+'&amp;dsaid=0&amp;act=new&amp;task=dsmid\',830,700,1,\'yes\',\'dsm\')">&nbsp;'+DSLang('assigntask')+'</a>';
	if (per=='dseditor' && thisdsmid != StartDSMID){
		menutext+=dsmenutag+'dsdelconfirm(\'';
		if (live==1 || live==3)
			windowtext=DSLang('deactivate');
		else
			windowtext=DSLang('activate');
	if (live==1 || live==3)
			menutext+=DSLang('alertsetinactive');
		else
			menutext+=DSLang('alertsetactive');
		menutext+='\',\''+dsxpath+DSCaller+'.cfm?dscmd=content_menu_menu_live&amp;dsmid='+langdsmid+'&amp;dspmid='+dspmid+'&amp;dsrandom='+DSRandom+'\')" onmouseover="window.status=\''+windowtext+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;';
		if (live==1 || live==3)
			menutext+=DSLang('deactivate');
		else
			menutext+=DSLang('activate');
		menutext+='</a>';
	}
	DSColorSchemeBar(3,'variable');
	menutext+='<div class="dscontextmenutitle">'+DSLang('Menu')+' ['+thisdsmid+']</div>'+colorschemebar+'</div>';
	DSContextShow(e,menutext);
}

function menu_dszid_text(e,dszid){
	menutext='';
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=snippet_snippet_snippet_edit&amp;dsx=1&amp;dszid='+dszid+'&amp;dsrandom='+DSRandom+'\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'</a>';
	if(DSEdition > 2 && DSArrayFind(DSContextMenuAction,'task'))
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_task_new&amp;dszid='+dszid+'&amp;dslinkidtype=dszid&amp;dslinkid='+dszid+'\',\'dspopup2\')" onmouseover="window.status=\''+DSLang('assigntask')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('assigntask')+'&nbsp;</a>';
	DSColorSchemeBar(3,'variable');
	menutext+='<div class="dscontextmenutitle">'+DSLang('snippet')+' ['+dszid+']</div>'+colorschemebar+'</div>';
	DSContextShow(e,menutext);
}
// Context Menü für Comments
function menu_dstceid_text(e,dstceid,dslinkid,live){
	menutext='';
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=module_comment_moderation_edit&amp;dstceid='+dstceid+'&amp;dslinkid='+dslinkid+'&amp;dsrandom='+DSRandom+'\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'</a>';
	if (live==0)
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=module_comment_moderation_publishconf&amp;dstceid='+dstceid+'&amp;dslinkid='+dslinkid+'&amp;dsrandom='+DSRandom+'\')" onmouseover="window.status=\''+DSLang('activate')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('activate')+'</a>';	
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=module_comment_moderation_delconf&amp;dstceid='+dstceid+'&amp;dslinkid='+dslinkid+'&amp;dsrandom='+DSRandom+'\')" onmouseover="window.status=\''+DSLang('delete')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('delete')+'</a>';
	DSColorSchemeBar(3,'variable');
	menutext+='<div class="dscontextmenutitle">'+DSLang('comment')+' ['+dstceid+']</div>'+colorschemebar+'</div>';
	DSContextShow(e,menutext);
}

function menu_dssid_text(e,per){
	menutext='';
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=site_site_site_edit&amp;dssid='+DSSID+'&amp;dsrandom='+DSRandom+'\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'&nbsp;Site</a>';
	if(DSServerAdmin==1) {
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=project_project_project_edit&amp;dscid='+DSCID+'\')" onmouseover="window.status=\''+DSLang('copy')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'&nbsp;Project</a>';
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=site_site_site_copyconf&amp;dssid='+DSSID+'\')" onmouseover="window.status=\''+DSLang('copy')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('copy')+'</a>';
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=site_site_site_delconf&amp;dssid='+DSSID+'\')" onmouseover="window.status=\''+DSLang('delete')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('delete')+'</a>';
		if(DSEdition > 2 && DSArrayFind(DSContextMenuAction,'task'))
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_task_new&amp;dssid='+DSSID+'&amp;dslinkidtype=dssid&amp;dslinkid='+DSSID+'\',\'dspopup2\')" onmouseover="window.status=\''+DSLang('assigntask')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('assigntask')+'&nbsp;</a>';
	}
	if (((per=='dsreader' || per=='dseditor' || per=='dsauthor') && (DSEdition > 2 && DSArrayFind(DSRoleNames,'dsexport') && DSArrayFind(DSContextMenuAction,'export'))))
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=site_export_export_select&amp;dsexpdssid='+DSSID+'&amp;dsexpdsmid=0\',\'dspopup1\',\'site_export_export_select\')" onmouseover="window.status=\''+DSLang('printexport')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('printexport')+'&nbsp;</a>';
	if(DSArrayFind(DSRoleNames,'dsdesign')) {
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=system_cache_cache_delconf\',\'dspopup2\')" onmouseover="window.status=\''+DSLang('deletecache')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('deletecache')+'</a>';		
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_set_set_directedit&amp;dssid='+DSSID+'&amp;dsdid='+DSDID+'&amp;designtype=layout\',\'dspopup1\',\'design_set_set_directedit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('editlayoutdesign')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('editlayoutdesign')+'</a>';
		if(isCSS)
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_set_set_directedit&amp;dssid='+DSSID+'&amp;dsdid='+DSDID+'&amp;designtype=custom\',\'dspopup1\',\'design_set_set_directedit\',\'cancelalert:1\')" onmouseover="window.status=\''+DSLang('editcustomdesign')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('editcustomdesign')+'</a>';		
		if(DSEdition > 2){
			menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_set_set_directedit&amp;dssid='+DSSID+'&amp;dsdid='+DSDID+'&amp;designtype=set\')" onmouseover="window.status=\''+DSLang('editdesignset')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('editdesignset')+'</a>';
			if(isCSS)			
				menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=design_explorer_explorer_set&dssid='+DSSID+'&amp;dsmid='+DSMID+'&amp;designtype=set\',\'dspopup3\')" onmouseover="window.status=\''+DSLang('designexplorer')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('designexplorer')+'&nbsp;</a>';
		}
	}
	DSColorSchemeBar(3,'variable');
	menutext+='<div class="dscontextmenutitle">'+DSLang('site')+' ['+DSSID+']</div>'+colorschemebar+'</div>';
	DSContextShow(e,menutext);
}
// Context Menü für Command
function menu_dscmdid_text(e,optionlist){
	menutext='';
	fieldcommand='';
	trigger='cmd';
	thisstep='project';
	dscmdid=0;
	DSOptionList(optionlist);
	if (trigger=='dscmd')
		thisstep='server';
	QueryString='&amp;dslatype='+thisstep+'&amp;dscmdtrigger='+trigger+'&amp;dscmdid='+dscmdid+'&amp;fieldcommand='+fieldcommand+'&amp;dsrandom='+DSRandom;
	menutext+='<div onclick="DSContextHide()" class="dscontextmenucontent">';
	if (fieldcommand!='')
		menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=command_language_'+thisstep+'_edit'+QueryString+'\',\'dspopup3\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;Language</a>';
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=command_command_field_new'+QueryString+'\',\'dspopup2\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;New Placeholder</a>';
	menutext+=dsmenutag+'dsloader(\''+dsxpath+'dynasite.cfm?dscmd=command_command_command_edit'+QueryString+'\',\'dspopup1\')" onmouseover="window.status=\''+DSLang('edit')+'\';return true" onmouseout="window.status=\' \';return true">&nbsp;'+DSLang('edit')+'</a>';
	DSColorSchemeBar(3,'variable');
	menutext+='<div class="dscontextmenutitle">Command ['+dscmdid+']</div>'+colorschemebar+'</div>';
	DSContextShow(e,menutext);
}


// ***************************
// * END Context HTML      *
// ***************************

// ******************************
// * Start Snippet _snippet.cfm *
// ******************************
 function dssnippet_uebergabe(was,typ){
	if (typ==3)
		showcode();
 	laenge=parent.dspopup1_loader.dsformfield.value.length;
	doit=1;
		if (was==2 && laenge>0){
		chk=confirm(DSLang('alertoverwritesnippet'));
		if (chk==false)
			doit=0;
	}
	if (doit>0){
		inhalt=$('snippet').value;
		if (typ==2){
			if (was==1)
		 		inhalt=inhalt+parent.dspopup1_loader.f1.shortbody.value;
			else if (was==3)
				inhalt=parent.dspopup1_loader.f1.shortbody.value+inhalt;
			parent.dspopup1_loader.f1.shortbody.value=inhalt;
			parent.dspopup1_loader.f1.ssubject.value='';
			parent.dspopup1_loader.f1.dszid.value=document.f1.tempdszid.value;
//			parent.dspopup1_loader.dsnews_output('text');
		}
		else{
			if (was==1)
		 		inhalt=inhalt+parent.dspopup1_loader.dsformfield.value;
			else if (was==3)
				inhalt=parent.dspopup1_loader.dsformfield.value+inhalt;
			parent.dspopup1_loader.dsformfield.value=inhalt;
		}
		parent.dspopup('close|dspopup2');
	}
	parent.dspopup_zindex('dspopup1');
	if(parent.dspopup3_loader.uebergabe_display!=null){
		for(i=0;i<parent.dspopup3_loader.uebergabe_display.length;i++){
			if(parent.dspopup3_loader.$('uebergabe_'+parent.dspopup3_loader.uebergabe_display[i])!=null)			
				parent.dspopup3_loader.$('uebergabe_'+parent.dspopup3_loader.uebergabe_display[i]).style.visibility='hidden';
		}
	}
	if(parent.dspopup1_loader.$('dsdir_'+parent.dsfield)!=null)
		parent.dspopup1_loader.$('dsdir_'+parent.dsfield).style.color='#00008b';	
//	parent.dsm_loader.dsform='';
//	parent.dsm_loader.dsfield='';
//	parent.dsm_loader.dsmmtyp='';
 }
// ******************************
// * END Snippet _snippet.cfm   *
// ******************************

// ******************************
// *     Skype Check BEGIN      *
// ******************************
var activex = ((navigator.userAgent.indexOf('Win')  != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
var CantDetect = ((navigator.userAgent.indexOf('Safari')  != -1) || (navigator.userAgent.indexOf('Opera')  != -1));

function oopsPopup() {
    if((navigator.language && navigator.language.indexOf("ja") != -1) || (navigator.systemLanguage && navigator.systemLanguage.indexOf("ja") != -1) || (navigator.userLanguage && navigator.userLanguage.indexOf("ja") != -1)) {
        var URLtoOpen = "http://download.skype.com/share/skypebuttons/oops/oops_ja.html";
    } else {
        var URLtoOpen = "http://download.skype.com/share/skypebuttons/oops/oops.html";
    }
	var windowName = "oops";
	var popW = 540, popH = 305;
	var scrollB = 'no';
	w = screen.availWidth;
	h = screen.availHeight;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	oopswindow = window.open(URLtoOpen, windowName,'width=' + popW + ',height=' + popH + ',scrollbars=' + scrollB + ',screenx=' +leftPos +',screeny=' +topPos +',top=' +topPos +',left=' +leftPos);
	return false;
}

if(typeof(detected) == "undefined" && activex) {
    document.write(
        ['<script language="VBscript">',
        'Function isSkypeInstalled()',
        'on error resume next',
        'Set oSkype = CreateObject("Skype.Detection")',
        'isSkypeInstalled = IsObject(oSkype)',
        'Set oSkype = nothing',
        'End Function',
        '</script>'].join("\n")
    );
}

function skypeCheck() {
    if(CantDetect) {
        return true;
    } else if(!activex) {
        var skypeMime = navigator.mimeTypes["application/x-skype"];
        detected = true;
        if(typeof(skypeMime) == "object") {
            return true;
        } else {
            return oopsPopup();
        }
    } else {
        if(isSkypeInstalled()) {
            detected = true;
            return true;
        }
    }
    
    detected = true;
    return oopsPopup();
}

function loadDetection() {
    if(document.getElementById && document.getElementsByTagName) {
        if (window.addEventListener) window.addEventListener('load', addDetection, false);
        else if (window.attachEvent) window.attachEvent('onload', addDetection);
    }
}

function addDetection() {
    var pageLinks = document.getElementsByTagName("a");
    for (var i=0; i < pageLinks.length; i++) {
        if(pageLinks[i].childNodes[0] && pageLinks[i].childNodes[0].src) {
            if((pageLinks[i].childNodes[0].src.indexOf('download.skype.com\/share\/skypebuttons') != -1 || pageLinks[i].childNodes[0].src.indexOf('mystatus.skype.com') != -1) && (typeof(pageLinks[i].onclick) == "undefined" || pageLinks[i].onclick == null)) {
                pageLinks[i].onclick = function sChk() { return skypeCheck(); }
            }
        }
    }
}

loadDetection();

// ******************************
// *  END    Skype Check        *
// ******************************



// Shortcut Start
if(ie)
	document.attachEvent("onkeypress", DSShortCutCaller);
else
	document.addEventListener("keypress", DSShortCutCaller,true);
var dsshortcut='';

function DSShortCutCaller(event){
	if(top.$('dsadminset')==null)
		return;
	viewmode=dsviewcheck();
	if(viewmode=='split' || viewmode=='MAIN') {
		thewindow='MAIN';
		dsparent='&dsparent=dsexplorer';
	}
	else { 
		thewindow='dsmanager';
		dsparent='&dsparent=dsmanager';
	}	
	thedoc=eval('top.'+thewindow);	
	commandadd='&dssid='+thedoc.DSSID+'&dsmid='+thedoc.DSMID+'&dspaid='+thedoc.DSPAID+'&dsrandom='+thedoc.DSRandom;
	if(ie){
		if(event.srcElement.tagName!='TEXTAREA' && event.srcElement.tagName!='INPUT'){
			if(dsshortcut==''){
				dsshortcut=event.keyCode;
				window.setTimeout("dsshortcut=''", 1000);
				return;
			}
			else{
				for(i=0;i<top.shortcut.length;i++){
					if(dsshortcut==top.shortcut[i][0].split(',')[0] && event.keyCode==top.shortcut[i][0].split(',')[1])
						thedoc.dsloader(DSAdminURL+'/dynasite.cfm?dscmd='+top.shortcut[i][1]+commandadd+dsparent,top.shortcut[i][2],top.shortcut[i][1]);
				}
				dsshortcut='';
			}
		}
	}
	else{
		if(event.target.nodeName!='TEXTAREA' && event.target.nodeName!='INPUT'){
			if(dsshortcut==''){
				dsshortcut=event.charCode;
				window.setTimeout("dsshortcut=''", 1000);
				return;
			}
			else{
				for(i=0;i<top.shortcut.length;i++){
					if(dsshortcut==top.shortcut[i][0].split(',')[0] && event.charCode==top.shortcut[i][0].split(',')[1])
						thedoc.dsloader(DSAdminURL+'/dynasite.cfm?dscmd='+top.shortcut[i][1]+commandadd+dsparent,top.shortcut[i][2],top.shortcut[i][1]);
				}
				dsshortcut='';
			}
		}
	}
}
// Shortcut End


// Start design/layout _layout.cfm 
function dsd_layout_select_chk(sn,si){
	var laenge = sn.length-5; 
	var Extrakt = sn.slice(0,laenge);
	var radioname = Extrakt+'_Head';
	var val = eval('document.f1.'+sn+'[si].value');
	if (si>0 && val.length==0 && si<eval('document.f1.'+sn+'.length'))
		eval('document.f1.'+sn+'.selectedIndex=si+1');
	if(eval('document.f1.'+radioname+'[0].checked==true')){
		var dshead='&dshead=0';}
	else if(eval('document.f1.'+radioname+'[1].checked==true')){
		var dshead='&dshead=1';}
	var snipurl = eval('document.f1.'+sn+'.value+dshead');

	if (eval('document.f1.'+sn+'.selectedIndex') > 0)
		eval('document.f1.'+Extrakt+'.value="dssnippet.cfm?dszid="+snipurl;');
	else
		eval('document.f1.'+Extrakt+'.value="";');
}
// END Design/layout.cfm


// DSM_Designer_Sets
function dsd_sets_highover(id){
	laenge=eval('$("'+id+'").length');
	if (laenge>0){
		if (eval('$("'+id+'[0]").className')=='dshighlight0')
			newclassname='dshighlight1'
		else
			newclassname='dshighlight0'
		for(i=0;i<laenge;i++){
			eval('$("'+id+'['+i+']").className=newclassname');
		}
	}
	else{
		if (eval('$("'+id+'").className')=='dshighlight0')
			newclassname='dshighlight1'
		else
			newclassname='dshighlight0'
		eval('$("'+id+'").className=newclassname')
	}
}
// END DSM

// Dynasite Tools
function dstooloptions(ToolSelection){
	if(ToolSelection == 'zitat' || ToolSelection == 'command'){
		$("dstooloptionsedit").style.display='none';
		$("dstooloptionsnew").style.display='none';
	}
	else if(ToolSelection == '0' && DSServerAdmin==0){
		$("dstooloptionsedit").style.display='none';
		$("dstooloptionsnew").style.display='none';
	}
	else{
		if(f1.dsinclude.value == 0){
			$("dstooloptionsedit").style.display='none';
			$("dstooloptionsnew").style.display='inline';
		}

		else{
			$("dstooloptionsedit").style.display='inline';
			$("dstooloptionsnew").style.display='none';
		}
	}
}

function dstoolwindow(Tool,DSTID,newdsmdscid){
	if(DSTID==0){
		toolstep='new';
		switch(Tool) {
		case "gallery": whichtool='asset_gallery_gallery_new'; break;
		case "faq": whichtool='module_faq_faq_new'; break;
		case "guestbook": whichtool='module_guestbook_guestbook_new'; break;
		case "vote": whichtool='module_vote_vote_new'; break;
		case "taf": whichtool='module_taf_taf_new'; break;
		default: whichtool='snippet_snippet_coldfusion_new'; break;
		}
	}
	else{
		toolstep='settings';
		switch(Tool) {
		case "gallery": whichtool='asset_gallery_gallery_edit'; break;			
		case "faq": whichtool='module_faq_faq_edit'; break;
		case "guestbook": whichtool='module_guestbook_guestbook_edit'; break;
		case "vote": whichtool='module_vote_vote_edit'; break;
		case "taf": whichtool='module_taf_taf_edit'; break;
		default: whichtool='snippet_snippet_coldfusion_edit'; break;
		}
	}
	dsloader(dsxpath+'dynasite.cfm?dscmd='+whichtool+'&DSTID='+DSTID+'&DSZSID='+DSTID+'&catid='+DSTID,'dspopup1');			
}



function dsremovegallerypic(){
	if($('gallerysort').selectedIndex!=-1){
		$('div_picture_options_'+$('gallerysort').options[$('gallerysort').selectedIndex].value).innerHTML='';
		$('gallerysort').options[$('gallerysort').selectedIndex]=null;
		$('gallerysort').selectedIndex=0;
		tempposition='';
		for(i=0;i<$('gallerysort').length;i++){
			if(i==0)
				tempposition+=$('gallerysort').options[i].value;
			else
				tempposition+=','+$('gallerysort').options[i].value;				
		}
		$('position').value=tempposition;
		if(parent.dspopup1_loader.$('gallerysort').length!=0)
			parent.dspopup1_loader.to_output();
		else{
			parent.dspopup1_loader.$('linktarget').selectedIndex=0;
			parent.dspopup1_loader.$('linkurl').value='';			
		}
	}
	else
		alert(DSLang('alertselectpicturebeforedelete'));
}
//END Dynasite Tools


function disablesubmenu(thiselement,thisvalue,dssid,optionlist) {
	what=thiselement.id.split('_')[0];
	dsmidListe=eval('top.dsmidListe'+dssid);
	depthListe=eval('top.depthListe'+dssid);						
	currentdepth='';
	display='onclick';
	if (optionlist!=null)
		DSOptionList(optionlist)
	if (what=='dssid') {
		disablestatus=1;
		if (display=='onclick') {
			if ($('dssid_image_'+dssid).src==dsgifpath+'icon_checkbox_unchecked.gif') {
				$('dssid_image_'+dssid).src=dsgifpath+'icon_checkbox_checked.gif';
				$('dssid_'+dssid).checked=true;			
			}
			else if ($('dssid_image_'+dssid).src==dsgifpath+'icon_checkbox_checked.gif'){
				$('dssid_image_'+dssid).src=dsgifpath+'icon_checkbox_unchecked.gif';
				$('dssid_'+dssid).checked=false;
				disablestatus=0;
			}
			else if ($('dssid_image_'+dssid).src==dsgifpath+'icon_checkbox_partialchecked.gif'){
				DSDispatchEvent('dsacc_site_export_export_sitemenu_'+dssid+'_arrow');
				$('dssid_image_'+dssid).src=dsgifpath+'icon_checkbox_unchecked.gif';
				$('dssid_'+dssid).checked=false;
				disablestatus=0;
			}	
			if (dsmidListe!=null) {
				for (i=0; i<dsmidListe.length; i++){
					if ($('dsmid_'+dsmidListe[i])!=null) {
						$('dsmid_'+dsmidListe[i]).checked=false;
						$('dsmid_'+dsmidListe[i]).disabled=disablestatus;					
					}
				}
			}
		}
		else if (display=='onload') {
			if ($('dssid_'+dssid).checked==false)
				disablestatus=0;
			if ($('dssid_image_'+dssid).src==dsgifpath+'icon_checkbox_unchecked.gif') {
				for (i=0; i<dsmidListe.length; i++){
					if ($('dsmid_'+dsmidListe[i])!=null) {
						$('dsmid_'+dsmidListe[i]).checked=false;			
						$('dsmid_'+dsmidListe[i]).disabled=false;
					}
				}			
			}
		}
	}
	else if (what=='dsmid') {
		if (thiselement.checked==true)
			disablestatus=1;
		else
			disablestatus=0;	
		//this_pos=DSArrayFindPos(dsmidListe,thisvalue);
		//currentdepth=depthListe[this_pos];
		$('dssid_image_'+dssid).src=dsgifpath+'icon_checkbox_partialchecked.gif';
		$('dssid_'+dssid).checked=false;
		current_checked=$('dsmid_'+thiselement.value).checked;
		//partialchecked=1;
		this_pos=-1;
		for (i=0; i<dsmidListe.length; i++){	
			if (thiselement.value==dsmidListe[i])
				this_pos=i;
			$('dsmid_'+dsmidListe[i]).checked=false;
			$('dsmid_'+dsmidListe[i]).disabled=false;
		}
		if (current_checked){
			$('dsmid_'+thiselement.value).checked=true;
			if (this_pos>-1 && this_pos<dsmidListe.length-1){
				currentdepth=depthListe[this_pos];
				for (i=this_pos+1; i<dsmidListe.length; i++){
					if (depthListe[i]<=currentdepth)
						break;
					else
						$('dsmid_'+dsmidListe[i]).disabled=true;
				}
			}
		}
	}						

}


// Start DSDEV

function DSDevbar_DSPopUp(theWindow,type) {
	if(type=='refresh')
		theWindow.location.href=theWindow.location;
	else if(type=='editcmd') {
		if(theWindow=='lastcmd') {
			cmdpos=top.DSFindLoader_Loaded('lastcmd');
			// alert(cmdpos);
			if (cmdpos>-1) {
				// alert(top.DSLoader_Loaded[cmdpos][2].name);
				theWindow=top.DSLoader_Loaded[cmdpos][2];
			}
		}						
		if(theWindow=='dsmanager')
			dsloader(dsxpath+'/dynasite.cfm?dscmd=command_command_command_edit&dscmdid=0&dscmdedit='+top.DSGUIObject_Active.DSTree_dsmanagertree_Content,'dspopup2')	
		else if(typeof theWindow.DSCMDID!='undefined')
			dsloader(dsxpath+'/dynasite.cfm?dscmd=command_command_command_edit&dscmdid='+theWindow.DSCMDID,'dspopup2')	
	}
}
function DSDev(type,action,optionlist) {
	var thelabel='';
	var promptString='';
	if(optionlist!=null) {
		file='&dsdev_file='+optionlist;
		
	}
	if(action=='cffile') {
		if(optionlist=='designsetcss')
			file=file+'&dsdid='+top.MAIN.DSDID;
		window.open('dynasite.cfm?dscmd=system_devtool_'+type+'_'+action+file+'','dsdevtool');
	}
	else {
		if(action=='selecttop')
			thelabel='\ntheTable,theTOP';
		else if(action=='selectid')
			thelabel='\ntheTable,theID';
		else if(action=='cfdump')
			thelabel='\nvar1,var2,var3';
		if(thelabel!='') {
			promptString = prompt(thelabel, "");
		}
		if(promptString!=null) {
			promptString='&DSDev_Table='+promptString;
			window.open('dynasite.cfm?dscmd=system_devtool_'+type+'_'+action+promptString+'','dsdevtool');
		}
	}
}
function DSShowJSObject(which){
	var result = "";
	if(which==''){
		which=prompt('Any Object or ID', "");
		which=eval(which);
	}
	for (var i in which) {
		result +=i+"="+which[i]+"\n";
	}
	alert(result);
}
function DSShowJSObjecttest(which){
	var result="";
	var result2="";					
	for (var i in which) {
		result +=i+"="+which[i][0]+"||"+which[i][1]+"\n";
		testobject=which[i][0];
		alert(result);						
		for (var v in testobject) {
			result2 +=v+"="+testobject[v]+"\n";
		}
		alert(result2)
	}
}
// END DSDEV


// Google like tag add select
function DDD(theElement) {
	pos=6;
	theElement.options[pos].text='Features';
	theElement.options[pos].value='tagadd_31';
}

// *************************************
// * zu Überpr\374fen                  *
// *************************************

// keine Ahnung wohl auf irgendwelchen Seiten eingebaut
function writedate() {
	jetzt = new Date();
	wochentag_list=new Array(DSLang('sunday'),DSLang('monday'),DSLang('tuesday'),DSLang('wednesday'),DSLang('thursday'),DSLang('friday'),DSLang('saturday'));
	monat=jetzt.getMonth()+1;
	if (monat<10)
		monat='0'+monat;
	date_string=wochentag_list[jetzt.getDay()]+', '+jetzt.getDate()+'.'+monat+'.'+jetzt.getFullYear();
	document.write(date_string)
}


// nur in command\_command.cfm
function dsbitmask_edition(this_select) {
	dsform_select_move(this_select);
	edition_active_value=0;
	for (i=0; i < $('select_active_1').length; ++i) { 
		edition_active_value=edition_active_value*1+$('select_active_1').options[i].value*1;
	}
	$('edition_bitmask').value=edition_active_value;
}


// 2005-07-28 [AP] Wird in der _filesystem.cfm verwendet, um die einzelnen Ordner auszul\344sen und anzuzeigen.
last_row=0;
function show(row,thisdir,gallery){
	$('dsdatafolder_'+last_row).className='dsmenu';
	$('dsdatafolder_'+row).className='dsmenua';
	last_row=row;
	dsloader(dsxpath+'dynasite.cfm?dscmd=asset_filesystem_filesystem_view&unlock=1&thisdir='+thisdir+'&gallery='+gallery,'dsloader');	
}

// Wird f\374r die Statistik ben\366tigt [TR 05.10.2005]	
function ds_referersubmit(dsmdssid,dsstatslang){
	widthSite=0;
	domains=0;
	show=$('top_'+dsmdssid).options[$('top_'+dsmdssid).selectedIndex].value;
	if($('widthsite_'+dsmdssid).checked==true)
		widthSite=1;
	if($('domains_'+dsmdssid).checked==true)
		domains=1;
	dsloader(dsxpath+'dynasite.cfm?dscmd=statistic_referer_referer_view&dsmdssid='+dsmdssid+'&top='+show+'&widthSite='+widthSite+'&domains='+domains+'&dsstatslang='+dsstatslang,'dsloader');		
}

// Wird für die Statistik benötigt [TR 27.08.08]
var	xx_posleft=0;
var	xx_postop=0;
function xx_set_visible(imageID, id, e, value){
	xx_posleft=Event.pointerX(Event);
	xx_postop=Event.pointerY(Event);
	if(Event.element(e).readAttribute('clickset')==null) {
		Event.element(e).setAttribute('clickset',1); 
		Event.element(e).observe('click', 
			function() {
				// alert(dsxpath+'dynasite.cfm?dscmd=statistic_visit_'+$(id).step+'_view&dsmdssid='+$(id).dssid+'&datum='+$(id).date);
				dsloader(dsxpath+'dynasite.cfm?dscmd=statistic_visit_'+$(id).readAttribute('step')+'_view&dsstatslang='+$(id).readAttribute('dsstatslang')+'&dsmdssid='+$(id).readAttribute('dssid')+'&datum='+$(id).readAttribute('date'),'dsloader');
			}
		); 	
	}	
	if (!xx_supported_client()) return ;
	xx_get_by_id(id).style.visibility= value ? "visible" : "hidden";
	if(value) xx_move_tag(imageID,id,e);
	xx_get_by_id(id).style.display=value ? "" : "none";
}

function xx_move_tag(id,e){
	if (!xx_supported_client()) return ;
	var popup = xx_get_by_id(id);
	if (popup.style.visibility!="visible") return ;

	var ie=document.all;
	var ns6=!(!document.getElementById || ie)   ; /*document.getElementById AND !document.all*/

	var iebody = !(!document.compatMode || document.compatMode=="BackCompat")? document.documentElement : document.body;

	var dx = 10, dy = 10;
	var posX=(ns6)?e.pageX : event.x+iebody.scrollLeft;
	var posY=(ns6)?e.pageY : event.y+iebody.scrollTop;

	if(ie || ns6) {
		var parent = popup.offsetParent ;
		while(parent) {		
			posX -= parent.offsetLeft;
			posY -= parent.offsetTop;
			parent=parent.offsetParent;
		}
	}

	var ieNOTopera = !(!ie || window.opera);	
	var rightedge= ieNOTopera ? iebody.clientWidth-event.clientX: window.innerWidth-e.clientX-20
	var bottomedge=ieNOTopera ? iebody.clientHeight-event.clientY : window.innerHeight-e.clientY-20

	if (xx_less(rightedge-dx,popup.offsetWidth))
		posX=ie? iebody.scrollLeft+event.clientX-popup.offsetWidth : window.pageXOffset+e.clientX-popup.offsetWidth;

	if (xx_less(bottomedge-dy,popup.offsetHeight)) {
		posY=ie? iebody.scrollTop+event.clientY-popup.offsetHeight : window.pageYOffset+e.clientY-popup.offsetHeight;
		dy =-dy;
	}
	popup.style.left=posX+dx+"px";
	popup.style.top=posY+dy+"px" ;
}

function xx_less(l,r) { return Math.max(l-r,0) == 0 ; /* l LE r */}
function xx_and(l, r) { return   !(!l || !r);         /*l AND r */}
function xx_supported_client() { 	return (document.all) || (document.getElementById);}
function xx_get_by_id(id) { return document.all? document.all[id]: document.getElementById? $(id) : "" }
Element.childrenWithClassName = function(element, className, findFirst) {
  var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)");
  var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) { 
    return (c.className && c.className.match(classNameRegExp));
  });
  if(!results) results = [];
  return results;
}


// START
/* XMLHttpRequest save as xmlHttp */
var DSXMLHTTP = false;
if (typeof XMLHttpRequest != 'undefined') {
    DSXMLHTTP = new XMLHttpRequest();
}
if (!DSXMLHTTP) {// Internet Explorer 6 und älter
    try {
        DSXMLHTTP  = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        try {
            DSXMLHTTP  = new ActiveXObject("Microsoft.XMLHTTP");
        } catch(e) {
            DSXMLHTTP  = false;
        }
    }
}


// First Called Function
function DSTagRecommender(e,theElement,DSTFID){
	if (!e)
	e = window.event;
	if(e.keyCode==32 || e.keyCode==13){
		load_tag_list(theElement,DSTFID);
	}
}

function load_tag_list(theElement,DSTFID){
	taglist=theElement.value;
	if (taglist.split(' ').length<2){
		$(theElement.id+'_recommendation').innerHTML=''
		recommended_tags=[]
	}
	if (recommended_tags.length<6){
		gettags(theElement,encodeURIComponent(taglist),DSTFID);
	}
}

function gettags(theElement,taglist,DSTFID){
	if (DSXMLHTTP) {
		DSXMLHTTP.abort();
		DSXMLHTTP.theElement=theElement;
		DSXMLHTTP.onreadystatechange = write_to_recommended_tags;
		DSXMLHTTP.open('GET', 'dynasite.cfm?dscmd=tag_tag_tag_connected&dstfid='+DSTFID+'&taglist='+taglist, true);
		DSXMLHTTP.send(null);
	}
}


recommended_tags=[];
function write_to_recommended_tags(){
	var i=0;
	if (DSXMLHTTP.readyState != 4 || DSXMLHTTP.status != 200)
		return;
	response_tags=DSTrim(DSXMLHTTP.responseText);
	new_tags=response_tags.split(' ');
	for (i=0;i<new_tags.length;i++)	{
		if (DSArrayFindPos(recommended_tags,new_tags[i])==-1)
			recommended_tags[recommended_tags.length]=new_tags[i];
	}
	if (new_tags.length)
		write_recommended_tags_list(DSXMLHTTP.theElement);
}

function write_recommended_tags_list(theElement){
	new_tag_list=[];
	curr_tag_list=theElement.value.split(' ');
	for (i=0;i<recommended_tags.length;i++){
		style='style="padding:2px; cursor:pointer; color:#0000FF;';
		if (DSArrayFindPos(curr_tag_list,recommended_tags[i])>-1)
			style+='background-color:#c0c0c0; color:#0000FF;';
		style+='"'
		new_tag_list[new_tag_list.length]='<span '+style+' onclick="add_remove_tag(this,\''+theElement.id+'\')">'+recommended_tags[i]+'</span>';
	}
	$(theElement.id+'_recommendation').innerHTML=new_tag_list.join(' ');
}


function add_remove_tag(this_element,theListElement){
	newtag=DSTrim(this_element.innerHTML);
	theListElement=$(theListElement);
	DSTFID=DSJS.ListGetAt(theListElement.id,DSJS.ListLen(theListElement.id,'_')-1,'_');
	curr_tag_list=theListElement.value.split(' ');
	theListElement.value='';
	new_tags=[];
	found_it=0;
	for (i=0;i<curr_tag_list.length;i++){
		if (DSTrim(curr_tag_list[i])==newtag){
			this_element.style.backgroundColor='#FFFFFF';
			found_it=1;
		}
		else
			new_tags[new_tags.length]=curr_tag_list[i];
	}
	if (found_it==0){
		new_tags[new_tags.length]=newtag;
	}
	theListElement.value=new_tags.join(' ');
	if (found_it==0){
		load_tag_list(theListElement,DSTFID)
	}
	else{
		newtag='';
	}
	if (new_tags.length==0){
		$(theElement+'_recommendation').innerHTML=''
		recommended_tags=[]
	}
	else
		write_recommended_tags_list(theListElement);
}


function DSTFID_Counter(dstfid,value) {
	// alert('DSTFID='+dstfid+' Counter='+value);
	if(dstfid!=0) {
		if(value!=null) {
			if(DSIsDefined('DSTFID_'+dstfid+'_Counter')!=0) {
				thedstfidvalue=eval('DSTFID_'+dstfid+'_Counter');
				eval('DSTFID_'+dstfid+'_Counter='+(thedstfidvalue*1+value));
				// alert(eval('DSTFID_'+dstfid+'_Counter'));
			}
			else {
				eval('DSTFID_'+dstfid+'_Counter='+value*1);
				// alert('JustSet:'+eval('DSTFID_'+dstfid+'_Counter'));
				
				//  alert('DSTFID['+dstfid+']='+eval('DSTFID_'+dstfid+'_Counter'));	
			}
		}
		else {
			thedstfidvalue=0;
			if(DSIsDefined('DSTFID_'+dstfid+'_Counter')!=0)
				thedstfidvalue=eval('DSTFID_'+dstfid+'_Counter');
			return thedstfidvalue;
			//alert('DSTFID:'+dstfid+'='+thedstfidvalue)
			
		}
	}	
}




// window['test'+i]='Hello World';
DSTagGUIList='taggrid,tagobject,tagcloud';

function tag(theElement,theListElement,theCMD,optionlist) {
	var theTagId='';
	var theList='';
	var thePosition='';
	var theID='';
	var theColor='';
	var tagselector='';
	var theObjList='';
	elementbox='';
	dstfid=0;
	resettags=0;

	//alert(theElement.tagName);
	theList=theListElement.value;
	if(optionlist!=null) {
		DSOptionList(optionlist);
	}
	if(theElement.tagName=='SELECT') {
		theTagId=DSJS.ListLast(theElement.options[theElement.selectedIndex].value,'_');
		if($(theElement).readAttribute('lastid')!='') {
			theList=DSJS.ListDeleteAt(theList,DSJS.ListFind(theList,$(theElement).readAttribute('lastid')))
		}
		eval('DSTFID_'+dstfid+'_Counter=0');
		if(theTagId!=0) {
			eval('DSTFID_'+dstfid+'_Counter=1');
			if(DSJS.Len(theList)==0)
				theList=theTagId;
			else	
				theList=DSJS.ListAppend(theList,theTagId);
		}
		$(theElement).writeAttribute('lastid',theTagId);
		theListElement.value=theList;
		// alert($(theElement).readAttribute('lastid'));
		return;
	}
	else {
		theTagId=DSJS.ListLast(theElement.id,'_');
	}
	thePosition=DSJS.ListFind(theList,theTagId);
	theID=theElement.id;
	theColor='';
	tagselector='[dsttid="'+theCMD+'_'+theTagId+'"]';
/*	if(optionlist!=null) {
		DSOptionList(optionlist);
	}*/
	if(elementbox=='') {
		if($('dspopupbody')) {
			elementbox='dspopupbody';
		}
		else
			elementbox='dsbody';
	}
	if(DSJS.Find('|',elementbox)) {
		for(i=1;i<=DSJS.ListLen(elementbox,'|');i++) {
			theObjList=theObjList+$(DSJS.ListGetAt(elementbox,i,'|').select(tagselector));	
		}
	}
	else
		theObjList=$(elementbox).select(tagselector);
	if(thePosition) {
		theList=DSJS.ListDeleteAt(theList,thePosition);
		DSTFID_Counter(dstfid,-1)			
	}
	else {
		DSTFID_Counter(dstfid,1)	
		if(DSJS.Len(theList)==0)
			theList=theTagId;
		else	
			theList=DSJS.ListAppend(theList,theTagId);
		theColor='#b10027';		
	}
	 // alert(theObjList+',Elemenbox: '+elementbox);
	if(resettags!=0) {
		if(resettags==1 || resettags=='date') {
			if($(theCMD+'_datefrom_view')) {
				if(!$(theCMD+'_datefrom_view').dsselectcalendar)
					$(theCMD+'_datefrom_view').onfocus();
				var dscal=$(theCMD+'_datefrom_view').dsselectcalendar; 
				if(dscal) {
						dscal.from.date=Date.parseDate('01.01.1901','%d.%m.%Y');
						dscal.dateChanged('from');
						dscal.to.date=Date.parseDate('01.01.1901','%d.%m.%Y');
						dscal.dateChanged('to');
				}		
			}
		}
		if(DSIsDefined(elementbox)==0) {
			if($('dspopupbody'))
				elementbox='dspopupbody';
			else
				elementbox='dsbody';
		}
		// alert(theList);
		theList=DSJS.ListAppend(theList,$(theCMD+'_dsttidlist').value);
		theListArray=DSJS.ListToArray(theList,',');
		if($(theCMD+'_dsttidlist'))
			$(theCMD+'_dsttidlist').value='';
		if(resettags==1) {
			if($(theCMD+'_searchphrase'))
			$(theCMD+'_searchphrase').value='';
		}
		if(resettags==1) {
			if($(theCMD+'_andor_or'))
				$(theCMD+'_andor_or').checked=true;
		}
		theListElement.value='';
		selects=$$('select[id*="_select_"]');
		selects.each(function(theselect) { 
			theselect.selectedIndex=0;
		});
		theListArray.each(function(theitem2) { 
			 // alert(theitem2);
			theColor='';
			tagselector='[dsttid="'+theCMD+'_'+theitem2+'"]';
			theObjList=$(elementbox).select(tagselector);
			
			theObjList.each(function(theitem) { 
				// alert('elementbox: '+elementbox+' tagselector: '+tagselector+' tagname:'+$(theitem).tagName);
				// Set Status to unselected/inactive
			
				if(theColor=='') {
					// alert($(theitem).tagName);
					if($(theitem).tagName=='A') {
						$(theitem).style.color='';
					}
					else if($(theitem).tagName=='INPUT') {
						// alert($(theitem).checked);
						$(theitem).checked=false;
					}
					else if($(theitem).tagName=='SELECT') {
						// alert($(theitem).checked);
						$(theitem).selectedIndex=0;
					}
					else {
						$(theitem).removeClassName('dspanel_shaded_blue');
						$(theitem).addClassName('dspanel_shaded_gray');
					}
				}
			}); 
		});

	}
	else {
		theObjList.each(function(theitem) { 
			// Set Status to unselected/inactive
			if(thePosition) {
				if($(theitem).tagName=='A') {
					$(theitem).style.color='';
				}
				else if($(theitem).tagName=='INPUT') {
					$(theitem).checked=true;
				}	
				else {
					$(theitem).removeClassName('dspanel_shaded_blue');
					$(theitem).addClassName('dspanel_shaded_gray');
				}
			}
			// Set Status to selected/active
			else {
				if($(theitem).tagName=='A') {
					$(theitem).style.color='#b10027';;
			
				}
				else if($(theitem).tagName=='INPUT') {
					$(theitem).checked=false;
				}				
				else {
					$(theitem).removeClassName('dspanel_shaded_gray');
					$(theitem).addClassName('dspanel_shaded_blue');
				}
			}
		}); 
		theListElement.value=theList;
	}

// else dsloader('dynasite.cfm?dscmd=contact_contact_contact_update&'+$('contactsorting').value+'&dstagaction='+DSJS.ListGetAt(theElement.id,2,'_')+'&tagidlist='+$('dscontactlist').value+'&dstagnamelist='+$('google_taglist').value,'dsloader');	
}



function DSCloudSelector(event,theElement,command,optionlist) {
	var id=DSJS.ListLast(theElement.id,'_');
	if($(command+'_dstagobjectidlist')!=null)
		var listelement=$(command+'_dstagobjectidlist');
	if(theElement.dsttidlist!=null){
		var selectedlist_obj=theElement.dsttidlist;
		var selectedlistlength=DSJS.ListLen(selectedlist_obj);
		var selectedlist_obj_all=$(command+'_dsttidlist_selectedobjects').value;
	}
	
	if (optionlist!=null)
		DSOptionList(optionlist)
	if(!event.altKey  && DSJS.LCase(theElement.nodeName)!='input')
		return;
		
	if($(command+'_dstagobjectidlist')!=null){		
		theList=listelement.value;
		thePosition=DSJS.ListFind(theList,id);
		if(thePosition) {
			theList=DSJS.ListDeleteAt(theList,thePosition);
			if(theElement.nodeName=='div' || theElement.nodeName=='DIV')
				theElement.style.borderColor='#d2cdba';
			else if(theElement.nodeName=='tr' || theElement.nodeName=='TR')
				theElement.className=theElement.classholder;
			else if(theElement.nodeName=='inputxxx' || theElement.nodeName=='INPUTxxx')
				theElement.checked=false;
		}
		else {
			if(DSJS.Len(theList)==0)
				theList=id;
			else		
				theList=DSJS.ListAppend(theList,id);
			if(theElement.nodeName=='div' || theElement.nodeName=='DIV')
				theElement.style.borderColor='#003366';
			else if(theElement.nodeName=='tr' || theElement.nodeName=='TR')
				theElement.className='dslist_selected';
			else if(theElement.nodeName=='inputxxx' || theElement.nodeName=='INPUTxxx')
				theElement.checked=true;
		}
	}
	if(theElement.dsttidlist!=null) {
		for(i=1;i<=selectedlistlength;i++) {
			theSelectedPosition=DSJS.ListFind(selectedlist_obj_all,DSJS.ListGetAt(selectedlist_obj,i));
			// alert(theSelectedPosition);
			if(thePosition) {
				if(theSelectedPosition)
					selectedlist_obj_all=DSJS.ListDeleteAt(selectedlist_obj_all,theSelectedPosition);
			}
			else {
				selectedlist_obj_all=DSJS.ListAppend(selectedlist_obj_all,DSJS.ListGetAt(selectedlist_obj,i));
			}
		}
	}


	
	
	// alert(theList);
	
	if($(command+'_tagactionbutton')) {

		if(DSJS.Len(theList)!=0) {
			$(command+'_tagactionbutton').show();
			$(command+'_tagfilterbutton').hide();
		}
		else {
			$(command+'_tagactionbutton').hide();
			$(command+'_tagfilterbutton').show();
		}
	}
	if($(command+'_dstagobjectidlist')!=null && ($(command+'_actionselect') || $(command+'_tagupdate') || $(command+'_tagdelete') || $(command+'_tagaction'))) {
		if(DSJS.Len(theList)!=0) {
			$(command+'_actionselect').disabled=false;
			if($(command+'_tagupdate'))
				$(command+'_tagupdate').disabled=false;
			if($(command+'_tagdelete'))
				$(command+'_tagdelete').disabled=false;
		}
		else {
			$(command+'_actionselect').disabled=true;
			if($(command+'_tagupdate'))
				$(command+'_tagupdate').disabled=true;
			if($(command+'_tagdelete'))
				$(command+'_tagdelete').disabled=true;			
		} 
	}
	if(theElement.dsttidlist)
		$(command+'_dsttidlist_selectedobjects').value=selectedlist_obj_all;
	if($(command+'_dstagobjectidlist')!=null)
		listelement.value=theList;
}
DSTypeAHead=new Object();

function DSInputNameCHK(e,this_element){
	if(e.keyCode==Event.KEY_ESC)
		return;
	if (DSTypeAHead.name_chk==0)
		return;
	if (!e)
		e = window.event;
	var i=0;
	var help_list=[];
	var help_email_list=[];
	var strg='';
	var curr_name=this_element.value;
	if (DSTypeAHead.type=='email')
		curr_name=curr_name.toLowerCase();
	var name_length=curr_name.length;
	if (e.keyCode==38 || e.keyCode==40){
		if ($('DSNamesToSelect') && $('DSInputSelectorContainer').style.display=='block'){
			$('DSNamesToSelect').focus();
			$('DSNamesToSelect').selectedIndex=1;
		}
	}
	else if (e.keyCode==13){
		if ($('DSNamesToSelect') && $('DSInputSelectorContainer').style.display=='block'){
			this_select=$('DSNamesToSelect');
			DSWriteReceiver(this_select.options[this_select.selectedIndex].value);
			$('DSNameToCheck').focus();
			$('DSInputSelectorContainer').style.display='none';
		}
		else if (DSTypeAHead.allow_freetext){
			if (DSTypeAHead.type!='email' || email_chk(curr_name)==-1){
				var bool=true;
				if(DSArrayFind(DSTypeAHead.selected_email_list,curr_name)){
					bool=false;
				}
				if(bool){
					DSTypeAHead.selected_id_list[DSTypeAHead.selected_id_list.length]=curr_name;
					DSTypeAHead.selected_name_list[DSTypeAHead.selected_name_list.length]=curr_name;
					DSTypeAHead.selected_email_list[DSTypeAHead.selected_email_list.length]=curr_name;
					DSTypeAHead.selected_receiver_list[DSTypeAHead.selected_receiver_list.length]=DSTypeAHead.current_selected_receiver;
					DSTypeAHead.selected_position_list[DSTypeAHead.selected_position_list.length]=curr_name;
					curr_name='';
					name_length=curr_name.length;
					$('DSNameToCheck').value='';
					$('DSNameToCheck').focus();
					DSWriteSelectedToForm();
				}else
					$('DSNameToCheck').value='';
					$('DSNameToCheck').focus();
			}
		}
	}
	else if (name_length){
		if(!DSTypeAHead.allowAjax){
			DSTypeAHead.name_chk=0;
			if (DSTypeAHead.total_name_list.length==0){
					DSTypeAHead.total_name_list=$('DSTypeAHead_Names').innerHTML.split('|');
					DSTypeAHead.total_id_list=$('DSTypeAHead_IDs').innerHTML.split(',');
			}
			if (name_length<=1)
				DSTypeAHead.current_name_list=DSTypeAHead.total_name_list;
			
			strg='<select id="DSNamesToSelect" class="ds_select" style="position:absolute;width:400px;" size="8" onkeydown="DSSelectName(event,this)" ondblclick="DSSelectNamebyClick(this.options[this.selectedIndex].value);">';
			for (i=0;i<DSTypeAHead.current_name_list.length;i++){
				if (DSLeft(DSTypeAHead.current_name_list[i],name_length).toLowerCase()==curr_name){
					if (!DSArrayFind(DSTypeAHead.selected_id_list,DSTypeAHead.total_id_list[i])){
						if (help_list.length/2==DSInt(help_list.length/2))
							bgcolor='#ffffff';
						else
							bgcolor='#ffffff';
						strg+='<option style="background-color:'+bgcolor+'" value="'+i+'"'
						if (help_list.length==0)
							strg+=' selected';
						strg+='>';
						strg+=DSTypeAHead.current_name_list[i]+'</option>';
						help_list[help_list.length]=DSTypeAHead.current_name_list[i];
					}
				}
			}
			DSTypeAHead.current_name_list=help_list;
			strg+='</select>';
			if (help_list.length==0){
				strg='';
				$('DSInputSelectorContainer').style.display='none'
			}
			else{
				$('DSInputSelectorContainer').innerHTML=strg;
				$('DSInputSelectorContainer').style.display='block';
			}
			// $('test').innerHTML=e.keyCode+'<br>'+this_element.value+'<br>'+name_length;
			DSTypeAHead.name_chk=1;
		}else{
			if(!(name_length>1 && DSTypeAHead.current_name_list.length==0) || (e.keyCode==8 || e.keyCode==46)){
				var chk=new Ajax.Request(DSTypeAHead.ajaxUrl, {
					  method: 'post',
					  parameters: 'name='+curr_name+'&switchmode='+DSTypeAHead.switchmode+'&showemail='+ DSTypeAHead.showEmail+'&allowtags='+DSTypeAHead.allowTags+'&disallowtags='+DSTypeAHead.disallowTags,
					  onSuccess: function(transport){
						var result=eval(transport.responseText);
						DSTypeAHead.total_name_list=result[0];
						DSTypeAHead.total_id_list=result[1];
						DSTypeAHead.total_email_list=result[2];
						DSTypeAHead.name_chk=0;
						var tmpcnl=DSTypeAHead.current_name_list;
						var tmpcel=DSTypeAHead.current_email_list;
						DSTypeAHead.current_name_list=DSTypeAHead.total_name_list;
						DSTypeAHead.current_email_list=DSTypeAHead.total_email_list;
						if(DSTypeAHead.total_name_list.length==0){
							DSTypeAHead.total_name_list=tmpcnl;
							DSTypeAHead.total_email_list=tmpcel;
						}
						strg='<select id="DSNamesToSelect" class="ds_select" style="position:absolute;width:400px;" size="8"  onkeydown="DSSelectName(event,this)" ondblclick="DSSelectNamebyClick(this.options[this.selectedIndex].value);">';
						for (i=0;i<DSTypeAHead.current_name_list.length;i++){
							if (!DSArrayFind(DSTypeAHead.selected_email_list,DSTypeAHead.total_email_list[i])){
								if (help_list.length/2==DSInt(help_list.length/2))
									bgcolor='#ffffff';
								else
									bgcolor='#ffffff';
								strg+='<option style="background-color:'+bgcolor+'" value="'+i+'"'
								if (help_list.length==0)
									strg+=' selected';
								strg+='>';
								strg+=DSTypeAHead.current_name_list[i];
								if(DSTypeAHead.current_email_list[i]!="")
									strg+=' ('+DSTypeAHead.current_email_list[i]+')';
								strg+='</option>';
								help_list[help_list.length]=DSTypeAHead.current_name_list[i];
								help_email_list[help_email_list.length]=DSTypeAHead.current_email_list[i];
							}
						}
						DSTypeAHead.current_name_list=help_list;
						DSTypeAHead.current_email_list=help_email_list;
						strg+='</select>';
						if (help_list.length==0){
							strg='';
							$('DSInputSelectorContainer').style.display='none'
						}
						else{
							$('DSInputSelectorContainer').innerHTML=strg;
							$('DSInputSelectorContainer').style.display='block';
						}
						// $('test').innerHTML=e.keyCode+'<br>'+this_element.value+'<br>'+name_length;
						DSTypeAHead.name_chk=1;
					  },
					  onFailure: function(e){
						DSTypeAHead.total_name_list=[];
						DSTypeAHead.total_id_list=[];
					  },
					  onException: function(e){
						DSTypeAHead.total_name_list=[];
						DSTypeAHead.total_id_list=[];
					  }
				});
			}else
				$('DSInputSelectorContainer').style.display='none'
		}
	}
	else{
		$('DSInputSelectorContainer').style.display='none';
	}	
}


function DSFieldLenCounter(fieldObj,labelObj) {
	thelen=DSJS.Len(fieldObj.value);
	thelist=labelObj.innerHTML;
	thelist=DSJS.ListSetAt(thelist,1,thelen,'/');
	labelObj.innerHTML=thelist;
}

function DSSelectName(e,this_element){
	if (e.keyCode==38 || e.keyCode==40)
		return;
		
	if (!e)
		e = window.event;
	if (e.keyCode==13){
		DSWriteReceiver(this_element.options[this_element.selectedIndex].value);
	}
	else if (e.keyCode==27){
		$('DSNameToCheck').focus();
	}
	else{
		$('DSNameToCheck').value+=String.fromCharCode(e.keyCode).toLowerCase();
		$('DSNameToCheck').focus();
		DSInputNameCHK(e,$('DSNameToCheck'))
	}
	$('DSInputSelectorContainer').style.display='none';
}

function DSSelectNamebyClick(this_pos){
	DSWriteReceiver(this_pos);
	$('DSInputSelectorContainer').style.display='none';
}

function DSSelectNameRemove(this_id,xobject){
	// 2009-01-02 [AP] Dieses Funktionswunder ist von Tim. 
	// Aufruf der Funktion auch in der DSXObject.Get() _dsscript_admin.js 
	var i=0;
	var this_pos=-1;
	if (xobject==null)
		xobject=1;
	if (xobject==1) {
		if ($('SelectedXObject') && $('SelectedXObject').value.isJSON()==1) {
			DSXObject.JSON.BuildArray();
			DSXObject.JSON.JSONArray.each(function(dati) {	
				if(dati.Email==this_id && (dati.Emaillinked==null || dati.Emaillinked==1)) {
					$$('[objectvalue="'+dati.LinkIDType+':'+dati.LinkID+'"]').each(function(x) {
						DSXObject.Get(x,'nolink:1');
					});
				}
			});
		}
	}
	this_pos=DSArrayFindPos(DSTypeAHead.selected_id_list,this_id);

	if (this_pos>-1){
		DSTypeAHead.selected_id_list=DSArrayDeleteElement(DSTypeAHead.selected_id_list,this_pos);
		DSTypeAHead.selected_name_list=DSArrayDeleteElement(DSTypeAHead.selected_name_list,this_pos);
		DSTypeAHead.selected_email_list=DSArrayDeleteElement(DSTypeAHead.selected_email_list,this_pos);
		DSTypeAHead.selected_receiver_list=DSArrayDeleteElement(DSTypeAHead.selected_receiver_list,this_pos);
		DSTypeAHead.selected_position_list=DSArrayDeleteElement(DSTypeAHead.selected_position_list,this_pos);
	}
	DSWriteSelectedToForm();
	
}

function DSSelectReceiver(receiver){
	if (DSTypeAHead.type=='email'){
		if (DSTypeAHead.current_selected_receiver!='' && $('DS_'+DSTypeAHead.current_selected_receiver+'_select'))
			$('DS_'+DSTypeAHead.current_selected_receiver+'_select').style.color='black';
		
		$('DS_'+receiver+'_select').style.color='red';
	}
	DSTypeAHead.current_selected_receiver=receiver;
	$('DSNameToCheck').focus();
}

function DSWriteReceiver(this_pos){
	if (DSTypeAHead.type=='search'){
		DSTypeAHead.selected_name_list[0]=DSTypeAHead.total_name_list[this_pos];
		$('DSNameToCheck').value='';
		DSWriteSelectedToForm();	
	}
	else{
		var i=0;
		var id=DSTypeAHead.total_id_list[this_pos];
		var bool=true;
		if (DSArrayFind(DSTypeAHead.selected_email_list,DSTypeAHead.total_email_list[this_pos])){
			bool=false;
		}else if(DSArrayFind(DSTypeAHead.selected_name_list,DSTypeAHead.total_name_list[this_pos]) && DSTypeAHead.total_email_list[this_pos]==""){
			bool=false;
		}
		if (bool){
			DSTypeAHead.selected_id_list[DSTypeAHead.selected_id_list.length]=id;
			DSTypeAHead.selected_name_list[DSTypeAHead.selected_name_list.length]=DSTypeAHead.total_name_list[this_pos];
			DSTypeAHead.selected_email_list[DSTypeAHead.selected_email_list.length]=DSTypeAHead.total_email_list[this_pos];
			DSTypeAHead.selected_receiver_list[DSTypeAHead.selected_receiver_list.length]=DSTypeAHead.current_selected_receiver;
			DSTypeAHead.selected_position_list[DSTypeAHead.selected_position_list.length]=this_pos;
			$('DSNameToCheck').value='';
			if (DSTypeAHead.type!='search')
				$('DSNameToCheck').focus();
			DSWriteSelectedToForm();
		}
	}
}

function DSWriteSelectedToForm(){
	if (DSTypeAHead.type=='search'){
		$('DSNameToCheck').value=DSTypeAHead.selected_name_list.join('|');
	}
	else{
		var i=0;	
		var receiver_list=[];
		var this_name='';
		if (DSTypeAHead.type=='email'){
			$('DS_to_list').innerHTML='To: ';
			$('DS_cc_list').innerHTML='CC: ';
			$('DS_bcc_list').innerHTML='BCC: ';
			$('DS_to_list').style.display='none';
			$('DS_cc_list').style.display='none';
			$('DS_bcc_list').style.display='none';
		}
		else if (DSTypeAHead.type=='collect'){
			$('DS_collect_list').innerHTML='';
		}
		for (i=0;i<DSTypeAHead.selected_id_list.length;i++){
			delimiter=',';
			if (!DSArrayFind(receiver_list,DSTypeAHead.selected_receiver_list[i])){
				receiver_list[receiver_list.length]=DSTypeAHead.selected_receiver_list[i];
				delimiter='';
				$('DS_'+DSTypeAHead.selected_receiver_list[i]+'_list').style.display='block';
			}
	
			this_name=DSTypeAHead.selected_name_list[i];
			strg=delimiter+'<span style="padding:2px; cursor:pointer" onclick="DSSelectNameRemove(\''+DSTypeAHead.selected_id_list[i]+'\');">'; 
			strg+=this_name;
			if(DSTypeAHead.selected_email_list[i]!='')
				strg+=" ("+DSTypeAHead.selected_email_list[i]+")";
			strg+='</span>';
			$('DS_'+DSTypeAHead.selected_receiver_list[i]+'_list').innerHTML+=strg;
		}
	
		$('DS_Selected_ID').value=DSTypeAHead.selected_id_list.join(',');
		$('DS_Selected_Receiver').value=DSTypeAHead.selected_receiver_list.join(',');
		$('DS_Selected_Name').value=DSTypeAHead.selected_name_list.join('|');
		$('DS_Selected_Email').value=DSTypeAHead.selected_email_list.join(',');
		DSPopUpResize();
	}
}

function DSDefaultSelect(id_list){
	var i=0;
	if (id_list=='')
		id_list=[];
	else
		id_list=id_list.split(',');
	if (DSTypeAHead.total_name_list.length==0){
		if(!DSTypeAHead.allowAjax){
			DSTypeAHead.total_name_list=$('DSTypeAHead_Names').innerHTML.split('|');
			DSTypeAHead.total_id_list=$('DSTypeAHead_IDs').innerHTML.split(',');
		}
	}
	for (i=0;i<id_list.length;i++){
		this_pos=DSArrayFindPos(DSTypeAHead.total_id_list,id_list[i]);
		if (this_pos>=0){
			if (!DSArrayFind(DSTypeAHead.selected_id_list,id_list[i])){
				DSTypeAHead.selected_id_list[DSTypeAHead.selected_id_list.length]=id_list[i];
				DSTypeAHead.selected_name_list[DSTypeAHead.selected_name_list.length]=DSTypeAHead.total_name_list[this_pos];
				DSTypeAHead.selected_email_list[DSTypeAHead.selected_email_list.length]=DSTypeAHead.total_email_list[this_pos];
				DSTypeAHead.selected_receiver_list[DSTypeAHead.selected_receiver_list.length]=DSTypeAHead.current_selected_receiver;
				DSTypeAHead.selected_position_list[DSTypeAHead.selected_position_list.length]=this_pos;
			}
		}
	}
	DSWriteSelectedToForm();
}

function DSTypeAHead_init(type,dsselectlist,allow_freetext,allowAjax, ajaxUrl,switchmode,showEmail,allowTags,disallowTags){
	DSTypeAHead.type=type;
	DSTypeAHead.allowAjax=allowAjax? allowAjax:false;
	DSTypeAHead.ajaxUrl=ajaxUrl? ajaxUrl:null;
	DSTypeAHead.switchmode=switchmode? switchmode:null;
	if (isNaN(allow_freetext)==true)
		allow_freetext=0;
	DSTypeAHead.allow_freetext=allow_freetext;
	DSTypeAHead.showEmail=showEmail? showEmail:false;
	DSTypeAHead.allowTags=allowTags? allowTags:false;
	DSTypeAHead.disallowTags=disallowTags? disallowTags:false;
	DSTypeAHead.total_name_list=[];
	DSTypeAHead.total_email_list=[];
	DSTypeAHead.total_id_list=[];
	DSTypeAHead.current_name_list=[];
	DSTypeAHead.current_email_list=[];
	
	DSTypeAHead.selected_name_list=[];
	DSTypeAHead.selected_email_list=[];
	DSTypeAHead.selected_id_list=[];
	DSTypeAHead.selected_receiver_list=[];
	DSTypeAHead.selected_position_list=[];
	
	DSTypeAHead.current_selected_receiver='to';
	DSTypeAHead.name_chk=1;
	document.observe('click',function(e){
		if($('DSNamesToSelect') && $('DSNamesToSelect').visible()){
			if(!$(Event.element(e)).up('#DSNamesToSelect'))
				$('DSNamesToSelect').hide();
		}
	});
	document.observe('keydown',function(e){
		if(e.keyCode==Event.KEY_ESC){
			if($('DSNamesToSelect') && $('DSNamesToSelect').visible()){
					Event.stop(e);
					$('DSNamesToSelect').hide();
			}
		}
	});
	if (dsselectlist!=''){
		if(!allowAjax){
			var rl;
			var receiver_elements=dsselectlist.split('|');
			var receiver;
			var receiver_list;
			for (rl=0;rl<receiver_elements.length;rl++){
				receiver=receiver_elements[rl].split(':')[0];
				receiver_list=receiver_elements[rl].split(':')[1];
				DSSelectReceiver(receiver);
				DSDefaultSelect(receiver_list);
			}
		}else{
			dsselectlist=eval(dsselectlist);
			DSTypeAHead.selected_id_list=dsselectlist[0];
			DSTypeAHead.selected_name_list=dsselectlist[1];
			DSTypeAHead.selected_email_list=dsselectlist[2];
			DSTypeAHead.selected_receiver_list=dsselectlist[3];
			DSSelectReceiver("to");
			DSWriteSelectedToForm();
		}
	}else
		DSSelectReceiver("to");
}
// Popup Position in dsrt_tagbuttonslite() datei dsscript_designmode.js
function dspopuppos(e,em,domtop,domleft,ietop,ieleft){
	if(typeof window.pageYOffset != "undefined")
		var scrollheight = window.pageYOffset;
	else if(typeof document.documentElement.scrollTop != "undefined")
		scrollheight = document.body.scrollTop;
	else
		var scrollheight = document.body.scrollTop;
	if(scrollheight==0)
		var scrollheight = document.documentElement.scrollTop;
	document.getElementById(em).style.top=ns6? e.clientY+domtop+scrollheight+'px' : event.clientY+ietop+scrollheight+'px';
	document.getElementById(em).style.left=ns6? e.clientX+domleft+'px' : event.clientX+ieleft+'px';
}

// Start Richttext Editor
function dsrt_tagbuttonslite(){
	outputtxt='';
	outputtxt+='<a href="javascript:dsrt_exec(\'cut\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/cut.gif" alt="Ausschneiden" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'copy\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/copy.gif" alt="Kopieren" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'paste\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/paste.gif" alt="Einf\374gen" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'undo\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/undo.gif" alt="R\374ckg\344ngig" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'redo\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/redo.gif" alt="Wiederherstellen" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'bold\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/bold.gif" alt="Fett" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'italic\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/italic.gif" alt="Kursiv" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'underline\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/undersco.gif" alt="Unterstrichen" /></a>';
	outputtxt+='<a href="javascript:dsfx_object(\'forecolor\',\'backcolor\',\'displayshowhide\', 5);" onclick="dspopuppos(event,\'forecolor\',0,0,10,5);"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/fontcolo.gif" alt="Schriftfarbe \344ndern" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifyleft\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/left.gif" alt="Linksb\374ndig" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifycenter\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/center.gif" alt="Zentriert" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifyright\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/right.gif" alt="Rechtsb\374ndig" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifyfull\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/justify.gif" alt="Blocksatz" /></a>';
	document.write(outputtxt);
	outputtxt='';
}
// Start Richttext Editor
function dsrt_tagbuttons(counter){
	outputtxt='';
	outputtxt+='<a href="javascript:dsrt_exec(\'cut\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/cut.gif" alt="Ausschneiden" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'copy\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/copy.gif" alt="Kopieren" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'paste\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/paste.gif" alt="Einf\374gen" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'undo\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/undo.gif" alt="R\374ckg\344ngig" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'redo\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/redo.gif" alt="Wiederherstellen" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'bold\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/bold.gif" alt="Fett" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'italic\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/italic.gif" alt="Kursiv" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'underline\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/undersco.gif" alt="Unterstrichen" /></a>';
	outputtxt+='<a href="javascript:dsfx_object(\'forecolor\',\'backcolor\',\'displayshowhide\', 5);" onclick="dspopuppos(event,\'forecolor\',0,0,10,5);"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/fontcolo.gif" alt="Schriftfarbe \344ndern" /></a>';
	outputtxt+='<a href="javascript:dsfx_object(\'backcolor\',\'forecolor\',\'displayshowhide\', 5);" onclick="dspopuppos(event,\'backcolor\',0,0,10,5);"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/bgcolor.gif" alt="Hintergrundfarbe \344ndern" /></a>';	
	outputtxt+='<a href="javascript:dsrt_exec(\'justifyleft\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/left.gif" alt="Linksb\374ndig" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifycenter\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/center.gif" alt="Zentriert" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifyright\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/right.gif" alt="Rechtsb\374ndig" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'justifyfull\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/justify.gif" alt="Blocksatz" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'outdent\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/indent_smaller.gif" alt="Einzug verkleinern" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'indent\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/indent_bigger.gif" alt="Einzug vergr\366\337ern" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'insertunorderedlist\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/ul.gif" alt="Aufz\344hlung" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'insertorderedlist\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/ol.gif" alt="Nummerierung" /></a>';
	outputtxt+='<a href="javascript:dsrt_showtagattributes(\'hyperlink\','+counter+');dsfx_object(\'\',\'\',\'dsloaderheight\');"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/btnhy.gif" alt="Hyperlink" /></a>';
	outputtxt+='<a href="javascript:dsrt_exec(\'unlink\')"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/unlink.gif" alt="Unlink" /></a>';
	outputtxt+='<a href="javascript:dsrt_showtagattributes(\'image\','+counter+');dsfx_object(\'\',\'\',\'dsloaderheight\');"><img class="dsrt_btn" src="'+DSGlobalPath+'image/htmlcmds/image.gif" alt="Image" /></a>';
	document.write(outputtxt);
	outputtxt='';
}

function dsrt_showtagattributes(tag,counter){
	if(tag=='fontfamily'){
	tag_form='<tr><td COLSPAN=3 CLASS="dsspacehead">Hyperlink</TD></TR>';
	tag_form+='<tr><td>Link URL - <span id="dsdir_TA_Href" class="dsfd_dir" onclick="dslgs_open(\''+dsrt_formname+'\',\'TA_Href\',\'site_site_site_view\');">&lt;Directory&gt;</span></TD></TR>';
	tag_form+='<tr><td><INPUT CLASS="ds_text" TYPE="Text" ID="TA_Href" NAME="TA_Href" VALUE="http://" STYLE="width:320px"></TD></TR>';
	tag_form+='<tr height=40><td ALIGN="RIGHT"><INPUT TYPE="BUTTON" CLASS="submit" ONCLICK="dsrt_hidetagattributes('+counter+')" VALUE="Abbrechen"> <INPUT CLASS="submit" TYPE=BUTTON VALUE="Einf\374gen" ONCLICK="inserttagattributes(4)"></TD><TD COLSPAN=2></TD></TR>';
	}
	else if(tag=='fontcolor'){
	tag_form='<TR><td colspan="3" class="dsspacehead">Hyperlink</TD></TR>';
	tag_form+='<TR><td>Link URL - <span id="dsdir_TA_Href" class="dsfd_dir" onclick="dslgs_open(\''+dsrt_formname+'\',\'TA_Href\',\'site_site_site_view\');">&lt;Directory&gt;</span></TD><TD>Text</TD><TD>Target</TD></TR>';
	tag_form+='<TR><td><INPUT CLASS="ds_text" TYPE="Text" ID="TA_Href" NAME="TA_Href" VALUE="http://" STYLE="width:320px"></TD><TD><INPUT CLASS="ds_text" TYPE="Text" STYLE="width:150px" NAME="TA_Text" VALUE=""></TD><TD><SELECT CLASS=textfree NAME="TA_Target"><OPTION VALUE="_self">_self<OPTION Value="_blank">_blank<OPTION VALUE="main">Artikelfenster</SELECT></TD></TR>';
	tag_form+='<TR HEIGHT=40><td ALIGN="RIGHT"><INPUT TYPE="BUTTON" CLASS="submit" ONCLICK="dsrt_hidetagattributes('+counter+')" VALUE="Abbrechen"> <INPUT CLASS="submit" TYPE=BUTTON VALUE="Einf\374gen" ONCLICK="inserttagattributes(4)"></TD><TD COLSPAN=2></TD></TR>';
	}
	else if(tag=='hyperlink'){
	tag_form='<tr><td colspan="3" class="dsspacehead">Hyperlink</td></tr>';
	tag_form+='<tr><td>Link URL - <span id="dsdir_dsrt_hyperlink" class="dsfd_dir" onclick="javascript:dslgs_open(\''+dsrt_formname+'\',\'dsrt_hyperlink\',\'site_site_site_view\');">&lt;Directory&gt;</span></TD></TR>';
	tag_form+='<tr><td><input class="ds_text" type="text" id="dsrt_hyperlink" name="dsrt_hyperlink"  value="http://" style="width:320px"></TD></TR>';
	tag_form+='<tr HEIGHT=40><TD ALIGN="RIGHT"><INPUT TYPE="BUTTON" CLASS="submit" ONCLICK="dsrt_hidetagattributes('+counter+')" VALUE="Abbrechen"> <INPUT CLASS="submit" TYPE="button" VALUE="Einf\374gen" ONCLICK="dsrt_inserttagattributes(\'hyperlink\','+counter+')"></TD><TD COLSPAN=2></TD></TR>';
	}
	else if(tag=='image'){
	tag_form='<TR><td colspan="4" class="dsspacehead">Image</TD></TR>';
	tag_form+='<TR><td colspan="2">Bild URL - <span id="dsdir_ta_src" class="dsfd_dir" onclick="javascript:dslgs_open(\''+dsrt_formname+'\',\'ta_src\',\'asset_asset_asset_view\');">&lt;Directory&gt;</span></TD><TD COLSPAN=2>ALT-Text</TD></TR>';
	tag_form+='<TR><td colspan="2"><INPUT CLASS="ds_text" TYPE="Text" NAME="ta_src" id="ta_src" VALUE="http://" STYLE="width:320px"></TD><TD COLSPAN=2><INPUT CLASS="ds_text" TYPE="Text" NAME="ta_alt" VALUE=""></TD></TR>';
	tag_form+='<TR><td>Align</td><td>Border</TD><TD>H-SPACE</TD><TD>V-SPACE</TD></TR>';
	tag_form+='<TR><td><SELECT CLASS="ds_select" NAME="ta_align" id="ta_align" STYLE="width:155px"><OPTION VALUE="none">None<OPTION Value="left">Left<OPTION VALUE="center">Center<OPTION VALUE="right">Right</SELECT></TD><TD><SELECT CLASS="ds_select" NAME="ta_border" id="ta_border" STYLE="width:155px"><OPTION VALUE=0>0 Pixel<OPTION VALUE=1>1 Pixel<OPTION VALUE=2>2 Pixel<OPTION VALUE=3>3 Pixel<OPTION VALUE=4>4 Pixel<OPTION VALUE=5>5 Pixel</SELECT></TD><TD><INPUT CLASS="textfree" STYLE="width:80px" TYPE="Text" NAME="ta_hspace" VALUE="0" SIZE="2"> Pixel</TD><TD><INPUT CLASS="textfree" STYLE="width:80px" TYPE="Text" NAME="ta_vspace" VALUE="0" SIZE="2"> Pixel</TD></TR>';
	tag_form+='<TR HEIGHT=40><TD COLSPAN=2 ALIGN="RIGHT"><INPUT TYPE="BUTTON" CLASS="submit" ONCLICK="dsrt_hidetagattributes('+counter+')" VALUE="Abbrechen"> <INPUT CLASS="submit" TYPE=BUTTON VALUE="Einf\374gen" ONCLICK="dsrt_inserttagattributes(\'image\','+counter+')"></TD><TD></TD></TR>';
	}
	document.getElementById("tagattributesview"+counter).innerHTML='<TABLE CELLPADDING=3 CELLSPACING=1 BORDER=0 ALIGN=CENTER WIDTH=100%>'+tag_form+'</TABLE>';
}

function dsrt_inserttagattributes(tag,counter){
	if (tag=='image'){
		if (document.getElementById("ta_align").selectedIndex!=0)
			align=' align="'+document.getElementById("ta_align").options[document.getElementById("ta_align").selectedIndex].value+'"'
		else
			align=''
		tvs='<img src="'+document.getElementById("ta_src").value+'" style="padding:'+document.getElementById("ta_vspace").value+'px '+document.getElementById("ta_hspace").value+'px '+document.getElementById("ta_vspace").value+'px '+document.getElementById("ta_hspace").value+'px;border:'+document.getElementById("ta_border").options[document.getElementById("ta_border").selectedIndex].value+'px" alt="'+document.getElementById("ta_alt").value+'"'+align+' />'
		dsrt_pastehtml(tvs);
	}
	else if(tag=='hyperlink'){
		dsrt_exec("createlink",document.getElementById("dsrt_hyperlink").value);
	}
	dsrt_hidetagattributes(counter);
}

function dsrt_viewchange(field) {
	if(eval('document.getElementById("div_'+field+'").style.display=="none"')) {
		eval('document.getElementById("'+field+'").value = dsrt_getIFrameDocument("'+field+'_iframe").body.innerHTML');
		eval('document.getElementById("'+field+'_iframe").style.display="none"');
		eval('document.getElementById("'+field+'_viewchange").innerHTML=" - &lt;Editor&gt;"');
		eval('document.getElementById("div_'+field+'").style.display="block"');
	}
	else {
		eval('dsrt_getIFrameDocument("'+field+'_iframe").body.innerHTML = document.getElementById("'+field+'").value');
		eval('document.getElementById("div_'+field+'").style.display="none"');
		eval('document.getElementById("'+field+'_viewchange").innerHTML=" - &lt;HTML&gt;"');
		eval('document.getElementById("'+field+'_iframe").style.display="block"');
	}
} 

function dsrt_pastehtml(content, aArg){
	if (dsrt_thisid=='')
		alert('Bitte setzen Sie einen Cursor!');
	else {	
	dsrt_getIFrameDocument('dsrt_tempiframe').body.innerHTML=content;	
	dsrt_getIFrameDocument('dsrt_tempiframe').execCommand('selectall',false, aArg);
	dsrt_getIFrameDocument('dsrt_tempiframe').execCommand('copy',false, aArg);
	document.getElementById(dsrt_thisid).contentWindow.focus();	
	dsrt_getIFrameDocument(dsrt_thisid).execCommand('paste',false,aArg);
	}
} 

function dsrt_hidetagattributes(counter){
	document.getElementById("tagattributesview"+counter).innerText="";
}

dsrt_thisid='';
function dsrt_feld(thisfield) {
	dsrt_thisid=thisfield;
	}      

function dsrt_load(){
	dsrt_getIFrameDocument("ssubject_iframe").designMode = "On";
	// 2005-06-19 [AP] teaster_iframe deaktiviert, da dieser ifram z.Zt. noch nicht aktiv ist und einen Fehler im Firefox verursacht hat
	// dsrt_getIFrameDocument("teaser_iframe").designMode = "On";
	dsrt_getIFrameDocument("shortbody_iframe").designMode = "On";
	dsrt_getIFrameDocument("dsrt_tempiframe").designMode = "On"; 	
 }

function dsrt_getIFrameDocument(aID){
  if (document.getElementById(aID).contentDocument){  
	return document.getElementById(aID).contentDocument;
  } 
  else {
	return document.frames[aID].document;
   }
}
 
function dsrt_exec(aName, aArg){
	if(dsrt_thisid=='')
	alert('Bitte setzen Sie einen Cursor!');
	else {
		dsrt_getIFrameDocument(dsrt_thisid).execCommand(aName,false, aArg);
		document.getElementById(dsrt_thisid).contentWindow.focus()
	}
} 

function dsrt_addLink(){
  var myUrl = prompt("Please enter a URL:", "");
  dsrt_getIFrameDocument(thisid).execCommand("createLink", false, myUrl);
}    

function dsrt_getSource(){
  document.getElementById("ssubject").value = dsrt_replace(dsrt_getIFrameDocument(dsrt_thisid).body.innerHTML,"<","&lt;");
}

function dsrt_replace(string,text,by) {
  var stringLength = string.length
  var textLength = text.length;
  if ((stringLength == 0) || (textLength == 0)) return string;
  var i = string.indexOf(text);
  if ((!i) && (text != string.substring(0,textLength))) return string;
  if (i == -1) return string;
  var newstr = string.substring(0,i) + by;
  if ( (i+textLength) < stringLength)
	newstr += dsrt_replace(string.substring(i+textLength,stringLength),text,by);
  return newstr;
} 

function dsrt_colorpicker(whatcolor){
	colorarray=new Array('FFFFFF','FFCCCC','FFCC99','FFFF99','FFFFCC','99FF99','99FFFF','CCFFFF','CCCCFF','FFCCFF','CCCCCC','FF6666','FF9966','FFFF66','FFFF33','66FF99','33FFFF','66FFFF','9999FF','FF99FF','C0C0C0','FF0000','FF9900','FFCC66','FFFF00','33FF33','66CCCC','33CCFF','6666CC','CC66CC','999999','CC0000','FF6600','FFCC33','FFCC00','33CC00','00CCCC','3366FF','6633FF','CC33CC','666666','990000','CC6600','CC9933','999900','009900','339999','3333FF','6600CC','993399','333333','660000','993300','996633','666600','006600','336666','000099','333399','663366','000000','330000','663300','663333','333300','003300','003333','000066','330099','330033');
	document.write('<div id="'+whatcolor+'" style="position:absolute;top:0px;left:0px;display:none;z-index:250;">');
	document.write('<table width="150" height="100" cellpadding="1" cellspacing="0" border="1" align="center">');
	Ccounter=0;
	for(i=0;i<7;i++){
		document.write('<tr>');
		for(y=0;y<10;y++){
			document.write('<td id="#'+colorarray[Ccounter]+'" bgcolor="#'+colorarray[Ccounter]+'" width="10" height="10" ><a href="javascript:dsrt_exec(\''+whatcolor+'\', \'#'+colorarray[Ccounter]+'\');dsfx_object(\''+whatcolor+'\',\''+whatcolor+'\',\'displayshowhide\', 5);"><img src="dot.gif" width="10" height="10" border="0"></a></td>');
			Ccounter+=1;
		}
	document.write('</tr>');							
	}
	document.write('</table>');
	document.write('</div>');
}
if(window.name=='MAIN')
	var slide=0;

function DSDistributor (OptionList) {	
	this.element=DSCommand;
	this.commandbarelement='none';
	this.pagingelement=DSCommand;	
	this.classelement=DSCommand;
	this.guielement='';
	this.page=0;
	this.lastpage=1;
	this.pagerows=25;
	this.isoutput=DSIsOutput;
	this.startend=0;
	this.distribute=0;
	this.scrollto='0';
	this.resetresult=0;
	this.xhr=0;
	this.evalScript=0;
	this.innerdistribution=0;
	this.commandbardistributioncode='';
	this.type='distribute';
	this.display=0;
	this.assignedcommandbar='';
	if (DSIsDefined('this_window')==false){
		this_window=self;
	}
		
	DSOptionList(OptionList);
	
	if (this.type=='distribute') {	
		if (this_window.$(this.classelement) && this_window.$(this.classelement).readAttribute('guielement')!=null)
			this.guielement=this_window.$(this.classelement).readAttribute('guielement');
		
		// Wenn ein Command im POPUP mit DSDistributor geladen und angezeigt wird
		//if (DSCaller=='dynasite' && DSReceiver!='dsloader' && DSReceiver!='' && DSJS.ListFindNoCase('dspopup1_loader,dspopup2_loader,dspopup3_loader',this_window.name))
		if (window.name==this_window.name)
			this.isoutput=1;

		// isOutput ist immer 0, wenn es im DSLoader IFRAME geladen wird, damit es zum Ziel zurückgeschrieben wird
		if (DSReceiver=='dsloader')
			this.isoutput=0;			
		
		if (this.xhr==0)
			DSContext();			
		DSPageRows();

		if (this.page!=0) {
			DSSetPage();
			DSDisplayNavigator();
			DSClearPagingElements();
		}		
		
		DSGuiPlace();
		
		DSContent();		
		DSPaging();
	}
	else if (this.type=='DisplayPage') {
		DSSetPage();
		DSDisplayNavigator();	
	}
	else if (this.type=='ClearPage') {
		DSClearPagingElements();
	}
	else if (this.type=='DisplayGuiPlace') {
		DSGuiPlace();
	}		
		
	DSOnEnd();
	/************************
	// Functions	
	************************/
	function DSOptionList(OptionList) {
		var i=0;
		var function_list='';
		var this_function='';
		
		if(OptionList!=null) {	
			theDelimiter=':';
			function_list= OptionList.split(",");
			for (i=0; i<function_list.length; i++) {
				this_function=function_list[i].split(theDelimiter);
				this[this_function[0]]=this_function[1];
			}
				
		}
		this.classelement=this.element;	
		if (DSJS.FindNoCase('pagingelement:',OptionList)==0)		
			this.pagingelement=this.element;
		if (this_window.$(this.classelement) && this_window.$(this.classelement).readAttribute('commandbar')!=null)
			this.commandbar=this_window.$(this.classelement).readAttribute('commandbar');
		
		if (this_window.$(this.element) && this_window.$(this.element).readAttribute('classelement')!=null)
			this.classelement=this_window.$(this.element).readAttribute('classelement');		
			
		if (DSJS.ListFindNoCase(OptionList,'commandbarelement')==false && $(this.element+'_dscommandbarcontent') && $(this.element+'_dscommandbarcontent').readAttribute('commandbarelement')!=null)
			this.commandbarelement=$(this.element+'_dscommandbarcontent').readAttribute('commandbarelement');	
	}	
	
	function DSContext(){
		if (this_window.$(this.element+'_context') && $(this.element+'_context')){
			//this_window.$(this.element+'_context').innerHTML=$(this.element+'_context').innerHTML;			
			this_window.$(this.element+'_context').innerHTML='';			
			this_window.$(this.element+'_context').insert({bottom:$(this.element+'_context').innerHTML});
		}
	}
	
	function DSPageRows() {
		if (DSIsDefined('runPageRowsDistributor')==false) {			
			if ($('dscommandbar_pagerows') && $(this.commandbarelement+'_dscommandbar_pagerows')) {
				$(this.commandbarelement+'_dscommandbar_pagerows').innerHTML=$('dscommandbar_pagerows').innerHTML;	
				$('dscommandbar_pagerows').innerHTML='';
				runPageRowsDistributor=1;
			}
			// 2008-01-14 [AP] Wenn ein Command im Artikel (Explorer) aufgerufen wird und das dscommandbar_pagerow element im content steht
			else if ($('dscommandbar_pagerows') && this_window.$(this.commandbarelement+'_dscommandbar_pagerows')) {
				this_window.$(this.commandbarelement+'_dscommandbar_pagerows').innerHTML=$('dscommandbar_pagerows').innerHTML;	
				$('dscommandbar_pagerows').innerHTML='';
				runPageRowsDistributor=1;
			}
		}		
	}
	
	function DSContent () {
		// Commandbar 

		if (this.commandbar==1 && $(this.element+'_dscommandbarcontent') && (this.page==0 || this.page==1 || this.resetresult==1 || this_window.$(this.commandbarelement+'_commandbar')==null)){
			this.commandbardistributioncode=$(this.element+'_dscommandbarcontent').innerHTML;
			$(this.element+'_dscommandbarcontent').remove();
			this_window.$(this.classelement).setAttribute('commandbar',1);				
		}		

		//if (DSCAID==2260)
		//	alert('window.name:'+window.name+'\nthis.window:'+this_window.name+'\nelement:'+this.element+'\npage:'+this.page+'\nlastpage:'+this.lastpage+'\noutput:'+this.isoutput+'\nresetresult:'+this.resetresult);

		if (this_window.$(this.element) && $(this.element) && this.isoutput==0) {
			if (this.page==0) {					
				// this_window.$(this.element).innerHTML=this.commandbardistributioncode+'<div id="'+this.element+'_outer" style="display:none">'+$(this.element).innerHTML+'</div>';
				// this_window.$(this.element+'_outer').setStyle({display:'block'}); 
				AddHTML=this.commandbardistributioncode+'<div id="'+this.element+'_outer" style="display:none">'+$(this.element).innerHTML+'</div>';
				if (this.evalScript==0)
					AddHTML=AddHTML.stripScripts();
				this_window.$(this.element).innerHTML='';
				this_window.$(this.element).insert({bottom:AddHTML});
				
				this_window.$(this.element+'_outer').setStyle({display:'block'});
			}
			// Content Distribution with Paging
			else {				
				// Clear Receiver-Element
				if ((this.resetresult==1 || this.page==1) && this_window.$(this.element)) 		
					this_window.$(this.element).innerHTML='';					
				
				// Set lastpage to display="none"
				if (this_window.$(this.element+'_'+this.lastpage))
					this_window.$(this.element+'_'+this.lastpage).style.display='none';					
				
				// Remove _header Element
				if ($(this.element+'_header') && this_window.$(this.element+'_header')) 
					$(this.element+'_header').remove();	
					
				AddHTML=this.commandbardistributioncode+'<div id="'+this.element+'_outer_'+this.page+'" style="display:none">'+$(this.element).innerHTML+'</div>';				
				if (this.evalScript==0)
					AddHTML=AddHTML.stripScripts();
			
				// Insert Paging Content
				//new this_window.Insertion.Bottom(this.element, AddHTML);
				this_window.$(this.element).insert({bottom:AddHTML});
				
				//this_window.Effect.Appear(element+'_outer_'+page,{afterUpdate:this_window.DSPopupHelper,afterFinish:this_window.DSPopupHelper});
				this_window.$(this.element+'_outer_'+this.page).setStyle({display:'block'}); 							
			}
			
		}
		else if (this.commandbardistributioncode!='') {
			// Setzt nur die CommandBar über den Content. Z.B. wenn der Command im Artikel geladen wird (erster Aufruf)
			this_window.$(this.element).innerHTML=this.commandbardistributioncode+$(this.element).innerHTML;
		}
		if (this_window.$(this.classelement))
			this_window.$(this.classelement).setAttribute('pagerows',this.pagerows);	
	}
	
	function DSGuiPlace () {				
		
		if (this.guielement=='' || (this.page>1 && this.resetresult==0))
			return false;

		if (this.display==1) {
			if (this.assignedcommandbar!='')
				this.commandbarelement=this.assignedcommandbar;
			else {
				if ($(this.classelement).readAttribute('commandbarelement'))					
					this.commandbarelement=DSJS.ReplaceNoCase($(this.classelement).readAttribute('commandbarelement'),'_commandbar','','All');
				else
					this.commandbarelement='none';
			}			
		}
		//if (DSCAID==2260)
		//	alert('commandbar:'+this.commandbarelement+'\nguielement:'+this.guielement+'\nactive:'+this_window.$(this.guielement).readAttribute('active'));
		// active:'+this_window.$(this.guielement).readAttribute('active')+'
		
		if (this_window.$(this.guielement) && this_window.$(this.guielement).readAttribute('active') && this_window.$(this_window.$(this.guielement).readAttribute('active')))			
			this_window.$(this_window.$(this.guielement).readAttribute('active')).style.display='none';
		
		this_window.$(this.guielement).setAttribute('active',this.commandbarelement+'_commandbar');
		
		//if (DSCAID==2260)
		//	alert(' window:'+this_window.name+'\n active:'+this.guielement+'\nclasselement:'+this.classelement+'\nelement:'+this.element+'\n commandbarelement:'+this.commandbarelement+'\n display:'+display);
			
		if (this.display==0 && $(this.element+'_dscommandbarcontent')) {			
			// Remove commandbar element falls schon vorhanden
			if (this.xhr==0 && this_window.$(this.commandbarelement+'_commandbar'))
				this_window.$(this.commandbarelement+'_commandbar').remove();
			
			//if ($(this.commandbarelement+'_commandbar'))
			//	alert($(this.commandbarelement+'_commandbar').innerHTML);
			
			AddHTML=$(this.element+'_dscommandbarcontent').innerHTML;		
			
			//if (this.xhr==1 && $(this.guielement).select('[id="'+this.commandbarelement+'_commandbar"]')!='')
			//	$(this.commandbarelement+'_commandbar').remove();
			
			if (this.evalScript==0)
				AddHTML=AddHTML.stripScripts();
			//new this_window.Insertion.Bottom(this.guielement, AddHTML);				
			this_window.$(this.guielement).insert({bottom:AddHTML});
			
			$(this.element+'_dscommandbarcontent').remove();		
		
			if (this_window.$(this.classelement)) {
				this_window.$(this.classelement).setAttribute('commandbar',1);
				this_window.$(this.classelement).setAttribute('commandbarelement',this.commandbarelement+'_commandbar');
				this_window.$(this.classelement).setAttribute('guielement',this.guielement);
			}			
			
			if (this_window.$(this.commandbarelement+'_commandbar'))
				this_window.$(this.commandbarelement+'_commandbar').setAttribute('classelement',this.classelement);			
		}			
		
		if (this_window.$(this_window.$(this.guielement).readAttribute('active'))!=null)
			this_window.$(this_window.$(this.guielement).readAttribute('active')).style.display='block';
		
	}
	// Set Last and current Page Number
	function DSSetPage () {	
		if (this_window.$(this.classelement)) {		
			if (this_window.$(this.classelement).readAttribute('page')!=null)
				this.lastpage=this_window.$(this.classelement).readAttribute('page');				
			this_window.$(this.classelement).setAttribute('page',this.page);			
			
			if ($(this.commandbarelement))
				$(this.commandbarelement).setAttribute('classelement',this.classelement);				
		}
		else {
			// Wenn alle Paging-Element im Dokument stehen und nur ein- und ausgeblendet werden (z.B. Manager-Übersicht)
			if (this.lastpage!=this.page)
				this.lastpage=this.page;
			top.DSGUIObject_Active["DSPaging_"+element]=this.page;
			//this.page=page;
		}
	}
	// Display Paging Navigator
	function DSDisplayNavigator () {
		var pagingcounter=2;		
		//if (DSCAID==2260)
		//	alert('element:'+this.element+' - Page:'+this.page+' - LastPage:'+this.lastpage+' - Counter:'+pagingcounter+' window name:'+this_window.name);
		if (this.page!=this.lastpage) {
			for (i=1;i<pagingcounter+1;i++) {
				if (this_window.$(this.element+'_dspage_void_'+i+'_'+this.lastpage)) {				
					this_window.$(this.element+'_dspage_void_'+i+'_'+this.lastpage).hide();
					this_window.$(this.element+'_dspage_'+i+'_'+this.lastpage).hide();
					
					if (this_window.$(this.element+'_dspage_void_'+i+'_'+this.page))
						this_window.$(this.element+'_dspage_void_'+i+'_'+this.page).hide();	

					if (this_window.$(this.element+'_dspage_'+i+'_'+this.page)){		
						this_window.$(this.element+'_dspage_'+i+'_'+this.page).show();	
					}
				}
			}	
		}
	}
	
	function DSClearPagingElements () {
		if(this.resetresult==1 || this.page==1) {
			if (this_window.$(this.commandbarelement+'_dscommandbar_paging')){				
				this_window.$(this.commandbarelement+'_dscommandbar_paging').innerHTML='';	
			}
			if (this_window.$(this.pagingelement+'_element_paging')) {
				this_window.$(this.pagingelement+'_element_paging').innerHTML='';	
				if ($(this.element+'_dsnavigatorbox_1_'+this.page)) {
					$(this.element+'_dsnavigatorbox_1_'+this.page).style.display='none';				
				}				
			}		
			if (this.removeelement!='' && this_window.$(this.removeelement)) {					
				this_window.$(this.removeelement).remove();
			}
		}
	}
	
	
	function DSPaging() {
		this_paging_window=this_window;
			
		if (this_paging_window.$(this.pagingelement+'_element_paging') || $(this.pagingelement+'_element_paging')) {
			if (this.innerdistribution==1)
				this_paging_window=self;		
			this_class='element_paging';
			dsnavigator_element=this.element;
			receiving_element=this.pagingelement+'_element_paging';
			//if (DSCAID==2260)
			//	alert('element:'+receiving_element+'\nwindow:'+this_paging_window.name);
		}
		//else if ((DSJS.ListFindNoCase('dsmanager,dspopup3_loader,dspopup1_loader',this_window.name) || DSCommandBar==1 || this_window.DSCommandBar==1) && (this.commandbardistributioncode!='' || (this_window.$(this.commandbarelement+'_dscommandbar_paging')!=null) && $(this.commandbarelement+'_dsnavigatorbox_1_'+this.page)!=null)) {
		else if (this_window.$(this.classelement) && this_window.$(this.classelement).readAttribute('commandbar')==1){
			this_class='dscommandbar_paging';
			dsnavigator_element=this.commandbarelement;
			receiving_element=this.commandbarelement+'_dscommandbar_paging';
			this.pagingelement=this.commandbarelement;			
		}
		else 			
			return false;
		
		if (this.xhr==1 && this_paging_window.$(receiving_element))
			this_paging_window.$(receiving_element).innerHTML='';
		
		//if (DSCAID==2260)
		//	alert('this_class:'+this_class+'\nreceiving_element:'+receiving_element+'\ndsnavigator_element:'+dsnavigator_element+'\nwindow:'+this_paging_window.name)
				
		if ($(dsnavigator_element+'_dsnavigatorbox_1_'+this.page) && this_paging_window.$(receiving_element)) {
			AddHTML=$(dsnavigator_element+'_dsnavigatorbox_1_'+this.page).innerHTML;
			
			if (this.evalScript==0)
				AddHTML=AddHTML.stripScripts();			
			this_paging_window.$(receiving_element).insert({top:AddHTML});
		
			//AddHTML=this_paging_window.$(receiving_element).innerHTML;
			//AddHTML=DSJS.Replace(AddHTML,"<","<span><</span>","All");
			//AddHTML+='<br /><br />';
			//top.MAIN.$('testing').innerHTML=AddHTML;
		}			
		
		if (this_paging_window.$(dsnavigator_element+'_dsnavigatorbox_1_'+this.page)) {
			//this_paging_window.$(dsnavigator_element+'_dsnavigatorbox_1_'+this.page).innerHTML='';			
			this_paging_window.$(dsnavigator_element+'_dsnavigatorbox_1_'+this.page).remove();			
			// Die Outer-Box muss auf display:none gesetzt werden, da ansonsten ein Abstand zwischen Content und DSCommandbar steht
			//this_paging_window.$(dsnavigator_element+'_dsnavigatorbox_1_'+this.page).style.display='none';
			this_paging_window.$(dsnavigator_element+'_dspage_1_'+this.page).className=this_class;
			this_paging_window.$(dsnavigator_element+'_dspage_void_1_'+this.page).className=this_class;
		}
	}
	
	function DSOnEnd() {
		if(this_window.$('dsformwaitcode'))
			this_window.$('dsformwaitcode').style.display='none';
			
		//if(this_window.name!='MAIN')
		this_window.DSPopUpResize();	
	
		if (this.scrollto!=0)
			this_window.scrollTo(0,0);
	}
};

//		if (DSCAID==2260)
//			alert('element:'+this.element+' page:'+this.page+' lastpage:'+this.lastpage+' window:'+this_window.name);

function dspaging(element,querystring,option) {
	page=1;
	lastpage=1;
	startend=0;
	scrollto='0';
	loadtype='dsloader';
	postform='';
	resetresult=0;
	pagingcounter=2;
	display='';
	// Option Loop
	DSOptionList(option);	
	
	this_window=DSLoader_getWindowObject(element);
	
	var ClassElement=element;
	if ($(element) && $(element).readAttribute('classelement')!=null) 
		ClassElement=$(element).readAttribute('classelement');
	
	if(startend==0 && resetresult==1) {
		$(ClassElement).setAttribute('page','');		
		DSDistributor('element:'+element+',page:'+page+',lastpage:'+lastpage+',resetresult:1,type:ClearPage');
	}		
		
	// Set LastPage
	if (this_window.$(ClassElement))
		lastpage=this_window.$(ClassElement).readAttribute('page');		
	else
		lastpage=top.DSGUIObject_Active["DSPaging_"+element];
	

	// Load new page if not exist in document
	if ($(element+'_'+page)==null || resetresult==1) {		
		if(lastpage!=''){				
			for (i=1;i<pagingcounter+1;i++) {	
				if($(element+'_dspage_void_'+i+'_'+lastpage)!=null) {						
					$(element+'_dspage_void_'+i+'_'+lastpage).style.display='block';
					$(element+'_dspage_'+i+'_'+lastpage).style.display='none';						
				}
			}
			if ($('dsformwaitcode')!=null) 
				$('dsformwaitcode').style.display='block';					
		}		
		if (top.DSLoader_URLAdd!=null && DSJS.ListFirst(top.DSLoader_URLAdd,"=")=='dssorting')
			top.DSLoader_URLAdd='';
		if ($(ClassElement) && $(ClassElement).readAttribute('pagerows')){
			if (DSJS.FindNoCase('dspagerows',querystring)==0)
				querystring+='&dspagerows='+$(ClassElement).readAttribute('pagerows');
			querystring+='&DSPageRowsAction='+$(ClassElement).readAttribute('pagerows');
		}
		if(postform!='' && $(postform)!=null)
			dsloader(querystring+'&dspage='+page+'&dsslide='+slide,'dsloader',element,'postform:'+postform);			
		else if(loadtype=='dsloader')
			dsloader(querystring+'&dspage='+page+'&dsslide='+slide,'dsloader',element);
		else if (loadtype=='selflocation')					
			self.location.href=querystring+'&dspage='+page;			
	}
	// Display next/prev. page
	else {			
		// Current Page Block - Old Page None
		$(element+'_'+lastpage).hide();
		$(element+'_'+page).show();
		// wenn alle Paging-Elemente im Dokument stehen und NICHT über den dsloader geladen werden
		if ($(element+'_dsnavigatorbox_1_'+page) && $(element+'_dsnavigatorbox_1_'+page).style.display=='none' && display!='' ) {
			$(element+'_dsnavigatorbox_1_'+page).show();
			$(element+'_dsnavigatorbox_1_'+lastpage).hide();
		}
		// Page Container	
		DSDistributor('element:'+element+',page:'+page+',lastpage:'+lastpage+',scrollto:'+scrollto+',type:DisplayPage');
	}	
}

function dstinymcecustomfilebrowser(element_id, url, type, win) {
	parent.TinyMCEInstance='tinymce';
	parent.TinyMCEWindow=win;			
	parent.dsfield=element_id;
	if(type=='image' || type=='flash')
		dslgs_open('f1',element_id,'asset_asset_asset_view');
	else if(type=='file')
		dslgs_open('f1',element_id,'site_site_site_view');
	else
		dslgs_open('f1',element_id,'site_site_site_view');				
}
function dstinymcstogglehtmlmode(action,textarea,height,font) {
	fieldtemp='';
	fonttemp='';
	if(font!=null){
		font=font.split('|')
		for(i=0;i<font.length;i++){
			if(font[i]=='size')
				fonttemp+='fontsizeselect,';
			if(font[i]=='family')
				fonttemp+='fontselect,';
		}
	}
	if(textarea=='ssubject')
		fieldtemp='fieldtype_title';
	else if (textarea=='teaser')
		fieldtemp='fieldtype_teaser';	
	else if (textarea=='shortbody')
		fieldtemp='fieldtype_body';	
	if(tinyMCE!=null)
		tinyMCE.execCommand('mceRemoveControl',false,textarea);
	if(action=='simple') {
		if($(fieldtemp)!='' && $(fieldtemp)!=null){
			if($('editor_warning_'+textarea).value==0 && $(fieldtemp).value!='editor'){				
				editor_warning=DSLang('alertswitcheditormodus');							
				if(editor_warning==false)
					return
				else{
					$('editor_warning_'+textarea).value=1;
					$(fieldtemp).value='editor';
				}
			}
		}
		if(fonttemp!=''){
			tempbutton1='"paste,pastetext,pasteword,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image"';
			tempbutton2='"'+fonttemp+'separator,bold,italic,underline,strikethrough,forecolor,backcolor"';
		}
		else{
			tempbutton1='"paste,pastetext,pasteword,separator,bold,italic,underline,strikethrough,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image"';
			tempbutton2='""';
		}		
		tinyMCE.init({
			mode : "exact",
			theme : "advanced",
			skin : "o2k7",
		    elements  : "+textarea+",
			plugins : "safari,table,media,searchreplace,contextmenu,inlinepopups,paste",
			theme_advanced_disable:"",
			theme_advanced_buttons1:eval(tempbutton1),
			theme_advanced_buttons2:eval(tempbutton2),
			theme_advanced_buttons3 : "",
			theme_advanced_statusbar_location : "none",

			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_link_targets : eval('"'+DSLang('mainwindow')+'=main;Reload=_top"'),
			extended_valid_elements : "+textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|rows|style|tabindex|title],input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value],+iframe[align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style|title|width],+fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],+noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width],+optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|selected<selected|style|title|value],+script[charset|defer|language|src|type],+select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|tabindex|title],param[id|name|type|value|valuetype<DATA?OBJECT?REF],+label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],+legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target],+a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|shape<circle?default?poly?rect|style|tabindex|title|target|type],+dd[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dl[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dt[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex]",
			table_styles : "DSTable_Table=dstable_table",
			table_cell_styles : "DSTable_Cell=dstable_cell",
			table_row_styles : "DSTable_Row=dstable_row",			
			document_base_url:eval('"'+DSFrontURL+'/"'),				
			language: eval('"'+dslang+'"'),
			docs_language:eval('"'+dslang+'"'),
			debug: false,
			width:"100%",
			height:eval('"'+height+'"'),
			force_hex_style_colors : true,
			force_br_newlines : DSEditorForceBR,
			force_p_newlines : DSEditorForceP,
			forced_root_block : false,
			inline_styles : false,
			relative_urls: true,
			convert_urls : false,
			apply_source_formatting: true,
			button_tile_map: true,
			convert_fonts_to_spans : false,
			cleanup : true,
			verify_html:true,
			remove_linebreaks : false,
//			cleanup_callback : "mceTagWrap",
			entity_encoding:eval('"'+entity_encoding+'"'),
			paste_use_dialog : false,
			file_browser_callback : "dstinymcecustomfilebrowser",
			init_instance_callback: "dsEditorCustomInitInstance",
			paste_postprocess : function(pl, o) {
				if(o.wordContent==true && DSEditorForceBR==true){
					var test = o.node.innerHTML;
					test = test.replace(/<p>/g,'');
					test = test.replace(/<\/p>/g,'</br>');					
					test = test.replace(/\&nbsp\;/g, ' ');
					test = test.replace(/\s{2,}/g, ' ');				
					o.node.innerHTML=test;
				}
			}
		});
		tinyMCE.execCommand('mceAddControl',false,textarea);
		if($('dirshow_'+textarea)!=null)
			$('dirshow_'+textarea).style.display='none';
		$('editorname_'+textarea).innerHTML='['+DSLang('contenteditor')+']';		
	}
	else if(action=='advanced') {
		if($(fieldtemp)!='' && $(fieldtemp)!=null){
			if($('editor_warning_'+textarea).value==0 && $(fieldtemp).value!='editor'){				
				editor_warning=confirm(DSLang('alertswitchtoeditor'));
				if(editor_warning==false)
					return
				else{
					$(fieldtemp).value='editor';					
					$('editor_warning_'+textarea).value=1;
				}
			}
		}
		if(fonttemp!=''){
			tempbutton1='"paste,pastetext,pasteword,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image"';
			tempbutton2='"'+fonttemp+'separator,bold,italic,underline,strikethrough,forecolor,backcolor"';
			tempbutton3='"cut,copy,separator,search,replace,separator,cleanup,removeformat,separator,sub,sup,charmap,separator,media,separator,tablecontrols,visualaid"';			
		}
		else{
			tempbutton1='"paste,pastetext,pasteword,separator,bold,italic,underline,strikethrough,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image"';
			tempbutton2='"cut,copy,separator,search,replace,separator,cleanup,removeformat,separator,sub,sup,charmap,separator,media,separator,tablecontrols,visualaid"';
			tempbutton3='""';
		}				
		tinyMCE.init({
			mode : "exact",
			theme : "advanced",
			skin : "o2k7",			
		    elements  : "+textarea+",
			plugins : "safari,table,media,searchreplace,contextmenu,inlinepopups,paste",
			theme_advanced_disable:"",			
			theme_advanced_buttons1:eval(tempbutton1),
			theme_advanced_buttons2:eval(tempbutton2),
			theme_advanced_buttons3:eval(tempbutton3),
			theme_advanced_statusbar_location : "none",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_link_targets : eval('"'+DSLang('mainwindow')+'=main;Reload=_top"'),
			extended_valid_elements : "+textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|rows|style|tabindex|title],input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value],+iframe[align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style|title|width],+fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],+noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width],+optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|selected<selected|style|title|value],+script[charset|defer|language|src|type],+select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|tabindex|title],param[id|name|type|value|valuetype<DATA?OBJECT?REF],+label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],+legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target],+a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|shape<circle?default?poly?rect|style|tabindex|title|target|type],+dd[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dl[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dt[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex]",
			table_styles : "DSTable_Table=dstable_table",
			table_cell_styles : "DSTable_Cell=dstable_cell",
			table_row_styles : "DSTable_Row=dstable_row",			
			document_base_url:eval('"'+DSFrontURL+'/"'),				
			language:eval('"'+dslang+'"'),
			docs_language:eval('"'+dslang+'"'),
			debug: false,
			width:"100%",
			height:eval('"'+height+'"'),
			force_hex_style_colors : true,
			force_br_newlines : DSEditorForceBR,
			force_p_newlines : DSEditorForceP,
			forced_root_block : false,			
			inline_styles : false,
			relative_urls: true,
			convert_urls : false,			
			apply_source_formatting: true,
			button_tile_map: true,
			dialog_type: "window",
			convert_fonts_to_spans : false,
			cleanup : true,
			verify_html:true,
			remove_linebreaks : false,
//			cleanup_callback : "mceTagWrap",
			entity_encoding:eval('"'+entity_encoding+'"'),
			paste_use_dialog : false,
			file_browser_callback : "dstinymcecustomfilebrowser",
			init_instance_callback: "dsEditorCustomInitInstance",
			paste_postprocess : function(pl, o) {
				if(o.wordContent==true && DSEditorForceBR==true){
					var test = o.node.innerHTML;
					test = test.replace(/<p>/g,'');
					test = test.replace(/<\/p>/g,'</br>');					
					test = test.replace(/\&nbsp\;/g, ' ');
					test = test.replace(/\s{2,}/g, ' ');				
					o.node.innerHTML=test;
				}
			}
		});
		tinyMCE.execCommand('mceAddControl',false,textarea);
		$('editorname_'+textarea).innerHTML='['+DSLang('contenteditor')+']';		
		if($('dirshow_'+textarea)!=null)		
			$('dirshow_'+textarea).style.display='none';
	}
	else if(action=='frontend') {
		if(fonttemp!=''){
			tempbutton1='"paste,pastetext,pasteword,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo"';
			tempbutton2='"'+fonttemp+'separator,bold,italic,underline,strikethrough,forecolor,backcolor"';
		}
		else{
			tempbutton1='"paste,pastetext,pasteword,separator,bold,italic,underline,strikethrough,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo"';
			tempbutton2='""';
		}
		tinyMCE.init({
			mode : "exact",
			theme : "advanced",
			skin : "o2k7",			
		    elements  : "+textarea+",
			plugins : "safari,table,media,searchreplace,contextmenu,inlinepopups,paste",
			theme_advanced_disable:"",			
			theme_advanced_buttons1:eval(tempbutton1),
			theme_advanced_buttons2:eval(tempbutton2),
			theme_advanced_buttons3 : "",
			theme_advanced_statusbar_location : "none",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_link_targets :  eval('"'+DSLang('mainwindow')+'=main;Reload=_top"'),
			extended_valid_elements : "+textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|rows|style|tabindex|title],input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value],+iframe[align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style|title|width],+fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],+noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width],+optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|selected<selected|style|title|value],+script[charset|defer|language|src|type],+select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|tabindex|title],param[id|name|type|value|valuetype<DATA?OBJECT?REF],+label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],+legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target],+a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|shape<circle?default?poly?rect|style|tabindex|title|target|type],+dd[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dl[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dt[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex]",
			table_styles : "DSTable_Table=dstable_table",
			table_cell_styles : "DSTable_Cell=dstable_cell",
			table_row_styles : "DSTable_Row=dstable_row",			
			document_base_url:eval('"'+DSFrontURL+'/"'),
			language:eval('"'+dslang+'"'),
			docs_language:eval('"'+dslang+'"'),
			debug: false,
			width:"100%",
			height:eval('"'+height+'"'),
			force_hex_style_colors : true,
			force_br_newlines: DSEditorForceBR,
			force_p_newlines : DSEditorForceP,
			forced_root_block : false,
			inline_styles : false,
			relative_urls: true,
			convert_urls : false,			
			apply_source_formatting: true,
			button_tile_map: true,
			dialog_type: "window",
			convert_fonts_to_spans : false,
			cleanup : true,
			verify_html:true,
			remove_linebreaks : false,
//			cleanup_callback : "mceTagWrap",
			entity_encoding:eval('"'+entity_encoding+'"'),
			paste_use_dialog : false,
			file_browser_callback : "dstinymcecustomfilebrowser",
			init_instance_callback: "dsEditorCustomInitInstance",
			paste_postprocess : function(pl, o) {
				if(o.wordContent==true && DSEditorForceBR==true){
					var test = o.node.innerHTML;
					test = test.replace(/<p>/g,'');
					test = test.replace(/<\/p>/g,'</br>');					
					test = test.replace(/\&nbsp\;/g, ' ');
					test = test.replace(/\s{2,}/g, ' ');				
					o.node.innerHTML=test;
				}
			}
		});
		tinyMCE.execCommand('mceAddControl',false,textarea);
		if($('dirshow_'+textarea)!=null)		
			$('dirshow_'+textarea).style.display='none';
	}
	else if(action=='frontendtable') {
		if(fonttemp!=''){
			tempbutton1='"paste,pastetext,pasteword,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo"';
			tempbutton2='"'+fonttemp+'separator,bold,italic,underline,strikethrough,forecolor,backcolor"';
			tempbutton3='"cut,copy,separator,search,replace,separator,cleanup,removeformat,separator,sub,sup,charmap,separator,flash,separator,tablecontrols,visualaid"';			
		}
		else{
			tempbutton1='"paste,pastetext,pasteword,separator,bold,italic,underline,strikethrough,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo"';
			tempbutton2='"cut,copy,separator,search,replace,separator,cleanup,removeformat,separator,sub,sup,charmap,separator,flash,separator,tablecontrols,visualaid"';
			tempbutton3='""';
		}						
		tinyMCE.init({
			mode : "exact",
			theme : "advanced",
			skin : "o2k7",			
		    elements  : "+textarea+",
			plugins : "safari,table,media,searchreplace,contextmenu,inlinepopups,paste",
			theme_advanced_disable:"",			
			theme_advanced_buttons1:eval(tempbutton1),
			theme_advanced_buttons2:eval(tempbutton2),
			theme_advanced_buttons3:eval(tempbutton3),
			theme_advanced_statusbar_location : "none",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_link_targets : eval('"'+DSLang('mainwindow')+'=main;Reload=_top"'),
			extended_valid_elements : "+textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|rows|style|tabindex|title],input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value],+iframe[align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style|title|width],+fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],+noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width],+optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|selected<selected|style|title|value],+script[charset|defer|language|src|type],+select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|tabindex|title],param[id|name|type|value|valuetype<DATA?OBJECT?REF],+label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],+legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],+area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target],+a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|shape<circle?default?poly?rect|style|tabindex|title|target|type],+dd[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dl[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex],+dt[class|id|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex]",
			table_styles : "DSTable_Table=dstable_table",
			table_cell_styles : "DSTable_Cell=dstable_cell",
			table_row_styles : "DSTable_Row=dstable_row",			
			document_base_url:eval('"'+DSFrontURL+'/"'),				
			language:eval('"'+dslang+'"'),
			docs_language:eval('"'+dslang+'"'),
			debug: false,
			width:"100%",
			height:eval('"'+height+'"'),
			force_hex_style_colors : true,
			force_br_newlines: DSEditorForceBR,
			force_p_newlines : DSEditorForceP,
			forced_root_block : false,		
			inline_styles : false,
			relative_urls: true,
			convert_urls : false,			
			apply_source_formatting: true,
			button_tile_map: true,
			dialog_type: "window",
			convert_fonts_to_spans : false,
			cleanup : true,
			verify_html:true,
			remove_linebreaks : false,
//			cleanup_callback : "mceTagWrap",
			entity_encoding:eval('"'+entity_encoding+'"'),
			paste_use_dialog : false,
			file_browser_callback : "dstinymcecustomfilebrowser",
			init_instance_callback: "dsEditorCustomInitInstance",
			paste_postprocess : function(pl, o) {
				if(o.wordContent==true && DSEditorForceBR==true){
					var test = o.node.innerHTML;
					test = test.replace(/<p>/g,'');
					test = test.replace(/<\/p>/g,'</br>');					
					test = test.replace(/\&nbsp\;/g, ' ');
					test = test.replace(/\s{2,}/g, ' ');				
					o.node.innerHTML=test;
				}
			}
		});
		tinyMCE.execCommand('mceAddControl',false,textarea);
		if($('dirshow_'+textarea)!=null)		
			$('dirshow_'+textarea).style.display='none';
	}	
	else if(action=='text'){
		if($('dirshow_'+textarea)!=null)		
			$('dirshow_'+textarea).style.display='block';
		$('editorname_'+textarea).innerHTML='['+DSLang('text')+']';
		if($(fieldtemp)!='' && $(fieldtemp)!=null)
			$(fieldtemp).value='text';
	}
	else if(action=='html'){
		if($('dirshow_'+textarea)!=null)		
			$('dirshow_'+textarea).style.display='block';
		$('editorname_'+textarea).innerHTML='['+DSLang('html')+']';
		if($(fieldtemp)!='' && $(fieldtemp)!=null)
			$(fieldtemp).value='html';
	}
	if($('dsacc_dseditor_'+textarea+'_option')!=null)
		$('dsacc_dseditor_'+textarea+'_option').innerHTML=$('DSEditorCall_'+textarea).innerHTML;
	
}


function dsEditorCustomInitInstance(ed) {
	if(ed.id=='ssubject'){
		tinymce.dom.Event.add(ed.getWin(), 'blur', function(e) {
			if($('metaname').value==''){
		        string=ed.getContent().replace(/<[^>]*>/g, '');
				$('metaname').value=string;
			}
		});
	}
}


function dseditorchange(e,textarea,height,changetype,font){
	var html_str='';
	if(font==null)
		font='';
	if(changetype==null)
		changetype=1;
	if(changetype>2)
		html_str+='<a class="dsconmenu" href="javascript:dstinymcstogglehtmlmode(\'text\',\''+textarea+'\',\''+height+'\',\''+font+'\');DSContextHide();">'+DSLang('text')+'</a>';
	if(changetype>0)
		html_str+='<a class="dsconmenu" href="javascript:dstinymcstogglehtmlmode(\'html\',\''+textarea+'\',\''+height+'\',\''+font+'\');DSContextHide();">'+DSLang('html')+'</a>';	
	if(changetype<2)
		html_str+='<a class="dsconmenu" href="javascript:dstinymcstogglehtmlmode(\'frontend\',\''+textarea+'\',\''+height+'\',\''+font+'\');DSContextHide();">'+DSLang('contenteditor')+'</a>';
	else
		html_str+='<a class="dsconmenu" href="javascript:dstinymcstogglehtmlmode(\'simple\',\''+textarea+'\',\''+height+'\',\''+font+'\');DSContextHide();">'+DSLang('contenteditor')+'</a>';	
	if(changetype>1)
		html_str+='<a class="dsconmenu" href="javascript:dstinymcstogglehtmlmode(\'advanced\',\''+textarea+'\',\''+height+'\',\''+font+'\');DSContextHide();">'+DSLang('editoradvanced')+'</a>';
	DSContextShow(e,html_str);			
}


// TinyMCE Zusatz Funktionen behebt die P Tag Problematik [TR] 30.07.07

function mceTagWrap(type, value) {
	switch (type) {
		case "get_from_editor":
			value=mceTrim(value);			
			if(value.charAt(0) == "<" && value.toLowerCase().charAt(1) == "p" && value.charAt(value.length - 1) == ">" && value.toLowerCase().charAt(value.length -2) == "p" && value.charAt(value.length -3) == "/" && value.toLowerCase().lastIndexOf("<p>")==0) {
				value = value.replace(/^<P>/i,'');	
				value = value.replace(/<\/P>$/i,'');
			}
			break;
	}
	return value;
}
function mceTrim(sInString) {
	sInString=sInString.replace( /^\s+/g, "" );// strip leading
	return sInString.replace( /\s+$/g, "" );// strip trailing
}


// *************************************
// * BEGIN Direct Edit                 *
// *************************************
var DSDirectEditStatus='inactive';
var DSDirectEditID='';
var DSDirectTempHref='';
var DSDirectTempTarget='';
var DSDirectTempClass='';

function DSDirectEdit(action){
	var new_function="DSDirectEditPosition(this)";
	var browserinfo = navigator.userAgent;	
	if(action=='active'){
		if(browserinfo.indexOf('MSIE 7') == -1 && browserinfo.indexOf('Firefox') == -1){
			alert(DSLang('alertdirectedit'))
			return
		}		
		top.dsnav.DSDirectEditStatus='active';
		top.dsnav.$('dsdireceditbutton').onclick=new Function('', "top.MAIN.DSDirectEdit('inactive')");
		top.dsnav.$('dsdireceditimage').src=dsgifpath+'icon/page.png';
		if(top.MAIN.$('dsdireceditbutton')!=null){		
			top.MAIN.$('dsdireceditbutton').onclick=new Function('', "top.MAIN.DSDirectEdit('inactive')");
			top.MAIN.$('dsdireceditimage').src=dsgifpath+'icon/page.png';
		}
		for(i=0;i<DSArticleTitleID.length;i++){		
			if($('dsarticletitle_'+DSArticleTitleID[i])!=null){
				$('dsarticletitle_'+DSArticleTitleID[i]).onclick= new Function('', new_function);
				if(ie)
					$('dsarticletitle_'+DSArticleTitleID[i]).attachEvent('onclick', stopevent);
				else
					$('dsarticletitle_'+DSArticleTitleID[i]).addEventListener('click',stopevent,true);
			}
		}
		for(i=0;i<DSArticleBodyID.length;i++){
			if($('dsarticlebody_'+DSArticleBodyID[i])!=null){
				$('dsarticlebody_'+DSArticleBodyID[i]).onclick= new Function('', new_function);			
				if(ie)
					$('dsarticlebody_'+DSArticleBodyID[i]).attachEvent('onclick', stopevent);
				else
					$('dsarticlebody_'+DSArticleBodyID[i]).addEventListener('click',stopevent,true);
			}
		}
		for(i=0;i<DSArticleTitleInactiveID.length;i++){
			if($('dsarticletitle_'+DSArticleTitleInactiveID[i])!=null){
				$('dsarticletitle_'+DSArticleTitleInactiveID[i]).style.opacity='.2';
				if(ie){
					$('dsarticletitle_'+DSArticleTitleInactiveID[i]).style.setAttribute("filter", "alpha(opacity=20)", false);
					$('dsarticletitle_'+DSArticleTitleInactiveID[i]).style.width='100%';
				}
			}
		}
		for(i=0;i<DSArticleBodyInactiveID.length;i++){
			if($('dsarticlebody_'+DSArticleBodyInactiveID[i])!=null){
				$('dsarticlebody_'+DSArticleBodyInactiveID[i]).style.opacity='.2';
				if(ie){
					$('dsarticlebody_'+DSArticleBodyInactiveID[i]).style.width='100%';
					$('dsarticlebody_'+DSArticleBodyInactiveID[i]).style.setAttribute("filter", "alpha(opacity=20)", false);
				}
			}
		}
		if($('dssiteheader')!=null){
			$('dssiteheader').style.opacity='.2';
			if(ie)
				$('dssiteheader').style.setAttribute("filter", "alpha(opacity=20)", false);
		}
		if($('dsmenuheader')!=null){
			$('dsmenuheader').style.opacity='.2';
			if(ie){
				$('dsmenuheader').style.width='100%';			
				$('dsmenuheader').style.setAttribute("filter", "alpha(opacity=20)", false);
			}
		}		
		if($('dsmenus')!=null){
			$('dsmenus').style.opacity='.2';
			if(ie){
				$('dsmenus').style.width='100%';
				$('dsmenus').style.setAttribute("filter", "alpha(opacity=20)", false);
			}
		}
		if($('dsmenufooter')!=null){
			$('dsmenufooter').style.opacity='.2';
			if(ie){
				$('dsmenufooter').style.width='100%';
				$('dsmenufooter').style.setAttribute("filter", "alpha(opacity=20)", false);
			}
		}				
		if($('dscontentheader')!=null){
			$('dscontentheader').style.opacity='.2';
			if(ie){						
				$('dscontentheader').style.width='100%';								
				$('dscontentheader').style.setAttribute("filter", "alpha(opacity=20)", false);
			}
		}
		if($('dscontentfooter')!=null){
			$('dscontentfooter').style.opacity='.2';
			if(ie){									
				$('dscontentfooter').style.width='100%';								
				$('dscontentfooter').style.setAttribute("filter", "alpha(opacity=20)", false);
			}
		}
		if($('dssitefooter')!=null){
			$('dssitefooter').style.opacity='.2';
			if(ie)
				$('dssitefooter').style.setAttribute("filter", "alpha(opacity=20)", false);
		}		
	}
	else{
		top.dsnav.DSDirectEditStatus='inactive';		
		top.dsnav.$('dsdireceditbutton').onclick=new Function('', "top.MAIN.DSDirectEdit('active')");		
		top.dsnav.$('dsdireceditimage').src=dsgifpath+'icon/page_edit.png';
		if(top.MAIN.$('dsdireceditbutton')!=null){
			top.MAIN.$('dsdireceditbutton').onclick=new Function('', "top.MAIN.DSDirectEdit('active')");		
			top.MAIN.$('dsdireceditimage').src=dsgifpath+'icon/page_edit.png';
		}
	
		for(i=0;i<DSArticleTitleID.length;i++){
			if($('dsarticletitle_'+DSArticleTitleID[i])!=null){
				$('dsarticletitle_'+DSArticleTitleID[i]).onclick='';
				if(ie)
					$('dsarticletitle_'+DSArticleTitleID[i]).detachEvent('onclick', stopevent);
				else
					$('dsarticletitle_'+DSArticleTitleID[i]).removeEventListener('click',stopevent,true);				
				tinyMCE.execCommand('mceRemoveControl',false,'dsarticletitle_'+DSArticleTitleID[i]);
			}
		}
		for(i=0;i<DSArticleBodyID.length;i++){
			if($('dsarticlebody_'+DSArticleBodyID[i])!=null){
				$('dsarticlebody_'+DSArticleBodyID[i]).onclick='';
				if(ie)
					$('dsarticlebody_'+DSArticleBodyID[i]).detachEvent('onclick', stopevent);
				else
					$('dsarticlebody_'+DSArticleBodyID[i]).removeEventListener('click',stopevent,true);				
				tinyMCE.execCommand('mceRemoveControl',false,'dsarticlebody_'+DSArticleBodyID[i]);
			}
		}
		for(i=0;i<DSArticleTitleInactiveID.length;i++){
			if($('dsarticletitle_'+DSArticleTitleInactiveID[i])!=null){
				$('dsarticletitle_'+DSArticleTitleInactiveID[i]).style.opacity='';
				$('dsarticletitle_'+DSArticleTitleInactiveID[i]).style.filter='';
			}
		}
		for(i=0;i<DSArticleBodyInactiveID.length;i++){
			if($('dsarticlebody_'+DSArticleBodyInactiveID[i])!=null){
				$('dsarticlebody_'+DSArticleBodyInactiveID[i]).style.opacity='';
				$('dsarticlebody_'+DSArticleBodyInactiveID[i]).style.filter='';
			}
		}
		if($('dssiteheader')!=null){
			$('dssiteheader').style.opacity='';
			$('dssiteheader').style.filter='';
		}
		if($('dsmenuheader')!=null){
			$('dsmenuheader').style.opacity='';
			$('dsmenuheader').style.filter='';
		}		
		if($('dsmenus')!=null){
			$('dsmenus').style.opacity='';
			$('dsmenus').style.filter='';
		}
		if($('dsmenufooter')!=null){
			$('dsmenufooter').style.opacity='';
			$('dsmenufooter').style.filter='';
		}		
		if($('dscontentheader')!=null){
			$('dscontentheader').style.opacity='';
			$('dscontentheader').style.filter='';
		}
		if($('dscontentfooter')!=null){
			$('dscontentfooter').style.opacity='';
			$('dscontentfooter').style.filter='';
		}
		if($('dssitefooter')!=null){
			$('dssitefooter').style.opacity='';
			$('dssitefooter').style.filter='';
		}			
		DSDirectEditID='';						
	}
}
function stopevent(event){
	if(ie){
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
	else
		event.preventDefault();
}
DSArticleImage='';
function DSDirectEditPosition(this_element){
	this_element_id=this_element.id;
	if(this_element_id.split('_')[0]=='dsarticletitle' || this_element_id.split('_')[0]=='dsarticlebody'){
		if(this_element_id.split('_')[0]=='dsarticletitle' && $(this_element_id).getElementsByTagName('a')[0].innerHTML=='' && $(this_element_id).getElementsByTagName('a')[0].name=='dstitle_'+this_element_id.split('_')[1])
			$(this_element_id).getElementsByTagName('a')[0].parentNode.removeChild($(this_element_id).getElementsByTagName('a')[0]);
		else if (this_element_id.split('_')[0]=='dsarticletitle'){
			DSDirectTempHref=$(this_element_id).getElementsByTagName('a')[0].href;
			DSDirectTempClass=$(this_element_id).getElementsByTagName('a')[0].classname;				
			if(DSDirectTempTarget=$(this_element_id).getElementsByTagName('a')[0].target!=null)
				DSDirectTempTarget=$(this_element_id).getElementsByTagName('a')[0].target;
			$(this_element_id).innerHTML=$(this_element_id).getElementsByTagName('a')[0].innerHTML;
		}
		if(document.getElementsByTagName('base')[0]!=null)
			document.getElementsByTagName('base')[0].parentNode.removeChild(document.getElementsByTagName('base')[0]);
		DSArticleImage=$(this_element_id).getElementsBySelector('[title="dsimage_div"]');
		for(i=0;i<DSArticleImage.length;i++){
			DSArticleImage[i].remove();
		}						
		for(i=0;i<$(this_element_id).getElementsByTagName('img').length;i++){
			if($(this_element_id).getElementsByTagName('img')[i].src.indexOf(DSFrontURL)!=-1)
				$(this_element_id).getElementsByTagName('img')[i].src=$(this_element_id).getElementsByTagName('img')[i].src.replace(DSFrontURL+'/', '');
		}
		for(i=0;i<$(this_element_id).getElementsByTagName('a').length;i++){
			$(this_element_id).getElementsByTagName('a')[i].href=$(this_element_id).getElementsByTagName('a')[i].href.replace(DSAdminURL+'/main.cfm', 'dynasite.cfm');
		}		
		tinyMCE.execCommand('mceAddControl',false,this_element_id);
		window.setTimeout("tinyMCE.execCommand('mceFocus',false,this_element_id);",100);
		DSDirectEditID=this_element_id;
	}
}


function myHandleEvent(e) {
	if(e.type=='blur'){
		tempcontent=tinyMCE.getContent();
		tinyMCE.execCommand('mceRemoveControl',false,DSDirectEditID);
		for(i=0;i<DSArticleImage.length;i++){
			$(this_element_id).insert({top:DSArticleImage[i]});
			//prototype.insert(this_element_id,{before:DSArticleImage[i]});
		}						
		for(i=0;i<$(this_element_id).getElementsByTagName('img').length;i++){
			$(this_element_id).getElementsByTagName('img')[i].src=$(this_element_id).getElementsByTagName('img')[i].src.replace(DSAdminURL+'/', DSFrontURL+'/');
		}
		for(i=0;i<$(this_element_id).getElementsByTagName('a').length;i++){
			$(this_element_id).getElementsByTagName('a')[i].href=$(this_element_id).getElementsByTagName('a')[i].href.replace(DSAdminURL+'dynasite.cfm', DSAdminURL+'/main.cfm').replace(DSFrontURL+'/dynasite.cfm', DSAdminURL+'/main.cfm');
		}
		dsloader(dsxpath+'dynasite.cfm?dscmd=content_article_direct_edit&DSDirectEditID='+DSDirectEditID.split('_')[1]+'&DSDirectEditType='+DSDirectEditID.split('_')[0],'dsloader');
		if(DSDirectEditID.split('_')[0]=='dsarticletitle'){
			if(DSDirectTempTarget!='')
				DSDirectTempTarget='target="'+DSDirectTempTarget+'"';
			if(DSDirectTempHref!='')
				$(this_element_id).innerHTML='<a name="dstitle_'+DSDirectEditID.split('_')[1]+'" class="'+DSDirectTempClass+'" href='+DSDirectTempHref+' '+DSDirectTempTarget+'>'+$(this_element_id).innerHTML+'</a>';			
			else
				$(this_element_id).innerHTML='<a name="dstitle_'+DSDirectEditID.split('_')[1]+'"></a>'+$(this_element_id).innerHTML;
		}
		DSDirectTempHref='';
		DSDirectTempClass='';		
		DSDirectTempTarget='';

	}
	return true;
}


// *************************************
// * END Direct Edit                   *
// *************************************

/* mouseover Prototype JS MEnu used by DL Helicopter */
var Menu = Class.create();
Menu.prototype = {
	
	initialize: function(idOrElement, name, customConfigFunction) {
		this.name = name;
		this.type = "menu";
		this.closeDelayTimer = null;
		this.closingMenuItem = null;
		this.config();
		if (typeof customConfigFunction == "function") {
			this.customConfig = customConfigFunction;
			this.customConfig();
		}
		this.rootContainer = new MenuContainer(idOrElement, this);
	},
	
	config: function() {
		this.collapseBorders = true;
		this.quickCollapse = true;
		this.closeDelayTime = 300;
	}
}





var MenuContainer = Class.create();
MenuContainer.prototype = {
	
	initialize: function(idOrElement, parent) {
		this.type = "menuContainer";
		this.menuItems = [];
		this.init(idOrElement, parent);
	},

	init: function(idOrElement, parent) {
		this.element = $(idOrElement);
		this.parent = parent;
		this.parentMenu = (this.type == "menuContainer") ? ((parent) ? parent.parent : null) : parent;
		this.root = parent instanceof Menu ? parent : parent.root;
		this.id = this.element.id;

		if (this.type == "menuContainer") {
			if (this.element.hasClassName("level1")) 
				this.menuType = "horizontal";
			else if (this.element.hasClassName("dssubmenus_1") || this.element.hasClassName("submenus_1")) 
				this.menuType = "dropdown";
			else 
				this.menuType = "flyout";
	
			if (this.menuType == "flyout" || this.menuType == "dropdown") {
				this.isOpen = false;
				Element.setStyle(this.element, {
					position: "absolute",
					top: "0px",
					left: "0px",
					visibility: "hidden"
				});
			}
			else {
				this.isOpen = true;
			}
		}
		else {
			this.isOpen = this.parentMenu.isOpen;
		}

		var childNodes = this.element.childNodes;
		if (childNodes == null) return;
	
		for (var i = 0; i < childNodes.length; i++) {
			var node = childNodes[i];
			if (node.nodeType == 1) {
				if (this.type == "menuContainer") {
					if (node.tagName.toLowerCase() == "li") {
						this.menuItems.push(new MenuItem(node, this));
					}
				}
				else {
					if (node.tagName.toLowerCase() == "ul")
						this.subMenu = new MenuContainer(node, this);
				}
			}
		}
	},

	getBorders: function(element) {
		var ltrb = ["Left","Top","Right","Bottom"];
		var result = {};
		for (var i = 0; i < ltrb.length; ++i) {
			if (this.element.currentStyle)
				var value = parseInt(this.element.currentStyle["border"+ltrb[i]+"Width"]);
			else if (window.getComputedStyle)
				var value = parseInt(window.getComputedStyle(this.element, "").getPropertyValue("border-"+ltrb[i].toLowerCase()+"-width"));
			else
				var value = parseInt(this.element.style["border"+ltrb[i]]);
			result[ltrb[i].toLowerCase()] = isNaN(value) ? 0 : value;
		}
		return result;
	},

	open: function() {
		if (this.root.closeDelayTimer) window.clearTimeout(this.root.closeDelayTimer);
		this.parentMenu.closeAll(this);
		this.isOpen = true;
		if (this.menuType == "dropdown") {
			Element.setStyle(this.element,{
				left: (Position.positionedOffset(this.parent.element)[0]) + "px",
				top: (Position.positionedOffset(this.parent.element)[1] + Element.getHeight(this.parent.element)) + "px"
			});
	  	}
		else if (this.menuType == "flyout") {
			var parentMenuBorders = this.parentMenu ? this.parentMenu.getBorders() : new Object();
			var thisBorders = this.getBorders();
			if ((Position.positionedOffset(this.parentMenu.element)[0] + this.parentMenu.element.offsetWidth + this.element.offsetWidth + 20) > (window.innerWidth ? window.innerWidth : document.body.offsetWidth)) {
				Element.setStyle(this.element,{
					left: (- this.element.offsetWidth - (this.root.collapseBorders ?  0 : parentMenuBorders["left"])) + "px"
				});
			}
			else {
				Element.setStyle(this.element,{
					left: (this.parentMenu.element.offsetWidth - parentMenuBorders["left"] - (this.root.collapseBorders ?  Math.min(parentMenuBorders["right"], thisBorders["left"]) : 0)) + "px"
				});
			}
			Element.setStyle(this.element,{
				top: (this.parent.element.offsetTop - parentMenuBorders["top"] - this.menuItems[0].element.offsetTop) + "px"
			});
		}
		Element.setStyle(this.element,{visibility: "visible"});
	},

	close: function() {
		Element.setStyle(this.element,{visibility: "hidden"});
		this.isOpen = false;
		this.closeAll();
	},

	closeAll: function(trigger) {
		for (var i = 0; i < this.menuItems.length; ++i) {
			this.menuItems[i].closeItem(trigger);
		}
	}
}


var MenuItem = Class.create();
Object.extend(Object.extend(MenuItem.prototype, MenuContainer.prototype), {
							
	initialize: function(idOrElement, parent) {
		var menuItem = this;
		this.type = "menuItem";
		this.subMenu;
		this.init(idOrElement, parent);
		if (this.subMenu) {
			this.element.onmouseover = function() {
				menuItem.subMenu.open();
			}
		}
		else {
			if (this.root.quickCollapse) {
				this.element.onmouseover = function() {
					menuItem.parentMenu.closeAll();
				}
			}
		}
		var linkTag = this.element.getElementsByTagName("A")[0];
		if (linkTag) {
			linkTag.onfocus = this.element.onmouseover;
			this.link = linkTag;
			this.text = linkTag.text;
		}
		if (this.subMenu) {
			this.element.onmouseout = function() {
				if (menuItem.root.openDelayTimer) window.clearTimeout(menuItem.root.openDelayTimer);


if (menuItem.root.closeDelayTimer) window.clearTimeout(menuItem.root.closeDelayTimer);



eval(menuItem.root.name + ".closingMenuItem = menuItem");
				menuItem.root.closeDelayTimer = window.setTimeout(menuItem.root.name + ".closingMenuItem.subMenu.close()", menuItem.root.closeDelayTime);
			}
		}
	},
	
	openItem: function() {
		this.isOpen = true;
		if (this.subMenu) { this.subMenu.open(); }
	},
	
	closeItem: function(trigger) {
		this.isOpen = false;
		if (this.subMenu) {
			if (this.subMenu != trigger) this.subMenu.close();
		}
	}
});

/* END mouseover Prototype JS MEnu used by DL Helicopter */

 
 /** 
 * @description		prototype.js based context menu
 * @author        Juriy Zaytsev; kangax [at] gmail [dot] com; http://thinkweb2.com/projects/prototype/
 * @version       0.6
 * @date          12/03/07
 * @requires      prototype.js 1.6
*/
//Start
if (Object.isUndefined(Proto)) { var Proto = { } }

Proto.MenuObjects=new Array();

Proto.Menu = Class.create({
	initialize: function() {
		var e = Prototype.emptyFunction;
		this.ie = Prototype.Browser.IE;
		this.options = Object.extend({
			selector: '.contextmenu',
			className: 'protoMenu',
			pageOffset: 25,
			fade: false,
			zIndex: 100,
			beforeShow: e,
			beforeHide: e,
			beforeSelect: e,
			mouseevent: 'contextmenu' //rightclick:contextmenu, leftclick:click, onMouseover:mouseover
		}, arguments[0] || { });
		this.shim = new Element('iframe', {
			style: 'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',
			src: 'javascript:false;',
			frameborder: 0
		});
		this.options.fade = this.options.fade && !Object.isUndefined(Effect);
		this.container = new Element('div', {className: this.options.className, style: 'display:none'});

		document.observe('click', function(e) {
			if (this.container.visible() && !e.isRightClick()) {
				this.options.beforeHide(e);
				if (this.ie) this.shim.hide();
				this.container.hide();
			}
		}.bind(this));

		var that=this;
		$$(this.options.selector).each(function(element){
			element.observe(that.options.mouseevent,function(e){
				if (Prototype.Browser.Opera && !e.ctrlKey) {
					return;
				}
				that.show(e,element);
			});
		});
		
		
		
		/*$$(this.options.selector).invoke('observe', Prototype.Browser.Opera ? 'click' : this.options.mouseevent, function(e){
			if (Prototype.Browser.Opera && !e.ctrlKey) {
				return;
			}
			this.show(e);
		}.bind(this));*/
		

		Proto.MenuObjects[Proto.MenuObjects.length]=this;
	},
	show: function(e,element) {
		if(this.options.menuItems.split('_')[0]=='menu')
			alert(1);
		else
			this.options.evalmenuItems=eval(this.options.menuItems);
		var list = new Element('ul');
		var that=this;
		optionlist='';
		if(element.attributes.optionlist)
			var optionlist=eval(element.attributes.optionlist.value);
		this.options.evalmenuItems.each(function(item) {
			if((!item.check) || (eval('optionlist[0].'+item.check))){
				list.insert(
					new Element('li', {className: item.separator ? 'separator' : ''}).insert(
						item.separator 
							? '' 
							: Object.extend(new Element('a', {
								href: 'javascript:dynasite()',
								title: item.name,
								className: (item.className || '') + (item.disabled ? ' disabled' : ' enabled')
							}), { _callback: item.callback })
							.observe('click', 
								function(e){
									that.onClick(e,element)
								}
							)
							.observe(this.options.mouseevent, Event.stop)
							.update(item.name)
					)
				)
			}
		}.bind(this));
		this.container.innerHTML='';
		$(document.body).insert(this.container.insert(list).observe(this.options.mouseevent, Event.stop));
		if (this.ie) { $(document.body).insert(this.shim) }		
		
		Proto.MenuObjects.each(function(thisitem) {
			thisitem.options.beforeHide(e);
			if (thisitem.ie) thisitem.shim.hide();
			thisitem.container.hide();  
		});		
		
		Event.stop(e);
		this.options.beforeShow(e);
		var x = Event.pointer(e).x,
			y = Event.pointer(e).y,
			vpDim = document.viewport.getDimensions(),
			vpOff = document.viewport.getScrollOffsets(),
			elDim = this.container.getDimensions(),
			elOff = {
				left: ((x + elDim.width + this.options.pageOffset) > vpDim.width 
					? (vpDim.width - elDim.width - this.options.pageOffset) : x) + 'px',
				top: ((y - vpOff.top + elDim.height) > vpDim.height && (y - vpOff.top) > elDim.height 
					? (y - elDim.height) : y) + 'px'
			};
		this.container.setStyle(elOff).setStyle({zIndex: this.options.zIndex});
		if (this.ie) { 
			this.shim.setStyle(Object.extend(Object.extend(elDim, elOff), {zIndex: this.options.zIndex - 1})).show();
		}
		this.options.fade ? Effect.Appear(this.container, {duration: 0.25}) : this.container.show();
		this.event = e;
	},
	onClick: function(e,element) {
		e.stop();
		if (e.target._callback && !e.target.hasClassName('disabled')) {
			this.options.beforeSelect(e);
			if (this.ie) this.shim.hide();
			this.container.hide();
			e.target._callback(this.event,element);
		}
	}
})
//End

// ***************************
// * START ContextMenu       *
// ***************************
context_onmouseout_space=25; //spacer which has to close "context" on mouse over
context_mouse_to_closer=10; // space between mouse and onmouseover-space to close the context
context_mouse_to_context=2; // space between mouse and context
context_mouse_space=context_mouse_to_closer+context_mouse_to_context;

function DSContextHide(){
	if ($("context") != null){
		$("context").style.display="none";
		if (ie)
			$("context_ie_help").style.display="none";
	}
}

function DSDoNothing() {
	
}

function dynasite() {}

function DSContextInnerHTML(this_content, onmouseout){
	context_div=$("context");
	context_div.IsMouseOver=0;
	//context_div.innerHTML='<div style="width:320px; height:200px">dasdsad</div>';
	//onmouseout_color='blue';
	//mouse_space_color='red';
	onmouseout_color=mouse_space_color='transparent';
	if (onmouseout==1){
		new_htm_str='<table cellpadding="0" cellspacing="0" border="0" style="background-color: transparent; position:relative; top:0px; left:0px;">';
		new_htm_str+='<tr>';
			new_htm_str+='<td style="background-color: '+onmouseout_color+';" colspan="3" onmouseover="DSContextHide()" height="'+context_onmouseout_space+'"> </td>';
		new_htm_str+='</tr>';
		new_htm_str+='<tr>';
			new_htm_str+='<td style="background-color: '+onmouseout_color+';" onmouseover="DSContextHide()" width="'+context_onmouseout_space+'"></td>';
			new_htm_str+='<td>';
				new_htm_str+='<table cellpadding="0" cellspacing="0" border="0" style="background-color: transparent;">';
				new_htm_str+='<tr>';
					new_htm_str+='<td style="background-color: '+mouse_space_color+';" colspan="3" height="'+context_mouse_space+'"></td>';
				new_htm_str+='</tr>';
				new_htm_str+='<tr>';
					new_htm_str+='<td style="background-color: '+mouse_space_color+';" width="'+context_mouse_space+'"></td>';
					new_htm_str+='<td style="background-color: '+mouse_space_color+';">'+this_content+'</td>';
					new_htm_str+='<td style="background-color: '+mouse_space_color+';" width="'+context_mouse_space+'"></td>';
				new_htm_str+='</tr>';
				new_htm_str+='<tr>';
					new_htm_str+='<td style="background-color: '+mouse_space_color+';" colspan="3" height="'+context_mouse_space+'"></td>';
				new_htm_str+='</tr>';
				new_htm_str+='</table>';
			new_htm_str+='</td>';
			new_htm_str+='<td style="background-color: '+onmouseout_color+';" onmouseover="DSContextHide()" width="'+context_onmouseout_space+'"></td>';
		new_htm_str+='</tr>';
		new_htm_str+='<tr>';
		new_htm_str+='<td colspan="3" style="background-color: '+onmouseout_color+';" onmouseover="DSContextHide()" height="'+context_onmouseout_space+'"> </td>';
		new_htm_str+='</tr>';
		new_htm_str+='</table>';
		//context_div.innerHTML='<textarea cols=30 rows=30>'+new_htm_str+'</textarea>';
		context_div.innerHTML=new_htm_str;
	}
	else{
		new_htm_str='<table cellpadding="0" cellspacing="0"><tr><td style="background-color: '+mouse_space_color+'; padding:'+context_mouse_to_context+'px">';
		new_htm_str+=this_content;
		new_htm_str+='</td></tr></table>';
		context_div.innerHTML=new_htm_str;
	}
}

function DSContextShow(e,this_content,info){
	if (dcbe==null)
		DSInit()
	context_div=$("context");
	x_show="right";//left,middle,right
	y_show="bottom";//top,middle,bottom
	onmouseout=1; // 0: no function, 1: onmouseout context will be closed
	if (typeof info!='undefined' && info!=''){
		this_info=info.split(';');
		for (i=0;i<this_info.length;i++){
			eval(this_info[i])
		}
	}
	if (onmouseout)
		onmouseout_space=context_onmouseout_space;
	else
		onmouseout_space=0;
	if($(this_content)){
		this_content=$(this_content).innerHTML;
	}
	if (typeof this_content != 'undefined' && this_content != ''){
		DSContextInnerHTML(this_content,onmouseout);
	}

	context_div.style.display="block";
	this_left=DSContextPos(e,context_div,'x',x_show,onmouseout);
	this_top=DSContextPos(e,context_div,'y',y_show,onmouseout);
	
	context_div.style.left=this_left+'px';
	context_div.style.top=this_top+'px';
	if (ie){
		context_iframe=$("context_ie_help");
		if (onmouseout){
			this_left= DSInt(this_left+context_mouse_space+context_onmouseout_space);
			this_top= DSInt(this_top+context_mouse_space+context_onmouseout_space);
		}
		else{
			this_left= DSInt(this_left+context_mouse_to_context);
			this_top= DSInt(this_top+context_mouse_to_context);
		}
		context_iframe.style.top = this_top+'px';
	    context_iframe.style.left = this_left+'px';
		context_iframe.style.width = this_width+'px';
		context_iframe.style.height = this_height+'px';
	    context_iframe.style.zIndex = context_div.style.zIndex - 1;
	    context_iframe.style.display = "block";
		//context_iframe.style.border = "1px solid blue";
	}
}

function DSContextPos(e,this_object,xy,show,onmouseout){
	if (onmouseout){
		onmouseout_space=context_onmouseout_space;
		mouse_to_closer=context_mouse_to_closer;
		mouse_to_context=context_mouse_to_context;
		mouse_space=context_mouse_space;
	}
	else{
		onmouseout_space=0;
		mouse_to_closer=0;
		mouse_to_context=context_mouse_to_context;
		mouse_space=context_mouse_to_context;
	}
	if (xy=='x'){
		this_width = DSInt(this_object.offsetWidth-2*onmouseout_space-2*mouse_space);
		xlim = DSInt((dcbe && dcbe.clientWidth)? dcbe.clientWidth : window.innerWidth) + DSInt(window.pageXOffset || (dcbe? dcbe.scrollLeft : 0) || 0) ;
		pos = DSInt(e.pageX || e.clientX || 0) + DSInt(ie? dcbe.scrollLeft : 0);
		this_size=this_width;
		this_lim=xlim;
		//alert(this_size+'...'+this_lim+'...'+pos+'...'+DSInt(e.pageX || e.clientX || 0)+'...'+DSInt(ie? dcbe.scrollLeft : 0)+'...'+ie)
	}
	else{
		this_height = DSInt(this_object.offsetHeight-2*onmouseout_space-2*mouse_space);
		ylim = DSInt((dcbe && dcbe.clientHeight)? dcbe.clientHeight : window.innerHeight) + DSInt(window.pageYOffset || (dcbe? dcbe.scrollTop : 0) || 0) ;
		pos = DSInt(e.pageY || e.clientY || 0) + DSInt(ie? dcbe.scrollTop : 0);
		this_size=this_height;
		this_lim=ylim;
		//alert(this_size+'...'+this_lim+'...'+pos+'...'+DSInt(e.pageY || e.clientY || 0)+'...'+DSInt(ie? dcbe.scrollTop : 0)+'...'+ie)	
	}
	
	if (show=='top' || show=='left'){
		check_pos=pos-this_size-mouse_to_context;
		if (check_pos>=0)
			pos=pos-onmouseout_space-mouse_space-this_size-mouse_to_context;
		else
			pos=pos-onmouseout_space-mouse_to_closer;
	}
	else if (show=='middle'){
		check_pos=DSInt(pos-this_size/2);
		if (check_pos<=0)
			pos=-onmouseout_space-mouse_space;
		else if (check_pos+this_size/2>=this_lim)
			pos=this_lim-this_size-onmouseout_space-mouse_space;
		else
			pos=check_pos-onmouseout_space-mouse_space;
	}
	else if (show=='bottom' || show=='right'){
		check_pos=pos+this_size+mouse_to_context;
		if (check_pos<=this_lim){
			pos=pos-onmouseout_space-mouse_to_closer;
		}
		else{
			pos=pos-onmouseout_space-mouse_space-this_size-mouse_to_context;
		}
	}
	return pos;
}
// ***************************
// * END ContextMenu         *
// ***************************



/* DS Slider used in Assets */
function theslider(element,thewindowobject) {
	thewindowobject[element+'_slider'] = new Control.Slider(element+'_handle',element+'_track',{
		maximum:30,
		minimum:5,
		step:0.5,
		increment:0.5,
		range:$R(5,30),
		disabled:sliderDisabled,
		sliderValue:sliderValue,
		handleImage:'dssliderbutton',
		onSlide:function(v){
			// zoomboxes are set in _asset_view.cfm
			// zoomboxes=$(element).select('[name="'+element+'_zoombox"]');
			zoomboxes.each(function(s) { 
				Element.setContentZoom(s, (v+0.25)*7);
			});
		},
		onChange:function(v){
			// zoomboxes=$(element).select('[name="'+element+'_zoombox"]');
			zoomboxes.each(function(s) { 
				Element.setContentZoom(s, (v+0.25)*7);
			});
		 	$(element+'_dsslidervalue').value=v;
		}
	});
}





if (typeof(dynasite) == "undefined") { dynasite = {}; }
/* DSSliderBox: */
dynasite.DSSliderBox = {
	productSlider: null,
	sliderVal: 0,
	animationId: false,
	// viewportWidth: 980,
	// contentWidth: 980,
	 /* init with offsets, this can be overridden at init */
	categories: [{id: 'pb-cat1', offset: 0}, {id: 'pb-cat2', offset: 0.32}],
	isSliding: false,
	lastX: 0.5,
	isMouseDown: false,
	dif: 0,
	overlap: 0,
	offsetImageWidth: 0,
	sliderOffset: 0,
	// offsetContentWidth: -980,
	clicked: false,
	startIndex: 0,
	name: 'webmart',
	arrowScrollAmount: 0.24,
	init: function(setupArgs) {
		if (typeof(setupArgs.categories) != 'undefined') {this.categories = setupArgs.categories;}
		if (typeof(setupArgs.imageOverlap) != 'undefined') {this.overlap = setupArgs.imageOverlap;}
		if (typeof(setupArgs.sliderCentering) != 'undefined') {this.sliderOffset = setupArgs.sliderCentering;}
		if (typeof(setupArgs.initialCategory) != 'undefined') {this.startIndex = setupArgs.initialCategory;}
		if (typeof(setupArgs.arrowScrollAmount) != 'undefined') {this.arrowScrollAmount = setupArgs.arrowScrollAmount;}

		$('dssliderbox_content').style.display = "block";

		$('dssliderbox_track').style.visibility = "visible";
		$('dssliderbox_container').style.overflow = "hidden";
		
		this.viewportWidth = $('dssliderbox_container').getWidth();
		this.offsetImageWidth = $$('#dssliderbox_content .dssliderbox_image')[0].getWidth()-this.overlap;
		this.contentWidth = this.offsetImageWidth * $$('#dssliderbox_content .dssliderbox_image').length;
		this.offsetContentWidth = -1 * (this.contentWidth - this.viewportWidth);
		
		this.productSlider = new Control.Slider('dssliderbox_handle', 'dssliderbox_track', {axis:'horizontal'});
		/* initial slide */
		dynasite.DSSliderBox.animateSlide(this.categories[this.startIndex].offset); 
		/* Slider callbacks */
		this.productSlider.options.onChange = function(value) {
			$('dssliderbox_handleimage').style.left = $('dssliderbox_handle').style.left;
			
			if (dynasite.DSSliderBox.isThrow && ! dynasite.DSSliderBox.isSliding) {
				dynasite.DSSliderBox.isSliding = true;
				dynasite.DSSliderBox.isThrow = false;
				
				var mod = value + dynasite.DSSliderBox.throwMod;
				if (mod < 0) {mod = 0;}
				if (mod > 1) {mod = 1;}
				dynasite.DSSliderBox.animateSlide(mod);
			}
			else if (! dynasite.DSSliderBox.isSliding && value){
				dynasite.DSSliderBox.isSliding = true;
				dynasite.DSSliderBox.animateSlide(value);
			}	
		};
		this.productSlider.options.onSlide = function(value) {		 
			$('dssliderbox_handleimage').style.left = $('dssliderbox_handle').style.left;
			if (value && ! dynasite.DSSliderBox.isSliding) {
					dynasite.DSSliderBox.isSliding = true;
				 	dynasite.DSSliderBox.isThrow = false;
					if (dynasite.DSSliderBox.isMouseDown) {
						dynasite.DSSliderBox.dif = value - dynasite.DSSliderBox.lastX;
						dynasite.DSSliderBox.lastX = value;	
						
						/* check for throw, the dif thresholds will affect how easily the throw happens */
						if(dynasite.DSSliderBox.dif > 0.05) {
							dynasite.DSSliderBox.isThrow = true;
							dynasite.DSSliderBox.throwMod = 0.2;
						}
						else if (dynasite.DSSliderBox.dif < -0.04) {
							dynasite.DSSliderBox.isThrow = true;
							dynasite.DSSliderBox.throwMod = -0.2;
						}
					}
			
					var w = dynasite.DSSliderBox.offsetContentWidth;
					$('dssliderbox_content').style.left = w * value + "px";
					
					this.sliderVal = value;
					dynasite.DSSliderBox.lastX = value;
					dynasite.DSSliderBox.colorCats();		
					dynasite.DSSliderBox.isSliding = false; /* reset */
			}
			
			Element.setStyle($('dssliderbox_container'), { overflow: "hidden"} );
		};
		
		Event.observe('dssliderbox_track', 'mousedown', function(e) {
			var o = e.offsetX || e.layerX;
			if (Event.element(e).id =='dssliderbox_track' && o < 100) {dynasite.DSSliderBox.animateSlide(0);}
		});
		Event.observe('dssliderbox_leftarrow', 'mousedown', function() {
			dynasite.DSSliderBox.left();
		});
		Event.observe('dssliderbox_rightarrow', 'mousedown', function() {
			dynasite.DSSliderBox.right();
		});
		
		Event.observe('dssliderbox_handle', 'mousedown', function() {
			dynasite.DSSliderBox.isMouseDown = true;
			$('dssliderbox_handle').style.zIndex = "5";
		});
		
		Event.observe('dssliderbox_handle', 'mouseup', function() {
			dynasite.DSSliderBox.isMouseDown = false;
		});
		
		dynasite.DSSliderBox.categories.each(function(c) {
			Event.observe($(c.id), 'mouseup', function(e) {
				dynasite.DSSliderBox.animateSlide(c.offset);
			});
		});			
	},
	
	animateSlide: function(toX) {
		/* make sure toX is sane: */
		if (toX > 1) {toX = 1;}
		if (toX < 0) {toX = 0;}
		dynasite.DSSliderBox.sliderVal = toX;
		window.clearInterval(dynasite.DSSliderBox.animationId); /* kill any running animation */
		var w = dynasite.DSSliderBox.offsetContentWidth;
		var stopPoint = w * toX;
		/* stopPoint = Math.round(stopPoint / dynasite.DSSliderBox.offsetImageWidth) * dynasite.DSSliderBox.offsetImageWidth; */
		var sliderStopPoint = (Math.round(dynasite.DSSliderBox.viewportWidth - dynasite.DSSliderBox.sliderOffset) * toX);
		
		dynasite.DSSliderBox.isSliding = true;
		

		dynasite.DSSliderBox.animationId = window.setInterval(function() {
			var sliderPos = parseInt($('dssliderbox_content').getStyle('left')) || 0;
			var handlePos = parseInt($('dssliderbox_handle').getStyle('left')) || 0;
			var x = dynasite.DSSliderBox.calculateDecel(sliderPos, stopPoint);
			var sx = dynasite.DSSliderBox.calculateDecel(handlePos, sliderStopPoint); 
			$('dssliderbox_content').style.left = x + "px";
			$('dssliderbox_handle').style.left = sx + "px";
			$('dssliderbox_handleimage').style.left = sx + "px";		
			dynasite.DSSliderBox.colorCats();
		
			if (x == stopPoint) {
				window.clearInterval(dynasite.DSSliderBox.animationId);
				dynasite.DSSliderBox.isSliding = false;			
			}
		}, 60);
	},
	
	colorCats: function() {
		var sliderX = parseInt($('dssliderbox_handle').getStyle('left')) + (($('dssliderbox_handle').getWidth()-20)/2);
		dynasite.DSSliderBox.categories.each(function(c) {
			var left = parseInt($(c.id).getStyle('left')) 
		 	var clr = Math.ceil((Math.min(sliderX,left) / Math.max(sliderX,left))*10);
		 	$(c.id).className = 'pb-catclass'+clr;
		});
	},
	
	left: function() {
		dynasite.DSSliderBox.animateSlide(dynasite.DSSliderBox.sliderVal - dynasite.DSSliderBox.arrowScrollAmount);
	},
	
	right: function() {
		dynasite.DSSliderBox.animateSlide(dynasite.DSSliderBox.sliderVal + dynasite.DSSliderBox.arrowScrollAmount);
	},
	
	calculateDecel: function(from, to) {
		var n = from - Math.floor( (from - to) * .4);
		if (Math.abs(from - to) < 4) {return to;}
		else {return n;}
	}
};

/* END DS Slider used in Assets */

/* DS roundedCorner */
// DSRoundedCorner('[class="dsarticle_3 dsarticle"], [class="dsarticle_2 dsarticle"]','top,bottom,both','##F0F0E7','size:medium');
function DSRoundedCorner(selector,corner,color,optionlist){
	var i;
	var v=$('dssubbody').getElementsBySelector('['+selector+']');
	size='medium';
	backgroundColor='#FFF';		
	DSOptionList(optionlist);
	for(i=0;i<v.length;i++){
		if(corner=='top' || corner=='both' || corner=='top,bottom')
			DSRoundedCorner_Add(v[i],backgroundColor,color,size,'top');
		if(corner=='bottom' || corner=='both'|| corner=='top,bottom')
			DSRoundedCorner_Add(v[i],backgroundColor,color,size,'bottom');
	}
}

function DSRoundedCorner_Add(el,bk,color,size,addtype) {
	var i;
	var d=document.createElement("b");
	var cn="dsrounded";
	var lim=4;
	if(size && size=="small"){ cn="dsroundedsmall"; lim=2}
	if(size && size=="wide"){ cn="dsroundedwide"; lim=12}
	d.style.backgroundColor=bk;
	if(addtype=='top') {
		d.className="dsroundedtop";
		for(i=1;i<=lim;i++) {
				var x=document.createElement("b");
				x.className=cn + i;
				x.style.backgroundColor=color;
				d.appendChild(x);
		}
		el.insertBefore(d,el.firstChild);
	}
	else {
		d.className="dsroundedbottom";
		for(i=lim;i>0;i--) {
			var x=document.createElement("b");
			x.className=cn + i;
			x.style.backgroundColor=color;
			d.appendChild(x);
		}
		el.appendChild(d,el.firstChild);
	}
}

/* END DS roundedCorner */

/* DS Tree */
// DispatchEvent=moz FireEvent=ie
function DSDispatchEvent(theobject) {
	//	alert(theobject);

	// alert(theobject);
	obj=$(theobject);
	if(obj!=null) {
		if(ie)
			obj.fireEvent('onclick');							
		else {
			if(document.createEvent && obj.dispatchEvent) {
				var evt=document.createEvent("MouseEvents");
				if(evt && evt.initMouseEvent){
					evt.initMouseEvent("click",true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);
					obj.dispatchEvent(evt);
				}
			}
		}
	}
}

function DSGetParentNodes(thetree,objID){
	var parent_nodes=[];
	var i;
	if ($(objID)){
		this_node=$(objID);
		for (i=0;i<50;i++){
			this_node=this_node.parentNode;
			if (this_node.id==thetree)
				break;
			else
				parent_nodes[parent_nodes.length]=this_node
		}
	}
	return parent_nodes;
}

function DSGetChildNodes(objID){
	var child_nodes=[];
	var i;
	if ($(objID)){
		this_node=$(objID);
		for (i=0; i<this_node.childNodes.length; i++){
			child_nodes[child_nodes.length]=this_node.childNodes[i];
		}
	}
	return child_nodes;
}

function DSTree_Opener(optionlist){
	var i=0;
	treename='';
	treeid='';
	objID='';
	dispatchevent=0;
	treeitemid='';
	DSOptionList(optionlist);
	if(treeid=='')
		treeid='DSTree_'+treename;
	objID=treeid+'_'+treeitemid+'_link';
	// alert('Obj:'+objID+'TreID:'+treeid);
	if($(objID)) {
		theul=$(objID).up('ul',0);
		if($(theul)) {
			while($(theul).id!=treeid) {
				$(theul).style.display='block';
				theul=$(theul).up('ul',0);
			}
		}
		if($(objID) && dispatchevent==1) {
			// alert(4);
			DSDispatchEvent(objID);
		}
	}
}


/* END DS Tree  */

/* DSSelectRow */
var DSSelectRow_ID='';
var DSSelectRow_lastrow='';
var DSSelectRow_lastrow_color='';
var DSSelectRow_lastrow_class='';

function DSSelectRow(thisrow,thisid) {
	if(DSSelectRow_lastrow!='') {
		DSSelectRow_lastrow.className=DSSelectRow_lastrow_class;
	}
	DSSelectRow_ID=thisid;
	DSSelectRow_lastrow=thisrow;
	DSSelectRow_lastrow_class=thisrow.className;	
	thisrow.className='dslist_selected';
}

/* END DSSelectRow */

// ******************************
// * START GUI Tree/TabBar/Accordion 
// ******************************

function DSTree(e,name,element,optionlist) {
	onclickevent='display';
	reloadtype='display';
	showcontent=1;
	dstreeitemdepth=0;
	expand=1;
	IsLoaded=0;
	dispatchTabBar=1;
	cmd='';
	xhr=0;
	var QueryString='';
	var ActiveCommandBarElement='';
	DSOptionList(optionlist);
		
	// Start ALL
	if(cmd!='')
		IsLoaded=top.DSFindLoader_Loaded(element,this.window);
	if($(element) && $(element).innerHTML.length==0)
		IsLoaded=-1;
	if(cmd!='' && $(element) && $(element).innerHTML.length==0 && IsLoaded<=0)
		onclickevent='load';
	// alert('Name:'+name+' Element:'+element+' IsLoaded:'+IsLoaded+' onclickevent:'+onclickevent);
	if((IsLoaded<=0 && onclickevent=='load') || (IsLoaded>=0 && reloadtype=='reload') || (cmd!= '' && e.ctrlKey && $(element)) || (cmd!= '' && e.metaKey && $(element))) {
		e.cancelBubble = true;
		if (e.stopPropagation) {
			e.preventDefault();			
			e.stopPropagation();
		}
		// 2008-06-30 [AP]
		if (element!=cmd)
			QueryString='&DSElement='+element;
		// 2008-06-16 [AP]
		if ($(name).readAttribute('commandbarelement')!='')
			QueryString+='&DSCommandBarElement='+$(name).readAttribute('commandbarelement');
		
		
		if ($(name).readAttribute('commandbarelement')!='') {
			ActiveCommandBarElement=$($(name).readAttribute('commandbarelement')).readAttribute('active');
			if (ActiveCommandBarElement!='' && ActiveCommandBarElement!=null && $(ActiveCommandBarElement))		
				$(ActiveCommandBarElement).style.display='none';
		}
		
		dsloader(dsxpath+'dynasite.cfm?'+cmd+'&DSRefresh=1'+QueryString,'dsloader',element,'xhr:'+xhr);
	}
	else if ($(name).readAttribute('commandbarelement')!='' && expand==0){
		// 2008-06-19 [AP] GUI Element	
		DSDistributor('element:'+element+',guielement:'+$(name).readAttribute('commandbarelement')+',display:1,type:DisplayGuiPlace');
	}

	// End All
	/*	// if(Event.element(e).readAttribute('expander')==1)
	if(Event.element(e).tagName=='IMG' || $(id).up(0).tagName=='A') {
		var expanderem=Event.element(e).up(0);
		innercode=$(expanderem).innerHTML;
		if(innercode.indexOf("maxi") != -1 ) {
			$(expanderem).innerHTML=top.DSTree_Expander_Opened;
		}
		else if (expand==1) {
			$(expanderem).innerHTML=top.DSTree_Expander_Closed;
		}		
		
	}*/
	if($(name+'_'+id+'_arrow')) {
		innercode=$(name+'_'+id+'_arrow').innerHTML;
		if(innercode.indexOf("maxi") != -1 ) {
			$(name+'_'+id+'_arrow').innerHTML=top.DSTree_Expander_Opened;
		}
		else if (expand==1 && innercode.indexOf("mini") != -1 ) {
			$(name+'_'+id+'_arrow').innerHTML=top.DSTree_Expander_Closed;
		}	
	}
	// expand function
	if(expand==1 && $(name+'_'+id+'_list')) {
		if(innercode.indexOf("<img") != -1) {
			DSStyle(name+'_'+id+'_list','effect:1,displayshowhide:1,dsnavname:'+name+element+',writingmode:'+name+'_'+element+'_arrow');
		}
		else {
			DSStyle(name+'_'+id+'_list','effect:1,displayshowhide:1,dsnavname:'+name+element);
		}
	}
	if(showcontent==1) {
		DSStyle(element,'display:1,dsnavname:'+name+'_Content');
		DSStyle(element+'_context','display:1,dsnavname:'+name+'_context');
		
		if($(name+'_'+id+'_list')) {
			$(name+'_'+id+'_list').style.display='block';
		}
		if($(name+'_'+id+'_arrow') && innercode.indexOf("<img") != -1)
			$(name+'_'+id+'_arrow').style.writingMode='tb-rl';
		// alert(name+'_'+id,'classname:'+style+',dsnavname:'+name);
		if($(name).readAttribute('active')!='')
			var activeobject=name+'_'+$(name).readAttribute('active');
		else
			var activeobject=name+'_'+element;
		$(activeobject+'_link').removeClassName('dstree_explorer_active');
		$(name+'_'+id+'_link').addClassName('dstree_explorer_active');
	$(name).writeAttribute('active',id);

	}
	// TabBar
	var tabbaroption=$(name).readAttribute('tabbar');
	if(DSJS.Len(tabbaroption)) {
		var tabBar=DSJS.ListGetAt(tabbaroption,1,',');
		var tabBar_Element=DSJS.ListGetAt(tabbaroption,2,',');
		var tabBar_Style=DSJS.ListGetAt(tabbaroption,3,',');
		if(dispatchTabBar==1) {
			if($(tabBar_Element)) {
				$('aDSTabBar_'+tabBar_Element+'_'+tabBar_Element).setAttribute('tree',element);
				if($(tabBar_Element).style.display=='none'){
					DSTabBar(e,tabBar_Element,tabBar_Element,'style:'+tabBar_Style+',position:1,dispatchTabBar:1');
				}
			}
		}
	}
	// if(this.window.name=='dsmanager') {
	//	if(this.window.name=='dsmanager' && element=='calendar_calendar_calendar_view_'+DSUID)
	//		$('ds_calendar_month_small_'+DSUID).style.display='block';
	//	else
	//		$('ds_calendar_month_small_'+DSUID).style.display='none';
	// }
	DSTree_Opener('treeid:'+name+',treeitemid:'+element);
	DSPopUpResize();
}

function DSBrowserTabBar() {
	
	
}

function DSTabBar(e,name,element,optionlist) {
	// 2006-10-25 [AP] New, Option Position & Recordcount, wird für die DSTabBar aquacenter benötigt
	onclickevent='display'; // 2008-11-13 [AP] Variable von onlick in onclickevent geändert. der variablen name onclick funktioniert nicht unter Safari
	reloadtype='display';
	cmd='';
	IsLoaded=0;
	position='';
	commandbar='';
	recordcount='';
	dispatchTabBar=0; // 2008-01-30 [AP] Wird von der DSTree Funktion ausgelöst
	xhr=0;
	var QueryString='';
	var ActiveElement='';
	var GuiElement=element;
	var CommandBarElement='';
	var AssignedCommandbar='';
	DSOptionList(optionlist);
	
	ParentNavigator=$('DSTabBar_'+name).readAttribute('parentnavigator');
	CommandBarElement=$('DSTabBar_'+name).readAttribute('commandbarelement');	
	
	// Start ALL
	if($('ankerDSTabBar_'+name+'_'+element)) {
		if($('ankerDSTabBar_'+name+'_'+element).readAttribute('display')) {
			if($('ankerDSTabBar_'+name+'_'+element).readAttribute('display')=='autodisplay')
				$('aDSTabBar_'+name+'_'+element).style.display='block';
				
		}
	}
	if(cmd!='')
		IsLoaded=top.DSFindLoader_Loaded(element,this.window);
	if($(element).innerHTML.length==0)
		IsLoaded=-1;
	if(cmd!='' && $(element) && $(element).innerHTML.length==0 && IsLoaded<=0)
		onclickevent='load';
	 // alert('Name:'+name+' Element:'+element+' IsLoaded:'+IsLoaded+' onclickevent:'+onclickevent);
	
	if((IsLoaded<=0 && onclickevent=='load') || (IsLoaded>=0 && reloadtype=='reload') || (cmd!= '' && e.ctrlKey && $(element))){
		e.cancelBubble=true;
		if (e.stopPropagation) e.stopPropagation();
		
		//2008-06-18 [AP]
		if (CommandBarElement!='') {
			if ($(CommandBarElement) && $($(CommandBarElement).readAttribute('active')))
				$($(CommandBarElement).readAttribute('active')).style.display='none';
			
			QueryString='&DSCommandBarElement='+CommandBarElement;
			
			ActiveElement=top.DSGUIObject_Active['DSTabBar_'+name];
			$('a'+ActiveElement).setAttribute('assignedcommandbar',$(CommandBarElement).readAttribute('active'));
			
			if(ParentNavigator!='')			
				$('aDSTabBar_'+ParentNavigator).setAttribute('assignedcommandbar',element+'_commandbar');		
		}
		dsloader(dsxpath+'dynasite.cfm?'+cmd+QueryString,'dsloader',element,'xhr:'+xhr);
	}
	// 2008-01-30 [AP] Wenn die commandbar ausserhalb vom command div sitzt muss diese ein und ausgeblendet werden
	else if (dispatchTabBar==0 && $(element).style.display=='none') {	
		
		AssignedCommandbar=$('aDSTabBar_'+name+'_'+element).readAttribute('assignedcommandbar');
		//if (DSCAID==2260)
		//	alert('AssignedCommandbar:'+AssignedCommandbar+'\nelement:'+element+'\name:'+name)
		
		if (typeof DSExplorer.GUIPlace.CommandBar=='object') {
			DSExplorer.GUIPlace.CommandBar.Element.each(function(s) { 
				if (s==element){
					AssignedCommandbar=null;
					$break;
				}
			}); 
		}					

		if (AssignedCommandbar!=null) {
			if (AssignedCommandbar!='none_commandbar' && $(AssignedCommandbar)){
				GuiElement=$(AssignedCommandbar).readAttribute('classelement');
				AssignedCommandbar='';
			}
			else
				AssignedCommandbar=',assignedcommandbar:'+DSJS.ReplaceNoCase(AssignedCommandbar,'_commandbar','','All');
		}
		else
			AssignedCommandbar='';
		if($('aDSTabBar_'+name+'_'+element).readAttribute('tree'))
			GuiElement=$('aDSTabBar_'+name+'_'+element).readAttribute('tree');		
		
		if ($('DSTabBar_'+name).readAttribute('commandbarelement') && $('DSTabBar_'+name).readAttribute('commandbarelement')!=null) {		
			dontdoit=0;
			if (typeof DSExplorer.GUIPlace.CommandBar=='object') {
				DSExplorer.GUIPlace.CommandBar.Element.each(function(s) { 
					if (s==GuiElement){
						dontdoit=1;
						$break;
					}
				}); 
			}					
			if (dontdoit==0) {
				activeelement=top.DSGUIObject_Active['DSTabBar_'+name];
				$('a'+activeelement).setAttribute('assignedcommandbar',$($('DSTabBar_'+name).readAttribute('commandbarelement')).readAttribute('active'));	
			}
			
		}
		// alert('element:'+GuiElement+',guielement:'+CommandBarElement+AssignedCommandbar+',display:1,type:DisplayGuiPlace');
		DSDistributor('element:'+GuiElement+',guielement:'+CommandBarElement+AssignedCommandbar+',display:1,type:DisplayGuiPlace');
		
		if(ParentNavigator!='')
			$('aDSTabBar_'+ParentNavigator).setAttribute('assignedcommandbar',$(CommandBarElement).readAttribute('active'));		
		
	}
	// End All
	
	// Display the Content Element of the Tab
	DSStyle(element,'display:1,dsnavname:'+name);
	// Display the Content Context Element of the Tab
	DSStyle(element+'_context','display:1,dsnavname:'+name+'_context');	
	// Change the Classes of Active tab to Inactive and Clicked Tab to Active
	if(style!='browsertab')
		DSStyle('DSTabBar_'+name+'_'+element,'classname:dstabbar_'+style+',recordcount:'+recordcount+',position:'+position+',dsnavname:DSTabBar_'+name);
	else {
		DSStyle('DSTabBar_'+name+'_'+element,'classname:dstabbar_'+style+',recordcount:'+recordcount+',position:'+position+',dsnavname:DSTabBar_'+name);
		
	}
	DSPopUpResize();
}




function DSAccordion(e,thiselement,element,cmd,optionlist) {
	onclickevent='display';
	reloadtype='display';
	boxelement='';
	effect=1;	
	palette=0;
	xhr=0;
	air=0;
	// style='classic';
	DSOptionList(optionlist,'=');
	// Start ALL
	if(cmd!='')
		IsLoaded=top.DSFindLoader_Loaded(element,this.window);
	if($(element).innerHTML.length==0)
		IsLoaded=-1;
	if(cmd!='' && $(element) && $(element).innerHTML.length==0 && IsLoaded<=0)
		onclickevent='load';
	// alert('CMD:'+cmd+' Name:'+name+' Element:'+element+' IsLoaded:'+IsLoaded+' onclickevent:'+onclickevent);
	if((IsLoaded<0 && onclickevent=='load') || (IsLoaded>=0 && reloadtype=='reload' && $(element).style.display=='none') || (cmd!= '' && e.ctrlKey && $(element))){
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		dsloader(dsxpath+'dynasite.cfm?'+cmd,'dsloader',element,'xhr:'+xhr);
	}
	// End ALL
	statusindicatorcode_element='writingmode:dsacc_'+element+'_arrow';
	if(style=='plusminus' || style =='plusminusaqua')
		statusindicatorcode_element='displayswitch:'+element+'_plusminus_';
	// 2007-02-01 [AP] New
	if(boxelement!='') {
		parentelement=DSFindParnetNodeByName(thiselement,boxelement);
		if(parentelement.style.borderRightWidth=='0px') 
        	borderwidth=2;
		else
			borderwidth=0;
		parentelement.style.borderRightWidth=borderwidth+'px';
		parentelement.style.borderBottomWidth=borderwidth+'px';
		parentelement.style.borderLeftWidth=borderwidth+'px';
	}
	if(group!='') {
		if(top['DSGUIObject_Active']['DSAccordion_'+group]==null)
			top['DSGUIObject_Active']['DSAccordion_'+group]=element;
		lastelement=top['DSGUIObject_Active']['DSAccordion_'+group];
		statusindicatorcode_lastelement='writingmode:dsacc_'+lastelement+'_arrow';
		if(style=='plusminus' || style =='plusminusaqua')
			statusindicatorcode_lastelement='displayswitch:'+lastelement+'_plusminus_';
		top['DSGUIObject_Active']['DSAccordion_'+group]=element;
		// alert('element: '+element+' lastelement: '+lastelement+' lastdisplay: '+$(lastelement).getStyle('display'));
		if(lastelement!=element && $(lastelement).getStyle('display')=='block')
			DSStyle(lastelement,'guitype:DSAccordion,style:'+style+',effect:'+effect+',palette:'+palette+',dsnavname:DSAccordion_'+group+',displayshowhide,'+statusindicatorcode_lastelement);
		DSStyle(element,'guitype:DSAccordion,style:'+style+',effect:'+effect+',palette:'+palette+',dsnavname:DSAccordion_'+group+',displayshowhide,'+statusindicatorcode_element);
	}
	else if(IsLoaded<=0 || reloadtype!='reload') {
		DSStyle(element,'guitype:DSAccordion,style:'+style+',air:'+air+',effect:'+effect+',palette:'+palette+',dsnavname:DSAccordion_'+element+',displayshowhide,resize:0,'+statusindicatorcode_element);
		// DSStyle(element,'guitype:DSAccordion,style:'+style+',dsnavname:DSAccordion_'+element+',resize:0,'+statusindicatorcode_element);
		// new Effect.Appear(element);
	}
}


function DSSortNavigation(thiscmd,sortorderelement,label,optionlist) {
	sort_window=DSLoader_getWindowObject(thiscmd);
	
	if (top['DSSortingNavigator_'+thiscmd]==null)
		top['DSSortingNavigator_'+thiscmd]=new Array();
	
	DSSortingNavigator=top['DSSortingNavigator_'+thiscmd];
	
	//if (DSCAID==2260)
	//	alert('nav: DSSortingNavigator_'+sortorderelement)
	
	if (sort_window.$(sortorderelement)!=null) {
		seperater='>';
		sortorder=0;
		lastelement='';
		DSOptionList(optionlist);
		DSSortingNavigator[sortorder]=label;
		seperater='<span class="dshead_sortorder_seperater">'+seperater+'</span>';
		if (sort_window.$(sortorderelement).innerHTML!=null) {
			sort_window.$(sortorderelement).innerHTML='';
			for(i=0;i<DSJS.ArrayLen(DSSortingNavigator);i++) {
				//alert(DSSortingNavigator[i]);
				if (i==0)
					lastelement=DSSortingNavigator[i];
				else
					sort_window.$(sortorderelement).innerHTML+=DSSortingNavigator[i]+seperater;
			}
			sort_window.$(sortorderelement).innerHTML+=lastelement;
		}
	}
}

// 2007-08-10 [AP]
function DSMultipleSort(e,theElement,element) {	
	if(e.ctrlKey || e.metaKey){
		DSSorting=new Array();
		LastElement='';
		ElementArray1=$(theElement).previousSiblings();
		ElementArray2=$(theElement).nextSiblings();
		// Join both Arrays
		ElementArray=ElementArray1.concat(ElementArray2); 	
		for(i=0;i<DSJS.ArrayLen(ElementArray);i++) {			
			if (DSJS.ListFindNoCase(ElementArray[i].className,'dshead_active',' ')) {
				if (ElementArray[i].readAttribute('sortorder')==0)
					LastElement=ElementArray[i].readAttribute('sortby')+'|'+ElementArray[i].readAttribute('sortdirection');
				else
					DSSorting[ElementArray[i].readAttribute('sortorder')]=ElementArray[i].readAttribute('sortby')+'|'+ElementArray[i].readAttribute('sortdirection');
			}
		}		
		if (LastElement!='')
			 DSSorting.unshift(LastElement);

		//DSJS.ArrayAppend(DSSorting,LastElement);
		// Deletes empty Array entries		
		DSSorting=DSSorting.compact();
		DSSorting=DSJS.ArrayToList(DSSorting,'@')+'@';	
		//alert(LastElement+'\n '+DSSorting);
		if ($(element)){
			$(element).setAttribute('multiplesorting',DSSorting);	
			//alert(element);
		}
		
		//if (DSSorting!='')
		//	top.DSLoader_URLAdd='&dssorting='+DSSorting;
	}
	else if ($(element)){
		$(element).setAttribute('multiplesorting','');		
		//alert('ms: DSSortingNavigator_'+element)
		if (top['DSSortingNavigator_'+element]!=null)
			delete top['DSSortingNavigator_'+element];
	}
	//top.DSLoader_URLAdd='';
}




function DSStyle(element,optionlist) {
	//Needed for Scriptaculous [TR] 07.08.07	
	dsnavname='';
	dsresize=1;
	palette=0;
	effect=0;
	air=0;	
	DSOptionList(optionlist);

	if(dsnavname!='')
		activeelement=top['DSGUIObject_Active'][dsnavname];
	//  alert('GUIName:'+dsnavname+' ElementIN:'+element+' Activeelement:'+activeelement);
	for (i=0; i<function_list.length; i++) {
		this_function=function_list[i].split(":")
		if (this_function[0]=='height')
			$(element).style.height=this_function[1];
		else if (this_function[0]=='classname'){
			if(this_function[1]=='dssystemmenu') {
				$(activeelement).className=this_function[1]+'_inactive';			
				$('a'+activeelement).className=this_function[1]+'_inactive';
				$(element).className=this_function[1]+'_active';			
				$('a'+element).className=this_function[1]+'_active';
			}
			else if(this_function[1]=='dstree_explorerXXXNOTMOREINUSE' || this_function[1]=='dstree_explorer_subXXXNOTMOREINUSE') {
				if(activeelement!=null && $(activeelement+'_link')!=null) {
					$(activeelement+'_listitem').className=this_function[1]+'_inactive';			
					$(activeelement+'_link').className=this_function[1]+'_inactive';
				}
				$(element+'_link').className=this_function[1]+'_active';
			}
			else if(this_function[1]=='dstabbar_narrow' || this_function[1]=='dstabbar_custom') {
				if($('anker'+activeelement)) {
					$('anker'+activeelement).className='';			
				}
				$('anker'+element).className='active';
				if (this_function[1]=='dstabbar_custom')
					$('anker'+element).className+=' DSTabBarCustomClass';
			}
			else if(this_function[1]=='dstabbar_straight') {
				if($(activeelement)) {
					$(activeelement).removeClassName('dstabbar_straighta');
				}
				$(element).addClassName('dstabbar_straighta');
			}
			else if(this_function[1]=='dstabbar_browsertab') {
				if($('a'+activeelement)) {
					$('a'+activeelement).removeClassName('tabTable-active');
				}
				$('a'+element).addClassName('tabTable-active');
			}			
			else {
				if($('a'+activeelement))
					$('a'+activeelement).className=this_function[1];
				if($('a'+element))					
					$('a'+element).className=this_function[1]+'a';
				if(this_function[1]=='dstabbar_aquacenter') {
					if (position==1) {
				 		$(element).previousSibling.className='dstabbar_aquacenter_spacer_left_active';
						$(dsnavname+'_spacer_right').className='dstabbar_aquacenter_spacer_right';
					}
					else if (position==recordcount) {
						$('a'+element).style.border='0px';
						$(element).nextSibling.className='dstabbar_aquacenter_spacer_right_active';
						$(dsnavname+'_spacer_left').className='dstabbar_aquacenter_spacer_left';
					}
					else {
						$(dsnavname+'_spacer_left').className='dstabbar_aquacenter_spacer_left';
						$(dsnavname+'_spacer_right').className='dstabbar_aquacenter_spacer_right';						
					}
				}
			}
		}
	
		else if (this_function[0]=='visibility'){
			$(activeelement).style.visibility="hidden";
			$(element).style.visibility="visible";
		}
		else if (this_function[0]=='writingmode' && $(this_function[1])) {
				innercode=$(this_function[1]).innerHTML;
				if(innercode.indexOf("foldeXXXXr") != -1 ) {
					if(innercode.indexOf("maxi") != -1 )
						$(this_function[1]).innerHTML=top.DSTree_Expander_Opened;
					else
						$(this_function[1]).innerHTML=top.DSTree_Expander_Closed;
				}
				else {
					if ($(this_function[1]).style.writingMode == "lr-tb")
						$(this_function[1]).style.writingMode = "tb-rl";
					else 
						$(this_function[1]).style.writingMode = "lr-tb";
				}
		}
		else if (this_function[0]=='display' ){
			if($(activeelement)) {
				// new Effect.Fade(activeelement);
				$(activeelement).style.display="none";
			}
			if($(element)) {
				//new Effect.Appear(element);
				$(element).style.display="block";
			}
		}
		else if (this_function[0]=='displayswitch') {
			if($(this_function[1]+'0').style.display=='inline') {
				$(this_function[1]+'0').style.display='none';
				$(this_function[1]+'1').style.display='inline';
			}
			else {
				$(this_function[1]+'1').style.display='none';
				$(this_function[1]+'0').style.display='inline';
			}
		}
		else if (this_function[0]=='hide')
			$(this_function[1]).style.visibility="hidden";
		else if (this_function[0]=='show')
			$(this_function[1]).style.visibility="visible";
		else if (this_function[0]=='displayhide')
			$(activeelement).style.display='none';
		else if (this_function[0]=='displayshow')
			$(element).style.display='block';
		else if (this_function[0]=='displayshowhide' && $(element)) {
			if($(element).getStyle('display')=="block") {
				//new Effect.Fade(element);
				if(effect==1){
					if(palette==1)
						new Effect.BlindUp(element,{duration:0.5,afterUpdate:DSPopupHelper,afterFinish:DSPaletteStyle});
					else if(palette==2)
						new Effect.BlindUp(element,{duration:0.5,afterUpdate:DSPopupHelper,afterFinish:paletteupdate});
					else{
						if(air==1)
							new Effect.BlindUp(element,{duration:0.5});
						else
							new Effect.BlindUp(element,{duration:0.5,afterUpdate:DSPopupHelper,afterFinish:DSPopupHelper});
					}
				}
				else{
					$(element).style.display="none";
					if(palette==1)
						DSPaletteStyle();
					else if(palette==2)
						paletteupdate();
				}
			}
			else {
				//new Effect.Appear(element);	
				if(effect==1){
					if(palette==1)
						new Effect.BlindDown(element,{duration:0.5,afterUpdate:DSPopupHelper,afterFinish:DSPaletteStyle});
					else if(palette==2)
						new Effect.BlindDown(element,{duration:0.5,afterUpdate:DSPopupHelper,afterFinish:paletteupdate});
					else{
						if(air==1)
							new Effect.BlindDown(element,{duration:0.5});
						else
							new Effect.BlindDown(element,{duration:0.5,afterUpdate:DSPopupHelper,afterFinish:DSPopupHelper});
					}
				}
				else{
					$(element).style.display="block";
					if(palette==1)
						DSPaletteStyle();
					else if(palette==2)
						paletteupdate();
				}
			}
		}
	}
	//alert('top.DSGUIObject_Active.'+dsnavname+'=element');
	if(dsnavname!='')
		top['DSGUIObject_Active'][dsnavname]=element;
	if(dsresize==1)
		DSPopUpResize();
}
function DSPopupHelper(){
	DSPopUpResize();
}

// ***************************
// * END TabBar/Accordion    *
// ***************************

// Sortable

var DSSortable = Class.create();

DSSortable.prototype = {
	initialize: function (options) {
		// Set Options
		this.setOptions(options);
		// Get sortable elements by classname
		if(this.options.portal=='dssubbody')
			var sortables = $(this.options.portal).select('.'+this.options.column);
		else
			var sortables = $(this.options.portal).select('.'+this.options.column).concat($(this.options.portal+'_context').select('.'+this.options.column));
		// Bind sortable function to each element in sotables variable
		sortables.each(function (sortable) {
			var that=this;
			Sortable.create(sortable, {
				containment: sortables,
				constraint: false,
				tag: this.options.tag,
				//only: this.options.block,
				elements:sortable.childElements().findAll(function(s) { return s.hasClassName(that.options.block)==true && s.hasClassName(that.options.block+'_nodrag')==false;}),
				dropOnEmpty: true,
				ghosting: this.options.ghosting,
				handle: this.options.handle,
				hoverclass: this.options.hoverclass,
				/* onChange: function (block) {	}.bind(this),*/
				onUpdate: function (container) {
					// poststring = Sortable.serialize(container);
					// alert(poststring);
					if (!this.options.saveurl)
						return;
					if (container.id == this.options.blocklist)
						return;
					var url = this.options.saveurl;
					var postBodyContent='';
					var blocks = $(container.id).select('.'+this.options.block);
					if(this.options.accordion==true){
						for(blockitem=0; blockitem<blocks.length;v++)						{
							commacode='';
							if(blockitem!=blocks.length-1)
								commacode=',';
							if(blocks[blockitem].getElementsByClassName('nix')[0].getStyle('display')=='block')
								styledisplay='block';
							else
								styledisplay='none';							
							postBodyContent+=blocks[blockitem].id+':'+styledisplay+commacode;
						}
					}
					else{
						if(this.options.portal=='dssubbody')
							postBodyContent += container.id+'='+blocks.pluck('id').join(',');
						else{
							var counter=1;
							sortables.each(function (sortable) {
								if(counter==1)		
									postBodyContent+='columnvalue='+sortable.id+'='+$(sortable.id).select('.'+that.options.block).pluck('id').join(',');
								else
									postBodyContent+='|'+sortable.id+'='+$(sortable.id).select('.'+that.options.block).pluck('id').join(',');
								counter+=1;
							});
						}
					}
					postBodyContent = '' + postBodyContent;					
					//alert(postBodyContent);
					new Ajax.Updater(this.options.portal+'_widgetsets',url, {method: 'post', postBody: postBodyContent});
				}.bind(this)
			});
		}.bind(this));
		// Get draggable elements by classname
		var blocks = $(this.options.portal).select('.'+this.options.block);
		// Bind block function to each element in blocks variable
		blocks.each(
			function (block) {
				if($(block).hasClassName(this.options.block+'_nodrag')==false){
					var content = Element.childrenWithClassName(block, this.options.content, true);
					var toggle = Element.childrenWithClassName(block, this.options.toggle, true);
					for (i=0;i<toggle.length;i++){
						Event.observe(toggle[i], 'click',function (e) { Effect.toggle(content[i], 'Slide'); },false);
					}
				}
			}.bind(this)
		);
		// Click-Event for displaying widget-list box -> onclickevent call displayBlockList Function
		if(this.options.blocklistlink!='')
			Event.observe(this.options.blocklistlink,'click',this.displayBlockList.bindAsEventListener(this),false);

		// Dragging for widget-list box
		if(this.options.blocklist!='' && this.options.blocklistdragging==1)
			new Draggable(this.options.blocklist, {handle: this.options.blocklisthandle});
	},
	
	displayBlockList: function (e) {
		Effect.toggle(this.options.blocklist,'blind');
		Event.stop(e);
	},

 	setOptions: function (options) {
		this.options = options;
		Object.extend(this.options, options || {});
	},
	// Append blocks to assigned containers
	applySettings: function (settings) {
		that=this;
		for (var container in settings) {
			$(container).select('.'+this.options.block).each(function (block) {
				$(that.options.blocklist).appendChild($(block));
			});
			settings[container].each(function (block) {
				$(container).appendChild($(block));
			});
		}
	}
}
// End Sortable



function dsformwait(wait,form,delay_msec){
	if(isNaN(delay_msec)==false) {
		window.setTimeout("DSStyle(\'"+form+"\','dsnavname:DSFormWait,displayshowhide:1');DSStyle(\'"+wait+"\','dsnavname:DSFormWait,displayshowhide:1');DSPopUpResize()",delay_msec);
	}
	else {
		DSStyle(wait,'dsnavname:DSFormWait,displayshowhide:1');
		DSStyle(form,'dsnavname:DSFormWait,displayshowhide:1')
		DSPopUpResize();
	}
}

// 2005-04-12 [AP]
function ds_dom_table_cellcontent(table){
	counter=counter+1;
	cellcontent_1 = '<input type="text" class="ds_text" name="dsipfilter_'+counter+'" id="dsipfilter_'+counter+'" value="" maxlength="15" />';
	cellcontent_2 = '<div style="width:180px" id="dsipfilterdelete_'+counter+'" onclick="ds_dom_table_deleterow(event);">['+DSLang('delete')+']</div>';
	ds_dom_table_insertrow(table,2);
	DSPopUpResize();
}

function ds_dom_table_insertrow(table,cells) {
	tbl = $(table);
	row = tbl.insertRow(-1);
	listclass='dslist2';
	if ($(table).rows.length/2==parseInt($(table).rows.length/2))
		listclass='dslist1';
	row.className=listclass;				
	for (repeater=1;repeater<cells+1;repeater++) {	
		td = row.insertCell(-1);
		if (typeof eval('cellcontent_'+repeater)=='object') {
			td.appendChild(eval('cellcontent_'+repeater));
		}
		else {
			td.innerHTML=eval('cellcontent_'+repeater);
		}
	}
}

function ds_dom_table_deleterow(e) {
	var searchfortable=ns6? e.target : event.srcElement;
	while(searchfortable.tagName!="TABLE") {
		if(searchfortable.tagName=="TR")
			rowindex=searchfortable.rowIndex;
		searchfortable=ns6? searchfortable.parentNode : searchfortable.parentElement;
	}
	searchfortable.deleteRow(rowindex);
}

function dsresizetextarea(element,smallheight,largeheight) {
	if($('resize_'+element).innerHTML=='[++]') {
		$(element).style.height=largeheight+'px';
		$('resize_'+element).innerHTML='[--]';
		$('dsacc_dseditor_'+element+'_option').innerHTML=$('DSEditorCall_'+element).innerHTML;
		if(tinyMCE.get(element)!=null)
			$(element+"_ifr").style.height=largeheight+'px';
	}
	else {
		$(element).style.height=smallheight+'px';
		$('resize_'+element).innerHTML='[++]';
		$('dsacc_dseditor_'+element+'_option').innerHTML=$('DSEditorCall_'+element).innerHTML;
		if(tinyMCE.get(element)!=null)
			$(element+"_ifr").style.height=smallheight+'px';
	}
	DSPopUpResize();
}

// ***************************
// * START DsPopUP           *
// ***************************
function dspopup_zindex(callerem) {
	if(callerem=='dspopup1'){
		if($('dspopup3').style.zIndex>$('dspopup2').style.zIndex*1)
			current=eval($('dspopup3').style.zIndex*1);
		else
			current=eval($('dspopup2').style.zIndex*1);		
	}
	else if(callerem=='dspopup2'){
		if($('dspopup1').style.zIndex>$('dspopup3').style.zIndex*1)
			current=eval($('dspopup1').style.zIndex*1);
		else
			current=eval($('dspopup3').style.zIndex*1);		
	}
	else if(callerem=='dspopup3'){
		if($('dspopup1').style.zIndex>$('dspopup2').style.zIndex*1)
			current=eval($('dspopup1').style.zIndex*1);
		else
			current=eval($('dspopup2').style.zIndex*1);		
	}
	else
		return;
	$(callerem).style.zIndex=eval(current+'*1+1');
}

// Popup Actions
function dspopup(command,callerem,receiver,receiverem,displayfirstem,actionurl) {
	this_function=command.split("|");
	if (this_function[0]=='display') {
		if(this_function[1]=='dspopup1_body' || this_function[1]=='dspopup2_body' || this_function[1]=='dspopup3_body') {
			display="none";
			if ($('popupcontent').style.display=="none")
				display="block";
			$('popupcontent').style.display=display;
			if($('dspopupresize'))
				$('dspopupresize').style.display=display;
			DSPopUpResize();
		}
	}
	if (this_function[0]=='close' || this_function[0]=='saveclose') {
		$(this_function[1]).style.display="none";
		// loadiframe('dscmd=document_document_document_unlock');
	}
}



function DSButton_Cancel(urlstring,optionlist) {
	cancelalert=0;
	DSOptionList(optionlist);
	if(cancelalert==1){
		cancelquestion=confirm(DSLang('alertclosewindow'));
		if(cancelquestion==false)
			return;
	}
	if(urlstring!=''){
		if(window.name=='MAIN_loader') {
			dsloader(urlstring,'dsloader');
			top.dsexplorer_action_height=0;
			top.DSSetFrames() ;
		}
		if(window.name=='dsmanager_loader') {
			dsloader(urlstring,'dsloader');
			top.dsmanager_action_height=0;
			top.DSSetFrames() ;
		}
	
		else {		
			target=DSLeft(window.name,8);
			dsloader(urlstring,'dsloader');
			parent.dspopup('close|'+target);
		
		}
	}
	else{
		target=DSLeft(window.name,8);		
		parent.dspopup('close|'+target);
	}
}


// DSPopUpResize('dspopup1','height:*,width:)
function DSPopUpResize(target,optionlist) {
	if($('dsformwaitcode')) {
		if($('dsformwaitcode').style.display=='block')
			return false;
	}
	if(target==null)
		target=window.name;

	if(target!='ds') {
// Wird nicht mehr benötig da es in dscommand gesetzt wird [TR] 02.08.07
//		if($('dspopupbody')!=null)
//			$('dspopupbody').className=window.name.split("_")[0];
		resize=0;
		width=0;
		height='*';
		DSOptionList(optionlist);
		if(resize!=0 && parent.dsloader1!=null)
			parent.dsloader1.resizeTo(this_function[1].split("|")[0],this_function[1].split("|")[1]);
		if(height!=0 && $("dspopupbody")) {
			if(target=='dspopup0')
				heightadd=0;
			if((window.name=='dspopup1_loader' || window.name=='dspopup2_loader' || window.name=='dspopup3_loader') && parent.$(target)!=null && eval('parent.'+window.name+'.document').getElementById("dspopupbody")!=null ) {
				parent.$(window.name).style.height=eval($("dspopupbody").offsetHeight+'*1')+'px';
				parent.$(window.name).height = eval($("dspopupbody").offsetHeight+'*1')+'px';
				temptarget=target.slice(0,8);
				parent.$(temptarget).style.height = eval($("dspopupbody").offsetHeight+'*1')+'px';
				//$('popupcontent').style.height = eval($("dspopupbody").offsetHeight+'*1')+'px';
			}
		}
		if(width!=0 && parent.$(target)!=null) {
			if (isNaN(width))
				width=width;
			else 
				width=width+'px';
			parent.$(target).style.width=width;
			parent.$(target+'_body').style.width=width;
			// parent.$(target+'_footer').style.width=width;
			// parent.$(target+'_title').style.width=this_function[1]-2;
			// parent.$(target+'_body').style.width=this_function[1];
			// parent.$(target+'_footer').style.width=this_function[1];
		}
	}
	if(Dialog!=null && Dialog.container && Dialog.visible()){
		Dialog.shadowUnder();
		if(parent.$(window.name) && parent.$(window.name).getHeight()<Dialog.container.cumulativeOffset()[1]+Dialog.container.getHeight()+5){
			parent.$(window.name).style.height=Dialog.container.cumulativeOffset()[1]+Dialog.container.getHeight()+5+"px"
			parent.$(window.name).height=Dialog.container.cumulativeOffset()[1]+Dialog.container.getHeight()+5+"px"
			temptarget=target.slice(0,8);
			parent.$(temptarget).style.height=Dialog.container.cumulativeOffset()[1]+Dialog.container.getHeight()+5+"px"
		}
	}
}

// ***************************
// * End DSPopUp             *
// ***************************

// ***************************
// * Start DragDrop          *
// ***************************


var dsdragapproved=false;
var dsdrag_z,dsdrag_x,dsdrag_y;
document.onmouseup=new Function("dsdragapproved=false");

function dsdrag(e,dragelement) {
	thedragelement=dragelement;
	dspopup_zindex(dragelement);
	dsdrag_z=$(dragelement);
	dsdrag_body=$(dragelement+'_body');
	dsdragapproved=true;
	if(dragelement=='dspopup2')
		startoffset=65;
	else if(dragelement=='dspopup3')
		startoffset=75;		
	else
		startoffset=50;
	if(dragelement=='dspopup1' || dragelement=='dspopup2' || dragelement=='dspopup3')
		dsdrag_body.style.display='none';
	temp1=parseInt(dsdrag_z.style.left+startoffset);
	temp2=parseInt(dsdrag_z.style.top+startoffset);
	dsdrag_x=ns6? e.clientX : event.clientX;
	dsdrag_y=ns6? e.clientY : event.clientY;
	document.onmousemove=dsdrag_move;
	return false;
}

function dsdrag_move(e) {
	if (dsdragapproved) {
		dsdrag_z.style.left=ns6? temp1+e.clientX-dsdrag_x+'px' : temp1+event.clientX-dsdrag_x+'px';
		// if(ie && parseInt(eventtop) > 20)
			dsdrag_z.style.top=ns6? temp2+e.clientY-dsdrag_y+'px' :  temp2+event.clientY-dsdrag_y+'px';
		eventtop=ns6? e.clientY :  event.clientY;
		if(ie && parseInt(eventtop) < 20 && (thedragelement=='dsm' || thedragelement=='dspopup1' || thedragelement=='dspopup2' || thedragelement=='dspopup3')) {
			document.onselectstart=new Function ("return false");
			dsdrag_z.style.top=ns6? e.clientY-dsdrag_y+15+'px' :  temp2+event.clientY-dsdrag_y+15+'px';
			dsdrag_body.style.display='block';
			// if(ie)
			// 	dsdrag_z.fireEvent('onmouseup');
			dsdragapproved=false;
			// document.onselectstart=new Function ("return true");
		}
		else
			return false;	
	}
}



//*****************
//* NewDSDragging *
//*****************
// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;


function dsdragstart(event,id,popup,el,option) {
  var el;
  var x, y;
  palette=0;
	if(option!=null) {
		DSOptionList(option);
	}
  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if(id){
	if(popup){
		dragObj.elNode = parent.$(id);
		parent.dspopup_zindex(id);
		//DSsetDocumentLock(true,dragObj.elNode);
	}
	else
		dragObj.elNode = $(id);
  }
  else {
    if (ie)
      dragObj.elNode = window.event.srcElement;
    else
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }
  // Get cursor position with respect to the page.
    x = event.screenX;
    y = event.screenY;
  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);
  dragObj.mouseDownWidth = parseInt(dragObj.elNode.style.width);
  dragObj.mouseDownHeight = parseInt(dragObj.elNode.style.height);  

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

//  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

	functionstopcode=dsdragstop;
	if(palette==1)
		functionstopcode=function (e) { dsdragstop(event,1);}
		
  if (ie) {
    parent.document.attachEvent("onmousemove", dsdraggo);
    parent.document.attachEvent("onmouseup",   functionstopcode);
    document.attachEvent("onmousemove", dsdraggo);
    document.attachEvent("onmouseup",   functionstopcode);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  else{
    parent.document.addEventListener("mousemove", dsdraggo,   true);
    parent.document.addEventListener("mouseup",   functionstopcode, true);
    document.addEventListener("mousemove", dsdraggo,   true);
    document.addEventListener("mouseup",   functionstopcode, true);
    event.preventDefault();
  }
}

function dsdraggo(event) {

  var x, y, top, left;

  // Get cursor position with respect to the page.

   x = event.screenX;
   y = event.screenY;

  // Move drag element by the same amount the cursor has moved.
  top=dragObj.elStartTop+y-dragObj.cursorStartY;
  top=top < 0 ? 0 : top;
  
  left=dragObj.elStartLeft+x-dragObj.cursorStartX;
  left=left < 0 ? 0 : left;

  dragObj.elNode.style.left = left + "px";
  dragObj.elNode.style.top  = top + "px";

  if (ie) {
	if(window.event==null){
		parent.window.event.cancelBubble = true;
		parent.window.event.returnValue = false;
	}
	else{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
  }
  else
    event.preventDefault();
}

function dsdragstop(event,palette) {
	if(palette!=null && palette==1)
		paletteupdate();
	
  // Stop capturing mousemove and mouseup events.
  if (ie) {
    parent.document.detachEvent("onmousemove", dsdraggo);
    parent.document.detachEvent("onmouseup",   functionstopcode);
    document.detachEvent("onmousemove", dsdraggo);
    document.detachEvent("onmouseup",   functionstopcode);
  }
  else {
    parent.document.removeEventListener("mousemove",dsdraggo,true);
    parent.document.removeEventListener("mouseup",functionstopcode,true);
    document.removeEventListener("mousemove",dsdraggo,true);
    document.removeEventListener("mouseup",functionstopcode,true);
  }
  //DSsetDocumentLock(false,dragObj.elNode);
}

function paletteupdate(){
	new Ajax.Request(DSAdminURL+'/dynasite.cfm?dscmd=system_palette_palette_position&left='+$('dspalette').getStyle('left')+'&top='+$('dspalette').getStyle('top')+'&open='+$('dspalette').getStyle('display')+'&minimize='+$('dspalette_content').getStyle('display'), {method: 'get'});	
}

function dsresizestart(event, id, ownobject) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id){
    dragObj.elNode = parent.$(id);
	parent.dspopup_zindex(id);
	dragObj.ownobject=ownobject;
  }
  else {
    if (ie)
      dragObj.elNode = window.event.srcElement;
    else (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

    x = event.clientX;

    y = event.clientY;


  // Save starting positions of cursor and element.
  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left,10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,10);
  dragObj.mouseDownWidth = parseInt(dragObj.elNode.style.width);
  dragObj.mouseDownHeight = parseInt(dragObj.elNode.style.height);   
  dragObj.Iframe=parent.$(id+'_loader');  

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

//  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (ie) {
    document.attachEvent("onmousemove", dsresizego);
    document.attachEvent("onmouseup", dsresizestop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  else {
    parent.document.addEventListener("mousemove",dsresizego2,true);
    parent.document.addEventListener("mouseup",dsresizestop,true);
    document.addEventListener("mousemove",dsresizego,true);
    document.addEventListener("mouseup",dsresizestop,true);

    event.preventDefault();
  }
}

function dsresizego(event) {
	width = dragObj.mouseDownWidth + (event.clientX - dragObj.cursorStartX);
	height = dragObj.mouseDownHeight + (event.clientY - dragObj.cursorStartY);

	width = width < 606 ? 606 : width;
	height = height < 100 ? 100 : height;


	dragObj.Iframe.style.width = (width) + 'px';
	dragObj.Iframe.style.height = (height) + 'px';
	dragObj.Iframe.width = width;
	dragObj.Iframe.height = height;
	dragObj.elNode.style.width = width + 'px';
	dragObj.elNode.style.height = height + 'px';
	//$('dspopupbody').style.width = (width-2) + 'px';
	//$('dspopupbody').style.height = height + 'px';
	$('popupcontent').style.width = (width-6) + 'px';
	$('popupcontent').style.height = (height-46) + 'px';
	DSsetDocumentLock(true,dragObj.ownobject);
//	this.headElement.style.width = width + 'px';
//	this.statusElement.style.width = width + 'px';

  if (ie) {
	window.event.cancelBubble = true;
	window.event.returnValue = false;
  }
  else
    event.preventDefault();
}

function dsresizego2(event) {
	width = dragObj.mouseDownWidth + (event.clientX - dragObj.cursorStartX - dragObj.elStartLeft);
	height = dragObj.mouseDownHeight + (event.clientY - dragObj.cursorStartY - dragObj.elStartTop );

	width = width < 606 ? 606 : width;
	height = height < 100 ? 100 : height;


	dragObj.Iframe.style.width = (width) + 'px';
	dragObj.Iframe.style.height = (height) + 'px';
	dragObj.Iframe.width = width;
	dragObj.Iframe.height = height;
	dragObj.elNode.style.width = width + 'px';
	dragObj.elNode.style.height = height + 'px';
//	$('dspopupbody').style.width = (width-2) + 'px';
//	$('dspopupbody').style.height = height + 'px';
	$('popupcontent').style.width = (width-2) + 'px';
	$('popupcontent').style.height = (height-46) + 'px';
	DSsetDocumentLock(true,dragObj.ownobject);	
//	this.headElement.style.width = width + 'px';
//	this.statusElement.style.width = width + 'px';

  if (ie) {
	window.event.cancelBubble = true;
	window.event.returnValue = false;
  }
  else
    event.preventDefault();
}

function dsresizestop(event) {

  // Stop capturing mousemove and mouseup events.

  if (ie) {
    document.detachEvent("onmousemove",dsresizego);
    document.detachEvent("onmouseup",dsresizestop);
  }
  else {
    parent.document.removeEventListener("mousemove",dsresizego2,true);
    parent.document.removeEventListener("mouseup",dsresizestop,true);	  
    document.removeEventListener("mousemove",dsresizego,true);
    document.removeEventListener("mouseup",dsresizestop,true);
  }
  	DSsetDocumentLock(false,dragObj.ownobject);
}


function DSsetDocumentLock (state,object) {
	var elm = $('mcWindowEventBlocker');

	if (state) {
		if (elm == null) {
			elm = document.createElement("div");

			elm.id = "mcWindowEventBlocker";
			elm.style.position = "absolute";
			elm.style.left = "0";
			elm.style.top = "0";

			document.body.appendChild(elm);
		}
		elm.style.display = "none";

		var width = document.body.clientWidth;
		var height = document.body.clientHeight-20;

		elm.style.width = width;
		elm.style.height = height;
		elm.innerHTML = '<img src="' + DSAdminURL + '/dot.gif" width="' + width + '" height="' + height + '" />';
		elm.style.zIndex = object.style.zIndex-1;
		elm.style.display = "block";
	} else if (elm != null) {
		elm.parentNode.removeChild(elm);
	}
};



// ***************************
// * END DragDrop            *
// ***************************

// ***************************
// * START dsfx_object       *
// ***************************
// 2005-04-21 [AP] In der project/_overview.cfm werden bis zu 7 Instances bengigt.
var dsfxlastobject_1='';
var dsfxlastobject_2='';
var dsfxlastobject_3='';
var dsfxlastobject_4='';
var dsfxlastobject_5=''; 

function dsfx_object(newobject,lastobject,functions,instance){
	if(newobject!='' && lastobject!='') {	
		if(instance==null)
			dsfxlastobject=dsfxlastobject_1;
		else	
			dsfxlastobject=this['dsfxlastobject_'+instance];
		if (dsfxlastobject=='')
			dsfxlastobject=lastobject;
	}
	function_list= functions.split(",");
	for (i=0; i<function_list.length; i++){
		this_function=function_list[i].split("=")
		if (this_function[0]=='height'){
			$(newobject).style.height=this_function[1];
		}
		else if (this_function[0]=='class'){
			$('a'+dsfxlastobject).className=this_function[1];			
			$('a'+newobject).className=this_function[1]+'a';
		}
		else if (this_function[0]=='visibility'){
			$(dsfxlastobject).style.visibility="hidden";
			$(newobject).style.visibility="visible";
		}
		else if (this_function[0]=='display'){
			$(dsfxlastobject).style.display="none";
			$(newobject).style.display="block";
		}
		else if (this_function[0]=='resize'){
			parent.dsloader1.resizeTo(this_function[1].split("|")[0],this_function[1].split("|")[1]);
		}
		else if (this_function[0]=='hide'){
			$(this_function[1]).style.visibility="hidden";
		}
		else if (this_function[0]=='show'){
			$(this_function[1]).style.visibility="visible";
		}
		else if (this_function[0]=='displayshowhide'){
			if($(newobject).style.display=="block"){
				$(newobject).style.display="none";
			}
			else{
				$(newobject).style.display="block";
				if(newobject!=lastobject)
					$(lastobject).style.display="none";
			}
		}
	}
	if(newobject!='' && lastobject!='') {	
		if(instance==null)		
			dsfxlastobject_1=newobject;
		else if (instance==2)
			dsfxlastobject_2=newobject;
		else if (instance==3)			
			dsfxlastobject_3=newobject;
		else if (instance==4)			
			dsfxlastobject_4=newobject;
		else if (instance==5)			
			dsfxlastobject_5=newobject;
	}
}
// ***************************
// * END dsfx_object         *
// ***************************

// ***************************
// * START Form            *
// ***************************
function dsform_submit_parent(theform) {
	parent.$('dsloaderform').innerHTML=$(theform).innerHTML;
	dsgetloaderid();
	parent.document.dsloaderform.target='dsloader'+dsloaderid;	
	if(actionurl!=null)
		parent.document.dsloaderform.action=actionurl;
	else
		parent.document.dsloaderform.action=$(theform).action;
	parent.document.dsloaderform.submit();
}

/* Replace
function dsform_submit(theform) {
	if(theform==null){
		$('f1').submit();
	}
	else{
		eval('document.'+theform+'.submit()');
	}
}
*/
// 2006-08-29 [AP] added Form-Validation 


function dsform_submit(option) {
	msg='';
	form='f1';
	posttarget='';
	validate=0;
	if(option!=null) {
		form=option.split(":");
		if(form.length!=1) {
			form='f1';
			DSOptionList(option);
		}
	}
	if($(form)){
		if (validate==1 && typeof form_validation=="function") 
			form_validation();
		else if (isNaN(validate)==true)
			eval(validate);	
		if (msg=='' || validate==0) {
			if (posttarget=='dsloader'){
				dsgetloaderid();
				$(form).target='dsloader'+dsloaderid;
			}
			$(form).submit();
		}
		else{
			alert(msg);			
			 if (document.getElementsByName('dsbutton_submit')!=null) {
				 for(i = 0; i < document.getElementsByName('dsbutton_submit').length; i++) {
					 if (document.getElementsByName('dsbutton_submit')[i]!=null)
						 document.getElementsByName('dsbutton_submit')[i].disabled=false;
				   }
			 }
			return false;
		}
	}
}


function dsform_submitversion(versioning) {
	if ($('dsbutton_versioning'))
		$('dsbutton_versioning').value=versioning;	
}


// 2006-03-30 [AP] Wenn ein Form per innerHTML neu gestzt wird mssen vorher alle Formfelder im DOM registriert werden fr den Firefox
function dsform_registerdom(theform) {
	for(i=0; i<eval('document.'+theform+'.elements.length'); i++){
		formfield=eval('document.'+theform+'.elements[i]');
		if (formfield.type=="select-one") {
			for (var k=0; k<formfield.options.length; k++) {
				if (k == formfield.selectedIndex) 
					formfield.options[formfield.selectedIndex].setAttribute("selected","selected");								
			}
		}
		else if (formfield.type=="text")
			formfield.setAttribute("value",formfield.value);	
	}
} 

// 2006-10-31 [AP] Transfered die Search-Form-Einstellungen in das Popup-Fenster, damit die Einstellung für den Reset-Command bestehen bleiben
function DSFormTransfer(elementlist,option) {
	var element=elementlist.split(",");
	var i=0;
	var k=0;
	runtime=1;
	cmd='';	
	if(option!=null){
		DSOptionList(option);
	}
	this_parent=eval('parent');
	if(cmd!=''){
		pos=top.DSFindLoader_Loaded(cmd);
		if (pos>-1)
			this_parent=top.DSLoader_Loaded[pos][0];	
	}
	for (i=0; i<element.length; i++) {
		var element_name=DSJS.ListFirst(element[i],"|");
		var element_id=DSJS.ListLast(element[i],"|");
		if (this_parent.$(element_id) && DSJS.ListFindNoCase('text,hidden,select-one',this_parent.$(element_id).type)) {			
			if (this_parent.$(element_id).type=="select-one")
				$(element_id+runtime).value=this_parent.$(element_id).options[this_parent.$(element_id).selectedIndex].value;
			else
				$(element_id+runtime).value=this_parent.$(element_id).value;
		}
		else if (this_parent.$(element_id) && this_parent.$(element_id).type=='textarea') {
			newTextarea=new Element("textarea", {				
				"name":$(element_id+runtime).name,
				"id":$(element_id+runtime).id	
			});
			if (ie)
				newTextarea.value=this_parent.$(element_id).value;	
			else
				newTextarea.innerHTML=this_parent.$(element_id).innerHTML;	
			$(element_id+runtime).remove();
			$('DSFormTransferContainer'+runtime).insert(newTextarea);			
		}
		else {
			if (this_parent.document.getElementsByName(element_name)!=null) {
				 for(k = 0; k < this_parent.document.getElementsByName(element_name).length; k++) {
					 if (this_parent.document.getElementsByName(element_name)[k].checked==true)
						$(element_name+runtime).value=this_parent.document.getElementsByName(element_name)[k].value;						
				 }
			 }			
		}		
	}
}



function dsmove(formular,feld,was,jump,newsort){
	ok=0;
	df=eval('document.'+formular);
	von=eval('df.'+feld+'.selectedIndex');
	textvon=eval('df.'+feld+'.options[von].text');	
	valuevon=eval('df.'+feld+'.options[von].value');
	l=eval('df.'+feld+'.length');
	if (was=='up' && von > 0 && von-jump>=0){
		if (jump==0)
			nach=0;
		else
			nach=von-jump;
		ok=1;
		for(pos = von; pos>nach; pos--){
			eval('df.'+feld+'.options[pos].text=document.'+formular+'.'+feld+'.options[pos-1].text');
			eval('df.'+feld+'.options[pos].value=document.'+formular+'.'+feld+'.options[pos-1].value')
		}
	}
	else if (was=='down' && von < l-1 && von+jump<l) {
		if (jump==0)
			nach=l-1;
		else
			nach=von+jump;
		ok=1;
		for(pos = von; pos < nach; pos++){
			eval('df.'+feld+'.options[pos].text=document.'+formular+'.'+feld+'.options[pos+1].text');
			eval('df.'+feld+'.options[pos].value=document.'+formular+'.'+feld+'.options[pos+1].value')
		}
	}
	if (ok==1){
		eval('df.'+feld+'.options[nach].text=textvon');
		eval('df.'+feld+'.options[nach].value=valuevon')
		eval('df.'+feld+'.selectedIndex=nach');
		newpos=new Array();;
		for(i = 0; i < l; i++)
			newpos[i]=eval('df.'+feld+'.options[i].value');
		eval('df.'+newsort+'.value=newpos.join(",")');
	}
}

function DSColorPicker(element){
	selected_color=$(element).value.replace('#','');
	Edit=open(dsxpath+"dynasite.cfm?dscmd=system_colorpicker_colorpicker_view&element="+element+"&selected_color="+selected_color,"Colopicker","width=250,height=550,screenX=0,screenY=0,locationbar=no,resizable=no,status=no,dependent=no");
	Edit.focus();
}

function dsform_select_move(this_select){
	select_id=this_select.id.split('_');
	this_value=this_select.value;
	active_value=$('active_'+select_id[2]).value.split(',');
	if (this_value!=''){
		if (select_id[1]=='inactive'){
			if($('active_'+select_id[2]).value=='')
				active_value[0]=this_value;
			else
				active_value[active_value.length]=this_value;			
		}
		else if (select_id[1]=='active'){
			new_value=new Array();
			for(k=0;k<active_value.length;k++){
				if(active_value[k]!=this_value){
					new_value[new_value.length]=active_value[k];
				}
			}
			active_value=new_value;
		}
		$('active_'+select_id[2]).value=active_value;
		dsform_select_move_init(select_id[2]);
	}
}

function dsform_select_move_init(id){
	active_value=$('active_'+id).value.split(',');
	select_active=$('select_active_'+id);
	select_inactive=$('select_inactive_'+id);
	dsform_select_move_option_name=eval('dsform_select_move_option_name_'+id);
	dsform_select_move_option_value=eval('dsform_select_move_option_value_'+id);
	for (i=select_active.length-1;i>=0;i--){
		select_active.options[i]=null;
	}
	for (i=select_inactive.length-1;i>=0;i--){
		select_inactive.options[i]=null;
	}
	for (i=0;i<dsform_select_move_option_value.length;i++){
		this_select=0;
		for(k=0;k<active_value.length;k++){
			if(active_value[k]==dsform_select_move_option_value[i]){
				this_select=1;
				break;
			}
		}
		if(this_select==0){
			select_inactive.options[select_inactive.length]=new Option(dsform_select_move_option_name[i],dsform_select_move_option_value[i],false,true);
		}
	}
	for(k=0;k<active_value.length;k++){
		for (i=0;i<dsform_select_move_option_value.length;i++){		
			if(active_value[k]==dsform_select_move_option_value[i]){
				select_active.options[select_active.length]=new Option(dsform_select_move_option_name[i],dsform_select_move_option_value[i],false,true);
				break;
			}
		}
	}
	select_active.selectedIndex=0;
	select_inactive.selectedIndex=0;
}

// 2005-04-22 [AP] Setzt eine Lists von Felder auf disabled true oder false in _articel.cfm, _site.cfm, _dsincludesettings.cfm, category.cfm
function dschangestatus(element,fieldlist,opposite) {
	if ($(element).options!=null) 
		thisvalue=$(element).options[$(element).selectedIndex].value;
	else
		 thisvalue=$(element).value;
	if (opposite!=null){
		if (thisvalue==0) thisdisabled=1;
		else thisdisabled=0;					
	}
	else {
		if (thisvalue==0){
			thisdisabled=0;
		}
		else { 
			thisdisabled=1;
		}
	}	
	field =fieldlist.split(",");						
	for(i=0; i < field.length; ++i){
		$(field[i]).disabled=thisdisabled;														
	}
}





// ***************************
// * END Form                *
// ***************************

// ****************************************
// * 2006-08-28 [AP] Validation *
// ****************************************

last_element='';
function dsvalidate(element_name,condition,error_msg){	
	condition=condition.split(' ');
	dfe=$(element_name);
	
	write_msg=0;
	if (condition[0]=='len' || condition[0]=='num' || condition[0]=='strg' || condition[0]=='si' ||  condition[0]=='date'){
		if (condition[0]=='len'){
			dfev=DSTrim(dfe.value);			
			dfev=dfev.length
			comparer=condition[2]*1;
		}
		else if (condition[0]=='num'){
			dfev=DSTrim(dfe.value);
			dfev=DSNumChk(dfe.value);
			if (isNaN(dfev)){
					//msg+=element_name+' ist keine Zahl, bitte geben Sie eine gueltige Zahl ein.\n'
					condition[1]="notanumber";
					write_msg=1;
			}
			else{
				dfev=dfev*1;
				if (isNaN(condition[2])){
					comparer=DSNumChk(eval('df.'+condition[2]+'.value'));
					if (isNaN(DSNumChk(comparer))){
						//msg+=condition[2]+' ist keine Zahl, bitte geben Sie eine gueltige Zahl ein.\n'
						condition[1]="notanumber"
						write_msg=1;
					}
					else
						comparer=comparer*1
				}
				else
					comparer=condition[2]*1;
			}
		}
		else if (condition[0]=='strg'){
			dfev=DSTrim(dfe.value.toLowerCase());
			comparer=condition[2].toLowerCase();
		}
		else if (condition[0]=='si'){
			dfev=dfe.options[dfe.selectedIndex].value;			
			//dfev=dfe.selectedIndex			
			comparer=condition[2];
		}
		// check for date , check for datetime  ('start_date','date <= end_date')
		else if (condition[0]=='date'){
			dfev_a=dfe.value.split("-");
			//dfe=eval('df.'+element_name+'_freetext')
			dfev_b=$(condition[2]).value.split("-");
			dfev=new Date(dfev_a[0],dfev_a[1]-1,dfev_a[2],0,0,0);
			dfev=dfev.getTime() / 1000;
			comparer=new Date(dfev_b[0],dfev_b[1]-1,dfev_b[2],0,0,0);
			comparer=comparer.getTime() / 1000;
		}
	
		if (condition[1] == 'eq'){
			if (dfev == comparer) write_msg=1;
		}
		else if (condition[1] == 'neq'){
			if (dfev != comparer) write_msg=1;
		}
		else if (condition[1] == 'gt'){
			if (dfev > comparer) write_msg=1;
		}
		else if (condition[1] == 'gte'){
			if (dfev >= comparer) write_msg=1;
		}
		else if (condition[1] == 'lt'){
			if (dfev < comparer) write_msg=1;

		}
		else if (condition[1] == 'lte'){
			if (dfev <= comparer) write_msg=1;
		}
		else if (condition[1] == 'notanumber'){// this condition is set above if not a numeric value
			write_msg=1;
		}
	}
	else if (condition[0]=='isnum' || condition[0]=='isnumeric'){
		dfev=DSTrim(dfe.value);
		dfev=DSNumChk(dfe.value);
		if (typeof condition[1]=='undefined')// condition[1] required or not required field
			condition[1]=0;
		if (condition[1]==1 && dfev==''){
			write_msg=1;
			dfev=' ';
		}		
		if (write_msg==0 && isNaN(dfev)) {
			write_msg=1;
		}		
	}
	else if (condition[0]=='findany'){
		dfev=dfe.value;
		if (condition.length==1){
			condition=new Array('\'',',','>','<',' ',':',';','(',')','"','*');
			startpos=0;
		}
		else{
			startpos=1;
		}
		for(i=startpos;i<condition.length;i++){
			if(condition[i]=='space')
				condition[i]=' ';
			if (dfev.indexOf(condition[i])>-1){
				if(condition[i]==' ')
					dfev='space';
				else
					dfev=condition[i];
				dfev=dfev.replace("<","&lt;");
				dfev=dfev.replace(">","&gt;");
				write_msg=1;
				break;
			}
		}
	}
	else if (condition[0]=='find'){
		dfev=dfe.value;
		if (dfev.indexOf(condition[1])>-1) write_msg=1;
	}
	else if (condition[0]=='findnocase'){
		dfev=dfe.value;
		dfev=dfev.toUpperCase(dfev);
		comparer=condition[1].toUpperCase();
		if (dfev.indexOf(comparer)>-1) write_msg=1;
	}	
	else if (condition[0]=='notfind'){
		dfev=dfe.value;
		if (dfev.indexOf(condition[1])==-1) write_msg=1;
	}
	else if (condition[0]=='notfindnocase'){
		dfev=dfe.value;
		dfev=dfev.toUpperCase(dfev);
		comparer=condition[1].toUpperCase();		
		if (dfev.indexOf(comparer)==-1) write_msg=1;
	}
	else if (condition[0]=='range'){
		range=condition[1].split('-');
		dfev=DSNumChk(dfe.value)*1;
			if (isNaN(dfev)){
				write_msg=1;
			}
			else if (dfev<range[0] || dfev>range[1]){
				write_msg=1;
			}
	}
	else if (condition[0]=='ishexa'){
		dfev=DSTrim(dfe.value);
		if (dfev!=''){
			write_msg=hex_chk(dfev);
		}
	}
	else if (condition[0]=='email'){
		if(typeof email_errors=='undefined')
			email_errors=new Array(DSLang('alertnoemailaddress'),DSLang('alertnoatsymbol'),DSLang('alertnonameforat'),DSLang('alertatatend'),DSLang('alertmaxoneat'),DSLang('alertnodot'),DSLang('alertdotnotbeginning'),DSLang('alertdotnotend'),DSLang('alertwrongcharacter'),DSLang('alertwrongcharacteratposition'),DSLang('alertmissingdotafterat'),DSLang('alertwrongtopleveldomain'));
		dfev=DSTrim(dfe.value);
		wrong_chr='';
		if(typeof condition[1]=='undefined')// pass condition[1]=1 only if Email is required field
			condition[1]=0;
		
		dfev_list=dfev.split(';');
		for (ee=0;	ee<dfev_list.length; ee++){
			dfev=DSTrim(dfev_list[ee]);
			if (condition[1]==1 || (condition[1]==0 && dfev!='')){
				if(typeof condition[2]=='undefined')
					error=email_chk(dfev);
				else
					error=email_chk(dfev,1);				
				if (error>-1){
					error_msg+=email_errors[error].replace("@@wrong@@",wrong_chr);
					write_msg=1;
				}
			}
		}
	}
	else if (condition[0]=='url'){
		if(typeof url_errors=='undefined'){
			url_errors=new Array(DSLang('alertnourl'),DSLang('alerturlstarthttp'),DSLang('alerurlminlength'),DSLang('alerturlmusthavedot'),DSLang('alerturlwrongcharacter'));
		}
		dfev=DSTrim(dfe.value);
		wrong_chr='';
		if(typeof condition[1]=='undefined')// pass condition[1]=1 only if URL is required field
			condition[1]=0;
		if (condition[1]==1 || (condition[1]==0 && dfev.length >7)){
			error=url_chk(dfev);
			if (error>-1){
				error_msg+='<ul>'+url_errors[error].replace("@@wrong@@",wrong_chr)+'</ul>';
				write_msg=1;
			}
		}
	}
	if (write_msg)
		msg+=error_msg;
	/*if (write_msg){
		error_msg=error_msg.replace("@@dfev@@",dfev);
		msg+='<li>'+error_msg+'</li>';
		dfe.style.borderTop="2px solid #cc0000";
		dfe.style.borderRight="2px solid #cc0000";
		dfe.style.borderBottom="2px solid #ff0a0a";
		dfe.style.borderLeft="2px solid #ff0a0a";
		if (element_tofocus=='')
			element_tofocus=dfe;
	}
	else if (last_element!=dfe.name){// if (dfe.style.borderTopColor != '#cc0000')
		dfe.style.borderTop="2px solid #606060";
		dfe.style.borderRight="1px solid #606060";
		dfe.style.borderBottom="1px solid #606060";
		dfe.style.borderLeft="2px solid #606060";
	} */
	last_element=dfe.name;
}

function hex_chk(hex){
	write_msg=0;
	if (hex.length != 6){
		//Hexadecimal code should be 6 chrs long
		write_msg=1;
	}
	if(write_msg==0){
		for (i=0; i<6; i++){
			if (isNaN(parseInt(hex.substring(i,i+1) , 16))){
				//Hexadecimal code should be 0,1,2,3,4,5,6,7,8,9,A,a,B,b,C,c,D,d,E,e,F,f
				write_msg=1;
				break;
			}
		}
	}
	return 	write_msg;
}

function email_chk(email,extend){
	error=-1;
	email_sub='';
	if(extend!=null && extend==1){
		email_temp=email;
		email_sub=email.split(' ');
		if(email_sub.length > 1){
			email=email_sub[0];
			email_sub=email_temp.slice(email_sub[0].length+1,email_temp.length);
		}
	}
	if (email.length < 6){
		error=0;
	}
	else{
		if(email.indexOf("@")==-1)
			error=1;
		else if(email.indexOf("@")==0)
			error=2;
		else if(email.indexOf("@")==email.length-1)
			error=3;
		else if(email.indexOf("@")!= email.lastIndexOf("@"))
			error=4;
		else if(email.indexOf(".")==-1)
			error=5;
		else if(email.indexOf(".")==0)
			error=6;
		else if(email.indexOf(".")==email.length-1)
			error=7;
		if (error==-1){
			wrongchk=email.split('(');
			wrong=new Array(',','>','<',' ','*',':',';','(',')','"','\'');
			for(i=0;i<wrong.length;i++){
				if (email.indexOf(wrong[i])>-1){
					error=8;
					wrong_chr='"'+wrong[i]+'"';
					break;
				}	
			}
		}
		if (error==-1){
			for(i=0;i<email.length;i++){
				if(email.charCodeAt(i)<=31 || email.charCodeAt(i)>=127){
					error=9;
					wrong_chr=i;
					break;
				}
			}
		}
		if (error==-1){
			tld_chk=email.split("@");
			tld_chk=tld_chk[tld_chk.length-1];
			tld_chk=tld_chk.split(".");
			if (tld_chk.length==1)
				error=10;
			else{
	toplevel_domain=['com','net','edu','arpa','org','gov','museum','biz','info','pro','name','aero','coop','mil','ac','ad','ae','af','ag','ai','al','am','an','ao','aq','ar','as','at','au','aw','az','ba','bb','bd','be','bf','bg','bh','bi','bj','bm','bn','bo','br','bs','bt','bv','bw','by','bz','ca','cc','cd','cf','cg','ch','ci','ck','cl','cm','cn','co','cr','cu','cv','cx','cy','cz','de','dj','dk','dm','do','dz','ec','ee','eg','eh','er','es','et','eu','fi','fj','fk','fm','fo','fr','ga','gd','ge','gf','gg','gh','gi','gl','gm','gn','gp','gq','gr','gs','gt','gu','gw','gy','hk','hm','hn','hr','ht','hu','id','ie','il','im','in','io','iq','ir','is','it','je','jm','jo','jp','ke','kg','kh','ki','km','kn','kp','kr','kw','ky','kz','la','lb','lc','li','lk','lr','ls','lt','lu','lv','ly','ma','mc','md','mg','mh','mk','ml','mm','mn','mo','mp','mq','mr','ms','mt','mu','mv','mw','mx','my','mz','na','nc','ne','nf','ng','ni','nl','no','np','nr','nu','nz','om','pa','pe','pf','pg','ph','pk','pl','pm','pn','pr','ps','pt','pw','py','qa','re','ro','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sj','sk','sl','sm','sn','so','sr','st','sv','sy','sz','tc','td','tf','tg','th','tj','tk','tm','tn','to','tp','tr','tt','tv','tw','tz','ua','ug','uk','um','us','uy','uz','va','vc','ve','vg','vi','vn','vu','wf','ws','ye','yt','yu','za','zm','zr','zw','int','local'];
				tld=tld_chk[tld_chk.length-1].toLowerCase();
				chk_ok=0;
				for (t=0; t<toplevel_domain.length; t++){
					if (tld==toplevel_domain[t]){
						chk_ok=1;
						break;
					}
				}
				if (chk_ok==0){
					error=11;
					wrong_chr='"'+tld+'"';
				}
			}
		}
	}
	if(email_sub.length>1 && error==-1){
		if(email_sub.charAt(email_sub.length-1)!=')' || email_sub.charAt(0)!='(')
			error=8;
	}
	return error;
}

function url_chk(url){
	error=-1;
	if (url.length <12)
		error=0;
	else{
		if (url.indexOf("http://")!=0)
			error=1;
		else if (url.length < 12)
			error=2;
		else if (url.indexOf(".")==-1)
			error=3;
		else {	
			wrong=new Array('>','<',' ','*',';','"','\'');
			for(i=0;i<wrong.length;i++){
				if (url.indexOf(wrong[i])>-1){
					error=4;
					if (wrong[i]==' ')
						wrong_chr='space';
					else
						wrong_chr=wrong[i];
					break;
				}	
			}
		}			
	}
	return error;
}

// Form - Validation 
/*
function dsform_validation(){
	url_cmd=dscommand.split("_");
	
	if (url_cmd[0]=='site' && url_cmd[1]=='export' && url_cmd[2]=='queue'){
		start_date=DSCreateDateTime('start_date','start_time');		
		compare_date=DSCreateDateTime('compare_date','compare_time');
		if (start_date<compare_date)
			msg+='Das Datum muss in der Zukunft liegen';
	}
	
	if (url_cmd[0]=='site' && url_cmd[1]=='export' && url_cmd[2]=='export' && url_cmd[3]!='select'){

	}
	// site_export_export_select
	else if (url_cmd[0]=='site' && url_cmd[1]=='export' && url_cmd[2]=='export' && url_cmd[3]=='select'){
		
		
	}
}
*/

// END Validation

var LACalendarMonth = new Array (DSLang('january'),DSLang('february'),DSLang('march'),DSLang('april'),DSLang('may'),DSLang('june'),DSLang('july'),DSLang('august'),DSLang('september'),DSLang('october'),DSLang('november'),DSLang('december'));
var LACalendarMonthShort = new Array ("Jan","Feb","M&auml;r","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez");

var LACalendarDayNames= new Array(DSLang('sunday'),DSLang('monday'),DSLang('tuesday'),DSLang('wednesday'),DSLang('thursday'),DSLang('friday'),DSLang('saturday'));
var LACalendarDay = new Array (DSLang('SO'),DSLang('MO'),DSLang('TU'),DSLang('WE'),DSLang('TH'),DSLang('FR'),DSLang('SA'));

MonthNames = LACalendarMonth;
DayNames= LACalendarDayNames;
DayNamesShort=LACalendarDay;

WeekStart="m"//s: if week starts on Sunday, m: if week starts on Monday
SS_oneday=1; // Show Saturday and Sunday in one field at month_view ( 1 or 0) only possibile if WeekStart is "m" (Monday)

CalendarWeek=DSLang('calendarweek');

period_option_list='none,wholeday,n-5,n-15,n-30,n-45,h-1,h-2,h-3,h-4,h-5,h-6,h-7,h-8,h-9,h-10,h-11,h-12,h-18,d-1,d-2,d-3,d-4,d-5,d-6,w-1,w-2,w-3,noend';
wholeday=DSLang('wholeday');
noend=LANoEnd=DSLang('noend');
n_var_text=DSLang('minutes');
h_var_text=DSLang('hours');
d_var_text=DSLang('days');
w_var_text=DSLang('weeks');

last_selected_date="";
last_selected_week="";

thisTimeElement="";
ds_new_calendar_hour=-1;
ds_new_calendar_minute=-1;


status_list_de=''+DSLang('Cancelled')+','+DSLang('Notstarted')+','+DSLang('Workinprogress')+','+DSLang('done')+','+DSLang('Waitingforsomeoneelse')+','+DSLang('Pushedback')+''.split(',');	


status_list_en='cancelled,notstarted,started,finished,waitforother,rejected'.split(',');
status_image_list_single='checkbox02.gif,checkbox00.gif,checkbox00.gif,checkbox01.gif,checkbox00.gif,checkbox02.gif'.split(',');
status_image_list_multiple='checkbox12.gif,checkbox10.gif,checkbox10.gif,checkbox11.gif,checkbox10.gif,checkbox12.gif'.split(',');


// 2006-10-05 [AP] Aus der Calendar/_entry.cfm ausgelagert
function dscalendar_entrytype(isevent) {
	entrytypeevent=new Array('Event_Label_DateStart','Event_Label_DateEnd','eventbox','event_alarm_type');
	entrytypetask=new Array('Task_Label_DateStart','Task_Label_DateEnd','task_alarm_type');
	var i=0;
	if(isevent==1) {
		settoblock=entrytypeevent;
		settonone=entrytypetask;
	}
	else{
		settoblock=entrytypetask;
		settonone=entrytypeevent;
	}
	// 2006-10-14 [AP] Müssen die Elemente noch auf Block gesetzt werden ?????
	for(i=0;i<settoblock.length;i++){
		if ($(settoblock[i])!=null)
			$(settoblock[i]).style.display='block';
	}
	for(i=0;i<settonone.length;i++){
		if ($(settonone[i])!=null)
			$(settonone[i]).style.display='none';
	}	
	DSPopUpResize();
}
function recurrence_show(onoff){
	if (onoff==1)
		$("recurrence_div").style.display="block";
	else
		$("recurrence_div").style.display="none"		
	DSPopUpResize();
 }
 function changeRecurrenceType(type){
	if (type==null)
		type=$('recurrence_type').options[$('recurrence_type').selectedIndex].value;
	if (type==0)
		$('recurrence_all').style.display="none";
	else
		$('recurrence_all').style.display="block";
	for(i=1; i<=4; i++){
		if (i==type)
			$('recurrence_'+i).style.display="block";
		else
			$('recurrence_'+i).style.display="none"
	}
	DSPopUpResize();
 }
 
 function entry_chk(caller){
	// 2006-10-22 [AP] Arguement Caller hinzugefügt, wenn ein Task vom Artikel gespeichert wird
	start_date=DSCreateDateTime('start_date','start_time');		
	end_date=DSCreateDateTime('end_date','end_time');
	d_diff=DSDateDiff('d',start_date,end_date);
	msg=''; 
	period=$('period');


	DSCal=eval('top.DSCal_'+$('dscalid').value);
	if (DSCal!=null && $('CalendarCurrDate')!=null){
		//alert(document.getElementById('dscalid').value);
		this_currdate=DSCal.calendar_currentdate;
		//alert(this_currdate.toString())
		thisvar=this_currdate.getFullYear()+'-'+DSInt(this_currdate.getMonth()+1)+'-'+this_currdate.getDate();
		$('CalendarCurrDate').value=thisvar;
	}	
	
	if (caller!='article' && DSTrim($('title').value)=='')
		msg+=DSLang('alertcalsubject');
	if ((end_date.getFullYear()==1901 || end_date.getFullYear()==2500) && end_date.getMonth()==0 && end_date.getDate()==1){
		msg+='';
	}
	else if (period!=null && period.value=='wholeday')
		msg+='';
	else if (start_date >end_date)
		msg+=DSLang('alertstartforenddate');
	
	if ($('recurrence_type').selectedIndex!=0){
		if ($('recurrence_type').selectedIndex==1){ //daily
			if (document.getElementsByName('daily_type')[0].checked){
				day_step=$('day_step').value;
				if (!DSIsNum(day_step)) {
					msg+=DSLang('alertnovalidinterval');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",day_step);
				}
				else{
					day_step=DSInt(day_step);
					if (d_diff >= day_step) {
						msg+=DSLang('alertintervaldailyrepeat');
						msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",day_step);
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",d_diff);
					}
				}
			}
			else{
				if (d_diff > 0)
					msg+=DSLang('alertrepeatworkdays');
			}
		}
		else if($('recurrence_type').selectedIndex==2){ // weekly
			if (!DSIsNum($('week_step').value)) {
				msg+=DSLang('alertnotavlidnumber');
				msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('week_step').value)
			}
			else{
				wd=document.getElementsByName('weekdays');
				start_date_wd_found=0;
				this_wd=new Array();
				for(i=0; i<wd.length; i++){
					if (wd[i].checked){
						this_wd[this_wd.length]=i
						if (start_date.getDay()==eval(wd[i].value-1))
							start_date_wd_found=1;	
					}
				}
				if (this_wd.length==0)
					msg+=DSLang('alertrepeatweekdays');
				else{
					if (this_wd.length==1)
						chk_days=6;
					else{
						start_diff=this_wd[0]-0;
						end_diff=6-this_wd[this_wd.length-1];
						chk_days=start_diff+end_diff;
						for(i=1; i<this_wd.length; i++){
							this_diff=this_wd[i]-this_wd[i-1]-1;
							if (this_diff<chk_days)
								chk_days=this_diff;
						}
					}
					if (d_diff>=$('week_step').value*7){
						msg+=DSLang('alerttimeperiodinterval');
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",eval(DSInt(d_diff/7)+1),"All");
					}
					else if (d_diff >=7 && this_wd.length!=1)
						msg+=DSLang('alertrepeatoneweekday');
					else if (d_diff > chk_days)
						msg+=DSLang('alerttimeperiodrepeatweekday');
					if (start_date_wd_found==0) {
						msg+=DSLang('alertrepeatweeklyacitve');
						msg=DSJS.ReplaceNoCase(msg,"@@replace3@@",DayNames[start_date.getDay()],"All");
					}
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",d_diff,"All");
					
					
				}
			}
		}
		else if($('recurrence_type').selectedIndex==3){ // monthly
			if (document.getElementsByName('monthly_type')[0].checked){
				if (!DSIsNum($('month_day').value)) {
					msg+=DSLang('alertnotavlidnumber');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('month_day').value);
				}
				else if (!DSIsNum($('month_step').value)){
					msg+=DSLang('alertnotavlidnumber');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('month_step').value);
				}
				else{
					rundate=new Date(start_date.getFullYear(),start_date.getMonth(),1,0,0,0);
					rundate=DSDateAdd('m',$('month_step').value,rundate);
					totalDays=DSDaysInMonth(rundate.getFullYear(),rundate.getMonth());
					month_day=$('month_day').value;
					if (month_day>totalDays)
						month_day=totalDays;
					rundate=new Date(rundate.getFullYear(),rundate.getMonth(),month_day,0,0,0);
					if (end_date>=rundate) {
						msg+=DSLang('alertendolderbeginn');
						msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",DSDateTimeFormat('date',end_date),"All");
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",DSDateTimeFormat('date',rundate),"All");
					}
				}
			}
			else{
				if (!DSIsNum($('month_selector_step').value)){
					msg+=DSLang('alertnotavlidnumber');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('month_selector_step').value)
				}
				else{
					selector_type=$('month_selector_type').value;
					selector=$('month_selector').value-1;
					rundate=new Date(start_date.getFullYear(),start_date.getMonth(),1,0,0,0);
					rundate=DSDateAdd('m',$('month_selector_step').value,rundate);
					totalDays=DSDaysInMonth(rundate.getFullYear(),rundate.getMonth());
					if (selector_type==5){
						rundate=new Date(rundate.getFullYear(),rundate.getMonth(),totalDays,0,0,0);
						for (i=0;i<totalDays;i++){
							if (rundate.getDay()==selector)
								break;
							else
								rundate=DSDateAdd('d',-1,rundate)
						}
					}
					else{
						counter=0;
						for (i=0;i<totalDays;i++){
							if (rundate.getDay()==selector)
								counter++
							if (counter==selector_type)
								break;
							else
								rundate=DSDateAdd('d',1,rundate)
						}
					
					}
					if (end_date>=rundate) {
						msg+=DSLang('alertendolderbeginn');
						msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",DSDateTimeFormat('date',end_date),"All");
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",DSDateTimeFormat('date',rundate),"All");
					}
				}
			}
		}
		else if($('recurrence_type').selectedIndex==4){ // yearly
			if (document.getElementsByName('yearly_type')[0].checked){
				if (!DSIsNum($('year_step').value)) {
					msg+=DSLang('alertnotavlidnumber');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('year_step').value);
				}
				else if (!DSIsNum($('year_day').value)) {
					msg+=DSLang('alertnotavlidnumber');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('year_day').value);
				}
				else{
					this_month=$('year_month').value-1;
					this_year=start_date.getFullYear()*1+$('year_step').value*1;
					rundate=new Date(this_year,this_month,1,0,0,0);
					totalDays=DSDaysInMonth(rundate.getFullYear(),rundate.getMonth());
					year_day=$('year_day').value;
					if (year_day>totalDays)
							year_day=totalDays;
						rundate=new Date(rundate.getFullYear(),rundate.getMonth(),year_day,0,0,0);
					
					if (end_date>=rundate){
						msg+=DSLang('alertendolderbeginn');
						msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",DSDateTimeFormat('date',end_date),"All");
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",DSDateTimeFormat('date',rundate),"All");
					}
				}
			}
			else{
				if (!DSIsNum($('year_selector_step').value)) {
					msg+=DSLang('alertnotavlidnumber');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('year_selector_step').value);
				}
				else{
					selector_type=$('year_selector_type').value;
					selector=$('year_selector').value-1;
					this_year=start_date.getFullYear()*1+$('year_selector_step').value*1;
					this_month=$('year_selector_month').value*1-1;
					rundate=new Date(this_year,this_month,1,0,0,0);
					totalDays=DSDaysInMonth(rundate.getFullYear(),rundate.getMonth());
					if (selector_type==5){
						rundate=new Date(rundate.getFullYear(),rundate.getMonth(),totalDays,0,0,0);
						for (i=0;i<totalDays;i++){
							if (rundate.getDay()==selector)
								break;
							else
								rundate=DSDateAdd('d',-1,rundate)
						}
					}
					else{
						counter=0;
						for (i=0;i<totalDays;i++){
							if (rundate.getDay()==selector)
								counter++
							if (counter==selector_type)
								break;
							else
								rundate=DSDateAdd('d',1,rundate)
						}
					
					}
					if (end_date>=rundate){
						msg+=DSLang('alertendolderbeginn');
						msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",DSDateTimeFormat('date',end_date),"All");
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",DSDateTimeFormat('date',rundate),"All");
					}
				}
			}
		}
	}
	
	if (msg=='') {
		if (caller!=null && caller=='article')
			submitform=1;
		else 
			dsform_submit();
	}
	else{
		alert(msg);
		$('dsbutton_submit').disabled=false;
	}
 }	

// END 2006-10-05 [AP] Aus der Calendar/_entry.cfm ausgelagert


function dsautodate(datename,datevalue,allow_no_date,info){
	var i;
	yearstart='';
	yearend='';
	dateid=datename;
	if (typeof info!='undefined'){
		info_array=info.split(",")
		for (i=0;i<info_array.length;i++){
			eval(info_array[i].replace(":","='")+"'")
		}
	}
	display=DSDateTimeFormat('weekday_date',datevalue);
	if(typeof allow_no_date == "undefined")
		allow_no_date=0
	if (datevalue=='2500-01-01')
		datevalue='1901-01-01';
	if (datevalue=='1901-01-01')
		display=DSLang('nodate');
	
	datevar='<input type="hidden" id="'+datename+'" name="'+datename+'" value="'+datevalue+'" />';
	datevar+='<div id="display_'+datename+'" class="ds_date" onClick="DSCalendarGetValue(event,\''+datename+'\','+allow_no_date+');" yearstart="'+yearstart+'" yearend="'+yearend+'">'+display+'</div>';
	//alert(datevar)
	document.write(datevar);
}

function dsautotime(timename,timevalue,info){
	showMinute=1;
	if (typeof info!='undefined'){
		info_array=info.split(",")
		for (i=0;i<info_array.length;i++){
			eval(info_array[i].replace(":","='")+"'")
		}
	}	
	display=DSDateTimeFormat('time',timevalue)
	datevar='<input type="hidden" id="'+timename+'" name="'+timename+'" value="'+timevalue+'" />';
	datevar+='<div id="display_'+timename+'" class="ds_time" onclick="DSTimeGetValue(event,\''+timename+'\','+showMinute+');" >'+display+'</div>';
	//alert(datevar)
	//datevar='<b>huhu</b>';
	document.writeln(datevar);
}

function dsautodatetime(datetimename,datevalue,allow_no_date,info){
	date_value=datevalue.split(" ");
	this_date_name=datetimename+'_date';
	this_time_name=datetimename+'_time';
	dsautodate(this_date_name,date_value[0],allow_no_date,info);
	dsautotime(this_time_name,date_value[1],info);
	if (date_value[0]=='1901-01-01' || date_value[0]=='2500-01-01'){
		$('display_'+this_time_name).style.display='none';
		$('display_'+this_date_name).innerHTML=DSLang('nodate');
	}
}

function DSCalendarGetValue(e,thiselement,allow_no_date){
	if (ie==true)
		thisDisplayDateElement=e.srcElement;
		
	else
		thisDisplayDateElement=e.target;
	thisDateElement=$(thisDisplayDateElement).previous('input');	
	now=DSCreateDateTime(thisDateElement,'');
	now=DS1901_2500Calibrate(now);
	DSCalendarView(now.getFullYear(),now.getMonth(),now.getDate(),'form',0,allow_no_date);
	DSContextShow(e,'','x_show="middle";y_show="bottom";onmouseout=1;');
}

function DSTimeGetValue(e,thiselement,showMinute){
	thisTimeElement=thiselement;
	ds_new_calendar_hour=-1;
	ds_new_calendar_minute=-1;
	this_time=$(thiselement).value;
	this_time_array=this_time.split(':');
	hour = this_time_array[0];
	minute =this_time_array[1];
	DSTimeView(hour,minute,showMinute);
	DSContextShow(e,'','x_show="right";y_show="bottom";onmouseout=1;');	
}

function DSCalendarNewTime(){
	new_time=ds_new_calendar_hour+':'+ds_new_calendar_minute
	$(thisTimeElement).value=new_time;
	$('display_'+thisTimeElement).innerHTML=new_time;
	
	start_enddate_adjust(thisTimeElement);
	
	DSContextHide();
	if (DSPeriodFunction){
		period_adjust(thisTimeElement)
	}
}

function DSTimeSelect(hour_minute,value){
	if (hour_minute=='hour'){
		$('time_hour_'+ds_new_calendar_hour).className='dscalendar_month_small_day';
		ds_new_calendar_hour=value;
		$('time_hour_'+ds_new_calendar_hour).className='dscalendar_month_small_active';
	}
	else{
		$('time_minute_'+ds_new_calendar_minute).className='dscalendar_month_small_mid';
		ds_new_calendar_minute=value;
		$('time_minute_'+ds_new_calendar_minute).className='dscalendar_month_small_active';
	}
}
function DSTimeView(hour,minute,showMinute){
	if (hour<10 && hour.length<2)
		hour='0'+hour;
	
	ds_new_calendar_hour=hour;
	ds_new_calendar_minute=minute;
	
	html_str='';
	html_str+='<table cellspacing="1" id="dscalendar_small">';
	html_str+='<tr>';
	//html_str+='<tr><td rowspan="2" valign="top" align="right">Hour:</td>';
	for (i=0;i<=23;i++){
		if (i<10)
			ii='0'+i;
		else
			ii=i;
		if(showMinute==1)
			html_str+='<td id="time_hour_'+ii+'" class="dscalendar_month_small_day" onclick="DSTimeSelect(\'hour\',\''+ii+'\');"><a href="javascript: DSBlank();"><strong>'+ii+'</strong></a></td>';
		else
			html_str+='<td id="time_hour_'+ii+'" class="dscalendar_month_small_day" onclick="DSTimeSelect(\'hour\',\''+ii+'\');DSCalendarNewTime();"><a href="javascript: DSBlank();"><strong>'+ii+'</strong></a></td>';		
		if (i==11)
			html_str+='</tr><tr>';
	}
	html_str+='</tr>';
	html_str+='<tr><td colspan="12"></td></tr>';
	if(showMinute==1){	
		html_str+='<tr>';
		//html_str+='<tr><td rowspan="6" valign="top" align="right">Minute:</td>';
		for (i=0;i<=55;i=i+5){
			if (i<10)
				ii='0'+i;
			else
				ii=i;
			html_str+='<td id="time_minute_'+ii+'" class="dscalendar_month_small_monthnav_mid" onclick="DSTimeSelect(\'minute\',\''+ii+'\');"><a href="javascript: DSBlank();"><strong>:'+ii+'</strong></a></td>';
		}
		html_str+='</tr>';
		html_str+='<tr><td colspan="12"></td></tr>';
		for (j=0;j<4;j++){
			html_str+='<tr>';
			for (i=1;i<=12;i++){
				ii=(i-1)*4+i+j
				if (ii<10)
					ii='0'+ii;
				html_str+='<td id="time_minute_'+ii+'" class="dscalendar_month_small_monthnav_mid" onclick="DSTimeSelect(\'minute\',\''+ii+'\');"><a href="javascript: DSBlank();">:'+ii+'</a></td>';
			}
			html_str+='</tr>';
		}
	}
	now = new Date();
	hour = now.getHours();
	minute = now.getMinutes();
	html_str+='<tr height="30">';
	if(showMinute==1){
		html_str+='<td colspan="4" class="ds_calendar_footer" valign="middle"><a style="width:auto;" href="javascript: DSTimeView('+hour+','+minute+')">'+DSLang('now')+'</a></td>';
		html_str+='<td colspan="4" class="ds_calendar_footer" align="center" valign="middle"><a style="width:auto;" href="javascript: DSCalendarNewTime()">'+DSLang('apply')+'</a></td>';
		html_str+='<td colspan="4" class="ds_calendar_footer" align="right" valign="middle"><a style="width:auto;" href="javascript:DSContextHide();">'+DSLang('close')+'</a></td>';		
	}
	else{
		html_str+='<td colspan="6" class="ds_calendar_footer" valign="middle"><a style="width:auto;" href="javascript: DSTimeView('+hour+',\'00\',0);DSCalendarNewTime();">'+DSLang('now')+'</a></td>';	
		html_str+='<td colspan="6" class="ds_calendar_footer" align="right" valign="middle"><a style="width:auto;" href="javascript:DSContextHide();">'+DSLang('close')+'</a></td>';		
	}
	html_str+='</tr>';
	html_str+='</table>';
	DSContextInnerHTML(html_str,1);
	DSTimeSelect('hour',ds_new_calendar_hour);
	if(showMinute==1){	
		DSTimeSelect('minute',ds_new_calendar_minute);
	}
}

//START  NEUE ZEITFUNKTION

function DSTimeWriteBack(this_element,value){
	$(this_element).innerHTML=value;
}

function DSTimeSelect_new(this_element,hour_min){
	time_value=$(this_element).innerHTML;
	html_str='';
	if (hour_min=='hour'){
		html_str+='<select class="ds_calendar_month_small_select" style="font-size:0.9em" size="5" id="help_hourlist" name="help_hourlist" onchange="DSTimeWriteBack(\''+this_element+'\',this.value)">';
		for (i=0;i<=23;i++){0
			i_show=''+i;
			if (i<10)
				i_show='0'+i_show;
			html_str+='<option value="'+i+'"'+((i==time_value)?' selected':'')+'>'+i_show+'</option>';
		}
		html_str+='</select>';
	}
	else{
		html_str+='<select class="ds_calendar_month_small_select" style="font-size:0.9em" size="5" id="help_minutelist" name="help_hourlist" onchange="DSTimeWriteBack(\''+this_element+'\',this.value)">';
		for (i=0;i<=59;i++){
			i_show=''+i;
			if (i<10)
				i_show='0'+i_show;
			if (i/5==DSInt(i/5))
				style=' style="background-color:#dddddd;"';
			else
				style='';
			html_str+='<option value="'+i+'"'+style+((i==time_value)?' selected':'')+'>'+i_show+'</option>';
		}
		html_str+='</select>';
	}
	$(this_element).innerHTML=html_str;
}

function DSTimeView_new(hour,minute){
	var i;
	html_str='';
	html_str+='<table cellspacing="1" id="dscalendar_small">';
	html_str+='<tr height="80">';
	html_str+='<td align="right" valign="middle" id="help_selected_hour" style="font-size:1.8em; cursor:pointer; width:80;" onclick="DSTimeSelect(this.id,\'hour\')">'+hour+'</td>';
	html_str+='<td align="center" valign="middle" style="font-size:1.8em" width="20"><strong>:</strong></td>';
	html_str+='<td align="left" valign="middle" id="help_selected_minute" style="font-size:1.8em; cursor:pointer; width:80;" onclick="DSTimeSelect(this.id,\'minute\')">'+minute+'</td>';
	html_str+='</tr>';
	
	html_str+='<tr>';
	html_str+='<td class="ds_calendar_footer" colspan="3" align="center"><a style="width:auto;" href="javascript: DSCalendarNewTime(document.getElementById(help_hourlist).value,document.getElementById(help_minutelist).value)">Ok</a></td>';
	html_str+='</tr>';
	
	html_str+='<tr>';
	html_str+='<td class="ds_calendar_footer" align="center"><a style="width:auto;" href="javascript:DSContextHide();">'+DSLang('close')+'</a></td>';
	html_str+='</tr>';
	html_str+='</table>';
	
	DSContextInnerHTML(html_str,1);
}

//ENDE  NEUE ZEITFUNKTION

// Date Create and Format functions

function DS1901_2500Calibrate(this_date){
	if ((this_date.getFullYear()==1901 || this_date.getFullYear()==2500) && this_date.getMonth()==0 && this_date.getDate()==1){
		this_date=new Date();
	}
	return this_date;
}

function DSCreateDateTime(this_date_element,this_time_element){
	if ($(this_date_element)!=null)
		this_date=$(this_date_element).value;
	else
		this_date='';
		
	if (this_time_element!='' && $(this_time_element)!=null)
		this_time=$(this_time_element).value;
	else
		this_time='';
	now = new Date();
	this_date=this_date.split('-');
	this_time=this_time.split(':');
	if(this_date.length != 3) {
		this_date[0]=now.getFullYear();
		this_date[1]=now.getMonth()+1;
		this_date[2]=now.getDate();
	}
	if(this_time.length != 2) {
		this_time[0]= now.getHours();
		this_time[1]= now.getMinutes();
	}
	if (this_date[1].substr(0,1)=='0')
		this_date[1]=this_date[1].replace(/0/,"");
	if (this_date[2].substr(0,1)=='0')
		this_date[2]=this_date[2].replace(/0/,"");
	if (this_time[0]=='--' || this_time[1]=='--'){
		this_time[0]= now.getHours();
		this_time[1]= now.getMinutes();
	}
	
	this_date[1]=this_date[1]*1-1;
	new_date=new Date(this_date[0],this_date[1],this_date[2],this_time[0],this_time[1],0);
	//alert(new_date);
	return new_date;
	
}

function DSDateTimeFormat(dt,this_value){

	if (typeof this_value=='object'){
		if (dt=='time'){
			this_value=this_value.getHours()+':'+this_value.getMinutes();
		}
		else if(dt=='date' || dt=='weekday_date'){
			this_month=this_value.getMonth()+1;
			this_value=this_value.getFullYear()+'-'+this_month+'-'+this_value.getDate();
		}
	}
	if (dt=='time'){
		this_val=this_value.split(':');
		hour=this_val[0]*1;
		minute=this_val[1]*1;
		if (hour<10)
			hour='0'+hour;
		if (minute<10)
			minute='0'+minute;
		this_value=hour+':'+minute;
	}
	else if(dt=='date' || dt=='weekday_date'){
		this_val=this_value.split('-');
		year=this_val[0]*1;
		month=this_val[1]*1;
		day=this_val[2]*1;
		if (month<10)
			month='0'+month;
		if (day<10)
			day='0'+day;
		this_value=day+'.'+month+'.'+year;
		if (dt=='weekday_date'){
			this_date=new Date(this_val[0],this_val[1]*1-1,this_val[2],0,0,0);
			this_weekday=DayNamesShort[this_date.getDay()];
			this_value=this_weekday+', '+this_value;
		}
	}
	return this_value;
}

function DSTimeFormat(chk_date){
	var hh=chk_date.getHours()*1;
	var mm=chk_date.getMinutes()*1;
	var ss=chk_date.getSeconds()*1;
	var ampm='PM';
	if (hh<12)
		ampm='AM';
	if (hh<10)
		hh='0'+hh;
	if (mm<10)
		mm='0'+mm;
	if (ss<10)
		ss='0'+ss;	
	return hh+':'+mm+' '+ampm
}


// END Date Create and Format functions

// DateADD and Datediff 
function DSDateAdd(datepart,dnum,chk_date){
	var this_date = new Date(chk_date);
	dnum=dnum*1;
	if (datepart=="y" || datepart=="year"){
		this_date.setFullYear(this_date.getFullYear() + dnum);
	}
	else if (datepart=="m" || datepart=="month"){
		this_date.setMonth(this_date.getMonth() + dnum);
	}
	else if (datepart=="d" || datepart=="day"){
		this_date.setDate(this_date.getDate() + dnum);
	}
	else if (datepart=="h" || datepart=="hour"){
		this_date.setHours(this_date.getHours() + dnum);
	}
	else if (datepart=="n" || datepart=="minute"){
		this_date.setMinutes(this_date.getMinutes() + dnum);
	}
	else if (datepart=="s" || datepart=="sec"){
		this_date.setSeconds(this_date.getSeconds() + dnum);
	}
	return this_date;
}

function DSDateDiff(datepart,chk_date1,chk_date2){
	date1 = new Date(chk_date1);
	date2 = new Date(chk_date2);
	
	TimezoneOffset=(date1.getTimezoneOffset()-date2.getTimezoneOffset())*60*1000;
	millisec_diff = date2.valueOf() - date1.valueOf()+TimezoneOffset;
	
	year_diff  = date2.getUTCFullYear() - date1.getUTCFullYear();
	month_diff = date2.getUTCMonth() - date1.getUTCMonth() + (year_diff!=0 ? year_diff*12 : 0);
	
	sec_diff = parseInt(millisec_diff/1000);
	min_diff = parseInt(sec_diff/60);
	hour_diff = parseInt(min_diff/60);
	day_diff  = parseInt(hour_diff/24);

	if (datepart=="y" || datepart=="year")
		return year_diff;
	else if (datepart=="m" || datepart=="month")
		return month_diff;
	else if (datepart=="d" || datepart=="day")
		return day_diff;
	else if (datepart=="h" || datepart=="hour")
		return hour_diff;
	else if (datepart=="n" || datepart=="minute")
		return min_diff;
	else if (datepart=="s" || datepart=="sec")
		return sec_diff;
	else
		return false;
}


// other usefull Date Functions

function DSIsLeapYear(year){
	ly=0;
	if ((year % 4) == 0 && (year < 1582 || (year % 100) > 0 || (year % 400) == 0))
		ly=1;
	return ly;
}
function DSDaysInMonth(year,month) {
	days_in_month=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	if (month==1 && DSIsLeapYear(year)){		
		days_in_month[1]=29;
	}		
	return days_in_month[month];
}
function DSDaysTotal(year,month,day){
	if ( month < 3 ){
		month = month + 12;
		year = year - 1;
	}
	month++;
	total_days = year * 365 + parseInt(year/4) - parseInt( year/100 ) + parseInt( year/400 ) + parseInt((month*306)/10) + day-426;
	return total_days;
}
function DSDayOfYear(year,month,day){
	total_days=day;
	for (mmi=0; mmi<month; mmi++) {
		total_days+=DSDaysInMonth(year,mmi);
	}
	return total_days;
}
function DSWeekOfYear(year,month,day){
	dayofyear=DSDayOfYear(year,month,day);
	td_0101=(DSDaysTotal(year,1,1) + 4) % 7;
	td_3112=(DSDaysTotal(year,12,31) + 4 ) % 7;
	td_0101_old=(DSDaysTotal(year-1,1,1) + 4 ) % 7;
	td_3112_old=(DSDaysTotal(year-1,12,31) + 4 ) % 7;
	d=td_0101-1;
	if ( td_0101 < 4 )
		d += 7;
	woy = parseInt((dayofyear+d)/7);
	if (woy==53 && td_3112 < 3)
		woy=1;
	if (woy==0){
		if ( ( td_0101_old == 3 ) || ( td_3112_old == 3 ) )
			woy = 53;
		else
			woy = 52;  
	}
	return woy;
}

// Period Functions
DSPeriodFunction=0;
function DSWritePeriod(){
	DSPeriodFunction=1;
 	option_list=period_option_list.split(',');
	html_str='<select class="ds_select" name="period" id="period" onchange="DSPeriodWriteNewDateTime(\'start_date\')">';
	for (i=0;i<option_list.length;i++){
		if (option_list[i]=="wholeday")
			this_text=wholeday;
		else if (option_list[i]=="none"){
			this_text='- - - - - - -';
		}
		else if (option_list[i]=="noend"){
			this_text=noend;
		}
		else{
			this_value=option_list[i].split('-');
			this_text=this_value[1]+' '+eval(this_value[0]+'_var_text');
		}
		html_str+='<option value="'+option_list[i]+'">'+this_text+'</option>';
	}
	html_str+='</select>';
	document.write(html_str);
}

function DSPeriodWriteNewDateTime(start_end_date){
	period=$('period');
	if (typeof start_end_date=='undefined')
		start_end_date='start_date';
	if (period.value=='none')
		return;
	period.options[0].text='- - - - - - -';
	
	this_val=period.value.split('-');
	datepart=this_val[0];
	dnum=this_val[1];
	if (datepart=='w'){
		datepart='d';
		dnum=dnum*7;
	}
	
	if (period.value=='wholeday'){
		$('display_start_time').style.display='none';
		$('display_end_time').style.display='none';
		$('display_end_date').style.display='none';
	}
	else{
		$('display_start_time').style.display='block';
		$('display_end_time').style.display='block';
		$('display_end_date').style.display='block';
		if (start_end_date=='end_date'){
			change_date='start';
			_time_display='block';
			if (period.value=='noend'){
				
			}
			else{
				enddate=$('end_date').value;
				endtime=$('end_time').value;
				start_date=DSDateAdd(datepart,-dnum,DSCreateDateTime('end_date','end_time'));
				month=start_date.getMonth()+1;
				startdate=start_date.getFullYear()+'-'+month+'-'+start_date.getDate();
				starttime=start_date.getHours()+':'+start_date.getMinutes();
			}
			$('start_date').value=startdate;
			$('display_start_date').innerHTML=DSDateTimeFormat('weekday_date',startdate);
			$('start_time').value=starttime;
			$('display_start_time').innerHTML=DSDateTimeFormat('time',starttime);
			$('display_'+change_date+'_time').style.display=_time_display;
		}
		else{
			change_date='end';
			if (period.value=='noend'){
				_date='2500-01-01';
				_date_show=DSLang('nodate');
				_time='23:59'
				_time_show=DSDateTimeFormat('time',_time)
				_time_display='none'
			}
			else{
				startdate=$('start_date').value;
				starttime=$('start_time').value;
				end_date=DSDateAdd(datepart,dnum,DSCreateDateTime('start_date','start_time'));
				month=end_date.getMonth()+1;
				_date=end_date.getFullYear()+'-'+month+'-'+end_date.getDate();
				_date_show=DSDateTimeFormat('weekday_date',_date);
				_time=end_date.getHours()+':'+end_date.getMinutes();
				_time_show=DSDateTimeFormat('time',_time)
				_time_display='block'
			}
			$(change_date+'_date').value=_date;
			$('display_'+change_date+'_date').innerHTML=_date_show;
			$(change_date+'_time').value=_time;
			$('display_'+change_date+'_time').innerHTML=_time_show;
			$('display_'+change_date+'_time').style.display=_time_display;
		}
	}
	//alert(datepart+'\n'+dnum+'\n'+start_date+'\n'+end_date);
 }
 
function period_chk(){
	//alert($('start_time').value);
	if ($('period')==null)
		return;
		
	var start_date_a=DSCreateDateTime('start_date','start_time');
	var end_date_a=DSCreateDateTime('end_date','end_time');
	
	var period=$('period');
	period.options[0].text='- - - - - - -';
	if ((end_date_a.getFullYear()==1901 || end_date_a.getFullYear()==2500) && end_date_a.getMonth()==0 && end_date_a.getDate()==1){
		period.options[period.length-1].selected=true;
		return; 
	}
	
	w_diff=0;
	d_diff=DSDateDiff('d',start_date_a,end_date_a)
	h_diff=DSDateDiff('h',start_date_a,end_date_a)
	n_diff=DSDateDiff('n',start_date_a,end_date_a)
	//period_option_list='none,wholeday,n-5,n-15,n-30,n-45,h-1,h-2,h-3,h-4,h-5,h-6,h-7,h-8,h-9,h-10,h-11,h-12,h-18,d-1,d-2,d-3,d-4,d-5,d-6,w-1,w-2,w-3,noend';
	if (d_diff > 6){
		w_diff=DSInt(d_diff/7);
		d_diff=d_diff-w_diff*7;
		h_diff=h_diff-w_diff*7*24;
		n_diff=n_diff-w_diff*7*24*60;
	}
	if (d_diff > 0){
		h_diff=h_diff-d_diff*24;
		n_diff=n_diff-d_diff*24*60;
	}
	if (h_diff > 0)
		n_diff=n_diff-h_diff*60;
	this_type='';
	if (w_diff==0 && d_diff==0 && h_diff==0 && n_diff>0)
		this_type='n';
	else if (w_diff==0 && d_diff==0 && h_diff>0 && n_diff==0)
		this_type='h';
	else if (w_diff==0 && d_diff>0 && h_diff==0 && n_diff==0)
		this_type='d';
	else if (w_diff>0 && d_diff==0 && h_diff==0 && n_diff==0)
		this_type='w';
	else if (h_diff==23 && n_diff==59)
		this_type='wholeday';
	else
		this_type='other';
	
	if (this_type=='other'){
		this_text='';			
		if (w_diff>0 || d_diff>0){
			this_diff=w_diff*7+d_diff*1
			if (this_diff>1)
				this_text+=this_diff+' Tage ';
			else
				this_text+=this_diff+' Tag ';	
		}
		if (h_diff>0)
			this_text+=h_diff+'h ';
		if (n_diff>0)
			this_text+=n_diff+'min ';
		period.options[0].text=this_text;
		period.options[0].selected=true;
	}
	else {
		period.options[0].text='- - - - - - -';
		if (this_type=='wholeday'){
			period.options[1].selected=true;
		}
		else {
			option_list=period_option_list.split(',');
			found_it=0;
			for (i=2;i<option_list.length;i++){
				this_value=option_list[i].split('-');
				if (this_value[0]==this_type && this_value[1]==eval(this_type+'_diff')){
					
					period.options[i].selected=true;
					found_it=i;
					break
				}
			}
			if (found_it==0){
				period.options[0].text=this_text;
				period.options[0].selected=true;
			}
		}
	}	
	//alert(start_date+'\n'+end_date+'\n w_diff:'+w_diff+'\n d_diff:'+d_diff+'\n h_diff:'+h_diff+'\n n_diff:'+n_diff+'\n this_type:'+this_type)
 }
 
 function period_adjust(DateTimeElement){
 	var period=$('period');
	if (period.value=='wholeday')
		return;
	start_end=$(DateTimeElement).name.split('_');
	if (start_end[0]=='start'){
		if (period.value=='none'){
			period_chk();
		}
		else if (period.value!='noend'){
			//if (dslang=='de')
				//period_check=confirm('Soll die eingestellte Dauer auf das Enddatum angewendet werden.');
			//else
				//period_check=confirm('Do you want to apply your setting to the start-period?\n(The end date will change automatically.)');
			period_check=true;
			if (period_check)
				DSPeriodWriteNewDateTime('start_date');
			else
				period_chk();
		}	
	}
	else{
		end_date=DSCreateDateTime('end_date','end_time');
		if ((end_date.getFullYear()==1901 || end_date.getFullYear()==2500) && end_date.getMonth()==0 && end_date.getDate()==1){
			period_chk();
		}
		else if (period.value=='noend' || period.value=='none'){
			period_chk();
		}
		else{		
			period_check=confirm(DSLang('alertapplysettingperiod'));
			if (period_check)
				DSPeriodWriteNewDateTime('end_date');
			else
				period_chk();
		}
	}
 }
  // End Period
  
  
function DSShowMonthList(e,year,month,day,view,dscalid){
	month_before=6;
	this_date=new Date(year,month,1,0,0,0);
	run_date=DSDateAdd('m',-month_before,this_date);
	html_str='';
	for (i=-month_before;i<=month_before;i++){
		this_year=run_date.getFullYear();
		this_month=run_date.getMonth();
		if (this_year==year && this_month==month)
			this_text='<b>'+MonthNames[this_month]+' '+this_year+'</b>';
		else
			this_text=MonthNames[this_month]+' '+this_year;
		if (view=='calendar_to_link')
			html_str+='<a class="dsconmenu" href="javascript: DSContextHide(); top.DSCalendar_Custom(\'month\','+this_year+','+this_month+','+day+','+dscalid+');">'+this_text+'</a>';
		else
			html_str+='<a class="dsconmenu" href="javascript: DSContextHide(); DSCalendarNewDataCHK('+this_year+','+this_month+','+day+',\''+view+'\','+dscalid+');">'+this_text+'</a>';
		run_date=DSDateAdd('m',1,run_date)
	}
	html_str+='<a class="dsconmenu" href="javascript: DSContextHide();"><b>'+DSLang('close')+'</b></a>';
	DSContextShow(e,html_str,'x_show="middle";y_show="middle";onmouseout=1;');
}


function DSMonthTotalDays(year,month){
	firstDay=startdate.getDay();
	lastDay=enddate.getDay();
	if (WeekStart=='s'){
		if (firstDay>0){
			startdate=DSDateAdd('d',-firstDay,startdate)
			totaldays=totaldays+firstDay;
		}
		if (lastDay<6){
			dayadd=6-lastDay;
			enddate=DSDateAdd('d',dayadd,enddate)
			totaldays=totaldays+dayadd;
		}
	}
	else{
		if (firstDay!=1){
			if (firstDay==0)
				dayadd=6;
			else
				dayadd=firstDay-1
			startdate=DSDateAdd('d',-dayadd,startdate);
			totaldays=totaldays+dayadd;
		}
		if (lastDay!=0){
			dayadd=7-lastDay;
			enddate=DSDateAdd('d',dayadd,enddate);
			totaldays=totaldays+dayadd;
		} 
	}
}


function DSCalendarNewDataCHK(year,month,day,view,dscalid,info){
	now = new Date(year,month,day);
	DSCal=eval('top.DSCal_'+dscalid);
	if (view=='form' || (now >= DSCal.range_startdate && now < DSCal.range_enddate)){
		DSCalendarView(year,month,day,view,dscalid,info);
	}
	else{
		month=month*1+1
		currdate=year+'-'+month+'-'+day;
		//alert(view)
		dsloader('dynasite.cfm?dscmd=calendar_calendar_calendar_view&currdate='+currdate+'&dscalid='+dscalid+'&calendar_load='+view,'dsloader');
	}
}

function DSCalendarScroll(datepart,dnum,year,month,day,view,dscalid,info) {
	now = new Date(year,month,day);
	now=DSDateAdd(datepart,dnum,now);
	year = now.getFullYear();
	month = now.getMonth();
	day = now.getDate();
	if (view=='calendar_to_link')
		DSCalendarView(year,month,day,view,dscalid,info);
	else
		DSCalendarNewDataCHK(year,month,day,view,dscalid,info)
}


function start_enddate_adjust(thisDateTimeElement){
	//alert($(thisDateTimeElement).readAttribute('thisname'))
	//start_end=$(thisDateTimeElement).readAttribute('thisname');
	start_end=$(thisDateTimeElement).name.split('_')[0];
	if (start_end=='start' && $('end_date')!=null){
		startdate=DSCreateDateTime('start_date','start_time');
		enddate=DSCreateDateTime('end_date','end_time');
		if (startdate>enddate){
			$('end_date').value=$('start_date').value;
			$('display_end_date').innerHTML=$('display_start_date').innerHTML;
			enddate=DSCreateDateTime('end_date','end_time');
			if (startdate>enddate){
				$('end_time').value=$('start_time').value;
				$('display_end_time').innerHTML=$('display_start_time').innerHTML;
			}
		}		
	}
	
	if (start_end=='end' && $('start_date')!=null){
		startdate=DSCreateDateTime('start_date','start_time');
		enddate=DSCreateDateTime('end_date','end_time');
		if (startdate>enddate){
			$('start_date').value=$('end_date').value;
			$('display_start_date').innerHTML=$('display_end_date').innerHTML;
			startdate=DSCreateDateTime('start_date','start_time');
			if (startdate>enddate){
				$('start_time').value=$('end_time').value;
				$('display_start_time').innerHTML=$('display_end_time').innerHTML;
			}
		}		
	}	
}

function DSCalendarNewDate(year,month,day,view,dscalid){
	if (view=='form'){
		olddate=$(thisDateElement).value;
		month=month*1+1;
		newdate=year+'-'+month+'-'+day;
		$(thisDateElement).value=newdate;
		
		do_period_chk=1; // NK 12.11.06 beim verstellen der startzeit soll keine Fehlermeldung bezüglich der endzeit auftreten,  daher ein verzicht auf periodenprüfung 
		
		if ((year==1901 || year==2500) && month==1 && day==1){
			show_date=DSLang('nodate');
			display_time='none';
		}
		else{
			show_date=DSDateTimeFormat('weekday_date',newdate)
			display_time='block';
		}
		
		if (DSPeriodFunction){
			period=$('period');
			if (period.value=='wholeday'){
				$('display_'+thisDateElement).innerHTML=show_date;
				DSContextHide();
				return;
			}
		}
		$(thisDisplayDateElement).innerHTML=show_date;
		
		start_enddate_adjust(thisDateElement);		
		chk_datetime_name=$(thisDateElement).name.split("_");
		if (chk_datetime_name.length==2){
			chk_time_name='display_'+chk_datetime_name[0]+'_time';
			if ($(chk_time_name)!=null)
				$(chk_time_name).style.display=display_time;
		}
		DSContextHide();
		
		if (DSPeriodFunction && do_period_chk==1){
			period_adjust(thisDateElement)
		}
	}
	else if (view=='calendar_to_link'){
		top.DSCalendar_Custom('day',year,month,day,dscalid);
	}
	else
		DSLoadCalendarView(year,month,day,'day',dscalid);		
	if (typeof DSCalendar_Custom_Validate=="function") 
		DSCalendar_Custom_Validate();
}

function DSCalendar_ContentCHK(view,dscalid){
	DSCal=eval('top.DSCal_'+dscalid);
	if ($('ds_calendar_'+view+'_'+dscalid)!=null){
		this_date=eval('top.DSCalInfo_'+dscalid+'.'+view+'_currdate');
		if (this_date < DSCal.range_startdate && this_date > DSCal.range_enddate)
			this_date=DSCal.calendar_currentdate;
	}
	else{
		this_date=DSCal.calendar_currentdate;
	}
	if (view=='week'){
		this_weekday=this_date.getDay();
		if (WeekStart=='s' && this_weekday!=0){
			this_date=DSDateAdd('d',-this_weekday,this_date);
		}
		else if (WeekStart=='m' && this_weekday!=1){
			if (this_weekday==0)
				this_weekday=6;
			else
				this_weekday--;
			this_date=DSDateAdd('d',-this_weekday,this_date);
		}
	}
	DSCalendarView(this_date.getFullYear(),this_date.getMonth(),this_date.getDate(),view,dscalid);
}


function DSLoadCalendarView(year,month,day,view,dscalid){
	if(typeof DSCalendarTree=='undefined')
		DSCalendarTree='dsmanagertree';
	DSCalInfo=eval('top.DSCalInfo_'+dscalid);
	DSCalInfo.view_to_load=view;
	DSCalInfo.view=view;
	this_date=new Date(year,month,day,0,0,0);
	eval('DSCalInfo.'+view+'_currdate=this_date');
	if ($('DSTree_'+DSCalendarTree+'_calendar_calendar_calendar_view_'+dscalid+'_link')!=null){
		DSDispatchEvent('DSTree_'+DSCalendarTree+'_calendar_calendar_calendar_view_'+dscalid+'_link');
	}
	else{
		DSDispatchEvent('DSTree_'+DSCalendarTree+'_module_calendar_calendar_view_link');
	}
	//DSDispatchEvent('DSTree_dsmanagertree_calendar_calendar_calendar_view_'+dscalid+'_link');
	DSDispatchEvent('aDSTabBar_CalendarNav_'+dscalid+'_ds_calendar_'+view+'_'+dscalid);
}

function DSCalendarView(year,month,day,view,dscalid,info){
	var i=0;
	if (view != 'form' && dscalid>0){
		DSContextHide();
		DSCal=eval('top.DSCal_'+dscalid);
		DSCalInfo=eval('top.DSCalInfo_'+dscalid);
		DSCalInfo.view=view;
		this_help_date=new Date(year,month,day,0,0,0);
		eval('DSCalInfo.'+view+'_currdate=this_help_date');
		allow_edit=0;
		if (DSArrayFind(DSCal.calendar_action,'edit'))
			allow_edit=1;
	}
	if (view != 'week' || view != 'day'){
		days=DSDaysInMonth(year,month)
		startdate=new Date(year,month,1);
		enddate=new Date(year,month,days,23,59,59);
		totaldays=days;
		DSMonthTotalDays(year,month);
	}
	if (view=='month_small' || view=='form' || view=='calendar_to_link'){		
		//alert('DSCalendarView'+year+','+month+','+day);		
		year_value='<strong>'+year+'</strong>';
		if (view=='form'){
			yearstart=$(thisDisplayDateElement).getAttribute('yearstart')
			yearend=$(thisDisplayDateElement).getAttribute('yearend');
			if (!isNaN(yearstart) && !isNaN(yearend) && yearstart!='' && yearend!=''){
				if (year>yearend)
					yearend=year+1;
				if (year<yearstart)
					yearstart=year-1;
				year_value='';
				year_value+='<select class="ds_calendar_month_small_select" size="1" id="help_yearlist" name="help_yearlist"  onChange="DSCalendarView(this.value,document.getElementById(\'help_monthlist\').value,'+day+',\''+view+'\','+dscalid+');">';
				for (i=yearstart;i<=yearend;i++){
					year_value+='<option value="'+i+'"'+((i==year)?' selected':'')+'>'+i+'</option>';
				}
				year_value+='</select>'
			}
		}
		else if (view=='calendar_to_link'){
			year_value='<a href="javascript: top.DSCalendar_Custom(\'year\','+year+','+month+','+day+','+dscalid+');"><strong>'+year+'</strong></a>';
		}
		
		html_str='<table cellspacing="0" id="dscalendar_month_small_yearnav"><tr>';
		html_str+='<td id="dscalendar_month_small_yearnav_left"><a href="javascript:DSCalendarScroll(\'year\',-1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&laquo;</a></td>';
		html_str+='<td id="dscalendar_month_small_yearnav_mid">'+year_value+'</td>';
		html_str+='<td id="dscalendar_month_small_yearnav_right"><a href="javascript:DSCalendarScroll(\'year\',1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&raquo;</a></td>';
		html_str+='</tr></table>';
		
		html_str+='<table cellspacing="0" id="dscalendar_month_small_monthnav"><tr>';
		html_str+='<td id="dscalendar_month_small_monthnav_left"><a href="javascript: DSCalendarScroll(\'month\',-1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&laquo;</a></td>';
		if (view=='month_small'){
			html_str+='<td id="dscalendar_month_small_monthnav_mid" onclick="DSShowMonthList(event,'+year+','+month+','+day+',\''+view+'\','+dscalid+')">'+MonthNames[month]+'</td>';
		}
		else{
			html_str+='<td id="dscalendar_month_small_monthnav_mid"><select class="ds_calendar_month_small_select" size="1" id="help_monthlist" name="help_monthlist"'
			if (view=='calendar_to_link')
				html_str+=' onChange="top.DSCalendar_Custom(\'month\','+year+',this.selectedIndex,1,'+dscalid+');">'
			else
				html_str+=' onChange="DSCalendarView('+year+',this.selectedIndex,'+day+',\''+view+'\','+dscalid+');">'
			for(i = 0; i <= 11; i++){
					selectcode='';
				if(i==month)
					selectcode=' selected="selected"';
				html_str+='<option value="'+i+'"'+selectcode+'>'+MonthNames[i]+'</option>';
			}
			html_str+='</select></td>';
		}
		html_str+='<td id="dscalendar_month_small_monthnav_right"><a href="javascript:DSCalendarScroll(\'month\',1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&raquo;</a></td>';
		html_str+='</tr></table>';
		
		html_str+='<table cellspacing="1" id="dscalendar_small">';		
		if (view=='month_small')
			html_str+='<tr id="dscalendar_month_small_dayname" onclick="DSLoadCalendarView('+year+','+month+','+day+',\'month\','+dscalid+')">';
		else
			html_str+='<tr id="dscalendar_month_small_dayname">'
		
		html_str+='<td>'+CalendarWeek+'</td>';
		for(i=0;i<7;i++){
			if (WeekStart=='s')
				this_day=i;
			else{
				this_day=i+1;
				if (this_day==7)
					this_day=0;
			}
			html_str+='<td>'+DayNamesShort[this_day]+'</td>';
		}
		html_str+='</tr>';		
		row=10;
		thisdate=startdate;
//top.DSCalendar_Custom(\'year\','+year+','+month+','+day+');
		for (i=1;i<=totaldays;i++){
			this_day=thisdate.getDate();
			this_month=thisdate.getMonth();
			this_year=thisdate.getFullYear();
			this_weekday=thisdate.getDay();
			if (row>=7){
				if (row>7)
					html_str+='</tr>';
				row=0;
				html_str+='<tr><td class="dscalendar_month_small_week">';
				if (view=='month_small')
					html_str+='<a href="javascript:DSLoadCalendarView('+this_year+','+this_month+','+this_day+',\'week\','+dscalid+')">'+DSWeekOfYear(this_year,this_month,this_day)+'</a></td>';
				else if (view=='calendar_to_link')
					html_str+='<a href="javascript:top.DSCalendar_Custom(\'week\','+this_year+','+this_month+','+this_day+','+dscalid+')">'+DSWeekOfYear(this_year,this_month,this_day)+'</a></td>';
				else
					html_str+=DSWeekOfYear(this_year,this_month,this_day)+'</td>';
			}
			//css=(this_day==day && this_month==month)?"dscalendar_month_small_active":((this_weekday==0 || this_weekday==6)?"dscalendar_month_small_weekend":"dscalendar_month_small_day");
			// css for link <a class="'+class+'"
			
			if (view=='calendar_to_link')
				tdcss=(this_day==top.DSCalendar_Custom_CurrentDate.getDate() && this_month==top.DSCalendar_Custom_CurrentDate.getMonth() && this_year==top.DSCalendar_Custom_CurrentDate.getFullYear())?" dscalendar_month_small_active":((this_weekday==0 || this_weekday==6)?" dscalendar_month_small_weekend":"");
			else
				tdcss=(this_day==day && this_month==month)?" dscalendar_month_small_active":((this_weekday==0 || this_weekday==6)?" dscalendar_month_small_weekend":"");
			html_str+='<td id="calendar_month_small_'+this_month+'_'+this_day+'_'+dscalid+'" class="dscalendar_month_small_day'+tdcss+'">';
			html_str+='<a href="javascript:DSCalendarNewDate('+this_year+','+this_month+','+this_day+',\''+view+'\','+dscalid+')">'+this_day+'</a></td>';
			thisdate=DSDateAdd('d',i,startdate);
			row++
		}

		if (view=='form'){
			now = new Date();
			year = now.getFullYear();
			month = now.getMonth();
			day = now.getDate();
			allow_no_date=info;
			html_str+='<tr height="35">';
			if (allow_no_date==1){
				html_str+='<td colspan="3" class="ds_calendar_footer" align="left"><a style="width:auto;" href="javascript: DSCalendarView('+year+','+month+','+day+',\'form\','+dscalid+')">'+DSLang('today')+'</a></td>';
				html_str+='<td colspan="2" class="ds_calendar_footer" align="center"><a style="width:auto;" href="javascript:DSCalendarNewDate(1901,0,1,\''+view+'\','+dscalid+');">'+DSLang('nodate')+'</a></td>';
				html_str+='<td colspan="3" class="ds_calendar_footer" align="right"><a style="width:auto;" href="javascript:DSContextHide();">'+DSLang('close')+'</a></td>';
			}
			else{
				html_str+='<td colspan="4" class="ds_calendar_footer" align="left"><a style="width:auto;" href="javascript: DSCalendarView('+year+','+month+','+day+',\'form\','+dscalid+')">'+DSLang('today')+'</a></td>';
				html_str+='<td colspan="4" class="ds_calendar_footer" align="right"><a style="width:auto;" href="javascript:DSContextHide();">'+DSLang('close')+'</a></td>';
			}
			
			html_str+='</tr>';
			//html_str+='</tr><td colspan="8">&nbsp;</td></tr>';
		}
		html_str+="</table>";
		if (view=='form')
			DSContextInnerHTML(html_str,1);
		else if (view=='month_small')
			$('ds_calendar_month_small_'+dscalid).innerHTML=html_str;
		else if (view=='calendar_to_link')
			$('ds_calendar_to_link_'+dscalid).innerHTML=html_str;
			
		if (view=='month_small' && DSCal!= null){
			loop_ok=0;
			for (ei=0;ei<DSCal.entries_length;ei++){
				if (DSCal.entries_show_date[ei] >= startdate && DSCal.entries_show_date[ei] < enddate){
					//alert(DSCal.entries_show_date[ei])
					$('calendar_month_small_'+DSCal.entries_show_date[ei].getMonth()+'_'+DSCal.entries_show_date[ei].getDate()+'_'+dscalid).className=' dscalendar_month_small_entry';
					loop_ok=1;
				}
				else if(loop_ok==1)
					break;
			}
		}
		
	}
	else if(view=='month'){
		//html_str='<div><a class="dscalendar_month_large_monthnav_left" href="javascript: DSCalendarScroll(\'month\',-1,'+year+','+month+','+day+',\''+view+'\','+dscalid+');">&laquo;</a><span style="width:300px; border:1px solid blue;"><a href="javascript:DSDoNothing()" class="dscalendar_month_large_monthnav_mid" onclick="DSShowMonthList(event,'+year+','+month+','+day+',\''+view+'\','+dscalid+')">'+MonthNames[month]+' '+year+'</a></span><a class="dscalendar_month_large_monthnav_right"><a href="javascript: DSCalendarScroll(\'month\',1,'+year+','+month+','+day+',\''+view+'\','+dscalid+');">&raquo;</a></div>';
			
		html_str='<table id="dscalendar_month_large_monthnav" class="dscalendar_month_large_monthnav" cellspacing="0" border="0">';
		html_str+='<tr>';
		html_str+='<td id="dscalendar_month_large_monthnav_left" class="dscalendar_month_large_monthnav_left"><a href="javascript: DSCalendarScroll(\'month\',-1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&laquo;</a></td>';
		html_str+='<td id="dscalendar_month_large_monthnav_mid" class="dscalendar_month_large_monthnav_mid"><a href="javascript:DSDoNothing()" onclick="DSShowMonthList(event,'+year+','+month+','+day+',\''+view+'\','+dscalid+')">'+MonthNames[month]+' '+year+'</a></td>';
		html_str+='<td id="dscalendar_month_large_monthnav_right" class="dscalendar_month_large_monthnav_right"><a href="javascript: DSCalendarScroll(\'month\',1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&raquo;</a></td>';
		html_str+='</tr></table>';
		
		
		html_str+='<table cellspacing="1" id="dscalendar_large"><tr id="dscalendar_month_large_dayname">';
		for(i=0;i<7;i++){
			if (WeekStart=='s'){
				this_day=i;
				html_str+='<td class="dscalendar_month_large_dayname">'+DayNamesShort[i]+'</td>';
			}
			else{
				this_day=i+1;
				if (this_day==7)
					this_day=0;
				if (WeekStart=="m" && SS_oneday==1 && this_day==6){
					html_str+='<td class="dscalendar_month_large_dayname">'+DayNamesShort[6]+' / '+DayNamesShort[0]+'</td>';
					break;
				}
				else{
					html_str+='<td class="dscalendar_month_large_dayname">'+DayNamesShort[this_day]+'</td>';
				}
			}
			
		}
		html_str+='</tr>';
		row=7;
		thisdate=startdate;
		for (i=1;i<=totaldays;i++){
			this_weekday=thisdate.getDay();
			this_day=thisdate.getDate();
			this_month=thisdate.getMonth();
			this_cf_month=this_month*1+1;
			this_year=thisdate.getFullYear();
			this_weekday=thisdate.getDay();
			if (row>=7){
				if (row>7)
					html_str+='</tr>';
				row=0;
				html_str+='<tr>';
			}
			css=(this_day==day && this_month==month)?"dscalendar_month_large_daynumber_active":((this_weekday==0 || this_weekday==6)?"dscalendar_month_large_daynumber_weekend":"dscalendar_month_large_daynumber");
			css='dscalendar_month_large_daynumber';
			tdcss=(this_day==day && this_month==month)?" dscalendar_month_large_active":((this_weekday==0 || this_weekday==6)?" dscalendar_month_large_weekend":"");
			if (WeekStart=="m" && SS_oneday==1){
				if (this_weekday==0 || this_weekday==6){
					if (this_weekday==0){
						html_str+='<tr>';
						html_str+='<td ondblclick="dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_event_new&amp;dscalid='+dscalid+'&amp;startdate='+this_year+'-'+this_cf_month+'-'+this_day+'\',\'dspopup2\')" id="calendar_month_'+this_month+'_'+this_day+'_'+dscalid+'" class="dscalendar_month_large_day'+tdcss+'"><a class="'+css+'" href="javascript:DSCalendarNewDate('+this_year+','+this_month+','+this_day+',\''+view+'\','+dscalid+')">'+this_day+'</a></td>';
						html_str+='</tr>';
					}
					else{
						html_str+='<td ondblclick="dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_event_new&amp;dscalid='+dscalid+'&amp;startdate='+this_year+'-'+this_cf_month+'-'+this_day+'\',\'dspopup2\')" id="calendar_month_'+this_month+'_'+this_day+'_'+dscalid+'" class="dscalendar_month_large_day'+tdcss+'"><a class="'+css+'" href="javascript:DSCalendarNewDate('+this_year+','+this_month+','+this_day+',\''+view+'\','+dscalid+')">'+this_day+'</a></td>';
					}
				}
				else{
					html_str+='<td rowspan="2" ondblclick="dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_event_new&amp;dscalid='+dscalid+'&amp;startdate='+this_year+'-'+this_cf_month+'-'+this_day+'\',\'dspopup2\')" id="calendar_month_'+this_month+'_'+this_day+'_'+dscalid+'" class="dscalendar_month_large_day'+tdcss+'"><a class="'+css+'" href="javascript:DSCalendarNewDate('+this_year+','+this_month+','+this_day+',\''+view+'\','+dscalid+')">'+this_day+'</a></td>';
				}
			}
			else{
				html_str+='<td ondblclick="dsloader(\''+dsxpath+'dynasite.cfm?dscmd=calendar_calendar_event_new&amp;dscalid='+dscalid+'&amp;startdate='+this_year+'-'+this_cf_month+'-'+this_day+'\',\'dspopup2\')" id="calendar_month_'+this_month+'_'+this_day+'_'+dscalid+'" class="dscalendar_month_large_day'+tdcss+'"><a class="'+css+'" href="javascript:DSCalendarNewDate('+this_year+','+this_month+','+this_day+',\''+view+'\','+dscalid+')">'+this_day+'</a></td>';
			}
			thisdate=DSDateAdd('d',i,startdate);
			row++
		}
		html_str+="</table>";
		
		$('ds_calendar_month_'+dscalid).innerHTML=html_str;

		loop_ok=0;
		//oncontextmenu="DSEntryContext(event,'+ei+','+dscalid+'); return false;" 
		for (ei=0;ei<DSCal.entries_length;ei++){
			if (DSCal.entries_show_date[ei] >= startdate && DSCal.entries_show_date[ei] < enddate){
				if (allow_edit)
					entry='<div class="dscalendar_month_large_entry" onmouseover="DSEventDetail(event,'+ei+','+dscalid+');" onclick="dsloader(\'dynasite.cfm?dscmd=calendar_calendar_event_edit&dscaleid='+DSCal.entries_id[ei]+'&dscalid='+dscalid+'\',\'dspopup2\')">'+DSCal.entries_title[ei]+'</div>';
				else
					entry='<div class="dscalendar_month_large_entry" onmouseover="DSEventDetail(event,'+ei+','+dscalid+');">'+DSCal.entries_title[ei]+'</div>';
				//alert(entry)
				$('calendar_month_'+DSCal.entries_show_date[ei].getMonth()+'_'+DSCal.entries_show_date[ei].getDate()+'_'+dscalid).innerHTML+=entry;
				loop_ok=1;
			}
			else if(loop_ok==1)
				break;
		}
	}
	else if(view=='week'){
		
		startdate=new Date(year,month,day);
		enddate=DSDateAdd('d',7,startdate);
		
		html_str='<table id="dscalendar_month_large_monthnav" class="dscalendar_month_large_monthnav" cellspacing="0" border="0">';
		html_str+='<tr>';
		html_str+='<td id="dscalendar_month_large_monthnav_left" class="dscalendar_month_large_monthnav_left"><a href="javascript: DSCalendarScroll(\'day\',-7,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&laquo;</a></td>';
		html_str+='<td id="dscalendar_month_large_monthnav_mid" class="dscalendar_month_large_monthnav_mid">'+DSWeekOfYear(year,month,day)+' in '+year+'</td>';
		html_str+='<td id="dscalendar_month_large_monthnav_right" class="dscalendar_month_large_monthnav_right"><a href="javascript: DSCalendarScroll(\'day\',7,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&raquo;</a></td>';
		html_str+='</tr></table>';

		
		html_str+='<table cellspacing="0" id="dscalendar_week"><tr>';

		c_str=""
		for(i=0;i<7;i++){
			thisdate=DSDateAdd('d',i,startdate);
			this_day=thisdate.getDate();
			this_month=thisdate.getMonth()+1;
			this_year=thisdate.getFullYear();
			if (WeekStart=="s")
				this_i=i;
			else{
				this_i=i+1;
				if (this_i==7)
					this_i=0;
			}
			html_str+='<tr>';
			html_str+='<td id="calendar_week_'+thisdate.getMonth()+'_'+this_day+'_'+dscalid+'" class="dscalendar_week_day" colspan="3" valign="top"><div class="dscalendar_week_day" style="cursor: pointer" onclick="DSCalendarView('+this_year+','+thisdate.getMonth()+','+this_day+',\'day\','+dscalid+')">'+DayNames[this_i]+' '+this_day+'.'+this_month+'.'+this_year+'</div></td>';
			html_str+='</tr>';
		}
		
		html_str+='</table>';
		$('ds_calendar_week_'+dscalid).innerHTML=html_str;

		loop_ok=0;
		for (ei=0;ei<DSCal.entries_length;ei++){
			if (DSCal.entries_show_date[ei]>=startdate && DSCal.entries_show_date[ei]<enddate){
				thisdate=DSCal.entries_show_date[ei];
				this_day=thisdate.getDate();
				this_month=thisdate.getMonth();
				if (allow_edit)
					entry='<div style="cursor: pointer" class="dscalendar_week_entry" onmouseover="DSEventDetail(event,'+ei+','+dscalid+');" onclick="dsloader(\'dynasite.cfm?dscmd=calendar_calendar_event_edit&dscaleid='+DSCal.entries_id[ei]+'\',\'dspopup2\')">'+DSCal.entries_title[ei]+'</div>';
				else
					entry='<div style="cursor: pointer" class="dscalendar_week_entry" onmouseover="DSEventDetail(event,'+ei+','+dscalid+');">'+DSCal.entries_title[ei]+'</div>';
				$('calendar_week_'+this_month+'_'+this_day+'_'+dscalid).innerHTML+=entry;
				loop_ok=1;
			}
			else if(loop_ok==1)
				break;
		}
		
		
	}
	
	else if(view=='day'){
		//document.getElementById('calendar_month_small_'+month+'_'+day).style.background='#EEEEEE';
		startdate=new Date(year,month,day,0,0,0);
		enddate=new Date(year,month,day,23,59,59);
		this_weekday=startdate.getDay();
		this_month=month*1+1;
		
		hour_height=20;
		day_width=650;
		day_height=DSInt(hour_height*24);		
		
		hour_width_left_listing=25;
				
		html_str='<div align="center" style="width:'+day_width+'px;"><table id="dscalendar_month_large_monthnav" class="dscalendar_month_large_monthnav" cellspacing="0" border="0">';
		html_str+='<tr>';
		html_str+='<td id="dscalendar_month_large_monthnav_left" class="dscalendar_month_large_monthnav_left"><a href="javascript: DSCalendarScroll(\'day\',-1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&laquo;</a>&nbsp;</td>';
		html_str+='<td id="dscalendar_month_large_monthnav_mid" class="dscalendar_month_large_monthnav_mid">'+DayNames[this_weekday]+', den '+day+'.'+this_month+'.'+year+'</td>';
		html_str+='<td id="dscalendar_month_large_monthnav_right" class="dscalendar_month_large_monthnav_right">&nbsp;<a href="javascript: DSCalendarScroll(\'day\',1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&raquo;</a></td>';
		html_str+='</tr>';
		html_str+='</table></div>';
		html_str+='<div id="calendar_day_'+day+'_'+dscalid+'" style="position:relative;">';
		html_str+='<table cellpadding="0" cellspacing="0" border="0">';
		for (i=0;i<=24;i++){
			if (i<10)
				real_i='0'+i;
			else
				real_i=i;
			html_str+='<tr height="'+hour_height+'"><td width="'+hour_width_left_listing+'">'+real_i+'</td><td><hr color="#DDDDDD" noshade="noshade" size="1" width="'+day_width+'"/></td></tr>';
		}
		html_str+='</table>';
		loop_ok=0;
		this_top=0;
		entry_list=new Array();
		entry_col=new Array();
		max_col=1;
		for (ei=0;ei<DSCal.entries_length;ei++){
			if (DSCal.entries_show_date[ei] >= startdate && DSCal.entries_show_date[ei] < enddate){
				entry_length=entry_list.length;
				entry_list[entry_length]=ei;
				entry_col[entry_length]=1;
				if (entry_length>0){
					for (ii=entry_length-1;ii>=0;ii--){
						if (DSCal.entries_end_date[entry_list[ii]]>DSCal.entries_show_date[ei]){
							this_col=entry_col[ii]+1;
							if (this_col>max_col)
								max_col=this_col;					
							entry_col[entry_length]=this_col;
							break;
						}
					}
				}
				html_str+='<div id="day_entry_time_'+ei+'_'+dscalid+'" style="position:absolute; border:0px solid blue; padding:0px; margin:0px; z-index:2; width:5px; height:5px; background-color: blue;"></div>';
				if (allow_edit)
					html_str+='<div id="day_entry_'+ei+'_'+dscalid+'" style="position:absolute; border:1px solid #333333; z-index: 1; padding-left:5px; background-color: #EFEBDE;" onmouseover="DSEventDetail(event,'+ei+','+dscalid+');" onclick="dsloader(\'dynasite.cfm?dscmd=calendar_calendar_event_edit&dscaleid='+DSCal.entries_id[ei]+'\',\'dspopup2\')">'+DSCal.entries_title[ei]+'</div>';
				else
					html_str+='<div id="day_entry_'+ei+'_'+dscalid+'" style="position:absolute; border:1px solid #333333; z-index: 1; padding-left:5px; background-color: #EFEBDE;" onmouseover="DSEventDetail(event,'+ei+','+dscalid+');">'+DSCal.entries_title[ei]+'</div>';
				loop_ok++;
			}
			else if(loop_ok>0)
				break;
		}
		
		
		html_str+='</div>';
		
		$('ds_calendar_day_'+dscalid).innerHTML=html_str;
		
		day_width=day_width-(hour_width_left_listing*1);
		
		for (i=0;i<entry_list.length;i++){		
			ei=entry_list[i];
			start_min=DSCal.entries_show_date[ei].getHours()*60+DSCal.entries_show_date[ei].getMinutes();
			if (DSCal.entries_end_date[ei]<enddate)
				end_min=DSCal.entries_end_date[ei].getHours()*60+DSCal.entries_end_date[ei].getMinutes();
			else
				end_min=1440;
			this_top=day_height*start_min/1440
			this_top=DSInt(this_top+hour_height/2)
			this_height=end_min-start_min;
			this_height=day_height*this_height/1440
			this_height=DSInt(this_height);
			if (this_height<1)
				this_height=1;
			this_width=DSInt(day_width/max_col);
			this_left=(this_width+10)*(entry_col[i]-1)+hour_width_left_listing;
			
			//alert(this_top+'px '+this_height+'px '+this_width+'px '+this_left+'px');
			
			this_entry=$('day_entry_'+ei+'_'+dscalid);
			this_entry.style.top=this_top+'px';
			if (this_height>25)
				this_entry.style.height=this_height+'px';
			this_entry.style.width=this_width+'px';
			this_entry.style.left=this_left+'px';

			time_entry=$('day_entry_time_'+ei+'_'+dscalid);
			time_entry.style.top=this_top+'px';
			time_entry.style.height=this_height+'px';
			time_entry.style.left=this_left+'px';

			//if (this_height>25 && max_col<=2){
				event_start_date='';
				if (DSCal.entries_start_date[ei]<startdate)
					event_start_date+=DayNamesShort[DSCal.entries_start_date[ei].getDay()]+', '+DSDateTimeFormat('date',DSCal.entries_start_date[ei])+' ';
				event_start_date+=DSDateTimeFormat('time',DSCal.entries_start_date[ei])
				event_end_date='';
				if (DSCal.entries_end_date[ei]>enddate)
					event_end_date+=DayNamesShort[DSCal.entries_end_date[ei].getDay()]+', '+DSDateTimeFormat('date',DSCal.entries_end_date[ei])+' ';
				event_end_date+=DSDateTimeFormat('time',DSCal.entries_end_date[ei]);
				this_entry.innerHTML+='<br />('+event_start_date+' - '+event_end_date+')';
			//}
			//else{
				//this_entry.style.fontSize='7pt';
			//}
			//this_entry.innerHTML+='start:'+start_min+' top:'+this_top+' height:'+this_height;
		}
	}
	else if(view=='overview_small'){
		
		now = new Date();
		now = new Date(now.getYear(), now.getMonth(),now.getDate(), 0, 0, 0);
		html_str='';
		maxshow=25;

		html_str+='<div align="center"><table class="dstable">';
		css_run=0;
		for (ei=0;ei<DSCal.entries_length;ei++){
			if (DSCal.entries_start_date[ei]>now){
				if ( DSInt(css_run/2) == css_run/2 ){
					css='dslist1';
				}
				else{
					css='dslist2';			
				}
				startdate=DSDateTimeFormat('date',DSCal.entries_start_date[ei])+' '+DSDateTimeFormat('time',DSCal.entries_start_date[ei]);
				html_str+='<tr class="'+css+'">';
				html_str+='<td style="vertical-align:top;white-space:nowrap;text-align:left">'+startdate+'</td>';
				if (allow_edit)
					html_str+='<td onmouseover="DSEventDetail(event,'+ei+','+dscalid+');" onclick="dsloader(\'dynasite.cfm?dscmd=calendar_calendar_event_edit&dscaleid='+DSCal.entries_id[ei]+'&dscalid='+dscalid+'\',\'dspopup2\')" style="padding-left:4px;text-align:left">'+DSCal.entries_title[ei]+'</td>';
				else
					html_str+='<td onmouseover="DSEventDetail(event,'+ei+','+dscalid+');" style="padding-left:4px;text-align:left">'+DSCal.entries_title[ei]+'</td>';
				html_str+='</tr>';
				css_run++;
			}
			if (css_run >= maxshow){
				break;
			}
		}
		html_str+='</table></div>';
		$('ds_calendar_overview_small_'+dscalid).innerHTML=html_str;
		$('ds_calendar_overview_small_'+dscalid).style.display='block';
	}
	else if(view=='overview'){
		now = new Date();
		now = new Date(now.getYear(), now.getMonth(),now.getDate(), 0, 0, 0);
		
		
		html_str='<table id="dscalendar_month_large_monthnav" class="dscalendar_month_large_monthnav" cellspacing="0" border="0">';
		html_str+='<tr>';
		html_str+='<td id="dscalendar_month_large_monthnav_left" class="dscalendar_month_large_monthnav_left"><a href="javascript: DSCalendarScroll(\'month\',-1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&laquo;</a></td>';
		html_str+='<td id="dscalendar_month_large_monthnav_mid" class="dscalendar_month_large_monthnav_mid"><a href="javascript:DSDoNothing()" onclick="DSShowMonthList(event,'+year+','+month+','+day+',\''+view+'\','+dscalid+')">'+MonthNames[month]+' '+year+'</a></td>';
		html_str+='<td id="dscalendar_month_large_monthnav_right" class="dscalendar_month_large_monthnav_right"><a href="javascript: DSCalendarScroll(\'month\',1,'+year+','+month+','+day+',\''+view+'\','+dscalid+',\''+info+'\');">&raquo;</a></td>';
		html_str+='</tr></table>';
		
		html_str+='<table cellpadding="1" cellspacing="0" border="0" width="100%">';
		css_run=0;
		for (ei=0;ei<DSCal.entries_length;ei++){
			if (DSCal.entries_start_date[ei].getMonth()==month){
				if ( DSInt(css_run/2) == css_run/2 ){
					if (DSCal.entries_start_date[ei]>=now)
						css='class="dslist1"';
					else
						css='bgcolor="#c0c0c0"';	
				}
				else{
					if (DSCal.entries_start_date[ei]>=now)
						css='class="dslist2"';
					else
						css='bgcolor="#e0e0e0"';			
				}
				this_startdate=DSDateTimeFormat('date',DSCal.entries_start_date[ei]);
				html_str+='<tr '+css+'>';
				html_str+='<td align="left" valign="top" width="80">'+this_startdate+'</td>';
				if (allow_edit)
					html_str+='<td align="left" onclick="dsloader(\'dynasite.cfm?dscmd=calendar_calendar_event_edit&dscaleid='+DSCal.entries_id[ei]+'&dscalid='+dscalid+'\',\'dspopup2\')">'+DSCal.entries_title[ei];
				else
					html_str+='<td align="left">'+DSCal.entries_title[ei];
				html_str+='<div>Start: '+DSDateTimeFormat('time',DSCal.entries_start_date[ei])+'</div>';
				html_str+='<div>Ende: '+DSDateTimeFormat('time',DSCal.entries_end_date[ei])+'</div>';
				html_str+='</td>';
				html_str+='</tr>';
				css_run++
			}
		}
		html_str+='</table></div>';
		
		$('ds_calendar_overview_'+dscalid).innerHTML=html_str;

	}
	//if(view!='day') dscalendar_monthselect
		//DSPopUpResize();	
}



function DSEventDetail(e,ei,dscalid){
	DSCal=eval('top.DSCal_'+dscalid);
	//top.DSCal_#dscalid#.calendar_action
	startdate=DSDateTimeFormat('date',DSCal.entries_start_date[ei])+' '+DSDateTimeFormat('time',DSCal.entries_start_date[ei]);
	enddate=DSDateTimeFormat('date',DSCal.entries_end_date[ei])+' '+DSDateTimeFormat('time',DSCal.entries_end_date[ei]);
	html_str='<div class="dscontextmenucontent">'
	
	if (DSArrayFind(DSCal.calendar_action,'edit'))
		html_str+='<a class="dsconmenu" href="javascript: DSContextHide(); dsloader(\'dynasite.cfm?dscmd=calendar_calendar_event_edit&dscaleid='+DSCal.entries_id[ei]+'&dscalid='+dscalid+'\',\'dspopup2\')">'+DSLang('edit')+'</a>';
	//html_str+='<div class="dscalendar_monthselect" style="font-weight:bold;">'+DSCal.entries_createdname[ei]+'</div>';
	html_str+='<div class="dsconmenu">Start: '+startdate+'</div>';
	html_str+='<div class="dsconmenu">Ende: '+enddate+'</div>';
	html_str+='<div class="dsconmenu">'+DSCal.entries_title[ei]+'</div>';
	//html_str+='<a class="dscalendar_monthselect dsconmenu" href="javascript: DSContextHide(); DSEntryDeleteConfirm('+DSCal.entries_id[ei]+','+dscalid+');">Delete</a>';
	DSColorSchemeBar(3,'variable');
	html_str+='<div class="dscontextmenutitle">Event ['+DSCal.entries_id[ei]+']</div>'+colorschemebar+'</div></div>';
	DSContextShow(e,html_str,'onmouseout=1;');
}

function DSEventDeleteConfirm(dscaleid,dscalid){
	ok=confirm(DSLang('alertdeleteevent'));
	if (ok){
		self.location.href='dynasite.cfm?dscmd=calendar_calendar_event_delete&dscaleid='+dscaleid+'&dscalid='+dscalid;
	}
}


function DSTaskDeleteConfirm(dscaleid,dscalid){
	ok=confirm(DSLang('alertdeletetask'));
	if (ok)
		self.location.href='dynasite.cfm?dscmd=calendar_calendar_task_delete&dscaleid='+dscaleid+'&dscalid='+dscalid;
}

function DSTaskStatusConfirm_xxxxxxxxx (newstatus,dscaleid,querystring){
		//ok=confirm('Do you realy want to set the Task to "'+status_list_en[newstatus]+'"?')
	ok=true;
	if (ok){
		dsloader('dynasite.cfm?dscmd=calendar_calendar_task_status&dscaleid='+dscaleid+'&newstatus='+newstatus+querystring,'dsloader');
	}
	DSContextHide();
}

function DSTaskStatus(e,status,dscaleid,querystring){
	var i=0;
	if (querystring==null)
		querystring='';
	html_str='<div class="dscontextmenucontent">';
	html_str+='<a class="dsconmenu" href="javascript:DSContextHide(); dsloader(\'dynasite.cfm?dscmd=calendar_calendar_task_edit&dscaleid='+dscaleid+querystring+'\',\'dspopup2\')">'+DSLang('edit')+'</a>';
	for (i=0;i<status_list_en.length;i++){
		if (status==status_list_en[i])
			this_val='<strong>'+status_list_de[i]+'</strong>';
		else
			this_val=status_list_de[i];	
		html_str+='<a class="dsconmenu" href="javascript:DSContextHide(); dsloader(\'dynasite.cfm?dscmd=calendar_calendar_task_status&amp;dscaleid='+dscaleid+'&amp;newstatus='+status_list_en[i]+querystring+'\',\'dsloader\')">'+this_val+'</a>';
		//html_str+='<a class="dsconmenu" href="javascript: DSTaskStatusConfirm(\''+status_list_en[i]+'\','+dscaleid+',\''+querystring+'\');">'+this_val+'</a>';
	}		
	DSColorSchemeBar(3,'variable');
	html_str+='<div class="dscontextmenutitle">'+DSLang('Task')+' ['+dscaleid+']</div>'+colorschemebar+'</div></div>';
	DSContextShow(e,html_str);
}
document.write('<link rel="stylesheet" type="text/css" charset="utf-8" href="'+DSGlobalPath+'script/jscalendar/calendar-blue3.css"/>');
document.write('<script type="text/javascript" charset="utf-8" src="'+DSGlobalPath+'script/jscalendar/calendar.js"></script>');
document.write('<script type="text/javascript" charset="utf-8" src="'+DSGlobalPath+'script/jscalendar/lang/calendar-'+dslang+'.js"></script>');
document.write('<script type="text/javascript" charset="utf-8" src="'+DSGlobalPath+'script/jscalendar/calendar-setup.js"></script>');
if(window.navigator.appName=="Microsoft Internet Explorer")
	var IE=Number(navigator.appVersion.substr(navigator.appVersion.search("MSIE")+5,1));
else 
	var IE=false;
document.write('<link rel="stylesheet" type="text/css" charset="utf-8" href="'+DSGlobalPath+'script/dscalendarnew/css/result.css"/>');
document.write('<link rel="stylesheet" type="text/css" charset="utf-8" href="'+DSGlobalPath+'script/dscalendarnew/css/dialog.css"/>');

//AppointmentCalendar
var AppointmentCalendar=Class.create({
   
   	GETFORDAY:1,
	GETFORWEEK:2,
	GETFORMONTH:3,
	GETAGENDA:4,
	
	initialize: function(view,resContainer,calContainer,urls,calid,uid,showOwners,isEditable,calOnlickLink) {
		var that=this;
		this.actAction=null;
		this.actDate=new Date();
		this.appointment_days=null;
		this.calendar=null;
		this.editor=null;
		this.model=null;
		this.owners=new Object();
		this.refresh=true;
		this.resCont=null;
		this.view=null;
		this.timer=null;
		this.isCalendarAct=false;
		this.displayOwners=showOwners;
		this.isEditable=isEditable? isEditable:false;
		this.calOnlick=null;
		if(calOnlickLink && calOnlickLink!=""){
			this.calOnlickLink=calOnlickLink;
			this.calOnclick=function(){
					DSDispatchEvent(that.calOnlickLink); 
			}
		}
		this.URL={
			appointments:null,
			newappointment:null,
			remove:null,
			getOwners:null,
			updateOwner:null
		};
		this.URL=urls;
		this.uid=uid;
		this.isSmalInitialized=false;
		this.isBigInitialized=false;
		this.calid=calid;
		this.calContainer=calContainer;
		this.model=new CalendarModel(this);
		if(view=="month_small" || view=="month_big_small"){
			this.isSmalInitialized=true;
			$(this.calContainer).show();
			this.setCalender();
			this.loadAppointments();
		}
		this.actAction=this.GETFORMONTH;
		if(view=="month_big" || view=="month_big_small"){
			this.result=resContainer+"_result";
			var tmp=new Element("div",{"id":this.result});
			var rc=$(resContainer);
			rc.addClassName("dscal_container");
			rc.insert(tmp);
			var rcw=rc.getWidth();
			tmp.style.width=rcw>=350? (rcw-5)+"px":"500px";
			var rch=rc.getHeight();
			tmp.style.height=rch>=350? (rch-5)+"px":"500px";
			this.height=tmp.getHeight();
			this.width=tmp.getWidth();
			this.resCont=$(this.result);
			this.resCont.addClassName("dscal_result");
			this.view=new CalendarView(this.resCont, this,this.result);
			if(view!="month_big_small")
				this.setCalender();
			if(this.displayOwners){
				if(!$(this.result+"_favorites")){
					this.minusOwnerWidth=true;
					$(resContainer).insert("<div id='"+this.result+"_favorites' class='dscal_favorites_container'></div>");
				}
			}
			this.getOwners();
		}
		this.seldate1=null;
		this.seldate2=null;
		//this.result=resContainer;
	},
	reInitialize:function(view,resContainer,calContainer,showOwners,isEditable,urls,calOnlickLink){
		this.URL=urls;
		this.displayOwners=showOwners;
		this.isEditable=isEditable? isEditable:this.isEditable;
		this.calOnlick=null;
		if(calOnlickLink && calOnlickLink!=""){
			this.calOnlickLink=calOnlickLink;
			this.calOnclick=function(){
					DSDispatchEvent(that.calOnlickLink); 
			}
		}
		if(view=="month_small" || view=="month_big_small"){
			this.calContainer=calContainer;
			this.isSmalInitialized=true;
			this.calendar.destroy();
			this.setCalender();
			$(this.calContainer).show();
			this.loadAppointments();
		}else if(view=="month_big" || view=="month_big_small"){
			this.isBigInitialized=false;
			this.result=resContainer+"_result";
			var tmp=new Element("div",{"id":this.result});
			var rc=$(resContainer);
			rc.addClassName("dscal_container");
			rc.insert(tmp);
			var rcw=rc.getWidth();
			tmp.style.width=rcw>200? (rcw-5)+"px":"500px";
			var rch=rc.getHeight();
			tmp.style.height=rch>200? (rch-5)+"px":"500px";
			this.height=tmp.getHeight();
			this.width=tmp.getWidth();
			this.resCont=$(this.result);
			this.resCont.addClassName("dscal_result");
			this.view=new CalendarView(this.resCont, this,this.result);
			if(view!="month_big_small" && !$(this.calContainer)){
				this.calendar.destroy();
				this.setCalender();
			}
			if(this.displayOwners){
				if(!$(this.result+"_favorites")){
					this.minusOwnerWidth=true;
					$(resContainer).insert("<div id='"+this.result+"_favorites'  class='dscal_favorites_container'></div>");
				}
			}
			this.getOwners();
		}
	},
	showQuickForm:function(event,ftn,withHours){
		var that=this;
		if(this.seldate1<this.seldate2){
			var fdate=this.seldate1.print("%Y-%m-%d %H:%M");
			var tdate=this.seldate2.print("%Y-%m-%d %H:%M");
		}
		else{
			var fdate=this.seldate2.print("%Y-%m-%d %H:%M");
			var tdate=this.seldate1.print("%Y-%m-%d %H:%M");
		}
		new Ajax.Request(that.URL.quickform, {
		  method: 'post',
		  parameters:'fulltime_from='+fdate+'&fulltime_to='+tdate+'&fulltime_recurrence='+tdate,
		  onComplete: function(transport) {
			Dialog.setMsg(transport.responseText);
			Dialog.setFooter("");
			Dialog.info(event,ftn);
		  }
		});
		/*
		var sbmt=new Element('input',{'type':'button','value':DSLang('Save'),'class':'ds_button'});
		sbmt.observe("click",function(){
			that.createAppointment($(that.calid+'_quick_app_title').value);
		});
		var footer=new Element("div");
		footer.insert(sbmt);
		var dateilslink=new Element("a",{href:that.URL.newappointment});
		dateilslink.update(DSLang("Details"));
		footer.insert("&nbsp;&nbsp;");
		footer.insert(dateilslink);
		var format=withHours? "%a %d.%m.%Y %H:%M":"%a %d.%m.%Y";
		if(this.seldate1<this.seldate2){
			tmpstr=this.seldate1.print(format)+" - "
			+this.seldate2.print(format);
		}
		else{
			tmpstr=this.seldate2.print(format)+" - "
			+this.seldate1.print(format);
		}
		var msg="<div>"+tmpstr+"</div>\
		<div><div class='ds_label'>"+DSLang("Title")+"&nbsp;</div><div class='ds_field' style='width:150px'><input type='text' class='ds_text' id='"+this.id+"_quick_app_title' name='title'/></div></div>\
		";
		Dialog.setFooter(footer);
		Dialog.setMsg(msg);
		Dialog.info(event,ftn);
		$(this.id+'_quick_app_title').focus();
		*/
	},
	showAll:function(date,event){
		var obj=this.model.appointments_long;
		var divAll=new Element("div",{"style":"width:250px"});
		for(ap in obj){
			if(obj[ap].isEqualsDay(date)){
				if(this.owners[obj[ap].owner_id].show==1){
					var ld="<div class='side'></div>";
					var rd="<div class='side'></div>";
					var that=obj[ap];
					if(obj[ap].isActive=="Maybe" ||obj[ap].isActive=="Unconfirmed")
						sings="? ";
					var div=new Element('div',{"class": "appointment","align":"left", 'style':'position:static'});
					div.observe('click', function(){that.show()});
					divAll.insert(div);
					if(obj[ap].isActive=="Cancelled")
							div.style.textDecoration="line-through";
					div.update("<div class='appointment_title' style='position:static; border-right:1px solid #DDDDDD;width:99%'><div class='spacer'></div><div class='text'>"+obj[ap].what+"</div></div>");
					div.style.backgroundColor=this.owners[obj[ap].owner_id].color;
				}
			}
		}
		var obj=this.model.appointments_short;
		for(ap in obj){
			if(obj[ap].isEqualsDay(date)){
				if(this.owners[obj[ap].owner_id].show==1){
					var ld="<div class='side'></div>";
					var rd="<div class='side'></div>";
					var that=obj[ap];
					if(obj[ap].isActive=="Maybe" ||obj[ap].isActive=="Unconfirmed")
						sings="? ";
					var div=new Element('div',{"class": "appointment","align":"left", 'style':'position:static'});
					div.observe('click', function(){that.show()});
					divAll.insert(div);
					if(obj[ap].isActive=="Cancelled")
							div.style.textDecoration="line-through";
					div.update("<div class='appointment_title' style='position:static; border-right:1px solid #DDDDDD;;width:99%'><div class='spacer'></div><div class='text'>"+obj[ap].from_date.print("%H:%M")+" "+obj[ap].what+"</div></div>");
					div.style.color=this.owners[obj[ap].owner_id].color;
				}
			}
		}
		Dialog.setMsg(divAll);
		Dialog.info(event);
		
	},
	changeDate:function(int){
		switch(this.actAction){
				case this.GETFORMONTH:
						var tmpdate=new Date(this.calendar.date);
						tmpdate.setMonth(tmpdate.getMonth()+int);
						break;
				case this.GETFORDAY:
						var tmpdate=new Date(this.calendar.date);
						tmpdate.setDate(tmpdate.getDate()+int);
					break;
				case this.GETFORWEEK:
						var tmpdate=new Date(this.calendar.date);
						tmpdate.setDate(tmpdate.getDate()+(int*7));
					break;
				default:
					var tmpdate=new Date(this.calendar.date);
					tmpdate.setDate(tmpdate.getDate()+int);
				}
		this.calendar._init(this.calendar.firstDayOfWeek,tmpdate);
		this.showAppointments();
	},
	createAppointment:function(title){
		/*this.editor=new AppointmentEditor(this);
		this.editor.create();*/
		var that=this;
		if(title=='') title=DSLang("noname");
		if(this.seldate1<this.seldate2){
			var fdate=this.seldate1.toLocaleString();
			var tdate=this.seldate2.toLocaleString();
		}
		else{
			var fdate=this.seldate2.toLocaleString();
			var tdate=this.seldate1.toLocaleString();
		}
		new Ajax.Request(that.URL.newappointment, {
							  method: 'post',
							  parameters:'title='+title+'&fulltime_from='+fdate+'&fulltime_to='+tdate+'&fulltime_recurrence='+tdate,
							  onComplete: function(transport) {
								that.refresh=true;
								that.loadAppointments();
							  }
							});
		Dialog.close();
	},
	removeAppointment:function(appointment){
		var that=this;
		new Ajax.Request(that.URL.remove+appointment.id, {
							  method: 'post',
							  onComplete: function(transport) {
								that.refresh=true;
								that.loadAppointments();
							  }
							});
	},
	editAppointment:function(appointment){
		/*this.editor=new AppointmentEditor(this);
		this.editor.edit(appointment);*/
	},
	showDetails:function(appointment){
		var that=this;
		new Ajax.Request(that.URL.details+appointment.id+"&owner_id="+appointment.owner_id, {
		  method: 'post',
		  evalScripts: true,
		  onComplete: function(transport) {
			Dialog.setMsg(transport.responseText);
			Dialog.info();
		  }
		});
	},
	dateIsSpecial:function(date,year, month, day) {
		if(!this.appointment_days[date.getFullYear()])
			return false;
		if(!this.appointment_days[date.getFullYear()][date.getMonth()])
			return false;
		return this.appointment_days[date.getFullYear()][date.getMonth()][date.getDate()]? true:false;
	},
	
	setOwnerColor:function(elm,id,color){
		this.owners[id].color=color;
		elm.style.backgroundColor=color;
		this.updateOwner(id);
	},
	setOwnerShow:function(id){
		if(this.owners[id].show==1)this.owners[id].show=0;
		else this.owners[id].show=1;
		this.updateOwner(id);
	},	
		
	updateOwner:function(id){
		var that=this;
		var qs="owner_id="+id+"&color="+this.owners[id].color+"&show="+this.owners[id].show;
		new Ajax.Request(that.URL.updateOwner, {
							  method: 'post',
							  parameters: qs,
							  onSuccess: function() {
								that.refresh=true;
								that.loadAppointments();
							  }
							});
	},
	
	initOwners:function(){
		if(this.displayOwners){
			var that=this;
			var ows=Object.keys(this.owners);
			$(this.result+'_favorites').update("");
			ows.each(function(e){
				var owner=that.owners[e];
				if(owner.show==1)
					var ch=true;
				else
					var ch=false; 
				var tmpd=new Element('div',{'class':'favorite'});
				var tmpch=new Element("input",{"type":"checkbox"});
				var tmpid=e;
				tmpch.observe("click",function(){
											that.setOwnerShow(tmpid);   
											  });
				var tmpbtn=new Element("div",{"class":"favorite_button","style":'background-color: '+owner.color}).update(owner.name);
				tmpbtn.observe("click",function(event){
											colorPicker.showPicker(event,function(elm, color){that.setOwnerColor(elm,tmpid,color)});   
											  });
				var tmpdiv1=new Element("div",{"class":"div_10percent"}).insert(tmpch);
				var tmpdiv2=new Element("div",{"class":"div_90percent"}).insert(tmpbtn);
				tmpd.insert(tmpdiv1);
				tmpd.insert(tmpdiv2);
				$(that.result+'_favorites').insert(tmpd);  
				tmpch.checked=ch;
			});
			if(!this.isBigInitialized){
				if(this.minusOwnerWidth){
					this.resCont.style.width=this.resCont.getWidth()-$(this.result+'_favorites').getWidth()+"px";
					this.width=this.resCont.getWidth();
				}
				this.isBigInitialized=true;
			}
		}else
			this.isBigInitialized=true;
		this.loadAppointments();
	},
	
	getOwners:function(){
		var that=this;
		new Ajax.Request(that.URL.getOwners, {
		  method: 'post',
		  onSuccess: function(transport) {
			if(transport.responseText)
				{
					that.owners=transport.responseText.evalJSON();
					that.initOwners();
				}
		  }
		});
		/*this.owners={"1":{"name":"Aleks","color":"rgb(255,102,102)","show":"1"}};
		this.initOwners();*/
	},
	
	showAppointments:function (){
		if(this.isBigInitialized){
			if((this.actDate.getYear()!=this.calendar.date.getYear())||(this.actDate.getMonth()!=this.calendar.date.getMonth())){
				this.actDate.setTime(this.calendar.date.getTime());
				this.refresh=true;
				this.loadAppointments(this.calendar.date);
			}
			else {
				switch(this.actAction){
				case this.GETFORMONTH:
						$(this.result+'_datetime').update(this.calendar.date.print("%B %Y"));
						if(this.refresh){
							this.view.showForMonth();
								this.refresh=false;
						}
						break;
				case this.GETFORDAY:
						$(this.result+'_datetime').update(this.calendar.date.print("%a %d.%m.%Y"));
						this.view.showForDay();
						this.refresh=false;
					break;
				case this.GETFORWEEK:
						$(this.result+'_datetime').update(this.calendar.date.print(""));
						if(this.actDate.getWeekNumber()!=this.calendar.date.getWeekNumber()||this.refresh){
							this.actDate.setTime(this.calendar.date.getTime());
							this.view.showForWeek();
							this.refresh=false;
						}
					break;
				case this.GETAGENDA:
						$(this.result+'_datetime').update(this.calendar.date.print("%a %d.%m.%Y"));
						this.view.showAgenda();
						this.refresh=false;
					break;
				default:
				}
			};
		}
	},
	
	dateChanged:function() {
			if(this.calOnclick)
				this.calOnclick();
			this.showAppointments();
	},
	
	DateStatusFunc:function (date,y, m, d) {
		if(this.appointment_days){
			if (this.dateIsSpecial(date,y, m, d)){
				return "appointment";
			}
			else{
				return false;
			};
		}else return false;
	},
	
	setCalender:function(){
	  var that=this;
	  if(!$(this.calContainer)){
	  	var tmp=new Element("div",{"id":"tmp_month_small_"+that.calid});
		new Insertion.After(this.resCont,tmp);
		tmp.hide();
		this.calContainer="tmp_month_small_"+that.calid;
	  }
	  this.calendar=Calendar.setup(
		{
		  flat         : that.calContainer, 
		  flatCallback  : function(){that.dateChanged()}, 
		  dateStatusFunc : function(date, y, m, d){return that.DateStatusFunc(date, y, m, d)},
		  firstDay  : 1,
		  showOthers: true,
		  enableFirstDayChange: false
		}
	  );
	  this.model.calendar=this.calendar;
	},
	loadAppointments:function(date){
		//try{
			//Dialog.close();
			Dialog.close();
			if(this.calendar){
				var date = new Date(this.calendar.date.getTime());
			}
			else{
				var date=date? new Date(date.getTime()): new Date();
			};
			date=date.setFirstWKDay(this.calendar.firstDayOfWeek);
			var tdate=new Date(date.getTime());
			tdate.setDate(date.getDate()+41);
			date.setHours(0);
			date.setMinutes(0);
			date=date.toUTCString();
			tdate.setHours(23);
			tdate.setMinutes(59);
			tdate=tdate.toUTCString();
			var that=this;
			new Ajax.Request(that.URL.appointments, {
			  method: 'post',
			  parameters: 'date='+date+'&tdate='+tdate,
			  onSuccess: function(transport){
				that.model.reset();
				that.model.parseData(transport);
				that.appointment_days=that.model.getAppointmentDays();
				that.refresh=true;
				that.calendar.refresh();
 				that.showAppointments();
			},
			  onFailure: function(e){
				var err = new Error(); 
			    err.name = 'URIError'; 
			    err.message = "Kalender: Server gab einen Fehler zur&uuml;ck."; 
			    if(typeof console!='undefined')console.error(err.message); 
				alert("CalError: \n"+e.responseText);
				that.model.reset();
				that.refresh=true;
				that.showAppointments();
			  },
			  onException: function(e){
				var err = new Error(); 
			    err.name = 'ConversionError'; 
			    err.message = "Kalender: Fehler bei Termindarstellung"; 
			    if(typeof console!='undefined')console.error(err.message);
				alert("CalException: \n"+e.responseText);
				that.model.reset();
				that.refresh=true;
				that.showAppointments();
			  }
			});
		//}catch(e){Dialog.info(e.message)}
	}
});
//END AppointmentCalendar


//Dialog
var Dialog={
	container:null,
	content:null,
	shadowbox:'<table id="dlg_shadow" cellpadding="0" cellspacing="0">\
				<tbody>\
					<tr><td class="dlg_shadow_top_left">&nbsp;</td><td class="dlg_shadow_top">&nbsp;</td><td class="dlg_shadow_top_right">&nbsp;</td></tr>\
					<tr><td  class="dlg_shadow_left">&nbsp;</td>\<td class="dlg_shadow_middle">&nbsp;</td>\<td  class="dlg_shadow_right">&nbsp;</td></tr>\
					<tr><td class="dlg_shadow_bottom_left">&nbsp;</td><td class="dlg_shadow_bottom">&nbsp;</td><td class="dlg_shadow_bottom_right">&nbsp;</td></tr>\
				</tbody>\
			</table>',
	box:'<div id="dlg_info" class="dlg_info_middle">\
				<div align="left" class="dlg_top"><div id="dlg_close"></div></div>\
				<div id="dlg_content"></div>\
				<div id="dlg_footer"></div>\
		</div>',
	iefix:null,
	shadowUnder: function() {
		var element = this.container;
		var offset = element.cumulativeOffset();
		var dimensions = element.getDimensions();
		var style = {
			  left: (offset[0]-20) + 'px',
			  position: "absolute",
			  top: (offset[1]-20) + 'px',
			  zIndex: element.getStyle('zIndex') - 1
			};
		this.shadow.show();
		this.shadow.setStyle(style);
		if(!this.shadow_middle)
			this.shadow_middle=$$(".dlg_shadow_middle")[0];
		this.shadow_middle.width=(dimensions.width-22) + 'px';
		this.shadow_middle.height=(dimensions.height-22) + 'px';
	  }
	
};
Dialog.visible=function(){
	return Dialog.container.visible();
};
Dialog.setMsg=function(msg){
	if(!this.container){
		this.init();
	}
	this.content.update(msg);
};
Dialog.setFooter=function(text){
	if(!this.container){
		this.init();
	}
	this.footer.update(text);
};
Dialog.Shirm=Class.create({
	  
	  initialize: function() {
		/*if(ie){
			this.element = new Element("iframe", {
			  "class": "dlg_overlay",
			  "src": "#",
			  "frameborder": 0
			});
		}else{*/
			this.element=new Element("div",{ "class": "dlg_overlay"	});			
		/*};*/
		$(document.body).insert(this.element);
		this.element.hide();
	  },
	  hide: function() {
		this.element.hide();
		return this;
	  },
	
	  show: function() {
		this.element.show();
		return this;
	  },
	  
	  positionUnder: function(element) {
		var element = $(element);
		var offset = element.cumulativeOffset();
		var dimensions = element.getDimensions();
		var style = {
			  left: offset[0] + 'px',
			  top: offset[1] + 'px',
			  width: dimensions.width + 'px',
			  height: dimensions.height + 'px',
			  zIndex: element.getStyle('zIndex') - 1
			};
		this.show()
		this.element.setStyle(style);
	
		return this;
	  },
	  positionOver: function(element) {
		var element = $(element);
		var offset = element.cumulativeOffset();
		var dimensions = element.getDimensions();
		var style = {
			  left: offset[0] + 'px',
			  top: offset[1] + 'px',
			  width: dimensions.width + 'px',
			  height: dimensions.height + 'px',
			  zIndex: element.getStyle('zIndex') + 1
			};
		this.element.show()	
		this.element.setStyle(style);
	
		return this;
	  },
	
	  setBounds: function(bounds) {
		for (prop in bounds) {
		  bounds[prop] += 'px';
		}
		this.element.setStyle(bounds);
		return this;
	  },

	  destroy: function() {
		if (this.element)
		  this.element.remove();
	
		return this;
	  }
});
Dialog.setSize=function(){
	
};
Dialog.setBounds=function(event){
	var left=Event.pointerX(event);
	var top=Event.pointerY(event);
	this.container.style.left=left+"px";
	this.container.style.top=top+"px";
	var clickX=event.clientX;
	var clickY=event.clientY;
	var contWidth=this.container.getWidth();
	var contHeight=this.container.getHeight();
	var viewWidth=document.viewport.getWidth();
	var viewHeight=document.viewport.getHeight();
	if(clickX+contWidth>=viewWidth)
		left=left-contWidth;
	if(clickY+contHeight>=viewHeight)
		top=top-contHeight;
	this.container.style.left=left+"px";
	this.container.style.top=top+"px";
};
Dialog.init=function(event){
	$(document.body).insert(this.box);
	$(document.body).insert(this.shadowbox);
	this.container=$("dlg_info");
	this.content=$("dlg_content");
	this.footer=$("dlg_footer");
	this.shadow=$("dlg_shadow");
	$("dlg_close").observe("click",function(){Dialog.close()});
	this.container.hide();
	this.shadow.hide();
	/*this.iefix = new Dialog.Shirm();
	this.iefix.positionUnder("dlg_info");*/
	if(!event){
		this.container.style.left=(document.viewport.getWidth()/2-this.container.getWidth()/2)+"px"; 
		this.container.style.top=(document.viewport.getHeight()/2-this.container.getHeight()/2)+"px";
	}
	//this.iefix.setBounds(document.viewport.getDimensions());
	//this.iefix.setBounds({top:0,left:0});
};
Dialog.info=function(event,onclose){
	var that=this;
	if(!this.container){
		this.init(event);
	}
	if(onclose)this.onclose=onclose;
	this.container.show();
	if(event){
		this.setBounds(event);
	}
	if(!IE || IE>=7)
		this.shadowUnder();
	/*if(this.iefix){
		this.iefix.show();
		this.iefix.positionUnder("dlg_info");
	}*/
	if(event){
		document.observe("mousedown",function(e){
			if(that.container.visible()){
				if(!$(Event.element(e)).up('#dlg_info'))
					Dialog.close();  
			}
		});
	}
};
Dialog.close=function(onclose){
	if(this.container){
		this.setFooter("");
		this.setMsg("");
		this.container.hide();
	}
	if(this.shadow)
		this.shadow.hide();
	if(this.onclose){
		this.onclose();
		this.onclose=null;
	}
};
//END Dialog

//Shirm
var Shirm=Class.create({
	  
	  initialize: function(insertion,position,offset,cls,iefix) {
		/*if(ie){
			this.element = new Element("iframe", {
			  "class": "dlg_overlay",
			  "src": "#",
			  "frameborder": 0
			});
		}else{*/
						
		/*};*/
		var cls=cls?cls: "dlg_overlay";
		this.element=new Element("div",{ "class": cls	});
		this.iefix=iefix;
		this.position=position? position: "absolute";
		this.offset=offset?offset:"cumulative";
		var insertion=insertion? insertion: $$("body")[0];
		insertion.insert(this.element);
		this.element.hide();
	  },
	  hide: function() {
		this.element.hide();
		return this;
	  },
	
	  show: function() {
		this.element.show();
		return this;
	  },
	  
	  positionUnder: function(element) {
		var that=this;
		var element = $(element);
		if(this.offset=="positioned")
			offset = element.positionedOffset();
		else
			offset = element.cumulativeOffset();
		dimensions = element.getDimensions();
		
		style = {
		  left: offset[0] + 'px',
		  top: offset[1] + 'px',
		  postion:that.position,
		  width: dimensions.width + 'px',
		  height: dimensions.height + 'px',
		  zIndex: element.getStyle('zIndex') - 1
		};
		this.element.setStyle(style).show();
	
		return this;
	  },
	  positionOver: function(element) {
		var that=this;
		var element = $(element);
		if(this.offset=="positioned")
			offset = element.positionedOffset();
		else
			offset = element.cumulativeOffset();
		dimensions = element.getDimensions();
		if(IE &&  IE< 7 && this.iefix){
			var parent=element.offsetParent;
			offset[1]=$(parent).cumulativeOffset()[1];
		}
		style = {
		  left: offset[0] + 'px',
		  top: offset[1] + 'px',
		  postion:that.position,
		  width: dimensions.width + 'px',
		  height: dimensions.height + 'px',
		  zIndex: element.getStyle('zIndex') + 1
		};
		this.element.setStyle(style).show();
	
		return this;
	  },
	
	  setBounds: function(bounds) {
		for (prop in bounds) {
		  bounds[prop] += 'px';
		}
		this.element.setStyle(bounds);
		return this;
	  },

	  destroy: function() {
		if (this.element)
		  this.element.remove();
	
		return this;
	  }
});
//END Shirm

//CalendarModel
var CalendarModel=Class.create({
								  
	appointments:null,
	appointments_short:null,
	appointments_long:null,
	controller:false,
	initialize: function(controller){
		this.appointments=new Object();
		this.appointments_short=new Object();
		this.appointments_long=new Object();
		this.controller=controller;
	},
	
	getAppointmentDays:function(){
		var appointment_days=new Object();
		appointment_days=new Object();
		var date= new Date();
		if(this.controller.calendar!=null)
			date.setTime(this.controller.calendar.date.getTime());
		date.setDate(1);
		var w=date.getWeekNumber();
		date.setMonth(0);
		date.setDate(((w-1)*7)+this.calendar.firstDayOfWeek-1);
		 if(!appointment_days[date.getFullYear()])
			appointment_days[date.getFullYear()]=new Object();
		 if(!appointment_days[date.getFullYear()][date.getMonth()])
			appointment_days[date.getFullYear()][date.getMonth()]=new Object();
		for(var i=1;i<=42;i++){
			date.setDate(date.getDate()+1);
			for(d in this.appointments){
				date.setHours(0);
				date.setMinutes(0);
				date.setSeconds(0);
				date.setMilliseconds(0);
				var a=date.getTime();
				var ftemp=new Date();
				ftemp.setTime(this.appointments[d].from_date.getTime());
				var ttemp=new Date();
				ttemp.setTime(this.appointments[d].to_date.getTime());
				ftemp.setHours(0);
				ftemp.setMinutes(0);
				ttemp.setHours(23);
				ttemp.setMinutes(59);
				ttemp.setSeconds(59);
				ttemp.setMilliseconds(999);
				var f=ftemp.getTime();
				var t=ttemp.getTime();
				if(( a> f && a < t) || (a == t || a ==f)){
				 if(!appointment_days[date.getFullYear()])
				 	appointment_days[date.getFullYear()]=new Object();
				 if(!appointment_days[date.getFullYear()][date.getMonth()])
				 	appointment_days[date.getFullYear()][date.getMonth()]=new Object();
				 appointment_days[date.getFullYear()][date.getMonth()][date.getDate()]=date.getDate();
				}
			}
		 }
		return appointment_days;
	},
	reset:function(){
		this.appointments=new Object();
		this.appointments_short=new Object();
		this.appointments_long=new Object();
	},
	parseData:function(transport){
		//try{
			if (transport.responseText){
				this.appointments=transport.responseText.evalJSON();
				for(i in this.appointments){
					var temp=Date.parseDate(this.appointments[i].from_date,"%Y/%m/%d %k:%M");
					this.appointments[i].from_date=new Date(temp.getTime());
					var temp=Date.parseDate(this.appointments[i].to_date,"%Y/%m/%d %k:%M");
					this.appointments[i].to_date=new Date(temp.getTime());
					this.appointments[i]=new Appointment(this.appointments[i],this.controller);
					var tf=this.appointments[i].from_date;
					var tt=this.appointments[i].to_date;
					if(tf.toDateString()==tt.toDateString()
						&&!(tf.getHours()==0 && tf.getMinutes()==0 &&  tt.getHours()==23 && tt.getMinutes()==59)){
						this.appointments_short[i]=this.appointments[i];
					}
					else{
						this.appointments_long[i]=this.appointments[i];
					}
				}
			}
		/*}catch(e){
			Dialog.info(e.name+"<br/>"+transport.responseText);
		};*/
	}
})
//END CalendarModel

// DayView
var dayView=Class.create({	
	container:null,
	controller:null,
	calendar:null,
	table:null,
	hoverlays:false,
	hwidth:55,
	
	destroyOverlays:function(){
		if(this.ov1){
			try{
				this.ov1.destroy();
				this.ov1=null;
			}catch(e){return}
		}
	},
	setHOverlays:function(elm){
		var that=this;
		if(!this.ov1){
			
			var daycont=$(this.controller.calid+'_day_content');
			this.ov1=new Shirm(daycont,"relative","positioned");
			document.observe("mousemove",function(e){
				if(!that.hoverlays)
					return;
				Event.stop(e);
				try{
					var daytable=$(that.controller.calid+'_daytable');
					var elmleftoffset=that.ov1.element.cumulativeOffset()[0];
					var elmleftPositionedoffset=that.ov1.element.positionedOffset()[0];
					var elmwidth=that.ov1.element.getWidth();
					var contleftoffset=daytable.cumulativeOffset()[0];
					var contwidth=daytable.getWidth();
					var xpos=e.pointerX();
					var ypos=e.pointerY();
				}catch(exc){return}
				if(xpos<=that.ov1.leftoffset)
					that.ov1.left=true;
				else if(xpos>=that.ov1.leftoffset+that.hwidth)
					that.ov1.left=false;
				if(!that.ov1.left && that.ov1.leftoffset!=elmleftoffset){
					that.ov1.element.style.left=that.ov1.leftPositionedoffset+"px";
					elmleftPositionedoffset=that.ov1.leftPositionedoffset;
					elmleftoffset=that.ov1.leftoffset;
				}else if(that.ov1.left){
					var diff=(elmleftoffset+elmwidth)-(that.ov1.leftoffset+that.hwidth);
					if(diff>0){
						that.ov1.element.style.width=elmwidth-diff+"px";
						elmwidth=that.ov1.element.getWidth();
					}
				}
				if(xpos<elmleftoffset){
					var offleft=elmleftoffset-that.hwidth*(Math.ceil((elmleftoffset-xpos)/that.hwidth));
					var width=elmwidth+that.hwidth*(Math.ceil((elmleftoffset-xpos)/that.hwidth));
					if(offleft>contleftoffset){
						that.ov1.element.style.left=(elmleftPositionedoffset-that.hwidth*(Math.ceil((elmleftoffset-xpos)/that.hwidth)))+"px";
						that.ov1.element.style.width=width+"px";
					}
				}else if(xpos>elmleftoffset && that.ov1.left && xpos>elmleftoffset+that.hwidth){
					var width=elmwidth-that.hwidth*(Math.floor((xpos-elmleftoffset)/that.hwidth));
					var offleft=elmleftoffset+that.hwidth*(Math.floor((xpos-elmleftoffset)/that.hwidth));
					if(offleft<contleftoffset+contwidth){
						that.ov1.element.style.left=(elmleftPositionedoffset+that.hwidth*(Math.floor((xpos-elmleftoffset)/that.hwidth)))+"px";
						if(width>=that.hwidth){
							that.ov1.element.style.width=width+"px";
						}
					}
				}else if(xpos>elmleftoffset && xpos>elmleftoffset+elmwidth && !that.ov1.left){
					var width=elmwidth+that.hwidth*(Math.ceil((xpos-(elmleftoffset+elmwidth))/that.hwidth));
					if(elmleftoffset+width<=contleftoffset+contwidth){
						that.ov1.element.style.width=width+"px";
					}
				}else if(xpos>elmleftoffset && xpos<elmleftoffset+elmwidth && !that.ov1.left){
					if(xpos<=(elmleftoffset+elmwidth-that.hwidth)){
						var width=elmwidth-that.hwidth*(Math.floor(((elmleftoffset+elmwidth)-xpos)/that.hwidth));
						if(width>=that.hwidth){
							that.ov1.element.style.width=width+"px";
						}
					}
				}
			});
			document.observe("mouseup",function(event){
				if(that.hoverlays){
					var diff=Math.round(that.ov1.element.getWidth()/that.hwidth)-1;
					that.controller.seldate2=new Date(that.controller.seldate1.getTime());
					if(that.ov1.element.cumulativeOffset()[0]>=that.ov1.leftoffset)
						that.controller.seldate2.setHours(that.controller.seldate2.getHours()+diff);
					else if(that.ov1.element.cumulativeOffset()[0]<that.ov1.leftoffset)
						that.controller.seldate2.setHours(that.controller.seldate2.getHours()-diff);
					if(that.controller.seldate1>that.controller.seldate2)
						that.controller.seldate1.setMinutes(59);
					else
						that.controller.seldate2.setMinutes(59);
					that.controller.showQuickForm(event,function(){that.destroyOverlays()});
					that.hoverlays=false;
				}
			});
		}
		var date=new Date(this.controller.seldate1.getTime());
		this.ov1.date=date;
		this.ov1.date2=date;
		var id=this.controller.calid+"_hour_"+date.getHours();
		this.ov1.positionOver(id);
		this.ov1.leftoffset=this.ov1.element.cumulativeOffset()[0];
		this.ov1.leftPositionedoffset=this.ov1.element.positionedOffset()[0];
		this.ov1.element.style.zIndex=5;
	},
	
	makeTable:function(){
		var that=this;
		var cw=this.controller.width-1;
		var ch=this.controller.height;
		var table='<div id="'+this.controller.calid+'_daytable" class="daytable" style="width:'+cw+'px;height:'+ch+'px">';
			table+='<div id="'+this.controller.calid+'_daytable_hd" class="daytable_hd" style="width:'+cw+'px;height:'+(ch*0.2)+'px"></div>';
			table+='<div class="hours_scroll_h" align="left" style="width:'+(cw-2)+'px; float:left" id="'+this.controller.calid+'_dscroll_track_h">'
					+'<div id="'+this.controller.calid+'_dscroll_h" class="scroll_h"><div class="side moreleft">&nbsp;</div>'
					+'<div class="side moreright">&nbsp;</div></div></div>';
			table+='<div class="daytable_body" style="height:'+(ch-(ch*0.2)-17)+'px;width:'+(cw-17)+'px;">';
			table+='<div class="day_content" id="'+this.controller.calid+'_day_content">';
					table+='<div class="hours">';
					for (var i=0;i<=23; i++){
						table+="<div height='15px' class='hournr'>"+i+":00</div>";
					};
					table+='</div>';
					table+='<div class="hours">';
					for (var i=0;i<=23; i++){
						table+="<div class='hour hour_h' id='"+this.controller.calid+"_hour_"+i+"'>&nbsp;</div>";
					};
					table+='</div>';
			table+="</div>";
			table+="</div>";
		table+='<div class="hours_scroll_v" align="left" id="'+this.controller.calid+'_dscroll_track_v" style="height:'+(ch-(ch*0.2)-17)+'px;"><div id="'+this.controller.calid+'_dscroll_v" class="scroll_v"><div class="stop">&nbsp;</div><div class="sbottom">&nbsp;</div></div></div>';
		table+='</div>';
		this.table=table;
		this.container.update("");
		this.container.insert(this.table);
		var box = $(this.controller.calid+'_day_content');
		var strackh=$(this.controller.calid+'_dscroll_track_h');
		if(!this.contheight)this.contheight=box.getHeight();
		
			this.slh=new Control.Slider(this.controller.calid+'_dscroll_h',strackh, {
			  range: $R(0, strackh.getWidth()),
			  sliderValue: 0,
			  onSlide: function(value) {
				if(strackh.getWidth()<box.getWidth()){
					var pos=-((box.getWidth()+16-strackh.getWidth())*((value*100)/strackh.getWidth())/100);
					box.setStyle({ left: pos + 'px'});
				}
			  },
			  onChange: function(value) { 
			  	if(strackh.getWidth()<box.getWidth()){
					var pos=-((box.getWidth()+16-strackh.getWidth())*((value*100)/strackh.getWidth())/100);
					box.setStyle({ left: pos + 'px'});
				}
			  }
			});
			this.slh.setValue(strackh.getWidth()/2);
		
		var strackv=$(this.controller.calid+'_dscroll_track_v');
		this.slv=new Control.Slider(this.controller.calid+'_dscroll_v',strackv, {
		  range: $R(0, strackv.getHeight()),
		  axis:'vertical',
		  sliderValue: 0,
		  onSlide: function(value) {
			if(strackv.getHeight()<box.getHeight()){
				var pos=-((box.getHeight()-strackv.getHeight())*((value*100)/strackv.getHeight())/100);
				box.setStyle({ top: pos + 'px'});
			}
		  },
		  onChange: function(value) { 
			if(strackv.getHeight()<box.getHeight()){
				var pos=-((box.getHeight()-strackv.getHeight())*((value*100)/strackv.getHeight())/100);
				box.setStyle({ top: pos + 'px'});
			}
		  }
		});
		if($(this.controller.calid+'_day_content').getWidth()<=$$('#'+this.container.id+' div.daytable_body')[0].getWidth()){
			$(this.controller.calid+'_dscroll_h').style.visibility="hidden";
		}
		if(this.controller.isEditable){
			var date=new Date(this.calendar.date.getTime());
			date.setHours(0);
			date.setMinutes(0);
			var hours=$$('#'+this.container.id+' div.hour');
			hours.each(function(hdiv){
				hdiv.date=new Date(date.getTime());
				var sbmt=new Element('input',{'type':'button','value':DSLang('Save')});
				sbmt.observe("click",function(){
							that.controller.createAppointment($(that.controller.id+'_quick_app_title').value);
				});
				hdiv.observe("mousedown",function(event){
											if(event)
												Event.stop(event);
											that.controller.seldate1=new Date(this.date.getTime());
											that.hoverlays=true;
											that.setHOverlays(this);
											});
				date.setHours(date.getHours()+1);
			});
			var date=new Date(this.calendar.date.getTime());
			date.setHours(0);
			date.setMinutes(0);
			$(this.controller.calid+'_daytable_hd').observe("click",function(event){
				if(event)
					Event.stop(event);
				that.controller.seldate1=new Date(date.getTime());
				that.controller.seldate2=new Date(date.getTime());
				that.controller.seldate2.setHours(23);
				that.controller.seldate2.setMinutes(59);
				that.controller.showQuickForm(event);
			})
		}
	},
	
	
	setDay:function(obj,date,matrix){
		var owner=this.controller.owners[obj.owner_id];
		if(owner && owner.show==1){
			var ld="<div class='side'></div>";
			var sings="";
			if(obj.from_date.toDateString()!=date.toDateString()){
				ld="<div class='side moreleft'></div>";
			}else{
				if(obj.isActive=="Maybe" ||obj.isActive=="Unconfirmed")
					sings="? ";
			};
			var rd="<div class='side'></div>";
			if(obj.to_date.toDateString()!=date.toDateString()){
				rd="<div class='side moreright'></div>";
			};
					
			var div=new Element('div',{"class": "appointment", "style":"position:relative"}).update(ld+"<div class='appointment_title'><div class='text'>"+sings+obj.what+"</div></div>"+rd);
			var that=obj;
			var daytable=$(this.controller.calid+'_daytable_hd');
			var i=0;
			for(i; i<matrix.length;i++){
				if(matrix[i]==null)break;
			};
			div.style.width=daytable.getWidth()-16+"px";
			div.observe('click', function(event){that.show(event)});
			matrix[i]=true;
			daytable.insert(div);
			if(obj.isActive=="Cancelled")
				div.style.textDecoration="line-through";
			div.style.backgroundColor=this.controller.owners[obj.owner_id].color;
		}
	},

	setHour:function(obj,date,matrix){
		var owner=this.controller.owners[obj.owner_id];
		if(owner && owner.show==1){
			var ld="<div class='side'></div>";
			var rd="<div class='side'></div>";
			var sings="";
			if(obj.isActive=="Maybe" ||obj.isActive=="Unconfirmed")
					sings="? ";
			var hourdiv=$(this.controller.calid+'_hour_'+obj.from_date.getHours());
			var div=new Element('div',{"class": "appointment","align":"left"}).update(ld+"<div class='appointment_title'><div class='spacer'></div><div class='text'>"+sings+obj.what+"</div></div>"+rd);
			var that=obj;
			div.observe('click', function(event){that.show(event)});
			var left=hourdiv.positionedOffset()[0];
			var mins=((obj.to_date.getHours()-obj.from_date.getHours())*60)+(obj.to_date.getMinutes()-obj.from_date.getMinutes());
			var mw=hourdiv.getWidth()/60;
			var lm=obj.from_date.getMinutes()*mw;
			var w=Math.ceil(mw*mins);
			var a=Math.ceil(left+lm);
			var e=a+w;
			var pos=0;
			for(var i=0; i<matrix.length;i++){
				var b=false;
				for(var j=0;j<matrix[i].length;j++){
					var a2=matrix[i][j][0];
					var e2=matrix[i][j][1];
					if((a<a2 && e>a2)||
					   (a>a2 && a<e2)||
					   (a==a2)||
					   (e==e2)
					   ){
						pos=i+1;
						b=false;
						break;
					}
					else{
						b=true;
					}
				}
				if(b) break;
			};
			
			if(!matrix[pos])matrix.push(new Array());
			matrix[pos].push([a,e]);
			new Insertion.After(hourdiv,div);
			var top=hourdiv.positionedOffset()[1];
			div.style.top=(top+(16*pos))+"px";
			div.style.width=w+"px";
			div.style.left=a+"px";
			if(obj.isActive=="Cancelled")
				div.style.textDecoration="line-through";
			div.style.backgroundColor=this.controller.owners[obj.owner_id].color;
			var h=top+(16*pos)+div.getHeight();
			if(this.contheight<h)
				$(this.controller.calid+'_day_content').style.height=h+"px";
		}
	},

	initElements:function(){
		this.calendar=this.controller.calendar;
		var date=new Date();
		date.setTime(this.calendar.date.getTime());
		var obj=this.controller.model.appointments_short;
		var matrix=new Array();
		$(this.controller.calid+'_day_content').style.height=this.contheight+"px";
		for(ap in obj){
			if(obj[ap].isEqualsDay(date)){
				this.setHour(obj[ap],date,matrix);
			}
		};
		var hd=$(this.controller.calid+"_hour_0").positionedOffset()[1]+3;
		for (var i=0;i<=23; i++){
			$(this.controller.calid+'_hour_'+i).style.height=$(this.controller.calid+'_day_content').getHeight()-hd+"px";
		};
		var obj=this.controller.model.appointments_long;
		var matrix=new Array();
		for(ap in obj){
			if(obj[ap].isEqualsDay(date)){
				this.setDay(obj[ap],date,matrix);
			}
		}
	},

	show:function(container, controller){
		this.container=container;
		this.controller=controller? controller: null;
		this.calendar=this.controller.calendar;
		this.makeTable();
		this.initElements();
	}
})
// END DayView


// MonthView
var monthView=Class.create({
	container:null,
	controller:null,
	calendar:null,
	divs:null,
	overlays:false,
	sarray:null,

	destroyOverlays:function(){
		try{
			this.ov1.destroy();
			this.ov1=null;
		}catch(e){return}
		try{
			this.ov2.destroy();
			this.ov2=null;
		}catch(e){return}
		try{
			this.ov3.destroy();
			this.ov3=null;
		}catch(e){return}
	},
	setOverlays:function(elm){
		var that=this;
		if(!this.ov1){
			var divmonth=$$('#'+this.container.id+' .div_month')[0];
			this.ov1=new Shirm(null,null,null,null,true);
			this.ov2=new Shirm(null,null,null,null,true);
			this.ov3=new Shirm(null,null,null,null,true);
			document.observe("mousemove",function(e){
				if(!that.overlays)
					return;
				Event.stop(e);
				try{
					var elmleftoffset=that.ov1.element.cumulativeOffset()[0];
					var elmtopoffset=that.ov1.element.cumulativeOffset()[1];
					var contleftoffset=divmonth.cumulativeOffset()[0];
					var conttopoffset=divmonth.cumulativeOffset()[1];
					var contwidth=divmonth.getWidth();
					var contheight=divmonth.getHeight();
					var elmwidth=that.ov1.element.getWidth();
					var xpos=e.pointerX();
					var ypos=e.pointerY();
				}catch(exc){return}
				if(xpos>=contleftoffset && xpos<=contleftoffset+contwidth && ypos>=conttopoffset && ypos<=conttopoffset+contheight){
					if(xpos<=that.ov1.leftoffset)
						that.ov1.left=true;
					else if(xpos>=that.ov1.leftoffset+that.daywidth)
						that.ov1.left=false;
					if(ypos<=that.ov1.topoffset){
						that.ov1.top=true;
						that.ov1.bottom=false;
					}else if(ypos>=that.ov1.topoffset+that.dayheight){
						that.ov1.top=false;
						that.ov1.bottom=true;
					}else{
						that.ov1.top=false;
						that.ov1.bottom=false;
					}
					
					if(that.ov1.bottom || that.ov1.top){
						if(that.ov1.bottom){
							if(elmleftoffset!=that.ov1.leftoffset){
								that.ov1.element.style.left=that.ov1.leftoffset+"px";
								elmleftoffset=that.ov1.leftoffset;
							}
							if(that.ov2.element.visible() && that.ov2.element.cumulativeOffset()[1]<elmtopoffset)
								that.ov2.hide();
							if(that.ov3.element.visible() && that.ov3.element.cumulativeOffset()[1]<elmtopoffset)
								that.ov3.hide();
						}else{
							var diff=(elmleftoffset+elmwidth)-(that.ov1.leftoffset+that.daywidth);
							if(diff>0){
								that.ov1.element.style.width=elmwidth-diff+"px";
								elmwidth=that.ov1.element.getWidth();
							}
							if(that.ov2.element.visible() && that.ov2.element.cumulativeOffset()[1]>elmtopoffset)
								that.ov2.hide();
							if(that.ov3.element.visible() && that.ov3.element.cumulativeOffset()[1]>elmtopoffset)
								that.ov3.hide();
						}
					}else{
						if(!that.ov1.left && that.ov1.leftoffset!=elmleftoffset){
							that.ov1.element.style.left=that.ov1.leftoffset+"px";
							elmleftoffset=that.ov1.leftoffset;
						}else if(that.ov1.left){
							var diff=(elmleftoffset+elmwidth)-(that.ov1.leftoffset+that.daywidth);
							if(diff>0){
								that.ov1.element.style.width=elmwidth-diff+"px";
								elmwidth=that.ov1.element.getWidth();
							}
						}
					}
					if(!that.ov1.top && !that.ov1.bottom){
						that.ov2.hide();
						that.ov3.hide();
						if(xpos<elmleftoffset){
							var offleft=elmleftoffset-that.daywidth;
							if(offleft>=contleftoffset){
								that.ov1.element.style.left=offleft+"px";
								var width=elmwidth+that.daywidth;
								that.ov1.element.style.width=width+"px";
							}
						}else if(xpos>elmleftoffset && that.ov1.left && xpos>elmleftoffset+that.daywidth){
							var width=elmwidth-that.daywidth;
							var offleft=elmleftoffset+that.daywidth;
							if(offleft<contleftoffset+contwidth){
								that.ov1.element.style.left=offleft+"px";
								if(width>=that.daywidth){
									that.ov1.element.style.width=width+"px";
								}
							}
						}else if(xpos>elmleftoffset && xpos>elmleftoffset+elmwidth && !that.ov1.left){
							var width=elmwidth+that.daywidth;
							if(elmleftoffset+width<=contleftoffset+contwidth){
								that.ov1.element.style.width=width+"px";
							}
						}else if(xpos>elmleftoffset && xpos<elmleftoffset+elmwidth && !that.ov1.left){
							if(xpos<=(elmleftoffset+elmwidth-that.daywidth)){
								var width=elmwidth-that.daywidth;
								if(width>=that.daywidth){
									that.ov1.element.style.width=width+"px";
								}
							}
						}
					}else if(that.ov1.top){
						if(!that.ov2.element.visible()){
							if(!that.ov1.left){
								that.ov2.element.style.width=((contleftoffset+contwidth)-(elmleftoffset+elmwidth)+that.daywidth)+"px";
								that.ov2.element.style.left=(elmleftoffset+elmwidth-that.daywidth)+"px";
							}else{
								that.ov2.element.style.width=((contleftoffset+contwidth)-(elmleftoffset))+"px";
								that.ov2.element.style.left=(elmleftoffset)+"px";
							}
							that.ov2.element.style.top=(elmtopoffset-that.dayheight)+"px";
							if(!that.ov1.left){
								that.ov1.element.style.width=that.daywidth+"px";
								elmwidth=that.ov1.element.getWidth();
								that.ov1.element.style.left=that.ov1.leftoffset+"px";
								elmleftoffset=that.ov1.leftoffset;
							}
							that.ov2.show();
							var width=elmleftoffset-contleftoffset+elmwidth;
							if(elmleftoffset>contleftoffset){
								that.ov1.element.style.width=width+"px";
								that.ov1.element.style.left=contleftoffset+"px";
							}
						}else{
							var elm2leftoffset=that.ov2.element.cumulativeOffset()[0];
							var elm2width=that.ov2.element.getWidth();
							var elm2topoffset=that.ov2.element.cumulativeOffset()[1];
							if(ypos<=elm2topoffset && elm2topoffset>=conttopoffset+that.dayheight){
								if(!that.ov3.element.visible()){
									that.ov3.element.style.left=(contleftoffset)+"px";
									that.ov3.element.style.top=(elmtopoffset-that.dayheight)+"px";
									that.ov3.element.style.width=contwidth+"px";
									that.ov3.element.style.height=that.dayheight+"px";
									that.ov3.show();
								}else{
									that.ov3.element.style.height=(that.ov3.element.getHeight()+that.dayheight)+"px";
									that.ov3.element.style.top=(that.ov3.element.cumulativeOffset()[1]-that.dayheight)+"px";
								}
								that.ov2.element.style.top=(elm2topoffset-that.dayheight)+"px";
								elm2topoffset=that.ov2.element.cumulativeOffset()[1];
							}else if(ypos>elm2topoffset+that.dayheight){
								if(elm2topoffset+that.dayheight <= elmtopoffset){
									if(that.ov3.element.visible()){
										if(that.ov3.element.getHeight()-that.dayheight>=that.dayheight){
											that.ov3.element.style.height=(that.ov3.element.getHeight()-that.dayheight)+"px";
											that.ov3.element.style.top=(that.ov3.element.cumulativeOffset()[1]+that.dayheight)+"px";
										}
										else
											that.ov3.hide();
									}
									that.ov2.element.style.top=(elm2topoffset+that.dayheight)+"px";
									elm2topoffset=that.ov2.element.cumulativeOffset()[1];
								}else{
									that.ov2.hide();
									return;
								}
							}
							if(xpos<elm2leftoffset){
								var offleft=elm2leftoffset-that.daywidth;
								if(offleft>=contleftoffset){
									that.ov2.element.style.left=offleft+"px";
									var width=elm2width+that.daywidth;
									that.ov2.element.style.width=width+"px";
								}
							}else if(xpos>elm2leftoffset && xpos>elm2leftoffset+that.daywidth){
								var width=elm2width-that.daywidth;
								var offleft=elm2leftoffset+that.daywidth;
								if(offleft<contleftoffset+contwidth){
									that.ov2.element.style.left=offleft+"px";
									if(width>=that.daywidth){
										that.ov2.element.style.width=width+"px";
									}
								}
							}
						}
					}else if(that.ov1.bottom){
						if(!that.ov2.element.visible() && elmtopoffset+that.dayheight<=conttopoffset+contheight-that.dayheight){
							if(!that.ov1.left)
								that.ov2.element.style.width=((elmleftoffset+elmwidth)-contleftoffset)+"px";
							else
								that.ov2.element.style.width=((elmleftoffset+that.daywidth)-contleftoffset)+"px";
							that.ov2.element.style.left=(contleftoffset)+"px";
							that.ov2.element.style.top=(elmtopoffset+that.dayheight)+"px";
							if(that.ov1.left){
								that.ov1.element.style.width=that.daywidth+"px";
								elmwidth=that.ov1.element.getWidth();
								that.ov1.element.style.left=that.ov1.leftoffset+"px";
								elmleftoffset=that.ov1.leftoffset;
							}
							that.ov2.show();
							var width=contwidth+contleftoffset-elmleftoffset;
							if(elmleftoffset+width<=contleftoffset+contwidth){
								that.ov1.element.style.width=width+"px";
							}
						}else if(that.ov2.element.visible()){
							var elm2leftoffset=that.ov2.element.cumulativeOffset()[0];
							var elm2width=that.ov2.element.getWidth();
							var elm2topoffset=that.ov2.element.cumulativeOffset()[1];
							if(ypos>=elm2topoffset+that.dayheight && elm2topoffset+that.dayheight<=conttopoffset+contheight-that.dayheight){
								if(!that.ov3.element.visible()){
									that.ov3.element.style.left=(contleftoffset)+"px";
									that.ov3.element.style.top=(elmtopoffset+that.dayheight)+"px";
									that.ov3.element.style.width=contwidth+"px";
									that.ov3.element.style.height=that.dayheight+"px";
									that.ov3.show();
								}else{
									that.ov3.element.style.height=(that.ov3.element.getHeight()+that.dayheight)+"px";
								}
								that.ov2.element.style.top=(elm2topoffset+that.dayheight)+"px";
								elm2topoffset=that.ov2.element.cumulativeOffset()[1];
							}else if(ypos<=elm2topoffset){
								if(elm2topoffset-that.dayheight >= elmtopoffset+that.dayheight){
									if(that.ov3.element.visible()){
										if(that.ov3.element.getHeight()-that.dayheight>=that.dayheight)
											that.ov3.element.style.height=(that.ov3.element.getHeight()-that.dayheight)+"px";
										else
											that.ov3.hide();
									}
									that.ov2.element.style.top=(elm2topoffset-that.dayheight)+"px";
									elm2topoffset=that.ov2.element.cumulativeOffset()[1];
								}else{
									that.ov2.hide();
									return;
								}
							}
							if(xpos>elm2leftoffset && xpos>elm2leftoffset+elm2width){
								var width=elm2width+that.daywidth;
								if(elm2leftoffset+width<=contleftoffset+contwidth){
									that.ov2.element.style.width=width+"px";
								}
							}else if(xpos>elm2leftoffset && xpos<elm2leftoffset+elm2width){
								if(xpos<=(elm2leftoffset+elm2width-that.daywidth)){
									var width=elm2width-that.daywidth;
									if(width>=that.daywidth){
										that.ov2.element.style.width=width+"px";
									}
								}
							}
						}
					}
				}
			});
			document.observe("mouseup",function(event){
				if(that.overlays){
					var diff=Math.round(that.ov1.element.getWidth()/that.daywidth)-1;
					if(that.ov2.element.visible())
						diff+=Math.round(that.ov2.element.getWidth()/that.daywidth);
					if(that.ov3.element.visible()){
						diff+=Math.round(that.ov3.element.getWidth()/that.daywidth)*Math.round(that.ov3.element.getHeight()/that.dayheight);
					}
					that.controller.seldate2=new Date(that.controller.seldate1.getTime());
					if(that.ov1.element.cumulativeOffset()[0]>=that.ov1.leftoffset)
						that.controller.seldate2.setDate(that.controller.seldate2.getDate()+diff);
					else if(that.ov1.element.cumulativeOffset()[0]<that.ov1.leftoffset)
						that.controller.seldate2.setDate(that.controller.seldate2.getDate()-diff);
					that.controller.seldate2.setHours(23);
					that.controller.seldate2.setMinutes(59);
					that.controller.showQuickForm(event,function(){that.destroyOverlays()});
					that.overlays=false;
				}
			});
		}
		var date=new Date(this.controller.seldate1.getTime());
		var id=this.controller.calid+'_div_day_'+date.getDate()+"_"+date.getMonth();
		this.ov1.positionOver(id);
		this.ov2.positionOver(id);
		this.ov3.positionOver(id);
		this.ov2.hide();
		this.ov3.hide();
		this.ov1.leftoffset=this.ov1.element.cumulativeOffset()[0];
		this.ov1.topoffset=this.ov1.element.cumulativeOffset()[1];
		this.ov2.leftoffset=this.ov2.element.cumulativeOffset()[0];
		this.ov2.topoffset=this.ov2.element.cumulativeOffset()[1];
		this.ov3.leftoffset=this.ov3.element.cumulativeOffset()[0];
		this.ov3.topoffset=this.ov3.element.cumulativeOffset()[1];
	},
	getElem:function(elem,date,matrix,long,mday){
		var actday=date.getDate();
		var actmonth=date.getMonth();
		var that=this;
		var owner=this.controller.owners[elem.owner_id];
		if(owner && owner.show==1){
			elem.divs[date.getWeekNumber()]=elem.divs[date.getWeekNumber()]? elem.divs[date.getWeekNumber()]: new Object();
			if(elem.divs[date.getWeekNumber()][elem.id]){
				div=elem.divs[date.getWeekNumber()][elem.id][0];
				matrix[mday][elem.divs[date.getWeekNumber()][elem.id][1]]=true;
				div.style.width=(div.getWidth()+this.daywidth)+"px";
				if(elem.to_date.toDateString()==date.toDateString()){
					var rd="<div class='side'></div>";
					div.update(div.innerHTML+rd);
				}
				else if(date.getDay()==0){
					var rd="<div class='side moreright' style='width:"+div.getWidth()+"px'></div>";
					div.update(div.innerHTML+rd);
				}
			}
			else{
				var i=1;
				var maxapp=Math.floor(this.dayheight/17);
				for(i; i<=maxapp;i++){
					if(!matrix[mday][i]){
						matrix[mday][i]=true;
						break;
					}
				};
				var daydiv=$(this.controller.calid+'_div_day_'+actday+'_'+actmonth);
				if (i>maxapp-1){
					if($(this.controller.calid+'_div_day_'+actday+'_'+actmonth+'_more')==null){
						var div=new Element('div',{"id":this.controller.calid+'_div_day_'+actday+'_'+actmonth+'_more',"class":"appointment"}).update("<div class='appointment_title'><div class='text more'>"+DSLang('more')+"</div></div>");
						var dt=new Date(date.getTime());
						var tmpdate=new Date(date.getTime());
						div.observe("click",function(event){
						  that.controller.showAll(tmpdate,event);
						 });
						new Insertion.After($$('#'+this.container.id+' .div_month')[0],div);
						if(IE && IE<7){
							var parent=daydiv.offsetParent;
							var topOffset=$(parent).cumulativeOffset()[1];
							div.style.top=((topOffset)+((i)*16)-3)+"px";
							div.style.left=(daydiv.cumulativeOffset()[0])+"px";
							div.style.width=(daydiv.getWidth())+"px";
						}else{
							div.style.top=((daydiv.cumulativeOffset()[1])+((i)*16)-3)+"px";
							div.style.left=(daydiv.cumulativeOffset()[0])+"px";
							div.style.width=(daydiv.getWidth())+"px";
						}
					}
				}
				else{
					var div=new Element('div',{"class": "appointment"});
					var elm=elem;
					div.observe('click', function(event){elm.show(event)});
					new Insertion.After($$('#'+this.container.id+' .div_month')[0],div);
					if(IE && IE<7){
						var parent=daydiv.offsetParent;
						var topOffset=$(parent).cumulativeOffset()[1];
						div.style.top=((topOffset)+((i)*16)-3)+"px";
						div.style.left=(daydiv.cumulativeOffset()[0])+"px";
						div.style.width=(daydiv.getWidth())+"px";
					}else{
						div.style.top=((daydiv.cumulativeOffset()[1])+((i)*16)-3)+"px";
						div.style.left=(daydiv.cumulativeOffset()[0])+"px";
						div.style.width=(daydiv.getWidth())+"px";
					}
					if(long){
						div.style.backgroundColor=this.controller.owners[elem.owner_id].color;
						var ld="<div class='side'></div>";
						if(elem.from_date.toDateString()!=date.toDateString())
							ld="<div class='side moreleft'></div>";
						if(elm.isActive=="Maybe" ||elm.isActive=="Unconfirmed")
							div.update(ld+"<div class='appointment_title'><div class='text'>? "+elem.what+"</div></div>");
						else
							div.update(ld+"<div class='appointment_title'><div class='text'>"+elem.what+"</div></div>");
					}
					else{
						div.style.color=this.controller.owners[elem.owner_id].color;
						if(elm.isActive=="Maybe" ||elm.isActive=="Unconfirmed")
							div.update("<div class='appointment_title'><div class='text'>? "+elm.from_date.print("%H:%M")+" "+elem.what+"</div></div>");
						else
							div.update("<div class='appointment_title'><div class='text'>"+elm.from_date.print("%H:%M")+" "+elem.what+"</div></div>");
					};
					if(elem.to_date.toDateString()==date.toDateString()){
						var rd="<div class='side'></div>";
						div.update(div.innerHTML+rd);
					}
					else if(date.getDay()==0){
						var rd="<div class='side moreright' style='width:"+div.getWidth()+"px'></div>";
						div.update(div.innerHTML+rd);
					}
					if(elm.isActive=="Cancelled")
						div.style.textDecoration="line-through";
					elem.divs[date.getWeekNumber()][elem.id]=new Array(2);
					elem.divs[date.getWeekNumber()][elem.id][0]=div;
					elem.divs[date.getWeekNumber()][elem.id][1]=i;
					var tmpdate=new Date(date.getTime());
					var j=(mday-(Math.floor(mday/7)*7));
					if(mday==7)j=7;
					if(j==0)j=7;
					var tpmJ=j;
					for(j;j<=7;j++){
						if(tmpdate>elem.to_date)
							break;
						matrix[mday+(j-tpmJ)][elem.divs[date.getWeekNumber()][elem.id][1]]=true;
						tmpdate.setDate(tmpdate.getDate()+1);
					}
				}
			}
		}
	},
	initElements:function(){
		var obj=this.controller.model.appointments_long;
		var matrix=new Array(43);
		for(i=0; i<matrix.length; i++){
			matrix[i]=new Array(Math.floor(this.dayheight/16));
		};
		var date = new Date(this.calendar.date.getTime());
		date=date.setFirstWKDay(this.calendar.firstDayOfWeek);
		date.setHours(0);
		date.setMinutes(0);
		date.setSeconds(0);
		for(d in this.controller.model.appointments){
			this.controller.model.appointments[d].resetDivs();
		};
		
		for(i=1; i<=42; i++){
			for(d in obj){
				if(obj[d].isEqualsDay(date)){
					this.getElem(obj[d],date,matrix,true,i);
				}
			}
			date.setDate(date.getDate()+1);
		};
		
		var obj=this.controller.model.appointments_short;
		date = new Date(this.calendar.date.getTime());
		date.setHours(0);
		date.setMinutes(0);
		date.setSeconds(0);
		date=date.setFirstWKDay(this.calendar.firstDayOfWeek);
		for(i=1; i<=42; i++){
			for(d in obj){
				if(obj[d].from_date.toDateString()==date.toDateString()){
					this.getElem(obj[d],date,matrix,false,i);
				}
			}
			date.setDate(date.getDate()+1);
		};
	},
	
	makeTable:function(){
		var that=this;
		var date = new Date(this.calendar.date.getTime());
		date=date.setFirstWKDay(this.calendar.firstDayOfWeek);
		var cw=this.controller.width-1;
		var ch=this.controller.height;
		var dayw=Math.floor(cw/7);
		var dayh=Math.floor((ch-17)/6);
		this.dayheight=dayh;
		this.daywidth=dayw;
		var fullh=dayh*6;
		var fullw=dayw*7;
		if(IE && IE < 7)
			fullw=fullw+2;
		var dayrows=$(this.controller.calContainer).getElementsByClassName('daysrow');
			var daynames=$(this.controller.calContainer).getElementsByClassName('daynames')[0].childElements();
			var table="<div class='grid' style='width:"+fullw+"px; height:"+(fullh+17)+"px'>";
			for(var i=1; i<=daynames.length-1;i++){
						table+='<div class="dayname" style="width:'+(dayw)+'px;">'+daynames[i].innerHTML+'</div>';
				};
			table+= '<div style="width:'+fullw+'px; height:'+(fullh)+'px;" >';
			for(i=0; i<dayrows.length; i++){
				table+='<div style="width:'+fullw+'px; height:'+(dayh)+'px;">';
				
				for(var j=1; j<=dayrows[i].childElements().length-1;j++){
						table+='<div style="width:'+(dayw)+'px; height:'+(dayh)+'px; float:left;" class="';
						if(dayrows[i].childElements()[j].hasClassName('othermonth')){
							table+='othermonth';
						}
						table+='">';
							table+='<div class="day_number">'+dayrows[i].childElements()[j].innerHTML+'</div>';
						table+='</div>';
				};
				table+='</div>';
			};
			table+='</div>';
			table+='<div class="grid_line_h" style="width:'+fullw+'px; height:1px;left:0px;top:'+((dayh)*0+17)+'px"></div>';
			table+='<div class="grid_line_h" style="width:'+fullw+'px; height:1px;left:0px;top:'+((dayh)*1+17)+'px"></div>';
			table+='<div class="grid_line_h" style="width:'+fullw+'px; height:1px;left:0px;top:'+((dayh)*2+17)+'px"></div>';
			table+='<div class="grid_line_h" style="width:'+fullw+'px; height:1px;left:0px;top:'+((dayh)*3+17)+'px"></div>';
			table+='<div class="grid_line_h" style="width:'+fullw+'px; height:1px;left:0px;top:'+((dayh)*4+17)+'px"></div>';
			table+='<div class="grid_line_h" style="width:'+fullw+'px; height:1px;left:0px;top:'+((dayh)*5+17)+'px"></div>';
			
			table+='<div class="grid_line_v" style="width:1px; height:'+(fullh+17)+'px;left:'+((dayw)*1-1)+'px;top:0px"></div>';
			table+='<div class="grid_line_v" style="width:1px; height:'+(fullh+17)+'px;left:'+((dayw)*2-1)+'px;top:0px"></div>';
			table+='<div class="grid_line_v" style="width:1px; height:'+(fullh+17)+'px;left:'+((dayw)*3-1)+'px;top:0px"></div>';
			table+='<div class="grid_line_v" style="width:1px; height:'+(fullh+17)+'px;left:'+((dayw)*4-1)+'px;top:0px"></div>';
			table+='<div class="grid_line_v" style="width:1px; height:'+(fullh+17)+'px;left:'+((dayw)*5-1)+'px;top:0px"></div>';
			table+='<div class="grid_line_v" style="width:1px; height:'+(fullh+17)+'px;left:'+((dayw)*6-1)+'px;top:0px"></div>';
			/*+'<div class="number" style="height:'+(((ch-15)/6)-16)+'px;"></div>'
									+'<div class="number" style="height:'+(((ch-15)/6)-16)+'px;"></div>'
									+'<div class="number" style="height:'+(((ch-15)/6)-16)+'px;"></div>'
									+'<div class="number" style="height:'+(((ch-15)/6)-16)+'px;"></div>'
									+'<div class="number" style="height:'+(((ch-15)/6)-16)+'px;"></div>'
									+'<div class="number" style="height:'+(((ch-15)/6)-16)+'px;"></div>'*/
			table+="</div>";
			var lft=IE? 0:2;
			table+= '<div class="div_month" style="width:'+fullw+'px; height:'+(ch-17)+'px;top:'+(-fullh)+'px">';
			for(i=0; i<dayrows.length; i++){
				table+='<div class="div_month_row" >';
				for(var j=1; j<=dayrows[i].childElements().length-1;j++){
					table+='<div class="day" style="width:'+(dayw)+'px; height:'+dayh+'px;" id="'+this.controller.calid+'_div_day_'+date.getDate()+"_"+date.getMonth()+'"></div>';
					date.setDate(date.getDate()+1);
				};
				table+='</div>';
			};
			table+='</div>';
			this.container.update("");
			this.container.insert(table);
			if(this.controller.isEditable){
				var days=$$('#'+this.container.id+' .day');
				date = new Date(this.calendar.date.getTime());
				date=date.setFirstWKDay(this.calendar.firstDayOfWeek);
				days.each(function(daydiv){
					daydiv.date=new Date(date.getTime());
					daydiv.observe("mousedown",function(event){
						if(event)
							Event.stop(event);
						that.controller.seldate1=new Date(this.date.getTime());
						that.controller.seldate1.setHours(0);
						that.controller.seldate1.setMinutes(0);
						that.overlays=true;
						that.setOverlays(this);
					});
					date.setDate(date.getDate()+1);
				});
			}
	},

	show:function(container, controller){
		this.container=container;
		this.controller=controller? controller: null;
		this.calendar=this.controller.calendar;
		this.makeTable();
		this.initElements();
		}
});
//this.controller.timer=new Date();
//alert(new Date()-this.controller.timer);
// END MonthView

// WeekView
var weekView=Class.create({
	container:null,
	controller:null,
	calendar:null,
	doverlays:false,
	sarray:null,
	hoverlays:false,
	hwidth:55,

	destroyOverlays:function(){
		if(this.ov1){
			try{
				this.ov1.destroy();
				this.ov1=null;
			}catch(e){return}
		}
		if(this.ov2){
			try{
				this.ov2.destroy();
				this.ov2=null;
			}catch(e){return}
		}
	},
	setHOverlays:function(elm){
		var that=this;
		if(!this.ov1){
			var tweek=$$('.tweek_hours')[0];
			var weekcont=$$('.week_content')[0];
			this.ov1=new Shirm(weekcont,"relative","positioned");
			document.observe("mousemove",function(e){
				if(!that.hoverlays)
					return;
				Event.stop(e);
				try{
					var elmleftoffset=that.ov1.element.cumulativeOffset()[0];
					var elmleftPositionedoffset=that.ov1.element.positionedOffset()[0];
					var elmwidth=that.ov1.element.getWidth();
					var contleftoffset=tweek.cumulativeOffset()[0];
					var contwidth=tweek.getWidth();
					var xpos=e.pointerX();
					var ypos=e.pointerY();
				}catch(exc){return}
				if(xpos<=that.ov1.leftoffset)
					that.ov1.left=true;
				else if(xpos>=that.ov1.leftoffset+that.hwidth)
					that.ov1.left=false;
				if(!that.ov1.left && that.ov1.leftoffset!=elmleftoffset){
					that.ov1.element.style.left=that.ov1.leftPositionedoffset+"px";
					elmleftPositionedoffset=that.ov1.leftPositionedoffset;
					elmleftoffset=that.ov1.leftoffset;
				}else if(that.ov1.left){
					var diff=(elmleftoffset+elmwidth)-(that.ov1.leftoffset+that.hwidth);
					if(diff>0){
						that.ov1.element.style.width=elmwidth-diff+"px";
						elmwidth=that.ov1.element.getWidth();
					}
				}
				if(xpos<elmleftoffset){
					var offleft=elmleftoffset-that.hwidth*(Math.ceil((elmleftoffset-xpos)/that.hwidth));
					var width=elmwidth+that.hwidth*(Math.ceil((elmleftoffset-xpos)/that.hwidth));
					if(offleft>contleftoffset){
						that.ov1.element.style.left=(elmleftPositionedoffset-that.hwidth*(Math.ceil((elmleftoffset-xpos)/that.hwidth)))+"px";
						that.ov1.element.style.width=width+"px";
					}
				}else if(xpos>elmleftoffset && that.ov1.left && xpos>elmleftoffset+that.hwidth){
					var width=elmwidth-that.hwidth*(Math.floor((xpos-elmleftoffset)/that.hwidth));
					var offleft=elmleftoffset+that.hwidth*(Math.floor((xpos-elmleftoffset)/that.hwidth));
					if(offleft<contleftoffset+contwidth){
						that.ov1.element.style.left=(elmleftPositionedoffset+that.hwidth*(Math.floor((xpos-elmleftoffset)/that.hwidth)))+"px";
						if(width>=that.hwidth){
							that.ov1.element.style.width=width+"px";
						}
					}
				}else if(xpos>elmleftoffset && xpos>elmleftoffset+elmwidth && !that.ov1.left){
					var width=elmwidth+that.hwidth*(Math.ceil((xpos-(elmleftoffset+elmwidth))/that.hwidth));
					if(elmleftoffset+width<=contleftoffset+contwidth){
						that.ov1.element.style.width=width+"px";
					}
				}else if(xpos>elmleftoffset && xpos<elmleftoffset+elmwidth && !that.ov1.left){
					if(xpos<=(elmleftoffset+elmwidth-that.hwidth)){
						var width=elmwidth-that.hwidth*(Math.floor(((elmleftoffset+elmwidth)-xpos)/that.hwidth));
						if(width>=that.hwidth){
							that.ov1.element.style.width=width+"px";
						}
					}
				}
			});
			document.observe("mouseup",function(event){
				if(that.hoverlays){
					var diff=Math.round(that.ov1.element.getWidth()/that.hwidth)-1;
					that.controller.seldate2=new Date(that.controller.seldate1.getTime());
					if(that.ov1.element.cumulativeOffset()[0]>=that.ov1.leftoffset)
						that.controller.seldate2.setHours(that.controller.seldate2.getHours()+diff);
					else if(that.ov1.element.cumulativeOffset()[0]<that.ov1.leftoffset)
						that.controller.seldate2.setHours(that.controller.seldate2.getHours()-diff);
					if(that.controller.seldate1>that.controller.seldate2)
						that.controller.seldate1.setMinutes(59);
					else
						that.controller.seldate2.setMinutes(59);
					that.controller.showQuickForm(event,function(){that.destroyOverlays()});
					that.hoverlays=false;
				}
			});
		}
		var date=new Date(this.controller.seldate1.getTime());
		this.ov1.date=date;
		this.ov1.date2=date;
		var id=this.controller.calid+'_day_'+date.getDay()+"_hour_"+date.getHours();
		this.ov1.positionOver(id);
		this.ov1.leftoffset=this.ov1.element.cumulativeOffset()[0];
		this.ov1.leftPositionedoffset=this.ov1.element.positionedOffset()[0];
		this.ov1.element.style.zIndex=5;
	},
	setDOverlays:function(elm){
		var that=this;
		if(!this.ov2){
			var weekdays=$$('.week_days')[0];
			this.ov2=new Shirm(weekdays,"relative","positioned");
			document.observe("mousemove",function(e){
				if(!that.doverlays)
					return;
				Event.stop(e);
				try{
					var elmtopoffset=that.ov2.element.positionedOffset()[1];
					var conttopoffset=weekdays.positionedOffset()[1];
					var elmheight=that.ov2.element.getHeight();
					var contheight=weekdays.getHeight();
					var ypos=e.pointerY();
				}catch(exc){return}

				if(ypos<=that.ov2.topoffset){
					that.ov2.top=true;
				}else{
					that.ov2.top=false;
				}
				if(!that.ov2.top && that.ov2.topoffset!=elmtopoffset){
					that.ov2.element.style.top=that.ov2.topoffset+"px";
					elmtopoffset=that.ov2.topoffset;
				}else if(that.ov2.top){
					var diff=(elmtopoffset+elmheight)-(that.ov2.topoffset+that.dayheight);
					if(diff>0){
						that.ov2.element.style.height=elmheight-diff+"px";
						elmheight=that.ov2.element.getHeight();
					}
				}
				if(that.ov2.top){
					if(ypos<elmtopoffset){
						var offtop=elmtopoffset-that.dayheight;
						if(offtop>=conttopoffset){
							that.ov2.element.style.top=offtop+"px";
							var height=elmheight+that.dayheight;
							that.ov2.element.style.height=height+"px";
						}
					}else if(ypos>elmtopoffset && ypos>elmtopoffset+that.dayheight){
						var height=elmheight-that.dayheight;
						var offtop=elmtopoffset+that.dayheight;
						if(offtop<conttopoffset+contheight){
							that.ov2.element.style.top=offtop+"px";
							if(height>=that.dayheight){
								that.ov2.element.style.height=height+"px";
							}
						}
					}
				}else{
					if(ypos>elmtopoffset && ypos<elmtopoffset-that.dayheight+elmheight){
						var offtop=elmheight-that.dayheight;
						var height=elmheight-that.dayheight;
						that.ov2.element.style.height=height+"px";
					}else if(ypos>elmtopoffset+elmheight){
						var height=elmheight+that.dayheight;
						if(elmtopoffset+height<=conttopoffset+contheight){
							that.ov2.element.style.height=height+"px";
						}
					}
				}
			});
			document.observe("mouseup",function(event){
				if(that.doverlays){
					var diff=Math.round(that.ov2.element.getHeight()/that.dayheight)-1;
					that.controller.seldate2=new Date(that.controller.seldate1.getTime());
					if(that.ov2.element.positionedOffset()[1]>=that.ov2.topoffset)
						that.controller.seldate2.setDate(that.controller.seldate2.getDate()+diff);
					else if(that.ov2.element.positionedOffset()[1]<that.ov2.topoffset)
						that.controller.seldate2.setDate(that.controller.seldate2.getDate()-diff);
					that.controller.seldate2.setHours(23);
					that.controller.seldate2.setMinutes(59);
					that.controller.showQuickForm(event,function(){that.destroyOverlays()});
					that.doverlays=false;
				}
			});
		}
		var date=new Date(this.controller.seldate1.getTime());
		var id=this.controller.calid+'_week_day_'+date.getDay();
		this.ov2.positionOver(id);
		this.ov2.element.style.zIndex=5;
		this.ov2.topoffset=this.ov2.element.positionedOffset()[1];
	},
	initElements:function(){
		for(var w=0;w<7;w++){
			var date=new Date(this.firstdate.getTime()+(24*60*60*1000*w));
			var daynr=date.getDay();
			var obj=this.controller.model.appointments_short;
			var matrix=new Array(Math.floor(this.hourheight/16));
			for(ap in obj){
					if(obj[ap].isEqualsDay(date)){
						if(this.controller.owners[obj[ap].owner_id].show==1){
							this.setHour(obj[ap],daynr,date,matrix);
						}
					}
			}
		};
		for(var w=0;w<7;w++){
			var date=new Date(this.firstdate.getTime()+(24*60*60*1000*w));
			var daynr=date.getDay();
			var obj=this.controller.model.appointments_long;
			var matrix=new Array(Math.floor(this.hourheight/17));
			for(ap in obj){
				if(obj[ap].isEqualsDay(date)){
					this.setDay(obj[ap],daynr,date,matrix);
				}
			}
		}
	},
	setHour:function(obj,daynr,date,matrix){
		var owner=this.controller.owners[obj.owner_id];
		if(owner && owner.show==1){
			var ld="<div class='side'></div>";
			var rd="<div class='side'></div>";
			var sings="";
			if(obj.isActive=="Maybe" ||obj.isActive=="Unconfirmed")
					sings="? ";
			var hourdiv=$(this.controller.calid+'_day_'+daynr+'_hour_'+obj.from_date.getHours());
			var div=new Element('div',{"class": "appointment","align":"left"}).update(ld+"<div class='appointment_title'><div class='spacer'></div><div class='text'>"+sings+obj.what+"</div></div>"+rd);
			var that=obj;
			div.observe('click', function(event){that.show(event)});
			var left=hourdiv.positionedOffset()[0];
			var mins=((obj.to_date.getHours()-obj.from_date.getHours())*60)+(obj.to_date.getMinutes()-obj.from_date.getMinutes());
			var mw=hourdiv.getWidth()/60;
			var lm=obj.from_date.getMinutes()*mw;
			var w=Math.ceil(mw*mins);
			var a=Math.ceil(left+lm);
			var e=a+w;
			var pos=0;
			for(var i=0; i<matrix.length;i++){
				var b=false;
				if(!matrix[i])
					matrix[i]=new Array();
				for(var j=0;j<matrix[i].length;j++){
					var a2=matrix[i][j][0];
					var e2=matrix[i][j][1];
					if((a<a2 && e>a2)||
					   (a>a2 && a<e2)||
					   (a==a2)||
					   (e==e2)
					   ){
						pos=i+1;
						b=false;
						break;
					}
					else{
						b=true;
					}
				}
				if(b) break;
			};
			if(pos!=matrix.length){
				matrix[pos].push([a,e]);
				new Insertion.After(hourdiv,div);
				 var top=hourdiv.positionedOffset()[1];
				div.style.top=(top+(16*pos))+"px";
				div.style.width=w+"px";
				div.style.left=a+"px";
				if(obj.isActive=="Cancelled")
					div.style.textDecoration="line-through";
				div.style.backgroundColor=this.controller.owners[obj.owner_id].color;
			}
			else 
				this.setMoreDay(daynr,date);
		}
	},

	setDay:function(obj,daynr,date,matrix){
		var owner=this.controller.owners[obj.owner_id];
		if(owner && owner.show==1){
			var daytable=$(this.controller.calid+'_week_day_'+daynr);
			var i=0;
			for(i; i<=matrix.length;i++){
				if(matrix[i]==null)break;
			};
			if(i!=matrix.length){
				var ld="<div class='side'></div>";
				var sings="";
				if(obj.from_date.toDateString()!=date.toDateString()){
					ld="<div class='side moreleft'></div>";
				}else{
					if(obj.isActive=="Maybe" ||obj.isActive=="Unconfirmed")
						sings="? ";
				};
				var rd="<div class='side'>&nbsp;</div>";
				if(obj.to_date.toDateString()!=date.toDateString()){
					rd="<div class='side moreright'></div>";
				};
				var div=new Element('div',{"class": "appointment", "style":"position:absolute"}).update(ld+"<div class='appointment_title'><div class='text'>"+obj.what+"</div></div>"+rd);
				var that=obj;
				div.style.width=daytable.getWidth()-1+"px";
				div.observe('click', function(event){that.show(event)});
				matrix[i]=true;
				new Insertion.After(daytable,div);
				var top=daytable.positionedOffset()[1];
				div.style.top=(top+(16*i))+"px";
				if(obj.isActive=="Cancelled")
					div.style.textDecoration="line-through";
				div.style.backgroundColor=this.controller.owners[obj.owner_id].color;
			}
			else{
				if(!$(this.controller.calid+"_week_more_"+date.getDay())){
					var div=new Element('div',{"id":this.controller.calid+'_week_more_'+date.getDay(),"class": "more", "style":"position:absolute"}).update(DSLang("more"));
					new Insertion.After(daytable,div);
					div.style.width=daytable.getWidth()-1+"px";
					var top=daytable.positionedOffset()[1];
					div.style.top=(top+(16*i))+"px";
					this.setMore(daynr,date);
				}
			}
		}
	},
	setMoreDay:function(daynr,date){
			var t=this;
			var m=$(this.controller.calid+'_week_more_'+daynr+'_2');
			m.show();
			var dtemp=new Date(date.getTime());
			m.onclick=function(event){
				  t.controller.showAll(dtemp,event);
			};
	},
	setMore:function(daynr,date){
			var t=this;
			var m=$(this.controller.calid+'_week_more_'+daynr);
			var dtemp=new Date(date.getTime());
			m.observe("click",function(event){
				t.controller.showAll(dtemp,event);
			});
	},
	makeTable:function(){
		//try{
		var actdate=this.controller.calendar.date;
		var actday=actdate.getDay();
		if(actday==0)actday=7;
		var that=this;
		var firstdate=new Date(actdate.getTime()-(24*60*60*1000*(actday-1)));
		var lastdate=new Date(firstdate.getTime()+(24*60*60*1000*6));
		this.firstdate=firstdate;
		this.lastdate=lastdate;
		var from=firstdate.print("%a, %d. %b %Y");
		var to=lastdate.print("%a, %d. %b %Y");
		var cw=this.controller.width-1;
		var ch=this.controller.height;
		var hh=Math.floor((ch-36-8)/7);
		this.hourheight=hh;
		this.dayheight=hh+1;
		var table='<div class="tweek_days" style="height:'+ch+'px">';
			table+='<div class="week_nr" style="width:'+((cw-45)*0.2+42)+'px">'+from+'<br/>'+to+'</div>';
			table+='<div class="week_names">';
			for(var i=0;i<7;i++){
				var col="";
				var tmpdate=new Date(firstdate.getTime()+(24*60*60*1000*i));
				if(tmpdate.getDay()==0||tmpdate.getDay()==6)col="week_name_red";
				table+='<div class="week_name '+col+'"  style="height:'+hh+'px">'+Calendar._SDN[tmpdate.getDay()]+'</div>';
			};
			table+='</div>';
			table+='<div class="week_days">';
			for(var i=0;i<7;i++){
				var tmpdate=new Date(firstdate.getTime()+(24*60*60*1000*i));
				table+='<div id="'+this.controller.calid+'_week_day_'+tmpdate.getDay()+'" class="week_day"  style="height:'+hh+'px;width:'+(cw-45)*0.2+'px"></div>'
			
			};
			table+='</div>';
			table+='<div class="week_more">';
			for(var i=0;i<7;i++){
				var tmpdate=new Date(firstdate.getTime()+(24*60*60*1000*i));
				var moretext=DSLang('more').toArray();
				var mt="";
				moretext.each(function(e){
					mt+=e+"<br/>";
				});
				table+='<div class="week_daymore"  style="height:'+hh+'px"><div id="'+this.controller.calid+'_week_more_'+tmpdate.getDay()+'_2" style="display:none;height:'+hh+'px" class="moretext">'+mt+'</div></div>';
			};
			table+='</div>';
		table+='</div>';
		table+='<div class="tweek_hours" style="height:'+(hh*7+36+8)+'px;width:'+(cw-45)*0.8+'px">';
			table+='<div class="hours_scroll_h" align="left" id="'+this.controller.calid+'_wscroll_track"><div id="'+this.controller.calid+'_wscroll" class="scroll_h"><div class="side moreleft">&nbsp;</div><div class="side moreright">&nbsp;</div></div></div>';
			table+='<div class="tweek_hours2"  style="height:'+(ch-17)+'px;width:'+(cw-45)*0.8+'px">';
				table+='<div id="'+this.controller.calid+'_week_content" class="week_content">';
					table+='<div class="hours">';
					for(var i=0;i<24;i++){
						table+='<div class="hournr">'+i+':00</div>';
					};
					table+='</div>';
					for(var w=0;w<7;w++){
						table+='<div class="hours">';
						var tmpdate=new Date(firstdate.getTime()+(24*60*60*1000*w));
						for(var i=0;i<24;i++){
							table+='<div class="hour hour_w" id="'+this.controller.calid+'_day_'+tmpdate.getDay()+'_hour_'+i+'"  style="height:'+hh+'px"></div>';
						};
						table+='</div>';
					}
				table+='</div>';
			table+='</div>';
		table+='</div>'
		this.container.update("");
		this.container.insert(table);
		var box = $(this.controller.calid+'_week_content');
		var strack=$(this.controller.calid+'_wscroll_track');
		var sl=new Control.Slider(this.controller.calid+'_wscroll',strack, {
		  range: $R(0, strack.getWidth()),
		  sliderValue: 0,
		  onSlide: function(value) {
			var pos=-((box.getWidth()-strack.getWidth())*((value*100)/strack.getWidth())/100);
			box.setStyle({ left: pos + 'px'});
		  },
		  onChange: function(value) { 
		   var pos=-((box.getWidth()-strack.getWidth())*((value*100)/strack.getWidth())/100);
			box.setStyle({ left: pos + 'px'});
		  }
		});
		sl.setValue(strack.getWidth()/2);
		if(this.controller.isEditable){
			var date=new Date(firstdate.getTime());
			date.setHours(0);
			date.setMinutes(0);
			var hours=$$('#'+this.container.id+' div.hour');
			hours.each(function(hdiv){
				hdiv.date=new Date(date.getTime());
				var sbmt=new Element('input',{'type':'button','value':DSLang('Save')});
				sbmt.observe("click",function(){
							that.controller.createAppointment($(that.controller.id+'_quick_app_title').value);
				});
				hdiv.observe("mousedown",function(event){
											if(event)
												Event.stop(event);
											that.controller.seldate1=new Date(this.date.getTime());
											that.hoverlays=true;
											that.setHOverlays(this);
											});
				date.setHours(date.getHours()+1);
			});
			var date=new Date(firstdate.getTime());
			date.setHours(0);
			date.setMinutes(0);
			var days=$$('div.week_day');
			days.each(function(wddiv){
				wddiv.date=new Date(date.getTime());
				var sbmt=new Element('input',{'type':'button','value':DSLang('Save')});
				sbmt.observe("click",function(){
							that.controller.createAppointment($(that.controller.id+'_quick_app_title').value);
				});
				wddiv.observe("mousedown",function(event){
											if(event)
												Event.stop(event);
											that.controller.seldate1=new Date(this.date.getTime());
											that.controller.seldate1.setHours(0);
											that.controller.seldate1.setMinutes(0);
											that.doverlays=true;
											that.setDOverlays(this);
											});
				date.setDate(date.getDate()+1);
			});
		}
		//}catch(e){alert(e)};
		
	},

	show:function(container, controller){
		this.container=container;
		this.controller=controller? controller: null;
		this.calendar=this.controller.calendar;
		this.makeTable();
		//this.controller.timer=new Date();
		this.initElements();
		//alert(new Date()-this.controller.timer);
	}
});
// END WeekView

// Agendaview
var agendaView=Class.create({
	container:null,
	controller:null,
	calendar:null,

	initElements:function(){
		var cw=this.controller.width-1;
		var ch=this.controller.height;
		var date=new Date(this.calendar.date.getTime());
		var i=0;
		var maxcont=0;
		while(maxcont<42){
			if(i>=35)
				break;
			var obj=this.controller.model.appointments_long;
			var isexists=false;
			for(ap in obj){
					if(obj[ap].isEqualsDay(date)){
						if(this.controller.owners[obj[ap].owner_id].show==1){
							if(!isexists){
								var divcontainer=new Element('div',{'class':'agenda_day'}).update("\
									<div id='"+this.controller.calid+"_agenda_right_"+date.getDate()+"_"+date.getMonth()+"' class='agenda_right' style='width:"+(cw*0.2)+"px'></div>\
									<div id='"+this.controller.calid+"_agenda_left_"+date.getDate()+"_"+date.getMonth()+"' class='agenda_left' style='width:"+(cw*0.8)+"px'></div>");
								$(this.controller.calid+'_agenda_grid').insert(divcontainer);
								$(this.controller.calid+"_agenda_right_"+date.getDate()+"_"+date.getMonth()).update(obj[ap].from_date.print("%a %d.%m.%Y"));
								isexists=true;
							};
							this.setApp(obj[ap],date,true);
							i++;
						}
					}
			}
			var obj=this.controller.model.appointments_short;
			for(ap in obj){
					if(obj[ap].isEqualsDay(date)){
						if(this.controller.owners[obj[ap].owner_id].show==1){
							if(!isexists){
								var divcontainer=new Element('div',{'class':'agenda_day'}).update("\
									<div id='"+this.controller.calid+"_agenda_right_"+date.getDate()+"_"+date.getMonth()+"' class='agenda_right' style='width:"+(cw*0.2)+"px'></div>\
									<div id='"+this.controller.calid+"_agenda_left_"+date.getDate()+"_"+date.getMonth()+"' class='agenda_left' style='width:"+(cw*0.8)+"px'></div>");
								$(this.controller.calid+'_agenda_grid').insert(divcontainer);
								$(this.controller.calid+"_agenda_right_"+date.getDate()+"_"+date.getMonth()).update(obj[ap].from_date.print("%a %d.%m.%Y"));
								isexists=true;
							};
							this.setApp(obj[ap],date,false);
							i++;
						}
					}
			}
			maxcont++;
			date.setDate(date.getDate()+1);
		}
		if($(this.controller.calid+'_agenda_grid').innerHTML=="")
			$(this.controller.calid+'_agenda_grid').update("<h3 class='noevent'>"+DSLang("MessageNoEvents")+"</h3>");
	},
	setApp:function(obj,date,long){
		var ld="<div class='side'></div>";
		var rd="<div class='side'></div>";
		var that=obj;
		if(obj.isActive=="Maybe" ||obj.isActive=="Unconfirmed")
			sings="? ";
		var div=new Element('div',{"class": "appointment","align":"left", 'style':'position:static;margin-top:-1px;'});
		div.style.width=$(this.controller.calid+"_agenda_left_"+date.getDate()+"_"+date.getMonth()).getWidth()-1+"px";
		div.observe('click', function(event){that.show(event)});
		$(this.controller.calid+"_agenda_left_"+date.getDate()+"_"+date.getMonth()).insert(div);
		if(obj.isActive=="Cancelled")
				div.style.textDecoration="line-through";
		if(!long){
			div.update("<div class='appointment_title' style='position:static'><div class='text'>"+date.print("%H:%M")+" "+obj.what+"</div></div>");
			div.style.color=this.controller.owners[obj.owner_id].color;
		}
		else{
			div.update("<div class='appointment_title' style='position:static'><div class='text'>"+obj.what+"</div></div>");
			div.style.backgroundColor=this.controller.owners[obj.owner_id].color;
		}
	},
	makeTable:function(){
		var cw=this.container.getWidth();
		var ch=this.container.getHeight();
		var grid="<div id='"+this.controller.calid+"_agenda_grid' class='agenda_grid'  style='width:"+cw+"px;height:"+ch+"px'></div>";
		this.container.update("");
		this.container.insert(grid);
	},
	show:function(container, controller){
		this.container=container;
		this.controller=controller? controller: null;
		this.calendar=this.controller.calendar;
		this.makeTable();
		this.initElements();
	}
});
// END Agendaview

// CalendarView
var CalendarView=Class.create({
	
	container:null,
	controller:null,
	calendar:null,

	initialize:function(rcontainer, controller,container){
		this.container=rcontainer;
		this.controller=controller? controller: null;
		this.monthView=new monthView();
		this.dayView=new dayView();
		this.weekView=new weekView();
		this.agendaView=new agendaView();
		var that=this;
		var bool=false
		var linkdiv=new Element("div");
		if(!$(container+"_getdaylink")){
			linkdiv.insert("<a href='#' id='"+container+"_getdaylink"+"'>"+DSLang("Day")+"</a>&nbsp;&nbsp;");
			bool=true;
		}
		if(!$(container+"_getweeklink")){
			linkdiv.insert("<a href='#' id='"+container+"_getweeklink"+"'>"+DSLang("Week")+"</a>&nbsp;&nbsp;");
			bool=true;
		}
		if(!$(container+"_getmonthlink")){
			linkdiv.insert("<a href='#' id='"+container+"_getmonthlink"+"'>"+DSLang("Month")+"</a>&nbsp;&nbsp;");
			bool=true;
		}
		if(!$(container+"_getagendalink")){
			linkdiv.insert("<a href='#' id='"+container+"_getagendalink"+"'>"+DSLang("Agenda")+"</a>&nbsp;&nbsp;");
			bool=true;
		}
		if(!$(container+"_setdateminus")){
			linkdiv.insert("<a href='#' id='"+container+"_setdateminus"+"'>"+DSLang("back")+"</a>&nbsp;&nbsp;");
			bool=true;
		}
		if(!$(container+"_setdateplus")){
			linkdiv.insert("<a href='#' id='"+container+"_setdateplus"+"'>"+DSLang("next")+"</a>&nbsp;&nbsp;");
			bool=true;
		}
		if(!$(container+"_datetime")){
			linkdiv.insert("<span id='"+container+"_datetime"+"'></span>&nbsp;&nbsp;");
			bool=true;
		}
		if(bool=true){
			new Insertion.Before($(container),linkdiv);
			this.container.style.height=this.container.getHeight()-linkdiv.getHeight()+"px";
		}
		$(container+"_getdaylink").observe("click",function(event){
			 Event.stop(event);
			 that.controller.actAction=that.controller.GETFORDAY;
			 that.controller.refresh=true;
			 this.addClassName("selectedview");
			 $(container+"_getmonthlink").removeClassName("selectedview");
			 $(container+"_getagendalink").removeClassName("selectedview");
			 $(container+"_getweeklink").removeClassName("selectedview");
			 that.controller.showAppointments()
		 });
		$(container+"_getweeklink").observe("click",function(event){
			 Event.stop(event);
			 that.controller.actAction=that.controller.GETFORWEEK;
			 that.controller.refresh=true;
			 this.addClassName("selectedview");
			 $(container+"_getmonthlink").removeClassName("selectedview");
			 $(container+"_getagendalink").removeClassName("selectedview");
			 $(container+"_getdaylink").removeClassName("selectedview");
			 that.controller.showAppointments()
		 });
		$(container+"_getmonthlink").observe("click",function(event){
			 Event.stop(event);
			 that.controller.actAction=that.controller.GETFORMONTH;
			 that.controller.refresh=true;
			 this.addClassName("selectedview");
			 $(container+"_getagendalink").removeClassName("selectedview");
			 $(container+"_getweeklink").removeClassName("selectedview");
			 $(container+"_getdaylink").removeClassName("selectedview");
			 that.controller.showAppointments()
		 });
		$(container+"_getagendalink").observe("click",function(event){
			 Event.stop(event);
			 that.controller.actAction=that.controller.GETAGENDA;
			 that.controller.refresh=true;
			 this.addClassName("selectedview");
			 $(container+"_getmonthlink").removeClassName("selectedview");
			 $(container+"_getweeklink").removeClassName("selectedview");
			 $(container+"_getdaylink").removeClassName("selectedview");
			 that.controller.showAppointments()
		 });
		$(container+"_getmonthlink").addClassName("selectedview");
		$(container+"_getagendalink").removeClassName("selectedview");
		$(container+"_getweeklink").removeClassName("selectedview");
		$(container+"_getdaylink").removeClassName("selectedview");
		
		$(container+"_setdateminus").observe("click",function(event){
			 Event.stop(event);
			 that.controller.changeDate(-1);
		 });
		$(container+"_setdateplus").observe("click",function(event){
			 Event.stop(event);
			 that.controller.changeDate(1)
		 });
	},
	
	showForMonth:function(){
		this.monthView.show(this.container,this.controller);
	},
	
	showForDay:function(){
		this.dayView.show(this.container,this.controller);
		
	},
	showForWeek:function(){
		this.weekView.show(this.container,this.controller);
	},
	showAgenda:function(){
		this.agendaView.show(this.container,this.controller);
	}
});
// END CalendarView

// Appointment
var Appointment=Class.create({
							 
	id:null,
	what:null,
	where:null,
	owner_id:null,
	description:null,
	from_date: null,
	to_date:null,
	divs:null,
	isEditable: false,
	controller:null,
	contentWin:null,
	
	initialize: function(obj,controller) {
		this.id=obj.id;
		this.what=obj.what;
		this.owner_id=obj.owner_id;
		this.description=obj.description.split("\\n").join("\n");
		this.to_date=obj.to_date;
		this.isEditable=obj.isEditable;
		this.from_date=obj.from_date;
		this.isActive=obj.isActive;
		this.controller=controller;
		this.url=obj.url;
		this.divs=new Object();
	},
	
	isEqualsDay: function(date){
		var ftemp=new Date();
		ftemp.setTime(this.from_date.getTime());
		ftemp.setHours(0);
		ftemp.setMinutes(0);
		ftemp.setSeconds(0);
		ftemp.setMilliseconds(0);
		var ttemp=new Date();
		ttemp.setTime(this.to_date.getTime());
		ttemp.setHours(23);
		ttemp.setMinutes(59);
		ttemp.setSeconds(59);
		ttemp.setMilliseconds(999);
		var a=date.getTime();
		var f=ftemp.getTime();
		var t=ttemp.getTime();
		if(( a> f && a < t) || (a == t || a ==f)){
			return true;
		}
		return false;
	},
	
	resetDivs:function(){
		this.divs=new Object();
	},
	
	isEqualsHours:function(date){
		var ftemp=new Date();
		ftemp.setTime(this.from_date.getTime());
		var ttemp=new Date();
		ttemp.setTime(this.to_date.getTime());
		ftemp.setMinutes(0);
		ttemp.setMinutes(59);
		ttemp.setSeconds(59);
		ttemp.setMilliseconds(999);
		date.setHours(0);
		date.setMinutes(0);
		date.setSeconds(0);
		date.setMilliseconds(0);
		var a1=date.getTime();
		date.setHours(23);
		date.setMinutes(59);
		date.setSeconds(59);
		date.setMilliseconds(999);
		var a2=date.getTime();
		var f=ftemp.getTime();
		var t=ttemp.getTime();
		if(a1<= f && a2 >= t){
			return true;
		}
		return false;
	},
	isEqualsHour:function(date){
		var ftemp=new Date();
		ftemp.setTime(this.from_date.getTime());
		var ttemp=new Date();
		ttemp.setTime(this.to_date.getTime());
		ftemp.setMinutes(0);
		ttemp.setMinutes(59);
		ttemp.setSeconds(59);
		ttemp.setMilliseconds(999);
		var a=date.getTime();
		var f=ftemp.getTime();
		var t=ttemp.getTime();
		if(( a> f && a < t) || (a == t || a ==f)){
			return true;
		}
		return false;
	},
	
	showDetails:function(){
		/*if(this.details){
			$('adf_datails_'+this.id).innerHTML=DSLang('Details')+" "+DSLang('Close');
			Dialog.setMsg("<div style='padding:5px;'>"+this.msg_long+"</div>");
		}else{
			$('adf_datails_'+this.id).innerHTML=DSLang('Details');
			Dialog.setMsg("<div style='padding:5px;'>"+this.msg+"</div>");
		}*/
	},
	_getMsg:function(msg,event){
		what=this.what;
		var that =this;
		if(this.url)
			what="<a href='"+this.url+"' target='_blank' style='text-decoration:none;color:"+this.controller.owners[this.owner_id].color+"'>"+this.what+"</a>";
		if(!this.msg){
			this.msg="<h3 class='title' style='color:"+this.controller.owners[this.owner_id].color+"'>"+what+"</h3>\
			<div>"+msg+"</div>";
		}
		if(this.isEditable && this.controller.isEditable){
			Dialog.setFooter('<a href="#" id="adf_datails_'+this.id+'"></a>&nbsp;&nbsp;\
								  <a href="#" id="adf_delete_'+this.id+'">'+DSLang('delete')+'</a>&nbsp;&nbsp;\
								  <a href="#" id="adf_edit_'+this.id+'">'+DSLang('edit')+'</a>');
			$('adf_delete_'+this.id).observe("click",function(event){
									 Event.stop(event);
									 that.remove();									 
			});
			$('adf_edit_'+this.id).observe("click",function(event){
										 that.controller.editAppointment(that);
										 Dialog.close();
										 Event.stop(event);
			});
		}else{
			Dialog.setFooter('<a href="#" id="adf_datails_'+this.id+'"></a>&nbsp;&nbsp;');
		}
		this.details=false;
		$('adf_datails_'+this.id).observe("click",function(event){
										 //that.details=(that.details)? false:true;
										 Dialog.close();
										 Event.stop(event);
										 that.controller.showDetails(that);
										});
		$('adf_datails_'+this.id).innerHTML=DSLang('Details');
		Dialog.setMsg("<div style='padding:5px;'>"+this.msg+"</div>");
		Dialog.info(event);
	},
	show:function(event){
		if(event)
			Event.stop(event);
		var that=this;
		new Ajax.Request(that.controller.URL.quickview+that.id+"&owner_id="+that.owner_id,{
		  method: 'post',
		  evalScripts: true,
		  onComplete: function(transport) {
			that._getMsg(transport.responseText,event);
		  } 
		});
		/*var that=this;
		var fromstr="";
		var tostring="";
		if(this.from_date.print("%d.%m.%Y")!=this.to_date.print("%d.%m.%Y")){
			if(this.from_date.print("%H:%M")!="00:00" && this.to_date.print("%H:%M")!="23:59"){
				fromstr=this.from_date.print("%d.%m.%Y %H:%M");
				tostr=this.to_date.print(" - %d.%m.%Y %H:%M");
			}else{
				fromstr=this.from_date.print("%d.%m.%Y");
				tostr=this.to_date.print(" - %d.%m.%Y %H:%M");
			}
		}else if(this.from_date.print("%H:%M")!="00:00" && this.to_date.print("%H:%M")!="23:59"){
			fromstr=this.from_date.print("%d.%m.%Y %H:%M");
			tostr=this.to_date.print("- %H:%M");
		}else{
			fromstr=this.from_date.print("%d.%m.%Y");
			tostr="";
		}
		what=this.what;
		if(this.url)
			what="<a href='"+this.url+"' target='_blank' style='text-decoration:none;color:"+this.controller.owners[this.owner_id].color+"'>"+this.what+"</a>";
		if(!this.msg){
			this.msg="<h3 class='title' style='color:"+this.controller.owners[this.owner_id].color+"'>"+what+"</h3>\
				<div>"+fromstr+tostr+"</div>\
				<div>"+this.description+"</div>";
			}
		/*if(!this.msg_long){
			this.msg_long=this.msg+"<br/>"+this.description;
			}*/
		
		//this.showDetails();
	},
	
	remove:function(){
		var that=this;
		Dialog.setFooter('<a href="#" id="adf_delete_'+this.id+'">'+DSLang('delete')+'</a>&nbsp;&nbsp;\
								  <a href="#" id="adf_cancel_'+this.id+'">'+DSLang('Cancel')+'</a>&nbsp;&nbsp;');
		
		$("adf_delete_"+this.id).observe("click",function(e){
							Event.stop(e);
							that.controller.removeAppointment(that);
							Dialog.close();
							
		});
		$("adf_cancel_"+this.id).observe("click",function(event){
							Event.stop(event);
							that.show();
							
		});
		Dialog.setMsg(DSLang("alertdeleteevent"));
		Dialog.info();
	}
})
// END Appointment


// ColorPicker
var colorPickerClass=Class.create({
	
	onClickCallBack:null,
	event_elm:null,
	color_web:new Array(			
		'000000','000000','000000',  '000000','003300','006600','009900','00CC00','00FF00',  '330000','333300','336600','339900','33CC00','33FF00', '660000','663300','666600','669900','66CC00','66FF00',        
		'000000','333333','000000',  '000033','003333','006633','009933','00CC33','00FF33',  '330033','333333','336633','339933','33CC33','33FF33', '660033','663333','666633','669933','66CC33','66FF33',
		'000000','666666','000000',  '000066','003366','006666','009966','00CC66','00FF66',  '330066','333366','336666','339966','33CC66','33FF66', '660066','663366','666666','669966','66CC66','66FF66',
		'000000','999999','000000',  '000099','003399','006699','009999','00CC99','00FF99',  '330099','333399','336699','339999','33CC99','33FF99', '660099','663399','666699','669999','66CC99','66FF99',
		'000000','CCCCCC','000000',  '0000CC','0033CC','0066CC','0099CC','00CCCC','00FFCC',  '3300CC','3333CC','3366CC','3399CC','33CCCC','33FFCC', '6600CC','6633CC','6666CC','6699CC','66CCCC','66FFCC',
		'000000','FFFFFF','000000',  '0000FF','0033FF','0066FF','0099FF','00CCFF','00FFFF',  '3300FF','3333FF','3366FF','3399FF','33CCFF','33FFFF', '6600FF','6633FF','6666FF','6699FF','66CCFF','66FFFF',
		
		'000000','FFFFFF','000000',  '990000','993300','996600','999900','99CC00','99FF00',  'CC0000','CC3300','CC6600','CC9900','CCCC00','CCFF00', 'FF0000','FF3300','FF6600','FF9900','FFCC00','FFFF00',
		'000000','FF0000','000000',  '990033','993333','996633','999933','99CC33','99FF33',  'CC0033','CC3333','CC6633','CC9933','CCCC33','CCFF33', 'FF0033','FF3333','FF6633','FF9933','FFCC33','FFFF33',
		'000000','00FF00','000000',  '990066','993366','996666','999966','99CC66','99FF66',  'CC0066','CC3366','CC6666','CC9966','CCCC66','CCFF66', 'FF0066','FF3366','FF6666','FF9966','FFCC66','FFFF66',
		'000000','0000FF','000000',  '990099','993399','996699','999999','99CC99','99FF99',  'CC0099','CC3399','CC6699','CC9999','CCCC99','CCFF99', 'FF0099','FF3399','FF6699','FF9999','FFCC99','FFFF99',
		'000000','FFFF00','000000',  '9900CC','9933CC','9966CC','9999CC','99CCCC','99FFCC',  'CC00CC','CC33CC','CC66CC','CC99CC','CCCCCC','CCFFCC', 'FF00CC','FF33CC','FF66CC','FF99CC','FFCCCC','FFFFCC',
		'000000','00FFFF','000000',  '9900FF','9933FF','9966FF','9999FF','99CCFF','99FFFF',  'CC00FF','CC33FF','CC66FF','CC99FF','CCCCFF','CCFFFF', 'FF00FF','FF33FF','FF66FF','FF99FF','FFCCFF','FFFFFF'
	),
	color_calendar: new Array(
		'CC3333','DD4477','994499','6633CC','336699','3366CC','22AA99',
		'329262','109618','66AA00','AAAA11','D6AE00','EE8800','DD5511',
		'A87070','8C6D8C','627487','7083A8','5C8D87','898951','B08B59'
	),
	
	popup_cont:null,
	popup:null,
	
	initialize: function(params){
		var that=this;
		this.params=Object.extend({
		    container:null,
			useColor:"color_calendar",
			popupClass:'cp_container'
		}, params);
		this.popup_cont=new Element("div",{'style':'position:absolute;', 'id':'cp_container','class':that.params.popupClass});
		this.popup_cont.update("<div class='header'><a href='javascript: colorPicker.closePicker()'><img style='text-decoration:none;border:none' src='"+DSGlobalPath+"image/close1.png'></a><div>");
		var params=params? params: {};
		this.colors=eval("this."+this.params.useColor);
		this.popup=this.params.container? $(this.params.container):this.popup_cont;
		this.popup.appendChild(this.color_table());
		this.popup.hide();
		var that=this;
		document.body.appendChild(this.popup);
		document.observe("mousedown",function(e){
			if(that.popup.visible()){
				if(!$(Event.element(e)).up('#'+that.popup.id))
					that.popup.hide();  
			}
		});
	},
		
	select_color:function(color){
		this.closePicker();
		if(this.onClickCallBack){
			this.onClickCallBack(this.event_elm,color);
		}
		else {
			return false;
		}
	},
	closePicker:function(){
		this.popup.hide();
	},
	showPicker:function(event, callBack){
		this.onClickCallBack=callBack? callBack: this.onClickCallBack;
		this.event_elm=Event.element(event);
		this.popup.show();
		var left=Event.pointerX(event);
		var top=Event.pointerY(event);
		this.popup.style.left=left+"px";
		this.popup.style.top=top+"px";
		var clickX=event.clientX;
		var clickY=event.clientY;
		var contWidth=this.popup.getWidth();
		var contHeight=this.popup.getHeight();
		var viewWidth=document.viewport.getWidth();
		var viewHeight=document.viewport.getHeight();
		if(clickX+contWidth>=viewWidth)
			left=left-(contWidth-(viewWidth-clickX))-10;
		if(clickY+contHeight>=viewHeight)
			top=top-(contHeight-(viewHeight-clickY))-10;
		this.popup.style.left=left+"px";
		this.popup.style.top=top+"px";
		var s="";
	},
	color_table:function(){
		var tbl=new Element("div",{});
		var that=this;
		var tbl=new Element("div",{'id':'cp_colortable'});
		for (var i=0; i<this.colors.length;i++){
			var color = this.colors[i];//this.value[k] + this.value[l] + this.value[m];
				var td=new Element('div',{'class':'cp_td'});
				td.style.backgroundColor='#'+color;
				td.observe('click',function(){that.select_color(this.style.backgroundColor)});
				tbl.appendChild(td);
		}
		return tbl;
	}
});
var colorPicker;
Event.observe(window,'load',function(){
									 colorPicker=new colorPickerClass();
									 });

// END ColorPicker

Date.prototype.equalsToDay = function(date) {
	return ((this.getFullYear() == date.getFullYear()) &&
		(this.getMonth() == date.getMonth()) &&
		(this.getDate() == date.getDate()));
};
Date.prototype.setFirstWKDay = function(firstDay) {
	var firstDay=firstDay?firstDay:0;
	this.setDate(1);
	var thisday=this.getDay();
	thisday=thisday==0?7:thisday;
	var setDay=(-thisday)+firstDay;
	this.setDate(this.getDate()+setDay);
	return this;
};
DSSelectCalendar=Class.create({
	initialize:function(opt,isExtend){
		var that=this;
		var start_date=new Date();
		start_date.setMinutes(start_date.getMinutes()>=30?30:0);
		this.options=Object.extend({
		    start_date:start_date,
			field: "start_date",
			onSelect:function (calendar,date){
						if (calendar.dateClicked){calendar.callCloseHandler();}
						that.date.setDateOnly(calendar.date);
						if(that.options.empty)
							that.checkEmpty(calendar.date,that.options.field);
						else
							that.setValues();
						},
			disable:false,
			format:"%d.%m.%Y"		
		}, opt);
		this.field=$(this.options.field+"_view");
		this.date=this.options.start_date;
		this.initCalendar();
		if(!isExtend){
			this.field.observe("change",function(){that.valueChanged()});
			this.setValues(true);
			if(this.options.disable)
				this.switcher(true);
		}
	},
	valueChanged:function(){
		this.date=Date.parseDate(this.field.value,this.options.format);
		this.setValues();
	},
	switcher:function(init){
		if(!init){
			if(this.field.disabled){
				this.field.disabled=false;
			}else{
				this.field.disabled=true;
			}
		}
	},
	setValues:function(init){
		if(!init){
			this.field.value = this.date.print(this.options.format);
		}
		$(this.options.field).value = this.date.print("%Y-%m-%d");
	},
	initCalendar:function(){
		var field=$(this.options.field+"_view");
		var onClose=function(){field.blur()};
		this.getCalendar(this.options.field+"_view",this.options.start_date,this.options.format,this.options.empty,this.options.onSelect,onClose);
	},
	onEnterHandler:function(){
		//alert(window.calendar.element.id);
	},
	checkEmpty:function(date,field){
		var that=this;
		var tmp=Date.parseDate("1.1.1901","%d.%m.%Y");
		var actfiled=$(field+"_view");
		actfiled.value=date.print(this.options.format);
		this.date=date;
		this.setValues();
		if(tmp.equalsToDay(date)){
			actfiled.value=DSLang("nodate");
		}
	},
	getCalendar:function(field,date,format,empty,onselect, onclose){
		var f=$(field);
		f.isActive=false;
		var that=this;
		var tmp=Date.parseDate("1.1.1901","%d.%m.%Y");
		if(tmp.equalsToDay(date))
			date=new Date();
		Calendar.setup({
			inputField :  field,
			ifFormat :   format,
			"range": [1900, 2100],
			firstDay  : 1,
			eventName: 'focus',
			onClose: onclose,
			onSelect: onselect?function(calendar,date){
									f.isActive?(f.isActive=false):onselect(calendar,date);
								}:null,
			'date': date,
			showOthers: true,
			isPopup: true,
			zIndex: 5001,
			empty: empty,
			enableFirstDayChange: false
		 });
		f.observe('keypress',function(e){
			switch(e.keyCode){
				case  Event.KEY_UP: // KEY up
					this.isActive=false;	break;
				case Event.KEY_DOWN: // KEY down
					this.isActive=false;	break;
				case Event.KEY_RETURN: // KEY down
					this.isActive? that.onEnterHandler():null;
					this.isActive=false;	break;
				default:
					this.isActive=true;
			}
		});
		f.observe('blur',function(e){
			try{
				if(window.calendar){
					window.calendar.callCloseHandler();
					window.calendar.destroy();
					window.calendar=null;
				}
			}catch(e){}
		 });
		f.observe('mousedown',function(e){
			f.blur()
		});
		f.observe('mouseup',function(e){
			f.focus()
		});
		/*f.observe('click',function(e){
			alert("test");
		});*/
	}
});
DSSelectCalendar.Time=Class.create({
	initialize:function(){
		this.overflow=null;
		this.elpos=0;
		this.actElm=null;
		this.options=Object.extend({
		    callHandler:null,
			handlerOpt:null,
			ContClass:"DSSCTimeContainer",
			OptionClass:"DSSCOption",
			SelectedClass:"DSSCSelected",
			IntervalClass:"DSSCInterval",
			field:null
		},arguments[0]);
		var that=this;
		this.valuefield=this.options.field;
		this.options.field=$(this.options.field.id+"_view");
		this.options.field.observe("focus",function(e){that.show()});
		this.options.field.observe("keydown",function(e){that.keypress(e)});
		this.options.field.observe("keydown",function(e){that.keypress(e)});
		this.options.field.observe('blur',function(e){that.actElm.click();that.closeHandler(e)});
		this.options.field.observe('mouseup',function(e){
			try{
			this.focus();
			}catch(e){return}
		});
		document.observe("click",function(e){that.closeHandler(e)});
		this.getSelect();
	},
	_remove:function(){
		this.overflow?this.overflow.remove():null;
	},
	_init:function(overflow){
		this._remove();
		this.overflow=overflow;
	},
	show:function(){
		this.overflow.show();
		var that=this;
		this.elpos=-1;
		this.overflow.childElements()[0].childElements().find(function(s) {
					that.elpos++;
					return s.hasClassName(that.options.SelectedClass);
				});
		this.actElm.getHeight();
		this.t=this.actElm.getHeight();
		var p=(this.elpos<this.overflow.childElements()[0].childElements().length-3)?this.elpos-2:this.elpos;
		this.overflow.scrollTop=p*this.t;
	},
	setActive:function(elm){
		this.actElm? this.actElm.removeClassName(this.options.SelectedClass):null;
		elm.addClassName(this.options.SelectedClass);
		this.actElm=elm;
	},
	keypress:function(e){
		switch(e.keyCode){
			case  Event.KEY_UP: // KEY up
				this.overflow.show();
				this.elpos=this.elpos==0?this.elpos:this.elpos-1;
				var p=(this.elpos<this.overflow.childElements()[0].childElements().length-3)?this.elpos-2:this.elpos;
				this.overflow.scrollTop=p*this.t;
				this.setActive(this.overflow.childElements()[0].childElements()[this.elpos]);
				break;
			case Event.KEY_DOWN: // KEY down
				this.overflow.show();
				this.elpos=(this.elpos==(this.overflow.childElements()[0].childElements().length-1))?this.elpos:this.elpos+1;
				var p=(this.elpos>2)?this.elpos-2:0;
				this.overflow.scrollTop=p*this.t;
				this.setActive(this.overflow.childElements()[0].childElements()[this.elpos]);
				break;
			case Event.KEY_RETURN: // KEY down
				this.actElm.click();
				this.overflow.hide();
				break;
			default:
				this.overflow.hide();
		}
	},
	closeHandler:function(e){
		try{
			var tar=e.element();
			if(this.options.field!=tar){
				this.overflow.hide();
			}
		}catch(e){}
	},
	getSelect:function(){
		var overflow=new Element('div',{'class':this.options.ContClass});
		var div=new Element("div");
		var tmpdate=new Date();
		tmpdate.setHours(0);
		tmpdate.setMinutes(0);
		var that=this;
		for(var i=0; i<=47;i++){
			var e=new Element('div',{'class':this.options.OptionClass}).update(tmpdate.print("%H:%M"));
			var tmp=tmpdate.print("%H:%M");
			var tmp2=Date.parseDate("01.01.1901 "+this.options.field.value,"%d.%m.%Y %H:%M");
			tmp2.setMinutes(tmp2.getMinutes()>=30?30:0);
			tmp2=tmp2.print("%H:%M");
			tmp2==tmp?this.setActive(e):null;
			tmpdate.setMinutes(tmpdate.getMinutes()+30);
			e.click=function(){
				var h=that.options.field.value.substring(0,2);
				var m=that.options.field.value.substring(2,4);
				that.options.field.value=that.options.field.value.include(":")?that.options.field.value:h+":"+m;
				var tmp=Date.parseDate("01.01.1901 "+that.options.field.value,"%d.%m.%Y %H:%M");
				that.options.field.value=tmp.print("%H:%M");
				that.options.field.value=overflow.visible()?this.innerHTML:that.options.field.value;
				that.valuefield.value=that.options.field.value;
				that.options.callHandler? that.options.callHandler(that.options.handlerOpt):null;
			};
			e.observe("click",function(e){
				this.click();
				});
			e.observe("mouseover",function(){
				that.setActive(this);
				});
			div.insert(e);
		}
		overflow.insert(div);
		$$('body')[0].insert(overflow);
		overflow.style.left=this.options.field.cumulativeOffset()[0]-(overflow.getWidth()-this.options.field.getWidth())+"px";
		overflow.style.top=this.options.field.cumulativeOffset()[1]+this.options.field.getHeight()+"px";
		overflow.hide();
		this._init(overflow);
	},
	getInterval:function(date){
		var that=this;
		var overflow=new Element('div',{'class':this.options.ContClass+" "+this.options.IntervalClass});
		var div=new Element("div");
		var tmpdate=new Date(date.getTime());
		var h=tmpdate.getHours();
		t=new Array();
		for(var i=0; i<=47;i++){
			var e=new Element('div',{'class':'option'}).update(tmpdate.print("%H:%M")+" ("+(i/2)+" h)");
			e.time=tmpdate.print("%H:%M");
			var tmp=tmpdate.print("%H:%M");
			this.options.field.value==tmp?this.setActive(e):null;
			tmpdate.setMinutes(tmpdate.getMinutes()+30);
			e.click=function(){
				var h=that.options.field.value.substring(0,2);
				var m=that.options.field.value.substring(2,4);
				that.options.field.value=that.options.field.value.include(":")?that.options.field.value:h+":"+m;
				var tmp=Date.parseDate("01.01.1901 "+that.options.field.value,"%d.%m.%Y %H:%M");
				that.options.field.value=tmp.print("%H:%M");
				that.options.field.value=overflow.visible()?this.innerHTML.substring(0,5):that.options.field.value;
				that.valuefield.value=that.options.field.value;
				that.options.callHandler? that.options.callHandler(that.options.handlerOpt):null;
			};
			e.observe("click",function(e){
								this.click();
								});
			e.observe("mouseover",function(){
									that.setActive(this);
									});
			div.insert(e);
		}
		overflow.insert(div);
		$$('body')[0].insert(overflow);
		overflow.style.left=this.options.field.cumulativeOffset()[0]-(overflow.getWidth()-this.options.field.getWidth())+"px";
		overflow.style.top=this.options.field.cumulativeOffset()[1]+this.options.field.getHeight()+"px";
		overflow.hide();
		this._init(overflow);
	}
});
DSSelectCalendar.withTime=Class.create(DSSelectCalendar,{

	initialize:function($super,opt,isExtend){
		var that=this;
		this.time_select=null;
		$super(opt,true);
		this.options=Object.extend(this.options,{
		    time_field:"start_time",
			time_opt:null
		});
		this.options=Object.extend(this.options, arguments[1]);
		this.time=$(this.options.time_field);
		this.time_view=$(this.options.time_field+"_view");
		this.time_view.observe("change",this.setValues());
		if(!isExtend){
			this.setValues(true);
			if(this.options.disable)
				this.switcher(true);
		}
		var timeopt=Object.extend({field:this.time},this.options.time_opt);
		this.time_select=new DSSelectCalendar.Time(timeopt);
	},
	switcher:function($super,init){
		$super(init);
		if(!init){
			if(!$("disabled_"+this.options.time)){
				var e=new Element("input",{"type":"text","class":this.time.className,"id":"disabled_"+this.options.time});
				new Insertion.After(this.time,e);
				e.disable();
				e.hide();
			}
			e=$("disabled_"+this.options.time);
			if(!e.visible()){
				e.value=this.time.value;
				e.show();
				this.time.hide();
			}else{
				e.hide();
				this.time.show();
			}
		}
	},
	setValues:function($super,init){
		$super(init);
		this.date.setHours(this.time_view.value.substring(0,2));
		this.date.setMinutes(this.time_view.value.substring(3,5));
		this.time.value=this.time_view.value;
	}
});
DSSelectCalendar.Double=Class.create({
	initialize:function(obj,isExtend){
		var that=this;
		this.options=Object.extend({
			start_date:new Date(),
			field: "start_date",
			format:"%d.%m.%Y",
			errorClass: "DSSCError",
			end_date:new Date(),
			field_to: "end_date",
			empty2:false,
			disable_to:false,
			intervalDay: 0,
			errorHandler: 1
		},obj);
		obj.empty=that.options.empty;
		obj.onSelect=function (calendar,date){
						that.from.date.setDateOnly(calendar.date);
						if (calendar.dateClicked){calendar.callCloseHandler();}
						that.dateChanged("from")
						};
		this.from=new DSSelectCalendar(obj,true);
		var obj_to={
		    start_date:that.options.end_date,
			field: obj.field_to,
			empty: that.options.empty2,
			onSelect:function (calendar,date){
						that.to.date.setDateOnly(calendar.date);
						if (calendar.dateClicked){calendar.callCloseHandler();}
						that.dateChanged("to")
						},
			disable:that.options.disable_to,
			format:that.options.format		
		};
		this.to=new DSSelectCalendar(obj_to,true);
		this.field=$(this.options.field+"_view");
		this.field_to=$(this.options.field_to+"_view");
		this.field.observe("change",function(){that.valuesChanged("from");});
		this.field_to.observe("change",function(){that.valuesChanged("to")});
		this.errorcorrecter=this.options.errorHandler==1? this.correct1:this.correct2;
		if(!isExtend){
			this.setValues(true);
			if(this.options.disable){
				this.errorcorrecter=this.correct3;
				this.switcher(true);
			}
		}
	},
	checkEmpty:function(date,field){
		var that=this;
		var tmp=Date.parseDate("1.1.1901","%d.%m.%Y");
		var actfiled=$(field);
		actfiled.value=date.print("%Y-%m-%d");
		$(field+"_view").value=date.print(this.options.format);
		if(tmp.equalsToDay(date)){
			if(field==this.options.field)
				this.from.date=date;
			else
				this.to.date=date;
			$(field+"_view").value=DSLang("nodate");
			return true;
		}else{
			return false;
		}
	},
	switcher:function(init){
		this.from.switcher(init);
		if(this.options.disable_to)
			this.to.switcher(init);
	},
	setValues:function(init){
		this.from.setValues(init);
		this.to.setValues(init);
		
	},
	valuesChanged:function(f){
		this.from.date=Date.parseDate(this.field.value,this.options.format);
		this.to.date=Date.parseDate(this.field_to.value,this.options.format);
		this.dateChanged(f);
	},
	dateChanged:function(f) {
		if(f=="from"){
			var actfield=this.options.field;
			var actdate=this.from.date;
			var emptyCheck=this.options.empty;
		}
		else{
			var actfield=this.options.field_to;
			var actdate=this.to.date;
			var emptyCheck=this.options.empty2;
		}
		if(emptyCheck){
			if(!this.checkEmpty(actdate,actfield)){
				var tmp=Date.parseDate("1.1.1901","%d.%m.%Y");
				if(!tmp.equalsToDay(this.from.date) && !tmp.equalsToDay(this.to.date)){
					if(f=="from" && this.options.intervalDay!=0){
						this.to.date.setFullYear(this.from.date.getFullYear());
						this.to.date.setMonth(this.from.date.getMonth());
						this.to.date.setDate(this.from.date.getDate()+this.options.intervalDay);
					};
					this.setValues();
					this.errorcorrecter(f);
				}
			}else{
				this.field.removeClassName(this.options.errorClass);
				this.field_to.removeClassName(this.options.errorClass);
			}
		}else{
			if(f=="from" && this.options.intervalDay!=0){
				this.to.date.setFullYear(this.from.date.getFullYear());
				this.to.date.setMonth(this.from.date.getMonth());
				this.to.date.setDate(this.from.date.getDate()+this.options.intervalDay);
			};
			this.setValues();
			this.errorcorrecter(f);
		}
	},
	correct1:function (f){
		this.field_to.removeClassName(this.options.errorClass);
		this.field.removeClassName(this.options.errorClass);
		if(f=="from"){
			if(this.from.date>this.to.date){
				this.field_to.addClassName(this.options.errorClass);
			}
		}else{
			if(this.from.date>this.to.date){
				this.field.addClassName(this.options.errorClass);
			}
		}
		if((this.from.date.print(this.options.format)==this.field.value)
			||(this.to.date.print(this.options.format)==this.field_to.value))
			this.setValues();
	},
	correct2:function(f){
			if(!this.from.date.equalsTo(this.to.date)){
				if(f=="from"){
					if(this.from.date>this.to.date){
							this.to.date=new Date(this.from.date.getTime());
					}
				}else{
					if(this.from.date>this.to.date){
						this.from.date=new Date(this.to.date.getTime());
					}
				}
			}
			this.setValues();
	},
	correct3:function(f){
			if(!this.from.date.equalsTo(this.to.date)){
					if(this.from.date>this.to.date){
							this.to.date=new Date(this.from.date.getTime());
					}
			}
			this.setValues();
	}
});
DSSelectCalendar.DoubleWithTime=Class.create(DSSelectCalendar.Double,{
	
	initialize:function($super){
		$super(arguments[1],true);
		this.tmphours=-1;
		this.options=Object.extend(this.options,{
			time_field:"start_time",
			time_to_field:"end_time",
			time_opt1:null,
			empty2:false,
			time_opt2:null,
			interval:60,
			errorHandler: 1
		});
		this.options=Object.extend(this.options, arguments[1]);
		this.interval=this.options.interval;
		this.time=$(this.options.time_field);
		this.time_view=$(this.options.time_field+"_view");
		this.time_to=$(this.options.time_to_field);
		this.time_to_view=$(this.options.time_to_field+"_view");
		var that=this;
		this.time.observe("change",function(){that.valuesChanged("from")});
		this.time_to.observe("change",function(){that.valuesChanged("to")});
		this.errorcorrecter=this.options.errorHandler==1? this.correct1:this.correct2;
		this.setValues(true);
		this.initSelect();
		if(this.options.disable)
		{
			this.errorcorrecter=this.correct3;
			this.switcher(true);
		}
	},
	switcher:function($super,init){
		$super(init);
		if(!init){
			if(!$("disabled_"+this.options.time_field)){
				var e=new Element("input",{"type":"text","class":this.time.className,"id":"disabled_"+this.options.time_field});
				new Insertion.After(this.time,e);
				e.disable();
				e.hide();
			}
			e=$("disabled_"+this.options.time_field);
			if(!e.visible()){
				e.value=this.time.value;
				e.show();
				this.time.hide();
			}else{
				e.hide();
				this.time.show();
			};
			if(this.options.disable_to){
				if(!$("disabled_"+this.options.time_to_field)){
					var e=new Element("input",{"type":"text","class":this.time_to.className,"id":"disabled_"+this.options.time_to_field});
					new Insertion.After(this.time_to,e);
					e.disable();
					e.hide();
				}
				e=$("disabled_"+this.options.time_to_field);
				if(!e.visible()){
					e.value=this.time_to.value;
					e.show();
					this.time_to.hide();
				}else{
					e.hide();
					this.time_to.show();
				};
			}
		}
	},
	setValues:function($super,init){
		$super(init);
		this.time.value=this.from.date.print("%H:%M");
		this.time_to.value=this.to.date.print("%H:%M");
		this.time_view==this.from.date.print("%H:%M");
		this.time_to_view.value=this.to.date.print("%H:%M");
	},
	correct1:function (f){
		this.field_to.removeClassName(this.options.errorClass);
		this.field.removeClassName(this.options.errorClass);
		this.time.removeClassName(this.options.errorClass);
		this.time_to.removeClassName(this.options.errorClass);
		if(f=="from"){
			if(this.from.date>this.to.date){
				this.time.addClassName(this.options.errorClass);
				this.field.addClassName(this.options.errorClass);
			}
		}else{
			if(this.from.date>this.to.date){
				this.time_to.addClassName(this.options.errorClass);
				this.field_to.addClassName(this.options.errorClass);
			}
		}
		if((this.from.date.print(this.options.format)==this.field.value)
			||(this.to.date.print(this.options.format)==this.field_to.value))
			this.setValues();
	},
	correct2:function(f){
			if(!this.from.date.equalsTo(this.to.date)){
				if(f=="from"){
					if(this.from.date>this.to.date){
							this.to.date=new Date(this.from.date.getTime());
							if(this.interval!=false)
								this.to.date.setMinutes(this.interval<0?(this.to.date.getMinutes()-this.interval):(this.to.date.getMinutes()+this.interval));
					}
				}else{
					if(this.from.date>this.to.date){
						this.from.date=new Date(this.to.date.getTime());
						if(this.interval!=false)
							this.from.date.setMinutes(this.interval<0?(this.from.date.getMinutes()+this.interval):(this.from.date.getMinutes()-this.interval));
					}
				}
			}
			this.setValues();
			this.reinitSelect();
	},
	correct3:function(f){
			if(!this.from.date.equalsTo(this.to.date)){
					if(this.from.date>this.to.date){
							this.to.date=new Date(this.from.date.getTime());
							if(this.interval!=false)
								this.to.date.setMinutes(this.interval<0?(this.to.date.getMinutes()-this.interval):(this.to.date.getMinutes()+this.interval));
					}
			}
			this.setValues();
			this.reinitSelect();
	},
	setInterval:function(){
		if(this.interval!=false){
			var int=((this.to.date.getHours()-this.from.date.getHours())*60)+(this.to.date.getMinutes()-this.from.date.getMinutes());
			this.interval=int;
		}
	},
	initSelect:function(){
		var that=this;
		var timeopt1=Object.extend({
									field:this.time,
									callHandler:function(opt){that.valuesChanged(opt)},
									handlerOpt:"from"
									},this.options.time_opt1);
		var dst=new DSSelectCalendar.Time(timeopt1);
		this.time_select=dst;
		var timeopt2=Object.extend({
									field:this.time_to,
									date:this.from.date,
									callHandler:function(opt){
										var tmpdate=new Date(that.to.date.getTime());
										var tmptime=Date.parseDate(tmpdate.print(that.options.format)+" "+that.time_to.value,that.options.format+" %H:%M");
										tmpdate.setHours(tmptime.getHours());
										tmpdate.setMinutes(tmptime.getMinutes());
										if(that.from.date>tmpdate){
											tmpdate.setDate(tmpdate.getDate()+1);
											that.to.date=new Date(tmpdate.getTime());
											that.setValues();
										}
										that.valuesChanged(opt)},
									handlerOpt:"to"
									},this.options.time_opt2);
		var dst2=new DSSelectCalendar.Time(timeopt2);
		if(this.interval!=false){
			if(this.from.date.equalsToDay(this.to.date))
				dst2.getInterval(this.from.date);
		}
		this.time_select_to=dst2;
	},
	reinitSelect:function(){
		if(this.from.date.equalsToDay(this.to.date) && this.interval!=false){
			this.time_select_to.getInterval(this.from.date);
		}else{
			this.time_select_to.getSelect();
		}
		this.time_select.getSelect();
	},
	valuesChanged:function(f){
		var tmp=this.date;
		var tmpdate=Date.parseDate(this.field.value,this.options.format);
		var tmptime=Date.parseDate(tmpdate.print(this.options.format)+" "+this.time.value,this.options.format+" %H:%M");
		tmpdate.setHours(tmptime.getHours());
		tmpdate.setMinutes(tmptime.getMinutes());
		this.from.date=new Date(tmpdate.getTime());
		if(f=="from"){
			if(this.interval!=false){
				this.to.date.setHours(this.from.date.getHours());
				this.to.date.setMinutes(this.from.date.getMinutes()+this.interval);
			}
		}else{
			tmpdate=Date.parseDate(this.field_to.value,this.options.format);
			tmptime=Date.parseDate(tmpdate.print(this.options.format)+" "+this.time_to.value,this.options.format+" %H:%M");
			tmpdate.setHours(tmptime.getHours());
			tmpdate.setMinutes(tmptime.getMinutes());
			this.to.date=new Date(tmpdate.getTime());
		}
		if(f=="from" && this.options.intervalDay!=0){
			this.to.date.setFullYear(this.from.date.getFullYear());
			this.to.date.setMonth(this.from.date.getMonth());
			this.to.date.setDate(this.from.date.getDate()+this.options.intervalDay);
		};
		if(f=="from"){
			var actfield=this.options.field;
			var actdate=this.from.date;
			var emptyCheck=this.options.empty;
		}
		else{
			var actfield=this.options.field_to;
			var actdate=this.to.date;
			var emptyCheck=this.options.empty2;
		}
		if(emptyCheck){
			if(!this.checkEmpty(actdate,actfield)){
				var tmp=Date.parseDate("1.1.1901","%d.%m.%Y");
				if(!tmp.equalsToDay(this.from.date) && !tmp.equalsToDay(this.to.date)){
					this.errorcorrecter(f);
				}
			}else{
				if(f=="from"){
					this.time.value="00:00";
					this.time_view.value="00:00";
				}
				else{
					this.time_to.value="00:00";
					this.time_to_view.value="00:00";
				}
				this.time.removeClassName(this.options.errorClass);
				this.field.removeClassName(this.options.errorClass);
			}
		}else{
			this.errorcorrecter(f);
		}
		this.reinitSelect();
		this.setInterval();
	},
	dateChanged:function(f) {
		if(f=="from"){
			var actfield=this.options.field;
			var actdate=this.from.date;
			var emptyCheck=this.options.empty;
		}
		else{
			var actfield=this.options.field_to;
			var actdate=this.to.date;
			var emptyCheck=this.options.empty2;
		}
		if(emptyCheck){
			if(!this.checkEmpty(actdate,actfield)){
				var tmp=Date.parseDate("1.1.1901","%d.%m.%Y");
				if(!tmp.equalsToDay(this.from.date) && !tmp.equalsToDay(this.to.date)){
					if(f=="from" && this.options.intervalDay!=0){
						this.to.date.setFullYear(this.from.date.getFullYear());
						this.to.date.setMonth(this.from.date.getMonth());
						this.to.date.setDate(this.from.date.getDate()+this.options.intervalDay);
					};
					this.setValues();
					this.errorcorrecter(f);
				}
			}else{
				if(f=="from"){
					this.time.value="00:00";
					this.time_view.value="00:00";
				}
				else{
					this.time_to.value="00:00";
					this.time_to_view.value="00:00";
				}
				this.time.removeClassName(this.options.errorClass);
				this.field.removeClassName(this.options.errorClass);
			}
		}else{
			if(f=="from" && this.options.intervalDay!=0){
				this.to.date.setFullYear(this.from.date.getFullYear());
				this.to.date.setMonth(this.from.date.getMonth());
				this.to.date.setDate(this.from.date.getDate()+this.options.intervalDay);
			};
			this.setValues();
			this.errorcorrecter(f);
		}
		this.reinitSelect();
		this.setInterval();
	},
	setFullDay:function(bool){
		if(this.options.disable||this.options.disable_to)
			return;
		if(bool){
			this.tmphours=this.from.date.getHours();
			this.tmpmin=this.from.date.getMinutes();
			this.tmphoursto=this.to.date.getHours();
			this.tmpminto=this.to.date.getMinutes();
			this.from.date.setHours(0);
			this.from.date.setMinutes(0);
			this.to.date.setHours(23);
			this.to.date.setMinutes(59);
			this.setValues();
			$(this.time.id+'_view').hide();
			$(this.time_to.id+'_view').hide();
		}else{
			if(this.tmphours==-1){
				this.tmphours=this.from.date.getHours();
				this.tmpmin=this.from.date.getMinutes();
				this.tmphoursto=this.to.date.getHours();
				this.tmpminto=this.to.date.getMinutes();
			}
			this.from.date.setHours(this.tmphours);
			this.from.date.setMinutes(this.tmpmin);
			this.to.date.setHours(this.tmphoursto);
			this.to.date.setMinutes(this.tmpminto);
			this.setValues();
			$(this.time.id+'_view').show();
			$(this.time_to.id+'_view').show();
			this.reinitSelect();
		}
	}
});
var CalendarURL=Class.create({
									
	initialize:function(urls,params){
		this.options=Object.extend({
			container:"urllist",
			itemname:"linklistitem_",
			textfield:"linktext",
			titlefield:"linkurltitle",
			urlfield:"linkurl",
			targetfield:"linktarget",
			linksort:"linksort",
			linkcount:"linkcount",
			classfirst:"dslist1",
			classsecond:"dslist2",
			classhandle:"sortablehandle",
			addbutton:"linklistadd"
		},params);
		this.linktext=$(this.options.textfield);
		this.url=$(this.options.urlfield);
		this.target=$(this.options.targetfield);
		this.linktitle=$(this.options.titlefield);
		this.linksort=$(this.options.linksort);
		this.linkcount=$(this.options.linkcount);
		this.addbutton=$(this.options.addbutton);
		var that=this;
		this.addbutton.observe("click",function(){that.addLink()});
		this.container=$(this.options.container);
		this.calUrlList=[];
		if(typeof(urls)!="undefined" && urls.length!=0){
			this.calUrlList=urls;
			for(var i=1;i<=this.calUrlList.length;i++){
				var str='<li class="'+this.options.classhandle+' '+this.options.classfirst+' menuselector" id="'+this.options.itemname+i+'">\
				<div class=" ds_3column_1">'+this.calUrlList[i-1].text+'</div>\
				<div class="ds_3column_2">'+this.calUrlList[i-1].url+'</div>\
				<div class="ds_3column_3">'+this.calUrlList[i-1].target+'</div>\
				<input type="hidden" id="'+this.options.itemname+i+'_text" name="'+this.options.itemname+i+'_text" value="'+this.calUrlList[i-1].text+'">\
				<input type="hidden" id="'+this.options.itemname+i+'_title" name="'+this.options.itemname+i+'_title" value="'+this.calUrlList[i-1].title+'">\
				<input type="hidden" id="'+this.options.itemname+i+'_url" name="'+this.options.itemname+i+'_url" value="'+this.calUrlList[i-1].url+'">\
				<input type="hidden" id="'+this.options.itemname+i+'_target" name="'+this.options.itemname+i+'_target" value="'+this.calUrlList[i-1].target+'">\
				</li>';
				this.container.insert(str);
				new Proto.Menu({selector: '.menuselector',className: 'menu desktop',menuItems: 'calendarlinklist_actions' ,mouseevent:'contextmenu'});
			}
		};
		this.calUrlActPos=1;
		this.calUrlEdit=false;
		this.updateLinkList();
	},
	sortLinks:function(){
		var i=1;
		var linksort="";
		var that=this;
		$$("#"+that.options.container+" li").each(function(handleEml){
			handleEml.removeClassName(that.options.classsecond);
			handleEml.removeClassName(that.options.classfirst);
			if(Math.round(i/2)!=(i/2))
				handleEml.addClassName(that.options.classfirst);
			else
				handleEml.addClassName(that.options.classsecond);
			i++;
			linksort+=linksort.length? ","+handleEml.id:handleEml.id;												
		});
		this.linksort.value=linksort;
		this.linkcount.value=i;
	},
	addLink:function(){
		if(!this.validateLink())
			return;
		var newLink=new Object();
		newLink.text=this.linktext.value;
		newLink.title=this.linktitle.value;
		newLink.url=this.url.value;
		newLink.target=this.target.value;
		this.calUrlList.push(newLink);
		var str='<li class="'+this.options.classfirst+' menuselector" id="'+this.options.itemname+this.calUrlList.length+'">\
			<div class=" ds_3column_1">'+this.linktext.value+'</div>\
			<div class="ds_3column_2">'+this.url.value+'</div>\
			<div class="ds_3column_3">'+this.target.value+'</div>\
			<input type="hidden" id="'+this.options.itemname+this.calUrlList.length+'_text" name="'+this.options.itemname+this.calUrlList.length+'_text" value="'+this.linktext.value+'">\
			<input type="hidden" id="'+this.options.itemname+this.calUrlList.length+'_title" name="'+this.options.itemname+this.calUrlList.length+'_title" value="'+this.linktitle.value+'">\
			<input type="hidden" id="'+this.options.itemname+this.calUrlList.length+'_url" name="'+this.options.itemname+this.calUrlList.length+'_url" value="'+this.url.value+'">\
			<input type="hidden" id="'+this.options.itemname+this.calUrlList.length+'_target" name="'+this.options.itemname+this.calUrlList.length+'_target" value="'+this.target.value+'">\
			</li>';
		this.linktext.value="";
		this.target.selectedIndex=0;
		this.url.value="";
		this.linktitle.value="";
		this.container.insert(str);
		new Proto.Menu({selector: '.menuselector',className: 'menu desktop',menuItems: 'calendarlinklist_actions' ,mouseevent:'contextmenu'});
		this.updateLinkList();
	},
	removeLink:function(elmid){
		var position=elmid.slice(this.options.itemname.length);
		this.calUrlList[position-1]=null;
		if(this.calUrlEdit){
			if(position==this.calUrlActPos){
				this.linktext.value="";
				this.target.selectedIndex=0;
				this.url.value="";
				this.linktitle.value="";
				var that=this;
				this.addbutton.stopObserving("click");
				this.addbutton.observe("click",function(){that.addLink();});
				this.calUrlEdit=false;
				this.addbutton.value=DSLang('add');
			}
		}
		$(this.options.itemname+position).remove();
		this.updateLinkList();
	},
	updateLink:function(){
		if(!this.validateLink())
			return;
		var position=this.calUrlActPos;
		var newLink=new Object();
		newLink.text=this.linktext.value;
		newLink.title=this.linktitle.value;
		newLink.url=this.url.value;
		newLink.target=this.target.value;
		this.calUrlList[position-1]=newLink;
		var str='<div class=" ds_3column_1">'+this.linktext.value+'</div>\
			<div class="ds_3column_2">'+this.url.value+'</div>\
			<div class="ds_3column_3">'+this.target.value+'</div>\
			<input type="hidden" id="'+this.options.itemname+position+'_text" name="'+this.options.itemname+position+'_text" value="'+this.linktext.value+'">\
			<input type="hidden" id="'+this.options.itemname+position+'_title" name="'+this.options.itemname+position+'_title" value="'+this.linktitle.value+'">\
			<input type="hidden" id="'+this.options.itemname+position+'_url" name="'+this.options.itemname+position+'_url" value="'+this.url.value+'">\
			<input type="hidden" id="'+this.options.itemname+position+'_target" name="'+this.options.itemname+position+'_target" value="'+this.target.value+'">\
			';
		var that=this;
		this.addbutton.stopObserving("click");
		this.addbutton.observe("click",function(){that.addLink();});
		this.linktext.value="";
		this.target.selectedIndex=0;
		this.url.value="";
		this.linktitle.value="";
		$(this.options.itemname+position).update(str);
		this.addbutton.value=DSLang('add');
		this.calUrlEdit=false;
		
	},
	editLink:function(elmid){
		var position=elmid.slice(this.options.itemname.length);
		this.linktitle.value=this.calUrlList[position-1].title;
		this.url.value=this.calUrlList[position-1].url;
		this.target.value=this.calUrlList[position-1].target;
		this.linktext.value=this.calUrlList[position-1].text;
		var that=this;
		this.addbutton.stopObserving("click");
		this.addbutton.observe("click",function(){that.updateLink();});
		this.addbutton.value=DSLang('save');
		this.calUrlActPos=position;
		this.calUrlEdit=true;
	},
	validateLink:function(){
		var msg="";
		if(this.linktext.value=="")
			msg=DSLang('linktext')+": "+DSLang("alerttexturlnotempty");
		if(this.url.value=="")
			msg=DSLang('linkurl')+": "+DSLang("alerttexturlnotempty");
		if(msg!="")alert(msg);
		if(msg!="")
			return false;
		else
			return true;
	},
	updateLinkList:function(){
		var that=this;
		Sortable.create(that.options.container,{ghosting:false,constraint:false,onUpdate:function(){that.sortLinks()}});
		this.sortLinks();
		DSPopUpResize();
	}
});
function initSelectCalendar(type,params,fullday,elm){
	params=params.evalJSON();
	switch(type){
		case "DoubleWithTime":
			$(params.field+"_view").onfocus=null;
			$(params.field_to+"_view").onfocus=null;
			$(params.time_field+"_view").onfocus=null;
			$(params.time_to_field+"_view").onfocus=null;
			$(params.field+"_view").dsselectcalendar=new DSSelectCalendar.DoubleWithTime(params);
			if(fullday){
				var clickstr="$('"+params.field+"_view').dsselectcalendar.setFullDay(this.checked)";
				$(fullday).onclick=function(){
							eval(clickstr);
						};
				if(elm.id==fullday)
					$(params.field+"_view").dsselectcalendar.setFullDay($(fullday).checked);
			}
			break;
		case "Double":
			$(params.field+"_view").onfocus=null;
			$(params.field_to+"_view").onfocus=null;
			$(params.field+"_view").dsselectcalendar=new DSSelectCalendar.Double(params);
			break;
		case "withTime":
			$(params.field+"_view").onfocus=null;
			$(params.time_field+"_view").onfocus=null;
			$(params.field+"_view").dsselectcalendar=new DSSelectCalendar.withTime(params);
			break;
		case "Date":
			$(params.field+"_view").onfocus=null;
			$(params.field+"_view").dsselectcalendar=new DSSelectCalendar(params);
			break;
	}
	if(elm.id!=fullday){
		elm.blur();
		elm.click();
	}
};
/* Functions */
function event_chk_form(caller){
	// 2006-10-22 [AP] Arguement Caller hinzugefügt, wenn ein Task vom Artikel gespeichert wird
	start_date=Date.parseDate($('start_date').value+" "+$('start_time').value,"%Y-%m-%d %H:%M");		
	end_date=Date.parseDate($('end_date').value+" "+$('end_time').value,"%Y-%m-%d %H:%M");	
	recurrence_end_date=Date.parseDate($('recurrence_end_date').value,"%Y-%m-%d");
	recurrence_end_date.setHours(23);
	recurrence_end_date.setMinutes(59);
	d_diff=DSDateDiff('d',start_date,end_date);
	msg=''; 
	period=$('period');


	DSCal=eval('top.DSCal_'+$('dscalid').value);
	if (DSCal!=null && $('CalendarCurrDate')!=null){
		//alert(document.getElementById('dscalid').value);
		this_currdate=DSCal.calendar_currentdate;
		//alert(this_currdate.toString())
		thisvar=this_currdate.getFullYear()+'-'+DSInt(this_currdate.getMonth()+1)+'-'+this_currdate.getDate();
		$('CalendarCurrDate').value=thisvar;
	}	
	
	if (DSTrim($('title').value)=='')
		msg+=DSLang('alertcalsubject');
	if ((end_date.getFullYear()==1901 || end_date.getFullYear()==2500) && end_date.getMonth()==0 && end_date.getDate()==1){
		msg+='';
	}
	else if (period!=null && period.value=='wholeday')
		msg+='';
	else if (start_date >end_date)
		msg+=DSLang('alertstartforenddate');
	
	if ($('recurrence_type').selectedIndex!=0){
		if ($('recurrence_type').selectedIndex==1){ //daily
			if (document.getElementsByName('daily_type')[0].checked){
				day_step=$('day_step').value;
				if (!DSIsNum(day_step)) {
					msg+=DSLang('alertnovalidinterval');
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",day_step);
				}
				else{
					day_step=DSInt(day_step);
					if (d_diff >= day_step) {
						msg+=DSLang('alertintervaldailyrepeat');
						msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",day_step);
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",d_diff);
					}
				}
			}
			else{
				if (d_diff > 0)
					msg+=DSLang('alertrepeatworkdays');
			}
		}
		else if($('recurrence_type').selectedIndex==2){ // weekly
			if (!DSIsNum($('week_step').value)) {
				msg+=DSLang('alertnotavlidnumber');
				msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",$('week_step').value)
			}
			else{
				wd=document.getElementsByName('weekdays');
				start_date_wd_found=0;
				this_wd=new Array();
				for(i=0; i<wd.length; i++){
					if (wd[i].checked){
						this_wd[this_wd.length]=i
						if (start_date.getDay()==eval(wd[i].value-1))
							start_date_wd_found=1;	
					}
				}
				if (this_wd.length==0)
					msg+=DSLang('alertrepeatweekdays');
				else{
					if (this_wd.length==1)
						chk_days=6;
					else{
						start_diff=this_wd[0]-0;
						end_diff=6-this_wd[this_wd.length-1];
						chk_days=start_diff+end_diff;
						for(i=1; i<this_wd.length; i++){
							this_diff=this_wd[i]-this_wd[i-1]-1;
							if (this_diff<chk_days)
								chk_days=this_diff;
						}
					}
					if (d_diff>=$('week_step').value*7){
						msg+=DSLang('alerttimeperiodinterval');
						msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",eval(DSInt(d_diff/7)+1),"All");
					}
					else if (d_diff >=7 && this_wd.length!=1)
						msg+=DSLang('alertrepeatoneweekday');
					else if (d_diff > chk_days)
						msg+=DSLang('alerttimeperiodrepeatweekday');
					if (start_date_wd_found==0) {
						msg+=DSLang('alertrepeatweeklyacitve');
						msg=DSJS.ReplaceNoCase(msg,"@@replace3@@",DayNames[start_date.getDay()],"All");
					}
					msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",d_diff,"All");
					
					
				}
			}
		}
	}
	if(start_date>recurrence_end_date && $('end_type_3').checked){
		msg+=DSLang('alertendolderbeginn');
		msg=DSJS.ReplaceNoCase(msg,"@@replace1@@",DSDateTimeFormat('date',end_date),"All");
		msg=DSJS.ReplaceNoCase(msg,"@@replace2@@",DSDateTimeFormat('date',recurrence_end_date),"All");
	}
	if (msg=='') {
		if (caller!=null && caller=='article')
			submitform=1;
		else 
			dsform_submit();
	}
	else{
		alert(msg);
		$('dsbutton_submit').disabled=false;
	}
 }	
 // JavaScript Document
function DSCurrentCommand(element) {
	// alert(element.id);
	$('fpcommentcommandname').innerHTML='';
	$('fpcommentcommandid').innerHTML=0;
	// Global TabBar
	if(DSJS.FindNoCase('ankerDSTabBar_view_view_view_view_',element.id)) {
		$('fpcommentcommandgui').innerHTML='tab';
		$('fpcommentcommand').innerHTML=DSJS.ListLast(element.id,'ankerDSTabBar_view_view_view_view_');
		DSCurrentCommandAction();
	}
	// Global Tree
	// 5311
	else if(DSJS.FindNoCase('DSTree_dsmenutree_5311',element.id)) {
		$('fpcommentcommandgui').innerHTML='tree';
		thecom=DSJS.ListGetAt(element.id,4,'_')+'_'+DSJS.ListGetAt(element.id,5,'_')+'_'+DSJS.ListGetAt(element.id,6,'_')+'_'+DSJS.ListGetAt(element.id,7,'_');
		$('fpcommentcommand').innerHTML=thecom;
		DSCurrentCommandAction();

	}
	// 5354
	else if(DSJS.FindNoCase('DSTree_dsmenutree_5354',element.id)) {
		$('fpcommentcommandgui').innerHTML='tree';
		thecom=DSJS.ListGetAt(element.id,4,'_')+'_'+DSJS.ListGetAt(element.id,5,'_')+'_'+DSJS.ListGetAt(element.id,6,'_')+'_'+DSJS.ListGetAt(element.id,7,'_');
		$('fpcommentcommand').innerHTML=thecom;
		DSCurrentCommandAction();

	}	
	// Accordion
	else if(DSJS.FindNoCase('dsacc',element.id)) {
		$('fpcommentcommandgui').innerHTML='accordion';
		thecom=DSJS.ListGetAt(element.id,2,'_')+'_'+DSJS.ListGetAt(element.id,3,'_')+'_'+DSJS.ListGetAt(element.id,4,'_')+'_'+DSJS.ListGetAt(element.id,5,'_');
		$('fpcommentcommand').innerHTML=thecom;
		DSCurrentCommandAction();
	}
	// Content
	else {
		$('fpcommentcommandgui').innerHTML='checkbox';
		thecom=DSJS.ListGetAt(element.id,2,'_')+'_'+DSJS.ListGetAt(element.id,3,'_')+'_'+DSJS.ListGetAt(element.id,4,'_')+'_'+DSJS.ListGetAt(element.id,5,'_');
		$('fpcommentcommand').innerHTML=thecom;
		DSCurrentCommandAction();
	}
		
}
function DSComment_Send() {
	DSCurrentCommandAction();
	if($('fpcommenttext').value!='') {
		new Ajax.Request(dsxpath+'dynasite.cfm?dscmd=message_comment_comment_insert&dsxhr=1&dslinkidtype='+$('fpcommentcommandlinkidtype').innerHTML+'&dslinkid='+$('fpcommentcommandid').innerHTML,{
			method: 'post',
			postBody:'comment_text='+encodeURIComponent($('fpcommenttext').value)+'&comment_status='+$F('comment_status')+'&comment_Date_Due='+$F('comment_date')+'&CommentNameTo='+encodeURIComponent($('fpcommentcommandname').innerHTML),
			onComplete:function(returnvalue){
				if($('fpcommentcommandid').innerHTML=='0') {
					if($('fpcommentcommand').innerHTML=='message_comment_comment_view') {
						dsloader(dsxpath+'dynasite.cfm?dscmd=message_comment_comment_view&dscommentfilterbar=1&dslinkidtype='+$('fpcommentcommandlinkidtype').innerHTML+'&dslinkid='+$('fpcommentcommandid').innerHTML,'dsloader','message_comment_comment_view');
					}
				}
				else {
					dsloader(dsxpath+'dynasite.cfm?dscmd=message_comment_comment_view&dscommentfilterbar=0&dslinkidtype='+$('fpcommentcommandlinkidtype').innerHTML+'&dslinkid='+$('fpcommentcommandid').innerHTML,'dsloader','message_comment_comment_view');
				}

			}
		});
		$('fpcommenttext').value='';
		return false;
	}
}
function DSAppSearch() {
	 if(DSJS.Left($F('intercomsearchphrase'),2)=='t:') {
		test=window.open('http://www.dict.cc/'+DSJS.ListGetAt($F('intercomsearchphrase'),2,':'));
		return false;
	 }
	 else {
		document.intercom_form.submit();
	 } 
 }
function DSAppSearch_ContextMenu(e,element,action){
	$('intercomsearchphrase').value=action;
	$('intercomsearchphrase').focus();								
} 
