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, designerPrintID, fauxPrintID, colorID, foilColorID, itemLayout, itemContent, fontFaceOne, fontSizeOne, fontFaceTwo, fontSizeTwo, fontFaceThree, fontSizeThree, fontFaceFour, fontSizeFour, initialFontOne, initialSizeOne, initialFontTwo, initialSizeTwo, initialFontThree, initialSizeThree, monogramStyle, designID;
var lineOneCopy, lineTwoCopy, lineThreeCopy, lineFourCopy, initialOneCopy, initialTwoCopy, initialThreeCopy;
var numberOfLines, includeDesign;
var currentStepDiv = "styleStep";
var currentStepNum = "1";
var napkinPictureUrl, printID, layoutChosen;
var fontID1, fontID2, fontID3, fontID4, size1, size2, size3, size4, line1, line2, line3, line4, ms;
var foilChoices;
var foilChoice = 1;
var productName = "";
var colorName = "";
var foilName1 = "";
var foilName = "";
//var previewButton = false;

function getAllValues() {
	styleID = document.productForm.styleID.value;
	designerPrintID = document.productForm.designerPrintID.value;
//	fauxPrintID = document.productForm.fauxPrintID.value;
	colorID = document.productForm.colorID.value;
	foilColorID = document.productForm.foilColorID.value;
	foilColorID2 = document.productForm.foilColorID2.value;
	itemLayout = document.productForm.itemLayout.value;
	itemContent = getRadioValue(document.productForm.itemContent);
	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;
//	initialOneCopy = document.productForm.initialOneCopy.value;
//	initialTwoCopy = document.productForm.initialTwoCopy.value;
//	initialThreeCopy = document.productForm.initialThreeCopy.value;
}

//function hideAndSeek(hideDivsArray,showDiv,showDivTwo,showDivThree) {
//	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'");
//	}
//}
function seek(showDiv) {
	eval(navRefOne + showDiv + navRefTwo + ".display = 'block'");
}
function hide(hideDiv) {
	eval(navRefOne + hideDiv + navRefTwo + ".display = 'none'");
}

var stepArray = new Array();
stepArray["styleStep"] = 1;
stepArray["colorStep"] = 2;
stepArray["foilStep"] = 3;
stepArray["copyStep"] = 4;
stepArray["layoutStep"] = 5;
stepArray["previewStep"] = 6;

function backStep() {
	var newStepNum = currentStepNum;
	if (currentStepNum == "3a") {
		newStepNum = 3;
	}
	if (newStepNum > 1) {
		newStepNum = newStepNum - 1;
	}
	if (currentStepNum == 3 && foilChoices == 2) {
		foilChoice = 1;
		newStepNum = "3";
	}
	for (newStep in stepArray) {
		if (stepArray[newStep] == newStepNum) {
			changeStep(newStep);
		}
	}
}
function changeStep(stepDiv) {
	var cat = "";
	getAllValues();
	if (stepDiv == "styleStep" && styleID == "18") {
		stepDiv = "colorStep";
	}
	if (stepDiv == "layoutStep" && styleID == "18") {
		if (currentStepDiv != "previewStep") {
			stepDiv = "previewStep";
		} else {
			stepDiv = "copyStep";
		}
	}
	stepnum = stepArray[stepDiv];
	if (currentStepNum == "3a") {
		eval(navRefOne + "stepno3" + navRefTwo.replace(/.style/,".className") + " = 'inactive-step'");
	} else {
		eval(navRefOne + "stepno" + currentStepNum + navRefTwo.replace(/.style/,".className") + " = 'inactive-step'");
	}
	eval(navRefOne + "stepno" + stepnum + navRefTwo.replace(/.style/,".className") + " = 'active-step'");
	if (stepDiv == "foilStep" && foilChoices == 2 && foilChoice == 1) {
		stepnum = stepnum + "a";
		stepDiv = stepDiv + "1";
	}
	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) {
		if (stepDiv == "colorStep") {
			if (styleID >= 41 && styleID <= 46) {
				sln = "Y";
			} else {
				sln = "N";
			}
			if (styleID == 1 || styleID == 41) {
				cat="B";
			} else if (styleID == 2 || styleID == 42) {
				cat="F";
			} else if (styleID == 3 || styleID == 43) {
				cat="P";
			} else if (styleID == 4 || styleID == 44) {
				cat="L";
			} else if (styleID == 5 || styleID == 45) {
				cat="G";
			} else if (styleID == 21 || styleID == 46) {
				cat="D";
			}
			if (styleID == 17 || styleID == 18) {
				cat="SC";
				setTimeout('loadIframe("colorSamples", "samplePages/showCoasterColors.php?cat=' + cat + '")',300);
			} else {
				setTimeout('loadIframe("colorSamples", "samplePages/showNapkinColors.php?cat=' + cat + '&sln=' + sln + '")',300);
			}
		} else if (stepDiv == "foilStep") {
			setTimeout('loadIframe("foilSamples", "samplePages/showFoils.php")',300);
		} else if (stepDiv == "foilStep1") {
			setTimeout('loadIframe("foilSamples1", "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 == "copyArtStep") {
//			setTimeout('loadIframe("copyArtSamples", "samplePages/showDesigns.php")',300);
//		} else if (stepDiv == "contentStep") {
//			setTimeout('loadIframe("contentSamples", "samplePages/showExtraContent.php")',300);
		} else if (stepDiv == "layoutStep") {
			setTimeout('loadIframe("layoutSamples", "samplePages/showLayouts.php")',300);
		}
	}
	currentStepDiv = stepDiv;
	currentStepNum = stepnum;
	updatePreview();
}

function selectStyle(selectItem,selectName) {
	document.productForm.styleID.value=selectItem;
	var d=document.getElementById('product_type');
	d.innerHTML=printName + "<br />" + selectName + " " + colorName;
	productName=selectName;
	getAllValues();
	styleSelect();
}

function selectNapkinColor(selectItem,selectName) {
	document.productForm.colorID.value=selectItem;
	var d=document.getElementById('product_type');
	d.innerHTML=printName + "<br />" + productName + " " + selectName;
	colorName=selectName;
	getAllValues();
	colorSelect();
}
function selectColor(selectItem,selectName) {
	document.productForm.colorID.value=selectItem;
	var d=document.getElementById('product_type');
	d.innerHTML=printName + "<br />" + productName + " " + selectName;
	colorName=selectName;
	getAllValues();
	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,foilNamex) {
	var d=document.getElementById('foil_type');
	if (foilChoices == 2 && foilChoice == 1) {
		document.productForm.foilColorID.value=selectItem;
		foilName1 = foilNamex;
	} else {
		document.productForm.foilColorID2.value=selectItem;
		foilName = foilNamex;
	}
	if (foilChoices == 2) {
		d.innerHTML = foilName1 + "<br />" + foilName;
	} else {
		document.productForm.foilColorID.value=selectItem;
		d.innerHTML = foilName;
	}
	foilColorSelect();
}
function selectBlank() {
	alert("Designer Prints REQUIRE an imprint color selection!");
//	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 selectDesignerPrint(selectItem,selectCat) {
	document.productForm.designerPrintID.value=selectItem;
	submitArray = new Array("/designerNapkins.php","/napkins.php","/matches.php","/bags.php","/tags.php","/coasters.php","/notecards.php","/favors.php","/favors.php","/favors.php","","","","/ribbons.php","","","","/stirsticks.php","","/placecards.php");
	document.productForm.action = submitArray[selectCat];
	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";
			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;
	}
	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 = findFont("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 = findFont("36", nxtFld);
			}
		}
	} else {
		nxtFld.selectedIndex = 0;
	}
	updatePreview();
}
function findFont(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 designerPrintSelect() {
	getAllValues();
}
function styleSelect() {
	getAllValues();
	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();
	if (foilChoices == 2 && foilChoice == 1) {
		foilChoice = 2;
		changeStep("foilStep");
	} else {
		if (foilChoices == 2 && foilChoice == 2) {
			foilChoice = 1;
		}
		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.");
//		}
//	}
	updatePreview();
}
function designSelect() {
	getAllValues();
	changeStep("layoutStep");
}
function layoutSelect() {
	getAllValues();
//	if (itemLayout == "squareSetup" && designID != "") {
//		designID = "";
//		document.productForm.designID.value="";
//		alert("Designs cannot be added to a Square Setup. Your design selection has been cleared.");
//	}
	if (itemLayout == "squareSetup" && itemContent.substr(0,8) == "monogram") {
		document.productForm.itemLayout.value="";
		alert("Square Setup cannot be selected with Monograms.");
		return;
	}
	changeStep("previewStep");
}
function fontSelect() {
	getAllValues();
	updatePreview();
}
//function monogramSelect() {
//	getAllValues();
//	var listResetArray = new Array("colorID", "foilColorID", "itemLayout", "fontFaceOne", "fontSizeOne", "fontFaceTwo", "fontSizeTwo", "fontFaceThree", "fontSizeThree", "initialOneFontList", "initialOneSizeList", "initialTwoFontList", "initialTwoSizeList", "initialThreeFontList", "initialThreeSizeList", "designID");
//	var hideDivsArray = new Array("layoutDiv", "colorDiv", "foilDiv", "lineOneDiv", "lineTwoDiv", "lineThreeDiv", "lineFourDiv", "initialOneDiv", "initialTwoDiv", "initialThreeDiv", "designsDiv", "previewButtonDiv");
//	if (monogramStyle == "noneChosen") {
//		var nextStep = "monogramStep";
//		var showDiv = 'monogramStyleDiv';
//	} else {
//		var nextStep = "layoutStep";
//		var showDiv = 'layoutDiv';
//	}
//	changeStep(nextStep);
//	resetLists(listResetArray);
//	hideAndSeek(hideDivsArray,showDiv);
//}

//var isMonogram = false;
//function copySelect() {
//	getAllValues();
//	if (itemContent.substr(0,8) == "monogram") {
//		isMonogram = true;
//	} else {
//		isMonogram = false;
//	}
//	var listResetArray = new Array("fontFaceOne", "fontSizeOne", "fontFaceTwo", "fontSizeTwo", "fontFaceThree", "fontSizeThree", "initialOneFontList", "initialOneSizeList", "initialTwoFontList", "initialTwoSizeList", "initialThreeFontList", "initialThreeSizeList");
//	var hideDivsArray = new Array("lineOneDiv", "lineTwoDiv", "lineThreeDiv", "lineFourDiv", "initialOneDiv", "initialTwoDiv", "initialThreeDiv", "previewButtonDiv");
//	if (isMonogram == false) {
//		var nextStep = "copyStep";
//		var showDiv = 'lineOneDiv';
//		if (itemLayout == "squareSetup" || itemContent.substr(0,7) == "twoLine") {
//			var showDivTwo = 'lineTwoDiv';
//		} else if (itemContent.substr(0,9) == "threeLine") {
//			var showDivTwo = 'lineTwoDiv';
//			var showDivThree = 'lineThreeDiv';
//		} else if (itemContent == "fourLine") {
//			var showDivTwo = 'lineTwoDiv';
//			var showDivThree = 'lineThreeDiv';
//			var showDivFour = 'lineFourDiv';
//		}
//	} else {
//		var nextStep = "copyStep";
//		var showDiv = 'initialOneDiv';
//		if (monogramStyle == "twoLettersHoriz" || monogramStyle == "twoLettersVert" || monogramStyle == "twoLettersOffset") {
//			var showDivTwo = 'initialTwoDiv';
//		} else if (monogramStyle == "threeLettersHoriz" || monogramStyle == "threeLettersVert" || monogramStyle == "threeLettersOffset") {
//			var showDivTwo = 'initialTwoDiv';
//			var showDivThree = 'initialThreeDiv';
//		}
//		if (itemContent == "monogramDate") {
//			var showDivFour = 'lineFourDiv';
//		}
//	}
//	changeStep(nextStep);
//	resetLists(listResetArray);
//	hideAndSeek(hideDivsArray,showDiv,showDivTwo,showDivThree,showDivFour);
////	checkContent();
//	seek('previewButtonDiv');
//}
//
//var currentContentStep;
//var contentDisplayed;
//function checkContent() {
//	getAllValues();
//	includeDesign = "no";
//	currentContentStep = "copyStep";
//
////	if (styleID != 3) { /* not a designer napkin */
//	if (itemContent.substr(0,8) != "monogram") {
//		contentDisplayed = itemContent;
//		if (itemContent.indexOf("Art") >= 0) {
//			includeDesign = "yes";
//		}
//		if (itemContent == "blank") {
//			currentContentStep = "contentStep";
//			numberOfLines = 0;
//		} else if (itemContent == "onlyArt") {
//			currentContentStep = "copyArtStep";
//			numberOfLines = 0;
//		} else if (itemContent.substr(0,7) == "oneLine") {
//			numberOfLines = 1;
//		} else if (itemContent.substr(0,7) == "twoLine" || itemLayout == "squareSetup") {
//			numberOfLines = 2;
//		} else if (itemContent.substr(0,9) == "threeLine") {
//			numberOfLines = 3;
//		} else if (itemContent == "fourLine") {
//			numberOfLines = 4;
//		}
//	} else {
//		if (monogramStyle == "oneLetter") {
//			contentDisplayed = "oneLetter";
//			numberOfLines = 1;
//		} else if (monogramStyle == "twoLettersHoriz" || monogramStyle == "twoLettersVert" || monogramStyle == "twoLettersOffset") {
//			contentDisplayed = "twoLetters";
//			numberOfLines = 2;
//		} else if (monogramStyle == "threeLettersHoriz" || monogramStyle == "threeLettersVert" || monogramStyle == "threeLettersOffset") {
//			contentDisplayed = "threeLetters";
//			numberOfLines = 3;
//		}
//		if (itemContent == "monogramDate") {
//			numberOfLines = 4;
//		}
//	}
////	} else if (styleID == 3) { /* is a designer napkin */
////		if (itemContent == "blank") {
////			currentContentStep = "contentStep";
////			contentDisplayed = "blank";
////			numberOfLines = 0;
////		} else if (itemContent == "onlyArt") {
////			currentContentStep = "contentOnlyArt";
////			contentDisplayed = "onlyArt";
////			numberOfLines = 0;
////			includeDesign = "yes";
////		} else if (designerPrintID == 1 || designerPrintID == 8) {
////			currentContentStep = "contentOneLineArt";
////			contentDisplayed = "oneLineArt";
////			numberOfLines = 1;
////			includeDesign = "yes";
////		} else if (designerPrintID == 12 || designerPrintID == 14) {
////			currentContentStep = "contentTwoLine";
////			contentDisplayed = "twoLine";
////			numberOfLines = 2;
////		} else {
////			currentContentStep = "contentOneLine";
////			contentDisplayed = "oneLine";
////			numberOfLines = 1;
////		}
////	}
//	/* reset errors */
//	errorString = "";
//	errorNumber = 0;
//	previewButton = true;
//	if (contentDisplayed != "blank" && contentDisplayed != "onlyArt") {
//		if (itemContent.substr(0,8) != "monogram") {
//			if (lineOneCopy == "" || fontFaceOne == "noneChosen" || fontSizeOne == "noneChosen") {
//				previewButton = false;
//				errorNumber++;
//				errorString += errorNumber + errorNumDot + "Line one font, size or text is not complete!\n";
//			}
//			if (numberOfLines != 1) {
//				if (lineTwoCopy == "" || fontFaceTwo == "noneChosen" || fontSizeTwo == "noneChosen") {
//					previewButton = false;
//					errorNumber++;
//					errorString += errorNumber + errorNumDot + "Line two font, size or text is not complete!\n";
//				}
//				if (numberOfLines != 2) {
//					if (lineThreeCopy == "" || fontFaceThree == "noneChosen" || fontSizeThree == "noneChosen") {
//						previewButton = false;
//						errorNumber++;
//						errorString += errorNumber + errorNumDot + "Line three font, size or text is not complete!\n";
//					}
//				}
//			}
//		} else {
//			if (initialOneCopy == "" || initialFontOne == "noneChosen" || initialSizeOne == "noneChosen") {
//				previewButton = false;
//				errorNumber++;
//				errorString += errorNumber + errorNumDot + "Initial one font, size or text is not complete!\n";
//			}
//			if (monogramStyle != "oneLetter") {
//				if (initialTwoCopy == "" || initialFontTwo == "noneChosen" || initialSizeTwo == "noneChosen") {
//					previewButton = false;
//					errorNumber++;
//					errorString += errorNumber + errorNumDot + "Initial two font, size or text is not complete!\n";
//				}
//				if (monogramStyle.substr(0,10) != "twoLetters") {
//					if (initialThreeCopy == "" || initialFontThree == "noneChosen" || initialSizeThree == "noneChosen") {
//						previewButton = false;
//						errorNumber++;
//						errorString += errorNumber + errorNumDot + "Initial three font, size or text is not complete!\n";
//					}
//				}
//			}
//		}
//		if (numberOfLines == 4) {
//			if (lineFourCopy == "" || fontFaceFour == "noneChosen" || fontSizeFour == "noneChosen") {
//				previewButton = false;
//				errorNumber++;
//				errorString += errorNumber + errorNumDot + "Line four/date line font, size or text is not complete!\n";
//			}
//		}
//	}
//	if (previewButton) {
//		var nextStep = "previewStep";
//	} else {
//		var nextStep = currentContentStep;
//	}
//	changeStep(nextStep);
//}
//
//function previewitemLayout() {
//	checkContent();
//	if (previewButton) {
//		showPreview();
//	} else {
//		alert(errorString);
//		var nextStep = currentContentStep;
//		changeStep(nextStep);
//	}
//}

var previewDelay;
var previewUrl;
//function showPreview() {
//	getAllValues();
//	if (styleID == 3 || styleID == 43) { /* designer napkin */
//		printID = designerPrintID;
//	} else if (styleID == 2 || styleID == 42) { /* faux napkin */
//		printID = fauxPrintID;
//	} else {
//		printID = "";
//	}
//	if (itemContent.substr(0,8) == "monogram") {
//		fontID1 = initialFontOne;
//		fontID2 = initialFontTwo;
//		fontID3 = initialFontThree;
//		fontID4 = fontFaceFour;
//		size1 = initialSizeOne;
//		size2 = initialSizeTwo;
//		size3 = initialSizeThree;
//		size4 = fontSizeFour;
//		line1 = initialOneCopy;
//		line2 = initialTwoCopy;
//		line3 = initialThreeCopy;
//		line4 = lineFourCopy;
//		ms = monogramStyle;
//		if (itemContent != "monogramDate") {
//			line4 = "";
//			if (monogramStyle.substr(0,5) != "three") {
//				line3 = "";
//				if (monogramStyle.substr(0,3) != "two") {
//					line2 = "";
//				}
//			}
//		}
//	} else {
//		fontID1 = fontFaceOne;
//		fontID2 = fontFaceTwo;
//		fontID3 = fontFaceThree;
//		fontID4 = fontFaceFour;
//		size1 = fontSizeOne;
//		size2 = fontSizeTwo;
//		size3 = fontSizeThree;
//		size4 = fontSizeFour;
//		line1 = lineOneCopy;
//		line2 = lineTwoCopy;
//		line3 = lineThreeCopy;
//		line4 = lineFourCopy;
//		ms = "noneChosen";
//		if (itemContent != "fourLine") {
//			line4 = "";
//			if (itemContent.substr(0,9) != "threeLine") {
//				line3 = "";
//				if (itemContent.substr(0,7) != "twoLine") {
//					line2 = "";
//					if (itemContent.substr(0,7) != "oneLine") {
//						line1 = "";
//					}
//				}
//			}
//		}
//	}
////	if (styleID == 3) { /* designer napkin */
////		if (designerPrintID == 14) {
////			layoutChosen = "squareSetup";
////		} else if (designerPrintID == 8 || designerPrintID == 6 || designerPrintID == 5) {
////			layoutChosen = "middleCenter";
////		} else if (designerPrintID == 12 || designerPrintID == 10) {
////			layoutChosen = "leftRotated";
////		} else if (designerPrintID == 2) {
////			layoutChosen = "vertMiddle";
////		} else if (designerPrintID == 1) {
////			layoutChosen = "flushLeft";
////		} else if (designerPrintID == 15) {
////			layoutChosen = "flushRight";
////		} else {
////			layoutChosen = "";
////		}
////	} else {
//		layoutChosen = itemLayout;
////	}
//
//	/* ------------ place url values in hidden fields------------ */
//	document.urlPlaceholderForm.styleID.value = styleID;
//	document.urlPlaceholderForm.colorID.value = colorID;
//	document.urlPlaceholderForm.foilColorID.value = foilColorID;
//	document.urlPlaceholderForm.layoutChosen.value = layoutChosen;
//	document.urlPlaceholderForm.printID.value = printID;
//	document.urlPlaceholderForm.designID.value = designID;
//	document.urlPlaceholderForm.includeDesign.value = includeDesign;
//	document.urlPlaceholderForm.numberOfLines.value = numberOfLines;
//	document.urlPlaceholderForm.fontID1.value = fontID1;
//	document.urlPlaceholderForm.fontID2.value = fontID2;
//	document.urlPlaceholderForm.fontID3.value = fontID3;
//	document.urlPlaceholderForm.fontID4.value = fontID4;
//	document.urlPlaceholderForm.size1.value = size1;
//	document.urlPlaceholderForm.size2.value = size2;
//	document.urlPlaceholderForm.size3.value = size3;
//	document.urlPlaceholderForm.size4.value = size4;
//	document.urlPlaceholderForm.line1.value = line1;
//	document.urlPlaceholderForm.line2.value = line2;
//	document.urlPlaceholderForm.line3.value = line3;
//	document.urlPlaceholderForm.line4.value = line4;
//	document.urlPlaceholderForm.ms.value = ms;
//	/* ----------------------- */
//
///* alert(getPictUrl()); */
//	showTweaks();
//	eval(navRefOne + "preview" + navRefTwo + ".visibility = 'visible'");
//	eval(navRefOne + "tweakDiv" + navRefTwo + ".visibility = 'visible'");
//	eval(navRefOne + "contentProducts" + navRefTwo + ".visibility = 'hidden'");
//	eval(navRefOne + "directions" + navRefTwo + ".visibility = 'hidden'");
//	eval(navRefOne + "productShot" + navRefTwo + ".visibility = 'hidden'");
//	previewUrl = getPictUrl();
//
//	previewDelay = setTimeout("displayPreview()",3000);
//}
//function displayPreview() {
//	eval(navRefOne + "preview" + navRefTwo + ".background = \"url('" + previewUrl + "') no-repeat center center #fff\"");
//}

function getPictUrl() {
	if (styleID == 18) {
		pictureUrl =
		"coasterPicture.php?" +
		"style=" + document.urlPlaceholderForm.styleID.value + "&" +
		"colorID=" + document.urlPlaceholderForm.colorID.value + "&" +
		"foilID=" + document.urlPlaceholderForm.foilColorID.value + "&" +
		"foilID2=" + document.urlPlaceholderForm.foilColorID2.value + "&" +
		"designID=" + document.urlPlaceholderForm.designID.value + "&" +
		"design=" + document.urlPlaceholderForm.includeDesign.value + "&" +
		"numLines=" + document.urlPlaceholderForm.numberOfLines.value + "&" +
		"fontID1=" + document.urlPlaceholderForm.fontID1.value + "&" +
		"fontID2=" + document.urlPlaceholderForm.fontID2.value + "&" +
		"fontID3=" + document.urlPlaceholderForm.fontID3.value + "&" +
		"fontID4=" + document.urlPlaceholderForm.fontID4.value + "&" +
		"size1=" + document.urlPlaceholderForm.size1.value + "&" +
		"size2=" + document.urlPlaceholderForm.size2.value + "&" +
		"size3=" + document.urlPlaceholderForm.size3.value + "&" +
		"size4=" + document.urlPlaceholderForm.size4.value + "&" +
		"line1=" + escape(document.urlPlaceholderForm.line1.value).replace(/\+/g,"%2B") + "&" +
		"line2=" + escape(document.urlPlaceholderForm.line2.value).replace(/\+/g,"%2B") + "&" +
		"line3=" + escape(document.urlPlaceholderForm.line3.value).replace(/\+/g,"%2B") + "&" +
		"line4=" + escape(document.urlPlaceholderForm.line4.value).replace(/\+/g,"%2B") + "&" +
		"monoStyle=" + document.urlPlaceholderForm.ms.value;
	} else {
		pictureUrl =
		"napkinPicture.php?" +
		"styleID=" + document.urlPlaceholderForm.styleID.value + "&" +
		"colorID=" + document.urlPlaceholderForm.colorID.value + "&" +
		"foilID=" + document.urlPlaceholderForm.foilColorID.value + "&" +
		"foilID2=" + document.urlPlaceholderForm.foilColorID2.value + "&" +
		"layout=" + document.urlPlaceholderForm.layoutChosen.value + "&" +
		"printID=" + document.urlPlaceholderForm.printID.value + "&" +
		"designID=" + document.urlPlaceholderForm.designID.value + "&" +
		"design=" + document.urlPlaceholderForm.includeDesign.value + "&" +
		"lines=" + document.urlPlaceholderForm.numberOfLines.value + "&" +
		"fontID1=" + document.urlPlaceholderForm.fontID1.value + "&" +
		"fontID2=" + document.urlPlaceholderForm.fontID2.value + "&" +
		"fontID3=" + document.urlPlaceholderForm.fontID3.value + "&" +
		"fontID4=" + document.urlPlaceholderForm.fontID4.value + "&" +
		"size1=" + document.urlPlaceholderForm.size1.value + "&" +
		"size2=" + document.urlPlaceholderForm.size2.value + "&" +
		"size3=" + document.urlPlaceholderForm.size3.value + "&" +
		"size4=" + document.urlPlaceholderForm.size4.value + "&" +
		"line1=" + escape(document.urlPlaceholderForm.line1.value).replace(/\+/g,"%2B") + "&" +
		"line2=" + escape(document.urlPlaceholderForm.line2.value).replace(/\+/g,"%2B") + "&" +
		"line3=" + escape(document.urlPlaceholderForm.line3.value).replace(/\+/g,"%2B") + "&" +
		"line4=" + escape(document.urlPlaceholderForm.line4.value).replace(/\+/g,"%2B") + "&" +
		"ms=" + document.urlPlaceholderForm.ms.value;
	}
	return(pictureUrl);
}
function updatePreview() {
	getAllValues();
//		if (colorID >= 200) {
//			styleID = 2;
//		}
		document.urlPlaceholderForm.styleID.value = styleID;
		if (styleID == 2 || styleID == 3) {
			document.urlPlaceholderForm.printID.value = colorID;
		} else {
			document.urlPlaceholderForm.printID.value = "noneChosen";
		}
		document.urlPlaceholderForm.colorID.value = colorID;
		document.urlPlaceholderForm.foilColorID.value = foilColorID;
		document.urlPlaceholderForm.foilColorID2.value = foilColorID2;
		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;
		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,700);
//	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 napkin style has not been chosen!\n";
	}
	/* -------------- check color or faux print -------------- */
	if (colorID == "") {
		errorNumber++;
		errorString += errorNumber + errorNumDot + "A napkin 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 (contentDisplayed != "blank") {
		if (itemLayout == "") {
			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.flushLeft = "Flush Left";
		layArray.flushRight = "Flush Right";
		layArray.angleCenter = "Angle Center";
		layArray.angleBottom = "Angle Bottom";
		layArray.middleCenter = "Middle Center";
		layArray.bottomCenter = "Bottom Center";
		layArray.squareSetup = "Square Set-up";
		layArray.leftRotated = "left Rotated";
		layArray.vertMiddle = "Vertical Middle";
		var layChosen = document.urlPlaceholderForm.layoutChosen.value;
		document.addCartForm.cart_layout.value = layArray[layChosen];
		if (designerPrintID == 35) {
			document.addCartForm.cart_layout.value += " [BI2]";
		}

		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;

//		if (document.urlPlaceholderForm.styleID.value == 2 || document.urlPlaceholderForm.styleID.value == 3 || document.urlPlaceholderForm.styleID.value == 42 || document.urlPlaceholderForm.styleID.value == 43) {
//			document.addCartForm.cart_colorID.value = document.urlPlaceholderForm.printID.value;
//		} else {
			document.addCartForm.cart_colorID.value = document.urlPlaceholderForm.colorID.value;
//		}

		document.addCartForm.cart_foilID.value = document.urlPlaceholderForm.foilColorID.value;
		document.addCartForm.cart_foilID2.value = document.urlPlaceholderForm.foilColorID2.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); */
}



