// 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",
	"www.rapak-ap.com",
	"www.tri-wall.eu.com",
	"www.zewathener.com"
	)
var replacePaths = new Array(
	"DS%20Smith%20plc/index.html",
	"DS%20Smith%20Plastics/index.html",
	"DS%20Smith%20Packaging/index.html",
	"PSM/index.html",
	"Worldwide%20Dispensers/index.html",
	"BSK/index.html",
	"Kaysersberg%20Plastics/index.html",
	"DW%20Plastics/index.html",
	"Demes%20Logistics/index.html",
	"Rapak/index.html",
	"Rapak/europe/index.html",
	"Rapak/USA/index.html",
	"Rapak-AP/index.html",
	"Tri-Wall/index.html",
	"Zewathener/index.html"
	)

// 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()

