/****************************** 
bswSwapImg is use for the project slideshows.
It swaps the main image, the thumbnail images and the caption
when a thumbnail is clicked. 
********************************/
function bswSwapImg(num){
	bswPrevImg = bswSelectedImg;
	bswSelectedImg = num;
	//swamp main project image
	document.images["bswProjImg"].src = bswProject[bswSelectedImg].src;
	//swap thumb image for selected project to 'on' state
	document.images["bswProjThmb" + bswSelectedImg].src = bswProjThmbOn[bswSelectedImg].src;
	//swap thumb image for previous project to 'off' state
	document.images["bswProjThmb" + bswPrevImg].src = bswProjThmbOff[bswPrevImg].src;
	// write caption to caption div
	caption = document.getElementById("bswProjCaption");
	caption.innerHTML = bswProjCaptions[bswSelectedImg];
}
/****************************** 
bswProjInit is called when a project detail page loads.
It sets up the initial project image and caption and thumbnail.
It also calls the hideDivs function to hide the 'more text'.
********************************/
function bswProjInit(){
	//alert('default = ' + bswSelectedImg);
	//swamp main project image
	document.images["bswProjImg"].src = bswProject[bswSelectedImg].src;
	//swap thumb image for selected project to 'on' state
	document.images["bswProjThmb" + bswSelectedImg].src = bswProjThmbOn[bswSelectedImg].src;
	// write caption to caption div
	caption = document.getElementById("bswProjCaption");
	caption.innerHTML = bswProjCaptions[bswSelectedImg];
	hideDivs('projIntro');
}



/***************************************************
 the following functions hide and show divs for the 
 'more' text
****************************************************/

function hideDivs(exempt)  {
	 if (!document.getElementsByTagName) {
      return null;
    }
    if (!exempt) exempt = "";
    var divs =
      document.getElementsByTagName("div");
    for(var i=0; i < divs.length; i++)
    {
      var div = divs[i];
      var id = div.id;
      if ((id != "wrapper") &&
          (id != "projTxt") &&
			 (id != "projListTxt") &&
			 (id != "bswProjCaption") &&
          (id != exempt))
      {
        div.style.display = "none";
      }
    }
  }
  
  function hide(what) {
	 if (!document.getElementById) {
      return null;
    }
    hideWhat =
      document.getElementById(what);
    hideWhat.style.display = "none";
    
  }
  
  function show(what)  {
	 if (!document.getElementById) {
      return null;
    }
    showWhat =
      document.getElementById(what);
    showWhat.style.display = "block";
    hideDivs(what);
  }
  
  /***************************************************
 the following functions hide and show layers for 
 the pop-up text boxes 
****************************************************/


function bswShowLayer(layerName)
{
    if (document.getElementById) // Netscape 6 and IE 5+
    {
       // alert('hello');
		  var targetElement = document.getElementById(layerName);
        targetElement.style.visibility = 'visible';
    }
}

function bswHideLayer(layerName)
{
    if (document.getElementById) // Netscape 6 and IE 5+
    {
        var targetElement = document.getElementById(layerName);
        targetElement.style.visibility = 'hidden';
    }
}

/***************************************************
 BELOW HERE NOT IN USE 
****************************************************/

/***************************************************
 the following functions determine the width of the
 browser and for positioning the pop-up text boxes 
****************************************************/


// determine width of browser in px
function base_x(){
	var x;
	if(document.all){
		x = document.body.clientWidth;
	} else {
		x = window.innerWidth;
	}	
	return x;
}

// position pop-up text boxes
function posItems(){
	if (document.getElementById("moreTxt")){
		document.getElementById("moreTxt").style.left=(base_x() - 774)/ 2;
	}
}