var RegstoreID = "invitationbox";
	
function gEBI(nodename){
	return(document.getElementById(nodename)); 
}

function processColor(colorEl, num, defColor) {
	if(colorEl) {
		tempcolor = colorEl.value;
		if (tempcolor == "Choose One:") {
			tempcolor = "Black";
		}
		return "&fontcolor" + num + "=" + escape(tempcolor);
	} else {
		return "&fontcolor" + num + "=" + escape(defColor);
	}
}

function processDDLValue(el, defVal, qsVar) {
	var s = "&" + qsVar + "=";
	if(el){
		if (el.value == "Choose One:") {
			return s + defVal;
		}
		return s + el.value;	
	}
	return "";
}

function processWaReturnVar(printNameId, quantityNameId) {
	if (gEBI(printNameId) && gEBI(printNameId).checked)
		return printNameId + "=1|" + quantityNameId + "=" + gEBI(quantityNameId).value + "|";
	return "";
}

function processReturnVar(elId) {
	return 	(gEBI(elId)) ? elId + "=" + gEBI(elId).value + "|" : "";
}

function processReturnVarRB(elId1, elId2) {
	return 	(gEBI(elId1)) ? ((gEBI(elId1).checked) ? elId1 + "=1|" : elId2 + "=1|") : "";
}

function previewParam(el, varName) {
	if (el) {
		return "&" + varName + "=" + el.value;
	}
	return "";
}

function getVendor(vendorEl) {
	if(vendorEl){
		var tempvendor = vendorEl.value;
		if (tempvendor == "wa"){
			if (gEBI('digitalprinted') && gEBI('digitalprinted').checked){
				return "wa-d";
			} else if(gEBI('flatprinted') && gEBI('flatprinted').checked){
				return "wa-f";
			} else if(gEBI('thermographyprinted') && gEBI('thermographyprinted').checked){
				return "wa-t";
			} else if(gEBI('engravedprinted') && gEBI('engravedprinted').checked){
				return "wa-e";
			}
		} else {
			return tempvendor;
		}	
	}
}

function getReturnVars() {
	var t = "";
	t += processWaReturnVar('digitalprinted', 'digitalquantity');
	t += processWaReturnVar('flatprinted', 'flatquantity');
	t += processWaReturnVar('thermographyprinted', 'thermographyquantity');
	t += processWaReturnVar('engravedprinted', 'engravedquantity');
	t += processWaReturnVar('printedprinted', 'quantity');
	t += processWaReturnVar('blankblank', 'blankquantity');
	t += processReturnVar('raline1'); 
	t += processReturnVar('raline2');
	t += processReturnVar('raline3');
	t += processReturnVar('rafont');
	t += processReturnVar('rafontcolor');
	t += processReturnVar('frontaddressfont');
	t += processReturnVar('frontaddressfontcolor');
	t += processReturnVar('liningcolor');
	t += processReturnVar('silhouette');
	t += processReturnVar('photocolor');
  t += processReturnVarRB('ReturnAddressPrintingYes', 'ReturnAddressPrintingNo' );
  t += processReturnVarRB('ReturnAddressPrintingBSPYes', 'ReturnAddressPrintingBSPNo' );
  t += processReturnVarRB('frontaddressyes', 'frontaddressno' );
  t += processReturnVarRB('envelopeliningyes', 'envelopeliningno' );
  t += processReturnVarRB('kwiksealenvelopesyes', 'kwiksealenvelopesno' );
  t += processReturnVarRB('layeredcardyes', 'layeredcardno' );
  t += processReturnVarRB('logoyes', 'logono' );
  t += processReturnVarRB('doubleenvelopeliningyes', 'doubleenvelopeliningno' );
  t += processReturnVarRB('enclosurecardenvelopesyes', 'enclosurecardenvelopesno' );
  t += processReturnVarRB('assembledyes', 'assembledno' );
  t += processReturnVarRB('proofyes', 'proofno' );
  t += processReturnVarRB('rushprocessingyes', 'rushprocessingno' );
  t += processReturnVarRB('preshipenvelopesyes', 'preshipenvelopesno' );

  t += (gEBI('superrushprocessing')) ? (gEBI('superrushprocessing').checked) ? "superrushprocessing=1|" : "" : "";
	t += (gEBI('specialinstructions')) ?	"specialinstructions=" + gEBI('specialinstructions').value + "|" : "";	
	
	return t;
}	

function previewUrl(form) {
	var s = "a=a";
	var t = "";
	
	for (i=1; i<21; i++){
		var tempfield = "Line " + ((i<10)?"0":"") + i;
		var tempstyle = "Line " + ((i<10)?"0":"") + i + " Style";
		var tempinfield = "Inside Line " + ((i<10)?"0":"") + i;
		var tempinstyle = "Inside Line " + ((i<10)?"0":"") + i + " Style";		
		
		if(form[tempfield]) {
			s += "&text" + i + "=" + encodeURIComponent(form[tempfield].value);
		}
		
		s += (form[tempstyle]) ? "&text" + i + "style=" + encodeURIComponent(form[tempstyle].value) : "";
		
		if(form[tempinfield]) {
			s += "&intext" + i + "=" + encodeURIComponent(form[tempinfield].value);
		}
		
		if(form[tempinstyle]) {
			s += "&intext" + i + "style=" + encodeURIComponent(form[tempinstyle].value);
		}
	}
	
	if(form['Font Style 1']){
		tempfont1 = form['Font Style 1'].value.toLowerCase();
		if (tempfont1 == "same as shown") {
			tempfont1 = form['vwfont1'].value.toLowerCase();
		}
		if (tempfont1 == "choose one:") {
			tempfont1 = form['vwfont1'].value.toLowerCase();
		}
		s += "&font1=" + tempfont1;
	}
	
	if(form['Font Style 2']){
		tempfont2 = form['Font Style 2'].value.toLowerCase();
		if(form['vwfont2']){
			if (tempfont2 == "no second font") {
				tempfont2 = form['vwfont2'].value.toLowerCase();
			} else if(tempfont2 == "same as shown"){
				tempfont2 = form['vwfont2'].value.toLowerCase();
			}
		} else {
			if (tempfont2 == "no second font") {
				tempfont2 = form['vwfont1'].value.toLowerCase();
			} else if(tempfont2=="same as shown"){
				tempfont2 = form['vwfont1'].value.toLowerCase();
		  }
		}
		s += "&font2=" + tempfont2;
	}

	s += processColor( form['Font Color 1'], '1', form['vwfontcolor1'].value);
	s += processColor( form['Font Color 2'], '2', 'Black');
	
	if(form['vwlayout']){
		layout = form['vwlayout'].value;
		if (layout != "5"){
			s += "&bgid=" + layout;
		} else {
			var temporient = form['Orientation'].value;
			layout = (temporient == "Choose One:"|temporient == "Horizontal (Landscape)") ? "1" : "3";
			s += "&bgid=" + layout;
		}
	}

	s += processDDLValue(form['papercolor'], "White", "papercolor");
	s += previewParam(form['previewid'], 'previewid');
	s += previewParam(form['vwblankimage'], 'blankimage');
	s += previewParam(form['vwshowfontcolor'], 'showfontcolor');
	
	if(form['Formatting']){
		for( i = 0; i < form['Formatting'].length; i++ ){
			if( form['Formatting'][i].checked == true )
				val = form['Formatting'][i].value;
		}
		var tempformatting = val;
		s += "&formatting=" + encodeURIComponent(tempformatting);
	}

	s += "&fontcode=" + ((typeof(ibFontCode) != "undefined") ? ((ibFontCode != "wafonts") ? ibFontCode : "" ) : "");
	s += "&colorcode=" + ((typeof(ibColorCode) != "undefined") ? ibColorCode : "");
	s += "&vendor=" + getVendor(form['vwvendor']);
	s += previewParam(form['vwlines'], 'lines');

	if(form['vwinlines']){
		var templines = form['vwinlines'].value;
		if (parseInt(templines) > 0) {
			s += "&inlines=" + templines;		
			s += "&numLayers=2";
		}
	}

	s += "&id=" + form['vwitem'].value;

	t = getReturnVars(form);

	s += "&returnVars="+encodeURIComponent(t);		
	return s;
}

function photoupload(form) {
	var s = "?photovalue=" + form['vwphotovalue'].value + "&prodid=" + form['vwitem'].value;

	var page = "http://upload.invitationbox.com/upload/photoupload.aspx";
	window.open(page+s,"Photo_Upload","height=475,width=665,scrollbars=no,location=no,toolbar=no,menubar=no");
}

function photopreview(form) {
	var s = previewUrl(form);
	var page = "http://preview.invitationbox.com/fonttest/photopreview.aspx?";
	window.open(page+s,"Photo_Preview","height=840,width=1020,scrollbars=yes,location=no,toolbar=no,menubar=no");
}

function insitePreview(form) {
	var s = encodeURIComponent(previewUrl(form));
  window.location = "http://www.invitationbox.com/preview.html?prvurl="+s,"Font_Preview","height=900,width=1020,scrollbars=no,location=no,toolbar=no,menubar=no";
}

function preview(form) {
	var s = previewUrl(form);

	var page = "http://www.theprintingbox.com/fonttest/Preview.aspx?";
	if(form['vwlayout']){
		var layout = form['vwlayout'].value;
		
		if(layout == "1"){
			window.open(page+s,"Font_Preview","height=600,width=1020,scrollbars=yes,location=no,toolbar=no,menubar=no");
		} else if(gEBI('insitepreview').value == "t"){
			s = s.substr(1,s.length-1);
			s = escape(s);			
			window.location = "http://www.invitationbox.com/preview.html?prvurl="+s,"Font_Preview","height=900,width=1020,scrollbars=no,location=no,toolbar=no,menubar=no";
		} else {
			window.open(page+s,"Font_Preview","height=900,width=1020,scrollbars=yes,location=no,toolbar=no,menubar=no");
		}
	} else {
		window.open(page+s,"Font_Preview","height=758,width=1020,scrollbars=yes,location=no,toolbar=no,menubar=no");
	}
}

function bcpreview(form) {
	var s = "?text1=" + encodeURIComponent(form['Line 01'].value);
	
	for (i=2; i<21; i++){
		var tempfield = "Line " + ((i<10)?"0":"") + i;

		if(form[tempfield]) {
			s += "&text" + i + "=" + encodeURIComponent(form[tempfield].value);
		}
	}
	
	if(form['Font Style 1']){
		tempfont1 = form['Font Style 1'].value.toLowerCase();
		if (tempfont1 == "same as shown") {
			tempfont1 = form['vwfont1'].value.toLowerCase();
		}
		if (tempfont1 == "choose one:") {
			tempfont1 = form['vwfont1'].value.toLowerCase();
		}
		s += "&font=" + tempfont1;
	}
	
	if(form['Font Color']) {
		tempcolor = form['Font Color'].value;
		if (tempcolor =="Choose One:") {
			tempcolor = "Black";
		}
		s += "&color=" + encodeURIComponent(tempcolor);
	}
	
	if(form['Inside Font Color']) {
		tempcolor = form['Inside Font Color'].value;
		if (tempcolor =="Choose One:") {
			tempcolor = "Black";
		}
		s += "&color=" + encodeURIComponent(tempcolor);
	}
	
	if(form['Verse']) {
		if (form['Verse'].disabled) {
		} else {
			tempverse = form['Verse'].value;
			if (tempverse =="Choose One:") {
				}
				s += "&verse=" + encodeURIComponent(tempverse);
		}
	}
	
	if(form['vwlayout']){
		var layout = form['vwlayout'].value;
		
		if (layout != "5"){
			s += "&orientation=" + layout;
		} else {
			var temporient = form['Orientation'].value;
			
			if (temporient == "Choose One:"|temporient == "Horizontal (Landscape)") {
				layout = "1";
			} else {
				layout = "3";
			}
			s += "&orientation=" + layout;
		}
	}	
	
	s += "&id=" + form['vwitem'].value;
	var page = "http://www.theprintingbox.com/fonttest/bcPreview.aspx";
	
	if(form['vwlayout']){
		if(layout == "1"){
			window.open(page+s,"Font_Preview","height=600,width=640,scrollbars=yes,location=no,toolbar=no,menubar=no");
		} else {
			window.open(page+s,"Font_Preview","height=780,width=480,scrollbars=yes,location=no,toolbar=no,menubar=no");
		}
	} else {
		window.open(page+s,"Font_Preview","height=758,width=720,scrollbars=no,location=no,toolbar=no,menubar=no");
	}
}

function rafontpreview(form) {
	var s = "?line1=" + encodeURIComponent(form['RA Line 01'].value)
	
	s += (form['RA Line 02']) ? "&line2=" + encodeURIComponent(form['RA Line 02'].value) : "";
	s += (form['RA Line 03']) ? "&line3=" + encodeURIComponent(form['RA Line 03'].value) : "";

	tempfont = (form['RA Font'].value == "Same as Shown") ? form['vwfont1'].value : form['RA Font'].value;	
	s += "&font=" + tempfont;
	
	s += "&vendor=" + getVendor(form['vwvendor']);
		
	if(gEBI('rafontcolor')){
		var tempRAFontColor = gEBI('rafontcolor').value;
		s += "&fontcolor=" + encodeURIComponent(tempRAFontColor);	
	}
	
	s += (form['vwreply'].value == "yes") ? "&type=reply" : "";
	
	var page = "http://www.theprintingbox.com/fonttest/fontpreview.aspx";
	window.open(page+s,"Font_Preview","height=430,width=500,scrollbars=no,location=no,toolbar=no,menubar=no");
}

function silhouettemodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('silhouettemodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('silhouettemodal').style.display='table-row';
	}
}

function silhouettemodaloff() {
	gEBI('modalbg').style.display='none';
	gEBI('silhouettemodal').style.display='none';
}

function waproofmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('waproofmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('waproofmodal').style.display='table-row';
	}
}

function waproofmodaloff() {
	gEBI('modalbg').style.display='none';
	gEBI('waproofmodal').style.display='none';
}

function waprocessingmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('waprocessingmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('waprocessingmodal').style.display='table-row';
	}
}

function waprocessingmodaloff() {
	gEBI('modalbg').style.display='none';
	gEBI('waprocessingmodal').style.display='none';
}

function processingmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('processingmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('processingmodal').style.display='table-row';
	}
}

function processingmodaloff() {
	gEBI('modalbg').style.display='none';
	gEBI('processingmodal').style.display='none';
}

function envelopemodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('envelopemodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('envelopemodal').style.display='table-row';
	}
}

function envelopemodaloff() {
	gEBI('modalbg').style.display='none';
	gEBI('envelopemodal').style.display='none';
}

function rushmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('rushmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('rushmodal').style.display='table-row';
	}
}

function rushmodaloff() {
	$('#modalbg').hide();
	$('#rushmodal').hide();
}

function printingmethodmodalon() {
	$('#modalbg').show();
	$('#printingmethodmodal').show();
}

function printingmethodmodaloff() {
	$('#modalbg').hide();
	$('#printingmethodmodal').hide();
}

function waprintingmethodmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('waprintingmethodmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('waprintingmethodmodal').style.display='table-row';
	}
}

function waprintingmethodmodaloff() {
	$('#modalbg').hide();
	$('#waprintingmethodmodal').hide();
}

function deliverymodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('shippingmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('shippingmodal').style.display='table-row';
	}
}

function deliverymodaloff() {
	$('#modalbg').hide();
	$('#shippingmodal').hide();
}

function relatedmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('relatedmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('relatedmodal').style.display='table-row';
	}
}

function relatedmodaloff() {
	$('#modalbg').hide();
	$('#relatedmodal').hide();
}

function pricingmodalon() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('modalbg').style.display='block';
		gEBI('pricingmodal').style.display='block';
	} else {
		gEBI('modalbg').style.display='table-row';
		gEBI('pricingmodal').style.display='table-row';
	}
}

function pricingmodaloff() {
	$('#modalbg').hide();
	$('#pricingmodal').hide();
}

function viewallwapricing(form) {
	var s = "?item=" + form['vwname'].value;

	s += (form['digitalquantity']) ? "&digital=" + "wa-" + form['vwpricecode'].value + "-d" : "";
	s += (form['flatquantity']) ? "&flat=" + "wa-" + form['vwpricecode'].value + "-d" : "";
	s += (form['thermographyquantity']) ? "&therm=" + "wa-" + form['vwpricecode'].value + "-d" : "";
	s += (form['engravedquantity']) ? "&engraved=" + "wa-" + form['vwpricecode'].value + "-e" : "";
	s += (form['vwrafree']) ? "&rafree=" + form['vwrafree'].value : "";

	var page = "http://site.invitationbox.com/pricing/waPricing.php";
	window.open(page+s,"View_All_Pricing","height=600,width=500,scrollbars=yes,location=no,toolbar=no,menubar=no");
}

function viewallpricing(form) {
	var s = "?pcode=" + form['vwpricecode'].value

	s += (form['vwwaprintingmethods']) ? "&wamethods=" + form['vwwaprintingmethods'].value : "";
	s += (form['vwasscode']) ? "&acode=" + form['vwasscode'].value : "";
	s += (form['vwracode']) ? "&racode=" + form['vwracode'].value : "";
	s += (form['vwonsale']) ? "&sale=" + form['vwonsale'].value : "";
	s += (form['vwrafree']) ? "&rafree=" + form['vwrafree'].value : "";
	s += (form['vwblankavailable']) ? "&blank=" + form['vwblankavailable'].value : "";
	s += "&item=" + form['vwname'].value;

	var page = "http://site.invitationbox.com/pricing/dynPricing.php";
	window.open(page+s,"View_All_Pricing","height=600,width=500,scrollbars=yes,location=no,toolbar=no,menubar=no");
}

function updateQtyText(si, ddl, idStr) {
	if (si > -1) {
		if(ddl.options[si]) {
			if (si > 0) {
				var price = ddl.options[si].value;
				price = price.substr(price.indexOf('$'), price.lastIndexOf('.')+3 - price.indexOf('$'));
				$(idStr).html(price);
			}	else {
				$(idStr).html('Please Select Quantity Above');
			}
		}
	}
}

function updateDDLItems(selDDL, elId, textId) {
	var ddl = gEBI(elId);
	if (ddl) {
		ddl.selectedIndex = selDDL.selectedIndex; 
		
		if (textId != '') {
			updateQtyText(selDDL.selectedIndex, ddl, textId);
		}
	}
}

function updateblankra() {
	var selObj = gEBI('blankquantity');
	updateDDLItems(selObj, 'raquantity', '#raprice');
	updateDDLItems(selObj, 'assembledquantity', '#assembledprice');
	updateDDLItems(selObj, 'layeredquantity', '#layeredprice');
	updateDDLItems(selObj, 'liningfee', '#liningprice');
	updateDDLItems(selObj, 'frontaddressfee', '#faprice');
	updateDDLItems(selObj, 'ecenvelopequantity', '#eceprice');
	updateDDLItems(selObj, 'ksenvelopequantity', '#kseprice');
}

function updatera() {
	var rbDigPrinted = $('#digitalprinted');
	var rbEngPrinted = $('#engravedprinted');
	var rbFlatPrinted = $('#flatprinted');
	var rbThermPrinted = $('#thermographyprinted');

	if (gEBI('quantity')) {
		var selObj = gEBI('quantity');
	} else if (gEBI('digitalquantity')){
		if(gEBI('digitalprinted').checked) {
			var selObj = gEBI('digitalquantity');
		}
	} else if(gEBI('blankquantity')) {
		var selObj = gEBI('blankquantity');
	}
	
	if (gEBI('thermographyquantity')){
		if(gEBI('thermographyprinted').checked) {
			var selObj = gEBI('thermographyquantity');
		}
	}
	 
	if (gEBI('engravedquantity')){
		if(gEBI('engravedprinted').checked) {
			var selObj = gEBI('engravedquantity');
		}
	}
	 
	if (gEBI('flatquantity')){
		if(gEBI('flatprinted').checked) {
			var selObj = gEBI('flatquantity');
		}
	} 

	updateDDLItems(selObj, 'raquantity', '#raprice');
	updateDDLItems(selObj, 'assembledquantity', '#assembledprice');
	updateDDLItems(selObj, 'layeredquantity', '#layeredprice');
	updateDDLItems(selObj, 'liningfee', '#liningprice');
	updateDDLItems(selObj, 'frontaddressfee', '#faprice');
	updateDDLItems(selObj, 'ecenvelopequantity', '#eceprice');
	updateDDLItems(selObj, 'ksenvelopequantity', '#kseprice');	
}

function updatelayerquantity() {
	var layerObj = gEBI('layeredquantity');	
	
	updateDDLItems(layerObj, 'quantity', '');	
	updateDDLItems(layerObj, 'blankquantity', '');	
	updateDDLItems(layerObj, 'raquantity', '');	
	updateDDLItems(layerObj, 'assembledquantity', '');	
	updateDDLItems(layerObj, 'liningfee', '');	
	updateDDLItems(layerObj, 'frontaddressfee', '');	
	updateDDLItems(layerObj, 'ecenvelopequantity', '');	
	updateDDLItems(layerObj, 'ksenvelopequantity', '');	
}

function updateece() {
	var seleceObj = gEBI('ecenvelopequantity');
	
	updateDDLItems(seleceObj, 'quantity', '');	
	updateDDLItems(seleceObj, 'assembledquantity', '');	
	updateDDLItems(seleceObj, 'liningfee', '');
}

function updatekse() {
	if (gEBI('ksenvelopequantity')){
		var selkseObj = gEBI('ksenvelopequantity');

		updateDDLItems(selkseObj, 'quantity', '');
		updateDDLItems(selkseObj, 'blankquantity', '');
		updateDDLItems(selkseObj, 'liningfee', '');
		updateDDLItems(selkseObj, 'raquantity', '');
	}
}

function updateecequantity() {
	var selObj = gEBI('quantity');

	updateDDLItems(selObj, 'ecenvelopequantity', '');
	updateDDLItems(selObj, 'assembledquantity', '');
	updateDDLItems(selObj, 'liningfee', '');
}

function updateegra(x) {
	var selObj = gEBI(x + 'quantity');
	
	updateDDLItems(selObj, x + 'raquantity', '');	
	updateDDLItems(selObj, x + 'assembledquantity', '');
	updateDDLItems(selObj, x + 'doubleliningfee', '');
	updateDDLItems(selObj, x + 'liningfee', '');
	updateDDLItems(selObj, x + 'twocolor', '');
	updateDDLItems(selObj, x + 'doublesided', '');
}

function ksdisable(){
	elDisable('ksenvelopequantity',true);
}

function ksenable(){
	elDisable('ksenvelopequantity',false);
}

function ecdisable(){
	elDisable('ecenvelopequantity',true);
}

function ecenable(){
	elDisable('ecenvelopequantity',false);
}

function elDisable(elId, disable) {
	gEBI(elId).disabled = disable;
}

function rcpapercheck() {
	var temppapercolor = gEBI('papercolor');
	if (temppapercolor.value == "Ecru"){
		if(gEBI('envlining')){
			gEBI('envlining').style.display = 'none';
		}
		eldisable(1);
	} else {
		if(navigator.appName.indexOf("Microsoft") > -1){
			gEBI('envlining').style.display='block';
		} else {
			gEBI('envlining').style.display='table-row';
		}
		if(gEBI('envelopeliningno').checked == true){
			eldisable(1);
		} else {
			elenable(1);
		}
	}
}

function updatelining() {
	var selLiningObj = gEBI('liningfee');
	
	updateDDLItems(selLiningObj, 'quantity', '');
	updateDDLItems(selLiningObj, 'raquantity', '');
	updateDDLItems(selLiningObj, 'assembledquantity', '');
	updateDDLItems(selLiningObj, 'frontaddressfee', '');
	updateDDLItems(selLiningObj, 'ecenvelopequantity', '');
	updateDDLItems(selLiningObj, 'layeredquantity', '');
}

function dupdatelining() {
	var selDoubleLiningObj = gEBI('doubleliningfee');

	updateDDLItems(selDoubleLiningObj, 'quantity', '');
	updateDDLItems(selDoubleLiningObj, 'raquantity', '');
	updateDDLItems(selDoubleLiningObj, 'assembledquantity', '');
	updateDDLItems(selDoubleLiningObj, 'frontaddressfee', '');
	updateDDLItems(selDoubleLiningObj, 'ecenvelopequantity', '');
	updateDDLItems(selDoubleLiningObj, 'liningfee', '');
	updateDDLItems(selDoubleLiningObj, 'layeredquantity', '');
}

function updateegbalining(x) {
	var selLiningObj = gEBI(x + 'liningfee');

	updateDDLItems(selLiningObj, x + 'quantity', '');
	updateDDLItems(selLiningObj, x + 'raquantity', '');
	updateDDLItems(selLiningObj, x + 'twocolor', '');
	updateDDLItems(selLiningObj, x + 'doublesided', '');
	updateDDLItems(selLiningObj, x + 'doubleliningfee', '');
}

function updateegbadlining(x) {
	var seldLiningObj = gEBI(x + 'doubleliningfee');

	updateDDLItems(seldLiningObj, x + 'quantity', '');
	updateDDLItems(seldLiningObj, x + 'raquantity', '');
	updateDDLItems(seldLiningObj, x + 'liningfee', '');
	updateDDLItems(seldLiningObj, x + 'twocolor', '');
	updateDDLItems(seldLiningObj, x + 'doublesided', '');
}

function checkstyle() {
	if (gEBI('fontstyle1')) {
		var stylepicker = gEBI('fontstyle1')
		for(i=0; i<25; i++){
			if (gEBI('style'+i)){
				var lineObj = gEBI('text'+i);
				var styleObj = gEBI('style'+i);
				if (lineObj.value.length == 0) {
					styleObj.disabled = true;
				} else {
					styleObj.disabled = false;
				}
			}
		}
	}
}

function enablestyle(x) {
	var lineObj = gEBI('text'+x);
	var styleObj = gEBI('style'+x);
	
	if (lineObj.value.length == null) {
   	styleObj.disabled = true;
	} else {
		styleObj.disabled = false;
	}
}

function enableinstyle(x) {
	var lineObj = gEBI('intext'+x);
	var styleObj = gEBI('instyle'+x);
	
	if (lineObj.value.length == null) {
   	styleObj.disabled = true;
	} else {
		styleObj.disabled = false;
	}
}

function updateassra() {
	var selObj = gEBI('quantity');

	updateDDLItems(selAssObj, 'quantity', '');
	updateDDLItems(selAssObj, 'raquantity', '');
	updateDDLItems(selAssObj, 'liningfee', '');
	updateDDLItems(selAssObj, 'frontaddressfee', '');
	updateDDLItems(selAssObj, 'ecenvelopequantity', '');
	updateDDLItems(selAssObj, 'layeredquantity', '');
}

function updatequantity() {
	var selRAObj = gEBI('raquantity');

	updateDDLItems(selRAObj, 'quantity', '');
	updateDDLItems(selRAObj, 'blankquantity', '');
	updateDDLItems(selRAObj, 'liningfee', '');
	updateDDLItems(selRAObj, 'frontaddressfee', '');
	updateDDLItems(selRAObj, 'ecenvelopequantity', '');
	updateDDLItems(selRAObj, 'ksenvelopequantity', '');
	updateDDLItems(selRAObj, 'layeredquantity', '');
}

function updatefaquantity() {
	var faObj = gEBI('frontaddressfee');

	updateDDLItems(faObj, 'quantity', '');
	updateDDLItems(faObj, 'raquantity', '');
	updateDDLItems(faObj, 'liningfee', '');
	updateDDLItems(faObj, 'assembledquantity', '');
	updateDDLItems(faObj, 'layeredquantity', '');
}

function updateegbaquantity(x) {
	var selRAObj = gEBI(x + 'raquantity');

	updateDDLItems(selRAObj, x + 'quantity', '');
	updateDDLItems(selRAObj, x + 'liningfee', '');
	updateDDLItems(selRAObj, x + 'doubleliningfee', '');
	updateDDLItems(selRAObj, x + 'twocolor', '');
	updateDDLItems(selRAObj, x + 'doublesided', '');
}

function updateegbadoublesided(x) {
	var selDoubleSidedObj = gEBI(x + 'doublesided');

	updateDDLItems(selDoubleSidedObj, x + 'quantity', '');
	updateDDLItems(selDoubleSidedObj, x + 'doubleliningfee', '');
	updateDDLItems(selDoubleSidedObj, x + 'liningfee', '');
	updateDDLItems(selDoubleSidedObj, x + 'twocolor', '');
	updateDDLItems(selDoubleSidedObj, x + 'raquantity', '');
}

function updateegbatwocolor(x) {
	var selTwoColorObj = gEBI(x + 'twocolor');

	updateDDLItems(selTwoColorObj, x + 'quantity', '');
	updateDDLItems(selTwoColorObj, x + 'doubleliningfee', '');
	updateDDLItems(selTwoColorObj, x + 'liningfee', '');
	updateDDLItems(selTwoColorObj, x + 'doublesided', '');
	updateDDLItems(selTwoColorObj, x + 'raquantity', '');
}

function checklayer() {
	if (gEBI('layeredcardno')){
		if (gEBI('layeredcardno').checked == true){
			nolayered(1);
		} else {
			addlayered(1);
		}
	}
}

function checkbirch() {
	if (gEBI('verseoptionsblank')){
		if (gEBI('verseoptionsblank').checked == true){
			blankbirch(1);
		}
	}
	if (gEBI('verseoptionspreprinted')){
		if (gEBI('verseoptionspreprinted').checked == true){
			preprintedbirch(1);
		}
	}
	if (gEBI('verseoptionscustom')){
		if (gEBI('verseoptionscustom').checked == true){
			custombirch(1);
		}
	}
}

function logoenable(){
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('logouploadbutton')){
			gEBI('logouploadbutton').style.display='block';
		}
	} else {
		if(gEBI('logouploadbutton')){
			gEBI('logouploadbutton').style.display='table-row';
		}
	}
}

function logodisable(){
	gEBI('logouploadbutton').style.display = 'none';
}

function setBCVerses(disVerse, disFontColor, disVerseText) {
	if (gEBI('verse')) {
		gEBI('verse').disabled = disVerse;
	}
	
	if (gEBI('fontcolor1')) {
		gEBI('fontcolor1').disabled = disFontColor;
	}
	
	if (gEBI('Versestext01')) {
		gEBI('Versestext01').disabled = disVerseText;
		gEBI('Versestext02').disabled = disVerseText;
		gEBI('Versestext03').disabled = disVerseText;
		gEBI('Versestext04').disabled = disVerseText;
		gEBI('Versestext05').disabled = disVerseText;
		gEBI('Versestext06').disabled = disVerseText;
	}	
}

function blankbirch(){
	setBCVerses(true, ((gEBI('fontcolor1') && !gEBI('printedprinted').checked)?true:false), true);	
	
	if (gEBI('verseslinescontainer')) {
		gEBI('verseslinescontainer').style.display = 'none';
	}
}

function preprintedbirch(){
	setBCVerses(false, false, true);
	
	if (gEBI('verseslinescontainer')) {
		gEBI('verseslinescontainer').style.display = 'none';
	}	
}

function custombirch(){
	setBCVerses(true, false, false);
	
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('verseslinescontainer')){
			gEBI('verseslinescontainer').style.display='block';
		}
	} else {
		if(gEBI('verseslinescontainer')){
			gEBI('verseslinescontainer').style.display='table-row';
		}
	}
}

function updaterafont() {
	updateDDLItems(gEBI('fontstyle1'), 'rafont', '');
}

function updatepersfont() {
	updateDDLItems(gEBI('rafont'), 'fontstyle1', '');
}

function updateassquantity() {
	var selRAObj = gEBI('raquantity');
	updateDDLItems(selRAObj, 'quantity', '');
	updateDDLItems(selRAObj, 'assembledquantity', '');
	updateDDLItems(selRAObj, 'liningfee', '');	
}

function hideproofwarning() {
	if(gEBI('proofnowarning')){
		gEBI('proofnowarning').style.display='none';
	}
}

function proofwarning() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('proofnowarning').style.display='block';
	} else {
		gEBI('proofnowarning').style.display='table-row';
	}
}

function rashow() {
	gEBI('ra').style.display='';
}

function raoptionsshow() {
	gEBI('raoptions').style.display='';
}

function rahide() {
	gEBI('ra').style.display='none';
}

function raoptionshide() {
	/*gEBI('raoptions').style.display='none';*/
}

function assemblyhide() {
	assemblypricing.style.display='none';
}

function radisable() {
	if(gEBI('raoptions')){
		gEBI('raoptions').style.display='none';
	}
	
	disableContentByName("RA Quantity",true);
	disableContentByName("RA Font",true);
	disableContentByName("RA Font Color",true);
	disableContentByName("RA Line 01",true);
	disableContentByName("RA Line 02",true);
	disableContentByName("RA Line 03",true);
}

function egbaradisable(x) {
	disableContent(x + "raquantity",true);
	disableContent(x + "rafont",true);
	disableContent(x + "raline01",true);
	disableContent(x + "raline02",true);
	disableContent(x + "raline03",true);
}

function egbadsdisable(x) {
	disableContent(x + "doublesided",true);
}

function egbatcdisable(x) {
	disableContent(x + "twocolor",true);
	disableContent(x + "secondfontcolor",true);
}

function nooptionsdisable() {
	disableContentByName("Name",true);
	disableContentByName("Date",true);
	disableContentByName("Personalization Line 01",true);
	disableContentByName("Personalization Line 02",true);
	disableContentByName("Personalization Line 03",true);	
}

function nooptionsenable() {
	disableContentByName("Name",false);
	disableContentByName("Date",false);
	disableContentByName("Personalization Line 01",false);
	disableContentByName("Personalization Line 02",false);
	disableContentByName("Personalization Line 03",false);	
}

function nolayered() {
	if(gEBI('layeredoptions')){
		gEBI('layeredoptions').style.display='none';

		disableContentByName("Layered Card Color",true);
		disableContentByName("Layered Quantity",true);		
	}
}

function eldisable() {

	if(gEBI('envliningoptions')){
		gEBI('envliningoptions').style.display='none';

		disableContentByName("Lining Color",true);
		disableContentByName("Lining Fee",true);
		disableContentByName("Lining Paper Color",true);
	}
}

function deldisable() {
	if(gEBI('doubleenvliningoptions')){
		gEBI('doubleenvliningoptions').style.display='none';

		disableContentByName("Double Lining Color",true);
		disableContentByName("Double Lining Fee",true);
		disableContentByName("Double Lining Paper Color",true);
	}
}

function fadisable() {
	if(gEBI('frontaddressoptions')){
		gEBI('frontaddressoptions').style.display='none';
	}

	disableContentByName("Front Address Quantity",true);
	disableContentByName("Front Address Font",true);
	disableContentByName("Front Address Font Color",true);
}

function disableContent(elId, disable) {
	var form=document.forms[1];
	var contlength = form.elements.length;
	
	for(i=0; i<contlength; i++){
		var content = form.elements[i];
		
		if(content.id == elId){
		  content.disabled = disable;
		}
	}
}

function disableContentByName(elName, disable) {
	var form=document.forms[1];
	var contlength = form.elements.length;
	
	for(i=0; i<contlength; i++){
		var content = form.elements[i];
		
		if(content.name == elName){
		  content.disabled = disable;
		}
	}
}	

function egbadeldisable(x) {
	disableContent(x+"doubleliningcolor", true);
	disableContent(x+"doubleliningfee", true);
}

function egbaeldisable(x) {
	disableContent(x+"liningcolor", true)
	disableContent(x+"liningfee", true);
}

function egbadsenable(x) {
	disableContent(x+"doublesided", false);
}

function egbatcenable(x) {
	disableContent(x+"twocolor", false);
	disableContent(x+"secondfontcolor", false);
}

function egbaelenable(x) {
	disableContent(x+"liningcolor", false)
	disableContent(x+"liningfee", false);
}

function egbadelenable(x) {
	disableContent(x+"doubleliningcolor", false);
	disableContent(x+"doubleliningfee", false);
}

function rablock() {
	if (gEBI('ReturnAddressPrintingYes')){
		gEBI('ReturnAddressPrintingYes').disabled = true;
	}
	if (gEBI('ReturnAddressPrintingNo')){
		gEBI('ReturnAddressPrintingNo').disabled = true;
	}
	if (gEBI('preshipenvelopesyes')) {
		gEBI('preshipenvelopesyes').disabled = true;
	}
	if (gEBI('preshipenvelopesno')) {
		gEBI('preshipenvelopesno').disabled = true;
	}
}

function raunblock() {
	if (gEBI('ReturnAddressPrintingYes')){
		gEBI('ReturnAddressPrintingYes').disabled = false;
	}
	if (gEBI('ReturnAddressPrintingNo')){
		gEBI('ReturnAddressPrintingNo').disabled = false;
	}
	if (gEBI('preshipenvelopesyes')) {
		gEBI('preshipenvelopesyes').disabled = false;
	}
	if (gEBI('preshipenvelopesno')) {
		gEBI('preshipenvelopesno').disabled = false;
	}
}

function raenable() {
	gEBI('raoptions').style.display='block';

	disableContentByName("RA Quantity", false);
	disableContentByName("RA Font", false);
	disableContentByName("RA Font Color", false);
	disableContentByName("RA Line 01", false);
	disableContentByName("RA Line 02", false);
	disableContentByName("RA Line 03", false);
}

function egbaraenable(x) {
	disableContent(x + "raquantity", false);
	disableContent(x + "rafont", false);
	disableContent(x + "raline01", false);
	disableContent(x + "raline02", false);
	disableContent(x + "raline03", false);
}

function egbashowenable(x,cardtype) {
	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI(x).style.display='block';
	} else {
		gEBI(x).style.display='table-row';
	}
	var form=document.forms[1];
	var contlength = form.elements.length;

	for(i=0; i<contlength; i++) {
		var content = form.elements[i];
		if(content.id.indexOf(x) == 0){
			content.disabled = false;
		}
	}
}

function egbahidedisable(x,cardtype) {
	var form=document.forms[1];
	var contlength = form.elements.length;
	gEBI(x).style.display='none';
	for(i=0; i<contlength; i++){
		var content = form.elements[i];
		if(content.id.indexOf(x) == 0){
			content.disabled = true;
		}
	}
}

function delenable() {
	
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('doubleenvliningoptions')){
			gEBI('doubleenvliningoptions').style.display='block';
		}	
	} else {
		if(gEBI('doubleenvliningoptions')){
			gEBI('doubleenvliningoptions').style.display='table-row';
		}
	}
	
	disableContentByName("Double Lining Color",false);
	disableContentByName("Double Lining Fee",false);
	disableContentByName("Double Lining Paper Color",false);
}

function addlayered() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('layeredoptions')){
			gEBI('layeredoptions').style.display='block';
		}	
	} else {
		if(gEBI('layeredoptions')){
			gEBI('layeredoptions').style.display='table-row';
		}
	}

	disableContentByName("Layered Card Color",false);
	disableContentByName("Layered Quantity",false);
}

function elenable() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('envliningoptions')){
			if(gEBI('vendor').value!="wa"){
				gEBI('envliningoptions').style.display='block';
			}
		}	
	} else {
		if(gEBI('envliningoptions')){
			if(gEBI('vendor').value!="wa"){
				gEBI('envliningoptions').style.display='table-row';
			}
		}
	}

	disableContentByName("Lining Color",false);
	disableContentByName("Lining Fee",false);
	disableContentByName("Lining Paper Color",false);
}

function faenable() {
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('frontaddressoptions')){
			gEBI('frontaddressoptions').style.display='block';
		}
	} else {
		if(gEBI('frontaddressoptions')){
			gEBI('frontaddressoptions').style.display='table-row';
		}
	}
	
	disableContentByName("Front Address Quantity",false);
	disableContentByName("Front Address Font",false);
	disableContentByName("Front Address Font Color",false);
}

function racheck() {
	var raObj;
	if(gEBI('ReturnAddressPrintingYes')){
		raObj = gEBI('ReturnAddressPrintingYes');
	}	else {
		raObj = "0"
	}
	
	if(raObj.checked == true){
		raenable(1);
	}	else {
		radisable(1);
	}
}

function elcheck() {
	if(gEBI('envelopeliningno')){
		var elObj = gEBI('envelopeliningno');
		if(elObj.checked == true){
		   eldisable(1);
		} else {
		   elenable(1);
		}
	}
}

function delcheck() {
	if(gEBI('doubleenvelopeliningno')){
		var elObj = gEBI('doubleenvelopeliningno');
		if(elObj.checked == true){
		   deldisable(1);
		} else {
		   delenable(1);
		}
	}
}

function printingenable() {
	var form = document.forms[1];
	var contlength = form.elements.length;
	
	raunblock(1);
	delcheck(1)
	elcheck(1);
	
	if(gEBI('frontaddressyes')){
		if(gEBI('frontaddressyes').checked == true){
			faenable(1);
		} else {
			fadisable(1);
		}
	}
	
	if(gEBI('assembledyes')){
		if(gEBI('assembledyes').checked == true){
			gEBI('assembledquantity').disabled = false;
		} else {
			gEBI('assembledquantity').disabled = true;
		}
	}
	
	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('printing')){ 
			gEBI('printing').style.display='block';
		}
		if(gEBI('outerassemblycontainer')){
			gEBI('outerassemblycontainer').style.display = 'block';
		}
		if(gEBI('outerspecialinstructionscontainer')){
			gEBI('outerspecialinstructionscontainer').style.display = 'block';
		}
		if(gEBI('bcprinting')){ 
			if(gEBI('outerloweroptioncontainer')){gEBI('outerloweroptioncontainer').style.display='block';}
			if(gEBI('outerlowerwordingcontainer')){gEBI('outerlowerwordingcontainer').style.display='block';}
			if(gEBI('outerlogocontainer')){gEBI('outerlogocontainer').style.display='block';}
		} 
		if(gEBI('proofoptions')){
			gEBI('proofoptions').style.display='block';
		}
		if(!gEBI('outerrushcontainer')){
			if(gEBI('orderprocessing')){
				gEBI('orderprocessing').style.display = 'block';
			}
		}
		if (gEBI('verseoptionsblank')){
			if (gEBI('verseoptionsblank').checked = true){
				if (gEBI('fontcolor1') && !gEBI('printedprinted').checked) {
					gEBI('fontcolor1').disabled = true;
				} else if(gEBI('fontcolor1') && gEBI('printedprinted').checked){
					gEBI('fontcolor1').disabled = false;
				}
			} else {
				if (gEBI('fontcolor1')){
					gEBI('fontcolor1').disabled = false;
				}
			}
		}
		if(gEBI('proofoutercontainer')){
			gEBI('proofoutercontainer').style.display='block';
		}
		if (gEBI('ra')){
			gEBI('ra').style.display='block';
		}
		if (gEBI('envelopes')){
			gEBI('envelopes').style.display='block';
		}
		if(gEBI('permission')){
			gEBI('permission').style.display='block';
		}
		if(gEBI('frontaddressprinting')){
			gEBI('frontaddressprinting').style.display='block';
		}
	} else {
		if(gEBI('printing')){
			gEBI('printing').style.display='table-row';
		}
		if(gEBI('bcprinting')){ 
			if(gEBI('outerloweroptioncontainer')){gEBI('outerloweroptioncontainer').style.display='table-row';}
			if(gEBI('outerlowerwordingcontainer')){gEBI('outerlowerwordingcontainer').style.display='table-row';}
			if(gEBI('outerlogocontainer')){gEBI('outerlogocontainer').style.display='table-row';}
		} 
		if(!gEBI('outerrushcontainer')){
			if(gEBI('orderprocessing')){
				gEBI('orderprocessing').style.display = 'table-row';
			}
		}
		if(gEBI('outerassemblycontainer')){
			gEBI('outerassemblycontainer').style.display = 'table-row';
			}
		if(gEBI('outerspecialinstructionscontainer')){
			gEBI('outerspecialinstructionscontainer').style.display = 'table-row';
				}
		if(gEBI('permission')){
			gEBI('permission').style.display='table-row';
		}
		if(gEBI('frontaddressprinting')){
			gEBI('frontaddressprinting').style.display='table-row';
		}
		if(gEBI('proofoptions')){
			gEBI('proofoptions').style.display='table-row';
			if(gEBI('proofoutercontainer')){
				gEBI('proofoutercontainer').style.display='table-row';
			}
		}
		if (gEBI('ra')){
			gEBI('ra').style.display='table-row';
		}
		if (gEBI('envelopes')){
			gEBI('envelopes').style.display='table-row';
		}
	}
	if(gEBI('proofyes')){
		gEBI('proofyes').disabled = false;
	}
	if(gEBI('proofno')){
		gEBI('proofno').disabled = false;
	}
	if(gEBI('formattingyes')){
		gEBI('formattingyes').disabled = false;
		gEBI('formattingno').disabled = false;
	}
	if(gEBI('frontaddressyes')){
		gEBI('frontaddressyes').disabled = false;
		gEBI('frontaddressno').disabled = false;
	}
	if(gEBI('ReturnAddressPrintingYes')){
		if(gEBI('ReturnAddressPrintingYes').checked == true){
			raenable(1);
		}
	}
	for(i=0; i<contlength; i++){
		var content = form.elements[i];
		if(content.name=="Font" || content.name=="Font Style 1" || content.name=="Font Style 2" || content.name=="Font Color" || content.name=="Font Color 1" || content.name=="Font Color 2" || content.name=="Orientation" || content.name=="Personalization Line 01" || content.name=="Personalization Line 02" || content.name=="Personalization Line 03" || content.name=="Personalization Line 04" || content.name=="Personalization Line 05" || content.name=="Line 01" || content.name=="Line 02" || content.name=="Line 03" || content.name=="Line 04" || content.name=="Line 05" || content.name=="Line 06" || content.name=="Line 07" || content.name=="Line 08" || content.name=="Line 09" || content.name=="Line 10" || content.name=="Line 11" || content.name=="Line 12" || content.name=="Line 13" || content.name=="Line 14" || content.name=="Line 15" || content.name=="Line 16" || content.name=="Line 17" || content.name=="Line 18" || content.name=="Line 19" || content.name=="Line 20" || content.name=="Inside Line 01" || content.name=="Inside Line 02" || content.name=="Inside Line 03" || content.name=="Inside Line 04" || content.name=="Inside Line 05" || content.name=="Inside Line 06" || content.name=="Inside Line 07" || content.name=="Inside Line 08" || content.name=="Inside Line 09" || content.name=="Inside Line 10" || content.name=="Inside Line 11" || content.name=="Inside Line 12" || content.name=="Inside Line 13" || content.name=="Inside Line 14" || content.name=="Inside Line 15" || content.name=="Inside Line 16" || content.name=="Inside Line 17" || content.name=="Inside Line 18" || content.name=="Inside Line 19" || content.name=="Inside Line 20" || content.name=="Photo color" || content.name=="Greeting Font Color"  || content.name=="Greeting Font"  || content.name=="Greeting"  || content.name=="Personalization Font" || content.name=="Front Address Quantity" || content.id=="quantity" || content.id=="assembledno" || content.id=="assembledyes" || content.name=="02 - Proof" || content.name=="03 - Printed Quantity - Assembled on Your Own"){
			   content.disabled = false;
		}
		else if(content.name=="00 - Blank Quantity"){
			   content.disabled = true;
		} else if(content.name=="RA Printing"){
			content.disabled = false;
			racheck(1);
		}
	}
	
	if(gEBI('ReturnAddressPrintingBSPYes')){
		if(gEBI('ReturnAddressPrintingBSPYes').checked == true){
			 raenable(1);
		} else {
			radisable(1);
		}
	}
}

function waoffon(){
	var rbDigPrinted = $('#digitalprinted');
	var rbEngPrinted = $('#engravedprinted');
	var rbFlatPrinted = $('#flatprinted');
	var rbThermPrinted = $('#thermographyprinted');
	if (gEBI('digitalprinted')) {
		if (rbDigPrinted[0].checked){			
			$('#digitalquantity').removeAttr("disabled");
			
			if (rbEngPrinted) {
				$('#engravedquantity').attr("disabled","disabled");
			}
			if (rbFlatPrinted){	
				$('#flatquantity').attr("disabled","disabled");
			}
			if (rbThermPrinted){		
				$('#thermographyquantity').attr("disabled","disabled");
			}
		}
	} 
	if (gEBI('engravedprinted')){
		if(gEBI('engravedprinted').checked){
			$('#engravedquantity').removeAttr("disabled");
			if (rbDigPrinted){		
				$('#digitalquantity').attr("disabled","disabled");
			}
			if (rbFlatPrinted){	
				$('#flatquantity').attr("disabled","disabled");
			}
			if (gEBI('thermographyprinted')){		
				gEBI('thermographyquantity').disabled = true;
			}
		}
	} 	
	if (gEBI('flatprinted')){
		if (rbFlatPrinted[0].checked){
			$('#flatquantity').removeAttr("disabled");
			if (rbDigPrinted){		
				$('#digitalquantity').attr("disabled","disabled");
			}
			if (rbEngPrinted){	
				$('#engravedquantity').attr("disabled","disabled");
			}
			if (rbThermPrinted){		
				$('#thermographyquantity').attr("disabled","disabled");
			}
		}
	} 	
	
	if (gEBI('thermographyprinted')){
		if(rbThermPrinted[0].checked){
			$('#thermographyquantity').removeAttr("disabled");
			if (rbDigPrinted){		
				$('#digitalquantity').attr("disabled","disabled");
			}
			if (rbEngPrinted){	
				$('#engravedquantity').attr("disabled","disabled");
			}
			if (rbFlatPrinted){		
				$('#flatquantity').attr("disabled","disabled");
			}
		}
	} 	
}

function waenable(){
	var rbDigPrinted = $('#digitalprinted');
	var rbEngPrinted = $('#engravedprinted');
	var rbFlatPrinted = $('#flatprinted');
	var rbThermPrinted = $('#thermographyprinted');
	
	if (gEBI('digitalprinted')) {
		if (rbDigPrinted[0].checked){			
			$('#digitalquantity').removeAttr("disabled");
			
			if (gEBI('fontcolor1')){
				populateDDL('fontcolor1',waDigitalFontColors);
			}
			if (gEBI('raquantity')){
				populateDDL('raquantity',waReturnAddress);
			}
			if (gEBI('fontcolor2')){
				populateDDL('fontcolor2',waDigitalFontColors2);
			}
			if (rbEngPrinted) {
				$('#engravedquantity').attr("disabled","disabled");
			}
			if (rbFlatPrinted){	
				$('#flatquantity').attr("disabled","disabled");
			}
			if (rbThermPrinted){		
				$('#thermographyquantity').attr("disabled","disabled");
			}
		}
	} 
	
	if (gEBI('engravedprinted')){
		if(gEBI('engravedprinted').checked){
			$('#engravedquantity').removeAttr("disabled");
			if (gEBI('fontcolor1')){
				populateDDL('fontcolor1',waEngravedFontColors);
			}
			if (gEBI('raquantity')){
				populateDDL('raquantity',waEngravedReturnAddress);
			}
			if (gEBI('fontcolor2')){
				populateDDL('fontcolor2',waEngravedFontColors2);
			}	
			if (rbDigPrinted){		
				$('#digitalquantity').attr("disabled","disabled");
			}
			if (rbFlatPrinted){	
				$('#flatquantity').attr("disabled","disabled");
			}
			if (gEBI('thermographyprinted')){		
				gEBI('thermographyquantity').disabled = true;
			}
		}
	} 	
	
	if (gEBI('flatprinted')){
		if (rbFlatPrinted[0].checked){
			$('#flatquantity').removeAttr("disabled");
			if (gEBI('fontcolor1')){
				populateDDL('fontcolor1',waFlatFontColors);
			}
			if (gEBI('raquantity')){
				populateDDL('raquantity',waReturnAddress);
			}
			if (gEBI('fontcolor2')){
				populateDDL('fontcolor2',waFlatFontColors2);
			}	
			if (rbDigPrinted){		
				$('#digitalquantity').attr("disabled","disabled");
			}
			if (rbEngPrinted){	
				$('#engravedquantity').attr("disabled","disabled");
			}
			if (rbThermPrinted){		
				$('#thermographyquantity').attr("disabled","disabled");
			}
		}
	} 	
	
	if (gEBI('thermographyprinted')){
		if(rbThermPrinted[0].checked){
			$('#thermographyquantity').removeAttr("disabled");
			if (gEBI('raquantity')){
				populateDDL('raquantity',waReturnAddress);
			}
			if (gEBI('fontcolor1')){
				populateDDL('fontcolor1',waThermographyFontColors);
			}
			if (gEBI('fontcolor2')){
				populateDDL('fontcolor2',waThermographyFontColors2);
			}
			if (rbDigPrinted){		
				$('#digitalquantity').attr("disabled","disabled");
			}
			if (rbEngPrinted){	
				$('#engravedquantity').attr("disabled","disabled");
			}
			if (rbFlatPrinted){		
				$('#flatquantity').attr("disabled","disabled");
			}
		}
	} 	
	
	printingenable(1);
}

function printingdisable() {
	var form = document.forms[1];
	var contlength = form.elements.length;
	
	if (gEBI('ReturnAddressPrintingBSPYes')){
		if (gEBI('ReturnAddressPrintingBSPYes').checked == true){
			racheck(1);
		} 
	} else {
		rablock(1);
		radisable(1);
		if (gEBI('ra')){
			gEBI('ra').style.display='none';
		}
	}
	
	eldisable(1);
	fadisable(1);
	
	if (gEBI('verseoptionsblank')){
		if (gEBI('verseoptionsblank').checked){
			if (gEBI('fontcolor1') && !gEBI('printedprinted').checked) {
				gEBI('fontcolor1').disabled = true;
			} else if(gEBI('fontcolor1') && gEBI('printedprinted').checked){
				gEBI('fontcolor1').disabled = false;
			}
		}
	}
	
	if(gEBI('outerassemblycontainer')){
		gEBI('outerassemblycontainer').style.display = 'none';
	}
	
	if(gEBI('outerspecialinstructionscontainer')){
		gEBI('outerspecialinstructionscontainer').style.display = 'none';
	}
	
	if(gEBI('envlining')){
		gEBI('envlining').style.display = 'none';
	}
	
	if(gEBI('envelopes')){
		if (gEBI('ReturnAddressPrintingBSPYes')){
		} else {
			gEBI('envelopes').style.display = 'none';
		}
	}
	
	if(gEBI('proof')){
		gEBI('proof').disabled = true;
	}
	
	if(gEBI('proofoutercontainer')){
		gEBI('proofoutercontainer').style.display='none';
	}
	
	if(!gEBI('outerrushcontainer')){
		if(gEBI('orderprocessing')){
			gEBI('orderprocessing').style.display = 'none';
		}
	}
	
	if(gEBI('printing')){
		gEBI('printing').style.display='none';
	} else if(gEBI('bcprinting')){
			if(gEBI('outerloweroptioncontainer')){gEBI('outerloweroptioncontainer').style.display='none';}
			if(gEBI('outerlowerwordingcontainer')){gEBI('outerlowerwordingcontainer').style.display='none';}
			if(gEBI('outerlogocontainer')){gEBI('outerlogocontainer').style.display='none';}
	}
	
	if(gEBI('permission')){
		gEBI('permission').style.display='none';
	}
	
	if(gEBI('proofoptions')){
		gEBI('proofoptions').style.display='none';
	}
	
	if(gEBI('frontaddressprinting')){
		if (gEBI('ReturnAddressPrintingBSPYes')){
		} else {
			gEBI('frontaddressprinting').style.display='none';
		}
	}
	
	if(gEBI('formattingyes')){
		gEBI('formattingyes').disabled = true;
		gEBI('formattingno').disabled = true;
	}
	
	if(gEBI('frontaddressyes')){
		if (gEBI('ReturnAddressPrintingBSPYes')){
			gEBI('frontaddressyes').disabled = false;
			gEBI('frontaddressno').disabled = false;
		} else {
			gEBI('frontaddressyes').disabled = true;
			gEBI('frontaddressno').disabled = true;
		}
	}
	
	for(i=0; i<contlength; i++) {
		var content = form.elements[i];
		if(content.name=="Font" || content.name=="Font Style 1" || content.name=="Font Style 2" || content.name=="Font Color" || content.name=="Font Color 1" || content.name=="Font Color 2" || content.name=="Orientation" || content.name=="Personalization Line 01" || content.name=="Personalization Line 02" || content.name=="Personalization Line 03" || content.name=="Personalization Line 04" || content.name=="Personalization Line 05" || content.name=="Line 01" || content.name=="Line 02" || content.name=="Line 03" || content.name=="Line 04" || content.name=="Line 05" || content.name=="Line 06" || content.name=="Line 07" || content.name=="Line 08" || content.name=="Line 09" || content.name=="Line 10" || content.name=="Line 11" || content.name=="Line 12" || content.name=="Line 13" || content.name=="Line 14" || content.name=="Line 15" || content.name=="Line 16" || content.name=="Line 17" || content.name=="Line 18" || content.name=="Line 19" || content.name=="Line 20" || content.name=="Inside Line 01" || content.name=="Inside Line 02" || content.name=="Inside Line 03" || content.name=="Inside Line 04" || content.name=="Inside Line 05" || content.name=="Inside Line 06" || content.name=="Inside Line 07" || content.name=="Inside Line 08" || content.name=="Inside Line 09" || content.name=="Inside Line 10" || content.name=="Inside Line 11" || content.name=="Inside Line 12" || content.name=="Inside Line 13" || content.name=="Inside Line 14" || content.name=="Inside Line 15" || content.name=="Inside Line 16" || content.name=="Inside Line 17" || content.name=="Inside Line 18" || content.name=="Inside Line 19" || content.name=="Inside Line 20" || content.name=="Photo Color" || content.name=="Greeting Font Color"  || content.name=="Greeting Font"  || content.name=="Greeting" || content.name=="Personalization Font" || content.name=="Front Address Quantity" || content.name=="00 - Quantity" || content.id=="assembledno" || content.id=="assembledyes" || content.name=="03 - Assembled Quantity" || content.name=="03 - Printed Quantity - Assembled on Your Own" || content.name=="02 - Proof"){
			content.disabled = true;
		} else if(content.name=="00 - Blank Quantity"){
			content.disabled = false;
		}
	}
	
	if(gEBI('ReturnAddressPrintingBSPYes')){
		if(gEBI('ReturnAddressPrintingBSPYes').checked == true){
			raenable(1);
		} else {
			radisable(1);
		}
	}
}

function assemblydisable() {
	if(gEBI('assembledquantity')){
		gEBI('assembledquantity').disabled = true;
	}
}

function assemblyenable() {
	if(gEBI('assembledquantity')){
		gEBI('assembledquantity').disabled = false;
	}
}

function printingCheck() {
	var counter = 0;
	var counter2 = 0;
	if(gEBI('blankblank')){
		if(gEBI('blankblank').checked == true){
			 printingdisable(1);
			 eldisable(1);
			 counter = counter + 1;
		}
		counter2 = counter2 +1;
	}
	
	if(gEBI('printedprinted')) {
		if(gEBI('printedprinted').checked == true) {
			printingenable(1);
			if(gEBI('ReturnAddressPrintingYes')) {
				if(gEBI('ReturnAddressPrintingYes').checked == true) {
				 	raenable(1);
				}
			}
		 	counter = counter + 1;
	   }
	   counter2 = counter2 +1;
	}
	
	if(gEBI('digitalprinted')){
		if(gEBI('digitalprinted').checked == true){
			waoffon(1);
			if(gEBI('ReturnAddressPrintingYes')){
				if(gEBI('ReturnAddressPrintingYes').checked == true){
					raenable(1);
				}
			}
		 	counter = counter + 1;
		}
		counter2 = counter2 +1;
	}
	
	if(gEBI('thermographyprinted')){
		if(gEBI('thermographyprinted').checked == true){
			waoffon(1);
			if(gEBI('ReturnAddressPrintingYes')){
				if(gEBI('ReturnAddressPrintingYes').checked == true){
					raenable(1);
				}
			}
		 	counter = counter + 1;
	  }
	  counter2 = counter2 +1;
	}
	if(gEBI('engravedprinted')){
		if(gEBI('engravedprinted').checked == true){
			waoffon(1);
			if(gEBI('ReturnAddressPrintingYes')){
				if(gEBI('ReturnAddressPrintingYes').checked == true){
					raenable(1);
				}
			}
		 	counter = counter + 1;
	  }
	  counter2 = counter2 +1;
	}
		 
	if(counter == 0){
		if(gEBI('printedprinted')){
			gEBI('printedprinted').checked = true;
			printingenable(1);
			eldisable(1);
		} else if(gEBI('blankblank')){ 
			gEBI('blankblank').checked = true;
			printingdisable(1);
		} else if(gEBI('digitalprinted')){ 
			gEBI('digitalprinted').checked = true;
			waenable(1);
		} else if(gEBI('thermographyprinted')){ 
			gEBI('thermographyprinted').checked = true;
			waenable(1);
		} else if(gEBI('engravedprinted')){ 
			gEBI('engravedprinted').checked = true;
			waenable(1);
		}						
			 				
		if(gEBI('ReturnAddressPrintingYes')){
			if(gEBI('ReturnAddressPrintingYes').checked == true){
				raenable(1);
			}
		}
	}

	if(counter2 == 0){
		if(gEBI('printedprinted')){ 
			printingenable(1);
			if(gEBI('ReturnAddressPrintingYes')){
				if(gEBI('ReturnAddressPrintingYes').checked == true){
					raenable(1);
		 		}
		 	}
		}
	}

	if(gEBI('ReturnAddressPrintingBSPYes')){
		if(gEBI('ReturnAddressPrintingBSPYes').checked == true){
			 raenable(1);
		} else {
			radisable(1);
		}
	}	
}

function detailstabselect() {
	gEBI('details-tab-header').style.display='none';
	gEBI('shipping-tab-header-selected').style.display='none';
	gEBI('shipping-tab').style.display='none';
	
	if(gEBI('pricing-tab-header-selected')) {
		gEBI('pricing-tab-header-selected').style.display='none';
	}
	
	if(gEBI('pricing-tab-sale-header-selected')){
		gEBI('pricing-tab-sale-header-selected').style.display='none';
	}
	
	if(gEBI('pricing-tab-header-selected')){
		gEBI('pricing-tab-header-selected').style.display='none';
	}
	
	if(gEBI('related-items-tab-header-selected')){
		gEBI('related-items-tab-header-selected').style.display='none';
	}

	if(gEBI('pricing-tab')){
		gEBI('pricing-tab').style.display='none';
	}
	
	if(gEBI('related-items-tab')){
		gEBI('related-items-tab').style.display='none';
	}

	if(navigator.appName.indexOf("Microsoft") > -1){
		gEBI('details-tab-header-selected').style.display='block';
		gEBI('shipping-tab-header').style.display='block';
		gEBI('details-tab').style.display='block';
	
		if(gEBI('pricing-tab-header')){
			gEBI('pricing-tab-header').style.display='block';
		}

		if(gEBI('pricing-tab-sale-header')){
			gEBI('pricing-tab-sale-header').style.display='block';
		}

		if(gEBI('related-items-tab-header')){	
			gEBI('related-items-tab-header').style.display='block';
		}
	} else {
		gEBI('details-tab-header-selected').style.display='table-row';
		gEBI('shipping-tab-header').style.display='table-row';
		gEBI('details-tab').style.display='table-row';
		
		if(gEBI('pricing-tab-header')){
			gEBI('pricing-tab-header').style.display='table-row';
		}
		
		if(gEBI('pricing-tab-sale-header')){
			gEBI('pricing-tab-sale-header').style.display='table-row';
		}
		
		if(gEBI('related-items-tab-header')){
			gEBI('related-items-tab-header').style.display='table-row';
		}
	}
}

function pricingtabselect() {
	if(gEBI('pricing-tab-header')){
		gEBI('pricing-tab-header').style.display='none';
	}
	
	if(gEBI('pricing-tab-sale-header')){
		gEBI('pricing-tab-sale-header').style.display='none';
	}
	
	gEBI('details-tab-header-selected').style.display='none';
	gEBI('shipping-tab-header-selected').style.display='none';
	gEBI('details-tab').style.display='none';
	gEBI('shipping-tab').style.display='none';
	
	if(gEBI('related-items-tab-header-selected')){
		gEBI('related-items-tab-header-selected').style.display='none';
	}

	if(gEBI('related-items-tab')){
		gEBI('related-items-tab').style.display='none';
	}

	if(navigator.appName.indexOf("Microsoft") > -1){
		if(gEBI('pricing-tab-header-selected')){
			gEBI('pricing-tab-header-selected').style.display='block';
		}
		if(gEBI('pricing-tab-sale-header-selected')){
			gEBI('pricing-tab-sale-header-selected').style.display='block';
		}
		gEBI('details-tab-header').style.display='block';
		gEBI('shipping-tab-header').style.display='block';
		if(gEBI('related-items-tab-header')){
			gEBI('related-items-tab-header').style.display='block';
		}
		gEBI('pricing-tab').style.display='block';
		} else {
	if(gEBI('pricing-tab-header-selected')){
		gEBI('pricing-tab-header-selected').style.display='table-row';
	}
	if(gEBI('pricing-tab-sale-header-selected')){
		gEBI('pricing-tab-sale-header-selected').style.display='table-row';
	}
		gEBI('details-tab-header').style.display='table-row';
		gEBI('shipping-tab-header').style.display='table-row';
		if(gEBI('related-items-tab-header')){
			gEBI('related-items-tab-header').style.display='table-row';
		}
		gEBI('pricing-tab').style.display='table-row';
	}
}

function shippingtabselect() {
	gEBI('shipping-tab-header').style.display='none';
	gEBI('details-tab-header-selected').style.display='none';
	if(gEBI('pricing-tab-header-selected')){
		gEBI('pricing-tab-header-selected').style.display='none';
	}
	if(gEBI('pricing-tab-sale-header-selected')){
		gEBI('pricing-tab-sale-header-selected').style.display='none';
	}
	if(gEBI('related-items-tab-header-selected')){
		gEBI('related-items-tab-header-selected').style.display='none';
	}
	gEBI('details-tab').style.display='none';
	if(gEBI('pricing-tab')){
		gEBI('pricing-tab').style.display='none';
	}
	if(gEBI('related-items-tab')){
		gEBI('related-items-tab').style.display='none';
	}
if(navigator.appName.indexOf("Microsoft") > -1){
	gEBI('shipping-tab-header-selected').style.display='block';
	gEBI('details-tab-header').style.display='block';
	if(gEBI('pricing-tab-header')){
		gEBI('pricing-tab-header').style.display='block';
	}
	if(gEBI('pricing-tab-sale-header')){
		gEBI('pricing-tab-sale-header').style.display='block';
	}
	if(gEBI('related-items-tab-header')){
		gEBI('related-items-tab-header').style.display='block';
	}
	gEBI('shipping-tab').style.display='block';
	} else {
	gEBI('shipping-tab-header-selected').style.display='table-row';
	gEBI('details-tab-header').style.display='table-row';
	if(gEBI('pricing-tab-header')){
		gEBI('pricing-tab-header').style.display='table-row';
	}
	if(gEBI('pricing-tab-sale-header')){
		gEBI('pricing-tab-sale-header').style.display='table-row';
	}
	if(gEBI('related-items-tab-header')){
		gEBI('related-items-tab-header').style.display='table-row';
	}
	gEBI('shipping-tab').style.display='table-row';
	}
}

function relateditemstabselect() {
	gEBI('related-items-tab-header').style.display='none';
	gEBI('details-tab-header-selected').style.display='none';
	if(gEBI('pricing-tab-header-selected')){
		gEBI('pricing-tab-header-selected').style.display='none';
	}
	if(gEBI('pricing-tab-sale-header-selected')){
		gEBI('pricing-tab-sale-header-selected').style.display='none';
	}
	gEBI('shipping-tab-header-selected').style.display='none';
	gEBI('details-tab').style.display='none';
	if(gEBI('pricing-tab')){
		gEBI('pricing-tab').style.display='none';
	}
	gEBI('shipping-tab').style.display='none';
if(navigator.appName.indexOf("Microsoft") > -1){
	gEBI('related-items-tab-header-selected').style.display='block';
	gEBI('details-tab-header').style.display='block';
	if(gEBI('pricing-tab-header')){
		gEBI('pricing-tab-header').style.display='block';
	}

	if(gEBI('pricing-tab-sale-header')){
		gEBI('pricing-tab-sale-header').style.display='block';
	}
	gEBI('shipping-tab-header').style.display='block';
	gEBI('related-items-tab').style.display='block';
	} else {
	gEBI('related-items-tab-header-selected').style.display='table-row';
	gEBI('details-tab-header').style.display='table-row';
	if(gEBI('pricing-tab-header')){
		gEBI('pricing-tab-header').style.display='table-row';
	}
	if(gEBI('pricing-tab-sale-header')){
		gEBI('pricing-tab-sale-header').style.display='table-row';
	}
	gEBI('shipping-tab-header').style.display='table-row';
	gEBI('related-items-tab').style.display='table-row';
	}
}

var templateType=null;

function ordercheck() {
	printingCheck();
	if(gEBI('blankblank')){
		if(gEBI('blankblank').checked == true){
			updateblankra(1);
		} else {
			updatera(1);
		} 
	} else {
		updatera(1);
	} 
	delcheck(1);
	elcheck(1);
	checkbirch(1);
	checklayer(1);
	if(gEBI('logouploadbutton')){
		if(gEBI('logoyes').checked == true){
			logoenable(1);
		} else {
			logodisable(1);
		}
	}
	if(gEBI('enclosurecardenvelopesyes')){
		if(gEBI('enclosurecardenvelopesyes').checked == true){
			ecenable(1);
		} else {
			ecdisable(1);
		}
	}
	if(gEBI('kwiksealenvelopesyes')){
		if(gEBI('kwiksealenvelopesyes').checked == true){
			ksenable(1);
		} else {
			ksdisable(1);
		}
	}
	checkstyle(1);
	if(gEBI('frontaddressyes')){
		if(gEBI('frontaddressyes').checked == true){
			faenable(1);
		} else {
			fadisable(1);
		}
	}
	if(gEBI('90no')){
		for(y=90; y<99; y++){
			if(gEBI(y+'no')){
				if(gEBI(y+'no').checked == true){
					egbahidedisable(y-90);
				}
			}
		}
	}
	if(gEBI('assembledno')){
		if(gEBI('assembledno').checked == true){
			 assemblydisable(1);
		}
		else {
			assemblyenable(1);
		}
	}
	if(gEBI('ReturnAddressPrintingYes')){
		if(gEBI('ReturnAddressPrintingYes').checked == true){
			 raenable(1);
		}
		else {
			radisable(1);
		}
	}
	
	if(gEBI('proofyes')){
		 if(gEBI('proofyes').checked == true ){
			 hideproofwarning(1);
		 }
	}
}

function isReturnAddressPrinting() {
	var f=gEBI("main_form");
	if (f) {
		els=f.getElementsByTagName("INPUT");

		for (var i=0;i<els.length;i++) {
			x=els[i];
			if (x.type=="radio" && x.name=="RA Printing" && x.value.indexOf("Yes")==0) {				
				if (x.checked) {
					return 1;
				} else {
					return 2;
				}
			}
		};
	}
	return 0;
}

function stringStartWith(x, y) {
	if (x.substring(0, y.length) == y) {
		return true;
	} else {
		return false;
	}
}

function getElementByName(x,tag,name) {
	var els=x.getElementsByTagName(tag);
	
	for (var i=0;i<els.length;i++) {
		if (els[i].name.toLowerCase()==name.toLowerCase()) {
			return els[i];
		}
	}
	
	return null;
}

function processValidation() {
	var x,y,z;
	var els,els1;
  var f=gEBI("main_form");
	var bBlank = false;
	
	if (gEBI('blankblank')) {
		if (gEBI('blankblank').checked) {
			bBlank = true;
		}
	}	
	
	if (f) {
		var ib_custom_printing=0;
		var ib_ra_printing=0;
				
		if(gEBI('formattingyes')){
			var formatcounter=0;
			if(gEBI('formattingyes').checked == true){
				formatcounter = formatcounter + 1;
    	}
	    if(gEBI('formattingno')){
				if(gEBI('formattingno').checked == true){
					formatcounter = formatcounter + 1;
				}
			}
			if(formatcounter == 0){
				alert('Please select a formatting option in the Special Instructions section');
				return false;
			}
		}
		
		els=f.getElementsByTagName("INPUT");

		for (var i=0;i<els.length;i++) {
			x=els[i];
			if (x.type=="radio" && x.name=="IB Printing" && x.value.indexOf("Blank Stock - ") == 0) {
				if (x.checked) {
					ib_custom_printing=2;
				} else {
					ib_custom_printing=1;
				}
			}
			if (x.type=="radio" && x.name=="RA Printing" && x.value.indexOf("Yes")==0) {				
				if (x.checked) {
					ib_ra_printing=1;
				} else {
					ib_ra_printing=2;
				}
			}
		};
		
		var address_printing=getElementByName(f,"SELECT","RA Printing");

		if (address_printing==null) {
			address_printing=getElementByName(f,"SELECT","BG RA Printing");
		}

		var blank_quantity=getElementByName(f,"SELECT","BlankQuantity");

		if (blank_quantity==null) {
			blank_quantity=getElementByName(f,"SELECT","Blank Quantity");
		}
		
		if (blank_quantity==null) {
			blank_quantity=getElementByName(f,"SELECT","00 - Blank Quantity");
		}
		
		var envelop_lining=getElementByName(f,"SELECT","Envelope Lining");
		
		if (envelop_lining==null) {
			envelop_lining=getElementByName(f,"SELECT","Envelope Lining Pricing");
		}
		
		var envelop_lining_color=getElementByName(f,"SELECT","Envelope Lining Color");
		
		if (blank_quantity!=null) {
			if (blank_quantity.selectedIndex>0) {
				if (blank_quantity.selectedIndex==1 && stringStartWith(blank_quantity.options[1].value,"No thanks! -")) {
					
				} else {
					if (bBlank) {
						return true;
					}
				}
			} else {
				if (bBlank) {
					alert('Please select a quantity to order blank.');
					return false;
				}
			}
		}		
		if (gEBI('correctnames')){
			if (gEBI('correctnames').checked == false){
		 		alert('You need to review your online proof and verify that all the names are spelled correctly by checking the box in the review your proof section.');
        return false;				
			}
		}
		if (gEBI('correctdates')){
			if (gEBI('correctdates').checked == false){
		 		alert('You need to review your online proof and verify that all the dates and times are correct by checking the box in the review your proof section.  If you do not have any dates or times, that is fine - but we still need you to check the box to move forward.');
        return false;				
			}
		}
		if (gEBI('correctinfo')){
			if (gEBI('correctinfo').checked == false){
		 		alert('You need to review your online proof and verify that all of the other information in your proof is correct by checking the box in the review your proof section.');
        return false;				
			}
		}
		
		els=f.getElementsByTagName("SELECT");
		
		for (var i=0;i<els.length;i++) {
			y=null;
			x=els[i];
			
			if (x.disabled==false) {
				if (x.name!="BlankQuantity" && x.selectedIndex==0 && (x.options[0].text.toLowerCase() == "choose one:" || x.options[0].text.toLowerCase() == "choose your quantity:") ) {
					if (x.name=="RA Font") {
						if (ib_ra_printing==1 || (address_printing!=null && address_printing.selectedIndex>1)) {
							alert("Please select value for 'Return Address Font'");
							return false;
						} else {
							continue;
						}	 
					}
					
					alert("You have not selected an option for '" + x.name + "'.  Please make a selection to move forward.");
					return false;					
				}				
			}
		}

		var is_disabled_controls=0;
		var is_empty_controls=0;

		var quantity_printing=getElementByName(f,"SELECT","Quantity");
		if (quantity_printing==null) {
			quantity_printing=getElementByName(f,"SELECT","03 - Printed Quantity - Assembled on Your Own");			
		}	

		if (ib_ra_printing!=0 || (ib_ra_printing==0 && address_printing!=null)) {			
			els=f.getElementsByTagName("INPUT");
	
			for (var i=0;i<els.length;i++) {
				x=els[i];
				if (x.type=="text" && x.name.length>7 && x.name.substring(0,8).toLowerCase()=="ra line ") {
					if (x.value!="") {
						is_empty_controls=2;//at least one is valid
						break;
					} else {							
						is_empty_controls=1;//empty
					}
				}
			}
			
			if (ib_ra_printing==0 && address_printing!=null) {
				if (is_empty_controls==2 && address_printing.selectedIndex<2) {
					alert ("You have selected 'No thanks' for return address printing, but you included text for us to custom print in the lines provided.  Please go back and select a quantity for return address printing, or if you would like for us to send you blank envelopes, simply remove the text you entered in the return address lines.");
					return false;
				} else {
					if (is_empty_controls==1  && address_printing.selectedIndex>1) {
						alert ("You have selected 'Yes' for return address printing, but you have not included any text for us to custom print in the lines provided.  Please go back and enter your return address text, or if you would like for us to send you blank envelopes, simply select 'No' for this option");
						return false;
					}					
				}
			} else {
				if (is_empty_controls==2) {
					//non empty
					if (ib_ra_printing==2) {
						alert ("You have selected 'No/Blank' for return address printing, but you included text for us to custom print in the lines provided.  Please go back and select 'Yes' for return address printing, or if you would like for us to send you blank envelopes, simply remove the text you entered in the return address lines.");
						return false;
					}				
				} else {
					if (is_empty_controls==1) {
						if (ib_ra_printing==1) {
							alert ("You have selected 'Yes' for return address printing, but you have not included any text for us to custom print in the lines provided.  Please go back and enter your return address text, or if you would like for us to send you blank envelopes, simply select the 'No/Blank' radio button in the return address printing options section.");
							return false;
						}	
					}
				}
			}
		}

		z=2;

		if (ib_custom_printing==1 || ib_custom_printing==0) {
			els=f.getElementsByTagName("INPUT");
		
			for (var i=0;i<els.length;i++) {
				x=els[i];
				if (x.type=="text" && (x.name=="Text" || stringStartWith(x.name.toLowerCase(),"line ") || stringStartWith(x.name.toLowerCase(),"personalization line ") || stringStartWith(x.name.toLowerCase(),"family name") || stringStartWith(x.name.toLowerCase(),"name:") || stringStartWith(x.name.toLowerCase(),"name 01"))) {
					if (x.disabled==false) {
						if (x.value!="") {
							z=2;
							break;
						} else {
							z=0;
						}
					} 				
				}
			}
			
			if (z==0) {
				if (ib_custom_printing==0) {	
					if (quantity_printing==null) {
						alert("You have not included the text you would like for us to custom print on your order.   Please go back and enter the customization info so that we can process the order.");
					}	else {
						alert("You have not included any text for us to custom print in the lines provided.  Please go back and enter the text, or if you would like for us to send them to you as blank stock, simply note 'Blank Stock' in line 1, and we will send you blank stock.");
					}
				}
			
				if (ib_custom_printing==1) {
					alert("You have selected the 'custom printed' option, but you have not included any text for us to custom print in the lines provided.  Please go back and enter the text, or if you would like for us to send them to you as blank stock, simply select the 'Blank Stock' radio button.");
				}

				return false;
			}						
		}
		
		if (quantity_printing!=null) {
			z="";
			y="";

			if (address_printing!=null) {
				y=(address_printing.selectedIndex>1) ? address_printing.options[address_printing.selectedIndex].value : "";
				y=y.substring(0,y.indexOf(" "));
			}

			if (envelop_lining!=null) {
				z=(envelop_lining.selectedIndex>1) ? envelop_lining.options[envelop_lining.selectedIndex].value : "";
				z=z.substring(0,z.indexOf(" "));
			}
		
			if (y!="" || z!="") {
				x = quantity_printing.options[quantity_printing.selectedIndex].value;
				x = x!="" ? x.substring(0,x.indexOf(" ")) : "";
				x = x.toLowerCase();
				y = y.toLowerCase();
				z = z.toLowerCase();

				if (y!="" && x!=y) {			
					alert ("The quantity values for invitations and return address printing must be the same.  Please go back and adjust the quantities so that they do match.  For example, if you selected 50 for invitations, you must select 50 for return address printing.");
					return false;	
				} else {
					if (z!="" && x!=z) {
						alert ("The quantity values for invitations and envelope lining must be the same.  Please go back and adjust the quantities so that they do match.  For example, if you selected 50 for invitations, you must select 50 for envelope lining.");
						return false;	
					}
				}
			}
		}

		if (envelop_lining!=null && envelop_lining_color!=null) {			
			if (envelop_lining.selectedIndex==1) {
				if (envelop_lining_color.selectedIndex!=1) {
					alert("You have selected 'No thanks' for envelope lining, but you selected an envelope lining color.  Please go back and either select a quantity for envelope lining, or go back and select the 'plain white envelopes' option.")
					return false;
				}
			}
			if (envelop_lining.selectedIndex>1) {
				if (envelop_lining_color.selectedIndex==1) {
					alert("You have selected a quantity for the envelope lining option, but you did not select an envelope lining color.  Please go back and select a color for the envelope lining, or go back and select 'No thanks' for the envelope lining option.")
					return false;
				}
			}			
		}
	}
	var cbVal = gEBI('checkBoxes');
	if (cbVal) {
		cbVal.value = "YES";
	}
	return true;
}

function initValidation () {
	var f=gEBI("main_form");
	
	if (f) {
		f.onsubmit=processValidation;
	}	
}