function  DatePicker(month,year,day){
	this.month = (month-1);
	this.year = year;
	this.day = day;
	this.f_month = (month-1);
	this.f_year = year;
	this.f_day = day;
	this.mainCnt = document.getElementById("theCal");
	this.titleCnt = document.getElementById("calTitle");
	//this.displayDP = displayDP;
	//this.next = doNext;
	//this.prev = doPrev;
	//this.getMonthName = getMonthName;
	//this.LastDayOfMonth = LastDayOfMonth;
	this.highlight = true;
	//this.setFdates = setFdates;
}

DatePicker.prototype.setFdates = function(y,m,d){
	this.f_year = y;
	this.f_month = m;
	this.f_day = d;
}

DatePicker.prototype.getMonthName = function(){
	switch(this.month){
	case 0:
		return 'January';
	break;
	case 1:
		return 'February';
	break;
	case 2:
		return 'March';
	break;
	case 3:
		return 'April';
	break;
	case 4:
		return 'May';
	break;
	case 5:
		return 'June';
	break;
	case 6:
		return 'July';
	break;
	case 7:
		return 'August';
	break;
	case 8:
		return 'September';
	break;
	case 9:
		return 'October';
	break;
	case 10:
		return 'November';
	break;
	case 11:
		return 'December';
	break;
	
	}
}
DatePicker.prototype.next = function(){
	if(this.month != 11){
		this.month = this.month + 1;
	}else{
		this.month = 0;
		this.year++;
	}
	this.displayDP();
}
DatePicker.prototype.prev = function(){
	if(this.month != 0){
		this.month = this.month - 1;
	}else{
		this.month = 11;
		this.year--;
	}
	this.displayDP();
}
DatePicker.prototype.LastDayOfMonth = function(){
        return(new Date((new Date(this.year, this.month+1,1))-1)).getDate();
}
DatePicker.prototype.displayDP = function(){

	
	//alert(this.month);
	var lastday = this.LastDayOfMonth();
	var fd = new Date(this.year,this.month,'1');
	var firstday = fd.getDate();
	var firstdow = fd.getDay();
	var curday = 1;
	var curdow = 0;
	//alert(firstday);
	//alert(firstdow);
	//alert(lastday);
	var html = '<tr>';
	//pre-fill beginning of month gap
	if(firstdow != 0){
		while(curdow != firstdow){
			html += '<td></td>';
			curdow++;
			//if end of week, end table row and start another
		}
	}
	while(curday != (lastday+1)){
		//write calendar block with day
		if(curday == this.f_day && this.month == this.f_month && this.year == this.f_year){
			html += '<td class="active" onclick="create_timeline(\'' + this.year + '\',\'' + (this.month+1) + '\',\'' + curday + '\'); dp.setFdates(\'' + this.year + '\',\'' + this.month + '\',\'' + curday + '\'); return false">' + curday + '</td>';
		}else{
			html += '<td onclick="create_timeline(\'' + this.year + '\',\'' + (this.month+1) + '\',\'' + curday + '\'); dp.setFdates(\'' + this.year + '\',\'' + this.month + '\',\'' + curday + '\'); return false">' + curday + '</td>';
		}
		//increment day of month & day of week
		curday++;
		curdow++;
		//if end of week, end table row and start another
		if(curdow == 7){
			curdow = 0;
			html += '</tr><tr>';
		}
	}
	if(curdow != 0){
		//fill ending of month gap
		while(curdow != 6){
			html+= '<td></td>';
			curdow++;
		}
	}
	html += '</tr>';
	
	//get month name
	var monthname = this.getMonthName();
	this.titleCnt.innerHTML = monthname + ' ' + this.year;
	html = '<table cellspacing="6"><colgroup span="7"></colgroup>' + html + '</table>';
	this.mainCnt.innerHTML = html;
	// calendar date click toggle active
		dateSelect();
		this.highlight = false;
}


