function form_cal_onsubmit()
{
var currDate="";
if (form_ka.C1.checked)
{
if (form_cal.RBT_Style[0].checked)
	form_cal.action="calendar/"+year_picker.yp.value+"/"+form_cal.Sel_Mon.value+"/"+form_cal.Sel_Day.value+form_cal.Sel_Mon.value+".htm";
else 
{	
	currDate=NewtoOld();
	if (form_cal.Sel_Mon.selectedIndex==0 && form_cal.Sel_Day.selectedIndex<13)
	{	i=(year_picker.yp.selectedIndex==0)?0:year_picker.yp.selectedIndex-1
		form_cal.action="calendar/"+year_picker.yp[i].value+"/"+currDate.substr(2,2)+"/"+currDate+".htm";
	}
	else
	form_cal.action="calendar/"+year_picker.yp.value+"/"+currDate.substr(2,2)+"/"+currDate+".htm";
}
}
else
{
if (form_cal.RBT_Style[0].checked)
	form_cal.action="calendar/zogadi/"+form_cal.Sel_Mon.value+"/"+form_cal.Sel_Day.value+form_cal.Sel_Mon.value+".htm"
else 
{
	currDate=NewtoOld();
	form_cal.action="calendar/zogadi/"+currDate.substr(2,2)+"/"+currDate+".htm";
}
}
}

function Sel_Mon_onchange()
{
var oElement29=document.createElement("OPTION");
	oElement30=document.createElement("OPTION");
	oElement31=document.createElement("OPTION");
var d;
var nak=28;

if (year_picker.yp.value % 4==0)
{
	nak=29;
}	

if (form_cal.Sel_Mon.value=="02")
{
	if (form_cal.Sel_Day.options.length>nak)
		form_cal.Sel_Day.options.length=nak;
}
if (form_cal.Sel_Mon.value=="04" || form_cal.Sel_Mon.value=="06" || form_cal.Sel_Mon.value=="09" || form_cal.Sel_Mon.value=="11")
{
	if (form_cal.Sel_Day.options.length>30)	
		form_cal.Sel_Day.options.length=30;
	if (form_cal.Sel_Day.options.length==28) 
		{
		form_cal.Sel_Day.options.add(oElement29);
		oElement29.text="29";
		oElement29.value="29";
		form_cal.Sel_Day.options.add(oElement30);
		oElement30.text="30";
		oElement30.value="30";
		}
	if (form_cal.Sel_Day.options.length==29) 
		{
		form_cal.Sel_Day.options.add(oElement30);
		oElement30.text="30";
		oElement30.value="30";
		}
}
if (form_cal.Sel_Mon.value=="01" || form_cal.Sel_Mon.value=="03" || form_cal.Sel_Mon.value=="05" || form_cal.Sel_Mon.value=="07" || form_cal.Sel_Mon.value=="08" || form_cal.Sel_Mon.value=="10" || form_cal.Sel_Mon.value=="12")
	{
	if (form_cal.Sel_Day.options.length==28) 
		{
		form_cal.Sel_Day.options.add(oElement29);
		oElement29.text="29";
		oElement29.value="29";
		form_cal.Sel_Day.options.add(oElement30);
		oElement30.text="30";
		oElement30.value="30";
		form_cal.Sel_Day.options.add(oElement31);
		oElement31.text="31";
		oElement31.value="31";
		}
	if (form_cal.Sel_Day.options.length==29) 
		{
		form_cal.Sel_Day.options.add(oElement30);
		oElement30.text="30";
		oElement30.value="30";
		form_cal.Sel_Day.options.add(oElement31);
		oElement31.text="31";
		oElement31.value="31";
		}
	if (form_cal.Sel_Day.options.length==30) 
		{
		form_cal.Sel_Day.options.add(oElement31);
		oElement31.text="31";
		oElement31.value="31";
		}
	}
}

function NewtoOld()
{
var oldMonth="";
	oldDay="";
	DayCount=31;
	oldDate="";
	nak=28;

if (year_picker.yp.value % 4==0)
{
	nak=29;
}	

switch (form_cal.Sel_Mon.value) {
	case "03": DayCount=nak; break;
	case "05": DayCount=30;
	case "07": DayCount=30;
	case "10": DayCount=30;
	case "12": DayCount=30;
	}
if (parseInt(form_cal.Sel_Day.value)-13<1)
	{
	oldMonth=(form_cal.Sel_Mon.value=="01")?12:parseInt(form_cal.Sel_Mon.value)-1;
	if (form_cal.Sel_Mon.value=="08")
		oldMonth=7;
	if (form_cal.Sel_Mon.value=="09")
		oldMonth=8;
	oldDay=DayCount+parseInt(form_cal.Sel_Day.value)-13;
	if (form_cal.Sel_Day.value=="08")
		oldDay=DayCount-5;
	if (form_cal.Sel_Day.value=="09")
		oldDay=DayCount-4;
	}
else
	{
	oldMonth=parseInt(form_cal.Sel_Mon.value);
	if (form_cal.Sel_Mon.value=="08")
		oldMonth=8;
	if (form_cal.Sel_Mon.value=="09")
		oldMonth=9;
	oldDay=parseInt(form_cal.Sel_Day.value)-13;
	}
oldDate=((oldDay<10)?"0"+oldDay:""+oldDay)+((oldMonth<10)?"0"+oldMonth:""+oldMonth);
return(oldDate);
}

function next_day_click()
{
if (form_cal.Sel_Day.selectedIndex==form_cal.Sel_Day.length-1)
	{
	if (form_cal.Sel_Mon.selectedIndex==11)
	{
	year_picker.yp.selectedIndex=(year_picker.yp.selectedIndex==year_picker.yp.length-1)?year_picker.yp.length-1:year_picker.yp.selectedIndex+1;
	Sel_Mon_onchange();
	form_cal.Sel_Mon.selectedIndex=0;
	}
	else
	{
	form_cal.Sel_Mon.selectedIndex=form_cal.Sel_Mon.selectedIndex+1;
	} 
	
	Sel_Mon_onchange();
	form_cal.Sel_Day.selectedIndex=0;
	}
else 
	{
	form_cal.Sel_Day.selectedIndex+=1;
	}
}

function prev_day_click()
{
if (form_cal.Sel_Day.selectedIndex==0)
	{
	if (form_cal.Sel_Mon.selectedIndex==0)
	{
	year_picker.yp.selectedIndex=(year_picker.yp.selectedIndex==0)?0:year_picker.yp.selectedIndex-1;
	form_cal.Sel_Mon.selectedIndex=11;
	}
	else
	{
	form_cal.Sel_Mon.selectedIndex=form_cal.Sel_Mon.selectedIndex-1;
	} 
	Sel_Mon_onchange();
	form_cal.Sel_Day.selectedIndex=form_cal.Sel_Day.length-1;
	}
else 
	{
	form_cal.Sel_Day.selectedIndex-=1;
	}
}

function go_today()
{
var d;
var currDate="";

d=new Date();



form_cal.Sel_Mon.selectedIndex=d.getMonth();
form_cal.Sel_Day.selectedIndex=d.getDate()-1;

if (form_cal.Sel_Mon.selectedIndex==0 && form_cal.Sel_Day.selectedIndex<13)
	{
	year_picker.yp.selectedIndex=1;
	}
else
	{
	year_picker.yp.selectedIndex=2;
	}

currDate=NewtoOld();
form_cal.Sel_Day.selectedIndex=currDate.substr(0,2)-1;
form_cal.Sel_Mon.selectedIndex=currDate.substr(2,2)-1;
Sel_Mon_onchange();

if (form_ka.C1.checked)
{
	form_cal.action="calendar/"+year_picker.yp.value+"/"+currDate.substr(2,2)+"/"+currDate+".htm";
}
else
{
	form_cal.action="calendar/zogadi/"+currDate.substr(2,2)+"/"+currDate+".htm";
}
form_cal.submit();
}

