function bodyinit() {
  initimgtags()
  if( document.getElementById( 'map' ) ) {
    loadMap()
  }
}

function initimgtags() {
  var overExt = "_on";
  if (document.getElementsByTagName) {
    var imgs = document.getElementsByTagName("img")
    var i, dotAt, imgFile, imgExt, tempImg;
    for (i = 0; i < imgs.length; i++) {
      if (imgs[i].className && imgs[i].className == "img-opaque") {
        eval( "imgs[i].onmouseover = function () { this.filters.alpha.opacity=100 }" ) 
        eval( "imgs[i].onmouseout  = function () { this.filters.alpha.opacity=90  }" ) 
      }
      else if (imgs[i].className && imgs[i].className == "img-swap") {
        dotAt  = imgs[i].src.lastIndexOf(".");
        if (dotAt > 0) {
          imgFile = imgs[i].src.substr(0,dotAt);
          imgExt  = imgs[i].src.substr(dotAt+1);
          if (imgFile.lastIndexOf(overExt) == imgFile.length - overExt.length) {
            // do nothing; image is already on
          }
          else {
            eval("imgs[i].onmouseover = function () {this.src = '" + imgFile + overExt + "." + imgExt + "'};");
            eval("imgs[i].onmouseout = function () {this.src = '" + imgFile + "." + imgExt + "'};");
            tempImg     = new Image;
            tempImg.src = imgFile + overExt+ "." + imgExt;
          }
        }
      }
    }
  }
}

function liover( id ) {
  var el = document.getElementById( id )
  el.className = 'nav-liover'
}
function liout( id ) {
  var el = document.getElementById( id )
  el.className = 'nav-liout'
}
function litoggle( id ) {
  var el = document.getElementById( id )
  el.className=(el.className=='divoff')?'divon':'divoff'
}

function hittest( target, keywords, num ) {
  var i
  var word = new Array()

  word = keywords.split(" ")
  for( i = 0; i < num; i++ )
    if( target.indexOf( word[i] ) == -1 )
      return 0
  return 1

}

function togglesubnav( flag ) {
  var id = document.getElementById('div-subnav')
  id.className=flag?'divon':'divoff'
}

var inav = 0
function showinav( num ) {
  var id, el
  if( inav != num && inav != 0 )
  {
    id = 'div-inav' + inav
    el = document.getElementById( id )
    el.className='divoff'
  }
  if( num )
  {
    id = 'div-inav' + num
    el = document.getElementById( id )
    el.className='divon'
  }
  inav = num
}

//
// query search string in page url
// http://www.eggheadcafe.com/articles/20020107.asp
//

function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key)); 
}


//
// popup image window
//

function imagepopup( imgpath, bg, popwidth, popheight, textdescription ) {
  var leftpos = ( window.screen.availWidth - popwidth ) / 2
  var toppos  = ( window.screen.availHeight - popheight ) / 2
  var winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
  var bodyattribute=(bg.indexOf(".")!=-1)? 'background="'+bg+'"' : 'bgcolor="'+bg+'"'
  bodyattribute += " topmargin='0' leftmargin='0' bottommargin='0' rightmargin='0' marginwidth='0' marginheight='0'"
  var scriptattribute=""
  if (typeof dppopwin=="undefined" || dppopwin.closed)
    dppopwin=window.open("","",winattributes)
  else
  {
    dppopwin.moveTo(leftpos, toppos)
    dppopwin.resizeTo(popwidth, popheight)
  }
  dppopwin.document.open()
  dppopwin.document.write('<html><title>'+textdescription+'</title><body '+bodyattribute+'>'+scriptattribute+'<center><img src="'+imgpath+'" GALLERYIMG="no"><center></body></html>')
  dppopwin.document.close()
  dppopwin.focus()
}
