
function open_needs_tool() {
  prepop_form(document.needsForm);
  $E('body').addClass("needstool_popup");
}

function close_needs_tool() {
  $E('body').removeClass("needstool_popup");
}

function open_contact() {
  prepop_form(document.contactForm);
  $E('body').addClass("contact_popup");
}

function close_contact() {
  document.contactForm.form_id.value = "1";
  document.contactForm.product_name.value = '';
  document.contactForm.product_website.value = '';
  $E('body').removeClass("contact_popup");
}

function open_product_contact(name, url) {
  prepop_form(document.contactForm);
  document.contactForm.form_id.value = "3";
  document.contactForm.product_name.value = name;
  document.contactForm.product_website.value = url;
  $E('body').addClass("contact_popup");
}

var rem_fields = ['first', 'last', 'company', 'title', 'email', 'phone']; // text inputs only

function require_fields(formObj, field_list) {
  var errors = false;
  var errMsg = ['Please enter the following information:'];
  errMsg.push('_______________________________________\n');
  field_list.each(function(field) {
    var fObj = formObj.elements[field[0]];
    if (fObj.value == "" || fObj.value == field[2]) {
      errors = true;
      errMsg.push(field[1]);
    }
  });
  errMsg.push('_______________________________________\n');

  if (errors) {
    alert(errMsg.join('\n'));
    return false
  } else {
    // cookie data
    var user_data = Json.evaluate(LL_get_cookie('user_data')) || {};
    rem_fields.each(function(fld) {
      try {
        if (formObj[fld] && formObj[fld].value) {
          user_data[fld] = formObj[fld].value;
        }
      } catch (ex) {} // field not in form
    });
    LL_set_cookie('user_data', Json.toString(user_data));
    return true
  }
}

function prepop_form(formObj) {
  var datastr = LL_get_cookie('user_data');
  var user_data = Json.evaluate(datastr);
  if (user_data) {
    rem_fields.each(function(fld) {
      try {
        formObj[fld].value = user_data[fld];
      } catch (ex) {} // field not in form
    });
  }
}

function add_product_website() {
  var msg = "";
  var web = LL_get_param('web');
  if (web) {
    var eweb = unescape(web);
    msg = '<p>For more information, visit this website: <a target="_new" href="' + eweb + '">' + eweb + '</a></p>';
  }
  document.write(msg);
}

function show_whats_new() {
  $('whats_new_list').style.display = "block";
}

function hide_whats_new() {
  $('whats_new_list').style.display = "none";
}

