// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// custom.js
// Copyright (c) 2004-2008 ipHouse.  All rights reserved.

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

var never = cookie_date(2037,1,1,0,0,0);

var re = /(http|https):\/\/[^.\/]*\.([^.\/]+\.[^.\/]+)\//;
var match = re.exec(window.location);
var domain = match[2];

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// reprogram

if (get_cookie('skin') == 'ein') {
  set_cookie('skin','default',never,'/',domain);
}
if (get_cookie('startrek') == 1) {
  delete_cookie('startrek','/',domain);
  set_cookie('fortune','1',never,'/',domain);
  set_cookie('fortune.src','startrek',never,'/',domain);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// customization

function get_custom (name) {
  return get_cookie(name);
}
function set_custom (name, value, reload) {
  set_cookie(name,value,never,'/',domain);

  if (reload) {
    window.location = window.location;
  }
  return true;
}
function toggle_custom (name) {
  if (get_cookie(name) == 1) {
    delete_cookie(name,'/',domain);
  } else {
    set_cookie(name,'1',never,'/',domain);
  }
  return true;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// select option

function select_opt (id) {
  field = document.getElementById(id);
  name = field.name;
  selectedValue = get_cookie(name);

  for (i = 0; i < field.length; i++) {
    if (field.options[i].value == selectedValue) {
      field.selectedIndex = i; break;
    }
  }
  return true;
}
function set_opt (field, reload) {
  name = field.name;
  value = field.options[field.selectedIndex].value;

  set_cookie(name,value,never,'/',domain);

  if (reload) {
    window.location = window.location;
  }
  return true;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// multicol if

function multicol_if (width, skin) {
  var stylin = '<link rel="stylesheet" type="text/css"';

  if (window.innerWidth > width
    || document.documentElement.clientWidth > width
    || document.body.clientWidth > width
  ) {
    document.write(stylin + ' href="/skin/style/multicol.css" />');
    document.write(stylin + ' href="/skin/' + skin + '/multicol.css" />');
  }
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// show div

function show_div (id) {
  document.getElementById(id).style.display = 'block';
  return true;
}
function hide_div (id) {
  document.getElementById(id).style.display = 'none';
  return true;
}
function toggle_div (id) {
  if (document.getElementById(id).style.display == 'none') {
    document.getElementById(id).style.display = 'block';
  } else {
    document.getElementById(id).style.display = 'none';
  }
}

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

