

function test(id){

	alert('id: ' +id);
}

function intiOpacity(opacity) {
	
	theThumb=document.getElementById('thumb_0');
	theThumb.style.filter = 'alpha(opacity=' + opacity*10 + ')';		// IE/Win
	theThumb.style.opacity = opacity/10;								// Safari 1.2, newer Firefox and Mozilla, CSS3
	theThumb.style.KHTMLOpacity = opacity/10;			 				// Safari<1.2, Konqueror
	theThumb.style.MozOpacity = opacity/10;				 			// Older Mozilla and Firefox
}

function preloadImages(imgCount, imgArray, path) {
	
	for(i=0; i<imgCount; i++) {
		
		if(i<10) tempString = path+'0'+i+'.jpg';
		else tempString = path+i+'.jpg';
		
		//alert(tempString);
		imgArray[i]=new Image;
		imgArray[i].src=tempString;
	}
}


function swapImage(imgFrame, imgArray, imgNumber, opacity ) {
	
	 // this handles Safari's code which calls onmouseover continually
	if(imgFrame.src.search(imgArray[imgNumber].src)!= -1) {
		
		return;
	}
	
	imgFrame.style.visibility = 'hidden';
	imgFrame.src=imgArray[imgNumber].src;
	
	//alert("imgFrame: " + imgFrame.src + " width: " +imgFrame.width);
	
	// handle placement of small veritcal images
	if(imgFrame.width<500) {
		imgFrame.hspace=98;
	}
	else {
		imgFrame.hspace=0;
	}

	imgFrame.style.visibility = 'visible';
	
	// new image has been framed, now handle the image thumbs
	
	// reset all of the thumb images to full opacity
	for(i=0; i<imgArray.length; i++) {
		
		tempString = 'thumb_'+i;
	//	alert(tempString);
		theThumb=document.getElementById(tempString);
		
		theThumb.style.opacity = 1;
		theThumb.style.filter = 'alpha(opacity=' + 100 + ')';
		theThumb.style.KHTMLOpacity = 1;
		theThumb.style.MozOpacity = 1;
	}
	
	// set the new selected thumb opacity
	tempString = 'thumb_'+imgNumber;
	theThumb=document.getElementById(tempString);
	theThumb.style.filter = 'alpha(opacity=' + opacity*10 + ')';		// IE/Win
	theThumb.style.opacity = opacity/10;								// Safari 1.2, newer Firefox and Mozilla, CSS3
	theThumb.style.KHTMLOpacity = opacity/10;			 				// Safari<1.2, Konqueror
	theThumb.style.MozOpacity = opacity/10;							// Older Mozilla and Firefox
}


 



function selectNavBar(path) {
	
	//var url= window.parent.mainFrame.document.location.href;
	var nav="none";
	var theLink=null;
	
	if((path=="")||(path==null)) {
		var url = document.location.href;	
		if (url.indexOf('/') != -1) {
		
			while (url.indexOf('/') != -1) {
				url = url.substring((url.indexOf('/')+1),url.length);
			}
			nav=url;
		}
	}
	else nav = path;
	
	//alert("url:" +nav);
	 
	// window.onload = function(){
	/*
			document.all.sub_list_1.style.display = 'none';
			document.all.sub_list_2.style.display = 'none';
			document.all.sub_list_3.style.display = 'none';
			document.all.sub_list_4.style.display = 'none';
			
			document.all.sub_list_11.style.display = 'none';
			document.all.sub_list_12.style.display = 'none';
			document.all.sub_list_13.style.display = 'none';
			document.all.sub_list_14.style.display = 'none';
			document.all.sub_list_15.style.display = 'none';
	*/
	/*
		for(var i = 0; i < document.anchors.length; i++) {
			
			var a = document.anchors[i];
			var text = null;
			if (a.name) {
				
				text = a.name;
				//alert("document.anchors[i].name:" +text);
				
				if(text.match("residential")) document.anchors[i].className="mbi_res";
				else if(text.match("architecture")) document.anchors[i].className="mbi_arch";
				else if(text.match("root_10")) document.anchors[i].className="mbi_off_page";
				else if(text.match("root_11")) document.anchors[i].className="mbi_off_page";
				else document.anchors[i].className="mbi";			
			}
		 	else document.anchors[i].className="mbi";
			
			//alert("document.anchors[i].name:" +text);
		}
		*/
		
			switch (nav) {
				
				case "index.html": 
				case "home.html":   theLink=document.getElementById('home'); break;
				
				case "wood.html":  theLink=document.getElementById('wood'); break;
				
				case "metal.html": theLink=document.getElementById('metal'); break;
				
				case "contact.html": theLink=document.getElementById('contact'); break;
						 						 
/*
				case "residential_01.html":
				document.getElementById('residential').className="heading_selected";
				theLink=document.getElementById('residential_01');
				break;
				 
				case "restoration_01.html":
				document.getElementById('restoration').className="heading_selected";
				theLink=document.getElementById('restoration_01'); break;
*/				
				 
				default:  theLink=document.getElementById('home'); break;
				 
			}
			
			if(theLink!=null) theLink.className="mbi_selected";
	}


function buildLogoBar(){

	document.write('<div class="logo">');
	document.write('<td><a href="home.html" target ="_parent"><img src="images/mra_shop_logo.jpg" name="logo_img" width="302" height="16" class="logo_img"/></a></td>');
	document.write('</div>');
}
	
 
 
function buildNavBar(buildThis){

	var nav="none";
	
	// if no build this argument, use the URL to determin what to build 
	// this code isn't completely working yet
	if((buildThis=="")||(buildThis==null)) {
		var url = document.location.href;
		
		if (url.indexOf('/') != -1) {
		
			while (url.indexOf('/') != -1) {
				url = url.substring((url.indexOf('/')+1),url.length);
			}
			nav=url;
		}
	}
	else nav = buildThis;
	
	//alert("nav:" +nav);
	
	document.write('<div class="nav_bar"><div class="MenuBarContainer">');
	 
	document.write('<a class="MenuBarItem" id="home"   target="_self" href="home.html" ><span>home</span></a><br />');
	 
	document.write('<a class="MenuBarItem" id="wood"   target="_self" href="wood.html">cabinet shop</a><br />');
	 
    document.write('<a class="MenuBarItem" id="metal"   target="_self" href="metal.html">metal shop</a><br />');
	   
	document.write('<a class="MenuBarItem" id="contact" target="_self" href="contact.html">contact</a><br />');
		

	document.write('</div>');
	document.write('</div>');

	buildLogoBar();
	selectNavBar("");

}


/************************** this code handles centering the page content in the browser window **********************************/

function align()

{
	var lmt = document.getElementById('center');	 
	var container = document.documentElement;
//alert("lmt: " +lmt+ " container: " +container);

	if(lmt && container){
		
	    var containerHeight;
		var lmtHeight;

	    if (container.innerWidth) containerHeight = container.innerHeight;
		else containerHeight = container.clientHeight;

		if (lmt.innerWidth) lmtHeight = lmt.innerHeight;
		else lmtHeight = lmt.offsetHeight;

		var y = Math.ceil((containerHeight - lmtHeight) / 2);

		if(y < 0) y = 0;

		lmt.style.position = "relative";
		lmt.style.top = y + "px";
	}


	if (document.getElementById) document.body.style.visibility = 'visible';
 	document.getElementById('center').style.visibility = 'visible'; 
}



function addevent(obj,evt,fn,capt){

	if(obj.addEventListener){

		obj.addEventListener(evt, fn, capt);
		return true;
	}

	else if(obj.attachEvent){

		obj.attachEvent('on'+evt, fn);
		return true;
	}

	else return false;
}



/* now add the events to the event manager */

if (document.getElementById && document.getElementsByTagName){

		addevent(window, 'load', align, false);
		addevent(window, 'resize', align, false);
}


/*********************** dreamweaver scripts ****************************/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}