// FastGun.js 

//======================================================================
// version control
//======================================================================

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNN4 = (document.layers ? true : false);
var isBackCompat = ((document.layers || document.all) ? true : false);

// -- NotifyNotW3C() - tell user if we can't do this
function NotifyNotW3C(){
	if (isDOM) return false;
    var ss = "Sorry, this requires a W3C DOM compliant browser such as IE 5 or 6 or Netscape Navigator 6."
	alert(ss);
	return true;
}
//-- NotifyNotBackCompat() - tell user if we can't do this
function NotifyNotBackCompat(){
	if (isBackCompat) return false;
	var ss = "This page works only for Netscape 4, and IE 4, 5, 6."
	ss += "\nThe new Netscape browsers are not backward compatible to version 4."
	ss += "\nUpdating this code is on my to-do list."
	alert(ss);
	return true;
}

//======================================================================
// utls
//======================================================================
//-- getEl()
function getEl(id){
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNN4) return document.layers[id];
}

// getSty() - from el
function getSty(el){
 return (isNN4 ? el : el.style);
}
 
// getAnchor()
function getAnchor(sAncName, sDivName){
    if (isDOM) return getEl(sAncName);
    // note: the anchor may need a name (not ID) for NN4. Not sure.
    return null;
}
// setVis()
function setVis(el, bDisplay){// show or hide a div
  var sty = getSty(el);
  if (isDOM) bDisplay ? sty.visibility='visible' : sty.visibility='hidden';
  else alert("error in setVis");
 }

// setDisplay()
function setDisplay(el, value){// show or hide a div
  var sty = getSty(el);
  sty.display=value;
 }

// setX() -
function setX(el, x){
  getSty(el).left = x;
}

// setY()-
function setY(el, y){
  getSty(el).top = y;
}

// setXY() -
function setXY(el, x, y){
  setX(el, x);
  setY(el, y);
}

// getX()
function getX(el){
  return getSty(el).left;
}

// getY()
function getY(el){
  return getSty(el).top;
}

// showXY()
function showXY(el){
  alert("x=" + getX(el) + "  y=" + getY(el));
}

// getOffset()
function getOffset(el, which) { // which = "Top" or "Left"
    // calculate x or y of an element.
    var sum = el["offset"+which]
    if (which=="Top")
        sum+=el.offsetHeight
    el = el.offsetParent
    while (el!=null) {
        sum+=el["offset"+which]
        el = el.offsetParent
    }
    return sum
}
// setImg()
function setImg(divId, imgId, imgSrc){
    var el = document.getElementById(imgId);
    el.src = imgSrc;
    setVis(getEl(divId), true);
}


//======================================================================
// special functions for FastGun site
//======================================================================
// use this on pages in the html directory
function goHome(){
  if (parent.right) location="Right.htm"
  else location="Default.htm"
}
// use this on ASPX pages (which are one up form the HTML directory).
function goHome_Down(){
  if (parent.right) location="html/Right.htm"
  else location="Default.htm"
}
// Use this from pages one down from the html directory.
// I may not  be need this any more.
function goHome_Up(){
  if (parent.right) location="../Right.htm"
  else location="../Default.htm"
}
