
var helpers = {
  
  path : function(actual_path){ helpers.actual_path = actual_path; },
  
  replace_path : function(path){
    if (typeof path == 'string')
        return path.replace(/images\//g, helpers.actual_path + 'images/');
    else if (typeof path == 'object'){
    for (var i = 0; i < path.length; i++)
        path[i] = path[i].replace(/images\//g, helpers.actual_path + 'images/');
    }
    return path;
  },
    
  adaptation : function(){
    var valiables = [
        'blankImage',
        'arrowImageMain',
        'arrowImageSub' ];
    for (var i in valiables){
    if (window[ valiables[i] ])
        window[ valiables[i] ] = helpers.replace_path(window[ valiables[i] ]);
    }
    if (itemStyles){
      for (var i in itemStyles){
        if (itemStyles[i])
            itemStyles[i] = helpers.replace_path(itemStyles[i]);
      }
    }
    if (menuStyles){
      for (var i in menuStyles){
        if (menuStyles[i])
            menuStyles[i] = helpers.replace_path(menuStyles[i]);
      }
    }
  },
  
  search : function(){
      var links = maker.dom.get(document.body).get('a');
      for (var i = 0; i < links.length; i++){
        if (this === links[i]){
            var next = maker.xtree.tree[0]._next_;
            var steps = i;
            while (next){
                if (!steps){
                    var node = maker.dom.get('#tree-item-id-' + next).get('span')[0];
                    maker.tree.select(node);
                    maker.tree.search(node);
                    return false;
                }
                next = maker.xtree.tree[next]._next_;
                steps--;
            }
        }
      }
      return false;
  }, 
  
  disable : function(){
      maker.dom.get(document.body).get('a').map(function(node){
          node.onclick = helpers.search;
      });
  },
  
  cssmenu : function(){
    var html = '';
    /** fix bad templates :-( */
    if (typeof fontStyle == 'string') fontStyle = [fontStyle, fontStyle];
    menuItems = maker.xtree.exportTree('DeluxeMenu');
    applyItemStyles();
    if (menuItems.length){
       helpers.adaptation();
       maker.parameters.unload(window);
       html += '\n\n<!-- Start PureCSSMenu.com STYLE -->\n';
       html += '<style>\n#pcm{display:none;}\n' + createCSS().replace(/\s+^/, '') + '</style>\n';
       html += '<!-- End PureCSSMenu.com STYLE -->\n\n';
       html += '\n\n<!-- Start PureCSSMenu.com MENU -->\n';
       html += createHTML();
       html += '<a id="pcm" href="http://www.purecssmenu.com/">CSS Drop Down Menu by PureCSSMenu.com</a>\n';
       html += '<!-- End PureCSSMenu.com MENU -->\n\n\n\n';
       html += '<!-- (c) 2009, PureCSSMenu.com -->\n';
    }
    return html;
  }
    
};

