I'm not shure if this would fix the problem,but I found a 'problem' in one of my functions. I guess not everything worked as expected.
So , now I need help with this one,to see if this will fix the whole pathfinding system.
Here's the function:
Code:

function tile_to_pos(tile)
{
var counter1 = 1;
var tmp1;
tmp1 = tile;
while(tmp1 > 0)
{
tmp1 -= glength;
counter1 += 1;
}
if(tmp1 < 0)
{
tmp1 += glength;
counter1 -= 1;
}
ttp.x = counter1;
ttp.y = tmp1;
}


This function takes a tile number and divides it by 50 a few times until the number reaches 0 or goes below. This way I can get the Y value of the nodes position on the grid and use a variable to pass it. Than , the remaining number is passed in the variable as X value. After this I can calculate the node possition,to set the adjacent nodes and calculate the h value. When it reaches one of the edges of the grid however the script returns incorect values and calculates incorect heuristics value,so from this point the whole pathfinding isnt working.
I hope this is the problem. I need help fast 02h:40min. till deadline I have to find a new way to calculate the X and Y pos. of a tile (eg. 3-rd row,2-nd column in the grid)

PS.: Sorry if the explanation is more than needed but I hope even not so experienced people could think on that with me. I really need help.