function daysInMonth(month,year) {
var m = [31,28,31,30,31,30,31,31,30,31,30,31];
if (month != 2) return m[month - 1];
if (year%4 != 0) return m[1];
if (year%100 == 0 && year%400 != 0) return m[1];
return m[1] + 1;
} 

function chk_null_submit_early()
{
	//alert('hi');
	 var chkreturn = 1;
	 var index=0;
	 var text="";
	 var chkRoomtype=0;
	
	
			if(document.getElementById('fromdate').value.length !=0)
			{
				//alert('chk rerurn'+chkreturn);
				var datefrom = document.getElementById('fromdate').value;
				var dateto = document.getElementById('todate').value;
				var fdate = datefrom.substr(0,2);
				var fmonth = datefrom.substr(3,2);
				var fyear = datefrom.substr(6,4);
				
				var tdate = dateto.substr(0,2);
				var tmonth = dateto.substr(3,2);
				var tyear = dateto.substr(6,4);
				var totalyear = parseInt(tyear)-parseInt(fyear);
			
			     //alert(parseInt(tdate));
				if(parseInt(tyear) < parseInt(fyear))
				{
					
					text = text+"<br><li>Please enter correct Check in period.";
					
				}
				else if(parseInt(tyear) == parseInt(fyear))
				{
					if(tmonth < fmonth)
					{
						
						text = text+"<br><li>Please enter correct Check in period.";
					
						
					}
					else if(tmonth == fmonth)
					{
						if(tdate < fdate)
						{
							
							text = text+"<br><li>Please enter correct Check in period.";		
								
						}
						else if(tdate == fdate)
						{
							text = text+"<br><li>Please enter correct Check in period.";
								
							
						}
						else
						{
							var total = parseInt(tdate) - parseInt(fdate);
							if(total >30)
							{
								text = text+"<br><li>Bookings can only be made for a maximum period of 30 days.";
							}
						}
						
					}
					else
					{
						if(tmonth-fmonth >1)
						{
							text = text+"<br><li>Bookings can only be made for a maximum period of 30 days.";
						}
						else
						{
						  var maxmonth = daysInMonth(fmonth,fyear);
						  var total1 = (parseInt(maxmonth) - fdate)+1;
						  var total = total1+parseInt(tdate);
						  if(total >30)
							{
								text = text+"<br><li>Bookings can only be made for a maximum period of 30 days.";
							}
						}
					}
					
					
				}
				else
				{
					if(tyear-fyear >1)
					{
						text = text+"<br><li>Bookings can only be made for a maximum period of 30 days.";
					}
					else
					{
					    if(tmonth-fmonth >1)
						{
							text = text+"<br><li>Bookings can only be made for a maximum period of 30 days.";
						}
						else
						{
						  var maxmonth = daysInMonth(fmonth,fyear);
						  var total1 = (parseInt(maxmonth) - fdate)+1;
						  var total = total1+parseInt(tdate);
						  if(total >30)
							{
								text = text+"<br><li>Bookings can only be made for a maximum period of 30 days.";
							}
						}
					}
				}
				
				
			}
			
			
	if(text.length ==0)
	{
		document.getElementById('errorDiv').innerHTML = "";
		return true;
	}
	else
	{
		///alert(text);
		document.getElementById('errorDiv').innerHTML = "<left><font color='#CC3300'>"+text+"</font>";
		return false;
	}
	
}// JavaScript Document