function putInput( name )
{
//	s = '<div>';
//	s += '<div style="float: left; background: url(img/inpb.png) -10px -10px no-repeat; width: 10px; height: 10px;font-size: 1pt;"></div>';
//	s += '<div style="float: right; width: 10px; height: 10px; background: url(img/inpb.png) 0px -10px no-repeat; font-size: 1pt;"></div>';
//	s += '<div style="background: url(img/inpb.png) -20px -10px no-repeat; width: auto; height: 10px;font-size: 1pt;"></div>';
//	s += '<div style="background: url(img/inpb.png) right bottom repeat-y; padding: 0px 10px 0px 0px;font-size: 1pt;">';
//	s += '<div style="background: url(img/inpb.png) 0px -20px repeat-y; padding: 0px 0px 0px 10px;font-size: 1pt;">';
//	s += '<input type=text style="border: 0px; background: url(img/inpb.png) -20px -20px;" name='+name+' id='+name+'>';
//	s += '</div></div>';
//	s += '<div style="float: left; background: url(img/inpb.png) -10px 0px no-repeat; width: 10px; height: 10px;font-size: 1pt;"></div>';
//	s += '<div style="float: right; width: 10px; height: 10px; background: url(img/inpb.png) 0px 0px no-repeat; font-size: 1pt;"></div>';
//	s += '<div style="background: url(img/inpb.png) -20px 0px no-repeat; width: auto; height: 10px;font-size: 1pt;"></div>';
//	s += '</div>';
	s = '<div style="background: url(img/inpb2.png) right top no-repeat; width: auto; padding-right: 10px; height: 33px;">';
	s += '<div style="background: url(img/inpb2.png) left top no-repeat; height: 33px; padding: 5px;">';
	s += '<input type=text style="border: 0px; background-color: #d7cec4; height: 23px; font-size: 12pt; width: 100%;" name='+name+' id='+name+'>';
	s += '</div></div>';
	document.write( s );
}

function putCalendarInput( name, empty )
{
	s = '<div style="background: url(img/inpb2.png) right top no-repeat; width: auto; padding-right: 10px; height: 33px;">';
	s += '<div style="background: url(img/inpb2.png) left top no-repeat; height: 33px; padding: 5px;">';
	s += '<div id=cal_'+name+'></div>';
	s += '<input type=hidden name='+name+' id='+name+'>';
	s += '</div></div>';
	document.write( s );
	var now = new Date();
	var next = new Date( now.getFullYear(), now.getMonth(), now.getDate()+1 );
	initCalendar( 'cal_'+name, next, true, (empty==1?1:0) );
}

var checkBoxes = new Array();
function putCheckBox( name, val, checked )
{
    cln = checked ? 'c' : 'n';
    s = '<div onclick="return turnCheckBox(\''+name+'\');" id=d_'+name+' class=rb' + cln +'></div>';
    s += '<input type=hidden id=i_'+name+' name=i_'+name+(checked?' value="'+val+'"':'')+'>';
    checkBoxes[ checkBoxes.length ] = new addCheckBoxItem( name, val, checked );
    document.write( s );
}

function addCheckBoxItem( name, val, checked )
{
    this.name = name;
    this.value = val;
    this.checked = (checked?true:false);
    return this;
}

function turnCheckBox( name )
{
    found = false; i=0;
    while( !found && i<checkBoxes.length )
	{
	found = ( checkBoxes[i].name == name );
	if( !found )
	    i++;
	}
    if( !found )
	return false;
    var dobj = findObject( 'd_'+name );
    var iobj = findObject( 'i_'+name );
    if( !dobj || !iobj )
	return false;
    checkBoxes[i].checked = !checkBoxes[i].checked;
    dobj.className = 'rb' + ( checkBoxes[i].checked ? 'c' : 'n' );
    iobj.value = ( checkBoxes[i].checked ? checkBoxes[i].value : '' );
    return false;
}

var radioBoxes = new Array();
function putRadioBox( name, val, checked )
{
    found = false; i = 0;
    while( !found && i<radioBoxes.length )
	{
	found = ( radioBoxes[i].name == name ); 
	if( !found )
	    i++;
	}
    if( !found )
	radioBoxes[ radioBoxes.length ] = new addRadioBoxGroup( name, val, checked );
    else
	radioBoxes[i].items[ radioBoxes[i].items.length ] = new addRadioBoxItem( radioBoxes[i].items.length, val );
    curr = radioBoxes[i].items.length-1;	
    if( checked )
	{
	var iobj = findObject( 'i_' + name );
	if( iobj )
	    iobj.value = val;
	radioBoxes[i].checked = curr;	
	}
    cln = checked ? 'c' : 'n';
    s = '<div onclick="return turnRadioBox(\''+name+'\','+curr+');" id=d_'+name+'_'+curr+' class=rb' + cln +'></div>';
    if( !found )
	s += '<input type=hidden id=i_'+name+' name=i_'+name+(checked?' value="'+val+'"':'')+'>';
    document.write( s );
//    alert( s );
}

function addRadioBoxGroup( name, val, checked )
{
    this.name = name;
    this.items = new Array();
    this.items[0] = new addRadioBoxItem( 0, val );
    this.checked = (checked?0:-1);
    return this;
}

function addRadioBoxItem( idx, val )
{
    this.idx = idx;
    this.value = val;
}

function turnRadioBox( name, idx )
{
//    alert( name +' ' +idx );
    found = false; fi = 0;
    while( !found && fi<radioBoxes.length )
	{
	found = ( radioBoxes[fi].name == name ); 
	if( !found )
	    fi++;
	}
    if( !found )
	return false;
    var obj; i = 0;
    while( obj = findObject( 'd_'+name+'_'+i ) )
	{
	obj.className = 'rbn';
	i++;
	}
    obj = findObject( 'd_'+name+'_'+idx );
    if( !obj )
	return false;
    obj.className = 'rbc';
    radioBoxes[fi].checked = idx;
    iobj = findObject( 'i_'+name );
    if( !iobj )
	return false;
    iobj.value = radioBoxes[fi].items[idx].value;
    return false;
}