function checksubmit(w,p)

{
var a=true;
if(p=='w'){
objp=document.getElementById("neuertext");
if(objp.value==''){document.getElementById("tdtitel").style.color="red"; a=false;}	
}
obj=document.getElementById("neuertext");
if(obj.value==''){document.getElementById("tdeintrag").style.color="red"; a=false;}

if(a==true){
if( w==1){
document.getElementById("send").submit();
document.getElementById("send").action="flirttips.php";
}
else if(w==0){ var vor=window.open("", "vorschau", "width=800, height=540, location=no, menubar=no, status=no,dependent=yes, toolbar=no, scrollbars=yes, resizable=yes");  
document.getElementById("send").target="vorschau";
document.getElementById("send").action="flirttipsvorschau.php";
document.getElementById("send").submit();
}
else{return true;}}
else{if(w==2){return false;}
}
}


function remove(){
var tb=document.getElementById("tbl");
tb.parentNode.removeChild(tb);
	
	}
 
function showedit(x)

{
	
if(x=='p'){var e='&e=cvkmdlfkvmaw320_';}
else if(x=='w'){var e='?&e=cvkmdlfkvmaw320_';}
else{var e='?&e=1';}
	
if(! document.getElementById("send")){
var url=window.location.href+e;
var tb=document.getElementById("td"+x);
var titel=document.getElementById("f"+x).innerHTML;
var text=new String();
if(x!='p' && x !='w')text=document.getElementById("ts"+x).innerHTML;


var td=document.createElement("TABLE");
tb.appendChild(td);
tb.lastChild.setAttribute("id","tbl");
tb.lastChild.style.width="100%";
var td=document.createElement("TBODY");
tb.lastChild.appendChild(td);

tb=tb.lastChild.lastChild;


if(x=='p' || x=='w'){
	
var td=document.createElement("TR");
tb.appendChild(td);
var td=document.createElement("TD");
tb.lastChild.appendChild(td);
tb.lastChild.lastChild.setAttribute("colSpan","3");
tb.lastChild.lastChild.style.fontWeight="bold";
if(x=='p')
td=document.createTextNode("neuer Kommentar");
else
td=document.createTextNode("neuer Beitrag");

tb.lastChild.lastChild.appendChild(td);

}
var td=document.createElement("TR");
tb.appendChild(td);
var td=document.createElement("TD");
tb.lastChild.appendChild(td);
tb.lastChild.lastChild.setAttribute("colSpan","3");
tb.lastChild.lastChild.setAttribute("id","tdtitel");
	
	
var td=document.createElement("FORM");
tb.lastChild.lastChild.appendChild(td);

var frm=tb.lastChild.lastChild.lastChild;
frm.action=url;
frm.setAttribute("name","send");
frm.setAttribute("id","send");
frm.setAttribute("method","post");
frm.setAttribute("onsubmit","javascript:return checksubmit(2,'"+x+"')");

td=document.createTextNode("Titel");
frm.appendChild(td);

td=document.createElement("BR");
frm.appendChild(td);

td=document.createElement("INPUT");
frm.appendChild(td);

frm.lastChild.setAttribute("MaxLength","50");
frm.lastChild.setAttribute("size","50");
frm.lastChild.setAttribute("value",titel);
frm.lastChild.setAttribute("size","50");
frm.lastChild.setAttribute("name","neuertitel");

td=document.createElement("BR");
frm.appendChild(td);
td=document.createElement("FONT");
frm.appendChild(td);

frm.lastChild.setAttribute("id","tdeintrag");

td=document.createTextNode("Eintrag");
frm.lastChild.appendChild(td);

td=document.createElement("BR");
frm.appendChild(td);

td =document.createElement("TEXTAREA");
frm.appendChild(td);
frm.lastChild.setAttribute("cols","50")
frm.lastChild.setAttribute("rows","10")
frm.lastChild.setAttribute("name","neuertext")
frm.lastChild.setAttribute("id","neuertext")
frm.lastChild.value=text;

td=document.createElement("TR");
tb.appendChild(td);

td=document.createElement("TR");
tb.appendChild(td);

var td=document.createElement("TD");

tb.lastChild.appendChild(td);
tb.lastChild.lastChild.setAttribute("align","right");
td =document.createElement("A");
tb.lastChild.lastChild.appendChild(td);
obj=tb.lastChild.lastChild.lastChild;
obj.setAttribute("className","button singlebutton");
obj.setAttribute("href","javascript:remove()");
obj.setAttribute("target","_self");
td =document.createElement("SPAN");
obj.appendChild(td);
obj.lastChild.innerHTML="schliessen";

var td=document.createElement("TD");
tb.lastChild.appendChild(td);
tb.lastChild.lastChild.setAttribute("align","center");
td =document.createElement("A");
tb.lastChild.lastChild.appendChild(td);
obj=tb.lastChild.lastChild.lastChild;
obj.setAttribute("className","button singlebutton");
obj.setAttribute("href","javascript:checksubmit(1,'"+x+"')");
obj.setAttribute("target","_self");
td =document.createElement("SPAN");
obj.appendChild(td);
obj.lastChild.innerHTML="speichern";

var td=document.createElement("TD");

tb.lastChild.appendChild(td);
tb.lastChild.lastChild.setAttribute("align","left");
//td =document.createElement("A");
//tb.lastChild.lastChild.appendChild(td);
//obj=tb.lastChild.lastChild.lastChild;

//obj.setAttribute("href","javascript:checksubmit(0,'"+x+"')");
//obj.setAttribute("target","_self");
//td =document.createElement("SPAN");
//obj.appendChild(td);
//obj.lastChild.innerHTML="Vorschau";
//obj.lastChild.setAttribute("className","butt");
//obj.lastChild.setAttribute("class","butt");

if(x=='p' || x=='w'){
	td=document.createElement("TR");
tb.appendChild(td);
	var td=document.createElement("TD");
tb.lastChild.appendChild(td);
tb.lastChild.lastChild.setAttribute("colSpan","3");
	var td=document.createElement("HR");
tb.lastChild.lastChild.appendChild(td);
tb.lastChild.lastChild.lastChild.style.width="100%";

if(x=='w'){window.scrollTo(0,10000);}
	
}}}
