/*
This file is part of Thomas Bley's moregroupware webmail2/calendar2/admin2 module. (tb-mgw)

More information:
-----------------

Simple Groupware Solutions Thomas Bley
Fichtenstr. 23
Germany, 85640 Putzbrunn

Contact:
--------

info@simple-groupware.de

http://www.simple-groupware.de


Copyright 2002-2003 Thomas Bley
tb-mgw is distributed under the terms of the GNU General Public License 

tb-mgw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

tb-mgw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with tb-mgw; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// Top
// Moregroupware.org

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}


function printit() {

  if (parent.frames.rightframe && parent.frames.rightframe.frames.mailview) {
	parent.frames.rightframe.frames.mailview.printsubmit();
  } else {
    window.status=lang_top_nomailinview;
  }
}

function reply() {
  if (parent.frames.rightframe && parent.frames.rightframe.frames.maillist) {
	parent.frames.rightframe.frames.maillist.replysubmit();
  }
}

function reply2() {
  if (parent.frames.rightframe && parent.frames.rightframe.frames.maillist) {
	parent.frames.rightframe.frames.maillist.replysubmit2();
  }
}

function forwardit() {
  if (parent.frames.rightframe && parent.frames.rightframe.frames.maillist) {
	parent.frames.rightframe.frames.maillist.forwardsubmit();
  }
}

function forwardit2() {
  if (parent.frames.rightframe && parent.frames.rightframe.frames.maillist) {
	parent.frames.rightframe.frames.maillist.forward2submit();
  }
}

function deleteit() {
  if (parent.frames.rightframe && parent.frames.rightframe.frames.maillist) {
	parent.frames.rightframe.frames.maillist.deletesubmit();
  }
}

function change_flag(value) {
  if (value!="" && parent.frames["rightframe"] && parent.frames.rightframe.frames["maillist"]) {
	parent.frames.rightframe.frames.maillist.change_flag(value);
  }
}

// var is_sidebar_mini = false;
var is_treeframe_mini = false;
var is_top_mini = false;

var na_settings3_over = "templates/default/media/n_o_settings6.gif";
var na_settings3_img = "templates/default/media/n_settings6.gif";

var na_settings4_over = "templates/default/media/n_o_settings5.gif";
var na_settings4_img = "templates/default/media/n_settings5.gif";

var na_settings7_over = "templates/default/media/n_o_settings7.gif";
var na_settings7_img = "templates/default/media/n_settings7.gif";

function modify_sidebar() {

    if (test2=parent.document.getElementById('frameset2')) {
      if (!is_sidebar_mini) {
        if (is_treeframe_mini) {
          test2.cols="0,0,*";
        } else {
          test2.cols="0,"+width_treeframe+",*";
        }
        is_sidebar_mini = true;
        
        if (test3=document.getElementById('na_settings3')) {
          test3.alt = lang_max_sidebar;
          test3.title = lang_max_sidebar;
          test3.src = "templates/default/media/n_settings3.gif";
          na_settings3_over = "templates/default/media/n_o_settings3.gif";
          na_settings3_img = "templates/default/media/n_settings3.gif";
        }
        
      } else {
        if (is_treeframe_mini) {
          test2.cols=width_sidebar+",0,*";
        } else {
          test2.cols=width_sidebar+","+width_treeframe+",*";
        }
        is_sidebar_mini = false;

        if (test3=document.getElementById('na_settings3')) {
          test3.alt = lang_min_sidebar;
          test3.title = lang_min_sidebar;
          test3.src = "templates/default/media/n_settings6.gif";
          na_settings3_over = "templates/default/media/n_o_settings6.gif";
          na_settings3_img = "templates/default/media/n_settings6.gif";
        }

      }
    }
}

function modify_top() {

    if ((test2=parent.document.getElementById('frameset3')) && (test4=document.getElementById('top_bar')) && parent.treeframe.navigator.family != "opera") {
      if (!is_top_mini) {
        test4.style.top="0px";
        test2.rows="19,*";

        is_top_mini = true;

        if (test3=document.getElementById('na_settings7')) {
          test3.alt = lang_max_top;
          test3.title = lang_max_top;
          test3.src = "templates/default/media/n_settings8.gif";
          na_settings7_over = "templates/default/media/n_o_settings8.gif";
          na_settings7_img = "templates/default/media/n_settings8.gif";
        }

      } else {
        if (parent.document.topheight) {
          topheight=parent.document.topheight
        } else {
          topheight=67;
        }
        test4.style.top="47px";
        test2.rows=topheight+",*";
        is_top_mini = false;

        if (test3=document.getElementById('na_settings7')) {
          test3.alt = lang_min_top;
          test3.title = lang_min_top;
          test3.src = "templates/default/media/n_settings7.gif";
          na_settings7_over = "templates/default/media/n_o_settings7.gif";
          na_settings7_img = "templates/default/media/n_settings7.gif";
        }

      }
    }
}

function putimg(img,imgfile) {
  if (test3=document.getElementById(img)) {
    test3.src=imgfile;
  }
}

function modify_treeframe() {
    if (test2=parent.document.getElementById('frameset2')) {

      if (!is_treeframe_mini) {
        if (is_sidebar_mini) {
          test2.cols="0,0,*";
        } else {
          test2.cols=width_sidebar+",0,*";
        }
        is_treeframe_mini = true;
        
        if (test3=document.getElementById('na_settings4')) {
          test3.alt = lang_max_tree;
          test3.title = lang_max_tree;
          test3.src = "templates/default/media/n_settings4.gif";
          na_settings4_over = "templates/default/media/n_o_settings4.gif";
          na_settings4_img = "templates/default/media/n_settings4.gif";
        }
        
      } else {
        if (is_sidebar_mini) {
          test2.cols="0,"+width_treeframe+",*";
        } else {
          test2.cols=width_sidebar+","+width_treeframe+",*";
        }
        is_treeframe_mini = false;

        if (test3=document.getElementById('na_settings4')) {
          test3.alt = lang_min_tree;
          test3.title = lang_min_tree;
          test3.src = "templates/default/media/n_settings5.gif";
          na_settings4_over = "templates/default/media/n_o_settings5.gif";
          na_settings4_img = "templates/default/media/n_settings5.gif";
        }
        
      }
    }
}

MM_preloadImages(
myimgpathmaster+'/n_mini_reply.gif',
myimgpathmaster+'/n_o_mini_reply.gif',
myimgpathmaster+'/n_mini_new.gif',
myimgpathmaster+'/n_o_mini_new.gif',
myimgpathmaster+'/n_mini_print.gif',
myimgpathmaster+'/n_o_mini_print.gif',
myimgpathmaster+'/n_mini_delete.gif',
myimgpathmaster+'/n_o_mini_delete.gif',
myimgpathmaster+'/n_mini_forward.gif',
myimgpathmaster+'/n_o_mini_forward.gif',
myimgpathmaster+'/n_mini_forward2.gif',
myimgpathmaster+'/n_o_mini_forward2.gif',
myimgpathmaster+'/n_mini_forward2.gif',
myimgpathmaster+'/n_o_mini_forward2.gif',
myimgpathmaster+'/n_settings.gif',
myimgpathmaster+'/n_o_settings.gif',
myimgpathmaster+'/n_settings2.gif',
myimgpathmaster+'/n_o_settings2.gif',
myimgpathmaster+'/n_settings3.gif',
myimgpathmaster+'/n_o_settings3.gif',
myimgpathmaster+'/n_settings4.gif',
myimgpathmaster+'/n_o_settings4.gif',
myimgpathmaster+'/n_settings5.gif',
myimgpathmaster+'/n_o_settings5.gif',
myimgpathmaster+'/n_settings6.gif',
myimgpathmaster+'/n_o_settings6.gif',
myimgpathmaster+'/n_settings7.gif',
myimgpathmaster+'/n_o_settings7.gif',
myimgpathmaster+'/n_settings8.gif',
myimgpathmaster+'/n_o_settings8.gif',
myimgpathmaster+'/n_mini_receive.gif',
myimgpathmaster+'/n_o_mini_receive.gif',
myimgpathmaster+'/n_mini_logout.gif',
myimgpathmaster+'/n_o_mini_logout.gif'
);

