how can i get which day of week month starts on from for given input of month and year?
You can get the day of the week by using the getDay function of the Date object.
To get the first of the month create a new Date object:
var year = "2012";
var month = "12";
var day = new Date(year + "-" + month + "-01").getDay();
// 6 - Saturday
console.log(day);
Since you count from 1 and Monday is the first day of the week you'll also have to do this:
day = (day===0) ? 7 : day