var MAXPAGES = 6;
var PAGES_NAV = 6;

// variable 'currentpage' identifies the 'index' of the current page of the website being viewed by the user. This is set // by the .htm file of the page itself in the 'init()' function.

var arrpage = new Array(6);
var arrmark = new Array(0, 100, 200, 300, 400, 500); // the values for the 'top' attribute for each image

arrpage[0] = new webpage(1,"index.htm","image/menu/bwelcomeup.jpg","image/menu/bwelcomedown.jpg");
arrpage[1] = new webpage(2,"testimonials.htm","image/menu/btestimonialup.jpg","image/menu/btestimonialdown.jpg");
arrpage[2] = new webpage(3,"services.htm","image/menu/bservicesup.jpg","image/menu/bservicesdown.jpg");
arrpage[3] = new webpage(4,"largest.htm","image/menu/blargestup.jpg","image/menu/blargestdown.jpg");
arrpage[4] = new webpage(5,"charity.htm","image/menu/bresearchup.jpg","image/menu/bresearchdown.jpg");
arrpage[5] = new webpage(6,"links.htm","image/menu/blinksup.jpg","image/menu/blinksdown.jpg");

      function webpage(apageno,apageurl,aimageup,aimagedown) {
         this.pageno = apageno;              // index of last paragraph added to 'descs' array
         this.pageurl = apageurl;
         this.imageup = aimageup;     //
         this.imagedown = aimagedown;     //
      }
      webpage.prototype.addcontent = function(acontent) {
      }
      

function initwebpage() {
   markpage(currentpage);
}

// generate the HTML for the left-hand menu bar
function makemenublock(apanel) {

   function getheight(aindex) {
      var divheight = 100;
      if (aindex==6) {
         divheight = 64;
         }
      return(divheight); 
      }
   

   // generate the HTML for one menu item
   function makemenuitem(index,aname,atop,aheight) {
      newdiv.id = aname;
      newdiv.style.top = atop+"px";
      newdiv.style.position = "absolute";
      newdiv.style.width = "125px";
      newdiv.style.height = aheight+"px";
      newdiv.style.left = "0px";
      newdiv.style.border = "0px white solid";
      newdiv.style.margin = "0px";
      newdiv.style.padding = "0px";


      newimage = document.createElement("img");
      newimage.id = "linkimage0"+index;
      newimage.src = arrpage[index-1].imageup;
      newimage.onmouseover = new Function("onmouseovermenu("+index+")");
      newimage.onmouseout = new Function("onmouseoutmenu("+index+")");
      newimage.onclick = new Function("gotopage("+index+")");

      newdiv.appendChild(newimage);
      newimage=null
      }


   for (var i=1; i<=MAXPAGES; i++) { 
      // create a DIV with enumerated identifier
      var newdiv=document.createElement("div");
      makemenuitem(i,"menuitem0"+1,arrmark[i-1],getheight(i));
   
      document.getElementById(apanel).appendChild(newdiv);
      newdiv=null;
      }

   }

      function altimg() {
	document.writeln("altimg entered");
         }

      function preloader() {
	bwelcomeup = new Image();
	bwelcomeup.src = "image/menu/bwelcomeup.jpg";
	bwelcomedown = new Image();
	bwelcomedown.src = "image/menu/bwelcomedown.jpg";
	btestimonialup = new Image();
	btestimonialup.src = "image/menu/btestimonialup.jpg";
	btestimonialdown = new Image();
	btestimonialdown.src = "image/menu/btestimonialdown.jpg";
	bservicesup = new Image();
	bservicesup.src = "image/menu/bservicesup.jpg";
	bservicesdown = new Image();
	bservicesdown.src = "image/menu/bservicesdown.jpg";
	blargestup = new Image();
	blargestup.src = "image/menu/blargestup.jpg";
	blargestdown = new Image();
	blargestdown.src = "image/menu/blargestdown.jpg";
	bcancerresearchup = new Image();
	bcancerresearchup.src = "image/menu/bresearchup.jpg";
	bcancerresearchdown = new Image();
	bcancerresearchdown.src = "image/menu/bresearchdown.gif";
	blinksup = new Image();
	blinksup.src = "image/menu/blinksup.jpg";
	blinksdown = new Image();
	blinksdown.src = "image/menu/bwelcomebase.jpg";
        }


	function onmouseovermenu(iItem) {
           var thissrc = document.getElementById("linkimage0"+iItem).src;
           var thisimg = document.getElementById("linkimage0"+iItem);

           if (iItem == currentpage) {
              return;
              }
	   if (thissrc == getbasedir()+arrpage[iItem-1].imageup) {
                thisimg.src = arrpage[iItem-1].imagedown;
		}
	   else {
                thisimg.src = arrpage[iItem-1].imageup;
		}
	}


	function onmouseoutmenu(iItem) {
           var thissrc = document.getElementById("linkimage0"+iItem).src;
           var thisimg = document.getElementById("linkimage0"+iItem);

           if (iItem == currentpage) {
              return;
              }
	   if (thissrc == getbasedir()+arrpage[iItem-1].imageup) {
		thisimg.src = arrpage[iItem-1].imagedown;
		}
	   else {
		thisimg.src = arrpage[iItem-1].imageup;
		}
	}


   function getbasedir(){
      var basedir = "";
      var i = 0;
            
      var path=window.location.href;
	   var path_array = path.split("/");
      while (i < (path_array.length - 1)) {
			if (i==0) {
				basedir = path_array[0];
				}
			else {
				basedir = basedir+"/"+path_array[i];
				}
         i+=1;
			}

      return(basedir+"/");
	}

 	function getip(){          
		var ip = '<!--#echo var="REMOTE_ADDR"-->';
            	return(" IP address: "+ip);
	}


function markpage(apage) {
   debug("markpage "+apage);

   var thisimg = document.getElementById("linkimage0"+apage);
   var marker = document.getElementById("pagemarker");
   marker.src = getbasedir()+"image/menu/pagemarker.jpg";
   marker.style.top = arrmark[apage-1]+"px";
   if (apage == 6) {
      marker.style.height = "64px";
      }
   else { 
      marker.style.height = "100px";
      }
   thisimg.src = arrpage[apage-1].imagedown;
   }

function gotopage(apage) {
   if (apage == currentpage) {
      return;
      }
      
   document.location.href = getbasedir()+arrpage[apage-1].pageurl;
   }



