Double Elimination Tournament Javascript Code