function getSource() {
  return self.opener.document.getElementById("entry_txt").value=self.opener.getIFrameWindow("editor").document.body.innerHTML;
}

function getValue(el_id){
  return self.opener.document.forms['blog_entry'].elements[el_id].value;
}

function getIFrameDocument(id) {
  iframe=null;
  // Mozilla
  if(document.getElementById(id).contentDocument){
    iframe=document.getElementById(id).contentDocument;
  }else {
  // IE
    iframe=document.frames[id].document;
  }
  return iframe;
}
function getIFrameWindow(id) {
  iframe=null;
  // Mozilla
  if(document.getElementById(id).contentWindow){
    iframe=document.getElementById(id).contentWindow;
  }else {
  // IE
    iframe=document.frames[id].window;
  }
  return iframe;
}
function setDesignMode() {
  getIFrameDocument("editor").designMode="on";
}
function execCmd(cmd) {
  getIFrameWindow("editor").document.execCommand(cmd, false, null);
  getIFrameWindow("editor").focus();
}
function addImage(url) {
  getIFrameWindow("editor").document.execCommand("insertimage", false, url);
  getIFrameWindow("editor").focus();
}
function addURL(url) {
  getIFrameWindow("editor").document.execCommand("createlink", false, url);
  getIFrameWindow("editor").focus();
}

function saveSource(id) {
  document.getElementById(id).value=getIFrameWindow("editor").document.body.innerHTML;
}
function showPreview() {
  document.getElementById("preview_title").value=document.getElementById("titel").value;
  saveSource('preview_txt');
  document.getElementById("preview").submit();
}
function load() {
  setDesignMode();
}
function comment(id)
{
	var l=(screen.availWidth-750)/2
	var t=(screen.availHeight-490)/2
	var obj=window.open("../commentblog.php?id="+id, "COMMENT", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=750,height=500,left="+l+",top="+t)
	obj.opener=top.window;
	obj.focus();
}
function doyoutube() {
  var code = prompt("embeded youtube code einfügen. video wird erst bei der vorschau oder nach dem veröffentlichen angezeigt", "");
  if (code != '' && code != null && (code.substring(0,7) === "<object" || code.substring(0,6) === "<embed")) {
    tempdiv=document.createElement("div");
    tempdiv.innerHTML="[MEDIA]"+code+"[/MEDIA]";
    getIFrameWindow("editor").document.body.appendChild(tempdiv);
  }
}