Non sono ferratissimo in javasvript e, comunque, bisognerebbe vedere anche l'html a contorno.