var isLeapYear = 0;
var year = "";

function stateChecker() 
{   
//	document.myForm.timerange[2].checked=true;
return true;
}

function checkFromMonth() 
{   
	var selIndex = document.myForm.frMonth.selectedIndex;
	if(selIndex == 1) 
	{
		year=document.myForm.frYear.options[document.myForm.frYear.selectedIndex].value ;
		var num = leap();
		if(num == 0)
		{
			if(document.myForm.frDay.selectedIndex > 27)
			{
				document.myForm.frDay.selectedIndex = 27;
			}
			document.myForm.frDay.options[30] =null;
			document.myForm.frDay.options[29] =null;
			document.myForm.frDay.options[28] =null;
		}
		else
		{
			if(document.myForm.frDay.selectedIndex > 28)
			{
				document.myForm.frDay.selectedIndex = 28;
			}
			document.myForm.frDay.options[30] =null;
			document.myForm.frDay.options[29] =null;
			if(document.myForm.frDay.options[28] == null)
			{
				document.myForm.frDay.options[28] = new Option("29","29");
			}
		}
	}
	else if(selIndex == "3" || selIndex == "5" || selIndex == "8" || selIndex == "10") 
	{
		if(document.myForm.frDay.selectedIndex == 30)
		{
			document.myForm.frDay.selectedIndex = 29;
		}
		checkFebFr();
		document.myForm.frDay.options[30] =null;
	}
	else
	{
		checkFebFr();
		if (document.myForm.frDay.options[30] == null)
		{
			document.myForm.frDay.options[30] = new Option("31","31");
		}
	}
	
}


function checkFebFr() 
{ 
	if(document.myForm.frDay.options[28] ==null)
	{
		document.myForm.frDay.options[28] = new Option("29","29");
	}
	if(document.myForm.frDay.options[29] ==null)
	{
		document.myForm.frDay.options[29] = new Option("30","30");
	}

}

function checkFebTo() 
{ 
	if(document.myForm.toDay.options[28] ==null)
	{
		document.myForm.toDay.options[28] = new Option("29","29");
	}
	if(document.myForm.toDay.options[29] ==null)
	{
		document.myForm.toDay.options[29] = new Option("30","30");
	}
}

function checkFromLeapYear() 
{ 
	if((document.myForm.frMonth.selectedIndex == 1) && (document.myForm.frDay.selectedIndex == 28))
	{
		document.myForm.frDay.selectedIndex = 27;
					
	}
	checkFromMonth();	
}

function checkToLeapYear() 
{ 
	if((document.myForm.toMonth.selectedIndex == 1) && (document.myForm.toDay.selectedIndex == 28))
	{
		document.myForm.toDay.selectedIndex = 27;
	}
	checkToMonth();
}

function checkDate() 
{   	
	checkFromMonth();
}


function leap() 
{
        checkYear(year);
        if (isLeapYear == 0)
          // "not a leap year.";
          return 0
        else
          // "a leap year.";
          return 1 ;
}


function checkYear(y) 
{
    if (y%4 == 0) 
	{
        isLeapYear = 1;
        if (y%100 == 0) 
		{
            isLeapYear = 0;
            if (y%400 == 0) 
			{
                isLeapYear = 1;
            }
        }
    }
    else 
	{ 
		isLeapYear = 0; 
	}
}
