/*
  copyright (c) 2003 Jan-Klaas Kollhof
 
  This 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 software 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 software; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
*/


svgui = function(){
    var svgui = new Object();

    svgui.xmlns = "jan";
   
    svgui.getObjectByNode = function(node){
        function parseNames(n){
            if(n.hasAttributeNS(svgui.xmlns, "root")){
                return new Array(); //n.getAttributeNS(svgui.xmlns,"root")
            }else{
                var parentNames = parseNames(n.parentNode);
                if(n.hasAttributeNS(svgui.xmlns, "name")){
                    var name = n.getAttributeNS(svgui.xmlns, "name")
                    parentNames.push(name);
                    return parentNames;
                }else{
                    return parentNames;
                }
            }
        }
        var names = parseNames(node);
        var obj = window;
        for(var i=0; i<names.length; i++){
            obj = obj[names[i]];
        }
        return obj;
    }
    
    svgui.dispatchEvent = function(receiver, event){
        if(receiver){
            if(receiver.handleEvent){
                receiver.handleEvent(event);
            }
        }
    }
    
    return svgui;
}();