/*  Dynamic Buttons with popoup images.   Copyright RomanticRoad Munich 2004-2006. All rights reserved  

This code gives the visibility attribute to a set of div containers (e.g., each containing a small image), for example: id =  elemm1, elemm2, ....  
and stores them in the array: dynbnObjs[]. The contents of a div container becomes visible when the appropriate  active text button  is moused-over. 
Each active text button contains a href-link so that when the button is mouse-clicked a window pops up containing an appropriate page.  

Note 1: Place in the head section.   <script type="text/javascript" src="../jscode/dynbn.js"></script>  

Note 2: On the main page in the body section, the function call to initdynbn("root") must be placed  just AFTER  the div containers.  For example:
document.write("<div id='popimg1' >");adaptImg("../images/popresv.jpg",75,75,"popimg");document.write("</div>");
document.write("<div id='popimg2' >");adaptImg("../images/poppack.gif",75,75,"popimg");document.write("</div>");
document.write("<div id='popimg3' >");adaptImg("../images/popviewrm.jpg",75,75,"popimg");document.write("</div>");
initdynbn("popimg");

Note 3. The corresponding active TEXT buttons are placed farther down in the body section, for example in a row of a table:
		<tr>
			<td valign="top" align="center">
				<p class="dynbn"><script language="javascript" type="text/javascript" >
				dyntxtbn("Specials","dynlink","packages.php",2);txtspace(3);
				dyntxtbn("Reserve Room","dynlink","resv.php",1);txtspace(3);
				dyntxtbn("Explore Rooms","dynlink","viewrooms.php",3);txtspace(2);
				</script></p>
			</td>
		</tr>	

Note 4. The corresponding active IMAGE buttons are placed farther down in the body section, for example:

		document.write("<div id='nav11' >"); dynroll("story",storyw,storyh,"nav","story.php",mobjsnum); document.write("</div>");
		document.write("<div id='nav12' >"); dynroll("ref",refw,refh,"nav","references.php",mobjsnum); document.write("</div>");

Note 5: The following list provides the usual correspondance between names of the popup images shown in Note 2 and the button links shown in Note 3.
popresv.jpg  	with  	"resv.php"
poppack.jpg   	with   	"packages.php"
popviewrm.jpg  	with 	"viewrooms.php"  
popstory.jpg	with 	"story.php"
popactiv.jpg	with 	"activities.php"
popevent.jpg  	with   	"events.php"
popspec.jpg 	with 	"specials.php"
popguest.jpg	with 	"guestbk.php"
popmenu.jpg	with	"menu.php"
popwine.jpg	with	"wine.php"
popref.jpg	with	"references.php"

*/

var dynbnObjs = new Array();
var nrpopimg = 3;  // this a default value that is to be reset in the head section

function initdynbn(rootid)
{
	var ctrObj = nrpopimg;
	for ( var i = 1; i <= ctrObj; i++)
	{
		var elemtemp = rootid + i;
		if (document.getElementById)
		{
			dynbnObjs[i]  = document.getElementById(elemtemp).style;
		}
		else
		{
			dynbnObjs[i] = document[elemtemp];
		}
		dynbnObjs[i].visibility = "hidden";
	}
}	
	
function imghide()
{
	for ( var i = 1; i <= nrpopimg; i++)
	{
		dynbnObjs[i].visibility = "hidden";
	}
}

function dyntxtbn(visibletxt,ankclass,linkhref,mobjsnum ) 
{
	// Dynamic TEXT button
	// Note: mobjsnum is the integer that equals the index i (of div container, rootidi ) of the array: dynbnObjs[i]  
	// The size of the text's font and the width of the text's external p container  are set in the head section.
	//  i.e.,  a valid call is:     dyntxtbn("Reserve Room","mnlink","mnbutton",1,"resv.php");
	
	document.write("<a  href='javascript:popWin(\"" + linkhref +"\")'  "  +
	"onMouseOver='dynbnObjs[" + mobjsnum + "].visibility = \"visible\"; '  " +
	" onMouseOut='dynbnObjs[" + mobjsnum + "].visibility = \"hidden\"; '  " +
	"class='" + ankclass + "'>" + visibletxt +  "</a>");
}

function dynroll(bnname,bnwidth,bnheight,bnclass,linkhref,mobjsnum)
{
	// Dynamic IMAGE button 
	// Note: values for each img button's width and height in pixels are set in the file:  ../config/custdatamain.js  
	// Therefore for example, if in the call to dynrollbn,  bnname is "resv"  then  bnwidth  should the variable name: resvw   
	// and bnheight should be the variable name:  resvh
	//  i.e.,  a valid call is:    dynrollbn("resv",resvw,resvh,"mnbutton","resv.php",1)

	var bnpgname = "images/bn" + bnname + scrw +  ".gif";
	var bnpgnameh = "images/bn" + bnname +  "h" + 1024 + ".gif"; 
	var imgw = Math.floor(bnwidth  * scrw / 1024);
	var imgh = Math.floor(bnheight * scrw / 1024);
	var tagn =  bnname + "name";

	document.write("<a  href='javascript:popWin(\"" + linkhref +"\")'  "  +
	"onMouseOver='document." + tagn + ".src=\"" + bnpgnameh + "\";dynbnObjs[" + mobjsnum + "].visibility=\"visible\";'   "   + 
	" onMouseOut='document." + tagn + ".src=\"" + bnpgname   + "\";dynbnObjs[" + mobjsnum + "].visibility=\"hidden\";' >"  +
	"<img src='" + bnpgname + "'  border='0'   width='"  + imgw + "'   height='"  + imgh + "'  "  +
	" name='" + tagn + "'   class='" + bnclass + "' /></a>"); 
}


