function changeCalendar(calendar_url) {
	if (document.getElementById) {
		var cal_month_e=document.getElementById('cal_month');
		var cal_year_e=document.getElementById('cal_year');
		var cal_grid_e=document.getElementById('cal_grid');

		month=cal_month_e.options[cal_month_e.selectedIndex].value-1;
		year=cal_year_e.options[cal_year_e.selectedIndex].value;
		
		var nowDate=new Date();

		//	Первый день месяца
		var firstDay=new Date(year, month, 1);
		var firstDayName=firstDay.getDay();
		if (firstDayName==0) firstDayName=7;
		startPos=2-firstDayName;

		//	Последний день месяца
		lastDay=new Date(year, month, 31);
		lastDayInMonth=31;
		for (i=0; i<3; i++) {
			if (lastDay.getDate()!=lastDayInMonth) {
				lastDayInMonth--;
				lastDay=new Date(year, month, lastDayInMonth);
			}
		}
		endPos=firstDayName-1+lastDayInMonth;
		for (i=0; i<6; i++) {
			if (endPos>6) endPos=endPos-7;
		}
		if (endPos>0) {
			endPos=lastDayInMonth+7-endPos;
		} else {
			endPos=lastDayInMonth;
		}

		
		if (nowDate.getTime()<firstDay.getTime()) { 
			iMin=iMax=-1000;
		} else {
			lastDay.setHours(23);
			lastDay.setMinutes(59);
			lastDay.setSeconds(59);
			if (nowDate.getTime()>lastDay.getTime()) {
			iMin=-1000;
			iMax=1000;
			} else {
				iMin=-1000;
				iMax=nowDate.getDate();
			}
		}

		calBody="<tr><th>П</th><th>В</th><th>С</th><th>Ч</th><th>П</th><th>С</th><th>В</th></tr>";
	
		cntr=1;
	
		for (i=startPos;i<=endPos;i++) {
			if (cntr==1) calBody+="<tr>";
			if ((i<1)||(i>lastDayInMonth)) {
				calBody+='<td>&nbsp;</td>';
			} else {
				if ((i<=iMax)&&(i>=iMin)) {
					calBody+='<td><a href="'+calendar_url+'?'+i+'.'+(month+1)+'.'+year+'">'+i+'</a></td>';
				} else {
					calBody+='<td>'+i+'</td>';
				}
			}
			cntr++;
			if (cntr==8) {
				calBody+="</tr>\n";
				cntr=1;
			}
		}




//		alert("First day is "+firstDayName+", Start pos is "+startPos+", Last day in month is "+lastDayInMonth+", End position is "+endPos);
		cal_grid_e.innerHTML='<table cellspacing="0">'+calBody+'</table>';
	}
}


function sethome(o,siteurl,sitename) {
	var name = navigator.appName;
	var useragent = navigator.userAgent;
	var version = parseInt(navigator.appVersion);
	var needtoknow = 1;
	
	if ( useragent.indexOf("MSIE") != -1) {
			var index = navigator.userAgent.indexOf("MSIE ");
			if ( index != -1 ) {
				version = parseInt(navigator.userAgent.substring(index+5,index+6));
			}
			if ( version > 4) {
				o.style.behavior='url(#default#homepage)'; o.setHomePage(siteurl);
				needtoknow = 0;
			}
	}
	if (needtoknow != 0) {
		openBrWindow('/help/makehomepage.html','winMakeHomepage','location=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=450');
	}
}


function updatetime() {
	if(document.getElementById) {
		ctTime=new Date();
		if (parseInt(ctTime.getHours())>9) {
			var ctHours=ctTime.getHours();
		} else {
			var ctHours='0'+ctTime.getHours();
		}
		if (parseInt(ctTime.getMinutes())>9) {
			var ctMinutes=ctTime.getMinutes();
		} else {
			var ctMinutes='0'+ ctTime.getMinutes();
		}
/*
		if (parseInt(ctTime.getSeconds())>9) {
			var ctSeconds=ctTime.getSeconds();
		} else {
			var ctSeconds='0'+ ctTime.getSeconds();
		}
*/
		var ctFull=ctHours + ':' + ctMinutes;
		if(document.getElementById('timeplace')) {
			document.getElementById('timeplace').innerHTML = ctFull;
			setTimeout("updatetime()", 10000);
		}                                      	
	}
}

