/* Replacement for German characters in javascript
	Chr	Replacement
	ä	\344
	ö	\366
	ü	\374
	Ä	\304
	Ö	\326http://192.168.1.220/login/w.cfm?cmd=591&app=14&cmd_old=243&id=58707
	Ü	\334
	ß	\337
*/

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 = naviuser.indexOf("msie") != -1 && document.all && dcbe && !opera;
var ns6 = (!opera && document.defaultView && typeof document.defaultView.getComputedStyle != 'undefined');
var w3c = !ie && !ns6 && !opera && document.getElementById;

var this_site="w.cfm?"
var disable_button_chk=0;
var disable_button_value="Bitte warten...";
var imageserver='http://i.xeu.de/w/';



/* Context BOX */ 
function context_hide(){
	document.getElementById("context").style.display="none";
	if (ie)
		document.getElementById("context_ie_help").style.display="none";
}
function context_innerhtml(this_content){
	document.getElementById("context").innerHTML=this_content;
}
function context_show(e,context_height,context_width){
	context_div=document.getElementById("context");
	if(typeof window.pageYOffset != "undefined")
		scrollheight = window.pageYOffset;
	else if(typeof document.documentElement.scrollTop != "undefined")
		scrollheight = document.documentElement.scrollTop;
	else
		scrollheight = document.body.scrollTop;
	if (typeof context_height != "undefined")
		context_div.style.height=context_height;
	if (typeof context_width != "undefined")
		context_div.style.width=context_width;
	
	context_div.style.left=ContextPos(e,'x',context_div);
	context_div.style.top=ContextPos(e,'y',context_div)
	context_div.style.display="block";
	
	if (ie){
		context_iframe=document.getElementById("context_ie_help");
	    context_iframe.style.top = context_div.style.top;
	    context_iframe.style.left = context_div.style.left;
		context_iframe.style.width = context_div.offsetWidth;
	    context_iframe.style.height = context_div.offsetHeight;
	    context_iframe.style.zIndex = context_div.style.zIndex - 1;
	    context_iframe.style.display = "block";
	}
}

function ContextPos(e,xy,this_object){
	if (xy=='x'){
		ShowLeft=false; //links oder rechts vom Cursor aufgehen?
		XFromCursor=5;	//Abstand vom Cursor (positiv oder negativ)
		this_width = Int(this_object.offsetWidth);
		if (ShowLeft)
			x_from_cursor=-(this_width+XFromCursor);
		else
			x_from_cursor=XFromCursor;		
		xlim = Int((dcbe && dcbe.clientWidth)? dcbe.clientWidth : window.innerWidth) + Int(window.pageXOffset || (dcbe? dcbe.scrollLeft : 0) || 0) - this_width ;
		pos = Int(e.pageX || e.clientX || 0) + Int(ie? dcbe.scrollLeft : 0) + x_from_cursor;
		if (pos > xlim)
			pos = xlim;
	}
	else{
		YFromCursor=5; //Abstand vom Cursor (positiv oder negativ)
		this_height = Int(this_object.offsetHeight);
		ylim = Int(window.innerHeight || dcbe.clientHeight) + Int(window.pageYOffset || (dcbe? dcbe.scrollTop : 0) || 0) - this_height - YFromCursor;
		pos = Int(e.pageY || e.clientY || 0) + Int(ie? dcbe.scrollTop : 0);
		if (pos > ylim)
			pos -=this_height;
	}
	pos+='px';
	return pos;
}


/* Global funktions */
function trim(this_value){
	return this_value.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function right(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 Int(to_integer){
	to_integer=parseInt(to_integer);
	if (isNaN(to_integer))
		to_integer=0;
	return to_integer;
}

function numchk(this_number){
	this_number=trim(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 list_array(this_obj){
	if (trim(this_obj.value)=='')
			retn_array=new Array();
		else
			retn_array=this_obj.value.split(",");
	return 	retn_array;
}

function win_open(url,this_width,this_height,this_name){
	if (typeof this_width=='undefined')
		this_width=800;
	if (typeof this_height=='undefined')
		this_height=600;
	if (typeof this_name=='undefined')
		this_name='NewWin'
	NewWin=window.open(url,this_name,'width='+this_width+',height='+this_height+',left='+Math.ceil(screen.width/2-this_width/2)+',top='+Math.ceil((screen.height-this_height)/2)+',scrollbars=1,resizable=1');
	NewWin.focus();
}


// Iframe Loader
var next_iframe=0;

function get_next_iframe(){
	next_iframe++
	if (next_iframe>2)
		next_iframe=1;
}

function loader (url,sio,this_width,this_height) {
	if (url.indexOf(this_site)==-1)
		url=this_site+url;
	if (typeof sio=='undefined' || sio=='0'){
		iframeloader=self;
		iframeloader.location.href=url;
	}
	else if (sio=='1'){
		get_next_iframe();
		iframeloader=eval('sbiframe'+next_iframe);
		iframeloader.location.href=url;
	}
	else if (sio=='2'){
		win_open(url,this_width,this_height);
	}
	else if (sio=='3'){
		opener.location.href=url;
		opener.focus();
	}
}


// Register or Tab /

last_tab='';
function tab(this_tab,error_show){
	if (last_tab!=this_tab && last_tab!=''){
		document.getElementById('fieldset_'+last_tab).style.display="none";	
		document.getElementById('register_'+last_tab).className="wm_register";	
	}
	if (document.getElementById('registertab')!=null)//assign value to hidden,so after submit same register tab can be shown
		document.getElementById('registertab').value=this_tab;
	document.getElementById('fieldset_'+this_tab).style.display="block";	
	document.getElementById('register_'+this_tab).className="wm_register_active";
	if (typeof error_show=='undefined' && document.getElementById("wm_message")!=null)// "showhide" passed when a page having more register tabs is loaded
		document.getElementById("wm_message").style.display="none";// if any form validation error shown hide that.
	last_tab=this_tab;
}

last_register='';
function register(this_register,url,sio,this_width,this_height){
	if (last_register!=this_register && last_register!=''){
		document.getElementById(last_register+'_content').style.display="none";	
		document.getElementById(last_register+'_tab').className="tab_inactive";	
	}
	document.getElementById(this_register+'_content').style.display="block";	
	document.getElementById(this_register+'_tab').className="tab_active";
	last_register=this_register;
	if (typeof url!='undefined')
		loader(url,sio,this_width,this_height)
}

function to_parent_div(element,loader){
	parent.document.getElementById(element).innerHTML=loader.document.getElementById(element).innerHTML;	
}

function to_parent_form(actionurl,this_width,this_height){
	parent.self.scrollTo(0, 0);
	if (typeof this_width=='undefined')
		this_width=600;
	if (typeof this_height=='undefined')
		this_height=500;
		
	parent.document.getElementById("f_popup").style.width=this_width+'px';
	parent.document.getElementById("f_popup").style.height=this_height+'px';
	
	parent.document.getElementById("f_body").style.width=this_width+'px';
	
	parent.document.f10.action='w.cfm?'+actionurl;
	if (document.getElementById("f_title")!=null)
		parent.document.getElementById("f_title").innerHTML=document.getElementById("f_title").innerHTML;
	else
		parent.document.getElementById("f_title").innerHTML="";
	if (document.getElementById("f_nav")!=null)
		parent.document.getElementById("f_nav").innerHTML=document.getElementById("f_nav").innerHTML;
	else
		parent.document.getElementById("f_nav").innerHTML="";
	parent.document.getElementById('f10').innerHTML=document.getElementById('f1').innerHTML;

	parent.document.getElementById("f_popup").style.display="block";
	parent.document.getElementById("f_body").style.display="block";
}

function f_popup_close(){
	parent.document.getElementById("f_popup").style.display="none";
}

function f_title_write(cfctitletext,width){
	if (typeof width=='undefined')
		width=600;
	oput='';
	oput+='<div id="f_title">';
	oput+='<table style="height:28px;background:#9D9DA1" cellpadding="0" cellspacing="0" border="0" width="'+width+'">';
	oput+='<tr><td colspan="3" style="background:#444444;height:1px;"></td></tr>';
	oput+='<tr><td colspan="3" style="background:#CCCCCC;height:1px;"></td></tr>';
	
	td_style='cursor:default;font-variant:small-caps;text-transform:capitalize;float:left;text-align:center;letter-spacing:1px;';
	
	oput+='<tr><td style="'+td_style+'" ondblclick="javascript:f_action(\'display\')" onmousedown="drag(event,\'f_popup\')" onmouseup="dragapproved=false;"></td>';
	
	td_style='font-weight:bold;font-size:1.05em;color:#ffffff;cursor:default;font-variant:small-caps;text-transform:capitalize;padding-left:5px;float:left;text-align:center;letter-spacing:1px;';
	
	oput+='<td style="'+td_style+'" ondblclick="javascript:f_action(\'display\')" onmousedown="drag(event,\'f_popup\')" onmouseup="dragapproved=false;">'+cfctitletext+'</td>';
	oput+='<td style="text-align:right;width:40px;"><a class="f_titleicon" href="javascript:f_action(\'display\')">_</a>&nbsp;&nbsp;<a class="f_titleicon" href="javascript:f_action(\'close\')">X</a>&nbsp;&nbsp;</td>'
	oput+='</tr>'
	oput+='<tr><td colspan="3" style="background:##444444;height:1px;"></td></tr>';
	oput+='</table>';
	oput+='</div>'
	document.write(oput)
}



/* Drag Element Script */
df=document.f1;
var dragapproved=false;
var drag_z,drag_x,drag_y;
document.onmouseup=new Function("dragapproved=false");

function moveit(e){
	if (dragapproved){
		drag_z.style.left=ns6? temp1+e.clientX-drag_x+'px' : temp1+event.clientX-drag_x+'px';
		drag_z.style.top=ns6? temp2+e.clientY-drag_y+'px' :  temp2+event.clientY-drag_y+'px';
		return false;
	}
}

function drag(e,dragelement){
		drag_z=document.getElementById(dragelement);
		dragapproved=true;
		temp1=parseInt(drag_z.style.left+100);
		temp2=parseInt(drag_z.style.top+100);
		drag_x=ns6? e.clientX : event.clientX;
		drag_y=ns6? e.clientY : event.clientY;
		document.onmousemove=moveit;
		return false;
}



// used for disabling any button (after submit time taking issue)

function disableobj(obj){
	document.getElementById(obj).disabled=true;
}

// for filling font combo used in layout.cfm (not used now can be deleted)
function write_font(name,thisval){
allfont=new Array("Verdana,Arial,Geneva","Arial,Helvetiva,Geneva","Comic Sans MS,Sans Serif,Geneva","Times New Roman,Serif","Trebuchet MS,Verdana,Geneva");
	str='<select name="'+name+'" id="'+name+'" class="wm_select">';	
	for (i=0;i<allfont.length;i++){
		str+='<option value="'+allfont[i]+'"';
		if(allfont[i]==thisval)
			str+=' selected="selected">';
		else
			str+='>';
		str+=allfont[i].replace(/,/g,", ")+'</option>';
	}
	str+='</select>';
	document.write(str);
}

// function for filling width combo box in layout.cfm (not used now can be deleted)
function write_width(name,start,end,step,thisval,fullwidth){
	str='<select name="'+name+'" id="'+name+'" class="wm_select">';
	if (fullwidth==1){
		str+='<option value="100"';
		if(thisval==100)
			str+=' selected="selected">100%';
		else
			str+='>100%';
	}
	for (i=start;i<=end;i=i+step){
		str+='<option value="'+i+'"';
		if(i==thisval)
			str+=' selected="selected">';
		else
			str+='>';
		str+=i+' px</option>';
	}
	str+='</select>';
	document.write(str);
}

// form functions
function form_button(save_val,cancel_val,cancel_url,formname,toiframe,layout){
	if (typeof formname=='undefined' || formname=='')
		formname='f1';
	if (typeof toiframe=='undefined' || toiframe=='')
		toiframe=0;
	strg='';
	if (typeof layout=='undefined' || layout=='')
		strg='<div class="wm_button">';
		
	if (cancel_val != '0' && cancel_val != ''){
		strg+='<input class="wm_submit" type="button" name="cancel" value="'+cancel_val+'" onclick="';
		if (cancel_url=='0' || cancel_url=='')
			strg+='history.back()';
		else if	(cancel_url=='-1') // self close pop up
			strg+='self.close()';
		else
			strg+='document.location.href=\'w.cfm?cmd='+cancel_url+'\'';
		strg+='" />';
	}
	strg+='&nbsp;&nbsp;';
	if (save_val !=''){
		strg+='<input class="wm_submit" name="wm_dummy" type="button" value="'+save_val+'" onclick="form_val(\''+formname+'\','+toiframe+',this);" />';
	}
	if (typeof layout=='undefined')
		strg+='</div>';
	document.write(strg);
	disable_button_chk=0;
}

function form_div_button(save_val,save_cancel_val,cancel_val){
	strg='';
	if (save_val!=''){
		strg+='<input class="wm_submit" type="button" value="'+cancel_val+'" onclick="f_action(\'close\');"  />';
		strg+='&nbsp;&nbsp;';
	}
	if (save_cancel_val!=''){
		strg+='<input class="wm_submit" type="button" value="'+save_cancel_val+'" onclick="f_action(\'saveclose\',this);" />';
		strg+='&nbsp;&nbsp;';
	}
	if (cancel_val!=''){
		strg+='<input class="wm_submit" type="button" value="'+save_val+'" onclick="f_action(\'save\',this)" />';
	}
	document.write(strg);
	disable_button_chk=0;
}

function f_action(command,this_button){
	if (command.indexOf("save")>-1){
		form_val('f10',1,this_button);
	}
	if(command=="display"){
		if (document.getElementById("f_body").style.display=="none")
			display="block";
		else
			display="none";
		document.getElementById("f_body").style.display=display;
		document.getElementById("f_nav").style.display=display;
	}
	else if(command.indexOf("close")>-1){
		document.getElementById("f_popup").style.display="none";
	}
}


function form_val(formname,toiframe,this_button){
	if (typeof formname=='undefined')
		df=document.f1;
	else
		df=eval('document.'+formname);
	qString=df.action.split("?");
	qString=qString[qString.length-1].split("&");
	url_cmd=0;
	for (i=0;i<qString.length;i++){
		if (qString[i].split("=")[0]=='cmd'){
			url_cmd=qString[i].split("=")[1]
			break;
		}
	}
	msg='';
	element_tofocus='';
	title='Fehler';
	form_validation();
	if (msg==''){
		if (toiframe==1){
			get_next_iframe();
			df.target='sbiframe'+next_iframe;
		}
		if (typeof this_button=='object'){
			this_button.disabled=true;
			this_button.value=disable_button_value;
			disable_button_chk=1;
		}
		df.submit();
		if (toiframe==1)
			f_popup_close();
	}
	else{
		display_errormsg(title,msg);
		if (typeof element_tofocus=='object')
			element_tofocus.focus();
		self.scrollTo(0,0);
		return false;
	}
}


last_element='';
function e_val(element_name,condition,error_msg){
	condition=condition.split(' ');
	dfe=eval('df.'+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=trim(dfe.value);
			dfev=dfev.length
			comparer=condition[2]*1;
		}
		else if (condition[0]=='num'){
			dfev=trim(dfe.value);
			dfev=numchk(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=numchk(eval('df.'+condition[2]+'.value'));
					if (isNaN(numchk(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=trim(dfe.value.toLowerCase());
			comparer=condition[2].toLowerCase();
		}
		else if (condition[0]=='si'){
			dfev=dfe.selectedIndex
			comparer=condition[2];
		}
		else if (condition[0]=='date'){
			dfev_a=dfe.value.split("-");
			dfe=eval('df.'+element_name+'_freetext')
			dfev_b=eval('df.'+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'){
		dfev=trim(dfe.value);
		dfev=numchk(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=numchk(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=trim(dfe.value);
		if (dfev!=''){
			write_msg=hex_chk(dfev);
		}
	}
	else if (condition[0]=='email'){
		if(typeof email_errors=='undefined'){			
			email_errors=new Array('Es ist keine Emailadresse eingegeben (min 6 Zeichen).','Die Emailadresse enth\344lt kein "@"','Vor dem "@" muss der Name der Emailadresse stehen.','Ein "@" darf nicht am Ende einer Emailadresse stehen.','Eine Emailadresse darf maximal ein "@" enthalten.','Die Emailadresse enthalt keinen ".".','Ein "." darf nicht am Anfang einer Emailadresse stehen.','Ein "." darf nicht am Ende einer Emailadresse stehen.','Eine Emailadresse darf kein @@wrong@@ enthalten.','Die Emailadresse enth\344lt ein ung\374ltiges Zeichen an Position:@@wrong@@.','Eine Emailadresse muss ein "." nach dem "@" enthalten.','Die Endung @@wrong@@ der Emailadresse ist keine g\374ltige "Top Level Domain".');
		}
		dfev=trim(dfe.value);
		wrong_chr='';
		if(typeof condition[1]=='undefined')// pass condition[1]=1 only if Email is required field
			condition[1]=0;
		if (condition[1]==1 || (condition[1]==0 && dfev!='')){
			error=email_chk(dfev);
			if (error>-1){
				error_msg+='<ul>'+email_errors[error].replace("@@wrong@@",wrong_chr)+'</ul>';
				write_msg=1;
			}
		}
	}
	else if (condition[0]=='url'){
		if(typeof url_errors=='undefined'){
			url_errors=new Array("Es ist keine URL eingegeben.","Eine URL muss mit http:// beginnen.","Eine URL muss mindestens 12 Zeichen lang sein.","Eine URL muss mindestens einen Punkt beinhalten.","Eine URL darf kein @@wrong@@ enthalten.");
		}
		dfev=trim(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){
		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){
	error=-1;
	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){	
			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'];
				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+'"';
				}
			}
		}
	}
	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;
}

// Calendar variables
date_delimiter='.'; // Dateformat:dmy, mdy, ymd'
date_format='dmy';
// MonthSTR_long = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
// MonthSTR_short = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
//MonthSTR_long = new Array ("Januar","Februar","M\344rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
//MonthSTR_short = new Array ("Jan","Feb","M\344rz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez");
//thisDateElement='';

/* Calendar  Script */
MonthSTR_long = new Array ("Januar","Februar","M\344rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");

function TCS_CreateDate(this_date){
	if(this_date.length < 6) {
		now = new Date();
	}
	else {
		this_date_array=this_date.split('-');
		if (this_date_array.length==3){
		splitYear = this_date_array[0];
		splitMonth =this_date_array[1];
		splitDay = this_date_array[2];
		if (splitYear.match(/^\d+$/) && splitMonth.match(/^\d+$/) && splitDay.match(/^\d+$/)) {
			y = parseInt(splitYear);
			m = parseInt(splitMonth)-1;
			d = parseInt(splitDay);
			now = new Date(y,m,d);
		}
		else
			now = new Date();
		}
		else
			now = new Date();
	}
	year = now.getFullYear();
	month = now.getMonth()+1;
	day = now.getDate();
	TCS_WriteCalendar(year,month,day);
}


function TCS_IsLeapYear(year){
	ly=0;
	if ((year % 4) == 0 && (year < 1582 || (year % 100) > 0 || (year % 400) == 0))
		ly=1;
	return ly;
	
}

function TCS_DaysInMonth(year,month) {
 	month--
	days_in_month=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	if (month==1 && TCS_IsLeapYear(year)){		
		days_in_month[1]=29;
	}		
	return days_in_month[month];
}

function TCS_DaysTotal(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 TCS_DayOfYear(year,month,day){
	total_days=day;
	for (i=1; i<month; i++) {
		total_days+=TCS_DaysInMonth(year,i);
	}
	return total_days;
}

function TCS_WeekOfYear(year,month,day){
	dayofyear=TCS_DayOfYear(year,month,day);
	td_0101=(TCS_DaysTotal(year,1,1) + 4) % 7;
	td_3112=(TCS_DaysTotal(year,12,31) + 4 ) % 7;
	td_0101_old=(TCS_DaysTotal(year-1,1,1) + 4 ) % 7;
	td_3112_old=(TCS_DaysTotal(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;
}

function TCS_ChangeMonth(year,month,day) {
	month++;
	TCS_WriteCalendar(year,month,day);
}
	
function TCS_ChangeCalendar(year_month,plus_minus,year,month,day) {
	if (year_month=='year')
		year=year+plus_minus;
	else if (year_month=='month'){
		month=month+plus_minus;
		if (month>12){
			month=1;
			year=year+1;
		}
		else if (month<1){
			month=12;
			year=year-1;
		}
	}
	TCS_WriteCalendar(year,month,day);
}

function TCS_WriteCalendar(year,month,day){
	html_str='<table cellspacing="1" border="0" id="wm_cal">';
	html_str+='<tr>'
	html_str+='<td class="wm_calweekday"><a href="javascript: TCS_ChangeCalendar(\'year\',-1,'+year+','+month+','+day+');">&lt;&lt;</a></td>';
	html_str+='<td class="wm_calweekday" colspan="6"><strong>'+year+'</strong></td>';
	html_str+='<td class="wm_calweekday"><a href="javascript: TCS_ChangeCalendar(\'year\',1,'+year+','+month+','+day+');">&gt;&gt;</a></td>';
	html_str+='</tr>';
	html_str+='<tr class="wm_calweekday">';
	html_str+='<td><a href="javascript: TCS_ChangeCalendar(\'month\',-1,'+year+','+month+','+day+');">&lt;&lt;</a></td>';
	html_str+='<td colspan="6"><select size="1" id="help_monthlist" name="help_monthlist" onChange="TCS_ChangeMonth('+year+',this.selectedIndex,'+day+');">'
	for(i = 0; i <= 11; i++){
		html_str+='<option value="'+i+'"'+((i==month-1)?' selected':'')+'>'+MonthSTR_long[i]+'</option>';
	}
	html_str+='</select></td>';	
	html_str+='<td><a href="javascript: TCS_ChangeCalendar(\'month\',1,'+year+','+month+','+day+');">&gt;&gt;</a></td>';
	html_str+='</tr>';
	
	html_str+='<tr class="wm_calweekheader">';
	html_str+='<td>KW</td>';
	html_str+='<td>MO</td>';
	html_str+='<td>DI</td>';
	html_str+='<td>MI</td>';
	html_str+='<td>DO</td>';
	html_str+='<td>FR</td>';
	html_str+='<td>SA</td>';
	html_str+='<td>SO</td>';
	html_str+='</tr>';

	this_day=1
	curCell=1
	days=TCS_DaysInMonth(year,month)
	firstDay=new Date(year,month-1,1).getDay();

	if(firstDay==0)
		firstDay=7;
	maxrow=Math.ceil((days + firstDay) / 7);
	//maxrow=parseInt((days + firstDay) / 7);
	
	for(var row = 1; row <= maxrow; ++row) {
		html_str+='<tr><td class="wm_calweekend">'+TCS_WeekOfYear(year,month,this_day)+'</td>';
		for(var col = 1; col <= 7; ++col) {
			if(this_day > days) break;
			if(curCell < firstDay) {
				html_str+="<td>&nbsp;</td>";
				curCell++;
			} else {
				css = (this_day == day)?"wm_calcurrentDay":((col > 5)?"wm_calweekend":"wm_calweekday");
				html_str+="<td><a href=\"javascript: cal_writeBack("+year+","+month+","+this_day+")\" class=" + css + ">" + this_day + "</a></td>";
				this_day++;
			}
	
		}
		html_str+="</tr>";
		if(this_day > days) break;
	}
	
	html_str+='<tr>';
	html_str+='<td colspan="4" align="left" class="wm_calweekend"><a href="javascript:TCS_CreateDate(\'_\')">Heute</a></td>';
	html_str+='<td colspan="4" align="right" class="wm_calweekend"><a href="javascript:context_hide();">Abbrechen</a></td>';
	html_str+='</tr>';
	html_str+="</table>";
	context_innerhtml(html_str);
}




function cal_GetValue(e,thiselement){
	thisDateElement=thiselement;
	this_date=document.getElementById(thiselement).value;
	TCS_CreateDate(this_date);
	context_show(e);
	
}

function cal_writeBack(thisyear,thismonth,thisday){
	//thismonth=parseInt(thismonth+1);
	newdate=thisyear+'-'+thismonth+'-'+thisday;
	//eval('document.f1.'+thisDateElement.id+'.value=newdate');
	document.getElementById(thisDateElement).value=newdate;
	if (date_format=='dmy')
		newdate=thisday+date_delimiter+thismonth+date_delimiter+thisyear;
	else if (date_format=='mdy')
		newdate=thismonth+date_delimiter+thisday+date_delimiter+thisyear;
	else if (date_format=='ymd')
		newdate=thisyear+date_delimiter+thismonth+date_delimiter+thisday;
	if (thisyear==1901 && thismonth==1 && thisday==1)
		document.getElementById(thisDateElement+'_freetext').value='---';
	else
		document.getElementById(thisDateElement+'_freetext').value=newdate;
	context_hide();
	
}
// DateField Script
function autodate(datename,datevalue){
	thisvalue=datevalue.split(date_delimiter);
	if (date_format=='dmy'){
		hiddendate=thisvalue[2]+'-'+thisvalue[1]+'-'+thisvalue[0];
	}
	else if (date_format=='mdy'){
		hiddendate=thisvalue[2]+'-'+thisvalue[0]+'-'+thisvalue[1];
	}
	else if (date_format=='ymd'){
		hiddendate=thisvalue[0]+'-'+thisvalue[1]+'-'+thisvalue[2];
	}
	datevar='<input type="hidden" name="'+datename+'" id="'+datename+'" value="'+hiddendate+'" />';
	if (hiddendate=='1901-01-01')
		datevalue='---';
	//datevar+='<span id="'+datename+'_div" style="font:normal 11px Verdana;cursor:hand;padding:2px;margin:0px 0px 2px 0px;background:#ffffff;border:#A5ACB2 1px solid; width:73px; height:14px;" onClick="cal_GetValue(event,\''+datename+'\')">'+datevalue+'</span>';
	datevar+='<input type="text" size="10" class="wm_text" style="cursor:hand;" name="'+datename+'_freetext" id="'+datename+'_freetext" value="'+datevalue+'" maxlength="10" onClick="this.blur();cal_GetValue(event,\''+datename+'\')"  onkeypress="return noenter(event)" />'
	//document.write(datevar);
	return datevar;
}


/* Image position map */
function imgpos(this_imgpos,fieldname){
	document.getElementById('imgpos_'+document.getElementById(fieldname).value).style.border='0px solid #FFD700';
	document.getElementById('imgpos_'+this_imgpos).style.border='2px solid #FFD700';
	document.getElementById(fieldname).value=this_imgpos;
}

function write_imgpos(this_imgpos,fieldname){
	str='<input type="hidden" name="'+fieldname+'" id="'+fieldname+'" value="'+this_imgpos+'" />';
	str+='<table cellpadding="0" cellspacing="0" style="background-image:url(http://img.webmart.de/w/newsimgpos.gif); background-repeat:no-repeat;"  border="0">';
	if (ns6){
		thiswidth=29;
		thisheight=25;
		td_spacer=5;
	}
	else if (opera){
		thiswidth=27;
		thisheight=27;
		td_spacer=3;
	}
	else{
		thiswidth=29;
		thisheight=21;
		td_spacer=5;
	}
		str+='<tr>';
		for (i=1; i<=4; i++){
			this_td_id=i;
			str+='<td id="imgpos_'+this_td_id+'" style="cursor:pointer;width:'+thiswidth+'px;height:'+thisheight+'px;" onclick="imgpos('+this_td_id+',\''+fieldname+'\');">&nbsp;</td>';
			if (i<4)
				str+='<td width="'+td_spacer+'"></td>';
		}
		str+='</tr>';
	str+='</table>';
	document.write(str);
	imgpos(this_imgpos,fieldname);
}


function colorpicker(element){
	url='system/colorpicker.htm?feld='+element+'&selected_color='+document.getElementById(element).value;
	this_width=280;
	this_height=560;
	NewWin=window.open(url,'ColorPicker','width='+this_width+',height='+this_height+',left='+Math.ceil(screen.width/2-this_width/2)+',top='+Math.ceil((screen.height-this_height)/2)+',scrollbars=0,resizable=1');
	NewWin.focus();
}

function noenter(event){
	keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	return !(keyCode == 13);
}

// function change color of box in side of pipette onblurr of textbox
function check_changecolor(colorfeld){
	selected_color=document.getElementById(colorfeld).value;
	//error=hex_chk(selected_color);
	if(hex_chk(selected_color)==0)
		document.getElementById('box_'+colorfeld).style.background = '#'+selected_color;
}

fieldtiptext='';
fieldtip='';
fieldtip_counter=0;
fieldtip_param='';

function sys_css(type,name,value,layout_type,label_value,more_info){
	option_value='';
	option_text='';
	delimiter=',';
	output='';
	if (type == 'color'){
		output+='<input type="text" class="wm_text" name="'+name+'" id="'+name+'" value="'+value+'" size="8" maxlength="6" onkeypress="return noenter(event)" onblur="check_changecolor(name)" />';
		output+='&nbsp;&nbsp;';
		output+='<img style="cursor:pointer;" align="absmiddle" src="'+imageserver+'pip.gif" ALT="Pipette" border="0" onclick="colorpicker(\''+name+'\');">';
		output+='&nbsp;&nbsp;';
		output+='<span id="box_'+name+'" name="box_'+name+'" style="border: 1px solid #938D73;position: absolute; width:18px; height:18px;background:#'+value+';">&nbsp;</span>';
	}
	else if (type == 'radio') {
		value=value.split("|");
		label_value=label_value.split("|");
		if (more_info == 'vertical')
			new_style=' style="clear:both;"';
		else
			new_style='';
		for(i=1; i<value.length ;i++){
			checked='';
			if(value[0]==value[i]) 
				checked=' checked="checked"';
			output+='<input type="radio" '+new_style+' class="wm_radio" name="'+name+'" id="'+name+value[i]+'" value="'+value[i]+'"'+checked+' />';
			if (label_value[0] != '')
				output+='<label class="wm_left" for="'+name+value[i]+'">&nbsp;'+label_value[i]+'</label>';
			if (more_info == 'vertical')
				output+='<div class="wm_clear"></div>';
		}
		label_value=label_value[0];
	}
	else if (type == 'checkbox') {
		value=value.split("|");
		label_value=label_value.split("|");
		name=name.split("|");
		more_info=more_info.split("|");
		if (more_info[1] == 'vertical')
			new_style=' style="clear:both;"';
		else
			new_style='';
		for(i=0; i<name.length;i++){
			input_val=value[i].split(",");
			checked='';
			if(input_val[0]==input_val[1]) {
				checked=' checked="checked"';
			}
			output+='<input type="checkbox" class="wm_checkbox"'+new_style+' name="'+name[i]+'" id="'+name[i]+'" value="'+input_val[1]+'"'+checked+' />';
			if (label_value[i]!=''){
				output+='<label class="wm_left" for="'+name[i]+'">&nbsp;'+label_value[i]+'</label>';
			}	
			if (more_info[1] == 'vertical'){
				output+='<div class="wm_clear"></div>';
			}
		}
		label_value=more_info[0]; // more_info[0] contains label value
	}
	else if (type == 'select') {
		value=value.split("|");
		label_value=label_value.split("|");
		if (typeof more_info=='undefined')
			more_info=1;
		output+='<select class="wm_select" name="'+name+'" id="'+name+'"';
		if (isNaN(more_info))
			output+=' style="width:'+more_info+'">';
		else
			output+=' size="'+more_info+'">';
		for(i=1; i<value.length ;i++){
			selected='';
			if(value[0]==value[i]) 
				selected=' selected="selected"';
			output+='<option value="'+value[i]+'"'+selected+' />'+label_value[i]+'</option>';
		}
		output+='</select>';
		label_value=label_value[0];		
	}
	else if (type == 'selectloop') {
		value=value.split("|");
		counter=1;
		label_value=label_value.split("|");
		if (typeof more_info=='undefined')
		more_info=1;
		output+='<select class="wm_select" name="'+name+'" id="'+name+'"';
		if (isNaN(more_info)==false) // if numeric then it is size
			output+=' size="'+more_info+'">';
		else { // if a extra option value is to be displayed above loop, more_info is passed as "|" separated values.
			more_info=more_info.split('|');
			selected='';		
			if (more_info.length==1 && more_info[0].indexOf('px') > -1)// if only width is specified in more_info
				output+=' style="width:'+more_info[0]+'"';
			// if width and option values are defined in more_info
			else if (more_info.length==3 && more_info[2].indexOf('px') > -1) 
				output+=' style="width:'+more_info[2]+';"';
			output+='>';	
			if (more_info.length >=2){
				if(value[0]==more_info[0])
					selected=' selected="selected"';
				output+='<option value="'+more_info[0]+'"'+selected+' />'+more_info[1]+'</option>';
			}	
		}
		for(i=value[1]*1; i<=value[2]*1 ;i=i*1+value[3]*1){
			selected='';
			if(value[0]==i)
				selected=' selected="selected"';
			output+='<option value="'+i+'"'+selected+' />'+label_value[1].replace("@@ev@@",i)+'</option>';
			counter=counter+1;
		}
		output+='</select>';
		label_value=label_value[0];
	}	
	else if (type.indexOf('size') > -1){
		to_chk='pt,px,em,%,pc,in,mm,cm,ex'
		to_chk=to_chk.split(',')
		this_value=value;
		for(i=0;i<to_chk.length;i++){
			if (this_value.indexOf(to_chk[i])>-1){
				this_value=this_value.replace(to_chk[i],'');
				value=to_chk[i];
				break;
			}
		}
		output+='<input class="" type="text" name="'+name+'" id="'+name+'" value="'+this_value+'" size="4" maxlength="4" onkeypress="return noenter(event)" />';
		output+='&nbsp;&nbsp;';
		if (type == 'fontsize'){
			option_value='px,pt,em';
			option_text=option_value;
		}
		else if (type == 'size'){
			option_value='px,%,em';
			option_text=option_value;
		}
		name=name+'_unit';
	}
	else if (type == 'align'){
		option_value='left,center,right';
		option_text='linksb\374ndig,zentriert,rechtsb&uuml;ndig';
	}
	else if (type == 'valign'){
		option_value='top,middle,bottom,baseline,sub,super,text-top,text-bottom';
		option_text='obenb\374ndig ausrichten,mittig ausrichten,untenb\374ndig ausrichten,an der Basislinie ausrichten (oder untenb\374ndig, wenn es keine Basislinie gibt),tieferstellen (ohne die Schriftgr\366ße zu reduzieren),h\366herstellen (ohne die Schriftgr\366ße zu reduzieren),am oberen Schriftrand ausrichten,am unteren Schriftrand ausrichten.';
	}
	else if (type == 'weight'){
		//option_value='unspecified,normal,bold,bolder,lighter,inherit';
		//option_text='unspecified,normal,bold,bolder,lighter,inherit';
		option_value='normal,bold';
		option_text='normal,fett';
	}
	else if (type == 'style'){
		//option_value='unspecified,normal,italic,oblique,inherit';
		//option_text='unspecified,normal,italic,oblique,inherit';
		option_value='normal,italic';
		option_text='normal,kursiv';
	}
	else if (type == 'style_weight'){
		option_value='normal normal,normal bold,italic normal,italic bold';
		option_text='normal,fett,kursiv,fett & kursiv';
	}
	else if (type == 'decoration'){
		option_value='none,underline,overline,line-through';
		option_text='none,underline,overline,linethrough';
	}
	else if (type == 'position'){
		option_value='top,center,middle,bottom,left,right';
		option_text='vertikal obenb\374ndig,horizontal zentriert,vertikal mittig,vertikal untenb\374ndig,horizontal linksb\374ndig,horizontal rechtsb\374ndig';
	}
	else if (type == 'repeat'){
		option_value='repeat,repeat-x,repeat-y,no-repeat';
		option_text='wiederholen (Voreinstellung),nur "eine Zeile lang" waagerecht wiederholen,nur "eine Spalte lang" senkrecht wiederholen,nicht wiederholen, nur als Einzelbild anzeigen';
	}
	else if (type == 'font'){
		option_value='Verdana,Arial,Geneva|Arial,Helvetiva,Geneva|Comic Sans MS,Sans Serif,Geneva|Times New Roman,Serif|Trebuchet MS,Verdana,Geneva';
		option_text=option_value;
		delimiter='|';
	}
	else if (type == 'text'){
		more_info=more_info.split('|');
		output+='<input class="wm_text" type="text" name="'+name+'" id="'+name+'" value="'+value+'" size="'+more_info[0]+'" maxlength="'+more_info[1]+'" onkeypress="return noenter(event)" />';
		if (more_info.length > 2) // if some text need to be written just after text box
			output+='&nbsp;'+more_info[2];
	}
	else if (type == 'password'){
		more_info=more_info.split('|');
		output+='<input class="wm_text" type="password" name="'+name+'" id="'+name+'" value="'+value+'" size="'+more_info[0]+'" maxlength="'+more_info[1]+'" onkeypress="return noenter(event)" />';
		if (more_info.length > 2) // if some text need to be written just after text box
			output+='&nbsp;'+more_info[2];
	}
	else if (type == 'file'){
		more_info=more_info.split('|');
		output+='<input class="wm_submit" type="file" name="'+name+'" id="'+name+'" size="'+more_info[0]+'" maxlength="'+more_info[1]+'" onkeypress="return noenter(event)" />';
	}
	else if (type == 'textarea'){
		more_info=more_info.split('|');
		output+='<textarea cols="'+more_info[0]+'" rows="'+more_info[1]+'" wrap="'+more_info[2]+'" name="'+name+'" id="'+name+'">'+value+'</textarea>'
	}
	else if (type == 'date'){
		output+=autodate(name,value)
	}
	else if (type == 'paragraph'){
		output+='<label class="wm_left">&nbsp;'+value+'</label>';
	}
	option_value=option_value.split(delimiter);
	option_text=option_text.split(delimiter);
	if (option_value.length>1){
		output+='<select name="'+name+'" id="'+name+'">';
		for (i=0;i<option_value.length;i++){
			output+='<option value="'+option_value[i]+'"';
			if (option_value[i]==value)
				output+=' selected';
			output+='>'+option_text[i]+'</option>';
			
		}
		output+='</select>';
	}
	// some time only input field are needed without container divs, so use another layout_type.
	if (layout_type!=0)
		sys_form(layout_type,name,label_value);
	document.write(output);
	if (layout_type!=0){
		if(fieldtiptext!='')
		   	sys_form_fieldtip(layout_type,fieldtiptext);
		sys_form_close(layout_type);
	}
	fieldtiptext='';
}

/* 	fieldtip_param are defined as 
	width, wm_sup, wm_left, wm_static, wm_sticky, wm_temp	
*/
function sys_form(layout_type,name,label_value){
	if (fieldtip != ''){
		fieldtip_counter++
		if (fieldtip_param=='')
			fieldtip_param='300';
		//fieldtip_param=fieldtip_param.split(',');
		//fieldtip_event=' style="cursor:pointer;" onmouseover="tt_Show(event,\'fieldtip_div'+fieldtip_counter+'\','+fieldtip_param[1]+','+fieldtip_param[2]+','+fieldtip_param[3]+','+fieldtip_param[4]+');" onmouseout="tt_Hide()"><img src="http://192.168.1.220/login/gif/wmques.gif" align="absmiddle">&nbsp;&nbsp;';
	fieldtip_event=' style="cursor:pointer;" onmouseover="context_innerhtml(document.getElementById(\'fieldtip_div'+fieldtip_counter+'\').innerHTML); context_show(event)" onmouseout="context_hide();"><img src="'+imageserver+'wmques.gif" align="absmiddle">&nbsp;&nbsp;'
	}
	else
		fieldtip_event='>';

	if (layout_type==1){
		document.write('<div class="wm_fieldbox" id="fieldbox_'+name+'">');
		document.write('<div class="wm_label">');
		document.write('<label for="'+name+'" id="label_'+name+'" '+fieldtip_event+label_value+'</label>');
		document.write('</div>');
		document.write('<div class="wm_field">');
	}
	else if (layout_type==2){
		document.write('<div class="wm_fieldbox" id="fieldbox_'+name+'">');
		document.write('<label for="'+name+'" id="label_'+name+'" class="wm_break"'+fieldtip_event+label_value+'</label>');
	}
}

function sys_form_close(layout_type){
	if (typeof layout_type=='undefined' || layout_type==1){
		document.write('</div></div>');
	}
	else if (layout_type==2){
		document.write('</div>');
	}
	
	if (fieldtip != ''){
		tipcontent=fieldtip.split("|");
		document.write('<div id="fieldtip_div'+fieldtip_counter+'" style="display:none; margin:0px; padding:0px; border:0px solid black;"><div class="wm_fieldsetinfo" style="width:'+fieldtip_param+'px; margin:0px; padding:3px;"><b>'+tipcontent[0]+':</b><br />'+tipcontent[1]+'</div></div>');
		fieldtip='';
		fieldtip_param='';
	}
}

function sys_form_fieldtip(layout_type,fieldtiptext){
	document.write('<div class="wm_fieldtip">'+fieldtiptext+'</div>');
}

// creates empty div, which is used to display client side checked errors in this div
function sys_error(popup){
	str='';
	if (popup==1)
		margin='0 5px 10px 5px;';
	else
		margin='0 0 10px 0;';
	str+='<fieldset id="wm_message" style="margin:'+margin+'display:none;"><legend><span style="color:red" id="wm_messagetitle"></span></legend><div style="float:left; width:100px;"><img src="'+imageserver+'warn.gif" width="60" hspace="8" vspace="8" height="54" /></div><div id="wm_messagetext" style="float:left; width:400px; padding:5px;"><ul id="wm_messagelist" style="margin:0 0 0 10px;line-height:1.5em;"></ul></div><div class="wm_clear"></div></fieldset><br class="wm_br01" />'
	document.write(str);
}
// function displays client side checked errors, in the top error box
function display_errormsg(title,msg){
	if (typeof title=='undefined')
		title='';
	if (typeof msg=='undefined')
		msg='';
	document.getElementById("wm_messagetitle").innerHTML=title;
	document.getElementById("wm_messagelist").innerHTML=msg;
	document.getElementById("wm_message").style.display="block";
}
// function display left menus in hauptauswahl in w.cfm file
function write_servicemenu(cmd){
	output='<ul id="wm_menu_service_ul">';

	output=output+'<li id="hauptauswahl"';
	if(cmd==1) 
		output=output+' class="wm_menu_service_active"'; 
	output=output+'><a href="w.cfm?app=1">Hauptauswahl</a></li>';

	output=output+'<li id="meinkonto"';
	if (cmd==188)
		output=output+' class="wm_menu_service_active"';
	output=output+'><a href="w.cfm?app=11&amp;cmd=188">Mein Konto</a></li>';
	
	output=output+'<li id="smscenter"';
	if (cmd==244 || cmd==245 || cmd==246 || cmd==251 || cmd==253) // all of these cmds belong to menu sms-center
		output=output+' class="wm_menu_service_active"';
	output=output+'><a href="w.cfm?app=15&amp;cmd=244">SMS-Center</a></li>';
	
	output=output+'<li id="directory"';
	if (cmd==670 || cmd==671 || cmd==672 || cmd==673 || cmd==674 || cmd==675) // all of these cmds belong to menu directory
		output=output+' class="wm_menu_service_active"';
	output=output+'><a href="w.cfm?app=31&amp;cmd=670">Verzeichnis</a> <img src="http:\/\/i.xeu.de\/w\/new.gif" width="28" height="11"></li>';
	
	output=output+'<li id="support"';
	if (cmd==268)
		output=output+' class="wm_menu_service_active"';
	output=output+'><a href="w.cfm?app=1&amp;cmd=268">Support</a></li>';

	output=output+'<li id="partner"';
	if (cmd==265)
		output=output+' class="wm_menu_service_active"';
	output=output+'><a href="w.cfm?app=1&amp;cmd=265">Partner</a></li>';

	output=output+'<li id="unternehmen"';
	if (cmd==266)
		output=output+' class="wm_menu_service_active"';
	output=output+'><a href="w.cfm?app=1&amp;cmd=266">Unternehmen</a></li>';
	
	output=output+'</ul>';
	document.write(output);	
}

// function for listing of tools in 1_welcome.cfm page
function write_tools(){
	output='<ul id="wm_menu_overview_ul"><li class="tcsred"><a href="w.cfm?app=6&cmd=68">Forum</a></li><li class="tcsblue"><a href="w.cfm?app=19&cmd=323">Newsletter</a></li><li class="tcsgreen"><a href="w.cfm?app=7&cmd=111">Shop / Basket</a></li><li class="tcsorange"><a href="w.cfm?app=16&cmd=276">Gästebuch</a></li><li class="tcsyellow"><a href="w.cfm?app=14&cmd=242">News-System</a></li><li class="tcsblue"><a href="w.cfm?cmd=660">Maps (Beta)<img src="'+imageserver+'new.gif" border="0" /></a></li><li class="tcsred"><a href="w.cfm?app=21&cmd=444">Event-Kalender</a></li><li class="tcsblue"><a href="w.cfm?app=20&cmd=367">Test-Generator</a></li><li class="tcsgreen"><a href="w.cfm?app=29&cmd=616">Form-Mail</a></li><li class="tcsorange"><a href="w.cfm?app=25&cmd=523">Call-Me</a></li><li class="tcsyellow"><a href="w.cfm?app=22&cmd=489">Vote / Umfrage</a></li><li class="tcsred"><a href="w.cfm?app=27&cmd=549">FAQ-System</a></li><li class="tcsblue"><a href="w.cfm?app=17&cmd=280">SMS-Newsletter</a></li><li class="tcsgreen"><a href="w.cfm?app=2&cmd=2">Tell-A-Friend</a></li><li class="tcsorange"><a href="w.cfm?app=26&cmd=540">Zitate</a></li><li class="tcsyellow"><a href="w.cfm?app=24&cmd=511">Ad-Server</a></li><li class="tcsred"><a href="w.cfm?app=28&cmd=612">Counter</a></li></ul><br />';
	document.write(output);
}

// function displays invitation box in w.cfm file
function write_invitationbox(){
	output='<div id="wm_menu"><div id="wm_menu_content"><ul id="wm_menu_service_ul"><li>'+
	   'Empfehlen Sie WebMart Ihren Freunden!'+
	   '<form method="post" action="w.cfm?cmd=613" target="InvPop"><br />'+
	   '<input type="text" size="18" name="InvEmail" value="Email-Adresse" onblur="if(this.value==\'\')this.value=\'Email-Adresse\';" onfocus="if(this.value==\'Email-Adresse\')this.value=\'\';"> '+
	   '<input type="submit" name="InvGo" value="Go" class="wm_submit" onClick="win_open(\'\',592,560,\'InvPop\')" />'+
	   '</form>'+
	   '</li></ul></div><img src="layout/sysimage/menu_bottom_round.png" alt="" style="vertical-align:top;border:0;padding:0;margin:0" />'+
	   '</div>';
	document.write(output);	
}

// function displays fac link box box in w.cfm file
function write_faq(faqid){
	output='<div id="wm_menu"><div id="wm_menu_content"><ul id="wm_menu_service_ul"><li>Noch Fragen?<br />Hier sind die Antworten<br /><a href="http://www.webmart.de/faq.cfm?faq='+faqid+'" target="_blank"><img src="http://i.xeu.de/w/wmfaq_ico.gif" style="border:0;margin-top:10px;"></a></li></ul></div><img src="layout/sysimage/menu_bottom_round.png" alt="" style="vertical-align:top;border:0;padding:0;margin:0" /></div>';
	document.write(output);	
}

// function displays know-how box in w.cfm file
function write_knowhow(knowhow){
	knowhow=knowhow.split('|');
	output='<div id="wm_menu"><div id="wm_menu_content" style="padding:5px 0 0 10px;">'+knowhow[1]+'</div><div id="wm_menu_content" style="text-align:center;"><a href="http://www.webmart.de/html/'+knowhow[0]+'" target="_blank"><img src="gif/wmkh_small.gif" style="margin:9px 0 0 0;border:0;"></a></div><img src="layout/sysimage/menu_bottom_round.png" style="vertical-align:top;border:1;padding:0;margin:0" /></div>';
	document.write(output);	
}
