
<!-- Created on Mar 5, 2004 4:26:06 PM -->
var Otitle="";
var Btitle="";

var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function showhide(id, elementObj) {
	if(elementObj.value == 'show code') {
		show(id);
		elementObj.value = 'hide code';
	} else {
		hide(id);
		elementObj.value = 'show code';
	}
}

function color(id, color) {
	// Netscape 4
	if(ns4){
		if(document.layers[id]) {
			document.layers[id].color = color;
		}
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.color = color;
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.color = color;
	}
}

function show(id) {
	// Netscape 4
	if(ns4){
		if(document.layers[id]) {
			document.layers[id].visibility = "show";
		}
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "visible";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.visibility = "visible";
	}
}

function hide(id) {
	// Netscape 4
	if(ns4){
		if(document.layers[id]) {
			document.layers[id].visibility = "hide";
		}
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "hidden";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.visibility = "hidden";
	}
}

function inner(id, innerh) {
	// Netscape 4
	if(ns4){
		if(document.layers[id]) {
			document.layers[id].inner_HTML = innerh;
		}
	}
	// Explorer 4
	else if(ie4){
		document.all[id].innerHTML = innerh;
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).innerHTML = innerh;
	}
}

// This is the function that refreshes the list after a keypress.
// The maximum number to show can be limited to improve performance with
// huge lists (1000s of entries).
// The function clears the list, and then does a linear search through the
// globally defined array and adds the matches back to the list.

function handleKeyUpO(maxNumToShow)
{
    var selectObj, textObj, functionListLength;
    var i, searchPattern, numShown;

    // Set references to the form elements
    selectObj = document.forms[0].functionselect;
    textObj = document.forms[0].functioninput;

    // Remember the function list length for loop speedup
    functionListLength = functionlist.length;
//    searchPattern = "^"+textObj.value;
    searchPattern = textObj.value;

    // Create a regulare expression
    re = new RegExp(searchPattern,"gi");
    // Clear the options list
    selectObj.length = 0;

    // Loop through the array and re-add matching options
    numShown = 0;
    for(i = 0; i < functionListLength; i++) {

	    if(functionlist[i].search(re) != -1) {
            selectObj[numShown] = new Option(functionlist[i],"");
   	      numShown++;
     		   x=i;
	     } 
    	  
        // Stop when the number to show is reached
        if(numShown == maxNumToShow) {
            break;
        }
    }

	for (i=0; i<mapheight; i++) {
		for (j=0; j<mapwidth; j++) {	
			if (map[i][j].ter!=0) {
			 	document.getElementById("dx"+i+"y"+j).cbe.background(colors[map[i][j].sec]);
			 }
		}
	} 
document.getElementById("loctltext").cbe.hide();
document.getElementById("smloctl").cbe.hide();			
document.getElementById("locbltext").cbe.hide();
document.getElementById("smlocbl").cbe.hide();			
document.getElementById("locbrtext").cbe.hide();
document.getElementById("smlocbr").cbe.hide();			
document.getElementById("loctrtext").cbe.hide();
document.getElementById("smloctr").cbe.hide();


    // When options list whittled to one, select that entry
    if (selectObj.length == 1) {
    
		var keywid=0;
		for (i=0;i<numkeywords;i++) {
			if (keyw_words[i]==selectObj.options[0].text) {
				keywid=keyw_ids[i];
			}
		}
		
var first=true;
for (i=0; i<numkeys; i++) {
	if (key_wid[i]==keywid) {
		hirow=key_row[i];
		hicol=key_col[i];
 		document.getElementById("dx"+hirow+"y"+hicol).cbe.background('ffff33');		
 		if (first) {
 			first=false;
 			var inner="You'll find that here";
			if (key_lid[i]!=0) {
				for (var k=0; k<numlocs; k++) {
					if (loc_ids[k]==key_lid[i]) {
						inner=inner+". Look "+loc_names[k];
					}
				}					
			}
			if (key_userstr[i]!='') {
				inner=inner+". Look for "+key_userstr[i];
			}
			inner=inner+".";

			if (hirow>(mapheight/2)) {
				if (hicol>(mapwidth/2)) {
					document.getElementById("locbrtext").cbe.innerHtml(inner);
					document.getElementById("locbrtext").cbe.show();
 					e1=document.getElementById("smlocbr").cbe;
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
		 			e1.show(); e1.slideTo(moffx+(tilesize*hicol)-265,moffy+(tilesize*hirow)-25,1000);
		 		}
		 		else {
					document.getElementById("locbltext").cbe.innerHtml(inner);
					document.getElementById("locbltext").cbe.show();
 					e1=document.getElementById("smlocbl").cbe;
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
		 			e1.show(); e1.slideTo(moffx+(tilesize*hicol)-5,moffy+(tilesize*hirow)-25,1000);
		 		}
			}
			else {
				if (hicol>(mapwidth/2)) {
					document.getElementById("loctrtext").cbe.innerHtml(inner);
					document.getElementById("loctrtext").cbe.show();
 					e1=document.getElementById("smloctr").cbe;			
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
 					e1.show(); e1.slideTo(moffx+(tilesize*hicol)-265,moffy+(tilesize*hirow)-5,1000);
				}
				else {
					document.getElementById("loctltext").cbe.innerHtml(inner);
					document.getElementById("loctltext").cbe.show();
 					e1=document.getElementById("smloctl").cbe;			
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
 					e1.show(); e1.slideTo(moffx+(tilesize*hicol)-5,moffy+(tilesize*hirow)-5,1000);
				}
			}
 		}
	}
}

      selectObj.options[0].selected = true;
    }
}

function handleSelectChangeO() {

			document.getElementById("loctltext").cbe.hide();
			document.getElementById("smloctl").cbe.hide();			
			document.getElementById("locbltext").cbe.hide();
			document.getElementById("smlocbl").cbe.hide();			
			document.getElementById("locbrtext").cbe.hide();
			document.getElementById("smlocbr").cbe.hide();			
			document.getElementById("loctrtext").cbe.hide();
			document.getElementById("smloctr").cbe.hide();

selectObj = document.forms[0].functionselect;
selectedValue = selectObj.options[selectObj.selectedIndex].text;
 
for (i=0; i<mapheight; i++) {
	for (j=0; j<mapwidth; j++) {	
		if (map[i][j].ter!=0) {	
		 	document.getElementById("dx"+i+"y"+j).cbe.background(colors[map[i][j].sec]);
		}
	}
} 
var keywid=0;
for (i=0;i<numkeywords;i++) {
	if (keyw_words[i]==selectedValue) {
		keywid=keyw_ids[i];
	}
}
var first=true;
for (i=0; i<numkeys; i++) {
	if (key_wid[i]==keywid) {
		hirow=key_row[i];
		hicol=key_col[i];
 		document.getElementById("dx"+hirow+"y"+hicol).cbe.background('ffff33');		
 		if (first) {
 			first=false;
 			var inner="You'll find that here";
			if (key_lid[i]!=0) {
				for (var k=0; k<numlocs; k++) {
					if (loc_ids[k]==key_lid[i]) {
						inner=inner+". Look "+loc_names[k];
					}
				}					
			}
			if (key_userstr[i]!='') {
				inner=inner+". Look for "+key_userstr[i];
			}
			inner=inner+".";

			if (hirow>(mapheight/2)) {
				if (hicol>(mapwidth/2)) {
					document.getElementById("locbrtext").cbe.innerHtml(inner);
					document.getElementById("locbrtext").cbe.show();
 					e1=document.getElementById("smlocbr").cbe;
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
		 			e1.show(); e1.slideTo(moffx+(tilesize*hicol)-265,moffy+(tilesize*hirow)-25,1000);
		 		}
		 		else {
					document.getElementById("locbltext").cbe.innerHtml(inner);
					document.getElementById("locbltext").cbe.show();
 					e1=document.getElementById("smlocbl").cbe;
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
		 			e1.show(); e1.slideTo(moffx+(tilesize*hicol)-5,moffy+(tilesize*hirow)-25,1000);
		 		}
			}
			else {
				if (hicol>(mapwidth/2)) {
					document.getElementById("loctrtext").cbe.innerHtml(inner);
					document.getElementById("loctrtext").cbe.show();
 					e1=document.getElementById("smloctr").cbe;			
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
 					e1.show(); e1.slideTo(moffx+(tilesize*hicol)-265,moffy+(tilesize*hirow)-5,1000);
				}
				else {
					document.getElementById("loctltext").cbe.innerHtml(inner);
					document.getElementById("loctltext").cbe.show();
 					e1=document.getElementById("smloctl").cbe;			
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
 					e1.show(); e1.slideTo(moffx+(tilesize*hicol)-5,moffy+(tilesize*hirow)-5,1000);
				}
			}
 		}
	}
}


}

// this function gets the selected value and sets the appropriate
// store terrain
function handleSelectClickO()
{
    selectObj = document.forms[0].functionselect;
    textObj = document.forms[0].functioninput;
    if (selectObj.selectedIndex==-1) return;
    selectedValue = selectObj.options[selectObj.selectedIndex].text;


for (i=0; i<mapheight; i++) {
	for (j=0; j<mapwidth; j++) {	
		if (map[i][j].ter!=0) {	
		 	document.getElementById("dx"+i+"y"+j).cbe.background(colors[map[i][j].sec]);
		}
	}
} 
var keywid=0;
for (i=0;i<numkeywords;i++) {
	if (keyw_words[i]==selectedValue) {
		keywid=keyw_ids[i];
	}
}

var first=true;
for (i=0; i<numkeys; i++) {
	if (key_wid[i]==keywid) {
		hirow=key_row[i];
		hicol=key_col[i];
 		document.getElementById("dx"+hirow+"y"+hicol).cbe.background('ffff33');		
 		if (first) {
 			first=false;
 			var inner="You'll find that here";
			if (key_lid[i]!=0) {
				for (var k=0; k<numlocs; k++) {
					if (loc_ids[k]==key_lid[i]) {
						inner=inner+". Look "+loc_names[k];
					}
				}					
			}
			if (key_userstr[i]!='') {
				inner=inner+". Look for "+key_userstr[i];
			}
			inner=inner+".";

			document.getElementById("loctltext").cbe.hide();
			document.getElementById("smloctl").cbe.hide();			
			document.getElementById("locbltext").cbe.hide();
			document.getElementById("smlocbl").cbe.hide();			
			document.getElementById("locbrtext").cbe.hide();
			document.getElementById("smlocbr").cbe.hide();			
			document.getElementById("loctrtext").cbe.hide();
			document.getElementById("smloctr").cbe.hide();

			if (hirow>(mapheight/2)) {
				if (hicol>(mapwidth/2)) {
					document.getElementById("locbrtext").cbe.innerHtml(inner);
					document.getElementById("locbrtext").cbe.show();
 					e1=document.getElementById("smlocbr").cbe;
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
		 			e1.show(); e1.slideTo(moffx+(tilesize*hicol)-265,moffy+(tilesize*hirow)-25,1000);
		 		}
		 		else {
					document.getElementById("locbltext").cbe.innerHtml(inner);
					document.getElementById("locbltext").cbe.show();
 					e1=document.getElementById("smlocbl").cbe;
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
		 			e1.show(); e1.slideTo(moffx+(tilesize*hicol)-5,moffy+(tilesize*hirow)-25,1000);
		 		}
			}
			else {
				if (hicol>(mapwidth/2)) {
					document.getElementById("loctrtext").cbe.innerHtml(inner);
					document.getElementById("loctrtext").cbe.show();
 					e1=document.getElementById("smloctr").cbe;			
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
 					e1.show(); e1.slideTo(moffx+(tilesize*hicol)-265,moffy+(tilesize*hirow)-5,1000);
				}
				else {
					document.getElementById("loctltext").cbe.innerHtml(inner);
					document.getElementById("loctltext").cbe.show();
 					e1=document.getElementById("smloctl").cbe;			
	 				e1.width(290); e1.height(50);
 					e1.moveTo(moffx+((mapwidth*tilesize)/2)-150,(moffy+((mapheight*tilesize)/2)));
 					e1.show(); e1.slideTo(moffx+(tilesize*hicol)-5,moffy+(tilesize*hirow)-5,1000);
				}
			}
 		}
	}
}

}

function clearO() {
	document.forms[0].functioninput.value='';
	handleKeyUpO(500);
	return;
}
