some changes. Added some javascript functions