// JavaScript Document
function randomImage() {
i = Math.round(Math.random()*1)+1;
	switch (i) {
		case 1:
		document.write("<img src='images/hp1.jpg' width='504' height='282' hspace='0' vspace='0'>");
		break;
		case 2:
		document.write("<img src='images/hp2.jpg' width='504' height='282' hspace='0' vspace='0'>");
		break;
	}
}


function open_picture(w,h,photo){
 	var winl = (screen.width / 2)-(w/2);
	var wint = (screen.height - h) / 2;
 		self.name="main";
		pic_window = window.open('', 'Picture', 'scrollbars=no,resizable=yes,left='+winl+',top='+wint+'');
		pic_window.resizeTo(w+10,h+80);
		pic_window.document.open();
		pic_window.document.write("<HTML><HEAD>");
		pic_window.document.write("<Title>BedWorks</title>");
		pic_window.document.write("<link href='/stylesheet.css' rel='stylesheet' type='text/css'>");
		pic_window.document.write("</head><body bgcolor='#FFFFFF' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0'>");
		pic_window.document.write("<div align='center'><a href='javascript:window.close()'><font size='2' face='Arial, Helvetica, sans-serif'>Close Window</font></a><br></div>");
		pic_window.document.write("<div align='center'><IMG HSPACE=0 VSPACE=0 height=" + h + " width=" + w + " SRC='" + photo + "'></div>");
		pic_window.document.write("</body></html>");
		pic_window.document.close();
}
function open_pictureFinish(w,h,photo,myName){
 	var winl = (screen.width / 2)-(w/2);
	var wint = (screen.height - h) / 2;
 		self.name="main";
		pic_window = window.open('', 'Picture', 'scrollbars=no,resizable=yes,left='+winl+',top='+wint+'');
		pic_window.resizeTo(w+30,h+130);
		pic_window.document.open();
		pic_window.document.write("<HTML><HEAD>");
		pic_window.document.write("<Title>"+myName+"</title>");
		pic_window.document.write("<link href='/stylesheet.css' rel='stylesheet' type='text/css'>");
		pic_window.document.write("</head><body bgcolor='#FFFFFF' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0'>");
		pic_window.document.write("<div align='center'><a href='javascript:window.close()'><font size='2' face='Arial, Helvetica, sans-serif'>Close Window</font></a><br></div>");
		pic_window.document.write("<div align='center'><IMG HSPACE=0 VSPACE=0 height=" + h + " width=" + w + " SRC='" + photo + "' border=1></div>");
		pic_window.document.write("<div align='center'><font size='2' face='Arial, Helvetica, sans-serif'>"+myName+"</font><br></div>");
		pic_window.document.write("<div align='center'><font size='1' face='Arial, Helvetica, sans-serif'>Your monitor may display finish color slightly different from actual</font><br></div>");
		pic_window.document.write("</body></html>");
		pic_window.document.close();
}
function open_pictureBed(w,h,photo,myName){
 	var winl = (screen.width / 2)-(w/2);
	var wint = (screen.height - h) / 2;
 		self.name="main";
		pic_window = window.open('', 'Picture', 'scrollbars=no,resizable=yes,left='+winl+',top='+wint+'');
		pic_window.resizeTo(w+30,h+130);
		pic_window.document.open();
		pic_window.document.write("<HTML><HEAD>");
		pic_window.document.write("<Title>"+myName+"</title>");
		pic_window.document.write("<link href='/stylesheet.css' rel='stylesheet' type='text/css'>");
		pic_window.document.write("</head><body bgcolor='#FFFFFF' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0'>");
		pic_window.document.write("<div align='center'><font size='2' face='Arial, Helvetica, sans-serif'>"+myName+"</font><br></div>");
		pic_window.document.write("<div align='center'><IMG HSPACE=0 VSPACE=0 height=" + h + " width=" + w + " SRC='" + photo + "'></div>");
		pic_window.document.write("<div align='center'><a href='javascript:window.close()'><font size='2' face='Arial, Helvetica, sans-serif'>Close Window</font></a><br></div>");
		pic_window.document.write("</body></html>");
		pic_window.document.close();
}
		
function buildDepth(iterations){
    var iterations=iterations-3;
    var depthStr="";
    for (i=0;i<iterations;i++){
        depthStr=depthStr + "../";
    }
    return depthStr;
}

function buildBreadCrumbTrail(){
//http://www.jacarandanyc.com/View_Collection/Flatware_Collection/100019.htm#

    var constituentFolders = new Array();
    var currentURL = document.location.toString();
	while (currentURL.indexOf("_")>0){
	whereIsIt = currentURL.indexOf("_");
	partA = currentURL.substring(0, whereIsIt);
	partB = currentURL.substring(whereIsIt + 1);
	currentURL = partA + " " + partB
	}
    constituentFolders=currentURL.split("/");
    var outputStr="<a href='/index.html' class='breadcrumbBlue'>Home</a><span class='breadcrumbBlack'> > </span>";
	
	for (count=3;count<(constituentFolders.length-1);count++){
	
        outputStr=outputStr + "<a href='" + buildDepth((constituentFolders.length-count)+1) + "index.htm' class='breadcrumbBlue'>" + constituentFolders[count] + "</a><span class='breadcrumbBlack'> > </span>";
    }
		
	lastSlash = currentURL.lastIndexOf("/");
	pageName = currentURL.substring(lastSlash+ 1);
	dotLoaction = pageName.indexOf(".");
	pageTitle = pageName.substring(0, eval(dotLoaction));
	howLong = constituentFolders.length - 2
	thisFolder = constituentFolders[howLong]
	if (pageTitle == "index"){
	outputStr=outputStr;
	} else{
	outputStr=outputStr + "<span class='breadcrumbBlack'>"+pageTitle+"</span>";
	}  
	document.write(outputStr);
}

function buildPageTitle(){
    var constituentFolders = new Array();
    var currentURL = document.location.toString();
	while (currentURL.indexOf("_")>0){
	whereIsIt = currentURL.indexOf("_");
	partA = currentURL.substring(0, whereIsIt);
	partB = currentURL.substring(whereIsIt + 1);
	currentURL = partA + " " + partB
	}
    constituentFolders=currentURL.split("/");
	var outputStr= "<title>"
    for (count=3;count<(constituentFolders.length-1);count++){
        outputStr=outputStr + constituentFolders[count] + " > ";
    }
	lastSlash = currentURL.lastIndexOf("/");
	pageName = currentURL.substring(lastSlash+ 1);
	dotLoaction = pageName.indexOf(".");
	pageTitle = pageName.substring(0, eval(dotLoaction));
	if (pageTitle == "index"){
	outputStr=outputStr + "</title>";
	document.write(outputStr);
	} else{
	outputStr=outputStr + pageTitle + "</title>";
	document.write(outputStr);
	}  
}