/* Replacement for German characters in javascript
	Chr	Replacement
	ä	\344
	ö	\366
	ü	\374
	Ä	\304
	Ö	\326 
	Ü	\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://www.guestbook24.eu/i/';



/* 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="gb_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="gb_register_active";
	if (typeof error_show=='undefined' && document.getElementById("gb_message")!=null)// "showhide" passed when a page having more register tabs is loaded
		document.getElementById("gb_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="gb_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="gb_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="gb_button">';
		
	if (cancel_val != '0' && cancel_val != ''){
		strg+='<input class="gb_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="gb_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="gb_submit" type="button" value="'+cancel_val+'" onclick="f_action(\'close\');"  />';
		strg+='&nbsp;&nbsp;';
	}
	if (save_cancel_val!=''){
		strg+='<input class="gb_submit" type="button" value="'+save_cancel_val+'" onclick="f_action(\'saveclose\',this);" />';
		strg+='&nbsp;&nbsp;';
	}
	if (cancel_val!=''){
		strg+='<input class="gb_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;
}


function colorpicker(element){
	url='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="gb_text" name="'+name+'" id="'+name+'" value="'+value+'" size="8" maxlength="6" onkeypress="return noenter(event)" onblur="check_changecolor(name)" />';
		output+='&nbsp;&nbsp;';
		output+='<span onclick="colorpicker(\''+name+'\');" id="box_'+name+'" name="box_'+name+'" style="cursor:pointer;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="gb_radio" name="'+name+'" id="'+name+value[i]+'" value="'+value[i]+'"'+checked+' />';
			if (label_value[0] != '')
				output+='<label class="gb_left" for="'+name+value[i]+'">&nbsp;'+label_value[i]+'</label>';
			if (more_info == 'vertical')
				output+='<div class="gb_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="gb_checkbox"'+new_style+' name="'+name[i]+'" id="'+name[i]+'" value="'+input_val[1]+'"'+checked+' />';
			if (label_value[i]!=''){
				output+='<label class="gb_left" for="'+name[i]+'">&nbsp;'+label_value[i]+'</label>';
			}	
			if (more_info[1] == 'vertical'){
				output+='<div class="gb_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="gb_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="gb_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="gb_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="gb_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="gb_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="gb_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, gb_sup, gb_left, gb_static, gb_sticky, gb_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="gb_fieldbox" id="fieldbox_'+name+'">');
		document.write('<div class="gb_label">');
		document.write('<label for="'+name+'" id="label_'+name+'" '+fieldtip_event+label_value+'</label>');
		document.write('</div>');
		document.write('<div class="gb_field">');
	}
	else if (layout_type==2){
		document.write('<div class="gb_fieldbox" id="fieldbox_'+name+'">');
		document.write('<label for="'+name+'" id="label_'+name+'" class="gb_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="gb_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="gb_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 160px;';
	str+='<div id="gb_message" style="margin:'+margin+'display:none;"><ul id="gb_messagelist" style="margin:0 0 0 10px;line-height:1.5em;"></ul></div>'
	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("gb_messagetitle").innerHTML=title;
	document.getElementById("gb_messagelist").innerHTML=msg;
	document.getElementById("gb_message").style.display="block";
}

// function displays invitation box in w.cfm file
function write_invitationbox(){
	output='<div id="gb_menu"><div id="gb_menu_content"><ul id="gb_menu_service_ul"><li>'+
	   'Empfehlen Sie Guestbook24.eu 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="gb_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 faq link box box in w.cfm file
function write_faq(faqid){
	output='<div id="gb_menu"><div id="gb_menu_content"><ul id="gb_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="'+imageserver+'gbfaq_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="gb_menu"><div id="gb_menu_content" style="padding:5px 0 0 10px;">'+knowhow[1]+'</div><div id="gb_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);	
}
