function form_validation(){
	// create new guestbook
	if (url_cmd==19){
		e_val('gbname','len lt 1','Name darf nicht leer bleiben.');
		e_val('homepage','len lt 12','Homepage darf nicht leer bleiben.');
	}
	// delete a guestbook
	else if (url_cmd==18){
		e_val('confirm','notfindnocase LOESCHEN','Geben Sie in dieses Feld das Wort \'LOESCHEN\' ein.')
	}
	// save guestbook setting 
	else if (url_cmd==17){
		shown=0
		e_val('bookrealname','len lt 1','Name darf nicht leer bleiben.');
		e_val('homepage','len lt 12','Homepage darf nicht leer bleiben.');
		e_val('welcome','len gt 2000','Bitte k\374zen Sie Ihre Begr\374ssungsnachricht.');
	}
	// edit message pop up
	else if (url_cmd==22){
		e_val('message','len lt 1','Bitte geben Sie eine Nachricht an!');
		e_val('message','len gt 7000','Ihre Eingabe ist @@dfev@@ Zeichen lang.\nMaximal sind 7000 Zeichen erlaubt.\nBitte k\374rzen Sie Ihre Eingabe und wiederholen Sie den Vorgang!');
	}
	// write comment pop up
	else if (url_cmd==23){
		e_val('message','len gt 2000','Ihre Eingabe ist @@dfev@@ Zeichen lang.\nMaximal sind 2000 Zeichen erlaubt.\nBitte k\374rzen Sie Ihre Eingabe und wiederholen Sie den Vorgang!');
	}
	else if (url_cmd==35){
		e_val('fontcolor','ishexa','Schriftfarbe muss eine g\374ltige Hexadezimalzahl sein.');
		e_val('linkcolor','ishexa','Link-Farbe muss eine g\374ltige Hexadezimalzahl sein.');
		e_val('hovercolor','ishexa','Hover-Farbe muss eine g\374ltige Hexadezimalzahl sein.');
		e_val('bgcolor','ishexa','Hintergrundfarbe muss eine g\374ltige Hexadezimalzahl sein.');
	}
	else if (url_cmd==43){
		e_val('password','len lt 6','Neues Passwort muss zwischen 6 und 16 Zeichen lang sein.');
		e_val('password1','len lt 6','Das Feld \'Wiedeholen Passwort\' muss zwischen 6 und 16 Zeichen lang sein.');
		if (msg==''){
			if(df.password.value!=df.password1.value)
				msg='Die Passwörter stimmen nicht überein';
		}
	}
}
// browser check for inserting smilie function
if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.userAgent.indexOf("Opera") ==-1)
	ie=true;
else
	ie=false;
var isselected=false;
var toinsertObj='';

function markselection(thistextObj){
	if(ie){
		if (toinsertObj!=thistextObj)
			toinsertObj=thistextObj
		thisSelection=document.selection.createRange().duplicate();
		isselected = true;
	}
}

function inserttag(formname,tvs,tve){
	df=eval('document.'+formname);
	if (isselected) {
		selectionlength=thisSelection.text.length;
		thisSelection.text=tvs+thisSelection.text+tve;
		if (selectionlength==0)
			isselected=false;
		else
			markselection(toinsertObj)
	}
	else{
		var revisedmsg;
		var currentmsg=df.message.value;
		revisedmsg=currentmsg+tvs;
		df.message.value=revisedmsg;
		df.message.focus();
	}
}
// function for creating smilies
function write_icon(){
	str=''
	str+='<div class="gb_fieldbox" id="fieldbox_icon"><div class="gb_label"><label for="icon" id="label_icon">Quick Icons&nbsp;<input type="checkbox" name="quickikon" value="1" checked="checked">:</label></div><div class="gb_field"><table cellspacing="0" cellpadding="5"><tr><td><a href="javascript: inserttag(\'f1\',\' :) \',\'\');"><img src="'+imageserver+'1.gif" style="width:19px;height:19px;border:0" /></a>&nbsp;&nbsp;<a href="javascript: inserttag(\'f1\',\' :( \',\'\');"><img src="'+imageserver+'2.gif" style="width:19px;height:19px;border:0" /></a>&nbsp;&nbsp;<a href="javascript: inserttag(\'f1\',\' :o \',\'\');"><img src="'+imageserver+'12.gif" style="width:19px;height:19px;border:0" /></a>&nbsp;&nbsp;<a href="javascript: inserttag(\'f1\',\' :D \',\'\');"><img src="'+imageserver+'11.gif" style="width:19px;height:19px;border:0" /></a>&nbsp;&nbsp;<a href="javascript: inserttag(\'f1\',\' ;) \',\'\');"><img src="'+imageserver+'7.gif" style="width:19px;height:19px;border:0" /></a>&nbsp;&nbsp;<a href="javascript: inserttag(\'f1\',\' :mad: \',\'\');"><img src="'+imageserver+'4.gif" style="width:19px;height:19px;border:0" /></a></td></tr></table></div></div>';
	document.write(str);
}

function checkall(chk){
	for (var i=0;i < document.f1.elements.length;i++){
		var e=document.f1.elements[i];
		if (e.type=="checkbox")
			e.checked=chk.checked;
	}
}

function chk_submit(){
	df=document.f1;
	ischecked=0
	for(i=1;i<df.itemid.length;i++){
		if (df.itemid[i].checked==true){
			ischecked=1
			break;
		}
	}
	if (ischecked==0)
		alert('Bitte w\344hlen Sie einen Eintrag!');
	else{
		if(df.act[df.act.selectedIndex].value=='delmsg'){
			if (confirm('Soll dieser Eintrag wirklich gel\366scht werden?')==true){
				df.action=df.action+'&cmd=25';
				df.submit();
			}
		}
		else if (df.act[df.act.selectedIndex].value=='publish'){
				df.action=df.action+'&cmd=26';
				df.submit();
		}
	}
}

function set_expert(obj){
	ischecked=document.getElementById('beginnermode').checked;
	if (ischecked==true)
		txt='Soll Ihr Profil wirklich in den Experten-Modus gesetzt werden?';
	else
		txt='Soll Ihr Profil wirklich in den Beginner-Modus gesetzt werden?';
	ok=confirm(txt);
	if (ok==1){
		document.getElementById('f10').submit();
	}
	else {
		if(ischecked==true)
			document.getElementById('beginnermode').checked=false;
		else
			document.getElementById('beginnermode').checked=true;
	}

}

// used für ipblock
function deleteip(){
	df=document.f1;
	if(df.tounblock.selectedIndex!=-1){
		var agree=confirm("IP Adresse wirklich loeschen?");
		if (agree)
			df.submit();
		else
			return false;
	}
	else 
		return false;
}

function change_Layout(layout){
	if (layout==1){
		layout_style='.wmhrbox{height: 5px;}hr.wmhr{display:none;}';
		layout_style+='.wmtitle{padding-top:110px;padding-bottom:10px;background: url('+imageserver+'@LA@_sh_1.gif) no-repeat left top;}';
		layout_style+='.wmwelcome{padding-top:10px;padding-bottom:10px;}';
		layout_style+='.wmsites{float:left;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmsitestop{}';
		layout_style+='.wmsitesbottom{}';
		layout_style+='.wmnewentry{float:right;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmclear{clear:both}';
		layout_style+='.wmentrybox{margin:5px 0 5px 0;border:1px solid #cccccc;padding:10px;}';
		layout_style+='.wmdate{background: url('+imageserver+'1_arrow_1.gif) no-repeat left top;text-indent:30px;margin-bottom:10px;}';
		layout_style+='.wmentry{overflow:hidden}';
		layout_style+='.wmcomment{margin-top:20px;}';
		layout_style+='.wmip{}';
	}
	else if (layout==2){
		layout_style='.wmhrbox{height: 5px;}hr.wmhr{display:none;}';
		layout_style+='.wmtitle{padding-top:140px;padding-bottom:10px;background: url('+imageserver+'@LA@_sh_2.jpg) no-repeat left top;}';
		layout_style+='.wmwelcome{padding-top:10px;padding-bottom:10px;}';
		layout_style+='.wmsites{float:left;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmsitestop{}';
		layout_style+='.wmsitesbottom{}';
		layout_style+='.wmnewentry{float:right;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmclear{clear:both}';
		layout_style+='.wmentrybox{margin:5px 0 5px 0;border:3px solid #776F65;padding:10px;background:url('+imageserver+'1_clanbg_2.gif) repeat}';
		layout_style+='.wmdate{margin-bottom:5px;}';
		layout_style+='.wmentry{overflow:hidden}';
		layout_style+='.wmcomment{margin-top:20px;}';
		layout_style+='.wmip{}';
	}
	else if (layout==3){
		layout_style='td.wmmain {background-color:#ffffff;padding:10px;}';
		layout_style+='.wmhrbox{height: 5px;}';
		layout_style+='hr.wmhr{display:none;}';
		layout_style+='.wmtitle{padding-top:140px;padding-bottom:10px;background: url('+imageserver+'@LA@_sh_3.jpg) no-repeat left top;}';
		layout_style+='.wmwelcome{padding-top:10px;padding-bottom:10px;}';
		layout_style+='.wmsites{float:left;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmsitestop{}';
		layout_style+='.wmsitesbottom{}';
		layout_style+='.wmnewentry{float:right;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmclear{clear:both}';
		layout_style+='.wmentrybox{margin:5px 0 5px 0;border:3px solid #F5F5EE;padding:10px;background-color:#F5F5EE}';
		layout_style+='.wmdate{margin-bottom:5px;}';
		layout_style+='.wmentry{overflow:hidden}';
		layout_style+='.wmcomment{margin-top:20px;}';
		layout_style+='.wmip{}';
	}
	else if (layout==4){
		layout_style='body.wmbody {background-image:url('+imageserver+'1_bodybg_family_4.gif);background-repeat:repeat-y;background-position:top center;}';
		layout_style+='.wmhrbox{background:url('+imageserver+'1_trenner_4.gif) repeat-x;height:23px}';
		layout_style+='hr.wmhr{display:none;}';
		layout_style+='.wmtitle{padding-top:140px;padding-bottom:10px;background: url('+imageserver+'@LA@_sh_4.gif) no-repeat left top;}';
		layout_style+='.wmwelcome{padding-top:10px;padding-bottom:10px;}';
		layout_style+='.wmsites{float:left;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmsitestop{}';
		layout_style+='.wmsitesbottom{}';
		layout_style+='.wmnewentry{float:right;margin-top:20px;margin-bottom:20px;}';
		layout_style+='.wmclear{clear:both}';
		layout_style+='.wmentrybox{margin:20px 0 20px 0;}';
		layout_style+='.wmdate{margin-bottom:5px;}';
		layout_style+='.wmentry{overflow:hidden}';
		layout_style+='.wmcomment{margin-top:20px;}';
		layout_style+='.wmip{}';
	}
	document.getElementById('layout').value=layout;
	document.getElementById('extrastylesheet').value=layout_style;
	set_border(layout);
}

function set_border(layout){
	for (i=1;i<=4;i++){
		if (i==layout)
			document.getElementById('layout_'+i).border=1;
		else
			document.getElementById('layout_'+i).border=0;
	}
}

function layout_save(fname){
	df=document.f1;
	ok=confirm('Soll dieses Layout wirklich gespeichert werden? Dadurch werden folgende Design-Einstellungen überschrieben:\n1. Hintergrundfarbe.\n2. Schriftfarbe.\n3. Link-Farbe.\n4. Hover-Farbe.\n5. Hintergrundbild.')
	if (ok)
		df.submit();
	else
		return false;
}


function preview_layout(url){
	lay=document.getElementById('layout').value
	url=url+'&lay='+lay;
	loader(url,2,1300,900);	
}

function show_help(nr){
	html_txt='';
	if(nr==1)
		html_txt='Wenn Sie den Forum-Code deaktivieren, sind keine erweiterten Formatierungen, Bilder etc. in Ihrem G\344stebuch m\366glich.';
	else if (nr==2)
		html_txt='In einem moderierten G\344stebuch erscheinen neue Eintr\344ge erst, wenn Sie diese freigeben. Die Freigabe von Beitr\344gen erfolgt unter dem Men\374punkt "Moderation".';
	else if (nr==3)
		html_txt='Zeigt auf der ersten G\344stebuch Seite die heutigen Aufrufe und Gesamtaufrufe an.';
	else if (nr==4)
		html_txt='Zeigt IP-Adresse einzelner Eintr\344ge auch im Frontend bei den Eintr\344gen an.';
	else if (nr==5)
		html_txt='Wählen Sie Nein, um das Feld Website zu deaktivieren. Es werden auch keine Website Links angezeigt.';
	else if (nr==6)
		html_txt='Wählen Sie Nein, um das Feld Email zu deaktivieren. Es werden auch keine Email Links angezeigt.';
	else if (nr==7)
		html_txt='Wählen Sie Nein, wenn Sie keine klickbaren Links in Ihren Beiträgen wünschen. Dies verhindert Werbung externer Webseiten in Ihrem Gästebuch.';
	else if (nr==8)
		html_txt='Wählen Sie Nein, wenn Sie keine externen Bilder in Ihren Beiträgen wünschen. Achtung: Dadurch werden auch keine Emoticons angezeigt.';		
	document.getElementById('help_code').innerHTML=html_txt;	
}

function show_div(id){
	document.getElementById(id).style.display='block';
}

function check_available(url){
	objvalue=trim(document.getElementById('email').value);
	error=email_chk(objvalue)
	if (error>-1)
		alert('Bitte geben Sie richtige Emailadresse ein!')
	else{
		url=url+'&email='+objvalue;		
		loader(url,2,650,400);
	}
}


function take_email(){
	opener.document.getElementById('email').value=document.getElementById('email').value;
	opener.focus();
	self.close();
}
