To put your code into the code tags use the # icon not the #i icon.
This should be in the javascript form not the dom and json form.
You don't identify array 1 or array 2 so I have to guess, but I think your problem is this function:
Code:
function pushForStack(newVal) {
CurUrl = newVal;
forstack.push(curUrl);
}
CurUrl = newVal; The capital makes this a different variable. Think it S/B
curUrl = newVal;