//==============================================================
// JavaScript Document
// By Martin Lundgren, Basilicon AB
// 2004-11-03 ML - Created
//==============================================================
// To use this functionallity it's asumed that you have a two
// dimentional global array called "arrImgs" defined.
// 
// 1. Current active picture true/false
// 2. <img> id
// 3. URL to non active picture
// 4. URL to active picture
// var arrImgs = new Array([false, 'menu0', 'images/menu_pic1_off.gif', 'images/menu_pic1_on.gif'],
//  					   [false, 'menu1', 'images/menu_pic2_off.gif', 'images/menu_pic2_on.gif']);
// 
// Then call imgClick() on load to set default.
// 
// <a href="asp/file1.asp" onClick="imgClick(0);" onMouseOver="imgSwap(0);" onMouseOut="imgRestore();"><img src="images/menu_pic1_off.gif" border="0" id="menu0"></a><br>
// <a href="asp/file2.asp" onClick="imgClick(1);" onMouseOver="imgSwap(1);" onMouseOut="imgRestore();"><img src="images/menu_pic2_off.gif" border="0" id="menu1"></a>



//==============================================================
// Function sets the active (clicked) button/image link.
//==============================================================
function imgClick(pos) {
  // Set the current button/image to non active
  if(arrImgs && pos >= 0) {
    var img;
    for(var i=0; i<arrImgs.length; i++) {
      if(arrImgs[i][0] == true) {
        arrImgs[i][0] = false;
	  }
    }
    // Activates the button/image that was clicked (sent to the functione by "pos")
	var img = document.getElementById(arrImgs[pos][1]);
    if(img) {
      img.src = arrImgs[pos][3];
	  arrImgs[pos][0] = true;
    }
  }
}


//==============================================================
// Function swaps the button/image difined by "pos" value
//==============================================================
function imgSwap(pos) {
  if(arrImgs && pos >= 0) {
    var img = document.getElementById(arrImgs[pos][1]);
    if(img && arrImgs[pos][0] != true) {
      img.src = arrImgs[pos][3];
    }
  }
}


//==============================================================
// Functions restore all images to there default (exept the active one)
//==============================================================
function imgRestore() {
  if(arrImgs) {
    var img;
    for(var i=0; i<arrImgs.length; i++) {
      img = document.getElementById(arrImgs[i][1]);
      if(img && arrImgs[i][0] != true) {
        img.src = arrImgs[i][2];
	  }
    }
  }
}
