/*
** =======================================================
** Copyright © 2006 Beware of Design. All rights reserved. 
** -------------------------------------------------------
** Site:     www.bewareofdesign.com
** File:     src_bod-code.js
** Purpose:  Site-wide JavaScript code
** Author:   Greg Gurr
** ------------------------------------------------
** 2006-Sep-03 Created
** ================================================
*/

/*
** Browser-compatible ways to access elements (typically DIV or SPAN) by
** their id attribute.
*/
function elm(eid) { // return the element by id
       if (document.getElementById) return document.getElementById(eid)
  else if (document.all)            return document.all[eid]
  else if (document.layers)         return document.layers[eid]
}
function elc(p, c) { // return the element of the given parent by the specified class
  for(var i=0 ; i < p.childNodes.length ; ++i) if (p.childNodes[i].className == c) return p.childNodes[i]
}
function txt(telm) { // return the text of an element by id
  var k_udf = 'undefined';
       if (typeof(telm.text)        != k_udf) return telm.text 
  else if (typeof(telm.textContent) != k_udf) return telm.textContent 
  else if (typeof(telm.innerText)   != k_udf) return telm.innerText
  else return ''
}
function wrt(telm, tval) { // write to the text of an element by id
  var k_udf = 'undefined';
       if (typeof(telm.text)        != k_udf) telm.text = tval
  else if (typeof(telm.textContent) != k_udf) telm.textContent = tval
  else if (typeof(telm.innerText)   != k_udf) telm.innerText = tval
}

function nextcard(e, n) { // set the next biz card image [1..9]
  var img_e = elm(e);
  var c = parseInt(img_e.src.charAt(img_e.src.length-5));
  c = (c == n) ? 1 : (c + 1);
  img_e.src = e + '-' + c + '.jpg';
}
