
/*
 * [businessofacting.at] scripts
 * $Id: script.js,v 1.35 2004/09/19 11:24:38 amael Exp $
 */


var protocol = 'http';
var domain = 'www.businessofacting.at'

var num_quotes = 11;
var num_recs = 4;
var rz = 1;

// --> menu items configuration

var sub_timeout = 3;
var sub_over = false;
var sub_level = -1;
var sub_active = -1;

var num_items = 3;
var sub_items = 3;

var item_links = new Array(num_items);
var sub_links  = new Array(num_items);

for (var i = 0; i < num_items; i++) {
  sub_links[i] = new Array(sub_items);
}

item_links[0] = 'company.html';
item_links[1] = 'service.html';
item_links[2] = 'contact.html';

sub_links[0][0] = 'howard.html';
sub_links[0][1] = 'objectives.html';
sub_links[0][2] = 'company.html';

sub_links[1][0] = 'industrial.html';
sub_links[1][1] = 'acting.html';
sub_links[1][2] = 'service.html';

sub_links[2][0] = false;
sub_links[2][1] = false;
sub_links[2][2] = false;

var s_item    = 'item';
var s_ihColor = '#ffc779';
var s_htem = 'item2';
var s_hhColor = '#ffc779';

var s_hide = 'hide';
var s_orange = 'orange';
var s_yellow = 'yellow';

// <-- end menu items configuration

// --> box items configuration

var num_atems = 7;

var s_atem = 'atem';
var s_atemHover = 'atem-hover';
var s_atemActive = 'atem-active';
var s_topAtem = 'top-atem';
var s_topAtemHover = 'top-atem-hover';
var s_topAtemActive = 'top-atem-active';

var s_boxcontent = 'box-content';

// <-- end box items configuration


// functions

function go(url) {
  window.location = protocol + '://' + domain + '/' + url;
}

function classname(obj, state) {
  if (obj && obj.evnt) {
    obj.evnt.className = state;
  }
}

function highlight(item, sub, obj) {
  if (sub) {
    obj.css.backgroundColor = s_hhColor;
    if (item == 0) {
      o_yhi.css.visibility = 'visible';
    }
  }
  else {
    obj.css.backgroundColor = s_ihColor;
    if (item == 0) {
      o_ohi.css.visibility = 'visible';
    }
  }
  if (sub || sub_links[item][0]) sub_over = true;
}

function dim(item, sub, obj) {
  obj.css.backgroundColor = 'transparent';

  if (item == 0) {
    if (sub) {
      o_yhi.css.visibility = 'hidden';
    }
    else {
      o_ohi.css.visibility = 'hidden';
    }
  }
  if (sub || sub_links[item][0]) sub_over = false;
}

function on_click(obj, handler)
{
  if (obj) {
    if(bw.ns4) {
      obj.ref.captureEvents(Event.MOUSEDOWN)
      obj.ref.onmousedown = new Function(handler);
    }
    else obj.evnt.onclick=new Function(handler);
  }
}


function sub_setup(active, show, item)
{
  if (active != 0 && item != -1 && sub_links[item][0]) o_yhi.css.visibility = 'hidden';
  if (sub_active == 0 && sub_level == item)  o_yhi.css.visibility = 'visible';

  if (!show || item < 0 || item > num_items || !sub_links[item][0]) {
    if (item < 0) {
      if (sub_level != -1) {
        sub_setup(sub_active, true, sub_level);
      }
      else {
        o_yellow.css.visibility = 'hidden';
        o_yhi.css.visibility = 'hidden';
        for (i = 0; i < num_items; i++) {
          for (h = 0; h < sub_items; h++) {
            if (o_htems[i][h]) o_htems[i][h].css.display = 'none';
          }
        }
      }
    }
  }
  else {
    o_yellow.css.visibility = 'visible';

    for (i = 0; i < num_items; i++) {
      for (h = 0; h < sub_items; h++) {
        if (i == item && o_htems[i][h]) {
          if (active != h) {
            o_htems[i][h].css.display = (show) ? 'block' : 'none';
            o_htems[i][h].evnt.onmouseover = new Function('highlight(' + h + ',1,o_htems['+i +']['+h+'])');
            o_htems[i][h].evnt.onmouseout = new Function('dim(' + h + ',1,o_htems['+i+']['+h+'])');
            on_click(o_htems[i][h], 'go("' + sub_links[i][h] + '")');
          }
          else {
            o_htems[i][h].css.display = (show) ? 'block' : 'none';
            o_htems[i][h].css.backgroundColor = s_hhColor;
            o_htems[i][h].evnt.onmouseover = new Function('');
            o_htems[i][h].evnt.onmouseout = new Function('');
            if (h == 0 && show) {
              o_yhi.css.visibility = 'visible';
            }
          }
        }
        else {
          if (o_htems[i][h]) o_htems[i][h].css.display = 'none';
        }
      }
    }
  }
}


function sub_delay() {
  if (sub_over) {
    setTimeout('sub_delay()', sub_timeout * 1000);
  }
  else {
    sub_setup(-1,false,-1);
  }
}

function sub_on(i, obj) {
  highlight(i,0,obj);
  sub_setup(-1,true,i);
}

function sub_off(i,obj) {
  setTimeout('sub_delay()', sub_timeout * 1000);
  dim(i,0,obj);
}

function box_show(box_active)
{
  o_btem.css.display = (box_active == -1) ? 'block' : 'none';
  for (i = 0; i < num_atems; i++) {
    if (box_active != i) {
      classname(o_atems[i], ((i == 0) ? s_topAtem : s_atem));
      classname(o_btems[i], s_hide);
      o_atems[i].evnt.onmouseover = new Function('classname(o_atems[' + i + '], ' + ((i == 0) ? 's_topAtemHover' : 's_atemHover') + ')');
      o_atems[i].evnt.onmouseout  = new Function('classname(o_atems[' + i + '], ' + ((i == 0) ? 's_topAtem' : 's_atem') + ')');
      on_click(o_atems[i], 'box_show(' + i + ')');
    }
    else {
      classname(o_atems[i], ((i == 0) ? s_topAtemActive : s_atemActive));
      classname(o_btems[i], s_boxcontent);
      o_atems[i].evnt.onmouseover = new Function();
      o_atems[i].evnt.onmouseout  = new Function();
    }
  }
}

function box_setup()
{
  o_btem = new lib_obj('b', 'skills');
  o_atems = new Array(num_atems);
  o_btems = new Array(num_atems);

  for (i = 0; i < num_atems; i++) {
    o_atems[i] = new lib_obj('a'+i, 'a');
    o_btems[i] = new lib_obj('b'+i, 'skills');
  }

  box_show(-1);
}


function random_quote()
{
  var z = Math.round(1 + (num_quotes - 1)*Math.random());
  document.write('<img class="quote" src="p/quote' + z + '.gif" alt="quote of the moment" />');
}

function get_width() {
  return (window.innerWidth) ? window.innerWidth :
    (document.body && document.body.offsetWidth) ? 
    (document.body.offsetWidth) : 0;
}
function get_height() {
  return (window.innerHeight) ? window.innerHeight :
    (document.body && document.body.offsetHeight) ? 
    (document.body.offsetHeight) : 0;
}

function post_intro(x,y) {
  o_logo.slideIt(x - 280, y, 4, 2, 'window.location = "intro.cgi";');
}

function placement(intro)
{
  var x = Math.round(get_width() / 2);
  var y = Math.round(get_height() / 8);

  if (!intro) {
    o_logo.moveIt(x - 280, y);
    o_blue.moveIt(x - 300, y + 25);
    o_orange.moveIt(x - 120, y + 45);
    o_yellow.moveIt(x - 180, y + 65);
  }
  else {
    o_logo.moveIt(x - 280, -25);
    o_blue.moveIt(-600, y + 25);
    o_orange.moveIt(x*2, y + 45);
    o_yellow.moveIt(x - 180, y + 65);
    o_logo.css.visibility = 'visible';
    o_blue.css.visibility = 'visible';
    o_orange.css.visibility = 'visible';

    o_blue.slideIt(x - 300, y + 25, 10, 1, 'post_intro('+x+','+y+')');
    o_orange.slideIt(x - 120, y + 45, 8, 2);
  }

  o_content.moveIt(x-300, y+110);
  o_disclaimer.moveIt(x-300, y+210+o_content.h);
}

function rec_next() {
   rz = (rz < num_recs) ? rz+1 : 1;
   o_rec.css.backgroundImage = 'url(p/rec_0' + rz + '.gif)';
}

function rec_prev() {
   rz = (rz > 1) ? rz-1 : num_recs;
   o_rec.css.backgroundImage = 'url(p/rec_0' + rz + '.gif)';
}

function setup(active, show_sub, active_sub, intro, rec)
{
  o_orange = new lib_obj('m1');
  o_yellow = new lib_obj('m2');
  o_ohi = new lib_obj('ohi', 'm1');
  o_yhi = new lib_obj('yhi', 'm2');
  o_logo = new lib_obj('logo');
  o_blue = new lib_obj('blue');
  o_content = new lib_obj('content');
  o_disclaimer = new lib_obj('disclaimer');

  if (rec) {
   o_rec = new lib_obj('rec');
   o_rn = new lib_obj('rn');
   o_rp = new lib_obj('rp');
   rz = (Math.round(1 + (num_recs - 1)*Math.random()));
   o_rec.css.backgroundImage = 'url(p/rec_0' + rz + '.gif)';
   on_click(o_rn, 'rec_next()');
   on_click(o_rp, 'rec_prev()');
  }

  classname(o_orange, s_orange);
  classname(o_yellow, s_yellow);

  o_items = new Array(num_items);
  o_htems = new Array(num_items);
  o_ohi.css.visibility = 'hidden';
  o_yhi.css.visibility = 'hidden';

  placement(intro);

  window.onresize = new Function('placement(false)');

  if (bw.ie) {
    o_orange.css.visibility = 'visible';
    o_logo.css.visibility = 'visible';
    o_blue.css.visibility = 'visible';
    o_content.css.visibility = 'visible';
    o_disclaimer.css.visibility = 'visible';
  }

  // orange item setup
  for (i = 0; i < num_items; i++) {
    o_items[i] = new lib_obj('i'+i, 'm1');
    if (active != i) {
      classname(o_items[i], s_item);
      o_items[i].evnt.onmouseover = new Function('sub_on('+i+', o_items['+i+'])');
      o_items[i].evnt.onmouseout = new Function('sub_off('+i+', o_items['+i+'])');
      on_click(o_items[i], 'go("' + item_links[i] + '")');
    }
    else {
      classname(o_items[i], s_item);
      o_items[i].css.backgroundColor = s_ihColor;
      o_items[i].evnt.onmouseover = new Function('sub_on('+i+', o_items['+i+'])');
      o_items[i].evnt.onmouseout = new Function('');
      if (i == 0) {
         o_ohi.css.visibility = 'visible';
      }
    }
    if (bw.ie) o_items[i].css.visibility = 'visible';

    // yellow item setup
    o_htems[i] = new Array(sub_items);
    for (h = 0; h < sub_items; h++) {
      o_htems[i][h] = (sub_links[i][h]) ? new lib_obj('i'+i+'h'+h, 'm2') : false;
      if (o_htems[i][h]) {
        classname(o_htems[i][h], s_htem);
        o_htems[i][h].css.visibility = 'visible';
      }
    }
  }
  sub_active = active_sub;
  sub_level = show_sub ? active : -1;
  sub_setup(sub_active, show_sub, sub_level);
}

/*
 * $Log: script.js,v $
 * Revision 1.35  2004/09/19 11:24:38  amael
 * added recommendations, fixed rb email and xml header
 *
 * Revision 1.34  2003/11/21 13:58:30  amael
 * *** empty log message ***
 *
 * Revision 1.33  2003/10/08 19:40:22  amael
 * fixed ie version
 *
 * Revision 1.32  2003/10/08 19:29:53  amael
 * fixed intro
 *
 * Revision 1.31  2003/10/08 14:04:11  amael
 * cleaned up scripts a little bit
 *
 * Revision 1.30  2003/10/06 22:08:04  amael
 * worked around explorer display glitch
 *
 * Revision 1.29  2003/10/01 17:02:10  rb
 * *** empty log message ***
 *
 * Revision 1.28  2003/09/26 21:06:34  amael
 * fixed iexplorer glitch
 *
 * Revision 1.27  2003/09/26 14:22:39  amael
 * hide stylesheets before they're loaded, first attempt
 *
 * Revision 1.26  2003/09/26 13:12:03  amael
 * finished intro and new submenu, added some event handling
 *
 * Revision 1.25  2003/09/25 22:38:50  amael
 * iexplorer fix
 *
 * Revision 1.24  2003/09/25 22:21:22  amael
 * iexplorer fix
 *
 * Revision 1.23  2003/09/25 22:14:51  amael
 * added intro slide and second submenu
 *
 * Revision 1.22  2003/09/25 18:43:42  amael
 * completely rewriting everything: broken at the moment
 *
 * Revision 1.21  2003/09/24 14:57:24  amael
 * fixed a few things...
 *
 * Revision 1.20  2003/09/22 20:40:54  amael
 * lores, 3rd version
 *
 * Revision 1.19  2003/09/22 20:31:20  amael
 * lores, 2nd version
 *
 * Revision 1.18  2003/09/21 11:22:27  amael
 * cb: nav seems to work in moz explorer and opera now
 *
 * Revision 1.17  2003/09/21 11:00:21  amael
 * added margin for first yellow element in all browsers
 *
 * Revision 1.16  2003/09/17 23:04:28  amael
 * fixed css errors
 *
 * Revision 1.15  2003/09/17 22:57:39  amael
 * fixed typo
 *
 * Revision 1.14  2003/09/17 22:36:01  amael
 * workaround for mozilla...
 *
 * Revision 1.13  2003/09/17 22:32:51  amael
 * found something that works, but it's strange...
 *
 * Revision 1.12  2003/09/17 21:50:32  amael
 * still broken highlights... testing only
 *
 * Revision 1.11  2003/09/17 21:23:16  amael
 * broken highlights... testing only
 *
 * Revision 1.10  2003/09/16 22:25:20  amael
 * added face, random quotes, fixed contact box/mozilla, added service box, some css changes
 *
 * Revision 1.9  2003/09/16 15:19:37  rb
 * *** empty log message ***
 *
 * Revision 1.8  2003/09/16 12:30:25  amael
 * fixed shade again...
 *
 * Revision 1.7  2003/09/16 12:25:52  amael
 * fixed shade links...
 *
 * Revision 1.6  2003/09/16 12:16:40  amael
 * handle fixed/absolute in script
 *
 * Revision 1.5  2003/09/16 12:13:51  amael
 * *** empty log message ***
 *
 * Revision 1.4  2003/09/09 11:18:58  amael
 * updated services, added scripts for service box
 *
 * Revision 1.3  2003/09/09 00:48:54  amael
 * okay, filled in lots of content
 *
 * Revision 1.2  2003/09/08 22:50:33  amael
 * lots of new scripts, moved stylesheets to css from src - that breaks stuff, but i'll fix it
 *
 * Revision 1.1  2003/09/08 18:11:17  amael
 * rewrote scripts and index.html - not tested yet
 *
 */

