Java Script Beginner the i RegExp

Hi!

Can you help me to understand something?

I have this code that was suplied on the internet and it´s taking time
to me understand.

This is a part of the code:

function navBarInit() {

var menu = new Array();
var layer, norm, high, dmmy;
var last;
var width;
var on, off;
var i, j, x, y, z;
var link;

if (!isMinNS4 && !isMinIE4)
return;

if (isMinNS4) {
origWidth = window.innerWidth;
origHeight = window.innerHeight;
}
window.onresize = navBarReload;

if (navBarMenuWidth < navBarHeaderWidth)
navBarMenuWidth = navBarHeaderWidth;

navBarBuild();
moveLayerTo(navBar, navBarX, navBarY);
showLayer(navBar);

x = 0;
y = 0;
i = 0;
while ((layer = getLayer(“menu” + (i + 1), window)) != null) {

width = navBarMenuWidth;
if (i == navBarMenus.length - 1)
  width = navBarWidth - x;


menu[i] = layer;
moveLayerTo(layer, x, y);


z = 0;
j = 0;
while ((layer = getLayer("item" + (i + 1) + "_" + (j + 1), menu[i])) != null) {


  norm = layer;
  moveLayerTo(norm, 0, z);
  clipLayer(norm, navBarBorderWidth, navBarBorderWidth,
            width - navBarBorderWidth,
            getHeight(norm) - navBarBorderWidth);
  if (isMinNS4 && j &gt; 0)
    layer.visibility = "inherit";
  else
    showLayer(norm);


  high = getLayer("high" + (i + 1) + "_" + (j + 1), menu[i]);
  moveLayerTo(high, 0, z);
  clipLayer(high, navBarBorderWidth, navBarBorderWidth,
            width - navBarBorderWidth,
            getHeight(norm) - navBarBorderWidth);
  hideLayer(high);


  dmmy = getLayer("dmmy" + (i + 1) + "_" + (j + 1), menu[i]);
  moveLayerTo(dmmy, 0, z);
  clipLayer(dmmy, 0, 0, width, getHeight(norm));
  if (j == 0)
    menu[i].high = high;
  else {
    dmmy.high = high;
    dmmy.onmouseover = navBarItemOn;
    dmmy.onmouseout  = navBarItemOff;
  }
  link = navBarMenus[i][j * 2 + 1];
  if (link != "") {
    if (isMinNS4) {
      dmmy.document.link = link;
      dmmy.document.onmousedown = navBarItemGo;
    }
    if (isMinIE4) {
      dmmy.link = link;
      dmmy.onmousedown = navBarItemGo;
    }
  }


  z += getHeight(norm) - navBarBorderWidth;
  if (j == 0)
    off = z + navBarBorderWidth - 1;
  on = z + navBarBorderWidth;
  j++;
}
x += navBarHeaderWidth - navBarBorderWidth;


menu[i].offWidth  = navBarHeaderWidth;
menu[i].offHeight = off + 1;
menu[i].onWidth   = width;
menu[i].onHeight  = on;
menu[i].onmouseover = navBarMenuOn;
menu[i].onmouseout  = navBarMenuOff;
clipLayer(menu[i], 0, 0, menu[i].offWidth, menu[i].offHeight);


showLayer(menu[i]);
i++;

}

navBarHeight = menu[i - 1].offHeight;

menu[i - 1].onmouseover = null;
menu[i - 1].onmouseout  = null;

clipLayer(menu[i - 1], 0, 0, menu[i - 1].onWidth, menu[i - 1].offHeight);

clipLayer(navBar, 0, 0, navBarWidth, menu[0].offHeight);

if (navBarTrackX || navBarTrackY) {
navBarScroll();
if (isMinNS4)
setInterval(‘navBarScroll()’, 20);
if (isMinIE4)
window.onscroll = navBarScroll;
}
}

The trouble is that i don’t see when i is a RegExp or i is a var in the code
just renaming the i var to another name like vari make´s the code not
work!!

I have take the time to see if there’s a object or something that i could
mean other than a RegExp or a simple var but i haven´t across at souch information!!!

If it´s not a RegExp why when i change the name of the var called i it just
stop working???

It just don´t make sense to me!!!

In Regular Expressions i means that the pattern matching is case insensitive and g means that the matching is global.

The variable i is an integer, that gets incremented during the while loop. i is used both to track where you are in the “while” loop, and is also used as an index to extract a specific value from an array, for example if i = 2, then menu[i] refers to the third value of the “menu” array (array counting starts at zero).

in a regular expression statement, “i” means that the search should be case insensitive

Ok! i see it now.

And i have to say that i t’s a mean thing to do that becuse the site was advertising that you could get the scripts and rearenge and learn from it.

So… Why do that??

Thank you all for this help!!

Regards.