function addNewsCheck() {
  var ret = true;
  if (news_form.name.value == "") {
    alert("Bitte einen Namen eingeben.");
    ret = false;
  }
  else if (news_form.betreff.value == "") {
    alert("Bitte einen Betreff eingeben.");
    ret = false;
  }
  if (document.news_form.an_alle_cats_senden.checked && document.news_form.auch_senden_an_cats.selectedIndex > -1) {
    ret = false; alert("Entweder ein oder mehrere Kategorien markieren oder \"An alle senden\" auswählen.");
  }

  return ret;
};

function help(what, news_id, email_adresse) {
  if (what == 'md') {
    win = open("/static/help_markdown.html", "", "left=200,top=100,width=570,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  if (what == 'ne') {
    var send_id = news_id;
    win = open("/news_send_error.html/"+send_id, "", "left=200,top=100,width=450,height=200,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  win.focus();
};

//function pause(millis) {
//   var now = new Date();
//   var exitTime = now.getTime() + millis;
//
//   while(true) {
//       now = new Date();
//       if(now.getTime() > exitTime) return;
//   }
//}

function signOnCheck() {
  var ret = true;
  if (user_form.email.value == "" || user_form.email.value.indexOf('@') == -1 || user_form.email.value.indexOf('.') == -1 || user_form.email.value.indexOf(' ') > -1) {
     alert("Bitte eine gültige Emailadresse eingeben.");
     ret = false;
  }
  return ret;
};

// Bloecke

function pop_add_block(news_id, block_art, breite, hoehe) {
  bwin = open("/add_block.html/"+news_id+"/"+block_art, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  bwin.focus();
};

function pop_edit_block(item_id, block_id, breite, hoehe) {
  var bwin;
  // not editing a block but the newsletters metadata
  if (block_id == 100) {
     bwin = open("/edit_news_metadata.html/"+item_id, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  // net editing a block but a Categorie
  // in this case news_id is a cat_id
  else if (block_id == 101) {
     bwin = open("/edit_cat.html/"+item_id, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  else if (block_id == 102) {
     bwin = open("/edit_header.html/"+item_id, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  else if (block_id == 103) {
     bwin = open("/edit_footer.html/"+item_id, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  // editing a block
  else {
     bwin = open("/edit_block.html/"+item_id+"/"+block_id, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  }
  bwin.focus();
};

function preview(news_id, breite, hoehe) {
  bwin = open("/preview.html/"+news_id, "", "left=200,top=100,width="+breite+",height="+hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1");
  bwin.focus();
};

// Upload progress indicator

function showit() {
  document.getElementById("progress").style.visibility = "visible";
  window.setTimeout("wait_pic()", 500);
};

function wait_pic() {
  document["wait"].src = "/images/loading.gif";
};

