var _tjoes_calculator_last, slideshowfiles, slideshowpath;
var SLIDES = new slideshow("SLIDES");

function _tjoes_calculator_debug(html)
{
  if ($('#tjoes_calculator_debug_id')) 
  {
    var    backs = [ 'pink', 'red', 'orange', 'yellow'
      , 'green', 'aqua', 'blue', 'navy-blue'
      , 'purple', 'magenta',
      ],
    last  = _tjoes_calculator_last,
    col  = '';
    last += (last == backs.length) ? -backs.length : 1;
    col    = backs[last];
    css    = { border        : "1px solid #000"
      , backgroundColor : col
      , padding        : "2px"
      , margin        : "2px"
      , "float"        : "left"
      };
    $(html).css(css).appendTo('#tjoes_calculator_debug_id');
    _tjoes_calculator_last = last;
  }
}
function tjoes_calculator_form_ready()
{
  tjoes_calculator_display_check('all', true);
  tjoes_calculator_display_open();
}

function tjoes_calculator_display_open()
{
  number_validator_display_open(false,
                          'tjoes_calculator_vehicle_bydistance_id');
}

function tjoes_calculator_display_check(task_fieldname, check_ceros)
{
  var all = (task_fieldname == 'all') ? true : false;

  if (all || task_fieldname == 'vehicle_bydistance')
  {
    number_validator_validate_num_field(
                      '#tjoes_calculator_vehicle_bydistance_value_id',
                      10, 3, false, check_ceros);
  }
}
function tjoes_calculator_form_method_change()
{
  // No fields to disable/enable
}

function tjoes_calculator_form_clear_display()
{
/*
  if  ( $('#tjoes_calculator_distance_value_id').val() == '')
  {
    $('#tjoes_calculator_distance_display_id').val('');
  }
*/
}
function ticode_slideshow_start(browser, filter, timeout, transition_time)
{
  var thefilter	= '';
  SLIDES.timeout  = timeout + (transition_time * 1000);
  SLIDES.setbrowser(browser);

  for (aslide in slideshowfiles)
  {
    SLIDES.add_slide(new slide(slideshowpath + slideshowfiles[aslide]));
  }

  if ('IE' == browser)
  {
    switch (filter)
    {
      case 'crosswipe':
	thefilter = 'progid:DXImageTransform.Microsoft.Barn(Duration='
		  + transition_time +')';
	break;
      case 'swapfade':
	thefilter = 'progid:DXImageTransform.Microsoft.Pixelate'
		  + '(Duration=' + transition_time + ')';
	break;
      case 'crossfade':
	thefilter = 'progid:DXImageTransform.Microsoft.Fade(Duration='
		  + transition_time + ')';
	break;
      default:
    }
  }
  else
  {
    thefilter = filter;
  }

  for (var i=0; i < SLIDES.slides.length; i++)
  {
    s	      = SLIDES.slides[i];
    s.target  = "SLIDES_popup";
    s.filter  = thefilter;
  }
}
