var sRequestReferrer = window.location.host; // document.referrer;
var sDefaultDomain = "http://www.furnitureontheweb.com/";
var sLinkDomain = sDefaultDomain; 
var sDefaultColor = "#99600D";
var sDomainColor = sDefaultColor;
var sLiveDomain = sDefaultDomain;
var sDefaultTitle = "Furniture";
var sDomainTitle = sDefaultTitle;
var sSiteID = "1";

// field enumerations
var iLiveDomain = 0;
var iTestDomain = 1;
var iColor = 2;
var iTitle = 3;
var iSiteID = 4;

var recDomains = [
	['www.artfurnitureontheweb.com', '/artfurnitureontheweb/', '#99600D', 'Art Furniture', '3'],
	['www.ceilingfansontheweb.com', '/ceilingfansontheweb/', '#99600D', 'Ceiling Fans', '13'],
	['www.furnishingsontheweb.com', '/furnishingsontheweb/', '#99600D', 'Furnishings', '4'],
	['www.furnitureontheweb.com', '/furnitureontheweb/', '#99600D', 'Furniture', '1'],
	['www.kitchenwareontheweb.com', '/kitchenwareontheweb/', '#99600D', 'Kitchenware', '38'],
	['www.lampsontheweb.com', '/lampsontheweb/', '#99600D', 'Lamps', '2'],
	['www.linensontheweb.com', '/linensontheweb/', '#99600D', 'Linens', '5'],
	['www.rugsontheweb.com', '/rugsontheweb/', '#99600D', 'Rugs', '20'],
	['www.otwmg.com', '/otwmg/', '#000000', 'Customer Service', '0'],
	['www.jewelryontheweb.com', '/jewelryontheweb/', '#999966', 'Jewelry', '22'],
	['www.diamondjewelryontheweb.com', '/diamondjewelryontheweb/', '#999966', 'Diamond Jewelry', '32'],
	['www.gemstonejewelryontheweb.com', '/gemstonejewelryontheweb/', '#006699', 'Gemstone', '33'],
	['www.goldjewelryontheweb.com', '/goldjewelryontheweb/', '#996633', 'Gold Jewelry', '34'],
	['www.silverjewelryontheweb.com', '/silverjewelryontheweb/', '#999966', 'Silver Jewelry', '30'],
	['www.onthewebstores.com', '/', '#99600D', 'Stores', '28']
	];

var iStartPos = 0;
var iEndPos;
var iDomain;

if (sRequestReferrer != "") {
	for (iDomain = 0; iDomain < recDomains.length; iDomain++) {
		// try a live domain name match
		if (sRequestReferrer.match("^" + recDomains[iDomain][iLiveDomain], "i") != null) {
			sLinkDomain = "http://" + recDomains[iDomain][iLiveDomain] + "/";
			sLiveDomain = sLinkDomain;
			break;
		} // if
		else {
			// else try a test domain name match
			if (sRequestReferrer.match(recDomains[iDomain][iTestDomain], "i") != null) {
				iEndPos = sRequestReferrer.indexOf(recDomains[iDomain][iTestDomain]) + recDomains[iDomain][iTestDomain].length;
				/*
				sLinkDomain = sRequestReferrer.substring(0, iEndPos);
				sLiveDomain = recDomains[iDomain][iLiveDomain] + "/";
				alert("sLinkDomain = " + sLinkDomain + "\r\nsLiveDomain = " + sLiveDomain);
				*/
				break;
			} // if
		}
	} // for

	if (iDomain < recDomains.length) {
		sDomainColor = recDomains[iDomain][iColor];
		sDomainTitle = recDomains[iDomain][iTitle];
		sSiteID = recDomains[iDomain][iSiteID];
	}
	
} // if
document.write('<link rel="stylesheet" type="text/css" href="' + sLiveDomain + 'standard.css">');
document.write('<style type="text/css">');
document.write('	.subCatHeader {background-color:white; color:black; font-weight=bold; text-decoration: none; }');
document.write('	a:hover.subCatHeader {color: #FF0000}');
document.write('	.subCatHeaderText {font-weight: normal; font-size: small; text-decoration: none; }');
document.write('	.footerCellStyle {border-collapse: collapse; border: none 0 ' + sDomainColor + '; border-top-width:1px; border-right-width:5px; border-left-width:2px; border-bottom-width:2px;}');
document.write('	.SpecialfooterCellStyle {border-collapse: collapse; border: none 0 #FF0000; border-top-width:1px; border-right-width:5px; border-left-width:2px; border-bottom-width:2px;}');
document.write('	.footerNoMoreMatchesCellStyle {border-collapse: collapse; border: solid 0 ' + sDomainColor + '; border-top-width:1px; border-right-width:2px; border-left-width:2px; border-bottom-width:2px;}');
document.write('	.rightCellStyle {border-collapse: collapse; border: solid 0 ' + sDomainColor + '; border-right-width:2px; }');
document.write('	.leftCellStyle {border-collapse: collapse; border: solid 0 ' + sDomainColor + '; border-left-width:1px; }');
document.write('	.oneCellStyle {border-collapse: collapse; border: solid 0 ' + sDomainColor + '; border-left-width:1px; border-right-width:5px; }');
document.write('	.noGroupingRightCellStyle {border-collapse: collapse; border: hidden 0 ' + sDomainColor + '; border-right-width:5px; border-bottom-width:1px;}');
document.write('	.noGroupingMiddleCellStyle {border-collapse: collapse; border: hidden 0 ' + sDomainColor + '; border-bottom-width:1px;}');
document.write('	.noGroupingLeftCellStyle {border-collapse: collapse; border: hidden 0 ' + sDomainColor + '; border-left-width:1px; border-bottom-width:1px;}');
document.write('	.noGroupingOneCellStyle {border-collapse: collapse; border: hidden 0 ' + sDomainColor + '; border-left-width:1px; border-right-width:2px; border-bottom-width:1px;}');
document.write('	.noGroupingLastRowRightCellStyle {border-collapse: collapse; hidden: solid 0 ' + sDomainColor + '; border-right-width:5px; border-bottom-width:2px;}');
document.write('	.noGroupingLastRowMiddleCellStyle {border-collapse: collapse; hidden: solid 0 ' + sDomainColor + '; border-bottom-width:2px;}');
document.write('	.noGroupingLastRowLeftCellStyle {border-collapse: collapse; hidden: solid 0 ' + sDomainColor + '; border-left-width:1px; border-bottom-width:2px;}');
document.write('	.noGroupingLastRowOneCellStyle {border-collapse: collapse; hidden: solid 0 ' + sDomainColor + '; border-left-width:1px; border-right-width:2px; border-bottom-width:2px;}');
document.write('	.footerText {color:' + sDomainColor + '; font-family:Arial, Helvetica; }');
document.write('	.advancedSearch {font-size:12px; height:18px; }');
document.write('	.advancedSearchSelect {font-size:12px; height:18px; width: 175;}');
document.write('	.nameLink {color:' + sDomainColor + ';font-weight:bold;}');
document.write('	.itemBorder {border-collapse: collapse; border: solid 0 ' + sDomainColor + '; border-left-width:1px;}');
document.write('	hr.refine {color:' + sDomainColor + '; }');
document.write('	.refine {color:' + sDomainColor + '; }');
document.write('	.refineHeader {background-color:' + sDomainColor + '; color:white; font-weight=bold; text-decoration: none; }');
document.write('	.refineHeaderText {font-weight: bold; }');
document.write('	.sortTable {border-collapse: collapse; border: solid 2 ' + sDomainColor + '; }');
document.write('	ul.refineBullets {list-style: none; margin-left:0; padding-left:0; }');
document.write('</style>');
