/* Javascripts voor World Servants (www.worldservants.nl) - Jan Marten */
function isEmail(adres){
  if(adres==''||((adres.indexOf('@',0)==-1)||(adres.indexOf('.',0)==-1))){
    return false;
    }
  return true;
  }


/* It's hip, it's hop, it's hopper! */
function hopper(x)
{
  if(x.options[x.selectedIndex].value != '')
  {
      this.location.href = x.options[x.selectedIndex].value;
  }
}
/* IM popup (om IM's mee te maken) */
function IM(IM)
{
    var MainWindow = window.open (IM,"_blank","toolbar=no,location=no,menubar=no,scrollbars=yes,width=400,height=230,resizable=1,status=no");
}
function remote(url)
{
  window.opener.location = url
}

/* In het profiel het plaatje wijzigen: */
function showimage()
{
  if (!document.images)
  return
    document.images.avatar.src=
    document.Register.avatar.options[document.Register.avatar.selectedIndex].value
}

/* thesmiley : by Tarin */
function smiley(thesmiley)
{
  document.form.message.value += thesmiley+" ";
  document.form.message.focus();
}

function hulp(hulp)
{
  // Deprecated ???
    var telwin = null;
    var thesite = 'help.php?' + hulp;
    telwin = window.open(thesite, 'hulpje', 'scrollbars=1, resizable=1, width=450, height=400');
}

function popup(pagina,height,width,scrollbars)
{
  // uitbreiden met toolbar ? Nee toch?
  newWindow = window.open(pagina, "popup",
    "toolbar=no,location=no,menubar=no,scrollbars=" + scrollbars + ",width=" + width + ",height=" + height + ",resizeable=yes,status=no,left=80,top=80");
  newWindow.creator=self
}

/* Form inhoud controleren sdf*/
function formcheck(x)
{
  var FID, TID, PID, UserName, Password, onderwerp, bericht;
    FID = document.form.FID.value;
    TID = document.form.TID.value;
    PID = document.form.PID.value;
    UserName = document.form.UserName.value;
    Password = document.form.Password.value;
    onderwerp = document.form.onderwerp.value;
    bericht = document.form.bericht.value;

  if (UserName=="" || Password=="")
  {
    alert("Geen inloggegevens gevonden, log in."); 
    document.form.UserName.focus();
    return false;
  }

  if (
        (FID != "" && (onderwerp == "" || bericht== "")) ||
    (TID != "" && bericht == "") ||
    (PID != "" && bericht == "")
       )
  {
    /* Nieuw onderwerp niet compleet ingevuld */
    alert("U heeft niet alles ingevuld!"); 
    document.form.bericht.focus();
    return false;
  }
    else
    {
        alert(bericht);
    }
}
function tab_url(URL, Titel, Datum, Tag, Status) 
{
  document.write("<a onmouseover=\"status='" + Status + " (Geplaatst op " + Datum + ")'; return true;\" onmouseout=\"status='World Servants'; return true;\" href=\"" + URL + "\" title=\"" + Tag + "\">" + Titel + "</a><br>\n");
}

function overzicht(TID, bg, threadstat, icon, title, beheer, laatste_datum, laatste_poster, topicsper, count)
{
  // Door de opmaak bij de gebruiker neer te leggen besparen we wat bandbreedte
  // bg werkt nog niet :s
  document.write("<tr>\n");
  document.write("<td background=\"gfx/bg_body/" + bg + "\" colspan=2 width=100% valign=top height=\"5px\">\n");

  document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n");
  document.write("<tr><td valign=top align=\"left\" width=\"40px\">");
  var threadstat_tag;
  // tagger voor threadstat (simplistisch)
  if (threadstat == "newlockfolder")
  {
    threadstat_tag = 'Nieuw onderwerp dat gesloten is';
  }
  else if (threadstat == "newfolder")
  {
    threadstat_tag = 'Nieuw onderwerp';
  }
  else if (threadstat == "sticky")
  {
    threadstat_tag = 'Mededeling';
  }
  else if (threadstat == "lockfolder")
  {
    threadstat_tag = 'Gesloten onderwerp, er kan niet meer gereageerd worden';
  }
  else //if (threadstat == "folder")
  {
    threadstat_tag = 'Op dit onderwerp kan gereageerd worden';
  }
  // output van de threadstat
  document.write("<img src=gfx/images/"+ threadstat + ".gif WIDTH=16 HEIGHT=14 alt=\"" + threadstat_tag + "\">\n");
  // blank icoon = default ook indien er niets is ingevuld..!
  if (icon == '')
  {
    icon = 'blank.gif';
  }
  document.write("<img src=\"gfx/images/icons/" + icon + "\" BORDER=0 WIDTH=15 HEIGHT=15></td>\n");
  // de titel + als tag de lastposter
  document.write("<td valign=top align=left width=\"500px\"><a href=\"interactie_lezen.php?TID=" + TID + "\" title=\"Laatste bericht door "+laatste_poster+"\">" + title + "</a>");
  // aantal paginas voor dit topic: (let op count++ -> startpost is not counted
  count++;
  var paginas = Math.ceil(count / topicsper);
  //alert ( count / topicsper );
  // pagina aantal instellen voor direct jumps naar pagina nr X
  if (paginas > 1)
  {
    document.write(" [Pagina");
    if (paginas < 6)
    {
      var begin = 1;
      var eind = paginas;
    }
    else
    {
      document.write("...");
      var begin = paginas - 5;
      var eind = paginas;
    }
    for (var i = begin; i <= eind ; i++)
    {
      document.write(" <a href=\"interactie_lezen.php?TID=" + TID + "&pagina="+i+"\"><b>" + i + "</b></a>");
    }
    document.write(" ]");
  }
  document.write("</td>\n");
  document.write("<td rowspan=1 align=right valign=center width=\"15px\"><font size=1>" + beheer + "</td>");
  document.write("<td rowspan=1 align=right valign=center width=\"80px\"><font size=1 title=\"Laatste bericht door " + laatste_poster + "\">" + laatste_datum + "</font></td>");
  document.write("</tr></table>");

  document.write("</td></tr>\n");
}

function startpagina()
{
  parent.document.title = document.title; // neem de <title> over!
  status=('World Servants: Bouwen aan jezelf door te bouwen voor een ander');
  //if (window != top) top.location = location; // zoiets?
}

