/*
Copyright 2006 Andrew Rader

This file is part of Fancy Categories

 Fancy Categories 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.

 Fancy Categories 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 Fancy Categories; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function fancat_click( e ) {
    if( e.target ) {
        src = e.target;
    }
    else {
        src = window.event.srcElement;
    }

    srcList = src.parentNode;
    childList = null;

    for( i = 0; i < srcList.childNodes.length; i++ ) {
        if( srcList.childNodes[i].nodeName.toLowerCase() == 'ul' ) {
            childList = srcList.childNodes[i];
        }
    }

    if( childList != null ) {
        if( src.getAttribute( "rel" ) == "hide" ) {
            childList.style.display = "none";
            src.setAttribute("rel","show");
            src.src = fancat_img_url + "expand.gif"
        }
        else {
            childList.style.display = "";
            src.setAttribute("rel","hide");
            src.src = fancat_img_url + "collapse.gif"
        }
    }

    if( e.preventDefault ) {
        e.preventDefault();
    }

    return false;
}
