//Browsercheck
v3 = 0; op = 0; ie4  = 0; ie5 = 0; nn4 = 0; nn6 = 0; isMac = 0; ff = 0;

if(document.images){
    if(navigator.userAgent.indexOf("Firefox") != -1) {
        ff = 1;
    }
    else if(navigator.userAgent.indexOf("Opera") != -1){
        op = 1;
    } else {
        ie4 = (document.all && !document.getElementById);
        nn4 = (document.layers);
        ie5 = (document.all && document.getElementById);
        nn6 = (document.addEventListener);
    }
} else {
    v3 = 1;    
}

n=document.layers
ie=document.all

if(navigator.userAgent.indexOf("Mac") != -1){
    isMac = 1;
}

slideshow_continue = 0;
slideshow_arr = new Array();
teller = document.all.length;

function preloadImages() { //v3.0
  var d=document; 
  
  if(d.images)
  {
    if(!d.mo_p) 
      d.mo_p=new Array();
      
    var i,j = d.mo_p.length, a=preloadImages.arguments;
    
    for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0)
      {
        d.mo_p[j]=new Image; 
        d.mo_p[j++].src=a[i];
      }
    }
}

preftab = "forward";  // or receive

//Hides the layer onload

function hideIt(){
  if(ie || n || ff){
    if(n) document.layers['divLoadCont'].visibility="hide";
    else divLoadCont.style.visibility="hidden";
  }
}

//Hides the MyPrefs.php Add button
function hideAddButton() {
  if(ie || n || ff){
    if(n) document.layers['addbtn'].visibility="hide";
    else addbtn.style.visibility="hidden";
  }
}

//Shows the MyPrefs.php Add button
function showAddButton() {
  if(ie || n || ff){
    if(n) document.layers['addbtn'].visibility="show";
    else addbtn.style.visibility="visible";
  }
}

//Hides the MyPrefs.php Remove button
function hideRemButton() {
  if(ie || n || ff){
    if(n) document.layers['rembtn'].visibility="hide";
    else rembtn.style.visibility="hidden";
  }
}

//Shows the MyPrefs.php Remove button
function showRemButton() {
  if(ie || n || ff){
    if(n) document.layers['rembtn'].visibility="show";
    else rembtn.style.visibility="visible";
  }
}

//Hides the secure fields
function hideSecure() {

  if(ie || n || ff){
    if(n) document.layers['securefields'].visibility="hide";
    else securefields.style.visibility="hidden";
  }
}

//Shows the secure fields
function showSecure() {
  if(ie || n || ff){
    if(n) document.layers['securefields'].visibility="show";
    else securefields.style.visibility="visible";
  }
}

//Hides the vidview
function hideVid() {

  if(ie || n || ff){
    if(n) document.layers['vidview'].visibility="hide";
    else vidview.style.visibility="hidden";
  }
}

//Shows the secure fields
function showVid() {
  if(ie || n || ff){
    if(n) document.layers['vidview'].visibility="show";
    else vidview.style.visibility="visible";
  }
}

function paste_strinL (strinL, isQuote) {
  if (strinL == '') alert('Please, select some text first');
  else {
    if (isQuote == 1) {
      strinL = '[i]' + strinL + '[/i]' + '\n';
    }
    if (isQuote == 2) {
      strinL = '[b]' + strinL + '[/b]' + '\n';
    }
    document.postmsg.comment.value = document.postmsg.comment.value + strinL;
  }
}

function callstats (f,cid) {
  t = Math.random();
  if (ff) {
    document.getElementById('stats').src = "stats.php?func=" + f + "&id=" + cid + "&r=" + escape(t);
  }
  else {
    document.stats.location.href = "stats.php?func=" + f + "&id=" + cid + "&r=" + escape(t);
  }
}

function get_username ()
{
  e = document.getElementById ('sel_postedby');
  if (e) {
     return ' ' + e.innerHTML;
  }
  return "";
}

function stop_slideshow ()
{
   slideshow_continue = 0;
}

function showslide (list, i) {
  if (list[i] && slideshow_continue) {
    if (ff) {
       document.getElementById('picview').src = list[i];
    }
    else {
      document.all['picview'].src = list[i];
    }
    next = i + 1;
    setTimeout ("showslide(list," + next + ")", 3000);
  }
}

function slideshow() {

  var pic = '<img title="Toon foto op ware grootte" id=picview border=0 width=242 src="images/spacer.gif">';
  
  document.all['vidview_container'].innerHTML = "";
  document.all['picview_container'].innerHTML = pic;  
  document.all['picview'].src = 'image/spacer';

  slideshow_continue = 1;
  document.getElementById('sel_message_id').value = "";

  if (ff) {
    d = document.getElementById('gallery');ge
  }
  else {
    d = document.gallery;
  }
  if (d)  {
    list = d.slideshow_arr;

    if (list) {
      setTimeout ("showslide(list, 0)", 100);
    }
    else {
       alert ('Slideshow not supported by this browser');
    }
  }
}

function highlight_gallery(id) {
   i = document.getElementById (id);
   if (i.className.indexOf('inactive') == -1) {
      i.className = "gallery_inactive";
   }
   else {
      i.className = "gallery_active";
   }
}

function addtogallery(id) {
   if (id == '') {
      alert('Selecteer eerst een gallery');
      return;
   }
   
   document.gal1.action.value = "add";
   document.gal1.submit();
}

function remfromgallery(id) {
   document.gal0.action.value = "rem";
   document.gal0.submit();
}

function reload_gallery(id) {
  url = "gallery_content.php?rows=2&sgallery=" + id;
  if (ff) {
    document.getElementById('to').src = url;
  }
  else {
    document.to.location.href = url
  }
}

function galgotopage(p,a,r,c) {

   frm = document.getElementById ("gal" + a);
   frm.action.value = "nav";
   frm.spage.value = p;
   frm.submit();
}

function updgotopage(p,r,c) {

   frm = document.getElementById ("update");
   frm.action.value = "nav";
   frm.spage.value = p;
   frm.submit();
}

function pickgal (id, fname) {
   highlight_gallery ('gal_' + id);
   document.getElementById ('selgal_' + id).value = '1';
}


function pagenav (nav) {
   document.getElementById('pagenav').innerHTML = nav; 
}

function playaudio(addtext, userid, mid, cid, fname,textmsg,postedby,country,timestamp,atavar_url) {

  parent.stop_slideshow();

  // increment clicks statistics
  callstats (1,cid);
  
  parent.document.all['picview'].src = "images/audioview.gif";
  parent.document.getElementById('sel_message_id').value = mid;
  parent.document.getElementById('sel_cid_id').value = cid;
  parent.document.getElementById('sel_user').value = userid;
  parent.document.getElementById('pictext').innerHTML = textmsg;
  parent.document.getElementById('sel_postedby').innerHTML = postedby;
  parent.document.getElementById('sel_country').innerHTML = country;
  parent.document.getElementById('sel_timestamp').innerHTML = timestamp;
  parent.document.getElementById('sel_atavar').src = atavar_url;

  if (addtext) {
     parent.document.getElementById('addtext_icon').src = "images/text.gif";
     parent.document.getElementById('delpic_icon').src = "images/delete_active.gif";
     
  }
  else {
     parent.document.getElementById('addtext_icon').src = "images/text_inactive.gif";
     parent.document.getElementById('delpic_icon').src = "images/delete_inactive.gif";
  }
  
  //if (playmms) {
  //   parent.document.getElementById('playmms_icon').src = "images/playmms.jpg";
  //}
  //else {
  //   parent.document.getElementById('playmms_icon').src = "images/spacer.gif";
  //}

  playSound(cid);
}

function showpic(addtext, userid, mid, cid, fname,textmsg,postedby,country,timestamp,atavar_url,ncomments) {

  parent.stop_slideshow();

  var pic = '<img title="Toon foto op ware grootte" id=picview border=0 width=242 src="images/spacer.gif">';
  
  parent.document.all['vidview_container'].innerHTML = "";
  parent.document.all['picview_container'].innerHTML = pic;  
  parent.document.all['picview'].src = fname;
  
  parent.document.getElementById('sel_message_id').value = mid;
  parent.document.getElementById('sel_cid_id').value = cid;
  parent.document.getElementById('sel_user').value = userid;
  parent.document.getElementById('pictext').innerHTML = textmsg;
  
  if (parent.document.getElementById('sel_postedby')) parent.document.getElementById('sel_postedby').innerHTML = postedby;  
  if (parent.document.getElementById('sel_country')) parent.document.getElementById('sel_country').innerHTML = country;
  if (parent.document.getElementById('sel_timestamp')) parent.document.getElementById('sel_timestamp').innerHTML = timestamp;
  if (parent.document.getElementById('sel_atavar')) parent.document.getElementById('sel_atavar').src = atavar_url;

  if (addtext) {
     parent.document.getElementById('addtext_icon').src = "images/text.gif";
     parent.document.getElementById('delpic_icon').src = "images/delete_active.gif";
  }
  else {
     parent.document.getElementById('addtext_icon').src = "images/text_inactive.gif";
     parent.document.getElementById('delpic_icon').src = "images/delete_inactive.gif";
  }

  if (parent.document.getElementById('ncomments')) parent.document.getElementById('ncomments').innerHTML = ncomments; 

  // increment clicks statistics
  callstats (1,cid);
}

function showvideo(addtext, userid, mid, cid, fname,textmsg,postedby,country,timestamp,atavar_url,ncomments, fname_orig) {

  parent.stop_slideshow();

  var vid  = '<OBJECT WIDTH="242" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="' + cid + '" ALIGN="">';
  var pic = '<img title="Toon foto op ware grootte" id=picview border=0 height=1 width=242 src="images/spacer.gif">';

  vid += '<PARAM NAME=movie VALUE="' + fname + '">';
  vid += '<!-- PARAM NAME=menu VALUE=false -->';
  vid += '<PARAM NAME=quality VALUE=high>';
  vid += '<PARAM NAME=bgcolor VALUE=#dddddd>';
  vid += '<EMBED src="' + fname + '" quality=high menu=false bgcolor=#dddddd';
  vid += '       WIDTH="242" NAME="intro" ALIGN="" TYPE="application/x-shockwave-flash"';
  vid += '       PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer"></EMBED>';
  vid += '</OBJECT>';
  
  var $vidtype = new String (fname_orig);
  if ($vidtype.indexOf('.bin') == -1) {
     vid += '<br><br><a target="_new" href="' + fname_orig + '">Show original movie</a>';
  }
  
  parent.document.all['picview_container'].innerHTML = pic;  
  parent.document.all['picview'].src = 'images/spacer.gif';
  parent.document.all['vidview_container'].innerHTML = vid;  
  
  parent.document.getElementById('sel_message_id').value = mid;
  parent.document.getElementById('sel_cid_id').value = cid;
  parent.document.getElementById('sel_user').value = userid;
  parent.document.getElementById('pictext').innerHTML = textmsg;
  
  if (parent.document.getElementById('sel_postedby')) parent.document.getElementById('sel_postedby').innerHTML = postedby;  
  if (parent.document.getElementById('sel_country')) parent.document.getElementById('sel_country').innerHTML = country;
  if (parent.document.getElementById('sel_timestamp')) parent.document.getElementById('sel_timestamp').innerHTML = timestamp;
  if (parent.document.getElementById('sel_atavar')) parent.document.getElementById('sel_atavar').src = atavar_url;

  if (addtext) {
     parent.document.getElementById('addtext_icon').src = "images/text.gif";
     parent.document.getElementById('delpic_icon').src = "images/delete_active.gif";
  }
  else {
     parent.document.getElementById('addtext_icon').src = "images/text_inactive.gif";
     parent.document.getElementById('delpic_icon').src = "images/delete_inactive.gif";
  }

  if (parent.document.getElementById('ncomments')) parent.document.getElementById('ncomments').innerHTML = ncomments; 

  // increment clicks statistics
  callstats (1,cid);
}

function opener_seldate(d) {

  document.cal.sdate.value = d;
  document.cal.spage.value = 1;
  document.cal.lastpage.value = 0;
  document.cal.submit();
}

function seldate(d) {
  
  document.cal.sdate.value = d;
  document.cal.spage.value = 1;
  document.cal.lastpage.value = 0;
  document.cal.submit();

  opener.opener_seldate(d);
}

function changelang() {
  // Set SESSION variable langCook
  list = document.getElementById('selLang').options;
  idx = document.getElementById('selLang').selectedIndex;

  lang = list[idx].value;
  
  document.setlang.submit();
}

function selfavorite() {
  document.cal.sdate.value = "";

  list = document.getElementById('favorites_list').options;
  idx = document.getElementById('favorites_list').selectedIndex;

  document.cal.sgallery.value = "";
  document.cal.sig.value = "";
  document.cal.suser.value = list[idx].value;
  document.cal.spage.value = 1;
  document.cal.lastpage.value = 0;
  document.cal.submit();
}

function addfavorite (slog) {

  if (ff) {
    document.getElementById('gallery').src = "secure_favorites.php?slog=" + slog;
  }
  else {
    document.gallery.location.href = "secure_favorites.php?slog=" + slog;
  }
}

function statustext (str) {
  window.status = str;
}

function seluser (id, sdate, slog,cid) {
  document.selauser.suser.value = id;
  document.selauser.sdate.value = sdate;
  document.selauser.slog.value  = slog;
  if (cid) document.selauser.scid.value  = cid;
  document.selauser.submit();
}

function gotouser (id,slog) {
  if (ff) {
    alert ('Make gotouser() function Firefox compatible');
  }
  else {
    parent.document.location.href = "mlog.php?suser=" + id + "&slog=" + slog + "&sig=";
  }
}

function gotoig (id,cid) {
  url = "mlog.php?suser=&slog=&sdate=&sig=" + id;
  if (cid) {
     url = url + "&scid=" + cid;
  }
  document.location.href = url;
}

function prevpage() {

  stop_slideshow();
  
  if (document.cal.spage.value > 1) {
    document.cal.spage.value = parseInt(document.cal.spage.value) - 1;
    document.cal.lastpage.value = 0;
    if (ff) {
      document.getElementById('gallery').src = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&sgallery=" + document.cal.sgallery.value;
    }
    else {
      document.gallery.location.href = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&sgallery=" + document.cal.sgallery.value;
    }
  }
}

function blog_gallery() {

  stop_slideshow();

  document.cal.spage.value = 1;

  list = document.getElementById('sgallerylst').options;
  idx = document.getElementById('sgallerylst').selectedIndex;

  sgallery = list[idx].value;

  document.cal.sgallery.value = sgallery;

  if (ff) {
     document.getElementById('gallery').src = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&sgallery=" + sgallery;
  }
  else {
     document.gallery.location.href = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&sgallery=" + sgallery;
  }
}

function nextpage() {

  stop_slideshow();

  if (parseInt(document.cal.lastpage.value) == 0) {
    document.cal.spage.value = parseInt(document.cal.spage.value) + 1;
   
    if (ff) {
       document.getElementById('gallery').src = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value+ "&sgallery=" + document.cal.sgallery.value;
    }
    else {
       document.gallery.location.href = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&sgallery=" + document.cal.sgallery.value;
    }
  }
}

function gotopage(p,r,c) {

  stop_slideshow();

  document.cal.spage.value = p;
  if (ff) {
    document.getElementById('gallery').src = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&rows=" + r + "&cols=" + c + "&sgallery=" + document.cal.sgallery.value;
  }
  else {
    document.gallery.location.href = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + "&sig=" + document.cal.sig.value + "&rows=" + r + "&cols=" + c + "&sgallery=" + document.cal.sgallery.value;
  }
}

function activate_tab(tab) {
  prefurl = "";
  
  if (tab == 'forward') {
    prefurl = "prefs.php?pref=" + tab;
    showAddButton();
    showRemButton();
  }
  if (tab == 'receive') {
    prefurl = "prefs.php?pref=" + tab;
    hideAddButton();
    showRemButton();
  }     
  if (tab == 'editor') {
    prefurl = "editor_prefs.php";
    hideAddButton();
    hideRemButton();
  }
  if (tab == 'setup') {
    prefurl = "setup_prefs.php";
    hideAddButton();
    hideRemButton();
  }

  if (ff) {
    document.getElementById('prefs').src = prefurl;
  }
  else {
    document.prefs.location.href = prefurl;
  }
}

function add_to_favorites_list (moid, userid, nickname) {

    var defaultSelected = false;
    var selected = false;

    var optionName = new Option(nickname, userid, defaultSelected, selected);

    var list = document.getElementById('favorites_list');

    for (var Current=0;Current < list.options.length;Current++) {        
        if (list.options[Current].value == userid) {
           // Item is already part of the list
           return;
        }
    }
    var length = list.options.length;
    list.options[length] = optionName;
}

function set_comment_ind (mid, cid) {
   ci = document.getElementById('ci_' + cid);
   if (ci) {
      ci.src = 'images/comment_border.gif';
   }

}

function reloadMLog (rows, cols, resetpic) {
  if (ff) {
    document.getElementById('gallery').src = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + '&rows=' + rows + '&cols=' + cols;
  }
  else {
    document.gallery.location.href = "content.php?spage=" + document.cal.spage.value + "&suser=" + document.cal.suser.value + "&sdate=" + document.cal.sdate.value + '&rows=' + rows + '&cols=' + cols;
  }
  
  if (resetpic == 1) {

     var pic = '<img title="Toon foto op ware grootte" id=picview border=0 width=242 src="images/spacer.gif">';

     parent.document.all['vidview_container'].innerHTML = "";
     parent.document.all['picview_container'].innerHTML = pic;  
     parent.document.all['picview'].src = 'images/spacer.gif';
  
     parent.document.getElementById('sel_message_id').value = "";
     parent.document.getElementById('sel_cid_id').value = "";
     parent.document.getElementById('sel_user').value = "";
     parent.document.getElementById('pictext').innerHTML = "";

     if (parent.document.getElementById('sel_postedby')) parent.document.getElementById('sel_postedby').innerHTML = "";  
     if (parent.document.getElementById('sel_country')) parent.document.getElementById('sel_country').innerHTML = "";
     if (parent.document.getElementById('sel_timestamp')) parent.document.getElementById('sel_timestamp').innerHTML = "";
     if (parent.document.getElementById('sel_atavar')) parent.document.getElementById('sel_atavar').src = 'images/spacer.gif';
  }
}

function showwarning()
{
   alert ('You need to login first');
}

function sel_gallery ()
{
   document.galleries.submit();
}

var atavarWin   = 0;
var prefWin     = 0;
var commentsWin = 0;
var addFavWin   = 0;
var playWin     = 0;
var addTextWin  = 0;
var delPicWin   = 0;
var playMMSWin  = 0;
var emailMsgWin = 0;
var calendarWin = 0;
var picWin      = 0;
var galleryWin  = 0;
var rssFeedWin  = 0;

function showrealsize()
{
   fname = document.all['picview'].src;

   if (fname.indexOf('spacer') != -1 || fname.indexOf('audio') != -1) {
      return;
   }

   if(picWin) {
      if(!picWin.closed) picWin.close();
   }
   picWin = window.open(fname,'picture','scrollbars=yes,resizable=yes,status=no,width=400,height=400,left=100,top=100');
}

function comments()
{
   if(commentsWin) {
      if(!commentsWin.closed) commentsWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select a MMS first');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   cid = document.getElementById('sel_cid_id').value;
   comments_url = 'comments.php?message_id=' + mid + '&cid=' + cid;
   
   commentsWin = window.open(comments_url,'','scrollbars=yes,status=no,width=350,height=600,left=100,top=100');
   if ((document.window != null) && (!commentWin.opener)) commentWin.opener = document.window;   
}

function show_comments(mid,cid)
{
   if(commentsWin) {
      if(!commentsWin.closed) commentsWin.close();
   }

   comments_url = 'comments.php?message_id=' + mid + '&cid=' + cid + '&showpic=y';
   
   commentsWin = window.open(comments_url,'','scrollbars=yes,status=no,width=350,height=600,left=100,top=100');
   if ((document.window != null) && (!commentWin.opener)) commentWin.opener = document.window;   
}

function emailmsg()
{
   if(emailMsgWin) {
      if(!emailMsgWin.closed) emailMsgWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select a MMS first');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   emailmsg_url = 'emailmsg.php?messageid=' + mid;
   
   emailMsgWin = window.open(emailmsg_url,'','scrollbars=no,status=no,width=400,height=270,left=100,top=100');
   if ((document.window != null) && (!emailMsgWin.opener)) emailMsgWin.opener = document.window;
}

function mmssounds()
{
   if(playWin) {
      if(!playWin.closed) playWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select a MMS first');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   mmssounds_url = 'mmssounds.php?messageid=' + mid;
   
   playWin = window.open(mmssounds_url,'','scrollbars=auto,status=no,width=400,height=270,left=100,top=100');
   if ((document.window != null) && (!playWin.opener)) playWin.opener = document.window;
}

function addfav()
{
   if(addFavWin) {
      if(!addFavWin.closed) addFavWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select your MMS first');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   addfav_url = 'addfav.php?messageid=' + mid;
   
   addFavWin = window.open(addfav_url,'','scrollbars=no,status=no,width=400,height=270,left=100,top=100');
   if ((document.window != null) && (!addFavWin.opener)) addFavWin.opener = document.window;   
}

function addfav()
{
   if(addFavWin) {
      if(!addFavWin.closed) addFavWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select your MMS first');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   addfav_url = 'addfav.php?messageid=' + mid;
   
   addFavWin = window.open(addfav_url,'','scrollbars=no,status=no,width=400,height=270,left=100,top=100');
   if ((document.window != null) && (!addFavWin.opener)) addFavWin.opener = document.window;   
}

function addtext(cols,rows)
{
   if(addTextWin) {
      if(!addTextWin.closed) addTextWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select your MMS first');
      return;
   }

   var $gif = new String (document.getElementById('addtext_icon').src);
   if ($gif.indexOf('inactive') != -1) {
      alert ('Je kunt alleen tekst toevoegen aan je eigen MMS berichten als je ingelogd bent');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   cid = document.getElementById('sel_cid_id').value;

   addtext_url = 'addtext.php?messageid=' + mid + '&cid=' + cid + '&rows=' + rows + '&cols=' + cols;
   
   addTextWin = window.open(addtext_url,'','scrollbars=no,status=no,width=400,height=270,left=100,top=100');
   if ((document.window != null) && (!addTextWin.opener)) addTextWin.opener = document.window;   
}

function delpic(cols,rows)
{
   if(delPicWin) {
      if(!delPicWin.closed) delPicWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select your MMS first');
      return;
   }

   var $gif = new String (document.getElementById('delpic_icon').src);
   if ($gif.indexOf('inactive') != -1) {
      alert ('Je kunt alleen je eigen MMS berichten verwijderen als je ingelogd bent');
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   cid = document.getElementById('sel_cid_id').value;

   delpic_url = 'delpic.php?messageid=' + mid + '&cid=' + cid + '&rows=' + rows + '&cols=' + cols;
   
   delPicWin = window.open(delpic_url,'','scrollbars=no,status=no,width=400,height=270,left=100,top=100');
   if ((document.window != null) && (!delPicWin.opener)) delPicWin.opener = document.window;   
}

function rssfeedig()
{
   if(rssFeedWin) {
      if(!rssFeedWin.closed) rssFeedWin.close();
   }

   if (document.getElementById('sig').value == "") {
      alert ('No community chosen');
      return;
   }
   sig = document.getElementById('sig').value;
   rssfeed_url = 'http://www.mofoto.nl/cgi-bin/genrssig.pl?igid=' + sig;
   
   rssFeedWin = window.open(rssfeed_url,'','scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,width=600,height=600,left=100,top=100');
   if ((document.window != null) && (!rssFeedWin.opener)) rssFeedWin.opener = document.window;   
}


function rssfeed()
{
   if(rssFeedWin) {
      if(!rssFeedWin.closed) rssFeedWin.close();
   }

   if (document.getElementById('sel_user').value == "") {
      alert ('Select your MMS first');
      return;
   }
   suser = document.getElementById('sel_user').value;
   rssfeed_url = 'http://www.mofoto.nl/cgi-bin/genrss.pl?userid=' + suser;
   
   rssFeedWin = window.open(rssfeed_url,'','scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,width=600,height=600,left=100,top=100');
   if ((document.window != null) && (!rssFeedWin.opener)) rssFeedWin.opener = document.window;   
}

function calendar()
{
   if(calendarWin) {
      if(!calendarWin.closed) calendarWin.close();
   }

   sdate = document.getElementById('sdate').value;
   suser = document.getElementById('suser').value;
   slog  = document.getElementById('slog').value;
   
   calendar_url = 'calendar.php?sdate=' + escape(sdate) + "&suser=" + suser + "&slog=" + slog;
   
   calendarWin = window.open(calendar_url,'','scrollbars=no,status=no,width=200,height=250,left=100,top=100');
   if ((document.window != null) && (!calendarWin.opener)) calendarWin.opener = document.window;   
}

function playmms()
{
   if(playMMSWin) {
      if(!playMMSWin.closed) playMMSWin.close();
   }

   if (document.getElementById('sel_message_id').value == "") {
      alert ('Select a multipart MMS first');
      return;
   }

   var gif = new String (document.getElementById('playmms_icon').src);
   if (gif.indexOf('spacer') != -1) {
      return;
   }
   
   mid = document.getElementById('sel_message_id').value;
   playmms_url = 'playmms.php?messageid=' + mid;
   
   playMMSWin = window.open(playmms_url,'','scrollbars=no,status=no,width=400,height=400,left=100,top=100');
   if ((document.window != null) && (!playMMSWin.opener)) playMMSWin.opener = document.window;   
}

function mlog_comments(mid)
{
   parent.document.getElementById('sel_message_id').value = mid;
   parent.comments();
}

function addpref()
{
   if(prefWin) {
      if(!prefWin.closed) prefWin.close();
   }

   if (preftab == "forward") {
      prefWin = window.open('addpreffwd.php?action=add','','scrollbars=no,status=no,width=400,height=300,left=100,top=100');
   }
   else {
      prefWin = window.open('prefrcv.php?action=add','','scrollbars=no,status=no,width=400,height=300,left=100,top=100');
   }
   if ((document.window != null) && (!prefWin.opener)) prefWin.opener = document.window;   
}

function modpref(id,name,email) {
   modurl = "addpreffwd.php?prefid=" + id + "&name=" + escape(name) + "&email=" + escape(email);
   
   if(prefWin) {
      if(!prefWin.closed) prefWin.close();
   }

   if (preftab == "forward") {
      prefWin = window.open(modurl,'','scrollbars=no,status=no,width=400,height=300,left=100,top=100');
   }
   if ((document.window != null) && (!prefWin.opener)) prefWin.opener = document.window;   
}

function rempref()
{
   document.prefs.action.value = "delete";
   document.prefs.submit();
}

function addgallery()
{
   if(galleryWin) {
      if(!galleryWin.closed) galleryWin.close();
   }

   galleryWin = window.open('addgallery.php','','scrollbars=no,status=no,width=400,height=300,left=100,top=100');

   if ((document.window != null) && (!galleryWin.opener)) galleryWin.opener = document.window;   
}

function modgallery()
{
   if(galleryWin) {
      if(!galleryWin.closed) galleryWin.close();
   }
   
   list = document.getElementById('sgallerylst').options;
   idx = document.getElementById('sgallerylst').selectedIndex;

   id = list[idx].value;
   
   if (!id) {
      alert ('Geen gallery geselecteerd');
      return;
   }
   gallery_url = "addgallery.php?sgallery=" + id;

   galleryWin = window.open(gallery_url,'','scrollbars=no,status=no,width=400,height=300,left=100,top=100');

   if ((document.window != null) && (!galleryWin.opener)) galleryWin.opener = document.window;   

}

function remgallery()
{
   document.galleries.action.value = "delete";
   document.galleries.submit();
}

function newpicture()
{
   if(atavarWin) {
      if(!atavarWin.closed) atavarWin.close();
   }

   atavarWin = window.open('newpicture.php','','scrollbars=no,status=no,width=400,height=300,left=100,top=100');
   if ((document.window != null) && (!atavarWin.opener)) atavarWin.opener = document.window;   
}

function uploadatavar() {
  if (ff) {
    document.getElementById('atavar').src = "upload_atavar.php";
  }
  else {
    document.atavar.location.href = "upload_atavar.php";
  }
}

function selectatavar() {
  if (ff) {
    document.getElementById('atavar').src = "atavars.php";
  }
  else {
    document.atavar.location.href = "atavars.php";
  }
}

function showusers(srange,spage) {
  if (ff) {
    document.getElementById('users').src = "users.php?srange=" + srange + "&spage=" + spage;
  }
  else {
    document.users.location.href = "users.php?srange=" + srange + "&spage=" + spage;
  }
}
