// ===============================------------------------
// ---------------- TIME FUNCTIONS

	function showTime(el){
	    document.getElementById(el+'_div').innerHTML = '<TABLE width=100% bgcolor=#ece9d8 cellpadding=2 cellspacing=0 class=zTable style="CURSOR: hand;">' +
	                '<TR><TD colspan=4 border=1 bordercolor=#466527 align=center bgcolor=#466527 style="COLOR: white"><b>Select Time</b></TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 6:00 am\');">&nbsp;6:00 am&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 12:00 pm\');">&nbsp;12:00 pm&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 6:00 pm\');">&nbsp;6:00 pm&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 12:00 am\');">&nbsp;12:00 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 6:30 am\');"><FONT color="#888888">&nbsp;6:30 am&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 12:30 pm\');"><FONT color="#888888">&nbsp;12:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 6:30 pm\');"><FONT color="#888888">&nbsp;6:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 12:30 am\');"><FONT color="#888888">&nbsp;12:30 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 7:00 am\');">&nbsp;7:00 am&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 1:00 pm\');">&nbsp;1:00 pm&nbsp;</TD>                            <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 7:00 pm\');">&nbsp;7:00 pm&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 1:00 am\');">&nbsp;1:00 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 7:30 am\');"><FONT color="#888888">&nbsp;7:30 am&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 1:30 pm\');"><FONT color="#888888">&nbsp;1:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 7:30 pm\');"><FONT color="#888888">&nbsp;7:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 1:30 am\');"><FONT color="#888888">&nbsp;1:30 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 8:00 am\');">&nbsp;8:00 am&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 2:00 pm\');">&nbsp;2:00 pm&nbsp;</TD>                            <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 8:00 pm\');">&nbsp;8:00 pm&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 2:00 am\');">&nbsp;2:00 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 8:30 am\');"><FONT color="#888888">&nbsp;8:30 am&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 2:30 pm\');"><FONT color="#888888">&nbsp;2:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 8:30 pm\');"><FONT color="#888888">&nbsp;8:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 2:30 am\');"><FONT color="#888888">&nbsp;2:30 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 9:00 am\');">&nbsp;9:00 am&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 3:00 pm\');">&nbsp;3:00 pm&nbsp;</TD>                            <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 9:00 pm\');">&nbsp;9:00 pm&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 3:00 am\');">&nbsp;3:00 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 9:30 am\');"><FONT color="#888888">&nbsp;9:30 am&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 3:30 pm\');"><FONT color="#888888">&nbsp;3:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 9:30 pm\');"><FONT color="#888888">&nbsp;9:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 3:30 am\');"><FONT color="#888888">&nbsp;3:30 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 10:00 am\');">&nbsp;10:00 am&nbsp;</TD>                        <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 4:00 pm\');">&nbsp;4:00 pm&nbsp;</TD>                            <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 10:00 pm\');">&nbsp;10:00 pm&nbsp;</TD>                        <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 4:00 am\');">&nbsp;4:00 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 10:30 am\');"><FONT color="#888888">&nbsp;10:30 am&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 4:30 pm\');"><FONT color="#888888">&nbsp;4:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 10:30 pm\');"><FONT color="#888888">&nbsp;10:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 4:30 am\');"><FONT color="#888888">&nbsp;4:30 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 11:00 am\');">&nbsp;11:00 am&nbsp;</TD>                          <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 5:00 pm\');">&nbsp;5:00 pm&nbsp;</TD>                      <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 11:00 pm\');">&nbsp;11:00 pm&nbsp;</TD>                        <TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 5:00 am\');">&nbsp;5:00 am&nbsp;</TD></TR>' +
	                '<TR><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 11:30 am\');"><FONT color="#888888">&nbsp;11:30 am&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 5:30 pm\');"><FONT color="#888888">&nbsp;5:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 11:30 pm\');"><FONT color="#888888">&nbsp;11:30 pm&nbsp;</TD><TD style="CURSOR: default" onmouseover="this.bgColor=\'#d7cdbf\';" onmouseout="this.bgColor=\'#ece9d8\';" onclick="selectTime(\''+el+'\', \' 5:30 am\');"><FONT color="#888888">&nbsp;5:30 am&nbsp;</TD></TR>' +
		            '<TR bgcolor=#f5f3e8><TD colspan=3 align=right><INPUT style="width: 50px" type=button value="Now" class=zText onclick="setNow(\''+el+'\'); closeTime(\''+el+'\');"></TD><TD><INPUT style="width: 50px" type=button value="'+lc_words['cancel']+'" class=zText onclick="closeTime(\''+el+'\');"></TD></TR></TABLE>';
	    document.getElementById(el+'_div').style.display  = 'inline';
	}

	function closeTime(el) {
	    document.getElementById(el+'_div').style.display  = 'none';
	}

	function selectTime(el, time) {
    	if (time.substr(0,1) == ' ') time = time.substr(1);
	    if ((time == '') || (time == null)) time = '';
	    if (time != '') {
	        t = time.split(':');
	        hour = t[0];
            if (t.length == 2) {
            	ind = t[1].indexOf(' ');
                ttt = new Array();
                ttt[0] = t[1].substr(0, ind);
                ttt[1] = t[1].substr(ind+1);
	            min   = ttt[0];
    	        ttype = ttt[1];
            } else {
            	min   = '00';
                ttype = 'am';
            }

	        if (t[1] != null) {
            	ind = t[1].indexOf(' ');
                ttt = new Array();
                ttt[0] = t[1].substr(0, ind);
                ttt[1] = t[1].substr(ind+1);
	            min   = ttt[0];
    	        ttype = ttt[1];
	        }
	    }
        if (ttype.substr(0,1) == ' ') { ttype = ttype.substr(1); }
	    if (hour > 12) { hour -= 12; ttype = 'pm'; }
		if (hour == 12) ttype = 'pm';
	    if (hour != null) document.getElementById(el+'_hour').value = hour;
	    if (min  != null) document.getElementById(el+'_min').value  = min;
	    if (ttype != null) document.getElementById(el+'_type').value = ttype;

	    setTime(el);
	    document.getElementById(el+'_div').style.display  = 'none';
	    return;
	}
	function setTime(el){
	    h = document.getElementById(el+'_hour').value;
	    m = document.getElementById(el+'_min').value;
	    t = document.getElementById(el+'_type').value;
	    if (document.getElementById(el+'_zone')) z = ' '+document.getElementById(el+'_zone').value; else z = '';
	    if (h == '' || m == '' || t == '0') { document.getElementById(el).value = ''; return; }
	    document.getElementById(el).value = (top.zUtils ? top.zUtils.trim(h) + ':' + top.zUtils.trim(m) + ' ' + t + z : h + ':' + m + ' ' + t + z);
        el = document.getElementById(el);
        if (el.onchange) el.onchange();
	    return;
	}
	function initTime(elm){
		var zone = '';
	    var time = document.getElementById(elm).value;
		if (time.indexOf('-') > 0) { var tmp = time.split('-');	time = tmp[0]; zone = '-'+tmp[1]; }
		if (time.indexOf('+') > 0) { var tmp = time.split('+');	time = tmp[0]; zone = '+'+tmp[1]; }
        if (time != '') {
	        tmp = time.split(':');
	        ttt = String(tmp[1]).substr(String(tmp[1]).length-2, 2);
	        if ((ttt == 'am') || (ttt == 'pm')) { tmp[1] = tmp[1].substr(0, String(tmp[1]).length-2); }
	        ttmp = tmp[0]+':'+tmp[1];
            if (ttmp.substr(ttmp.length-1, 1) == ' ') ttmp = ttmp.substr(0, ttmp.length-1);
	        tam  = time.substr(time.length-2, 2);
	        if (tmp[0] > 12) { tam = 'pm'; tmp[0] = tmp[0]-1; }
	        if ((tam == 'am') || (tam == 'pm')) { time = ttmp + ' ' + tam; } else { time = ttmp + ' am'; }
	        if (time.substr(time.length-3, 1) != ' ') {
	            time = time.substr(0, time.length-2) + ' ' + time.substr(time.length-2, 2);
	        }
        }
	    if (zone != '' && document.getElementById(elm+'_zone')) { document.getElementById(elm+'_zone').value = zone; }
	    if (time != '') { selectTime(elm, time); }
	    ell = document.getElementById(elm+'_type');
	    if (ell.value == '') ell.value = 'am';
	    return;
	}
	function setNone(el) {
	    document.getElementById(el+'_hour').value  = '';
	    document.getElementById(el+'_min').value   = '';
	    document.getElementById(el+'_type').value  = 0;
	    if (document.getElementById(el+'_zone')) document.getElementById(el+'_zone').value  = '';
	    document.getElementById(el).value = '';
        el = document.getElementById(el);
        if (el.onchange) el.onchange();
	}
	function setNow(el) {
	    document.getElementById(el+'_hour').value  = lc_dates['h'];
	    document.getElementById(el+'_min').value   = lc_dates['i'];
	    document.getElementById(el+'_type').value  = lc_dates['a'];
	    document.getElementById(el).value = lc_dates['hia'] + ' ' + (document.getElementById(el+'_zone') ? document.getElementById(el+'_zone').value : '');
        el = document.getElementById(el);
        if (el.onchange) el.onchange();
	}

// ===============================------------------------
// ---------------- DATE FUNCTIONS

    var curr_d;
    var cal = new class_calendar('none');

    function showDate(i, d1){
        curr_d = d1;

        var d = Array();
        var dt = new Date();
        d[0] = dt.getMonth()+1;

        d[0] = document.getElementById(d1+'_month').value;
        d[1] = document.getElementById(d1+'_day').value;
        d[2] = document.getElementById(d1+'_year').value;

        if (Number(d[0]) == 0 ) {
            d[0] = dt.getMonth()+1;
            d[1] = dt.getDate();
            d[2] = dt.getFullYear();
        }

        if (d[0] < 10) { d[0] = '0' + d[0]; }
        if (d[1] < 10) { d[1] = '0' + d[1]; }
        cal.onSelectDate = 'selectDate';
        cal.onNextMonth  = 'nextMonth';
        cal.onPrevMonth  = 'prevMonth';
        document.getElementById('calendar'+d1).innerHTML = '<TABLE bgcolor=#ece9d8 cellpadding=1 cellspacing=0><TR><TD colspan=2 align=center bgcolor=#466527><FONT color=white style="FONT-FAMILY: verdana; FONT-SIZE: 13px;"><b>'+lc_words['seldate']+'</b></FONT></TD></TR><TR><TD>' +
                cal.buildAMonth(d[0], d[2], true) + '</TD><TD>' + cal.buildAMonth(Number(d[0])+1, d[2]) + '</TD></TR>'+
                '<TR><TD><DIV><SELECT id="idChangeYear'+d1+'"></SELECT></DIV></TD><TD align=right><INPUT type=button value="'+lc_words['today']+'" class=zText onclick="todayCal(\''+d1+'\');"> <INPUT type=button value="'+lc_words['cancel']+'" class=zText onclick="closeCal(\''+d1+'\');"></TD></TR></TABLE>';
        document.getElementById('calendar'+d1).style.display  = 'inline';
        fillYear(d1);
    }
    function showNull(d){
        document.getElementById(d+'_month').value = '';
        document.getElementById(d+'_day').value   = '';
        document.getElementById(d+'_year').value  = '';
        el = document.getElementById(d);
        el.value = '';
        if (el.onchange) el.onchange();
    }
    function closeCal(d) {
        document.getElementById('calendar'+d).style.display  = 'none';
    }
    function todayCal(d1) {
        var d = Array();
        var dt = new Date();
        d[0] = dt.getMonth()+1;
        d[1] = dt.getDate();
        d[2] = String(dt.getYear());
        d[2] = '20'+d[2].substr(d[2].length-2,2);

        if (d[0] < 10) { d[0] = '0' + Number(d[0]); }
        if (d[1] < 10) { d[1] = '0' + Number(d[1]); }
        document.getElementById(d1+'_month').value = d[0];
        document.getElementById(d1+'_day').value   = d[1];
        document.getElementById(d1+'_year').value  = d[2];
        document.getElementById(d1).value = d[2] + '-' + d[0] + '-' + d[1];
        el = document.getElementById(d1);
        if (el.onchange) el.onchange();

        document.getElementById('calendar'+d1).style.display  = 'none';
    }
    function selectDate(date, d1){
        if (d1 == null) d1 = curr_d;
        d = date.split('-');
        if (Number(d[2].substr(d[2].length-2,2)) < 20) {
            d[2] = '20'+d[2].substr(d[2].length-2,2);
        } else {
            d[2] = '19'+d[2].substr(d[2].length-2,2);
        }
        if (d[0] < 10) { d[0] = '0' + Number(d[0]); }
        if (d[1] < 10) { d[1] = '0' + Number(d[1]); }
        document.getElementById(d1+'_month').value = d[0];
        document.getElementById(d1+'_day').value   = d[1];
        document.getElementById(d1+'_year').value  = d[2];
        document.getElementById(d1).value = d[2] + '-' + d[0] + '-' + d[1];
        el = document.getElementById(d1);
        if (el.onchange) el.onchange();

        document.getElementById('calendar'+d1).style.display  = 'none';
    }
    function nextMonth(month, d) {
        if (d == null) d = curr_d;
        var m = month.split(',');
        document.getElementById('calendar'+d).innerHTML = '<TABLE bgcolor=#ece9d8 cellpadding=1 cellspacing=0><TR><TD colspan=2 align=center bgcolor=#466527><FONT color=white style="FONT-FAMILY: verdana;FONT-SIZE: 13px;"><b>'+lc_words['seldate']+'</b></FONT></TD></TR><TR><TD>' +
                cal.buildAMonth((Number(m[0])+1), m[1], true) + '</TD><TD>' + cal.buildAMonth((Number(m[0])+2), m[1]) + '</TD></TR><TR><TD><SELECT class=zList id="idChangeYear'+d+'"></SELECT></TD><TD align=right><INPUT type=button value="'+lc_words['today']+'" class=zText onclick="todayCal(\''+d+'\');"> <INPUT type=button value="'+lc_words['cancel']+'" class=zText onclick="closeCal(\''+d+'\');"> </TD></TR></TABLE>';
        fillYear(d);
        return;
    }
    function prevMonth(month, d) {
        if (d == null) d = curr_d;
        var m = month.split(',');
        document.getElementById('calendar'+d).innerHTML = '<TABLE bgcolor=#ece9d8 cellpadding=1 cellspacing=0><TR><TD colspan=2 align=center bgcolor=#466527><FONT color=white style="FONT-FAMILY: verdana; FONT-SIZE: 13px;"><b>'+lc_words['seldate']+'</b></FONT></TD></TR><TR><TD>' +
                cal.buildAMonth((Number(m[0])-2), m[1], true) + '</TD><TD>' + cal.buildAMonth((Number(m[0]))-1, m[1]) + '</TD></TR><TR><TD><SELECT class=zList id="idChangeYear'+d+'"></SELECT></TD><TD align=right><INPUT type=button value="'+lc_words['today']+'" class=zText onclick="todayCal(\''+d+'\');"> <INPUT type=button value="'+lc_words['cancel']+'" class=zText onclick="closeCal(\''+d+'\');"> </TD></TR></TABLE>';
        fillYear(d);
        return;
    }
    function fillYear(d) {
        var dt = new Date();
        var newYears = '<OPTION selected></OPTION>';
        for (var i=1960; i<=2020; i++){
            m_year = document.getElementById(d+'_year').value;
            if (m_year == '') { m_year = dt.getFullYear(); }
            //if (i==m_year) { add = 'selected'; } else { add = '';}
            add = '';
            newYears += '<OPTION value="' + i + '" '+add+'>' + i + '</OPTION>';
        }
        document.getElementById('idChangeYear'+d).parentNode.innerHTML = '<FONT STYLE="font-size: 10PX; FONT-FAMILY: verdana">&nbsp;'+lc_words['jump']+':</FONT><SELECT onchange="changeYear(this.value,\''+d+'\');" class=zList id="ChangeYear'+d+'" style="font-size:9px; width=50px">' + newYears + '</SELECT>';
    }

    function changeYear(year, d) {
        document.getElementById('calendar'+d).innerHTML = '<TABLE bgcolor=#ece9d8 cellpadding=1 cellspacing=0><TR><TD colspan=2 align=center bgcolor=#466527><FONT color=white style="FONT-FAMILY: verdana; FONT-SIZE: 13px;"><b>'+lc_words['seldate']+'</b></FONT></TD></TR><TR><TD>' +
                cal.buildAMonth(1, year, true) + '</TD><TD>' + cal.buildAMonth(2, year) + '</TD></TR><TR><TD><SELECT class=zList id="idChangeYear'+d+'"></SELECT></TD><TD align=right><INPUT type=button value="'+lc_words['today']+'" class=zText onclick="todayCal(\''+d+'\');"> <INPUT type=button value="'+lc_words['cancel']+'" class=zText onclick="closeCal(\''+d+'\');"> </TD></TR></TABLE>';
        fillYear(d);
        return;
    }

    function doData(name) {
		// if ((this.value == '' || String(Number(this.value))=='NaN' || this.value == '0') && document.getElementById('$name').value != '') this.value = '1';
    	day	  = document.getElementById(name + '_day');
    	month = document.getElementById(name + '_month');
    	year  = document.getElementById(name + '_year');
    	// day
		if (String(Number(day.value)) == 'NaN') day.value = '';
    	if (Number(day.value < 1) && day.value != '0' && day.value != '')  day.value = 1;
    	if (Number(day.value) > 31) day.value = 31;
    	// month
		if (String(Number(month.value)) == 'NaN') month.value = '';
    	if (Number(month.value) < 1 && month.value != '0' && month.value != '')  month.value = 1;
    	if (Number(month.value) > 12 && month.value != '0') month.value = 12;
    	// year
		if (String(Number(year.value)) == 'NaN') year.value = '';
    	if (String(year.value).length == 2) {
    		if (parseInt(year.value) < 30) year.value = '20'+ year.value;
    		else if (parseInt(year.value) >=30) year.value = '19'+ year.value;
    	}
		if (year.value != '') {
			if (parseInt(year.value) < 1900) year.value = 1900;
			if (parseInt(year.value) > 2030) year.value = 2030;
		}

    	ndate = (year.value != '' ? year.value : '1900') + '-' +
				(month.value != '' ? month.value : '1') + '-' +
				(day.value != '' ? day.value : '1');
		if (year.value == '' && month.value == '' && day.value == '') ndate = '';
    	if (ndate != '--') document.getElementById(name).value = ndate;
    }

    function checkData(el) {
    	str = String(el.id).replace('_day', '').replace('_month', '').replace('_year', '');
    	day	  = document.getElementById(str + '_day');
    	month = document.getElementById(str + '_month').value;
    	year  = document.getElementById(str + '_year').value;
    	if (year.value == 0) year = 2001;

    	// check number of days
    	cal = new top.class_calendar('desktop');
	    if ( (year/4) == Math.floor(year/4) ) { // LEAP YEAR
	        cal.daysInMonth[1] = '29';
	    } else {
	    	cal.daysInMonth[1] = '28';
	    }
    	if (cal.daysInMonth[month-1] < parseInt(day.value)) {
    		day.value = cal.daysInMonth[month-1];
    		//alert('The month of '+ cal.months[month-1] +' has only '+ cal.daysInMonth[month-1] + ' days.');
    	}



    }