// Firefox support for Netactiva24.com
// version 0.1 BETA!
// 2008-11-29
// Copyright (c) 2008, Fernando P. García
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Hello World", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          Firefox support for Netactiva24.com
// @namespace     http://develcuy.com/download/
// @description   Makes the site: Netactiva24.com compatible with Firefox
// @include       https://www.netactiva24.com/privado/*
// ==/UserScript==

// Check if jQuery's and jqURL's loaded
function netactiva24_wait() {
  if (typeof window.jQuery == 'undefined' || typeof window.jQuery.jqURL == 'undefined') {
    window.setTimeout(netactiva24_wait, 100);
  }
  else {
    netactiva24_init();
  }
}

// Wait for jQuery to load
netactiva24_wait();

function netactiva24_init() {
  if ($.jqURL.get('WCI') == 'WIMenu') {
    //~ $('span').css('display', 'block');
    // Identify Sub-menu Items
    $('table:first span').each(function(i) {
      $(this).attr({'class': 'MenuSub_'+ i +'_wrapper'});
    });
    // Browse menu items
    $('td.MenuMain').each(function(i) {
      // Remove not working onclick callback
      //~ $(this).attr({'onclick': 'alert(1)'});
      // Make sub-menu items appear (the jQuery way)
      $(this).click(function() {
        menu_item = '.MenuSub_'+ i +'_wrapper';
        if ($(menu_item).css('display') == 'block')
          item_display = 'none';
        else
          item_display = 'block';
        $(menu_item).css('display', item_display);
      });
    });
  };
}

