var preError = "The following errors have been found:\n------------------------------------\n";
var errorString = "";
var postError = "------------------------------------\nPlease correct these errors and re-submit.";
var errorNumber = 0;
var errorNumDot = ". ";

var styleID, itemContent, monogramStyle, colorID, foilColorID, itemLayout, dblsided;
var fontFaceOne, fontSizeOne, fontFaceTwo, fontSizeTwo, fontFaceThree, fontSizeThree, initialOneFont, initialOneSize, initialTwoFont, initialTwoSize, initialThreeFont, initialThreeSize, designID;
var lineOneCopy, lineTwoCopy, lineThreeCopy, initialOneCopy, initialTwoCopy, initialThreeCopy, lineOneEnvCopy, lineTwoEnvCopy;
var numLines, includeDesign;
var currentStepDiv = "styleStep";
var currentStepNum = "1";
var pictureUrl, layoutChosen;
var fontID1, fontID2, fontID3, size1, size2, size3;
var productName = "";
var colorName = "";
var doLayout = true;
var designWithCopy = true;
var dodblside = false;
//var previewButton = false;

function getAllValues() {
	styleID = document.productForm.styleID.value;
	colorID = document.productForm.colorID.value;
	foilColorID = document.productForm.foilColorID.value;
	itemLayout = document.productForm.itemLayout.value;
	itemContent = getRadioValue(document.productForm.itemContent);
	dblsided = (document.productForm.dblsided.checked);
	fontFaceOne = getSelectValue(document.productForm.fontFaceOne);
	fontSizeOne = getSelectValue(document.productForm.fontSizeOne);
	fontFaceTwo = getSelectValue(document.productForm.fontFaceTwo);
	fontSizeTwo = getSelectValue(document.productForm.fontSizeTwo);
	fontFaceThree = getSelectValue(document.productForm.fontFaceThree);
	fontSizeThree = getSelectValue(document.productForm.fontSizeThree);
	fontFaceFour = getSelectValue(document.productForm.fontFaceFour);
	fontSizeFour = getSelectValue(document.productForm.fontSizeFour);
	designID = document.productForm.designID.value;
	lineOneCopy = document.productForm.lineOneCopy.value;
	lineTwoCopy = document.productForm.lineTwoCopy.value;
	lineThreeCopy = document.productForm.lineThreeCopy.value;
	lineFourCopy = document.productForm.lineFourCopy.value;
}
//function hideAndSeek(hideDivsArray,showDiv,showDivTwo,showDivThree,showDivFour) {
//	var index;
//	var arrayLength = hideDivsArray.length;
//	for (index = 0; index < arrayLength; index++) {
//		eval(navRefOne + hideDivsArray[index] + navRefTwo + ".display = 'none'");
//	}
//	eval(navRefOne + showDiv + navRefTwo + ".display = 'block'");
//	if (showDivTwo != null) {
//		eval(navRefOne + showDivTwo + navRefTwo + ".display = 'block'");
//	}
//	if (showDivThree != null) {
//		eval(navRefOne + showDivThree + navRefTwo + ".display = 'block'");
//	}
//	if (showDivFour != null) {
//		eval(navRefOne + showDivFour + navRefTwo + ".display = 'block'");
//	}
//}
function seek(showDiv) {
	eval(navRefOne + showDiv + navRefTwo + ".display = 'block'");
}
function hide(hideDiv) {
	eval(navRefOne + hideDiv + navRefTwo + ".display = 'none'");
}
//function resetLists(resetListsArray) {
//	var index;
//	var arrayLength = resetListsArray.length;
//	for (index = 0; index < arrayLength; index++) {
//		eval('document.productForm.' + resetListsArray[index] + '.selectedIndex = 0');
//	}
//}
var stepArray = new Array();
stepArray["styleStep"] = 1;
stepArray["colorStep"] = 2;
stepArray["foilStep"] = 3;
stepArray["copyStep"] = 4;
stepArray["copyArtStep"] = 5;
stepArray["layoutStep"] = 6;
stepArray["previewStep"] = 7;

function backStep() {
	var newStepNum = currentStepNum;
	if (currentStepNum > 1) {
		newStepNum = currentStepNum - 1;
	}
	for (newStep in stepArray) {
		if (stepArray[newStep] == newStepNum) {
			changeStep(newStep);
		}
	}
}
function changeStep(stepDiv) {
	stepnum = stepArray[stepDiv];

	var cat = "";
	getAllValues();
	if (colorID == "133" && stepnum != "1" && stepnum != "2" && stepnum != "7") {
		if (currentStepDiv != "previewStep") {
			stepDiv = "previewStep";
			stepnum = "7";
		} else {
			stepDiv = "colorStep";
			stepnum = "2";
		}
	}
	if (designID > 4000 && designID < 100100) {
		if (stepDiv == "styleStep") {
			stepDiv = "colorStep";
			stepnum = "2";
		}
		if (stepDiv == "copyArtStep" || stepDiv == "layoutStep") {
			if (currentStepDiv != "previewStep") {
				stepDiv = "previewStep";
				stepnum = "7";
			} else {
				stepDiv = "copyStep";
				stepnum = "4";
			}
		}
	}
	if (styleID == 254) {
		if (stepDiv == "copyArtStep" || stepDiv == "layoutStep") {
			if (currentStepDiv != "previewStep") {
				stepDiv = "previewStep";
				stepnum = "7";
			} else {
				stepDiv = "copyStep";
				stepnum = "4";
			}
		}
	}

//	if (stepDiv == "copyArtStep" && (itemContent.substr(0,8) == "monogram" || lineFourCopy != "" || lineThreeCopy != "" || (styleID != "8" && styleID != "26" && styleID != "27" && styleID != "67" && styleID != "68" && (lineOneCopy != "" || lineTwoCopy != "")))) { //no art on monograms, 3+ lines of some and any text on others
//		if (doLayout && currentStepDiv != "layoutStep") {
//			stepDiv = "layoutStep";
//			stepnum = "6";
//		} else if (!doLayout && currentStepDiv != "previewStep") {
//			stepDiv = "previewStep";
//			stepnum = "7";
//		} else {
//			stepDiv = "copyStep";
//			stepnum = "4";
//		}
//	}
	if (stepDiv == "layoutStep" && !doLayout){
		if (currentStepDiv != "previewStep") {
			stepDiv = "previewStep";
			stepnum = "7";
		} else {
			stepDiv = "copyArtStep";
			stepnum = "5";
		}
	}

	eval(navRefOne + "stepno" + currentStepNum + navRefTwo.replace(/.style/,".className") + " = 'inactive-step'");
	eval(navRefOne + "stepno" + stepnum + navRefTwo.replace(/.style/,".className") + " = 'active-step'");
	eval(navRefOne + "stepdesc" + currentStepNum + navRefTwo + ".display = 'none'");
	eval(navRefOne + "stepdesc" + stepnum + navRefTwo + ".display = 'block'");
	eval(navRefOne + currentStepDiv + navRefTwo + ".display = 'none'");
	eval(navRefOne + stepDiv + navRefTwo + ".display = 'block'");
	if (currentStepDiv != stepDiv || stepDiv == "colorStep" || stepDiv == "foilStep" || stepDiv == "itemContentStep") {
		if (stepDiv == "colorStep") {
			var cat="";
			if (styleID == "26") {
				cat="30";
			} else if (styleID == "27") {
				cat="40";
			} else if (styleID == "229") {
				cat="ST";
			} else if (styleID != "") {
				cat="all";
			}
			setTimeout('loadIframe("colorSamples", "samplePages/showPaperColors.php?cat=' + cat + '")',300);
		} else if (stepDiv == "foilStep") {
			setTimeout('loadIframe("foilSamples", "/samplePages/showFoils.php")',300);
//		} else if (stepDiv == "monogramStep") {
//			setTimeout('loadIframe("monogramSamples", "/samplePages/showMonograms.php")',300);
//		} else if (stepDiv == "copyStep") {
//			setTimeout('loadIframe("copySamples", "/samplePages/showFonts.php")',300);
//		} else if (stepDiv == "itemContentStep") {
//			if (styleID == "23") {
//				setTimeout('loadIframe("contentSamples", "/samplePages/showStemwrapContent.php")',300);
//			} else {
//				setTimeout('loadIframe("contentSamples", "/samplePages/showContent.php")',300);
//			}
		} else if (stepDiv == "layoutStep") {
			setTimeout('loadIframe("layoutSamples", "/samplePages/showMatchLayouts.php")',300);
		} else if (stepDiv == "copyArtStep") {
			setTimeout('loadIframe("copyArtSamples", "/samplePages/showDesigns.php")',300);
		}
	}
	if (stepDiv == "copyStep" && (styleID == "80" || dblsided || itemContent.substr(0,8) == "monogram")) {
		seek("lines34");
	} else {
		hide("lines34");
	}
	currentStepDiv = stepDiv;
	currentStepNum = stepnum;
	updatePreview();
	nextTip();
}

//function changeColorList(coasterColorValue, coasterColorList) {
//	var selbox = document.productForm.coasterColorList;
//	var selbox2 = document.tweakDivForm.tweakColorList;
//	selbox.options.length = 0;
//	selbox2.options.length = 0;
//	if (styleID == "noneChosen") {
//	  selbox.options[selbox.options.length] = new Option('Please select coaster style first','noneChosen');
//	} else {
//		var index;
//		var arrayLength = coasterColorList.length;
//		for (index = 0; index < arrayLength; index++) {
//		  selbox.options[selbox.options.length] = new Option(coasterColorList[index],coasterColorValue[index]);
//		  selbox2.options[selbox2.options.length] = new Option(coasterColorList[index],coasterColorValue[index]);
//		}
//	}
//}

function selectStyle(selectItem,selectName) {
	document.productForm.styleID.value=selectItem;
	var d=document.getElementById('product_type');
	d.innerHTML=selectName + " " + colorName;
	productName=selectName;
	document.productForm.itemLayout.value="";				// clear the layout
	getAllValues();
	styleSelect();
}
function selectColor(selectItem,selectName) {
	document.productForm.colorID.value=selectItem;
	var d=document.getElementById('product_type');
	d.innerHTML=productName + " " + selectName;
	colorName=selectName;
	getAllValues();
	if (selectItem == "133") {
		selectBlank();
	} else {
		colorSelect();
	}
}
//function selectContent(selectItem) {
//	document.productForm.itemContent.value=selectItem;
//	getAllValues();
//	contentSelect();
//}
function selectLayout(selectItem) {
	document.productForm.itemLayout.value=selectItem;
	getAllValues();
	layoutSelect();
}
//function selectMonogram(selectItem) {
//	document.productForm.monogramStyleList.value=selectItem;
//	getAllValues();
//	monogramSelect();
//}
function selectFoil(selectItem,foilName) {
	document.productForm.foilColorID.value=selectItem;
	var d=document.getElementById('foil_type');
	d.innerHTML=foilName;
	getAllValues();
	foilColorSelect();
}
function selectBlank() {
	document.productForm.foilColorID.value="";
	var d=document.getElementById('foil_type');
	d.innerHTML="";
	getAllValues();
	changeStep("previewStep");
}
function selectDesign(selectItem) {
	document.productForm.designID.value=selectItem;
	getAllValues();
	designSelect();
}
function selectFont(selectItem) {
	ffield.selectedIndex=selectItem;
	hidebox('fontBox');
	hidebox('allFontBox');
	getAllValues();
	fontSelect();
}
function selectGiftset(selectItem, selectName) {
	document.productForm.giftsetID.value=selectItem;
	document.productForm.action = "/giftsets.php";
	if (BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7){
		setTimeout('document.productForm.submit()',300);
	} else {
		document.productForm.submit();
	}
}
function updateCopy(EW_this) {
	getAllValues();
	var nxtFldName = EW_this.name.replace(/line/,"fontFace");
	nxtFldName = nxtFldName.replace(/Copy/,"");
	var lineNo = nxtFldName.slice(8);
	var lstFld;
	var lstFldName;
	var lstFldNo = "";
	switch (lineNo) {
		case "Two":
			lstFldNo = "One";
			break;
		case "Three":
			lstFldNo = "Two";
			if (designID != "") {
				designID = "";
				document.productForm.designID.value="";
				alert("Designs cannot be added with 3 lines of text. Your design selection has been cleared.");
			}
			break;
		case "Four":
			lstFldNo = "Three";
			if (designID != "") {
				designID = "";
				document.productForm.designID.value="";
				alert("Designs cannot be added with 4 lines of text. Your design selection has been cleared.");
			}
			break;
	}
	if (designID != "" && (lineOneCopy != "" || lineTwoCopy != "") && !designWithCopy) {
		designID = "";
		document.productForm.designID.value="";
		alert("Designs cannot be added with text on this match style. Your design selection has been cleared.");
	}
	var nxtFld = eval(navRefOne + nxtFldName + navRefTwo.replace(/.style/,""));
	if (EW_this.value != "") {
		if (nxtFld.selectedIndex == 0) {
			if (lstFldNo != "") {
				lstFldName = nxtFldName.replace(lineNo,lstFldNo);
				lstFld = eval(navRefOne + lstFldName + navRefTwo.replace(/.style/,""));
				nxtFld.selectedIndex = lstFld.selectedIndex;
	    } else {
				nxtFld.selectedIndex = findItem("2", nxtFld);
			}
		}
	} else {
		nxtFld.selectedIndex = 0;
	}
	nxtFldName = nxtFldName.replace(/Face/,"Size");
	nxtFld = eval(navRefOne + nxtFldName + navRefTwo.replace(/.style/,""));
	if (EW_this.value != "") {
		if (nxtFld.selectedIndex == 0) {
			if (lstFldNo != "") {
				lstFldName = nxtFldName.replace(lineNo,lstFldNo);
				lstFld = eval(navRefOne + lstFldName + navRefTwo.replace(/.style/,""));
				nxtFld.selectedIndex = lstFld.selectedIndex;
	    } else {
				nxtFld.selectedIndex = findItem("21", nxtFld);
			}
		}
	} else {
		nxtFld.selectedIndex = 0;
	}
	updatePreview();
}
function findItem(seekValue, seekList) {
	var index;
	var arrayLength = seekList.length;
	for (index = 0; index < arrayLength; index++) {
	  if (seekList.options[index].value == seekValue) {
	  	return index;
	  }
	}
}
/* ================================= Begin onChange functions ================================= */
function styleSelect() {
	getAllValues();
	if (colorID != "") {
		if (styleID == "26" || styleID == "27" || styleID == "229") {    // Strike matches
			var arrayName = "c" + styleID;
		} else {
			var arrayName = "c6";
		}
		var arrayLength = colorValue[arrayName].length;
		var validColor = false;
		for (var i=1; i<arrayLength; i++) {
			if (colorValue[arrayName][i] == colorID) {
				validColor = true;
				break;
			}
		}
		if (!validColor) {
			colorID = "";
			document.productForm.colorID.value = "";
			colorName="";
			var d=document.getElementById('product_type');
			d.innerHTML=productName + " " + colorName;
		}
	}
	if (styleID != "8" && styleID != "54" && styleID != "62" && styleID != "67" && styleID != "68" && styleID != "81") {
		document.productForm.dblsided.checked = false;
		if (dodblside) {
			var d=document.getElementById('line1');
			d.innerHTML="Line 1 (if any)";
			var d=document.getElementById('line2');
			d.innerHTML="Line 2 (if any)";
			var d=document.getElementById('line3');
			d.innerHTML="Line 3 (if any)";
			var d=document.getElementById('line4');
			d.innerHTML="Line 2 Back (if any)";
		}
		dodblside = false;
		hide("dsDiv");
	} else {
		seek("dsDiv");
	}
	if (styleID == "80") {
		var d=document.getElementById('line1');
		d.innerHTML="Line 1 Front (if any)";
		var d=document.getElementById('line2');
		d.innerHTML="Line 2 Front (if any)";
		var d=document.getElementById('line3');
		d.innerHTML="Line 1 Back (if any)";
		dodblside = true;
		document.productForm.dblsided.checked = true;
		dblsided = true;
	}
	if (styleID == "6" || styleID == "26" || styleID == "27" || styleID == "62" || styleID == "80" || styleID == "229" || styleID == "254") {
		doLayout = false;
		document.productForm.itemLayout.value = ""
	} else {
		doLayout = true;
	}
	if (dblsided) {
		doLayout = false;
	}
	designWithCopy = true;
	if (styleID != "6" && styleID != "8" && styleID != "26" && styleID != "27" && styleID != "67" && styleID != "68" && styleID != "77" && styleID != "78" && styleID != "80" && styleID != "229") {
		designWithCopy = false;
	}
	if (designID > 4000 && designID < 100100) {
		doLayout = false;
		designWithCopy = true;
	}
	if (designID != "" && (lineOneCopy != "" || lineTwoCopy != "") && !designWithCopy) {
		designID = "";
		document.productForm.designID.value="";
		alert("Designs cannot be added with text on this match style. Your design selection has been cleared.");
	}
	changeStep("colorStep");
//	if ((styleID >= 1 && styleID <= 3) || (styleID >= 41 && styleID <= 43) || styleID == 5 || styleID == 45) { /* bev or gt napkin */
//		eval(navRefOne + "giftboxDiv" + navRefTwo + ".display = 'block'");
//	} else {
//		document.productForm.giftbox.checked = false;
//		eval(navRefOne + "giftboxDiv" + navRefTwo + ".display = 'none'");
//	}
}
function colorSelect() {
	getAllValues();
	changeStep("foilStep");
}
function foilColorSelect() {
	getAllValues();
	changeStep("copyStep");
}
function contentSelect() {
	getAllValues();
	if (itemContent.substr(0,8) == "monogram") {
		if (designID != "") {
			designID = "";
			document.productForm.designID.value="";
			alert("Designs cannot be added with Monograms. Your design selection has been cleared.");
		}
		seek("lines34");
		var d=document.getElementById('line1');
		d.innerHTML="first initial";
		var d=document.getElementById('line2');
		d.innerHTML="second initial (if any)";
		var d=document.getElementById('line3');
		d.innerHTML="third initial (if any)";
		var d=document.getElementById('line4');
		d.innerHTML="date (if any)";
	} else {
		var d=document.getElementById('line1');
		d.innerHTML="Line 1 (if any)";
		var d=document.getElementById('line2');
		d.innerHTML="Line 2 (if any)";
		var d=document.getElementById('line3');
		d.innerHTML="Line 3 or Line 1 Back (if any)";
		var d=document.getElementById('line4');
		d.innerHTML="Line 2 Back (if any)";
		if (dblsided) {
			dodblside = true;
		} else {
			dodblside = false;
		}
		if (!dodblside) {
			lineFourCopy = "";
			document.productForm.lineFourCopy.value="";
			hide("lines34");
		} else {
			seek("lines34");
			doLayout = false;
			var d=document.getElementById('line1');
			d.innerHTML="Line 1 Front (if any)";
			var d=document.getElementById('line2');
			d.innerHTML="Line 2 Front (if any)";
			var d=document.getElementById('line3');
			d.innerHTML="Line 1 Back (if any)";
		}
	}
	updatePreview();
}
function designSelect() {
	getAllValues();
	if (designID != "" && (itemContent.substr(0,8) == "monogram" || (designID < 4000 && (lineFourCopy != "" || lineThreeCopy != "")) || (!dblsided && !designWithCopy && (lineOneCopy != "" || lineTwoCopy != "")))) { //no art on monograms, 3+ lines of some and any text on others {
		designID = "";
		document.productForm.designID.value="";
		if (itemContent.substr(0,8) == "monogram") {
			alert("Designs cannot be added with Monograms. Your design selection has been cleared.");
		} else if (lineFourCopy != "" || lineThreeCopy != "") {
			alert("Designs cannot be added with more than 2 lines of text on this style of match. Please go back to Content Step and clear out lines 3 and 4 if you would like to add a design.");
		} else {
			alert("Designs cannot be added with text on this style of match. Please go back to Content Step and clear out your text or select \"Imprint on Front and Back\", (if available), if you would like to select a design.");
		}
		return;
	}
	changeStep("layoutStep");
}
function layoutSelect() {
	getAllValues();
	changeStep("previewStep");
}
function fontSelect() {
	getAllValues();
	updatePreview();
}

var previewDelay;
var previewUrl;

function getPictUrl() {
	pictureUrl =
	"matchPicture.php?" +
	"style=" + document.urlPlaceholderForm.elements[0].value + "&" +
	"colorID=" + document.urlPlaceholderForm.elements[1].value + "&" +
	"foilID=" + document.urlPlaceholderForm.elements[2].value + "&" +
	"layout=" + document.urlPlaceholderForm.elements[3].value + "&" +
	"ds=" + document.urlPlaceholderForm.dblsided.value + "&" +
	"designID=" + document.urlPlaceholderForm.elements[5].value + "&" +
	"design=" + document.urlPlaceholderForm.elements[6].value + "&" +
	"lines=" + document.urlPlaceholderForm.elements[7].value + "&" +
	"fontID1=" + document.urlPlaceholderForm.elements[8].value + "&" +
	"fontID2=" + document.urlPlaceholderForm.elements[9].value + "&" +
	"fontID3=" + document.urlPlaceholderForm.elements[10].value + "&" +
	"fontID4=" + document.urlPlaceholderForm.elements[11].value + "&" +
	"size1=" + document.urlPlaceholderForm.elements[12].value + "&" +
	"size2=" + document.urlPlaceholderForm.elements[13].value + "&" +
	"size3=" + document.urlPlaceholderForm.elements[14].value + "&" +
	"size4=" + document.urlPlaceholderForm.elements[15].value + "&" +
	"line1=" + escape(document.urlPlaceholderForm.elements[16].value).replace(/\+/g,"%2B") + "&" +
	"line2=" + escape(document.urlPlaceholderForm.elements[17].value).replace(/\+/g,"%2B") + "&" +
	"line3=" + escape(document.urlPlaceholderForm.elements[18].value).replace(/\+/g,"%2B") + "&" +
	"line4=" + escape(document.urlPlaceholderForm.elements[19].value).replace(/\+/g,"%2B") + "&" +
	"monoStyle=" + document.urlPlaceholderForm.elements[20].value;
//document.productForm.comments.value=pictureUrl;	
	return(pictureUrl);
}
function updatePreview() {
	getAllValues();
		document.urlPlaceholderForm.styleID.value = styleID;
		document.urlPlaceholderForm.colorID.value = colorID;
		document.urlPlaceholderForm.foilColorID.value = foilColorID;
		document.urlPlaceholderForm.designID.value = designID;
		document.urlPlaceholderForm.line1.value = lineOneCopy;
		document.urlPlaceholderForm.fontID1.value = fontFaceOne;
		document.urlPlaceholderForm.size1.value = fontSizeOne;
		document.urlPlaceholderForm.line2.value = lineTwoCopy;
		document.urlPlaceholderForm.fontID2.value = fontFaceTwo;
		document.urlPlaceholderForm.size2.value = fontSizeTwo;
		document.urlPlaceholderForm.line3.value = lineThreeCopy;
		document.urlPlaceholderForm.fontID3.value = fontFaceThree;
		document.urlPlaceholderForm.size3.value = fontSizeThree;
		document.urlPlaceholderForm.line4.value = lineFourCopy;
		document.urlPlaceholderForm.fontID4.value = fontFaceFour;
		document.urlPlaceholderForm.size4.value = fontSizeFour;
		document.urlPlaceholderForm.layoutChosen.value = itemLayout;
		document.urlPlaceholderForm.dblsided.value = (dblsided)?"1":"0";
		contentDisplayed = itemContent;
		ms = "noneChosen";
		if (contentDisplayed.substr(0,8) == "monogram") {
			if (document.urlPlaceholderForm.line3.value != "") {
				ms = "threeLetters" + contentDisplayed.substr(8);
			} else if (document.urlPlaceholderForm.line2.value != "") {
				ms = "twoLetters" + contentDisplayed.substr(8);
			} else if (document.urlPlaceholderForm.line1.value != "") {
				ms = "oneLetter";
			}
		}
		document.urlPlaceholderForm.ms.value = ms;
		if ((currentStepDiv == "foilStep" || currentStepDiv == "copyStep") && lineOneCopy == "" && lineTwoCopy == "" && lineThreeCopy == "" && designID == "") {
			document.urlPlaceholderForm.line1.value = "Font/";
			document.urlPlaceholderForm.line2.value = "Design";
			document.urlPlaceholderForm.line3.value = "Color";
		}
		if (document.urlPlaceholderForm.line4.value != "") {
			numberOfLines = 4;
		} else if (document.urlPlaceholderForm.line3.value != "") {
			numberOfLines = 3;
		} else if (document.urlPlaceholderForm.line2.value != "") {
			numberOfLines = 2;
		} else if (document.urlPlaceholderForm.line1.value != "") {
			numberOfLines = 1;
		} else {
			numberOfLines = 0;
		}
		document.urlPlaceholderForm.numberOfLines.value = numberOfLines;
		includeDesign = "no";
		if (document.urlPlaceholderForm.designID.value != "" && document.urlPlaceholderForm.designID.value != 0) {
			includeDesign = "yes";
		}
		document.urlPlaceholderForm.includeDesign.value = includeDesign;

//alert(itemContent + "\n" + getPictUrl());
	previewUrl = getPictUrl();

	previewDelay = setTimeout("displayPreview()",500);
}

function displayPreview() {
	eval(navRefOne + "previewboxcontainer" + navRefTwo + ".background = \"url('" + previewUrl + "') no-repeat center center\"");
}
//	eval(navRefOne + "" + navRefTwo + ".background = \"url('/" + getPictUrl() + "') no-repeat center center\"");
//}

function largePreview(e) {
	getAllValues();
//alert(itemContent + "\n" + getPictUrl());
	if (!e) var e = window.event;

	enlarge("/" + getPictUrl() + "&large=y",e,'center',300,300);
//	var newWin = window.open("/" + getPictUrl() + "&large=y", 'samples', 'width=700,height=750,top=0,left=0,resizable,scrollbars=yes,statusbar');
//	newWin.focus();
}

function checkErrors() {
	getAllValues();
	contentDisplayed = itemContent;
	if (lineOneCopy == "" && lineTwoCopy == "" && lineThreeCopy == "" && lineFourCopy == "" && designID == "" && foilColorID == "") {
		contentDisplayed = "blank"
	}
	/* reset errors */
	errorString = "";
	errorNumber = 0;
	/* -------------- check style -------------- */
	if (styleID == "") {;
		errorNumber++;
		errorString += errorNumber + errorNumDot + "A match style has not been chosen!\n";
	}
	/* -------------- check color -------------- */
	if (colorID == "") {
		errorNumber++;
		errorString += errorNumber + errorNumDot + "A match color has not been chosen!\n";
	}
	/* -------------- check foil -------------- */
	if (contentDisplayed != "blank") {
		if (foilColorID == "") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A foil color has not been chosen!\n";
		}
	}
	/* -------------- check line or initial one (if neccessary) -------------- */
	if (lineOneCopy == "" && contentDisplayed.substr(0,8) == "monogram") {
		errorNumber++;
		errorString += errorNumber + errorNumDot + "Initial one is empty!\n";
	} else if (lineOneCopy == "" && designID == "" && contentDisplayed == "textDesign") {
		errorNumber++;
		errorString += errorNumber + errorNumDot + "Line one and design are empty!\nIf you wanted NO PRINTING please return to Imprint Color Step and select BLANK/NO PRINTING.\nIf you wanted CUSTOM ART please return to Design Step and select CUSTOM ART.\n";
	}
	/* -------------- check line one (if neccessary) -------------- */
	if (lineOneCopy != "") {
		if (fontFaceOne == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font for line or initial one has not been chosen!\n";
		}
		if (fontSizeOne == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font size for line or initial one has not been chosen!\n";
		}
	}
	/* -------------- check line two (if neccessary) -------------- */
	if (lineTwoCopy != "") {
		if (fontFaceTwo == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font for line or initial two has not been chosen!\n";
		}
		if (fontSizeTwo == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font size for line or initial two has not been chosen!\n";
		}
	}
	/* -------------- check line three (if neccessary) -------------- */
	if (lineThreeCopy != "") {
		if (fontFaceThree == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font for line or initial three has not been chosen!\n";
		}
		if (fontSizeThree == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font size for line or initial three has not been chosen!\n";
		}
	}
	/* -------------- check line four (if neccessary) -------------- */
	if (lineFourCopy != "") {
		if (fontFaceFour == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font for line four has not been chosen!\n";
		}
		if (fontSizeFour == "noneChosen") {
			errorNumber++;
			errorString += errorNumber + errorNumDot + "A font size for line four has not been chosen!\n";
		}
	}
	/* -------------- check layout (if neccessary)-------------- */
	if (doLayout && itemLayout == "" && contentDisplayed != "blank") {
		errorNumber++;
		errorString += errorNumber + errorNumDot + "A layout has not been chosen!\n";
	}
	/* -------------- check design (if neccessary)-------------- */
//	if (lineOneCopy == "" && contentDisplayed == "textDesign" && designID == "") {
//		errorNumber++;
//		errorString += errorNumber + errorNumDot + "A design has not been chosen!\n";
//	}
	if (errorNumber != 0) {
		return true;
	} else {
		return false;
	}
}

function addToCart() {
	if (checkErrors()) {
		alert(preError + errorString + postError);
	} else {

		var monogramStyleName;
		var contentType;
		document.addCartForm.cart_url.value = getPictUrl();
		document.addCartForm.cart_productID.value = document.urlPlaceholderForm.styleID.value;

		var layArray = new Array();
		layArray.vertical = "Traditional Vertical";
		layArray.vert = "Vertical";
		layArray.horizontal = "Horizontal";
		var layChosen = document.urlPlaceholderForm.layoutChosen.value;
		var layoutType = "Middle Center";
		if (doLayout) {
			layoutType += " (" + layArray[layChosen] + ")";
		} else {
			layoutType += " (Horizontal)";
		}
		document.addCartForm.cart_layout.value = layoutType;

		var monoArray = new Array();
		monoArray.oneLetter = "One Letter";
		monoArray.twoLettersHoriz = "Two Letters Horizontal";
		monoArray.twoLettersVert = "Two Letters Vertical";
		monoArray.twoLettersOffset = "Two Letters Offset";
		monoArray.threeLettersHoriz = "Three Letters Horizontal";
		monoArray.threeLettersVert = "Three Letters Vertical";
		monoArray.threeLettersOffset = "Three Letters Offset";
		if (document.urlPlaceholderForm.ms.value != "noneChosen") {
			var monoChoice = document.urlPlaceholderForm.ms.value;
			monogramStyleName = monoArray[monoChoice];
			contentType = "Monogram " + "(" + monogramStyleName + ")";
		} else {
		 	contentType = document.urlPlaceholderForm.numberOfLines.value + " line(s)";
		}
		if (document.urlPlaceholderForm.includeDesign.value == "yes") {
			contentType += " plus a design";
			document.addCartForm.cart_designID.value = document.urlPlaceholderForm.designID.value;
		}
		document.addCartForm.cart_contentType.value = contentType;
		document.addCartForm.cart_fontFiveSize.value = document.urlPlaceholderForm.dblsided.value;

		document.addCartForm.cart_colorID.value = document.urlPlaceholderForm.colorID.value;
		document.addCartForm.cart_foilID.value = document.urlPlaceholderForm.foilColorID.value;

		document.addCartForm.cart_lineOneCopy.value = document.urlPlaceholderForm.line1.value;
		document.addCartForm.cart_fontOneID.value = document.urlPlaceholderForm.fontID1.value;
		document.addCartForm.cart_fontOneSize.value = document.urlPlaceholderForm.size1.value;

		document.addCartForm.cart_lineTwoCopy.value = document.urlPlaceholderForm.line2.value;
		document.addCartForm.cart_fontTwoID.value = document.urlPlaceholderForm.fontID2.value;
		document.addCartForm.cart_fontTwoSize.value = document.urlPlaceholderForm.size2.value;

		document.addCartForm.cart_lineThreeCopy.value = document.urlPlaceholderForm.line3.value;
		document.addCartForm.cart_fontThreeID.value = document.urlPlaceholderForm.fontID3.value;
		document.addCartForm.cart_fontThreeSize.value = document.urlPlaceholderForm.size3.value;

		document.addCartForm.cart_lineFourCopy.value = document.urlPlaceholderForm.line4.value;
		document.addCartForm.cart_fontFourID.value = document.urlPlaceholderForm.fontID4.value;
		document.addCartForm.cart_fontFourSize.value = document.urlPlaceholderForm.size4.value;

		document.addCartForm.cart_comments.value = document.productForm.comments.value;

		if (document.productForm.giftbox.checked) {
			document.addCartForm.cart_giftbox.value = "yes";
		} else {
			document.addCartForm.cart_giftbox.value = "no";
		}
		document.addCartForm.cart_insert.value = "yes";

		document.addCartForm.submit();
	}

/* var test; */
/* test = "url = " + document.addCartForm.cart_url.value + "\n"; */
/* test += "product ID = " + document.addCartForm.cart_productID.value + "\n"; */
/* test += "layout = " + document.addCartForm.cart_layout.value + "\n"; */
/* test += "content = " + document.addCartForm.cart_contentType.value + "\n"; */
/* test += "color ID = " + document.addCartForm.cart_colorID.value + "\n"; */
/* test += "foil ID = " + document.addCartForm.cart_foilID.value + "\n"; */
/* test += "design ID = " + document.addCartForm.cart_designID.value + "\n"; */
/* test += "line one = " + document.addCartForm.cart_lineOneCopy.value + "\n"; */
/* test += "font one ID = " + document.addCartForm.cart_fontOneID.value + "\n"; */
/* test += "font one size = " + document.addCartForm.cart_fontOneSize.value + "\n"; */
/* test += "line two = " + document.addCartForm.cart_lineTwoCopy.value + "\n"; */
/* test += "font two ID = " + document.addCartForm.cart_fontTwoID.value + "\n"; */
/* test += "font two size = " + document.addCartForm.cart_fontTwoSize.value + "\n"; */
/* test += "line three = " + document.addCartForm.cart_lineThreeCopy.value + "\n"; */
/* test += "font three ID = " + document.addCartForm.cart_fontThreeID.value + "\n"; */
/* test += "font three size = " + document.addCartForm.cart_fontThreeSize.value + "\n"; */
/* test += "line four = " + document.addCartForm.cart_lineFourCopy.value + "\n"; */
/* test += "font four ID = " + document.addCartForm.cart_fontFourID.value + "\n"; */
/* test += "font four size = " + document.addCartForm.cart_fontFourSize.value + "\n"; */
/* test += "line five = " + document.addCartForm.cart_lineFiveCopy.value + "\n"; */
/* test += "font five ID = " + document.addCartForm.cart_fontFiveID.value + "\n"; */
/* test += "font five size = " + document.addCartForm.cart_fontFiveSize.value + "\n"; */
/* alert(test); */
}



