

function selectNavBar(path) {
	
	//var url= window.parent.mainFrame.document.location.href;
	var nav="none";
	 	
	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;
	
	 
	var group = nav.substr(0,6);  // this is reside, interi, landsc etc.
	var id = nav.substr(0,9);
	
	//alert("group: " +group+ "  id:" +id);
		
	if(document.getElementById(group)!=null) { 
		
		document.getElementById(group).className="main_category_selected";
	}
	
	if(document.getElementById(id)!=null) { 
 
		document.getElementById(id).className="sub_category_selected";
	}
}


function buildLogoBar(buildThis){

	var group = buildThis.substr(0,6);  // this is reside, interi, landsc etc.
	//alert("group: " +group);
		
	document.write('<div class="logo">');

	// insert shop services logo if it's a shop services page
	if(group=="shopse") { 
		
		document.write('<a href="home.html" target ="_self"><img src="images/mra_shop_logo.jpg" /></a>');
	}
	else document.write('<a href="index.html" target ="_self"><img src="images/mrf_logo.jpg" /></a>');

	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">');
	 
		
	//--OUTDOOR LINKS--//
	
	document.write('<a class="main_category" id="indout"   target="_self" href="indout.html">indoor / outdoor group</a><br />');
	   
	   if(nav=="indout") {
            document.write('<div class="right_nav_sub_list" id="indout_list">');
				document.write('<a class="sub_category" id="indout_01" target="_self" href="indout_01.html">dining table</a> <br />');
				document.write('<a class="sub_category" id="indout_02" target="_self" href="indout_02.html">dining chair</a> <br />');
				document.write('<a class="sub_category" id="indout_03" target="_self" href="indout_03.html">dining bench</a> <br />');
				document.write('<a class="sub_category" id="indout_04" target="_self" href="indout_04.html">low table</a> <br />');
				document.write('<a class="sub_category" id="indout_05" target="_self" href="indout_05.html">low lounge</a> <br />');
				document.write('<a class="sub_category" id="indout_06" target="_self" href="indout_06.html">chaise lounge</a> <br />');
				
		 document.write('</div>');
	   }	

	//--DINING LINKS--//

	document.write('<a class="main_category" id="dining"   target="_self" href="dining.html">dining group</a><br />');
	 
	 if(nav=="dining") {
            document.write('<div class="right_nav_sub_list" id="dining_list">');
				document.write('<a class="sub_category" id="dining_01" target="_self" href="dining_01.html">dining table</a> <br />');
				document.write('<a class="sub_category" id="dining_02" target="_self" href="dining_02.html">dining chair</a> <br />');
				document.write('<a class="sub_category" id="dining_03" target="_self" href="dining_03.html">side board</a> <br />');
				
		 document.write('</div>');
	 }
	 
	 //--LIVING GROUP LINKS--//
	
	document.write('<a class="main_category" id="living" target="_self" href="living.html"><span>living group</span></a><br />');
	 
	 if(nav=="living") {
				document.write('<div class="right_nav_sub_list" id="living_list" >');		
					document.write('<a class="sub_category" id="living_01"   target="_self" href="living_01.html">sofa</a> <br />');
					document.write('<a class="sub_category" id="living_02"   target="_self" href="living_02.html">sette</a> <br />');
					document.write('<a class="sub_category" id="living_03"   target="_self" href="living_03.html">club chair</a> <br />');
					document.write('<a class="sub_category" id="living_04"   target="_self" href="living_04.html">ottoman</a> <br />');
					document.write('<a class="sub_category" id="living_05"   target="_self" href="living_05.html">coffee table</a> <br />');
					
					document.write('</div>');
		}
	
	//--BEDROOM LINKS--//
	
	 document.write('<a class="main_category" id="bedrom"  target="_self" href="bedrom.html" ><span>bedroom group</span></a><br />');	
	
		if(nav=="bedrom") {
				document.write('<div class="right_nav_sub_list" id="bedrom_list" >');		
					document.write('<a class="sub_category" id="bedrom_01"   target="_self" href="bedrom_01.html">platform bed</a> <br />');
					document.write('<a class="sub_category" id="bedrom_02"   target="_self" href="bedrom_02.html">dresser</a> <br />');
					document.write('<a class="sub_category" id="bedrom_03"   target="_self" href="bedrom_03.html">night stand</a> <br />');
					
				document.write('</div>');
		}
	
	//--VIENNA WAY LINKS--//
	
	 document.write('<a class="main_category" id="vienna"  target="_self" href="vienna.html" ><span>vienna way group</span></a><br />');	
	
		if(nav=="vienna") {
				document.write('<div class="right_nav_sub_list" id="vienna_list" >');		
					document.write('<a class="sub_category" id="vienna_01"   target="_self" href="vienna_01.html">sofa</a> <br />');
					document.write('<a class="sub_category" id="vienna_02"   target="_self" href="vienna_02.html">chair</a> <br />');
					document.write('<a class="sub_category" id="vienna_03"   target="_self" href="vienna_03.html">side table</a> <br />');
					document.write('<a class="sub_category" id="vienna_04"   target="_self" href="vienna_04.html">lamp</a> <br />');
					document.write('<a class="sub_category" id="vienna_05"   target="_self" href="vienna_05.html">club chair</a> <br />');
					document.write('<a class="sub_category" id="vienna_06"   target="_self" href="vienna_06.html">club sette</a> <br />');
					document.write('<a class="sub_category" id="vienna_07"   target="_self" href="vienna_07.html">platform bed</a> <br />');
				document.write('</div>');
		}
	
	//--RANCH GROUP LINKS--//
	
	document.write('<a class="main_category" id="ranchg"  target="_self" href="ranchg.html" ><span>ranch group</span></a><br />');	
	
		if(nav=="ranchg") {
				document.write('<div class="right_nav_sub_list" id="ranchg_list" >');		
					document.write('<a class="sub_category" id="ranchg_01"   target="_self" href="ranchg_01.html">indoor sofa</a> <br />');
					document.write('<a class="sub_category" id="ranchg_02"   target="_self" href="ranchg_02.html">indoor chair</a> <br />');
					document.write('<a class="sub_category" id="ranchg_03"   target="_self" href="ranchg_03.html">dining chair</a> <br />');
					document.write('<a class="sub_category" id="ranchg_04"   target="_self" href="ranchg_04.html">outdoor chaise lounge</a> <br />');
					document.write('<a class="sub_category" id="ranchg_05"   target="_self" href="ranchg_05.html">stool</a> <br />');
					document.write('<a class="sub_category" id="ranchg_06"   target="_self" href="ranchg_06.html">outdoor settee</a> <br />');
					document.write('<a class="sub_category" id="ranchg_07"   target="_self" href="ranchg_07.html">outdoor coffee table</a> <br />');
					document.write('<a class="sub_category" id="ranchg_08"   target="_self" href="ranchg_08.html">outdoor low table</a> <br />');
					document.write('<a class="sub_category" id="ranchg_09"   target="_self" href="ranchg_09.html">outdoor lounge</a> <br />');
					document.write('<a class="sub_category" id="ranchg_10"   target="_self" href="ranchg_10.html">bed</a> <br />');
					
				document.write('</div>');
		}
		
		//--DESERT COLLECTION LINKS--//
	
	document.write('<a class="main_category" id="desert"  target="_self" href="desert.html" ><span>desert collection</span></a><br />');	
	
		//if(nav=="desert") {
				//document.write('<div class="right_nav_sub_list" id="desert_list" >');		
					//document.write('<a class="sub_category" id="desert_01"   target="_self" href="desert_01.html">chaise</a> <br />');
					//document.write('<a class="sub_category" id="desert_02"   target="_self" href="desert_02.html">side table</a> <br />');
					//document.write('<a class="sub_category" id="desert_03"   target="_self" href="desert_03.html">sette</a> <br />');
					//document.write('<a class="sub_category" id="desert_04"   target="_self" href="desert_04.html">lounge chair</a> <br />');
					//document.write('<a class="sub_category" id="desert_05"   target="_self" href="desert_05.html">coffee table</a> <br />');
					
				//document.write('</div>');
		//}
	
	//--KINGS ROAD LINKS--//
	
	document.write('<a class="main_category" id="kingrd"   target="_self" href="kingrd.html">kings road</a><br />');
		
		if(nav=="kingrd") {
            document.write('<div class="right_nav_sub_list" id="kingrd_list">');
				document.write('<a class="sub_category" id="kingrd_01" target="_self" href="kingrd_01.html">sofa</a> <br />');
				document.write('<a class="sub_category" id="kingrd_02" target="_self" href="kingrd_02.html">sling chair</a> <br />');
				document.write('<a class="sub_category" id="kingrd_03" target="_self" href="kingrd_03.html">ottoman</a> <br />');
				document.write('<a class="sub_category" id="kingrd_04" target="_self" href="kingrd_04.html">childs chair</a> <br />');
				document.write('<a class="sub_category" id="kingrd_05" target="_self" href="kingrd_05.html">stool</a> <br />');
           document.write('</div>');
		}

      document.write('<a class="main_category" id="mrfurn"   target="_self" href="mrfurn.html">about</a><br />');
	  
	  document.write('<a class="main_category" id="purchs" target="_self" href="purchs.html"><span>purchase</span></a><br />');
	 
	 document.write('<a class="main_category" id="contct" target="_self" href="contct.html"><span>contact</span></a><br />');
	 
	 document.write('<a class="main_category" id="homepg" target="_blank" href="http://www.marmol-radziner.com"><span>marmol radziner</span></a><br />');
    
	document.write('</div>');
	document.write('</div>');

	buildLogoBar(nav);
	selectNavBar("");

}


function test(id){

	alert('id: ' +id);
}



/* this code handles the thumb display and oppacity of the current selected image/thumb */

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=96;
	}
	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
}


 

/************************** 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.innerHeight) containerHeight = container.innerHeight;
		else containerHeight = container.clientHeight;

		if (lmt.innerHeight) 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];}
}
