// External JavaScript library for amending links in webpages when site is accessed without webserver

// History:
// JM: 14DEC2001 - 15:00-> library written

// Define variables (ensure last entry in arrays do NOT have a comma)
var rootPath = "C:/DSSmith/";
var matchDomains = new Array(
	"www.dssmith.uk.com",
	"www.dssmith-plastics.com",
	"www.dssmith-packaging.com",
	"www.psm-dssmith.com",
	"www.worldwide-dispensers.com",
	"www.bsk-laminating.com",
	"www.kaysersberg-plastics.com",
	"www.dwplastics.com",
	"www.demes-logistics.com",
	"www.rapak.com",
	"europe.rapak.com",
	"usa.rapak.com"
	)
var replacePaths = new Array(
	"DS.html Smith plc/index.htm",
	"DS.html Smith Plastics/index.htm",
	"DS.html Smith Packaging/index.htm",
	"PSM/index.htm",
	"Worldwide.html Dispensers/index.htm",
	"BSK/index.htm",
	"Kaysersberg.html Plastics/index.htm",
	"DW.html Plastics/index.htm",
	"Demes.html Logistics/index.htm",
	"Rapak/index.htm",
	"Rapak/UK/index.htm",
	"Rapak/USA/index.htm"
	)

// Functions start here (do not edit)
function replaceLinks() {
	if (document.location.protocol=="file:") {
		for (i=0; i<document.links.length; i++) {
			thisReplacement = findMatch(document.links[i].hostname);
			if (thisReplacement!="") {document.links[i].href=rootPath + thisReplacement}
			}
		}
	}

function findMatch(thisDomain) {
	for (j=0; j<matchDomains.length; j++) {
		if (matchDomains[j]==thisDomain) {return replacePaths[j]}
		}
	return ""
	}
	

replaceLinks()

