
ns4=(document.layers)?true:false;
ie4=(document.all)?true:false;

function getRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function hidemenu(e) {
 if (MenuObj.cursid != "") {   
        if (ns4) {
                img = document.images[MenuObj.cursid];
                menu = document["menu_" + MenuObj.cursid];
                
                imgX = img.x;
                imgY = img.y;
                imgH = img.height;                      
                imgW = img.width;

				menuX = menu.pageX;
                menuY = menu.pageY;       
                menuW = menu.clip.right;        
		        menuH = menu.clip.bottom;

            //e.pageY and e.pageX are the current mouse location
			// mouse above the image (e.pageY < imgY)
			// mouse is below the menu (e.pageY > menuY)
			
		   if 	(((e.pageY < imgY) || (e.pageY > (menuY+menuH)))
		   		 || ((e.pageY > imgY) && (e.pageY < imgY+imgH) && ((e.pageX < imgX) || (e.pageX > imgX + imgW)))
		   		 || ((e.pageY > menuY) && (e.pageY < menuY+menuH) && ((e.pageX < menuX) || (e.pageX > menuX + menuW)))
		   		 
		  		 )  {
                hidediv(MenuObj.cursid);
              }
        } 
        else {
                hidediv(MenuObj.cursid);
        }

}  
}

function showdiv(sid, hasmenu){
        
	    if (MenuObj.cursid != "") {
            hidediv(MenuObj.cursid);                
        }
		if (sid != MenuObj.lit) {
	        document.images[sid].src =  MenuObj.imgdir + sid + "2.gif";        
		}
        MenuObj.cursid = sid;				
                        if (ns4) {
                                 divsid=eval("document.menu_"+sid);
                                 
                                 windowwidth = window.innerWidth;
                                 imageloc = document.images[sid].x;
                                 imagewidth = document.images[sid].width;
                                 imageheight = document.images[sid].height;                                 
                                 imagetop = document.images[sid].y;
                        }
                        if (ie4) {
                                divsid=eval("menu_"+sid+".style");
                                 windowwidth = document.body.clientWidth;
                                imageloc = getRealLeft(document.all["s_" + sid]);
                                imagewidth = document.all["s_" + sid].width;
                                imageheight = document.all["s_" + sid].height;
                                
                            imagetop =  getRealTop(document.all["s_" + sid]);
                        }
				if (imageloc > 0) {
					imageloc = imageloc - 1;
				}
                divsid.left= (imageloc);

                divsid.top= imagetop + imageheight -1;
 if (ns4) {
	divsid.visibility="show";
 }
if (ie4) { 
	divsid.visibility="visible";
}
//        }       
      if (ie4) window.event.cancelBubble = true;
}       

function subover(subrow) {
        subrow.style.backgroundColor = MenuObj.mocolor;
        subrow.style.cursor = 'hand';
}

function subout(subrow) {
        subrow.style.backgroundColor = MenuObj.bgcolor;
}

function hidediv(sid){
if (sid != "") {     
		if (sid != MenuObj.lit) {
		  document.images[sid].src = MenuObj.imgdir + sid + "1.gif";
		}
        if (ns4) divsid=eval("document.menu_"+ sid);
        if (ie4) divsid=eval("menu_"+sid+".style");
        if (ns4) divsid.visibility="hide";
        if (ie4) divsid.visibility="hidden";
        MenuObj.cursid = "";
}

}

function loadImage(imgname) {

	if (document.images) {
        		 imageObj1 = imgname + "1";
		         temp = eval(imageObj1 + " = new Image()");
        		 temp.src = MenuObj.imgdir + imageObj1 + ".gif";
				 
		         imageObj2 = imgname + "2";
        		 temp = eval(imageObj2 + " = new Image()");
		         temp.src = MenuObj.imgdir +  imageObj2 + ".gif";
}
}

function go2(urlstr) {
        top.location.href = urlstr;
}                        

function ft_highlight(imgname) {

	  document.images["ft_" + imgname].src = MenuObj.imgdir + imgname + "2.gif";

}
function ft_dim(imgname) {

	  document.images["ft_" + imgname].src = MenuObj.imgdir + imgname + "1.gif";
	  
}

if (ns4) { 
         document.captureEvents(Event.MOUSEMOVE); 
    	 document.onmousemove = hidemenu;
} else {
        document.onmouseover = hidemenu;
}
             
                         
function JCMenu() {
	this.bgcolor	="#FFFFFF";
	this.bordercolor="#000000";
	this.mocolor	="#CCCCCC";
	this.imgdir   = "";
	this.toroot   = "";
	this.cursid   = ""
}

MenuObj = new JCMenu();


function JCSubMenu(menuName) {
	this.menuName = menuName;
	this.nameArray = new Array();
	this.linkArray = new Array();
	loadImage(menuName)
	this.addItem 	= JCSubMenu_addItem;
	this.writeMenu  = JCSubMenu_showItems;
	
}

function JCSubMenu_addItem(itemname, itemlink) {
//get the highest item
	ItemNum = this.linkArray.length;
	this.nameArray[ItemNum] = itemname;
	this.linkArray[ItemNum] = itemlink;
}



function JCSubMenu_showItems() {

	numItems = this.linkArray.length;
	if (ns4) {
		ot = '<layer name="menu_' + this.menuName + '" visibility="hide" onmouseout="hidediv(MenuObj.cursid)">';
		ct = '</layer>';
	}
	else if (ie4 || is_nav5up) {
		ot = "<div id=\"menu_" + this.menuName + "\" style=\"position:absolute; visibility:hidden\" onmouseover=\"showdiv('" + this.menuName + "')\">";		
		ct = '</div>';
	}
	document.write (ot);

	if (numItems > 0) {
document.write('<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + MenuObj.bordercolor + '"><tr><td><table border="0" cellspacing="0" cellpadding="3" width="100%" bgcolor="' + MenuObj.bgcolor + '">');
		for (i = 0; i < numItems; i++) {
		suboverstr= (ie4) ? " onMouseOver=\"subover(this)\" onMouseOut=\"subout(this)\" onClick=\"go2('" + MenuObj.toroot + this.linkArray[i] + "')\" " : '';
		    document.write('<tr' + suboverstr + '>');
    		document.write('<td><a class="menu" target="_top" href="' + MenuObj.toroot + this.linkArray[i] + '">&nbsp;&nbsp;' + this.nameArray[i] +	'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>');
		}

	document.write("</table></td></tr></table>");	
	}
	
	document.write(ct);
}

MenuObj.section = jc_section
MenuObj.bordercolor= jc_bordercolor; 
MenuObj.bgcolor = jc_bgcolor;
MenuObj.mocolor = jc_mocolor;
MenuObj.imgdir  = jc_imgdir;
MenuObj.toroot  = jc_root;
MenuObj.lit  = jc_lit;

tempmenu = new JCSubMenu(MenuObj.section + "_products");
	tempmenu.addItem("Altars",  "products/altars/index.html");
	tempmenu.addItem("Baptismal Fonts",  "products/fonts/index.html");
	tempmenu.addItem("Biers",  "products/biers/index.html");
	tempmenu.addItem("Candlesticks",  "products/candlesticks/index.html");
	tempmenu.addItem("Chairs",  "products/chairs/index.html");
	tempmenu.addItem("Flower Stands",  "products/flowerstands/index.html");
	tempmenu.addItem("Kneelers",  "products/kneelers/index.html");
	tempmenu.addItem("Lecterns",  "products/lecterns/index.html");
	tempmenu.addItem("Pews",  "products/pews/index.html");
	tempmenu.addItem("Presiders Chairs",  "products/presiders/index.html");
	tempmenu.addItem("Prie-dieux",  "products/prie-dieux/index.html");
	tempmenu.addItem("Pulpits",  "products/pulpits/index.html");		
	tempmenu.addItem("Specials",  "products/specials/index.html");	
tempmenu.writeMenu();

tempmenu = new JCSubMenu(MenuObj.section + "_services");
	tempmenu.addItem("Computer Layouts",  "services/layouts.html");
	tempmenu.addItem("Kneeler Repair",  "services/kneelers.html");
	tempmenu.addItem("Pew Refinishing",  "services/refinishing.html");
	tempmenu.addItem("Reupholstering",  "services/reupholstery.html");			
	tempmenu.addItem("Custom Furniture Design", "services/custom.html");			
tempmenu.writeMenu();


tempmenu = new JCSubMenu(MenuObj.section + "_parts");
	tempmenu.addItem("Kneeler Parts",  "parts/kneelerparts.html");
	tempmenu.addItem("Kneeler Hardware",  "parts/hardware.html");
	tempmenu.addItem("Kneeler Shoes",  "parts/shoes.html");
tempmenu.writeMenu();

tempmenu = new JCSubMenu(MenuObj.section + "_usedpews");
tempmenu.writeMenu();

tempmenu = new JCSubMenu(MenuObj.section + "_aboutus");
	tempmenu.addItem("Contact Us", "about/contact.html");
	tempmenu.addItem("Directions", "about/directions.html");	
	tempmenu.addItem("History", "about/history.html");		
tempmenu.writeMenu();

tempmenu = new JCSubMenu(MenuObj.section + "_help");
	tempmenu.addItem("Search", "help/search.html");
	tempmenu.addItem("Sitemap", "help/sitemap.html");	
	tempmenu.addItem("FAQ", "help/faq.html");	
	tempmenu.addItem("Links", "help/links.html");			
tempmenu.writeMenu();