var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);
var itemString; 
var stepZeroImg = '<img src="http://site.invitationbox.com/images/IMG-Progress0_StartOver_ON.gif" border=0><img src="http://site.invitationbox.com/images/IMG-Progress1_Personalize_OFF.gif" border=0><img src="http://site.invitationbox.com/images/IMG-Progress2_Envelopes_OFF.gif" border=0><img src="http://site.invitationbox.com/images/IMG-Progress3_Review_OFF.gif" border=0>';
var stepOneImg = '<a href="javascript:startStepOne();"><img src="http://site.invitationbox.com/images/IMG-Progress0_StartOver_ON.gif" border=0></a><img src="http://site.invitationbox.com/images/IMG-Progress1_Personalize_ON.gif" border=0><img src="http://site.invitationbox.com/images/IMG-Progress2_Envelopes_OFF.gif" border=0><img src="http://site.invitationbox.com/images/IMG-Progress3_Review_OFF.gif" border=0>';
var stepTwoImg = '<a href="javascript:startStepOne();"><img src="http://site.invitationbox.com/images/IMG-Progress0_StartOver_ON.gif" border=0></a><a href="javascript:startStepTwo();"><img src="http://site.invitationbox.com/images/IMG-Progress1_Personalize_ON.gif" border=0></a><img src="http://site.invitationbox.com/images/IMG-Progress2_Envelopes_ON.gif" border=0><img src="http://site.invitationbox.com/images/IMG-Progress3_Review_OFF.gif" border=0>';
var stepThreeImg = '<a href="javascript:startStepOne();"><img src="http://site.invitationbox.com/images/IMG-Progress0_StartOver_ON.gif" border=0></a><a href="javascript:startStepTwo();"><img src="http://site.invitationbox.com/images/IMG-Progress1_Personalize_ON.gif" border=0></a><a href="javascript:startStepThree();"><img src="http://site.invitationbox.com/images/IMG-Progress2_Envelopes_ON.gif" border=0></a><img src="http://site.invitationbox.com/images/IMG-Progress3_Review_ON.gif" border=0>';;
var btnRTP = '<a href="javascript:startStepTwo();"><img src="http://site.invitationbox.com/images/BTN-Return-to-Personalize.gif" border=0></a>';
var renderTB = '<div class="topicheading"><span style="float:left;margin-left:10px;">Review Your Online Proof</span><span style="float:right;margin-right:10px;"><a style="color:#FFFFFF;" href="javascript:showFaqRender();">Need More Info?</a></span></div>';
var personalizeTB = '<div class="apheading"><h2>Personalize Your Card '+itemString+'</h2></div><img src="http://site.invitationbox.com/images/imgDashLine.gif">';
var divInstructions = '\
<div id="divInstructions" class="mdlAPInstructions">\
 <div class="modalClose"><a href="javascript:closeInstructions();"><img class="rollOverImg" src="http://site.invitationbox.com/images/btnCloseCircle-off.gif" border=0></a>&nbsp;</div>\
 <p style="text-align:center;font-size:16pt;font-weight:bold;color:#5E89A9;">Welcome to the InvitationBox.com online proofing system!</p>\
 <div style="text-align:center;">\
  <img src="http://site.invitationbox.com/images/imgDashLine.gif"><br>\
  <p style="text-align:center;color:#563C2C;font-size:12pt;">On this page you will have the opportunity to typeset your card.  Your preview will include options to select font styles, font colors, text sizes and text placement.</p>\
  <img src="http://site.invitationbox.com/images/imgDashLine.gif">\
 </div>\
 <p style="font-weight:bold;color:#563C2C;font-size:14pt;">&nbsp;&nbsp;Quick Tips</p>\
 <div class="modalAPInnerBorder">\
  <p><font color="#006699"><b>The text is movable</b></font><br>\
   <ul>\
    <li>In the preview area, click on the text you would like to move, and drag it with your mouse to the desired location on the card.</li>\
    <li>Text can be moved as a group or line by line using the "Move All Text At Once" button.</li>\
   </ul>\
  </p>\
  <p><font color="#006699"><b>Additional lines of text</b></font><br>\
   <ul>\
    <li>If you require additional lines of text to be added to your card, you can enter them in the special instructions box in step 3 of the personalization process.</li>\
   </ul>\
  </p>\
  <p><font color="#006699"><b>Saving your design</b></font><br>\
   <ul>\
    <li>After you are finished typesetting your card, click on the green "Save and Continue" button to continue placing your order.</li>\
    <li>Please note, clicking "Save and Continue" ONLY saves your design while you are placing your order. It does NOT save your design into your account or into your shopping cart.</li>\
    <li>If you close out, or leave the website, any <i>saved work will be lost</i>.</li>\
   </ul>\
  </p>\
 </div>\
 <div class="modalAPCloseModal"><a href="javascript:closeInstructions();"><img class="rollOverImg" src="http://site.invitationbox.com/images/btnClosePopup-off.gif" border=0></a></div>\
</div>';
document.write(divInstructions);

var bStarted = false;
var bHasPhoto = false;

function savePreview(qs, prodid, returnVars) {
  var pid = document.getElementById('pid');
  var saveTxt = document.getElementById('saveTxt');
  var rVars = document.getElementById('returnVars');
  
  pid.value = prodid;
  saveTxt.value = qs;
  rVars.value = returnVars;
  
  // alert(returnVars);
  document.forms['saveForm'].submit();
  // startStepThree();
}

$(document).ready(function() { 
	if (true) {
		itemString = (typeof(itemNum) != 'undefined') ? "(Item #: " + itemNum + ")" : '';
		personalizeTB = '<div class="apheading"><h2>Personalize Your Card '+itemString+'</h2></div><img src="http://site.invitationbox.com/images/imgDashLine.gif">';
		
		startStepOne(); 
		$('#mpblankquantity').change( function() {
			$('#mpquantity').attr('disabled',true);
			$('#mpblankquantity').attr('disabled',false);
			$('#blankblank').attr('checked',true);
			$('#blankblank').trigger('click');
		});
	
		$('#mpquantity').change( function() {
			$('#mpblankquantity').attr('disabled',true);
			$('#mpquantity').attr('disabled',false);
			$('#printedprinted').attr('checked',true);
		});
		
		$('#printedprinted').click( function() {
			$('#mpquantity').attr('disabled',false);
			$('#mpblankquantity').attr('disabled',true);
			$('#mpAddToCart').hide();
			$('#printedpricing .btnpersonalize').show();
			startStepOne();
			printingenable();
		});
		
		$('#blankblank').click( function() {
			$('#mpquantity').attr('disabled',true);
			$('#mpblankquantity').attr('disabled',false);
			$('#mpAddToCart').show();
			$('#printedpricing .btnpersonalize').hide();
			startStepOne();
			printingdisable();
		});
		
		$('#mpAddToCart').click( function () {
			if ($('#blankblank').is(':checked')) {
				if (processValidation()) {
					$('#main_form').trigger("submit");
				}
			}
		});
		
		$('#mpblankquantity').change( function() {
			$('#blankquantity').attr('selectedIndex',this.selectedIndex);
		});
		
		$('#blankrushprocessing').change( function() {
			if (this.checked) {
				$('#rushprocessingyes').attr('checked',true);
			} else {
				$('#rushprocessingyes').attr('checked',false);
			}
		});
	
		if (document.main_form['vwphotovalue']) {
			var photoValue = document.main_form['vwphotovalue'].value;
			if (photoValue != '') {
				if (parseInt(photoValue) > 0) {
					bHasPhoto = true;
				}
			}
		}
	
		window.onunload = function() { 
	    	window["__flash__removeCallback"] = function (instance, name) { 
	    	 return; 
	    	}; 
		}
		
		$('img.rollOverImg').hover(
			function() {
				this.src = this.src.replace("-off", "-on");
			},
			function() {
				this.src = this.src.replace("-on", "-off");
			}
		);
	} else {
		$('.pr_review_summary').hide();
		$('.btnpersonalize').hide();
		$('.titleBarContainer').hide();
		$('#mpalloptions').show();
		$('#mpiteminfo').show();
		$('#divstepsholder').show();	
		$('#mpprinting').show();
		$('#mpenvelopes').show();
		$('#divquantity').show();
		$('#mporderprocessing').show();
		$('#mpaddtocart').show();
		$('#titleBarName').show();
		$('#mppreview').show();
		$('#renderTitleBar').show();	
		$('#divHelpfulLinks').hide();
		$('#step3save').show();
	}

});

function startStepOne() {
	//$('#mpalloptions').hide();
	$('#mpiteminfo').show();
	$('#divstepsholder').hide();	
	$('#mpprinting').hide();
	$('#mpenvelopes').hide();
	$('#divquantity').hide();
	$('#mporderprocessing').hide();
	$('#mpaddtocart').hide();
	$('#titleBarName').hide();
	$('#mppreview').hide();
	$('#renderTitleBar').hide();	
	$('#divHelpfulLinks').hide();
	$('#step3save').hide();
}

function getParams() {
	var params = "";
	var prevId = (document.main_form['previewid']) ? document.main_form['previewid'].value : '';
	var returnVars = encodeURIComponent(getReturnVars());

	if (prevId == '') {
		try {
			if (typeof(previewExists)!="undefined") {
				if (previewExists) {
					return "previewid=" + document.main_form['previewid'].value + "&returnVars=" + returnVars;
				}
			}
			
			if (typeof ibPreviewId != 'undefined') {
				if (ibPreviewId != '') {
					return "previewid=" + ibPreviewId + "&returnVars=" + returnVars;
				}
			}
		} catch (ex) { alert (ex);	}
	}
	
	return previewUrl(document.main_form);
}

function startStepTwo() {
	$('#titleBarName').show();
	$('#mpprinting').hide();
	$('#mpenvelopes').hide();
	$('#divquantity').hide();
	$('#mporderprocessing').hide();	
	$('#mpiteminfo').hide();
	$('#mpaddtocart').hide();
	$('#step3save').hide()
	$('#divstepsholder').show();
	$('#divstepsholder').html(stepOneImg);
	//
	var bStarted = true;
	var params = getParams();
		
	//alert(params);	
		
	var ht = '\
<form id="saveForm" name="saveForm" action="http://www.theprintingbox.com/fontTest/savePreview.aspx" METHOD="POST">\
	<input type=hidden id="pid" name="pid" value="">\
	<input type=hidden id="saveTxt" name="saveTxt" value="">\
	<input type=hidden id="returnVars" name="returnVars" value="">\
</form>\
<div style="width:100%;text-align:center;">\
<div class="apheading" style="text-align:center;width:988px;margin:0px 0px 0px 11px;"><span style="float:left;margin-left:10px;">Personalize Your Card '+ itemString +'</span><span style="float:right;margin-right:10px;"><a style="color:#5E89A9;" href="javascript:showFaqPersonalize();">Need Help?</a></span></div>\
<img src="http://site.invitationbox.com/images/imgDashLine-Long.gif">\
<div class="helpfulLinks">';
  ht += $('#divHelpfulLinks').html();
	ht += '</div><img src="http://site.invitationbox.com/images/imgDashLine-Long.gif"></div><br><div id="previewHolder">Flash Previewer</div>';
	if (bHasPhoto) {
		ht += '<span style="float:left;margin-right:10px;padding-left:10px;"><a style="color:#5E89A9;" href="javascript:photoModalToggle(true);">Photo Manager Help</a></span><br><br>';
	}
	
	$('#mppreview').html(ht);
	$('#mppreview').show();
	addSwfObject(params,"previewHolder", "1000", "850");
	
	$("img.helpLinkRollover").hover(
		function() {
			this.src = this.src.replace("_Off", "_On");
		},
		function() {
			this.src = this.src.replace("_On", "_Off");
		}
	);

	var instructions = GetCookie("showInstr");

	if (instructions != 'N') {
		$("#divInstructions").show();
		document.cookie = "showInstr=N;path=/;domain=invitationbox.com";
	}
}

function startStepThree() {
	$('#renderTitleBar').hide();
	$('#titleBarName').show();
	$('#mpiteminfo').hide();
	$('#divstepsholder').show();
	$('#divstepsholder').html(stepTwoImg);
	$('#mpprinting').hide();
	$('#mporderprocessing').hide();
	$('#mpaddtocart').hide();
	$('#mppreview').hide();	
	$('#blankpricing .pricing').hide();
	$('#divquantity').show();
	$('#mppricing').show();
	$('#mpenvelopes').show();
	$('#step3save').show()

	var vendor = document.main_form['vwvendor'].value;
	//alert('vendor='+vendor);
	if (vendor == "wa") {
		var rb;
		rb = gEBI('engravedprinted');		
		if (rb) {
			if (rb.checked) {
				$('#thermographypricing .pricing').hide();
				$('#digitalpricing .pricing').hide();
				$('#flatpricing .pricing').hide();
				$('#engravedpricing .pricing').show();
			}
		} else {
			rb = gEBI('thermographyprinted');
			if (rb) {
				if (rb.checked) {
					$('#engravedpricing .pricing').hide();
					$('#digitalpricing .pricing').hide();
					$('#flatpricing .pricing').hide();
					$('#thermographypricing .pricing').show();
				}
			} else {
				rb = gEBI('digitalprinted');
				if (rb) {
					if (rb.checked) {
						$('#thermographypricing .pricing').hide();
						$('#engravedpricing .pricing').hide();
						$('#flatpricing .pricing').hide();
						$('#digitalpricing .pricing').show();
					}
				} else {
					rb = gEBI('flatprinted');
					if (rb) {
						if (rb.checked) {
							$('#thermographypricing .pricing').hide();
							$('#engravedpricing .pricing').hide();
							$('#digitalpricing .pricing').hide();
							$('#flatpricing .pricing').show();
						}
					}
				}
			}
		}		
	} else {
		var rb = gEBI('printedprinted');
		if (rb) {
			rb.checked = true;
		}
	}		
}

function startStepFour() {

	if (stepTwoValidate()) {
		if (typeof(previewExists)!="undefined") {
			if (previewExists) {
				var params = "renderOnly=y&previewid=" + document.main_form['previewid'].value;

				addSwfObject(params,"confirmContainer","650","650");
			}
		}
		$('#mpiteminfo').hide();
		$('#titleBarName').show();
		$('#divstepsholder').show();
		$('#divstepsholder').html(stepThreeImg);
		$('#mpprinting').hide();
		$('#mppreview').hide();
		$('#mpenvelopes').hide();
		$('#divquantity').hide();	
		$('#mpaddtocart').show();
		$('#mporderprocessing').show();
		$('#renderTitleBar').show();
		$('#renderTitleBar').html(renderTB);
		$('#returnToPersonalize').html(btnRTP);
		$('#returnToPersonalize').show();
		$('#divHelpfulLinks').hide();
		$('#step3save').hide()
	}
}

function stepTwoValidate() {
	var x,y,z;
	var els,els1;
	var f=gEBI("main_form");
	
	if (f) {
		var ib_custom_printing=0;
		var ib_ra_printing=0;
	
		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");
		}

		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 {
					return true;
				}
			}
		}
		
		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;
						}	 
					}
					/*
					var e = gEBI('fontcolor1');
					
					alert(e.selectedIndex + ' = ' + e.options[e.selectedIndex].value);
					alert(x.selectedIndex + ' = ' + x.options[x.selectedIndex].value);
					*/
					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(),"inside 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;
				}
			}			
		}
	}

	return true;
}

function stepThreeValidate() {
	if (!formattingCheck()) { alert('Please select a formatting option in the Special Instructions section'); }

	if (gEBI('correctnames')){
		if (gEBI('correctnames').checked == false){
	 		alert('Please verify that all names are spelled correctly and check the appropriate box in the Order Processing section');
			return false;				
		}
	}
	if (gEBI('correctdates')){
		if (gEBI('correctdates').checked == false){
	 		alert('Please verify that all dates are correct and check the appropriate box in the Order Processing section');
			return false;				
		}
	}
	if (gEBI('correctinfo')){
		if (gEBI('correctinfo').checked == false){
	 		alert('Please verify that all other information on the card is correct and check the appropriate box in the Order Processing section');
   		return false;				
		}
	}
	var cbVal = gEBI('checkBoxes');
	if (cbVal) {
		cbVal.value = "YES";
	}
	return true;
}

function updateWAQty(ddl, code) {
	var qtyddl;
	
	switch (code) {
		case 'd':
			qtyddl = gEBI('digitalquantity');
			break;
		case 'e':
			qtyddl = gEBI('engravedquantity');
			break;
		case 'f':
			qtyddl = gEBI('flatquantity');
			break;
		case 't':
			qtyddl = gEBI('thermographyquantity');
			break;
	}
	
	if (qtyddl) {
		qtyddl.selectedIndex = ddl.selectedIndex;
	}	
}

function updateQty(ddl) {
	var qtyddl = gEBI('quantity');
	
	if (qtyddl) {
		qtyddl.selectedIndex = ddl.selectedIndex;
	}
}

function updateBlankQty(ddl) {
	var qtyddl = gEBI('blankquantity');
	
	if (qtydll) {
		qtyddl.selectedIndex = ddl.selectedIndex;
	}
}

function showFaqPersonalize() {
	$('#divModalPersonalize').show();	
}

function hideFaqPersonalize() {
	$('#divModalPersonalize').hide();
}

function showFaqRender() {
	$('#divModalRender').show();	
}

function hideFaqRender() {
	$('#divModalRender').hide();
}

function openSampleCard(url) {
	window.open(url, 'Sample_Card', 'toolbars=0,scrollbars=0,location=0,statusbars=1,menubars=0,resizable=0,width=650,height=650,left =250,top =185');
}

function openCalendar() {
	window.open('calendar.html', 'Calendar', 'toolbars=0,scrollbars=0,location=0,statusbars=1,menubars=0,resizable=0,width=350,height=320,left=250,top=185');
}

function showFontHelp() {
	var url = 'info1.html';
	var vendor = gEBI('vendor');
	
	if (vendor) {
		switch(vendor.value) {
			case 'nw':
				url = 'nofo.html';
				break;
			case 'sc':
				url = 'stclbodifoov.html';
				break;
			case 'wa':
				url = 'william-arthur-fonts.html';
				break;
			case 'egb':
				url = 'emgrbelamfo.html';
				break;
		}
	}
	window.open(url, 'Font_Help', 'toolbars=1,scrollbars=1,location=1,statusbars=1,menubars=1,resizable=1,width=800,height=600,left=250,top=185');
}

function photoModalToggle(_on) {
	if (_on) {
		$('#modalbg').show();
		$('#photomodal').show();
	} else {
		$('#modalbg').hide();
		$('#photomodal').hide();		
	}
}

function photomodaloff() {
	photoModalToggle(false);
}

function closeInstructions() {
	$("#divInstructions").hide();
}

function setColorStepTwo(colorCode) {
	ibColorCode = colorCode;
	startStepTwo();
}

function thisMovie(movieName) {
	try {
    return (navigator.appName.indexOf("Microsoft") != -1) ? window[movieName] : document[movieName];
	} catch(e) {
		alert("flash not found");
	}
}

function setLine(line, lineNumber) {
	var elMv = thisMovie("previewHolder");
	if (elMv) {
		try {
			elMv.sendTextToFlash(line, lineNumber);
		} catch (e) {
			alert( 'MP: ' + e);
		}
	} else {
		alert('no movie');
	}
}

function setDomain() {
		document.domain = "invitationbox.com";
}

function addSwfObject(paramString, divId, _width, _height) {
	var now = new Date();
	
	var flashVars = {};
	var vars = paramString.split('&');
	
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split('=');
		
		flashVars[pair[0]] = pair[1];
	}
	
	var params = {
     'allowfullscreen': 'false', 
     'allowscriptaccess': 'always',
     'wmode': 'transparent' 
	}
		
	swfobject.embedSWF("http://preview.invitationbox.com/fontTest/inlinePreview.swf?+"+now, divId, _width, _height, "9.0.0","http://preview.invitationbox.com/fontTest/expressInstall.swf", flashVars, params);	
}
