/*
  *     slide_mgr.js -- Map Gallery Slide Manager  Library
/* ----------------------------------------------------------------------------------------------------- */
/*
   version 1.1 -- Jim Cory, Horizon Mapping
   
   This version differs from the generic hm_slide_mgr.js used in the HM gallery.
   It loads the slides in reverse order (highest div id first) so that the last added
   map shows first (the last added is usually the newest).
 
*/

/*
-- Example of variable settings reqd in html head tag --

var currmapdiv = 0 ;
var maxmapdiv = 3 ;
var infodivs = new Array() ;

// assign values to array elements

infodivs[0] = "mapdiv0" ;
infodivs[1] = "mapdiv1" ;
infodivs[2] = "mapdiv2" ;
infodivs[3] = "mapdiv3" ;

*/

function toggleDiv(divid){
var ix;

// alert(divid);
// alert(infodivs[divid]) ;
// alert(document.getElementById("mapdiv0").style.display) ;
for (ix=maxmapdiv; ix>=0 ; ix--)
{ 
// alert(ix) ;
  document.getElementById(infodivs[ix]).style.display = 'none';
}
if (divid < 0) { 
 currmapdiv = maxmapdiv ;
 document.getElementById(infodivs[currmapdiv]).style.display = 'block'; 
}
else if (divid > maxmapdiv)
{ currmapdiv = 0 ;
  document.getElementById(infodivs[currmapdiv]).style.display = 'block';
}
else
{ 
// alert(infodivs[divid]) ;
  document.getElementById(infodivs[divid]).style.display = 'block';
}
}

function slideControl(buttonType, mouseType) {

  switch (buttonType) {
    case 'prevchap':
	  switch (mouseType) {
	    case 'down':
          currmapdiv = maxmapdiv ; 
          document.images.prevchap.src='images/openbook_nav_prevchapoff.png' ;
          toggleDiv(currmapdiv);
		break ;
	    case 'over':
		  if (currmapdiv != maxmapdiv) {
	        document.images.prevchap.src='images/openbook_nav_prevchapover.png';
		  }
		  break ;
		case 'out':
		  if (currmapdiv < maxmapdiv) {
	        document.images.prevchap.src='images/openbook_nav_prevchap.png'; 
		  }
		  else {
		    document.images.prevchap.src='images/openbook_nav_prevchapoff.png' ;
		  }
		  break ;
	  }
	  break ;
	case 'prevpg':
	  switch (mouseType) {
	    case 'down':
          currmapdiv = currmapdiv + 1 ;
          if (currmapdiv == maxmapdiv) {  
		    document.images.prevchap.src='images/openbook_nav_prevchapoff.png' ;
		  }
		  else {
		    document.images.prevchap.src='images/openbook_nav_prevchap.png' ; 
		  }		  
          toggleDiv(currmapdiv);
		  break ;
		case 'over':
	      document.images.prevpg.src='images/openbook_nav_prevpgover.png'; 
          break ;
		case 'out':
    	  document.images.prevpg.src='images/openbook_nav_prevpg.png' ;
		  break ;
		  }
	  break ;
	case 'nextpg':
	  switch (mouseType) {
	    case 'down':
		  currmapdiv = currmapdiv - 1 ; 
          if (currmapdiv >= 0) {
		    document.images.prevchap.src='images/openbook_nav_prevchap.png' ; 
		  }
		  else {
		    document.images.prevchap.src='images/openbook_nav_prevchapoff.png' ; 
		  }
	      toggleDiv(currmapdiv);
		  break ;
		case 'over':
		  document.images.nextpg.src='images/openbook_nav_nextpgover.png' ;
          break ;
		case 'out':
          document.images.nextpg.src='images/openbook_nav_nextpg.png' ;
		  break ;
		  }
	  break ;
	case 'nextchap':
	  switch (mouseType) {
	    case 'down':
		  currmapdiv = 0;
          toggleDiv(currmapdiv) ;
  		  document.images.prevchap.src='images/openbook_nav_prevchap.png' ; 
		  break ;
		case 'over':
	      document.images.nextchap.src='images/openbook_nav_nextchapover.png' ; 
          break ;
		case 'out':
    	  document.images.nextchap.src='images/openbook_nav_nextchap.png' ;
		  break ;
		  }
	  break ;

  }
	 
}
 
 function getanchor() {
  currURL = document.URL ;
//  alert(currURL) ;
  docanchor = currURL.substr(currURL.indexOf("#") + 1) ;
// alert(docanchor) ;
  currmapdiv = parseInt(docanchor,10) ;
// alert("--" + currmapdiv) ;
  if(!(isNaN(docanchor))) {
    toggleDiv(currmapdiv) ;
   if (currmapdiv >= 0 && currmapdiv < maxmapdiv) {
	 document.images.prevchap.src='images/openbook_nav_prevchap.png' ; 
   }
   else {
	 document.images.prevchap.src='images/openbook_nav_prevchapoff.png' ; 
   }
}
  else {
//    alert("no go") ;
	currmapdiv = maxmapdiv ;
	  }

}
