/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Geeklog 1.3                                                               |
// +---------------------------------------------------------------------------+
// | Commmon javascript functions                                              |
// |                                                                           |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2005,2006 by the following authors:                         |
// |                                                                           |
// |            Blaine Lang - blaine@portalparts.com                           |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | This program 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.                    |
// |                                                                           |
// | This program 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 this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+

// -------------------------------------------------------------------
// caItems(form object)
// Check All Items - generic function that can be used to check and un-check all items in a list
// Used in the Admin Lists - like on the moderation page
// -------------------------------------------------------------------
   function caItems(f) {  
       var n=f.elements.length;
       for (i=0;i<n; i++) {
           var field=f.elements[i];
           if (field.type == 'checkbox' && field.name.match("delitem")) {
                if (f.chk_selectall.checked) {
                    field.checked=true;
                } else {
                    field.checked=false;
                }
           }

       }
   }




// Basic function to show/hide (toggle) an element - pass in the elment id
    function elementToggle(id) {
        var obj = document.getElementById(id);
        if (obj.style.display == 'none') {
            obj.style.display = '';
        } else {
            obj.style.display = 'none';
        }
    }

// Basic function to show/hide an element - pass in the elment id and option.
// Where option can be: show or hide or toggle
    function elementShowHide(id,option) {
        var obj = document.getElementById(id);
        if (option == 'hide') {
            obj.style.display = 'none';
        } else if (option == 'show') {
            obj.style.display = '';
        } else if (option == 'toggle') {
            elementToggle(id);
        }
    }

// ツリーメニュー
//flag = false;
//function treeMenu(tName) {
//  tMenu = document.getElementById(tName);
//  if(tMenu) {
//    if(tMenu.style.display == 'none') tMenu.style.display = "block";
//    else tMenu.style.display = "none";
//  }
//}
theName="menu2=";                           //cookie名を変更
S_Array=new Array("treeMenu2");   //初めに表示するID名 ,"ID名" と増やします
//----------------------------------------
d_Array=S_Array;

function MyMenu_set(){
if(document.all)
menu_obj=document.all;
else
menu_obj=document.getElementsByTagName("div");
//for(i=0;i<menu_obj.length;i++){
//if(menu_obj[i].className=="display_none")
//menu_obj[i].style.display="none";
//}
 theCookie=document.cookie+";";
 start=theCookie.indexOf(theName);
if(start !=-1){
  end=theCookie.indexOf(";",start);
  theData=unescape(theCookie.substring(start+theName.length,end));
  d_Array=theData.match(/[^,]+/g);
}
if(d_Array=="all_none"){
  d_Array=new Array();
  return;
}
try {
 for(i=0;i<d_Array.length;i++){
   if(document.all){
document.all(d_Array[i]).style.display="block";
    }else{
document.getElementById(d_Array[i]).style.display="block";
    }
  }
}catch(e) {d_Array=new Array();}
}

function MyMenu(tName){

  j=0;
   if(document.all){
      tMenu=document.all(tName).style;
   }else{
      tMenu=document.getElementById(tName).style;
    }
if(tMenu.display=='none'){
  tMenu.display="block";
  for(i=0;i<d_Array.length;i++){if(tName==d_Array[i])j++;}
  if(!j)d_Array.push(tName);
}else{
  tMenu.display="none";
  for(i=0;i<d_Array.length;i++){if(tName==d_Array[i])j=i;}
  d_Array.splice(j, 1);
}
}
function MyMenu_close(){
  myData="";setDay=new Date();
 myData=(!d_Array.length)?"all_none":d_Array.join(",");
 setDay.setTime(setDay.getTime()+(1*1000*60*60*24));
document.cookie=theName+escape(myData)+";expires="+setDay.toGMTString();
}
function firstMenu(){
 setDay=new Date();myData="";
 d_Array=S_Array;
 myData=(!d_Array.length)?"all_none":d_Array.join(",");
 setDay.setTime(setDay.getTime()+(1*1000*60*60*24));
 document.cookie=theName+escape(myData)+";expires="+setDay.toGMTString();
location.reload(true);
}/* himajin.moo.jp */

onload=MyMenu_set;
onunload=MyMenu_close;

