//Function to get Yeara list
function getList() {
		var dt = new Date();
		var cDate = dt.getFullYear();
		for(var j=cDate;j > 1930;j--) {
			var opt1 = document.createElement("option");
			opt1.text=j;
			opt1.value = j;
			document.getElementById('dyear').options.add(opt1);
		}
		//
}

//Function to get days based on month
function getDays() {
		var rmonth="";
		rmonth= (document.getElementById('dmonth').value).rtrim();
		//rmonth.rtrim();
		//alert("a"+rmonth+"b");
	removedays();	
	if (rmonth==0 || rmonth=='Month') {
			document.getElementById('regi_response').innerHTML = "Select Month";
			document.getElementById('dmonth').focus();
			return false;
	} else {
				
			//removedays();
			if(rmonth == "1" || rmonth == "3" || rmonth == '5' || rmonth == "7" || rmonth == "8" || rmonth == "10" || rmonth == "12") {
				fundays(32);
				
			} else if(rmonth == "4" || rmonth == "6"  || rmonth == "9" || rmonth == "11" ) {
				fundays(31);
			}	else if(rmonth=="2"){
				getFebDays();
			}
		}
 }
 
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

// Function for Februry day	
		
function getFebDays() {
	var yr = document.getElementById('dyear').value;
	
	if((document.getElementById('dmonth').value).rtrim()=="2") {
		if(yr == 'Year' || yr =='' ) {
			removedays();
			fundays(29);
		} else {
			var lpDays = (((yr % 4 == 0) && ( (!(yr % 100 == 0)) || (yr % 400 == 0))) ? 30 : 29 );
			removedays();
			fundays(lpDays);
		}
	}
}

// Function to remove days 	
function removedays() {
	
	if(document.getElementById('ddate').options.length > 2) {
			for(var i = document.getElementById('ddate').options.length - 1; i >=1; i--) {
				document.getElementById('ddate').remove(i);
			}
		}
	}

// Function to display days	
function fundays(s) {
		for(var k=1;k < s;k++) {
				var opt = document.createElement("option");
				opt.text = k;
				opt.value = k;
				document.getElementById('ddate').options.add(opt);
		}
	
	}	