// ===================================================================

// drow_box_top()
//   This function prints the header of a table for a text
//   after the text, you have to run also drow_box_bottom()
function drow_box_top()
{
	document.write('<TABLE border="0" cellpadding="0" cellspacing="0"><TR> <TD id="tabel_1_1" width=12 height=12></TD> <TD id="tabel_1_2"></TD> <TD id="tabel_1_3" width=12 height=12></TD></TR><TR> <TD id="tabel_1_4"></TD><TD>');
}

// drow_box_bottom()
//   This function prints the footer of a table for a text
//   it should be executed only after drow_box_top
function drow_box_bottom()
{
	document.write('</TD><TD id=tabel_1_6></TD></TR><TR> <TD id=tabel_1_7 width=12 height=12></TD> <TD id=tabel_1_8></TD><TD id=tabel_1_9 width=12 height=12></TD></TR></TABLE>');
}

// ================= functions for 2 camendars with dates on one page ==============
function setMultipleValues4(y,m,d) {
	document.forms["contact"].date1_year.value=y;
	document.forms["contact"].date1_month.selectedIndex=m;
	for (var i=0; i<document.forms["contact"].date1_date.options.length; i++) {
		if (document.forms["contact"].date1_date.options[i].value==d) {
			document.forms["contact"].date1_date.selectedIndex=i;
		}	}
	d=d+7;
	if (d>30) {d=d-30; m=m+1;	if (m>12) {m=m-12; y=y+1;} }
	setMultipleValues5(y,m,d);
	}
function setMultipleValues5(y,m,d) {
	document.forms["contact"].date2_year.value=y;
	document.forms["contact"].date2_month.selectedIndex=m;
	for (var i=0; i<document.forms["contact"].date2_date.options.length; i++) {
		if (document.forms["contact"].date2_date.options[i].value==d) {
			document.forms["contact"].date2_date.selectedIndex=i;
	}	}	}
function getDateString(y_obj,m_obj,d_obj) {
	var y = y_obj.options[y_obj.selectedIndex].value;
	var m = m_obj.options[m_obj.selectedIndex].value;
	var d = d_obj.options[d_obj.selectedIndex].value;
	if (y=="" || m=="") { return; }
	if (d=="") { d=1; }
	return str= y+'-'+m+'-'+d;
	}
function use_2_big_calendars(last_day) {	//the controls should be in a form called "contact"
	var now = new Date();
	eval('cal1 = new CalendarPopup()');			// trick to use global variables in  function
	eval('cal1.setReturnFunction("setMultipleValues4")');
	eval('cal2 = new CalendarPopup()');
	eval('cal2.setReturnFunction("setMultipleValues5")');
	eval('cal1.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"))');
	eval('cal2.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"))');
	if (last_day.length == 12) {
		eval('cal1.addDisabledDates(last_day,null)');
		eval('cal2.addDisabledDates(last_day,null)'); }
	else alert("Invalid date: "+last_day);
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function hide_show(val, id) {
//alert("ascund/arat "+id+" ("+val+")");
if (val == -1)
	{showdiv(id)}
else
	{hidediv(id)}
}

