// VARIABLEN
fonts = new Array("Arial","Comic Sans MS","Times New Roman","Verdana");
fontss = new Array("8pt","10pt","12pt","14pt","16pt");
linkfg = new Array("privat (keine)","öffentlich (einbinden)","öffentlich (kopieren)","öffentlich (einbinden & kopieren)");


// VARIABLEN ENDE

/*
function create_element_ausconf(elem){
  //  neue ID erzeugen
  new Ajax.Request(relpath+"inc/php/ajaxodb.php",{method: 'post',parameters:{aktion:'create_eid',nutzer:nutzer},onComplete: set_eid});

  // Element in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method: 'post',parameters:{aktion:'ins_elem',nutzer:nutzer,typ:elem,eid:eid,sid:sid}});

}
*/

function create_element(elem){
  
  show_load();
  
  //  neue ID erzeugen
  new Ajax.Request(relpath+"inc/php/ajaxodb.php",{method: 'post',parameters:{aktion:'create_eid',nutzer:nutzer},onComplete: set_eid});

  // Textbox erzeugen
  if (elem=='text'){
    create_text_box_fromdb(eid,"c_td1",1,escape('Neuer Text (zum Ändern doppelklicken)'));
  }else{
  // Andere Elemente erzeugen
    create_element_fromdb(elem,eid,"c_td1",1,nutzer,0);
  }
  
  //Variablen initial setzen
  /* PARAMS:
      (linkbox,textbox,bildbox)
   0  bg_color
   1  border_color
   2  titel
   3  titel_font_color
   4  titel_bg_color
   5-textbox : schriftfarbe
   5-linkbox : freigabe
   6-textbox : schrifgroesse
   7-textbox : schriftart
  */

  params = new Array();

  params.push('default');
  params.push('#d3d3d3');
  
  if(elem=='text'){
    params.push('Deine Textbox');
    params.push('#000000');
    params.push('default');
    params.push('#333333');
    params.push('10pt');
    params.push('Arial');
  }
  if(elem=='bild'){
    params.push('Deine Bildbox');
    params.push('#000000');
    params.push('default');
  }
  if(elem=='link'){
    params.push('Deine Linkbox');
    params.push('#000000');
    params.push('default');
    params.push('privat (keine)');
  }

  set_box_values(eid,params,1,elem); 

  // Element in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method: 'post',parameters:{aktion:'ins_elem',nutzer:nutzer,typ:elem,eid:eid,sid:sid}, onSuccess: function(reponse) {eval(reponse.responseText);}  });
}

function create_text_box_fromdb(id,spalte,eh,ntext){
    neu_element = create_text_box(id,ntext,eh);

    //damit ueberlanger text abgeschnitten wird - alt
    neu_element.childNodes[1].childNodes[0].style.width = document.getElementById("c_td1").offsetWidth-30+"px";

    document.getElementById(spalte).appendChild(neu_element);
    //eventhandler fuer das neu eingehaengte div setzen
    if(eh==1){
      init_element(id);
    }
}

function create_element_fromdb(elem,id,spalte,eh,lo,inc){

  if (elem == 'link'){
    neu_element = create_link_box(id,eh,lo,inc); 
    document.getElementById(spalte).appendChild(neu_element);
    //eventhandler fuer das neu eingehaengte div setzen
    if(eh==1||eh==3){
      init_element(id);
    }else if(eh==2&&inc!=0){{
      document.getElementById(id+"_mbtn").onclick = show_inc_mn;
    }}
  }

  if (elem == 'bild'){
    neu_element = create_bild_box(id,eh); 
    document.getElementById(spalte).appendChild(neu_element);
    //eventhandler fuer das neu eingehaengte div setzen
    if(eh==1){
      init_element(id);
    }
  }

  fill_height_array()
}

//////////////////////////////////////////////////////////////////////////////////////////
//    
//    LINKBOXEN
//
//////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////
// Neue Leere Linkbox erstellen - Übergabe name der BOX
//////////////////////////////////////////////////////////////////////////////////////////

function create_link_box(eid,eh,lo,inc){

  //rahmen
  new_lbox = document.createElement("div");
  new_lbox.setAttribute("className","content_container");
  new_lbox.setAttribute("class","content_container");
  new_lbox.setAttribute("id",eid);
  
  //header
  new_header = document.createElement("div");
  new_header.setAttribute("className","header");
  new_header.setAttribute("class","header");
  new_header.setAttribute("id",eid+"_header");

    new_header_c3 = document.createElement("div");
    new_header_c3.setAttribute("className","title");
    new_header_c3.setAttribute("class","title");
    new_header_c3.setAttribute("id",eid+"_title");
    new_header_c3.appendChild(document.createTextNode("Titel"));
  new_header.appendChild(new_header_c3);


  // nur wenn besitzer der box oder gast und box zum einbinden freigegeben ist
  if((eh==1||eh==3)||(eh==2&&inc!=0)){
    new_header_c4 = document.createElement("div");
    new_header_c4.setAttribute("className","ctrl");
    new_header_c4.setAttribute("class","ctrl");
    new_header_c4.setAttribute("id",eid+"_mbtn");

      mnbtn_img = document.createElement("img");
      mnbtn_img.setAttribute("src",relpath+"inc/gfx/mnbtn.jpg");
      mnbtn_img.setAttribute("alt","Box Menue");
      mnbtn_img.setAttribute("title","Box Menue");
      mnbtn_img.setAttribute("border","0");
      mnbtn_img.setAttribute("width","13");
      mnbtn_img.setAttribute("height","12");
      mnbtn_img.setAttribute("id",eid+"_pic");

    new_header_c4.appendChild(mnbtn_img);
  new_header.appendChild(new_header_c4);
  }

    new_header_c5 = document.createElement("div");
    new_header_c5.setAttribute("className","dragger");
    new_header_c5.setAttribute("class","dragger");
    new_header_c5.setAttribute("id",eid+"_dragger");
  new_header.appendChild(new_header_c5);

  if(eh==1||eh==3){
    new_header.appendChild(create_link_menue(eid,eh));
  }else{
    if(eh==2&&inc!=0){
    new_header.appendChild(create_inc_menue(eid,inc));
    }
  }
  //content
  new_content = document.createElement("div");
  new_content.setAttribute("className","link_div");
  new_content.setAttribute("class","link_div");
  new_content.setAttribute("id",eid+"_content");

    new_content_c1 = document.createElement("div");
    new_content_c1.setAttribute("className","addlinkbtn");
    new_content_c1.setAttribute("class","addlinkbtn");
  if(eh==1){
    new_content_c1.setAttribute("id",eid+"_addl");
    new_content_c1.onclick=add_link;
    new_content_c1.appendChild(document.createTextNode("neues Lesezeichen erstellen"));
  }else{
    if(eh==3){
      new_content_c1.appendChild(document.createTextNode("Diese Linkbox wird gepflegt von: "+lo));
    }
  }

  new_content.appendChild(new_content_c1);
    
  new_lbox.appendChild(new_header);
  new_lbox.appendChild(new_content);

  return new_lbox;
}

//////////////////////////////////////////////////////////////////////////////////////////
// Neue Bookmark innerhalb einer Linkbox erstellen Übergabe ID der Linksbox Nr des Links
//////////////////////////////////////////////////////////////////////////////////////////

function create_new_bookmark(eid,pid,tit,des,url,eh){

  //rahmen
  new_book = document.createElement("div");
  new_book.setAttribute("className","bookmark");
  new_book.setAttribute("class","bookmark");
  new_book.setAttribute("id",eid);

  //titel
  new_book_title = document.createElement("div");
  new_book_title.setAttribute("className","ltle");
  new_book_title.setAttribute("class","ltle");
  new_book_title.setAttribute("id",eid+"_title");

    new_book_title_link = document.createElement("a");
    new_book_title_link.setAttribute("id",eid+"_alink");
    new_book_title_link.setAttribute("target","_blank");
    new_book_title_link.setAttribute("href",checkurl(url));
    new_book_title_link.appendChild(document.createTextNode(tit));

    new_book_move_btn = document.createElement("div");
    new_book_move_btn.setAttribute("className","bmbtn");
    new_book_move_btn.setAttribute("class","bmbtn");
    new_book_move_btn.setAttribute("id",eid+"_bmbtn");

    new_book_drg = document.createElement("div");
    new_book_drg.setAttribute("className","bmdragger");
    new_book_drg.setAttribute("class","bmdragger");
    new_book_drg.setAttribute("id",eid+"_bmdragger");

  if(eh=='1'){
    new_book_drg.onmousedown = mdown_bm;
  } 

      new_book_move_btn_img = document.createElement("img");
      favurl = makefavicon (url);
//      new_book_move_btn_img.setAttribute("src",relpath+"inc/gfx/star.png");
      new_book_move_btn_img.setAttribute("src",favurl);
      new_book_move_btn_img.setAttribute("border","0");
      new_book_move_btn_img.setAttribute("height","16");
      new_book_move_btn_img.setAttribute("width","16");
      new_book_move_btn_img.setAttribute("id",eid+"_mopic");
  
    new_book_move_btn.appendChild(new_book_move_btn_img);

  //wenn boxbesitzer dann den linkmenue button einblenden
  if(eh=='1'){

    new_book_title_mnbtn = document.createElement("div");
    new_book_title_mnbtn.setAttribute("className","lmnbtn");
    new_book_title_mnbtn.setAttribute("class","lmnbtn");
    new_book_title_mnbtn.setAttribute("id",eid+"_mbtn");

    new_book_title_mnbtn.onclick = toggle_book_menue;
      new_book_title_mnbtn_img = document.createElement("img");
      new_book_title_mnbtn_img.setAttribute("src",relpath+"inc/gfx/mnbtn.jpg");
      new_book_title_mnbtn_img.setAttribute("alt","Link Menue");
      new_book_title_mnbtn_img.setAttribute("title","Link Menue");
      new_book_title_mnbtn_img.setAttribute("border","0");
      new_book_title_mnbtn_img.setAttribute("width","13");
      new_book_title_mnbtn_img.setAttribute("height","12");
      new_book_title_mnbtn_img.setAttribute("id",eid+"_pic");

    new_book_title_mnbtn.appendChild(new_book_title_mnbtn_img);
  }    

  new_book_title.appendChild(new_book_title_link);
  new_book_title.appendChild(new_book_drg);
  new_book_title.appendChild(new_book_move_btn);

  if(eh=='1'){  
    new_book_title.appendChild(new_book_title_mnbtn);
  }
    
  //beschreibung
  new_book_desc = document.createElement("div");
  new_book_desc.setAttribute("className","ldes");
  new_book_desc.setAttribute("class","ldes");
  new_book_desc.setAttribute("id",eid+"_desc");
  new_book_desc.appendChild(document.createTextNode(des));
  

  new_book.appendChild(new_book_title);
  new_book.appendChild(new_book_desc);

  if(eh=='1'){  
    //bookmarkmenue
    new_book_menue = create_book_menue(eid,tit,des,url);
    new_book.appendChild(new_book_menue);
  }
  
  return new_book;
}

//////////////////////////////////////////////////////////////////////////////////////////
// FUNKTIONEN ZUM ERSTELLEN DER MENUES
//////////////////////////////////////////////////////////////////////////////////////////


function create_menue_input(name,eid,id,defval,typ){
  
  typ = typ||'col';

  // farbwahlfelder

    new_lmn_tr = document.createElement("tr");
    new_lmn_tr.setAttribute("valign","middle");
    new_lmn_tr.appendChild(document.createElement("td"));
    new_lmn_tr.appendChild(document.createElement("td"));
    new_lmn_tr.childNodes[0].appendChild(document.createTextNode(name));

  if(typ=="col"){  
    cpdiv = document.createElement("div");
    cpdiv.setAttribute("id",eid+"_"+id);
    cpdiv.style.width = "50px";
    cpdiv.style.height = "13px";
    cpdiv.style.border = "1px solid #d3d3d3";
    
    if(defval!=""){
      cpdiv.style.backgroundColor=defval;
    }

    cpdiv.innerHTML = "&nbsp;";
    cpdiv.onclick = showcp;
    new_lmn_tr.childNodes[1].appendChild(cpdiv);
    new_lmn_tr.childNodes[1].childNodes[0].onclick = showcp;
  }
  if (typ=="txtip"){
    new_lmn_tr.childNodes[1].appendChild(document.createElement("input"));
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("id",eid+"_"+id);
    new_lmn_tr.childNodes[1].childNodes[0].type = "text";
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("value",defval);
  }
  if (typ=='font'){
    new_lmn_tr.childNodes[1].appendChild(document.createElement("select"));
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("id",eid+"_"+id);
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("size",1);
   
    for(i=0;i<fonts.length;i++){
      new_lmn_tr.childNodes[1].childNodes[0].appendChild(document.createElement("option"));
      new_lmn_tr.childNodes[1].childNodes[0].lastChild.appendChild(document.createTextNode(fonts[i]));
    }
  }
  if (typ=='fontsize'){
    new_lmn_tr.childNodes[1].appendChild(document.createElement("select"));
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("id",eid+"_"+id);
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("size",1);
   
    for(i=0;i<fontss.length;i++){
      new_lmn_tr.childNodes[1].childNodes[0].appendChild(document.createElement("option"));
      new_lmn_tr.childNodes[1].childNodes[0].lastChild.appendChild(document.createTextNode(fontss[i]));
    }
  }
  if (typ=='linkfg'){
    new_lmn_tr.childNodes[1].appendChild(document.createElement("select"));
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("id",eid+"_"+id);
    new_lmn_tr.childNodes[1].childNodes[0].setAttribute("size",1);
   
    for(i=0;i<linkfg.length;i++){
      new_lmn_tr.childNodes[1].childNodes[0].appendChild(document.createElement("option"));
      new_lmn_tr.childNodes[1].childNodes[0].lastChild.appendChild(document.createTextNode(linkfg[i]));
    }
  }
 
  return new_lmn_tr;
}

function create_text_menue(eid){

  new_tmn = document.createElement("div");
  new_tmn.setAttribute("id",eid+"_menue");
  new_tmn.setAttribute("class","menue");
  new_tmn.setAttribute("className","menue");
  new_tmn.style.visibility = "hidden";
  new_tmn.style.zIndex = "100000000";

  new_tmn_tab = document.createElement("table");
  new_tmn_tab.setAttribute("id","mtab");
  new_tb = document.createElement("tbody");

  //std box werte
  new_tb.appendChild(create_menue_input("Hintergrundfarbe:",eid,"ncontbgc",""));
  new_tb.appendChild(create_menue_input("Rahmenfarbe:",eid,"nbcolor",""));

  new_tb.appendChild(create_menue_input("Titel Text:",eid,"ntitle","","txtip"));
  new_tb.appendChild(create_menue_input("Titel Schriftfarbe:",eid,"ntitlefc",""));
  new_tb.appendChild(create_menue_input("Titel Hintergrundfarbe:",eid,"ntitlebgc",""));

  //spezielle werte
  new_tb.appendChild(create_menue_input("Text Schriftfarbe:",eid,"ntextfc",""));
  new_tb.appendChild(create_menue_input("Text Schriftart:",eid,"ntextf","","font"));
  new_tb.appendChild(create_menue_input("Text Schriftgröße:",eid,"ntextfs","","fontsize"));

    new_tmn_tr2 = document.createElement("tr");
    new_tmn_tr2.appendChild(document.createElement("td"));
    new_tmn_tr2.childNodes[0].setAttribute("colSpan","2");
    new_tmn_tr2.childNodes[0].setAttribute("align","center");

      new_sbtn = document.createElement("input");
      new_sbtn.setAttribute("name",eid+"_msb");
      new_sbtn.setAttribute("id",eid+"_msb");
      new_sbtn.setAttribute("type","button");
      new_sbtn.value = "Speichern";

      new_cbtn = document.createElement("input");
      new_cbtn.setAttribute("name",eid+"_mcab");
      new_cbtn.setAttribute("id",eid+"_mcab");
      new_cbtn.setAttribute("type","button");
      new_cbtn.value = "Abbrechen";

      new_rbtn = document.createElement("input");
      new_rbtn.setAttribute("name",eid+"_mreb");
      new_rbtn.setAttribute("id",eid+"_mreb");
      new_rbtn.setAttribute("type","button");
      new_rbtn.value = "Entfernen";

    new_tmn_tr2.childNodes[0].appendChild(new_sbtn);
    new_tmn_tr2.childNodes[0].appendChild(new_cbtn);
    new_tmn_tr2.childNodes[0].appendChild(new_rbtn);

  new_tb.appendChild(new_tmn_tr2);
  
  new_tmn_tab.appendChild(new_tb);
  new_tmn.appendChild(new_tmn_tab);
  return new_tmn ; 
}

function create_bild_menue(eid){

  new_tmn = document.createElement("div");
  new_tmn.setAttribute("id",eid+"_menue");
  new_tmn.setAttribute("class","menue");
  new_tmn.setAttribute("className","menue");
  new_tmn.style.visibility = "hidden";
  new_tmn.style.zIndex = "100000000";

  new_tmn_tab = document.createElement("table");
  new_tmn_tab.setAttribute("id","mtab");
  new_tb = document.createElement("tbody");

  //std box werte
  new_tb.appendChild(create_menue_input("Hintergrundfarbe:",eid,"ncontbgc",""));
  new_tb.appendChild(create_menue_input("Rahmenfarbe:",eid,"nbcolor",""));

  new_tb.appendChild(create_menue_input("Titel Text:",eid,"ntitle","","txtip"));
  new_tb.appendChild(create_menue_input("Titel Schriftfarbe:",eid,"ntitlefc",""));
  new_tb.appendChild(create_menue_input("Titel Hintergrundfarbe:",eid,"ntitlebgc",""));

    new_tmn_tr2 = document.createElement("tr");
    new_tmn_tr2.appendChild(document.createElement("td"));
    new_tmn_tr2.childNodes[0].setAttribute("colSpan","2");
    new_tmn_tr2.childNodes[0].setAttribute("align","center");

      new_sbtn = document.createElement("input");
      new_sbtn.setAttribute("name",eid+"_msb");
      new_sbtn.setAttribute("id",eid+"_msb");
      new_sbtn.setAttribute("type","button");
      new_sbtn.value = "Speichern";

      new_cbtn = document.createElement("input");
      new_cbtn.setAttribute("name",eid+"_mcab");
      new_cbtn.setAttribute("id",eid+"_mcab");
      new_cbtn.setAttribute("type","button");
      new_cbtn.value = "Abbrechen";

      new_rbtn = document.createElement("input");
      new_rbtn.setAttribute("name",eid+"_mreb");
      new_rbtn.setAttribute("id",eid+"_mreb");
      new_rbtn.setAttribute("type","button");
      new_rbtn.value = "Entfernen";

    new_tmn_tr2.childNodes[0].appendChild(new_sbtn);
    new_tmn_tr2.childNodes[0].appendChild(new_cbtn);
    new_tmn_tr2.childNodes[0].appendChild(new_rbtn);

  new_tb.appendChild(new_tmn_tr2);
  
  new_tmn_tab.appendChild(new_tb);
  new_tmn.appendChild(new_tmn_tab);
  return new_tmn ; 
}

function create_link_menue(eid,eh){

  new_lmn = document.createElement("div");
  new_lmn.setAttribute("id",eid+"_menue");
  new_lmn.setAttribute("class","menue");
  new_lmn.setAttribute("className","menue");
  new_lmn.style.visibility = "hidden";
  new_lmn.style.zIndex = "100000000";

  new_lmn_tab = document.createElement("table");
  new_tb = document.createElement("tbody");

  new_tb.appendChild(create_menue_input("Hintergrundfarbe:",eid,"ncontbgc",""));
  new_tb.appendChild(create_menue_input("Rahmenfarbe:",eid,"nbcolor",""));

  new_tb.appendChild(create_menue_input("Titel Text:",eid,"ntitle","","txtip"));
  new_tb.appendChild(create_menue_input("Titel Schriftfarbe:",eid,"ntitlefc",""));
  new_tb.appendChild(create_menue_input("Titel Hintergrundfarbe:",eid,"ntitlebgc",""));

  if(eh==1){
    //spezielle werte
    new_tb.appendChild(create_menue_input("Link Freigabe:",eid,"nlinkfg","","linkfg"));
  }

    new_lmn_tr2 = document.createElement("tr");
    new_lmn_tr2.appendChild(document.createElement("td"));
    new_lmn_tr2.childNodes[0].setAttribute("colSpan","2");
    new_lmn_tr2.childNodes[0].setAttribute("align","center");

      new_sbtn = document.createElement("input");
      new_sbtn.setAttribute("name",eid+"_msb");
      new_sbtn.setAttribute("id",eid+"_msb");
      new_sbtn.setAttribute("type","button");
      new_sbtn.value = "Speichern";

      new_cbtn = document.createElement("input");
      new_cbtn.setAttribute("name",eid+"_mcab");
      new_cbtn.setAttribute("id",eid+"_mcab");
      new_cbtn.setAttribute("type","button");
      new_cbtn.value = "Abbrechen";

      new_rbtn = document.createElement("input");
      new_rbtn.setAttribute("name",eid+"_mreb");
      new_rbtn.setAttribute("id",eid+"_mreb");
      new_rbtn.setAttribute("type","button");
      new_rbtn.value = "Enternen";

    new_lmn_tr2.childNodes[0].appendChild(new_sbtn);
    new_lmn_tr2.childNodes[0].appendChild(new_cbtn);
    new_lmn_tr2.childNodes[0].appendChild(new_rbtn);

  new_tb.appendChild(new_lmn_tr2);
  
  new_lmn_tab.appendChild(new_tb);
  new_lmn.appendChild(new_lmn_tab);
  return new_lmn ; 
}


function create_inc_menue(eid,inc){
  new_lmn = document.createElement("div");

  new_lmn.setAttribute("id",eid+"_incmenue");
  new_lmn.setAttribute("class","incmenue");
  new_lmn.setAttribute("className","incmenue");
  new_lmn.style.visibility = "hidden";
  new_lmn.style.zIndex = "100000000";

  new_lmn_tab = document.createElement("table");
  new_tb = document.createElement("tbody");

    new_lmn_tr1 = document.createElement("tr");
    new_lmn_td1 = document.createElement("td");

    // wenn zum einbinden freigegeben
    if (inc==1||inc==3){
      new_inc_btn1 = document.createElement("input");
      new_inc_btn1.setAttribute("id",eid+"_incbtn");
      new_inc_btn1.type="button";
      new_inc_btn1.setAttribute("value","Einbinden");
      new_inc_btn1.onclick=inclinkbox;
      
      new_lmn_td1.appendChild(new_inc_btn1);
    }

    // wenn zum kopieren freigegeben
    if (inc==2||inc==3){
      new_inc_btn2 = document.createElement("input");
      new_inc_btn2.setAttribute("id",eid+"_copybtn");
      new_inc_btn2.type="button";
      new_inc_btn2.setAttribute("value","Kopieren");
      new_inc_btn2.onclick=copylinkbox;

      new_lmn_td1.appendChild(new_inc_btn2);
    }

    new_inc_btn3 = document.createElement("input");
    new_inc_btn3.setAttribute("id",eid+"_clbtn");
    new_inc_btn3.type="button";
    new_inc_btn3.setAttribute("value","Abbrechen");
    new_inc_btn3.onclick = show_inc_mn;

    new_lmn_td1.appendChild(new_inc_btn3);

    new_lmn_tr1.appendChild(new_lmn_td1);

  new_tb.appendChild(new_lmn_tr1);
  
  new_lmn_tab.appendChild(new_tb);
  new_lmn.appendChild(new_lmn_tab);

  return new_lmn;

}

function create_book_menue(eid,tit,des,url){

  new_bmn = document.createElement("div");
  new_bmn.setAttribute("class","lmen");
  new_bmn.setAttribute("className","lmen");
  new_bmn.setAttribute("id",eid+"_menue");
  new_bmn.style.display = "none";

  new_bmn_form = document.createElement("form");
  new_bmn_form.setAttribute("id",eid+"_vform");
  new_bmn_form.setAttribute("name",eid+"_vform");

  new_bmn_tab = document.createElement("table");
  new_bmn_tab.setAttribute("id","bm_tab");
  new_tb = document.createElement("tbody");

  new_tb.appendChild(create_menue_input("Titel:",eid,"ntitle",tit,"txtip"));
  new_tb.appendChild(create_menue_input("Beschreibung:",eid,"ndesc",des,"txtip"));
  new_tb.appendChild(create_menue_input("URL:",eid,"nurl",checkurl(url),"txtip"));

  new_tb.appendChild(create_menue_input("Link Schriftfarbe:",eid,"nbmlc","#0000ff"));
  new_tb.appendChild(create_menue_input("Text Schriftfarbe:",eid,"nbmfc","#333333"));
  new_tb.appendChild(create_menue_input("Text Schriftart:",eid,"nbmf","","font"));
  new_tb.appendChild(create_menue_input("Text Schriftgröße:",eid,"nbmfs","","fontsize"));

    new_bmn_tr2 = document.createElement("tr");
    new_bmn_tr2.appendChild(document.createElement("td"));
    new_bmn_tr2.childNodes[0].setAttribute("colSpan","2");
    new_bmn_tr2.childNodes[0].setAttribute("align","center");

    new_input1 = document.createElement("input");
    new_input2 = document.createElement("input");
    new_input3 = document.createElement("input");

    new_input1.setAttribute("id",eid+"_msb");
    new_input1.type = "button";
    new_input1.setAttribute("value","Speichern");
    new_input1.onclick = set_book_werte;

    new_input2.setAttribute("id",eid+"_mcab");
    new_input2.type = "button";
    new_input2.setAttribute("value","Abbrechen");
    new_input2.onclick = toggle_book_menue;

    new_input3.setAttribute("id",eid+"_mrem");
    new_input3.type = "button";
    new_input3.setAttribute("value","Entfernen");
    new_input3.onclick = remove_book;

    new_bmn_tr2.childNodes[0].appendChild(new_input1);
    new_bmn_tr2.childNodes[0].appendChild(new_input3);
    new_bmn_tr2.childNodes[0].appendChild(new_input2);

  new_tb.appendChild(new_bmn_tr2);

  new_bmn_tab.appendChild(new_tb);
  new_bmn_form.appendChild(new_bmn_tab);
  new_bmn.appendChild(new_bmn_form);
  return new_bmn;
}

//////////////////////////////////////////////////////////////////////////////////////////
// EVENT HANDLER
//////////////////////////////////////////////////////////////////////////////////////////

function set_box_values(eid,params,eh,typ){
    // content bg color
    if(params[0]!='default'){
      document.getElementById(eid+"_content").style.backgroundImage = "url()";
      document.getElementById(eid+"_content").style.backgroundColor = params[0];
    }

    // border color
    document.getElementById(eid+"_header").style.borderColor = params[1];
    document.getElementById(eid+"_content").style.borderColor = params[1];

    // titel text
    document.getElementById(eid+"_title").replaceChild(document.createTextNode(params[2]), document.getElementById(eid+"_title").firstChild);


    // titel font color
    document.getElementById(eid+"_title").style.color = params[3];

    if(params[4]!='default'){
      // titel bg color
      document.getElementById(eid+"_header").style.backgroundImage = "url()";
      document.getElementById(eid+"_header").style.backgroundColor = params[4];
    }


    if(eh==1||(eh==3&&typ=='link')){
      //MENUE schreiben
      if(params[0]!="default"){document.getElementById(eid+"_ncontbgc").style.backgroundColor = params[0];}
      document.getElementById(eid+"_nbcolor").style.backgroundColor = params[1];

      document.getElementById(eid+"_ntitle").value = params[2];

      document.getElementById(eid+"_ntitlefc").style.backgroundColor = params[3];
      if(params[4]!="default"){document.getElementById(eid+"_ntitlebgc").style.backgroundColor = params[4]};
    }

    if(typ=='link'){
      //menue
      if(eh==1){
        //Linkfreigabe schreiben
        setsel(eid+"_nlinkfg",unescape(params[5]));
      }      
    }

    if(typ=='text'){
      //menue
      if(eh==1){
        document.getElementById(eid+"_ntextfc").style.backgroundColor = params[5];
        setsel(eid+"_ntextfs",params[6]);
        setsel(eid+"_ntextf",params[7]);
      }
      //werte
      document.getElementById(eid+"_content").style.color = params[5];
      document.getElementById(eid+"_content").style.fontSize = params[6];
      document.getElementById(eid+"_content").style.fontFamily = params[7];
    }

}

function set_bm_values(eid,params,eh){

  if(eh==1){
    //MENUE schreiben
    setsel(eid+"_nbmf",params[0]);
    setsel(eid+"_nbmfs",params[1]);
    document.getElementById(eid+"_nbmfc").style.backgroundColor = params[2];
    document.getElementById(eid+"_nbmlc").style.backgroundColor = params[3];
  }

  document.getElementById(eid+"_desc").style.color = params[2];
  document.getElementById(eid+"_desc").style.fontFamily = params[0];
  document.getElementById(eid+"_desc").style.fontSize = params[1];
  
  document.getElementById(eid+"_alink").style.color = params[3];
  document.getElementById(eid+"_alink").style.fontFamily = params[0];
  document.getElementById(eid+"_alink").style.fontSize = params[1];
}

function toggle_menue(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));
  set_focus(ob_id);
  tgm(ob_id+'_menue');
}

function tgm(id) {
  if (document.getElementById(id).style.visibility=='hidden'){
    document.getElementById(id).style.visibility='visible';
  }else{
    document.getElementById(id).style.visibility='hidden';
  }
}

function toggle_book_menue(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));
  tgbm(ob_id+'_menue');
}

function tgbm(id) {
  if (document.getElementById(id).style.display=="none"){
    document.getElementById(id).style.display="block";
  }else{
    document.getElementById(id).style.display="none";
  }
}

function toggle_bild_edit(e) {
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));

  if (document.getElementById(ob_id+"_bildmenue").style.display=="none"){
    document.getElementById(ob_id+"_bildmenue").style.display="block";
  }else{
    document.getElementById(ob_id+"_bildmenue").style.display="none";
  }    
}

function toggle_text_edit(e) {
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));
  //toggle
  tgte(ob_id);
}

function tgte(id){
  if (document.getElementById(id+"_tedit").style.display=="none"){
    document.getElementById(id+"_tedit").style.display="block";
    document.getElementById(id+"_text").style.display="none";
  }else{
    document.getElementById(id+"_tedit").style.display="none";
    document.getElementById(id+"_text").style.display="block";
  } 
}

function show_inc_mn(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));
  set_focus(ob_id);
  tgincm(ob_id);
}

function tgincm(id){
  if (document.getElementById(id+"_incmenue").style.visibility=='hidden'){
    document.getElementById(id+"_incmenue").style.visibility='visible';
  }else{
    document.getElementById(id+"_incmenue").style.visibility='hidden';
  } 
}

function set_text(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));

  ntext = escape(document.getElementById(ob_id+"_ntext").value);

  document.getElementById(ob_id+"_text").innerHTML = escapetohtml(ntext);

// Text in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);} ,parameters:{aktion:'sav_book',eid:eid}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method:'post',parameters:{aktion:'sav_text',eid:ob_id,uid:nutzer,ntext:ntext}});

  //toggle
  tgte(ob_id);
}

function set_werte(e){

  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));

  //FarbWerte bestimmen
  ntbc = document.getElementById(ob_id+"_ntitlebgc").style.backgroundColor;
  ntfc = document.getElementById(ob_id+"_ntitlefc").style.backgroundColor;
  nboc = document.getElementById(ob_id+"_nbcolor").style.backgroundColor;
  nbgc = document.getElementById(ob_id+"_ncontbgc").style.backgroundColor;

  if(ntfc.charAt(0)=='r'){
    ntfc=cohexco(ntfc);
    ntbc=cohexco(ntbc);
    nboc=cohexco(nboc);
    nbgc=cohexco(nbgc);
  }

  //Titeltext bestimmen
  ntt = document.getElementById(ob_id+"_ntitle").value;

  //ALLE BOXEN GEMEINSAM
  
    // titel bg color
    if(ntbc==''){
      document.getElementById(ob_id+"_header").style.backgroundColor = "white";
      document.getElementById(ob_id+"_header").style.backgroundImage = "url('"+relpath+"inc/gfx/box_tbg.jpg')";
    }else{
      document.getElementById(ob_id+"_header").style.backgroundImage = "url()";
      document.getElementById(ob_id+"_header").style.backgroundColor = ntbc;
    }
    // titel font color
    document.getElementById(ob_id+"_title").style.color = ntfc;
  
    // titel text
    document.getElementById(ob_id+"_title").replaceChild(document.createTextNode(ntt), document.getElementById(ob_id+"_title").firstChild);

    // border color
    document.getElementById(ob_id+"_header").style.borderColor = nboc;
    document.getElementById(ob_id+"_content").style.borderColor = nboc;

    // content bg color
    if(nbgc==''){
      document.getElementById(ob_id+"_content").style.backgroundColor = "white";
      document.getElementById(ob_id+"_content").style.backgroundImage = "url('"+relpath+"inc/gfx/boxbg.jpg')";
    }else{
      document.getElementById(ob_id+"_content").style.backgroundImage = "url()";
      document.getElementById(ob_id+"_content").style.backgroundColor = nbgc;
    }

  // TEXT MENUE
  if(document.getElementById(ob_id+"_text")){

    //textfarbe
    ntc = document.getElementById(ob_id+"_ntextfc").style.backgroundColor;
    if(ntc.charAt(0)=='r'){ntc=cohexco(ntc);}
    document.getElementById(ob_id+"_content").style.color = ntc;

    //textfont
    ntf = getsel(ob_id+"_ntextf"); 
    document.getElementById(ob_id+"_content").style.fontFamily = ntf;
    
    //textgroeße
    nts = getsel(ob_id+"_ntextfs");
    document.getElementById(ob_id+"_content").style.fontSize = nts;
    
    // Werte in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);} ,parameters:{aktion:'sav_book',eid:eid}
    new Ajax.Request(relpath+"inc/php/ajax.php",{method:'post',parameters:{aktion:'sav_werte',typ:'text',eid:ob_id,sid:sid,ntbc:ntbc,ntfc:ntfc,ntt:ntt,nboc:nboc,nbgc:nbgc,ntc:ntc,ntf:ntf,nts:nts}});


  }else{
  
  //BILD MENUE
  if(document.getElementById(ob_id+"_bild")){
  
    // Werte in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);} ,parameters:{aktion:'sav_book',eid:eid}
    new Ajax.Request(relpath+"inc/php/ajax.php",{method:'post',parameters:{aktion:'sav_werte',typ:'link',eid:ob_id,sid:sid,ntbc:ntbc,ntfc:ntfc,ntt:ntt,nboc:nboc,nbgc:nbgc}});

  }
  
  //LINKMENUE
  else {
    
    if(document.getElementById(ob_id+"_nlinkfg")){
      //linkboxfreigabe
      nlf = escape(getsel(ob_id+"_nlinkfg"));
      
    }else{
      nlf = "na";
    }
    
    // Werte in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);} ,parameters:{aktion:'sav_book',eid:eid}
    new Ajax.Request(relpath+"inc/php/ajax.php",{method:'post',parameters:{aktion:'sav_werte',typ:'link',eid:ob_id,sid:sid,ntbc:ntbc,ntfc:ntfc,ntt:ntt,nboc:nboc,nbgc:nbgc,nlf:nlf}});
  
  }}

  tgm(ob_id+"_menue");
}

function remove_book(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));
  pid = document.getElementById(ob_id).parentNode.id.substr(0,document.getElementById(ob_id).parentNode.id.lastIndexOf('_'));

  document.getElementById(pid+'_content').removeChild(document.getElementById(ob_id));

  // Element aus Datenbank loeschen ,onSuccess: function(reponse) {alert(reponse.responseText);} ,parameters:{aktion:'sav_book',eid:eid}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method:'post',parameters:{aktion:'rem_book',eid:ob_id,pid:pid}});
  
  //tglm(ob_id+'_menue');
}

function set_book_werte(e){

  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));

  //FarbWerte bestimmen
  nbc = document.getElementById(ob_id+"_nbmfc").style.backgroundColor;
  nlc = document.getElementById(ob_id+"_nbmlc").style.backgroundColor;

  if(nbc.charAt(0)=='r'){
    nbc=cohexco(nbc);
    nlc=cohexco(nlc);
  }

  //restliche werte bestimmen
  nbf =  getsel(ob_id+"_nbmf");
  nbfs =   getsel(ob_id+"_nbmfs");
  ntitle = document.getElementById(ob_id+"_ntitle").value;
  ndesc = document.getElementById(ob_id+'_ndesc').value;
//  nurl = document.getElementById(ob_id+'_nurl').value
  nurl = checkurl(document.getElementById(ob_id+'_nurl').value);

  //werte setzen

  document.getElementById(ob_id+"_desc").style.color = nbc;
  document.getElementById(ob_id+"_desc").style.fontFamily = nbf;
  document.getElementById(ob_id+"_desc").style.fontSize = nbfs;
  
  document.getElementById(ob_id+"_alink").style.color = nlc;
  document.getElementById(ob_id+"_alink").style.fontFamily = nbf;
  document.getElementById(ob_id+"_alink").style.fontSize = nbfs;

  document.getElementById(ob_id+"_title").firstChild.replaceChild(document.createTextNode(ntitle), document.getElementById(ob_id+"_title").firstChild.firstChild);
  document.getElementById(ob_id+'_desc').replaceChild(document.createTextNode(ndesc), document.getElementById(ob_id+'_desc').firstChild);
//  document.getElementById(ob_id+'_title').firstChild.href='http://'+nurl;
  document.getElementById(ob_id+'_title').firstChild.href = nurl;

// Element in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method:'post',parameters:{aktion:'sav_book',eid:ob_id,nurl:nurl,ndesc:ndesc,ntitle:ntitle,nbc:nbc,nlc:nlc,nbf:nbf,nbfs:nbfs}});

  tgbm(ob_id+'_menue');
}


function set_bild_url(eid,url,w,h,vh){

  // Bilder zunächst Blind anlegen
  // werden dann in set bild size skaliert und sichtbar gemacht

  if(document.getElementById(eid+"_bild").firstChild){
    document.getElementById(eid+"_bild").removeChild(document.getElementById(eid+"_bild").firstChild);
  }
  
  new_bild = document.createElement("img");

  new_bild.setAttribute("id",eid+"_img");
  new_bild.setAttribute("src",relpath+"picupload/"+url);

  if(document.getElementById(eid+"_bild").offsetWidth < w){
    w = document.getElementById(eid+"_bild").offsetWidth - 10;
    h = Math.round(w/vh);
  }
  new_bild.setAttribute("width",w);
  new_bild.setAttribute("height",h);

  document.getElementById(eid+"_bild").appendChild(new_bild);
}

function add_link(e){

  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.length-5);

  show_load();

//  neue ID erzeugen
  new Ajax.Request(relpath+"inc/php/ajaxodb.php",{method: 'post',parameters:{aktion:'create_eid',nutzer:nutzer},onComplete: set_eid});

  document.getElementById(ob_id+"_content").insertBefore(create_new_bookmark(eid,ob_id,"I-DEX.de","Deine Linksseite im Internet!","www.i-dechs.de","1"),document.getElementById(ob_id+"_content").lastChild);

// Element in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method: 'post',parameters:{aktion:'ins_elem',nutzer:nutzer,typ:'bookm',eid:eid,sid:sid,pid:ob_id}, onSuccess: function(reponse) {eval(reponse.responseText);} });

}

//////////////////////////////////////////////////////////////////////////////////////////
//    
//    TEXTBOXEN
//
//////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////
// Neue Leere Textbox erstellen - Übergabe: Name der BOX
//////////////////////////////////////////////////////////////////////////////////////////

function create_text_box(eid,text,eh){

  //rahmen
  new_tbox = document.createElement("div");
  new_tbox.setAttribute("className","content_container");
  new_tbox.setAttribute("class","content_container");
  new_tbox.setAttribute("id",eid);
  
  //header
  new_header = document.createElement("div");
  new_header.setAttribute("className","header");
  new_header.setAttribute("class","header");
  new_header.setAttribute("id",eid+"_header");

    new_header_c3 = document.createElement("div");
    new_header_c3.setAttribute("className","title");
    new_header_c3.setAttribute("class","title");
    new_header_c3.setAttribute("id",eid+"_title");
    new_header_c3.appendChild(document.createTextNode("Titel"));
  new_header.appendChild(new_header_c3);

  if(eh==1){
      new_header_c4 = document.createElement("div");
      new_header_c4.setAttribute("className","ctrl");
      new_header_c4.setAttribute("class","ctrl");
      new_header_c4.setAttribute("id",eid+"_mbtn");
  
        mnbtn_img = document.createElement("img");
        mnbtn_img.setAttribute("src",relpath+"inc/gfx/mnbtn.jpg");
        mnbtn_img.setAttribute("alt","Box Menue");
        mnbtn_img.setAttribute("title","Box Menue");
        mnbtn_img.setAttribute("border","0");
        mnbtn_img.setAttribute("width","13");
        mnbtn_img.setAttribute("height","12");
        mnbtn_img.setAttribute("id",eid+"_pic");
  
      new_header_c4.appendChild(mnbtn_img);    
  
    new_header.appendChild(new_header_c4);
  }

    new_header_c5 = document.createElement("div");
    new_header_c5.setAttribute("className","dragger");
    new_header_c5.setAttribute("class","dragger");
    new_header_c5.setAttribute("id",eid+"_dragger");
  new_header.appendChild(new_header_c5);

  if(eh==1){
    new_header.appendChild(create_text_menue(eid));
  }
  
  //content
  new_content = document.createElement("div");
  new_content.setAttribute("className","text_div");
  new_content.setAttribute("class","text_div");
  new_content.setAttribute("id",eid+"_content");

  //content_i zwecks zu langen textes
  new_content_i = document.createElement("div");
  new_content_i.setAttribute("className","text_div_i");
  new_content_i.setAttribute("class","text_div_i");
  new_content_i.setAttribute("id",eid+"_contenti");


    new_content_text = document.createElement("div");
    new_content_text.setAttribute("className","ctextbox");
    new_content_text.setAttribute("class","ctextbox");
    new_content_text.setAttribute("id",eid+"_text");
    new_content_text.innerHTML = escapetohtml(text);
    //new_content_text.appendChild(document.createTextNode(text));

  new_content_i.appendChild(new_content_text);
//  new_content.appendChild(new_content_text);

    new_content_text_edit = document.createElement("div");
    new_content_text_edit.setAttribute("className","textedit");
    new_content_text_edit.setAttribute("class","textedit");
    new_content_text_edit.setAttribute("id",eid+"_tedit");

      new_content_text_edit_ta =  document.createElement("textarea");
      new_content_text_edit_ta.setAttribute("id",eid+"_ntext");
      new_content_text_edit_ta.setAttribute("cols","40");
      new_content_text_edit_ta.setAttribute("rows","5");
      
      new_content_text_edit_ta.appendChild(document.createTextNode(unescape(text)));
    new_content_text_edit.appendChild(new_content_text_edit_ta);


      new_btn_div = document.createElement("div");

      new_sav_btn = document.createElement("input");
      new_sav_btn.setAttribute("id",eid+"_tsb");
      new_sav_btn.setAttribute("type","button");
      new_sav_btn.setAttribute("value","Speichern");

      new_can_btn = document.createElement("input");
      new_can_btn.setAttribute("id",eid+"_tcb");
      new_can_btn.setAttribute("type","button");
      new_can_btn.setAttribute("value","Abbrechen");

    new_btn_div.appendChild(new_sav_btn);
    new_btn_div.appendChild(new_can_btn);
    
    new_content_text_edit.appendChild(new_btn_div);

    new_content_text_edit.style.display = "none";
    
  new_content_i.appendChild(new_content_text_edit);

  new_content.appendChild(new_content_i);
  
  new_tbox.appendChild(new_header);
  new_tbox.appendChild(new_content);
  
  return new_tbox;
}




//////////////////////////////////////////////////////////////////////////////////////////
//    
//    BILDBOXEN
//
//////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////
// Neue Bildbox erstellen - Übergabe: Name der BOX
//////////////////////////////////////////////////////////////////////////////////////////

function create_bild_box(eid,eh){
  
  //rahmen
  new_bbox = document.createElement("div");
  new_bbox.setAttribute("className","content_container");
  new_bbox.setAttribute("class","content_container");
  new_bbox.setAttribute("id",eid);
  
  //header
  new_header = document.createElement("div");
  new_header.setAttribute("className","header");
  new_header.setAttribute("class","header");
  new_header.setAttribute("id",eid+"_header");

    new_header_c3 = document.createElement("div");
    new_header_c3.setAttribute("className","title");
    new_header_c3.setAttribute("class","title");
    new_header_c3.setAttribute("id",eid+"_title");
    new_header_c3.appendChild(document.createTextNode("Titel"));
  new_header.appendChild(new_header_c3);

  if(eh==1){
      new_header_c4 = document.createElement("div");
      new_header_c4.setAttribute("className","ctrl");
      new_header_c4.setAttribute("class","ctrl");
      new_header_c4.setAttribute("id",eid+"_mbtn");
  
        mnbtn_img = document.createElement("img");
        mnbtn_img.setAttribute("src",relpath+"inc/gfx/mnbtn.jpg");
        mnbtn_img.setAttribute("alt","Box Menue");
        mnbtn_img.setAttribute("title","Box Menue");
        mnbtn_img.setAttribute("border","0");
        mnbtn_img.setAttribute("width","13");
        mnbtn_img.setAttribute("height","12");
        mnbtn_img.setAttribute("id",eid+"_pic");
  
      new_header_c4.appendChild(mnbtn_img);
  
    new_header.appendChild(new_header_c4);
  }

    new_header_c5 = document.createElement("div");
    new_header_c5.setAttribute("className","dragger");
    new_header_c5.setAttribute("class","dragger");
    new_header_c5.setAttribute("id",eid+"_dragger");
  new_header.appendChild(new_header_c5);

  new_header.appendChild(create_bild_menue(eid));

  //content
  new_content = document.createElement("div");
  new_content.setAttribute("className","bild_div");
  new_content.setAttribute("class","bild_div");
  new_content.setAttribute("id",eid+"_content");
  
    new_bdiv = document.createElement("div");
    new_bdiv.setAttribute("className","bild");
    new_bdiv.setAttribute("class","bild");
    new_bdiv.setAttribute("id",eid+"_bild"); 

  new_content.appendChild(new_bdiv);

  if(eh==1){
    new_bmen = document.createElement("div");
    new_bmen.setAttribute("className","bmen");
    new_bmen.setAttribute("class","bmen");
    new_bmen.setAttribute("id",eid+"_bildmenue"); 
    new_bmen.style.display = "none";

      new_fform = document.createElement("form");
      new_fform.setAttribute("action","index.php");
      new_fform.setAttribute("method","POST");
      new_fform.setAttribute("id",eid+"_fform");
      new_fform.encoding = "multipart/form-data";

      new_fminput = document.createElement("input");
      new_fminput.type = "hidden";
      new_fminput.name = "MAX_FILE_SIZE";
      //byte
      new_fminput.value = mfs;

      new_finput = document.createElement("input");
      new_finput.name = "userfile";
      new_finput.setAttribute("id",eid+"_nfile");
      new_finput.type = "file";

      new_fsub = document.createElement("input");
      new_fsub.setAttribute("name",eid+"_subfile");
      new_fsub.setAttribute("id",eid+"_subfile");
      new_fsub.setAttribute("type","submit");
      new_fsub.value = "Upload";

      new_fcan = document.createElement("input");
      new_fcan.setAttribute("name",eid+"_babbr");
      new_fcan.setAttribute("id",eid+"_babbr");
      new_fcan.setAttribute("type","button");
      new_fcan.value = "Abbrechen";

      new_fh2 = document.createElement("input");
      new_fh2.setAttribute("name","bbid");
      new_fh2.setAttribute("id","bbid");
      new_fh2.setAttribute("value",eid);
      new_fh2.setAttribute("type","hidden");

      new_fform.appendChild(new_fminput);
      new_fform.appendChild(new_finput);
      new_fform.appendChild(new_fsub);
      new_fform.appendChild(new_fcan);
      new_fform.appendChild(new_fh2);

    new_bmen.appendChild(new_fform);

      //button zum upload Menue
      
      new_bbtn = document.createElement("div");
      new_bbtn.setAttribute("className","pic_mbtn");
      new_bbtn.setAttribute("class","pic_mbtn");
      new_bbtn.setAttribute("id",eid+"_wbild");
  
        mnbtn_img = document.createElement("img");
        mnbtn_img.setAttribute("src",relpath+"inc/gfx/mnbtn.jpg");
        mnbtn_img.setAttribute("alt","Bild Upload");
        mnbtn_img.setAttribute("title","Bild Upload");
        mnbtn_img.setAttribute("border","0");
        mnbtn_img.setAttribute("width","13");
        mnbtn_img.setAttribute("height","12");
        mnbtn_img.setAttribute("id",eid+"_pic");
  
      new_bbtn.appendChild(mnbtn_img);

    new_content.appendChild(new_bmen);
    new_content.appendChild(new_bbtn);
  }
  
  new_bbox.appendChild(new_header);
  new_bbox.appendChild(new_content);
  
  // Variablen Speicherung fuer infos zur linkbox
  return new_bbox;
}


function inclinkbox(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));
// Element in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method: 'post',parameters:{aktion:'inc_link',nutzer:nutzer,eid:ob_id}});
  
  tgincm(ob_id);
}

function copylinkbox(e){
  // Object ID Bestimmen
  var e2 = (window.event)? window.event: e;
  objSrc = (e2.target)? e2.target : e2.srcElement;
  clicked = objSrc.id;
  ob_id = clicked.substr(0,clicked.lastIndexOf('_'));

// Element in DB speichern ,onSuccess: function(reponse) {alert(reponse.responseText);}
  new Ajax.Request(relpath+"inc/php/ajax.php",{method: 'post',parameters:{aktion:'copy_link',uid:nutzer,eid:ob_id}});
  
  tgincm(ob_id);
}

//////////////////////////////////////////////////////////////////////////////////////////
//    
//    HELPER
//
//////////////////////////////////////////////////////////////////////////////////////////

function escapetohtml(text){
  text = text.replace(/%0A/g, "<br>");
  text = unescape(text);
  return text;
}

function cohexco(val){

  if(val=="") return val;

  var reg = /^rgb\((\d{1,3}), \s*(\d{1,3}), \s*(\d{1,3})\)$/;
  reg.exec(val);
  
  r = Number(RegExp.$1).toString(16);
  g = Number(RegExp.$2).toString(16);
  b = Number(RegExp.$3).toString(16);
  
  if(r.length == 1){r='0'+r}; 
  if(g.length == 1){g='0'+g};
  if(b.length == 1){b='0'+b};

  op = '#'+r+g+b;
  return op;
}

function getsel(id) {
  for(i=0;i<=document.getElementById(id).length;i++){
    if(document.getElementById(id).options[i].selected)
    return document.getElementById(id).options[i].innerHTML;
  }
  return "";
}

function setsel(id,val) {
  if (val!='none'){
    for(i=0;i<=document.getElementById(id).length;i++){
      if(document.getElementById(id).options[i].innerHTML==val){
        document.getElementById(id).options[i].selected=true;
        return;
      }
    }
  }
}

function checkurl(url){
  if((url.substring(0,7)!="http://")&&(url.substring(0,8)!="https://")){
    url = "http://"+url; 
  }
  return url;
}

function makefavicon(url){

  if((url.substring(0,4)=="http")){
    var pre = url.substring(0,url.indexOf(":")) + "://";
    var pos = url.substring(url.indexOf("://")+3,url.length);
    
    if(pos.indexOf("/")!=-1){
      pos = pos.substring(0,pos.indexOf("/"));
    }
    url = pre+pos+"/favicon.ico";;
  } else{
    if(url.indexOf("/")!=-1){
      url = url.substring(0,url.indexOf("/"));
    }  
      url = "http://"+url+"/favicon.ico";
  }
  
  return url;
}