function currentMonth(){
	var d = new Date();
	var cd = d.getMonth();
	return cd;
}
function currentYear(){
	var d = new Date();
	var cd = d.getFullYear();
	return cd;
}
function currentDay(){
	var d = new Date();
	var cd = d.getDate();
	return cd;
}
function maxFeb(year){
	if ((year % 400 == 0) || (year % 4 == 0) && (!(year % 100 == 0)))
		return 29;
	else
		return 28;	
}
function maxDays(month,year){
	if (month==2) //February
		return maxFeb(year);
  	else if ((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10)  || (month == 12))
		return 31;
	else
		return 30;     
 }
function populateMonths(m){
	var selm = document.getElementById(m);
	selm.options[0] = new Option('Jan','01');
	selm.options[1] = new Option('Feb','02');
	selm.options[2] = new Option('Mar','03');
	selm.options[3] = new Option('Apr','04');
	selm.options[4] = new Option('May','05');
	selm.options[5] = new Option('Jun','06');
	selm.options[6] = new Option('Jul','07');
	selm.options[7] = new Option('Aug','08');
	selm.options[8] = new Option('Sep','09');
	selm.options[9] = new Option('Oct','10');
	selm.options[10] = new Option('Nov','11');
	selm.options[11] = new Option('Dec','12');
	selm.options[currentMonth()].selected="selected";
}
function populateDays(d){
	seld = document.getElementById(d);
	cd = currentDay() - 1;
	nr = maxDays(currentMonth()+1,currentYear());
	for(i=0;i<nr;i++){
		ziua = i+1;
		if(ziua < 10) ziua = "0" + ziua;
		seld.options[i]= new Option(ziua,ziua);
	}
	seld.options[cd].selected="selected";
}
function populateYears(y){
	sely = document.getElementById(y);
	var cy = currentYear();
	sely.options[0]= new Option(cy,cy);
	sely.options[1]= new Option(cy+1,cy+1);
	sely.options[2]= new Option(cy+2,cy+2);
}
function populateHours(h){
	selh = document.getElementById(h);
	k=-1;
	for (i=0;i<24;i++){
		j=i;
		if(j<10) j="0"+j;
		j1=j+":00";
		j2=j+":30";
		k++;
		selh.options[k] = new Option(j1,j1);
		k++;
		selh.options[k] = new Option(j2,j2);
	}
}
function populateForm(){
	populateMonths("_frommonth");
	populateDays("_fromday");
	populateYears("_fromyear");
	populateHours("_fromhour");
	populateMonths("_tomonth");
	populateDays("_today");
	populateYears("_toyear");
	populateHours("_tohour");
}
function resetDays(mo,da,ye){
	m = document.getElementById(mo);
	d = document.getElementById(da);
	d.options.length = 0;
	y = document.getElementById(ye);
	nr = maxDays(m.options[m.selectedIndex].value,y.options[y.selectedIndex].value);
	for(i=0;i<nr;i++){
		ziua = i+1;
		if(ziua < 10) ziua = "0" + ziua;
		d.options[i]= new Option(ziua,ziua);
	}
}
function createDate(m,d,y,time){
	//d = d+1;
	//if(d<10) d = "0"+d;
	return m+"/"+d+"/"+y+" "+time;
}
function verifyQuote(){
	var f = document.frmQuote;
	from_loc = f._pickup.options[f._pickup.selectedIndex].value;
	to_loc = f._dropoff.options[f._dropoff.selectedIndex].value;
	if(from_loc.length < 1){
		alert("Please select a pickup location");
		return false;
	}
	if(to_loc.length < 1){
		alert("Please select a drop off location");
		return false;
	}
	frommonth = f._frommonth.options[f._frommonth.selectedIndex].value;
	fromday = f._fromday.options[f._fromday.selectedIndex].value;
	fromyear = f._fromyear.options[f._fromyear.selectedIndex].value;
	fromtime = f._fromhour.options[f._fromhour.selectedIndex].value;
	
	tomonth = f._frommonth.options[f._tomonth.selectedIndex].value;
	today = f._today.options[f._today.selectedIndex].value;
	toyear = f._toyear.options[f._toyear.selectedIndex].value;
	totime = f._tohour.options[f._tohour.selectedIndex].value;
	
	fromdate = createDate(frommonth,fromday,fromyear,fromtime);
	todate = createDate(tomonth,today,toyear,totime);
	
	d1 = new Date(fromdate);
	d2= new Date(todate);
	
	//alert(d1+"/"+d2);
	
	if(d2<=d1){
		alert("Drop off date must be at least 30 min later then pick up date");
		return false;
	}
	return true;
}