// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// order.js
// Copyright (c) 2007 ipHouse.  All rights reserved.

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// configuration

var cgiemail = 'http://umn.iphouse.com/cgi-bin/cgiemail';

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// init form

function init_order () {
  var fe = document.getElementById('order').elements;

  if (type = window.location.search.substring(1)) {
    if (match = /(\d+),(\d+)/.exec(type)) {
      fe['required-service'].selectedIndex = parseInt(match[1]);
      fe['required-dsl_service'].selectedIndex = parseInt(match[2]);
    } else if (match = /(\d+)/.exec(type)) {
      fe['required-service'].selectedIndex = parseInt(match[1]);
    }
  }
  set_type();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// set service type

function set_type (f) {
  var fe = document.getElementById('order').elements;
  var sel = fe['required-service'];
  var type = sel.options[sel.selectedIndex].value;

  if (type.match(/DSL/)) {
    if (fe['dsl_phone'].value == '') {
      fe['dsl_phone'].value = fe['required-phone'].value;
    }
    tmpl = '/order_dsl.txt';
    d = document.getElementById('service_block').style.display;
  } else {
    tmpl = '/order_dialup.txt';
    d = 'none';
  }
  document.getElementById('order').action = cgiemail + tmpl;
  document.getElementById('dsl_block').style.display = d;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

