function checkDate()
{
	 document.getElementById('error').innerHTML="";
 mnth = document.dateform.month.options[document.dateform.month.selectedIndex].value
 mnth = parseInt(mnth);
 dy = parseInt(document.dateform.day.options[document.dateform.day.selectedIndex].value)
 dy = dy;
maxdy = 30
 //if the month 22 isn't February...
 if (mnth != 2)
 {
 // then see if it's a month that only has 30 days...
 
 if (mnth == 4 || mnth == 6 || mnth == 9 || mnth == 11)
 {
 // if it is, and the day value is greater than 30, alert the user
 if (dy > maxdy)
 {
 document.getElementById('error').innerHTML='<font color="#FF0000">'+"لا يمكن أن يكون هناك أكثر من" +maxdy+ "يوما"+' </font>';

 // and select the 30 for them...
 document.dateform.day.selectedIndex = 0
 err = true
 return
 }
 }
 }
 else
 {
 //if it IS February , check if it's a leap year
 yr1 = parseInt(document.dateform.year.value)
 // (this is the modulus operation which returns the remainder of the selected year divided by 4
 leapYrTest = yr1 % 4
 // if the year divides evenly by 4, it is a leap year and the remainder will be 0...
 if (leapYrTest == 0)
 {
 // so our max day for february is 29
 maxdy = 29
 }
 else
 {
 maxdy = 28
 }
 // if the user selected a value greater than the max day AND the month is February
 if (dy > maxdy)
 {
 // Alert the user and set the day back to 1

	document.getElementById('error').innerHTML='<font color="#FF0000">'+"لا يمكن أن يكون هناك أكثر من" +maxdy+ "يوما"+' </font>';
 document.dateform.day.selectedIndex = 0
 err = true
 return
 }
 }
} 
function changeType(index)
{
	document.dateform.type[index].checked = true;
}
function changeDateHandler(sText){
	document.getElementById('loading').style.display="none";
	document.getElementById('go').style.display="block";
	if(sText){
		document.getElementById('result').innerHTML=sText;
	}else{
		document.getElementById('error').innerHTML='<font color="#FF0000">نعتذر منك  لم نتمكن من الحصول على نتيجة </font>';
	}
}
function changeDate()
{
	document.getElementById('loading').style.display="block";
	document.getElementById('go').style.display="none";
	for (var i=0; i < document.dateform.type.length; i++)
   {
	   if (document.dateform.type[i].checked)
	   {
	      var rad_val = document.dateform.type[i].value;
	   }
	}
	AJAXGet(base_url+"changeDate.php?type="+rad_val+"&day="+document.dateform.day.value+"&month="+document.dateform.month.value+"&year="+document.dateform.year.value+"&hday="+document.dateform.hday.value+"&hmonth="+document.dateform.hmonth.value+"&hyear="+document.dateform.hyear.value,changeDateHandler,false,false);
}
function dateKey(evt)
{
	if(evt ==13)
	{
		document.dateform.submit();
	}
}