function connectFields( field1, field2, field2_label, field3 )
{
	$(field1).bind( 'change', {}, function()
	{
		f	= $(field1);
		t	= f.attr('type');
		if( t == 'radio' || t == 'checkox' )
			v = f.attr('checked');
		else
			v = f.val() != 0 && f.val() != "";
		if( v )
		{
			$(field2).addClass( 'mandatory' );
			$(field2_label).addClass( 'mandatory' );
		}
		else
		{
			$(field2).removeClass( 'mandatory' );
			$(field2_label).removeClass( 'mandatory' );
		}
	});
	$(field1).change();
	if( field3 )
		$(field3).change(function(){$(field1).change()});

}
// if set useNegative, then the event will disable the field2 even if the field1 was changed to a negative value
function disableFields( field1, field2, field2_label, field3, useNegative )
{
	$(field1).bind( 'change', {}, function()
	{
		f	= $(field1);
		t	= f.attr('type');
		if( t == 'radio' || t == 'checkox' )
			v = f.attr('checked');
		else
			v = f.val() != 0 && f.val() != "" && (useNegative ? 1 : f.val() > 0);
		if( v )
		{
			$(field2).attr( 'disabled', true );
			$(field2_label).addClass( 'disabled' );
		}
		else
		{
			$(field2).attr( 'disabled', false );
			$(field2_label).removeClass( 'disabled' );
		}
	});
	$(field1).change();
	if( field3 )
		$(field3).change(function(){$(field1).change()});

}