function cw_changePortfolio(serviceName, projectNum) {
	// change the service name and project number in the top bar of the viewer

	// ----- change the project number in the top bar of the viewer ---- 
	// set the max projects in this service
	var maxProjects = 0;
	var shortName = "";
	     if (serviceName == "Remodels")	{maxProjects = maxRemProjects; shortName = "Rem"; }
	else if (serviceName == "Additions")	{maxProjects = maxAddProjects; shortName = "Add"; }
	else if (serviceName == "Miscellaneous")	{maxProjects = maxMisProjects; shortName = "Mis"; }
	else if (serviceName == "Kitchens")	{maxProjects = maxKitProjects; shortName = "Kit"; }
	else if (serviceName == "Baths")	{maxProjects = maxBatProjects; shortName = "Bat"; }
	else if (serviceName == "Interiors")	{maxProjects = maxIntProjects; shortName = "Int"; }
	else if (serviceName == "Exteriors")	{maxProjects = maxExtProjects; shortName = "Ext"; }

	document.getElementById("portViewTop").innerHTML = serviceName+"&#160;&#160;&#160;&#160;";

	if (maxProjects == 0) {
		document.getElementById("portViewVeryBot").innerHTML = "<span style='font-size:10px;color:#999999;'>Not Available</span>";
		return false;
	}
	else {
		var numStr = "<span style='font-size:10px;color:#999999;'><br />Select Project -> ";
		for (co = 1; co <= maxProjects; co++) {
			if (co == projectNum) 
				numStr += "<span class='currentProjectNum'> "+co+"&#160;&#160;</span>";
			else numStr += " <a class='projectNumLink' href='#' onclick=\"cw_changePortfolio('"+serviceName+"',"+co+");return false;\">"+co+"</a>&#160;&#160;";

		}
		numStr += "</span>"
		document.getElementById("portViewVeryBot").innerHTML = numStr;
		cw_loadPortfolio(shortName,projectNum);
		return true;
	}
}
function cw_loadPortfolio(shortName, projectNum) {
	// get the directory name of this portfolio
	var dirName = "images_portfolio/DBS_"+shortName+"_"+projectNum;
	// there are large, medium, and small images.
	// load the small images
	var maxpics = 0;
	if (shortName == "Rem")
		maxpics = maxRemProjectFiles[projectNum]
	else if (shortName == "Add")
		maxpics = maxAddProjectFiles[projectNum]
	else if (shortName == "Mis")
		maxpics = maxMisProjectFiles[projectNum]
	else if (shortName == "New")
		maxpics = maxNewProjectFiles[projectNum]
	else if (shortName == "Kit")
		maxpics = maxKitProjectFiles[projectNum]
	else if (shortName == "Bat")
		maxpics = maxBatProjectFiles[projectNum]
	else if (shortName == "Int")
		maxpics = maxIntProjectFiles[projectNum]
	else if (shortName == "Ext")
		maxpics = maxExtProjectFiles[projectNum]
	var smallImgStr = "";
	for (picNum = 1; picNum <= maxpics; picNum++) {
		if (picNum % 9 == 0)
			smallImgStr += "<br />";
		if (picNum > 9)
			var numfrmt = "_00";
		else var numfrmt = "_000";
		smallImgStr += "<a href='javascript:show_IM(\"DBS_"+shortName+"_"+projectNum+"/large/DBS_"+shortName+"_"+projectNum+numfrmt+picNum+".jpg\")' onMouseOver=\"cw_showMediumPicture('"+shortName+"',"+projectNum+","+picNum+");\"><img hspace='2' vspace='4' src='images_portfolios/DBS_"+shortName+"_"+projectNum+"/small/DBS_"+shortName+"_"+projectNum+numfrmt+picNum+".jpg' style='border: 1px solid black;' height='40' /></a>";
	}
	document.getElementById("portViewBot").innerHTML = smallImgStr;
	cw_showMediumPicture(shortName,projectNum,1);
	
}
function cw_showMediumPicture(shortName,projectNum,picNum) {
		if (picNum > 9)
			var numfrmt = "_00";
		else var numfrmt = "_000";
	document.getElementById("portViewMid").innerHTML = "<a href='javascript:show_IM(\"DBS_"+shortName+"_"+projectNum+"/large/DBS_"+shortName+"_"+projectNum+numfrmt+picNum+".jpg\")'><img vspace='10' src='images_portfolios/DBS_"+shortName+"_"+projectNum+"/medium/DBS_"+shortName+"_"+projectNum+numfrmt+picNum+".jpg' style='border: 1px solid black;'></a>";
}
var IMWin = null;
function show_IM(image_name) {
	var image_x = 600;
	var image_y = 400;
        var IMtoshow = "view_large.php?p=" + image_name;
        image_x += 20; // Add some padding.
        image_y += 80; // Add padding at the top for client name.
        if (IMWin == null || IMWin.closed) {
                var open_arg_str = "resizable=yes,scrollbars=yes,toolbar=no,status=no,width=" +image_x+",height="+image_y+",left=10,top=30"
                IMWin = window.open(IMtoshow,"DBSviewer",open_arg_str);
        }
        else { // the window is already open.
                IMWin.location = IMtoshow;
        }
        IMWin.focus();
}


