Substring In Javascript Using Parameters