//***************************************************
//***** COPYRIGHT 2006 PRACTICAL DATA, INC.  ********
//***** USE WITHOUT PERMISSION IS PROHIBITED ********
//***************************************************
function validateOmForm(frm){
	var personalization = getSelectValue(document.omForm["Personalization"]);
	var gift = getCheckedValue(document.omForm["Gift Wrapping"]);
	var recipients = getCheckedValue(document.omForm["Recipient Variations"]);
	var pSetting = getSelectValue(document.omForm["Personalization"]);
	
	if(personalization == null || personalization == ""){
		alert("Please select a personalization option.\r\n \r\n If you do not need personalization, \r\n select \"No Etching/ Blank Goods\" from \r\n the drop-down menu.");
	}
	if(gift == null || gift == ""){
		alert("Please choose a gift wrapping option.");
	}
	switch(pSetting){
		case "Company Logo":
			if(recipients == null || recipients == ""){
				alert("Please specify if this item will have mulitple recipients.");
				return false;
			}			
			break;
		case "Company Logo w/text":
			if(recipients == null || recipients == ""){
				alert("Please specify if this item will have mulitple recipients.");
				return false;
			}			
			break;
		case "Text Only":
			if(recipients == null || recipients == ""){
				alert("Please specify if this item will have mulitple recipients.");
				return false;
			}			
			break;
	}
	if(personalization == null || personalization == "" || gift == null || gift == ""){
		return false;	
	}else{
		return true;
	}
}
function getSelectValue(selectObj){
	return selectObj.options[selectObj.selectedIndex].value;
}

function textCounter( field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    alert( 'You have reached the 85 character limit.' );
    return false;
  }else{
    document.getElementById("charText").innerHTML = maxlimit - field.value.length;
  }
}

function isNumber(sText,surcharge){
	var qty = document.omForm["vwquantity"].value - 0;
	var qtyRecip = document.omForm["Recipients"].value - 0;

	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	
	for (i = 0; i < sText.length && IsNumber == true; i++){ 
	Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1){
			alert("This field can only contain numbers.");
		}else{
			var rCount = document.omForm["Recipients"].value - 0;
			var updatePriceStr = 'surcharge,' + rCount + ',' + surcharge;
			if(rCount > qty){alert("You cannot exceed your item quantity.  Please adjust your recipient count.");document.omForm["Recipients"].value = "";return false;}
			updatePrice(updatePriceStr);
		}
	}
	if(!sText){
		updatePrice();
	}
}


function giftItemDisplay(setDisplay,minQty,minQtySurcharge){
	var optionStr = "gift";
	if(setDisplay == 'No'){
	document.getElementById("giftItemDisplay").style.display = 'none';
	document.omForm["Gift Wrapping"].selectedIndex = 2;
	document.omForm["Gift Card Message"].value = '';	
    document.getElementById("charText").innerHTML = '85';
	updatePrice(optionStr,minQty,minQtySurcharge);
	}else if(setDisplay == 'Yes'){
	document.getElementById("giftItemDisplay").style.display = 'block';
	document.omForm["Gift Wrapping"].selectedIndex = 1;
	updatePrice(optionStr,minQty,minQtySurcharge);
	}
}

function recipientsDisplay(setDisplay){
	if(setDisplay == 'No'){
		document.omForm["Recipients"].value = '';		
		document.omForm["Recipients Surcharge"].value = 0;		
		document.getElementById("recipientsInputDisplay").style.display = 'none';
		updatePrice();
	}else if(setDisplay == 'Yes'){
		document.getElementById("recipientsInputDisplay").style.display = 'block';
	}
}

function parseOptionPrice(optionStr){
	//FIND PRICE DIFFERENCE	
 	var optionPriceStart = optionStr.indexOf("(");
	var optionPriceEnd = optionStr.indexOf(")");
	var optionPriceStr = optionStr.substring(optionPriceStart + 3, optionPriceEnd);
	var optionPriceDiff = optionStr.charAt(optionPriceStart + 1);
	var optionPriceNum = 0;
	//IF COST DIFFERENCE, RETURN NUMBER	
	if(optionPriceStart > 0 && optionPriceDiff == '-'){
		var num = optionPriceStr - 0;
		var numDouble = num * 2;
		var numNeg = num - numDouble;
		optionPriceNum = numNeg;
	}else if(optionPriceStart > 0 && optionPriceDiff == '+'){
		optionPriceNum = optionPriceStr - 0;	
	}
	//RETURN NUMBER
	//alert(optionPriceNum);
	return optionPriceNum;
}

function parseRecipientData(data,pos){
	switch(pos){
		case 1:
		 	var start = data.indexOf(",");
		 	var end = data.lastIndexOf(",");
			var num = data.substring(start+1,end);
			num = num - 0;
			return num;
			break;
		case 2:
		 	var start = data.lastIndexOf(",");
		 	var end = data.length;
			var num = data.substring(start+1,end);
			num = num - 0;
			return num;
			break;
	}
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function delayUpdatePrice(optionStr,minQty,minQtySurcharge) {
	var numberMillis = 250;
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return updatePrice(optionStr,minQty,minQtySurcharge);
    }
}
function updatePrice(optionStr,minQty,minQtySurcharge){
	if(!optionStr){optionStr = "";};

	//GET ADDITIONAL OPTIONS PRICING CHANGE
	var priceChange = 0;
	var rItemSurcharge = 0;
	
	//LOOP AND FIND ADDITIONAL OPTION FIELDS / UPDATE PRICE CHANGE VARIABLE
	for(i=0; i<document.omForm.elements.length; i++){
		var idString = document.omForm.elements[i].id + ''; 
		if(idString.match("add-opt")){
			var addOptionString = document.getElementById(idString).value;
			priceChange += parseOptionPrice(addOptionString)
		}
	}
	
	//GET ITEM PRICE
	var itemPriceStr = document.getElementById("omPrice").innerHTML;
	var itemPriceNum = itemPriceStr - 0;

	//GET QUANTITY
	var quantity = document.getElementById("vwquantity").value;
	
	//MIN QTY LOGIC
	var surcharge = 0;
	var getHtmlSurcharge = document.getElementById("minQtySurchargeAmount").innerHTML;
	var formatHtmlSurcharge = getHtmlSurcharge - 0;
	var getHtmlMinQtyNum = document.getElementById("minQtyNumber").innerHTML;
	var formatHtmlMinQtyNum = getHtmlMinQtyNum - 0;
	minQtySurcharge = formatHtmlSurcharge;
	minQty = formatHtmlMinQtyNum;
	
	var persOpt = document.omForm["Personalization"].value;	
	var minQtyMessage = "Minimum purchase of " + minQty + " items required to avoid $" + minQtySurcharge + " surcharge when choosing Logo option."; 
	if(quantity < minQty){
		switch(persOpt){
			case "Company Logo":
				surcharge = minQtySurcharge / quantity;
				if(optionStr != "gift"){alert(minQtyMessage)};
				var surchargeFormatted = surcharge.toFixed(2);
				minQtySurchargeHTML("surcharge",surchargeFormatted);
				surcharge = minQtySurcharge;
				break;
			case "Company Logo w/text":
				surcharge = minQtySurcharge / quantity;
				if(optionStr != "gift"){alert(minQtyMessage)};
				var surchargeFormatted = surcharge.toFixed(2);
				minQtySurchargeHTML("surcharge",surchargeFormatted);
				surcharge = minQtySurcharge;
				break;
			default:
				minQtySurchargeHTML();
				surcharge = 0;
				break;
		}	
	}else{
		minQtySurchargeHTML();		
	}

	//GET UNIT PRICE
	var unitPrice = itemPriceNum;
	if(document.getElementById("omQtyPrice")){
		//GET QUANTITY PRICING STRING
		var itemQtyPricingStr = document.getElementById("omQtyPrice").innerHTML;
		unitPrice = getQuantityPricing(quantity,itemQtyPricingStr);
	}

	//GET PERSONALIZE PRICE
	var personalizeOption = document.omForm["Personalization"].value;
	var personalizePrice = parseOptionPrice(personalizeOption);
	//GET GIFT OPTION PRICE
	var giftOption = getCheckedValue(document.omForm["Gift Wrapping"]);
	var giftPrice = parseOptionPrice(giftOption);

	//PERFORM MULTIPLE RECIPIENTS SURCHARGE LOGIC
	if(optionStr.match("surcharge") == "surcharge"){
		var rCount = parseRecipientData(optionStr,1);
		var rSurcharge = parseRecipientData(optionStr,2);
		rCalculation = (rCount * rSurcharge) / quantity;
		rItemSurcharge = rCalculation.toFixed(2) - 0;
		document.omForm["Recipients Surcharge"].value = '(+$' + rItemSurcharge + ')';
	}else{
		if(document.getElementById("recipientsSurcharge")){
			var getRSurcharge = document.getElementById("recipientsSurcharge").value;
			var getRStart = getRSurcharge.indexOf("$");
			var getRStartEnd = getRSurcharge.indexOf(")");
			var getRStr = getRSurcharge.substring(getRStart+1,getRStartEnd);
			rItemSurcharge = getRStr - 0;
		}
	}
	
	//MAKE SURE SURCHARGE IS NOT ADDED TWICE
	if(optionStr.match("quantityField") == "quantityField"){
		surcharge = minQtySurcharge;
	}
	//alert('surcharge=' + surcharge);
	//alert('minQtySurcharge=' + minQtySurcharge);
	
	//CALCULATE TOTAL PRICE
	var totalPrice = ((unitPrice * 1) + personalizePrice + giftPrice + priceChange + rItemSurcharge) * quantity + surcharge;

	//UPDATE DISPLAY
	document.getElementById("omPriceDisplay").innerHTML = formatCurrency(totalPrice);
}

function getQuantityPricing(qty, ruleString) {

	//******************
	//*** INITIALIZE ***
	//******************
	var unitPrice = false;
	//ruleString = "1 " + ruleString;

	//*********************
	//*** PARSE RULESET ***
	//*********************
	var ruleAttributes = new Array();
	ruleAttributes = ruleString.split(" ");
	
		//*******************
		//*** SPLIT RULES ***
		//*******************
		var rules = new Object();
		var item = new Object();
		var i = 0;
		var j = 0;
		for(item in ruleAttributes) {
			if(i%2 == 0) {
				rules[j] = new Object();
				rules[j].price = ruleAttributes[item];
			} else {
				rules[j].qty = ruleAttributes[item];
				j++;
			}
			i++;
		}
	
	//****************************
	//*** DETERMINE UNIT PRICE ***
	//****************************
	var item = new Object();
	var found = false;
	for(item in rules) {		
		if(qty - 0 < rules[item].qty && !found) {
			unitPrice = rules[item].price;
			found = true;
		}
	}
	if(!found) unitPrice = rules[item].price;
	
	//**************
	//*** RETURN ***
	//**************	
	return unitPrice;

}

function resetOm(){
	document.omForm["Personalization"].selectedIndex = 0;
	document.omForm.omForm["Gift Wrapping"].selectedIndex = 0;
	updatePrice();
}


function imgPopIt(img, title, width, height) {
	var windowHandle = new Object();
	if(!width) width = 380;
	if(!height) height = 380;
	windowHandle = window.open("", "popUpWindow", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,scrolling=yes,resizable=yes,width=" + width + ",height=" + height);
	var pageContent = "";		
	pageContent = '<html>';
	pageContent = '<head><link rel="stylesheet" href="http://site.corporateawards.net/personalizeOptionMatrixStyle.css" type="text/css"></head>';
	pageContent += '<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF"><center>';
	pageContent += '<table cellpadding="8" border="0" cellspacing="0"><tr><td align="center">';
	pageContent += '<div class="omPopTitle">' + title + '</div>';
	pageContent += '<a href="#" onClick="window.close();"><img src="http://site.corporateawards.net/images/samples/' + img + '" style="border:1px solid #000000;" vspace="10"></a>';
	pageContent += '<br><a href="#" onClick="window.close();" class="omPopLink"><b>Close Window</b></a></td></tr></table>';
	pageContent += '</center></body></html>';
	windowHandle.document.open();
	windowHandle.document.write(pageContent);
	windowHandle.document.close();
	windowHandle.focus();
	return false;
}


function monogramDisplay(monogram){
	var html ='';
	var tableFormatStart = '<table border=0 cellpadding=0 cellspacing=0><tr valign="top"><td align="center">';
	var tableFormatMiddle = '</td><td>&nbsp;&nbsp;</td><td class="omText">';
	var tableFormatEnd = '</td></tr></table>';
	//MONOGRAM 3 INITIALS INPUT HTML/ LEFT CENTER RIGHT
	var monogramInputHTML = '';
	monogramInputHTML += '<b>Enter your initials:</b><br>';
	monogramInputHTML += '<table border="0" cellpadding="3" cellspacing="1"><tr>';
	monogramInputHTML += '<td bgcolor="#CCCCCC" width="36" align="center" class="omSmall"><b>Left</b><br><input type="text" id="Monogram-Text-1" name="Monogram Initial - Left" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogram\');"></td>';
	monogramInputHTML += '<td bgcolor="#CCCCCC" width="36" align="center" class="omSmall"><b>Center</b><br><input type="text" id="Monogram-Text-2" name="Monogram Initial - Center" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogram\');"></td>';
	monogramInputHTML += '<td bgcolor="#CCCCCC" width="36" align="center" class="omSmall"><b>Right</b><br><input type="text" id="Monogram-Text-3" name="Monogram Initial - Right" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogram\');"></td>';
	monogramInputHTML += '</tr></table>'; 

	//MONOGRAM 3 INITIALS INPUT HTML/ LEFT TOP, LEFT BOTTOM, RIGHT
	var monogramInputPanelHTML = '';
	monogramInputPanelHTML += '<b>Enter your initials:</b><br>';
	monogramInputPanelHTML += '<table border="0" cellpadding="3" cellspacing="1"><tr>';
	monogramInputPanelHTML += '<td bgcolor="#CCCCCC" width="36" align="center" class="omSmall"><b>Top Left</b><br><input type="text" id="Monogram-Text-1" name="Monogram Initial - Top Left" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogram\');"></td>';
	monogramInputPanelHTML += '<td bgcolor="#CCCCCC" width="36" align="center" class="omSmall"><b>Lower Left</b><br><input type="text" id="Monogram-Text-2" name="Monogram Initial - Lower Left" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogram\');"></td>';
	monogramInputPanelHTML += '<td bgcolor="#CCCCCC" width="36" align="center" class="omSmall"><b>Right<br></b><br><input type="text" id="Monogram-Text-3" name="Monogram Initial - Right" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogram\');"></td>';
	monogramInputPanelHTML += '</tr></table>'; 
	
	//MONOGRAM 1 INITIALS INPUT HTML
	var monogramInputInitialHTML ='';
	monogramInputInitialHTML += '<b>Enter your initial:</b><br>';
	monogramInputInitialHTML += '<table border="0" cellpadding="3" cellspacing="2" bgcolor="#CCCCCC" width="100"><tr>';
	monogramInputInitialHTML += '<td class="omSmall"><input type="text" id="Monogram-Text-1" name="Monogram Initial" size="1" class="omInputUpper" maxlength="1" onKeyUp="updateProofDisplay(\'monogramInitial\');"></td><td>&nbsp;</td>';
	monogramInputInitialHTML += '</tr></table><span class="omSmall">* Generally your last initial</span>'; 
				
	var casualHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'Casual.jpg\',\'Casual Monogram Style\');"><img src="http://site.corporateawards.net/images/omCasual.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputHTML + tableFormatEnd;
	var diamondHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'Diamond.jpg\',\'Diamond Monogram Style\',380,430);"><img src="http://site.corporateawards.net/images/omDiamond.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputHTML + tableFormatEnd;
	var romanHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'Roman.jpg\',\'Roman Monogram Style\',380,350);"><img src="http://site.corporateawards.net/images/omRoman.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputHTML + tableFormatEnd;
	var staggerHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'Stagger.jpg\',\'Stagger Monogram Style\',380,430);"><img src="http://site.corporateawards.net/images/omStagger.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputHTML + tableFormatEnd;
	var panelHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'Panel.jpg\',\'Panel Monogram Style\',380,330);"><img src="http://site.corporateawards.net/images/omPanel.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputPanelHTML + tableFormatEnd;
	var oldEnglishHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'OldEnglish.jpg\',\'Old English Monogram Style\',380,380);"><img src="http://site.corporateawards.net/images/omOldEnglish.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputInitialHTML + tableFormatEnd;
	var scriptHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'Script.jpg\',\'Script Monogram\',380,430);"><img src="http://site.corporateawards.net/images/omScript.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + monogramInputHTML + tableFormatEnd;

	//DISPLAY MONOGRAM STYLE INFO
	switch (monogram){
	case "Casual":
		monogramDisplayHTML(casualHTML);
		break
	case "Diamond":
		monogramDisplayHTML(diamondHTML);
		break
	case "Roman":
		monogramDisplayHTML(romanHTML);
		break
	case "Stagger":
		monogramDisplayHTML(staggerHTML);
		break
	case "Panel":
		monogramDisplayHTML(panelHTML);
		break
	case "Old English":
		monogramDisplayHTML(oldEnglishHTML);
		break
	case "Script":
		scriptMonogramDisplayHTML(scriptHTML);
		break
	default:
		monogramDisplayHTML(html,'yes');
	}
}
function minQtySurchargeHTML(set,surcharge){
	var html = '<input type="hidden" name="Surcharge" value="(+$' + surcharge + ')"><font color="red"><b>* Surcharge Applied</b></font>';
	if(set == "surcharge"){
		document.getElementById("minQtySurcharge").innerHTML = html;	
	}else{
		document.getElementById("minQtySurcharge").innerHTML = "";		
	}
}

function recipientsHTML(surcharge){
	var surchargeFormatted = surcharge.toFixed(2);
	var html = '';
	html += '<b>Please enter the number of recipients/unique versions:</b><br>';
	html += '<input type="text" name="Recipients" size="3" onkeyup="isNumber(this.value,' + surcharge + ');"> <i>(*numbers only, e.g. "10")</i>';
	html += '<input type="hidden" name="Recipients Surcharge" id="recipientsSurcharge">';
	html += '<br><font color="red">*$' + surchargeFormatted + ' surcharge per unique version';
	return html;
}


function monogramDisplayHTML(monogramHTML,enableInfo){
	if(enableInfo == 'yes'){
		document.getElementById("monogramInfoDisplay").style.display = 'block';
	}else{
		document.getElementById("monogramInfoDisplay").style.display = 'none';
	}
	document.getElementById("monogramInputDisplay").style.display = 'block';
	document.getElementById("monogramInputDisplay").innerHTML = monogramHTML;
	document.getElementById("omProofTextDisplay").innerHTML = '';	
}

function scriptMonogramDisplayHTML(monogramHTML){
	//var html = document.getElementById("scriptMonogram").innerHTML;
	htmlStart = '';
	htmlStart += '<div class="omWhiteLine"><img src="http://site.corporateawards.net/images/whiteLine.gif"></div>';
	htmlStart += '<table border="0" cellpadding="0" cellspacing="0" width="250" align="center">';
	htmlStart += '<tr valign="top"><td><img src="http://site.corporateawards.net/images/om2.gif" width="23" height="41"></td>';
	htmlStart += '<td>&nbsp;&nbsp;</td><td width="99%"><div class="omTitle1" style="padding-bottom:8px;">Script Monogram</div>';
    htmlEnd = '</td></tr></table>';	
	
	//document.getElementById("scriptMonogramDisplay").style.display = 'block';		
	//document.getElementById("scriptMonogramDisplay").innerHTML = html;	
	document.getElementById("scriptMonogramDisplay").style.display = 'block';		
	document.getElementById("scriptMonogramDisplay").innerHTML = htmlStart + monogramHTML + htmlEnd;
	document.getElementById("omProofTextDisplay").innerHTML = '';	
}

function nameInputHTML(){
	var html ='';
	html += '<input type="text" id="name" name="Name" maxlength="24" size="24" class="omInputFirstNameUpper" onKeyUp="updateProofDisplay(\'name\');">';
	html += '<br><a href="#" class="omLinkSm" onClick="imgPopIt(\'Name.jpg\',\'First Name\',380,330);">&raquo; View Sample</a>';

	return html;
}

function firstNameInputHTML(){
	var html ='';
	html += '<input type="text" id="First-Name" name="First Name" maxlength="10" size="10" class="omInputFirstName" onKeyUp="updateProofDisplay(\'firstName\');">';
	html += '<br><a href="#" class="omLinkSm" onClick="imgPopIt(\'Name.jpg\',\'First Name\',380,330);">&raquo; View Sample</a>';

	return html;
}

function nameTitleInputHTML(){
	var html ='';
	html += '<table cellpadding="4" cellspacing="1" border="0">';
	html += '<tr bgcolor="#CCCCCC"><td>Name:</td><td><input type="text" id="Text-1" name="Name" maxlength="24" size="15" class="omInputUpper" style="width:150px;" onKeyUp="updateProofDisplay(\'twoLines\');"></td></tr>';
	html += '<tr bgcolor="#CCCCCC"><td>Title:</td><td><input type="text" id="Text-2" name="Title" maxlength="24" size="15" class="omInputUpper" style="width:150px;" onKeyUp="updateProofDisplay(\'twoLines\');"></td></tr>';
	html += '<tr><td colspan="2"><span class="omSmall">(Maximum 24 Characters Per Line)</span></td></tr>';
	html += '</table>';
	return html;
}

function namesDateInputHTML(){
	var html ='';
	html += '<table cellpadding="4" cellspacing="1" border="0">';
	html += '<tr bgcolor="#CCCCCC"><td>Name 1:</td><td><input type="text" id="Name-Text-1" name="Name 1" maxlength="15" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'namesDates\');"></td></tr>';
	html += '<tr bgcolor="#CCCCCC"><td>Name 2:</td><td><input type="text" id="Name-Text-2" name="Name 2" maxlength="15" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'namesDates\');"></td></tr>';
	html += '<tr bgcolor="#CCCCCC"><td>Date:</td><td><input type="text" id="Date-Text" name="Date" maxlength="15" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'namesDates\');"></td></tr>';
	html += '<tr><td colspan="2"><span class="omSmall">(*Case Sensitive, 15 Characters Per Line Max)</span></td></tr>';
	html += '</table>';
	return html;
}

function fourLinesInputHTML(){
	var html ='';
	html += '<table cellpadding="4" cellspacing="1" border="0">';
	html += '<tr bgcolor="#CCCCCC"><td>Line 1:</td><td><input type="text" id="Text-1" name="Line 1" maxlength="25" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'fourLines\');"></td></tr>';
	html += '<tr bgcolor="#CCCCCC"><td>Line 2:</td><td><input type="text" id="Text-2" name="Line 2" maxlength="25" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'fourLines\');"></td></tr>';
	html += '<tr bgcolor="#CCCCCC"><td>Line 3:</td><td><input type="text" id="Text-3" name="Line 3" maxlength="25" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'fourLines\');"></td></tr>';
	html += '<tr bgcolor="#CCCCCC"><td>Line 4:</td><td><input type="text" id="Text-4" name="Line 4" maxlength="25" size="15" class="omInputName" onKeyUp="updateProofDisplay(\'fourLines\');"></td></tr>';
	html += '<tr><td colspan="2"><span class="omSmall">(*Case Sensitive, 25 Characters Per Line Max)</span></td></tr>';
	html += '</table>';
	return html;
}

function sportsLogoDisplay(logo){
	var html ='';
	var tableFormatStart = '<table border=0 cellpadding=0 cellspacing=0><tr valign="top"><td align="center">';
	var tableFormatMiddle = '</td><td>&nbsp;&nbsp;</td><td class="omText">';
	var tableFormatEnd = '</td></tr></table>';
	
	//NAME INPUT HTML
	var nameInputHTML ='';
	nameInputHTML += '<b>Enter your name:</b><br>';
	nameInputHTML += '<table border="0" cellpadding="3" cellspacing="2" bgcolor="#CCCCCC" width="110"><tr>';
	nameInputHTML += '<td class="omSmall"><input type="text" id="Name-Text" name="Name Text" size="12" class="omInput" maxlength="12" onKeyUp="updateProofDisplay(\'sportsLogoName\');" style="width:95px;"><br><span class="omSmall">*12 Characters Max</span></td><td>&nbsp;</td>';
	nameInputHTML += '</tr></table><span class="omSmall"></span>'; 
				
	var footballHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omFootball.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;
	var baseballHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omBaseball.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;
	var golfHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omGolf.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;
	var tennisHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omTennis.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;
	var barGrillHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omBarGrill.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;
	var soccerHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omSoccer.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;
	var basketballHTML = tableFormatStart + '<a href="#" class="omLinkSm" onClick="imgPopIt(\'PersonalLogo.jpg\',\'Personal & Sports Logo\',625,825);"><img src="http://site.corporateawards.net/images/omBasketball.gif" width="80" height="80" border="0"><br>&raquo; More Info</a>' + tableFormatMiddle + '' + nameInputHTML + tableFormatEnd;

	//DISPLAY SPORTS LOGO INFO
	switch (logo){
	case "Football":
		sportsLogoDisplayHTML(footballHTML);
		break
	case "Baseball":
		sportsLogoDisplayHTML(baseballHTML);
		break
	case "Golf":
		sportsLogoDisplayHTML(golfHTML);
		break
	case "Tennis":
		sportsLogoDisplayHTML(tennisHTML);
		break
	case "Bar & Grill":
		sportsLogoDisplayHTML(barGrillHTML);
		break
	case "Soccer":
		sportsLogoDisplayHTML(soccerHTML);
		break
	case "Basketball":
		sportsLogoDisplayHTML(basketballHTML);
		break
	default:
		sportsLogoDisplayHTML(html);
	}
}

function sportsLogoDisplayHTML(sportsLogoHTML){
	document.getElementById("personalLogoInputDisplay").style.display = 'block';
	document.getElementById("personalLogoInputDisplay").innerHTML = sportsLogoHTML;
	document.getElementById("omProofTextDisplay").innerHTML = '';	
}

function fontDisplay(font){
	var html ='';
	var tableFormatStart = '<table border=0 cellpadding=0 cellspacing=0><tr valign="top"><td align="center">';
	var tableFormatEnd = '</td></tr></table>';
					
	var souvenirHTML = tableFormatStart + '<img src="http://site.corporateawards.net/images/omFontSouvenir.gif" border="0">' + tableFormatEnd;
	var helveticaHTML = tableFormatStart + '<img src="http://site.corporateawards.net/images/omFontHelvetica.gif" border="0">' + tableFormatEnd;
	var optimaHTML = tableFormatStart + '<img src="http://site.corporateawards.net/images/omFontOptima.gif" border="0">' + tableFormatEnd;
	var korinaHTML = tableFormatStart + '<img src="http://site.corporateawards.net/images/omFontKorina.gif" border="0">' + tableFormatEnd;
	var murrayScriptHTML = tableFormatStart + '<img src="http://site.corporateawards.net/images/omFontMurrayScript.gif" border="0">' + tableFormatEnd;
	var palatinoHTML = tableFormatStart + '<img src="http://site.corporateawards.net/images/omFontPalatino.gif" border="0">' + tableFormatEnd;

	//DISPLAY SPORTS LOGO INFO
	switch (font){
	case "Souvenir":
		fontDisplayHTML(souvenirHTML);
		break
	case "Helvetica":
		fontDisplayHTML(helveticaHTML);
		break
	case "Optima":
		fontDisplayHTML(optimaHTML);
		break
	case "Korina":
		fontDisplayHTML(korinaHTML);
		break
	case "Murray Script":
		fontDisplayHTML(murrayScriptHTML);
		break
	case "Palatino":
		fontDisplayHTML(palatinoHTML);
		break
	default:
		fontDisplayHTML(html,'yes');
	}
}

function fontDisplayHTML(fontHTML,enableInfo){
	var optionStr = document.getElementById("Personalization").value;
 	var bracketStart = optionStr.indexOf("(");
	var optionSubStr = '';
	
	if(bracketStart > 0){
		optionSubStr = optionStr.substring(0, bracketStart - 1);
	}else{
		optionSubStr = optionStr;
	}

	
	if(enableInfo == 'yes'){
		document.getElementById("fontInfoDisplay").style.display = 'block';
		if(optionSubStr == 'Company Logo w/text'){
			document.getElementById("companyLogoTextDisplay").style.display = 'none';
		}else{
			document.getElementById("textDisplay").style.display = 'none';		
		}
	}else{
		document.getElementById("fontInfoDisplay").style.display = 'none';
		if(optionSubStr == 'Company Logo w/text'){
			document.getElementById("companyLogoTextDisplay").style.display = 'block';
		}else{
			document.getElementById("textDisplay").style.display = 'block';		
		}
	}
	document.getElementById("fontPreviewDisplay").style.display = 'block';
	document.getElementById("fontPreviewDisplay").innerHTML = fontHTML;
}

function enableProofDisplay(){
	document.getElementById("omProof").style.display = 'block';	
}

function updateProofDisplay(option){	
	var html ='';
	enableProofDisplay();
	
	switch(option){
	case "monogram":
		var mText1 = document.getElementById("Monogram-Text-1").value;
		var mText2 = document.getElementById("Monogram-Text-2").value;
		var mText3 = document.getElementById("Monogram-Text-3").value;
		html += mText1;
		html += '&nbsp; ';
		html += mText2;
		html += '&nbsp; ';
		html += mText3;	
		document.getElementById("omProofTextDisplay").innerHTML = '<span class="omTextUpper"><b>' + html + '</b></span>';
		break		
	case "monogramInitial":
		var mText1 = document.getElementById("Monogram-Text-1").value;
		html += mText1;
		document.getElementById("omProofTextDisplay").innerHTML = '<span class="omTextUpper"><b>' + html + '</b></span>';
		break		
	case "firstName":
		var firstName = document.getElementById("First-Name").value;	
		html += firstName;
		document.getElementById("omProofTextDisplay").innerHTML = '<span class="omText" style="background-color:#FFFFFF; padding:5px;"><b>' + html + '</b></span> <span class="omSmall">(*Case Sensitive)</span>';
		break
	case "namesDates":
		var textLine1 = document.getElementById("Name-Text-1").value;	
		var textLine2 = document.getElementById("Name-Text-2").value;	
		var textLine3 = document.getElementById("Date-Text").value;	
		html += textLine1 + ' <br>';
		html += textLine2 + ' <br>';
		html += textLine3;
		document.getElementById("omProofTextDisplay").innerHTML = '<div class="omText" style="background-color:#FFFFFF; padding:5px;"><b>' + html + '</b></div> <span class="omSmall">(*Case Sensitive)</span>';
		break
	case "fourLines":
		var textLine1 = document.getElementById("Text-1").value;	
		var textLine2 = document.getElementById("Text-2").value;	
		var textLine3 = document.getElementById("Text-3").value;	
		var textLine4 = document.getElementById("Text-4").value;	
		html += textLine1 + ' <br>';
		html += textLine2 + ' <br>';
		html += textLine3 + ' <br>';
		html += textLine4;
		document.getElementById("omProofTextDisplay").innerHTML = '<div class="omText" style="background-color:#FFFFFF; padding:5px;"><b>' + html + '</b></div> <span class="omSmall">(*Case Sensitive)</span>';
		break
	case "name":
		var textLine1 = document.getElementById("name").value;	
		html += textLine1;
		document.getElementById("omProofTextDisplay").innerHTML = '<div class="omTextUpper" style="background-color:#FFFFFF; padding:5px;"><b>' + html + '</b></div>';
		break
	case "twoLines":
		var textLine1 = document.getElementById("Text-1").value;	
		var textLine2 = document.getElementById("Text-2").value;	
		html += textLine1 + ' <br>';
		html += textLine2;
		document.getElementById("omProofTextDisplay").innerHTML = '<div class="omTextUpper" style="background-color:#FFFFFF; padding:5px;"><b>' + html + '</b></div> <span class="omSmall"></span>';
		break
	case "sportsLogoName":
		var text = document.getElementById("Name-Text").value;	
		html += text + ' <br>';
		document.getElementById("omProofTextDisplay").innerHTML = '<div class="omText" style="background-color:#FFFFFF; padding:5px;"><b>' + html + '</b></div> <span class="omSmall">(*Case Sensitive)</span>';
		break

	default:
	}
}

function updateOmDisplay(optionStr,minQty,minQtySurcharge,recipientsSurcharge){
	
	//TRIM OPTION PRICE INFO
 	var bracketStart = optionStr.indexOf("(");
	var optionSubStr = '';
	
	if(bracketStart > 0){
		optionSubStr = optionStr.substring(0, bracketStart - 1);
	}else{
		optionSubStr = optionStr;
	}
	
	//DISPLAY APPROPRIATE OPTION MATRIX
	switch (optionSubStr){
	case "Monogram":
		resetOmDisplay();
		var html = document.getElementById("monogramSelect").innerHTML;
		document.getElementById("monogramSelectDisplay").style.display = 'block';	
		document.getElementById("monogramSelectDisplay").innerHTML = html;	
		document.getElementById("monogramInfoDisplay").style.display = 'block';	
		document.getElementById("omOptionsBlock").style.display = 'block';	
		break
	case "Script Monogram":
		resetOmDisplay();
		monogramDisplay("Script");
		document.getElementById("omOptionsBlock").style.display = 'block';
		break
	case "Name":
		resetOmDisplay();
		document.getElementById("nameDisplay").style.display = 'block';
		document.getElementById("nameInputDisplay").innerHTML = nameInputHTML();	
		break
	case "Name and Title":
		resetOmDisplay();
		document.getElementById("nameTitleDisplay").style.display = 'block';
		document.getElementById("nameTitleInputDisplay").innerHTML = nameTitleInputHTML();	
		break
	case "First Name":
		resetOmDisplay();
		document.getElementById("firstNameDisplay").style.display = 'block';
		document.getElementById("firstNameInputDisplay").innerHTML = firstNameInputHTML();	
		break
	case "Names and Date":
		resetOmDisplay();
		document.getElementById("namesDatesDisplay").style.display = 'block';
		document.getElementById("namesDatesInputDisplay").innerHTML = namesDateInputHTML();	
		break
	case "Names and Date w/bouquet":
		resetOmDisplay();
		document.getElementById("namesDatesBouquetDisplay").style.display = 'block';
		document.getElementById("namesDatesBouquetInputDisplay").innerHTML = namesDateInputHTML();	
		break
	case "Up to Four Lines of Text":
		resetOmDisplay();
		document.getElementById("fourLinesDisplay").style.display = 'block';
		document.getElementById("fourLinesInputDisplay").innerHTML = fourLinesInputHTML();	
		break
	case "Wedding Invitation":
		resetOmDisplay();
		document.getElementById("weddingInvitationDisplay").style.display = 'block';
		break
	case "Company Logo":
		resetOmDisplay();
		var html = recipientsHTML(recipientsSurcharge);
		if(minQty && minQty != 0){
			document.getElementById("minQtyDisplay").style.display = 'block';
			document.omForm["vwquantity"].value = minQty;
		}	
		document.getElementById("companyLogoDisplay").style.display = 'block';
		document.getElementById("recipientsDisplay").style.display = 'block';
		document.getElementById("recipientsInputDisplay").innerHTML = html;
		break
	case "Company Logo w/text":
		var html = document.getElementById("fontSelect").innerHTML;
		var html2 = recipientsHTML(recipientsSurcharge);
		resetOmDisplay();
		if(minQty && minQty != 0){
			document.getElementById("minQtyDisplay").style.display = 'block';
			document.omForm["vwquantity"].value = minQty;
		}	
		document.getElementById("fontInfoDisplay").style.display = 'block';
		document.getElementById("fontSelectDisplay").style.display = 'block';
		document.getElementById("fontSelectDisplay").innerHTML = html;
		document.getElementById("recipientsDisplay").style.display = 'block';
		document.getElementById("recipientsInputDisplay").innerHTML = html2;
		break
	case "Personal & Sports Logo":
		resetOmDisplay();
		var html = document.getElementById("personalLogoSelect").innerHTML;
		document.getElementById("personalLogoSelectDisplay").style.display = 'block';	
		document.getElementById("personalLogoSelectDisplay").innerHTML = html;	
		document.getElementById("omOptionsBlock").style.display = 'block';	
		break
	case "Text Only":
		var html = document.getElementById("fontSelect").innerHTML;
		var html2 = recipientsHTML(recipientsSurcharge);
		resetOmDisplay();
		document.getElementById("fontInfoDisplay").style.display = 'block';
		document.getElementById("fontSelectDisplay").style.display = 'block';
		document.getElementById("fontSelectDisplay").innerHTML = html;
		document.getElementById("recipientsDisplay").style.display = 'block';
		document.getElementById("recipientsInputDisplay").innerHTML = html2;
		break
	default:
		resetOmDisplay();
	}
	//UPDATE PRICE DISPLAY
	updatePrice();
}

function resetOmDisplay(){
	//RESET RECIPIENTS DISPLAY
	document.getElementById("recipientsInputDisplay").innerHTML = '';
	document.getElementById("recipientsDisplay").style.display = 'none';
	//RESET MONOGRAM STYLE
	document.getElementById("omOptionsBlock").style.display = 'none';
	document.getElementById("monogramSelectDisplay").style.display = 'none';
	document.getElementById("monogramSelectDisplay").innerHTML = '';
	document.getElementById("omProofTextDisplay").innerHTML = '';
	document.getElementById("monogramInputDisplay").style.display = 'none';
	document.getElementById("monogramInputDisplay").innerHTML = '';	
	document.getElementById("monogramInfoDisplay").style.display = 'none';	
	document.getElementById("scriptMonogramDisplay").style.display = 'none';	
	document.getElementById("scriptMonogramDisplay").innerHTML = '';
	document.getElementById("omProof").style.display = 'none';			
	//RESET NAME
	document.getElementById("nameDisplay").style.display = 'none';
	document.getElementById("nameInputDisplay").innerHTML = '';
	//RESET NAME & TITLE
	document.getElementById("nameTitleDisplay").style.display = 'none';
	document.getElementById("nameTitleInputDisplay").innerHTML = '';
	//RESET FIRST NAME
	document.getElementById("firstNameDisplay").style.display = 'none';
	document.getElementById("firstNameInputDisplay").innerHTML = '';
	//RESET NAMES DATES
	document.getElementById("namesDatesDisplay").style.display = 'none';
	document.getElementById("namesDatesInputDisplay").innerHTML = '';
	//RESET NAMES DATES
	document.getElementById("namesDatesBouquetDisplay").style.display = 'none';
	document.getElementById("namesDatesBouquetInputDisplay").innerHTML = '';
	//RESET FOUR LINES
	document.getElementById("fourLinesDisplay").style.display = 'none';
	document.getElementById("fourLinesInputDisplay").innerHTML = '';
	//RESET WEDDING INVITATION
	document.getElementById("weddingInvitationDisplay").style.display = 'none';
	//RESET COMPANY LOGO
	document.getElementById("companyLogoDisplay").style.display = 'none';
	//RESET COMPANY LOGO w/TEXT
	document.getElementById("fontSelectDisplay").style.display = 'none';	
	document.getElementById("fontSelectDisplay").innerHTML = '';
	document.getElementById("fontPreviewDisplay").style.display = 'none';
	document.getElementById("fontPreviewDisplay").innerHTML = '';
	document.getElementById("fontInfoDisplay").style.display = 'none';
	document.getElementById("companyLogoTextDisplay").style.display = 'none';
	//RESET PERSONAL SPORTS LOGO
	document.getElementById("omOptionsBlock").style.display = 'none';
	document.getElementById("personalLogoSelectDisplay").style.display = 'none';
	document.getElementById("personalLogoSelectDisplay").innerHTML = '';
	document.getElementById("omProofTextDisplay").innerHTML = '';
	document.getElementById("personalLogoInputDisplay").style.display = 'none';
	document.getElementById("personalLogoInputDisplay").innerHTML = '';	
	document.getElementById("omProof").style.display = 'none';			
	//RESET TEXT ONLY
	document.getElementById("textDisplay").style.display = 'none';
	//RESET MIN QTY
	document.getElementById("minQtyDisplay").style.display = 'none';
	document.omForm["vwquantity"].value = "1";
}

function submitOmForm(){
	document.omForm.submit();
}


