// BEGIN checkout.js ==============================================
//Now entirely included in all.footer.js
/* New Checkout 20-08-2007
Copyright 2007 Kaboose, Inc. More info available at
http://www.kaboose.com */
function RetAnswers(val)
{
	var ctext;
	var url="http://abhidev.birthdayinabox.com";
	switch(val)
	{
		case 'Security':ctext = "<p>Birthday in a Box values internet security. We use 128 bit encryption "
							ctext = ctext + " to keep your data safe. Look for the lock symbol in the lower right"
							ctext = ctext + " hand portion of your screen. This ensures that your session is safe."
							ctext = ctext + " Additionally, we partner with HackerSafe which continuously scans our"
							ctext = ctext + " website for potential vulnerabilities.</p>"

							document.getElementById('tdsecstat').style.backgroundColor="#eaffff";
							document.getElementById('tdcontent').innerHTML=ctext;
							
							//remove the color of other if set
							document.getElementById('tdshpchg').style.backgroundColor="#ffffff";
							document.getElementById('tddeldate').style.backgroundColor="#ffffff";
							document.getElementById('tdretploicy').style.backgroundColor="#ffffff";
							document.getElementById('tdpersitems').style.backgroundColor="#ffffff";
							document.getElementById('tdprivpolicy').style.backgroundColor="#ffffff";
							document.getElementById('tdcustserv').style.backgroundColor="#ffffff";
							document.getElementById('tdright').style.backgroundColor="#ffffff";
							document.getElementById('tdleft').style.backgroundColor="#ffffff";
							break;
			
			case 'Shipping':var link="<a href=\"#\" onclick=\"javascript:void(window.open('" + url + "/checkout/shipping_main.asp" + "','mywindow','menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,top=25,left=25,width=650,height=650'));\">"
							ctext = "<p>Shipping charges are based on the shipping method and the dollar amount"
							ctext = ctext + " of your order. Depending on your location, we use either UPS, USPS or"
							ctext = ctext + " an International Broker to deliver your package.<br>"
							ctext = ctext + link + "<font color='navy'>Click here for more details.</font></a></p>"
			
																
							document.getElementById('tdshpchg').style.backgroundColor="#eaffff";
							document.getElementById('tdcontent').innerHTML=ctext;
							//remove the color of other if set
							document.getElementById('tdsecstat').style.backgroundColor="#ffffff";
							document.getElementById('tddeldate').style.backgroundColor="#ffffff";
							document.getElementById('tdretploicy').style.backgroundColor="#ffffff";
							document.getElementById('tdpersitems').style.backgroundColor="#ffffff";
							document.getElementById('tdprivpolicy').style.backgroundColor="#ffffff";
							document.getElementById('tdcustserv').style.backgroundColor="#ffffff";
							document.getElementById('tdright').style.backgroundColor="#ffffff";
							document.getElementById('tdleft').style.backgroundColor="#ffffff";
							break;
			
			case 'Delivery':ctext = "<p>The typical order takes 1-4 business days to process and pack, and "
							ctext = ctext + "another 1-6 business days in transit. Not fast enough? Upgrade your"
							ctext = ctext + " shipping. If your order is placed before 11 A.M. Eastern, and you"
							ctext = ctext + " select an upgraded shipping method for delivery within the United"
							ctext = ctext + " States, we can have your order to you as soon as the next business day!</p>"	
			
							document.getElementById('tddeldate').style.backgroundColor="#eaffff";
							document.getElementById('tdcontent').innerHTML=ctext;
							//remove the color of other if set
							document.getElementById('tdshpchg').style.backgroundColor="#ffffff";
							document.getElementById('tdsecstat').style.backgroundColor="#ffffff";
							document.getElementById('tdretploicy').style.backgroundColor="#ffffff";
							document.getElementById('tdpersitems').style.backgroundColor="#ffffff";
							document.getElementById('tdprivpolicy').style.backgroundColor="#ffffff";
							document.getElementById('tdcustserv').style.backgroundColor="#ffffff";
							document.getElementById('tdright').style.backgroundColor="#ffffff";
							document.getElementById('tdleft').style.backgroundColor="#ffffff";
							break;
							
			case 'RetPolicy':ctext = "<p>We are committed to our customers satisfaction. We will accept returns "
							ctext = ctext + "of non-personalized, unopened and unused products or any product that"
							ctext = ctext + " does not meet your quality expectations. Returns will be accepted up to"
							ctext = ctext + " 60 days following the order date.</p>"
			
							document.getElementById('tdretploicy').style.backgroundColor="#eaffff";
							document.getElementById('tdcontent').innerHTML=ctext;
							//remove the color of other if set
							document.getElementById('tdshpchg').style.backgroundColor="#ffffff";
							document.getElementById('tddeldate').style.backgroundColor="#ffffff";
							document.getElementById('tdsecstat').style.backgroundColor="#ffffff";
							document.getElementById('tdpersitems').style.backgroundColor="#ffffff";
							document.getElementById('tdprivpolicy').style.backgroundColor="#ffffff";
							document.getElementById('tdcustserv').style.backgroundColor="#ffffff";
							document.getElementById('tdright').style.backgroundColor="#ffffff";
							document.getElementById('tdleft').style.backgroundColor="#ffffff";
							break;
							
			case 'PersItems':ctext = "<p>Our personalized products are created by our talented graphic artists."
							ctext = ctext + " Want to see a proof before we ship your order?"
							ctext = ctext + " No problem! On the last step of checkout, simply type, \“Request Proof\”"
							ctext = ctext + " in the comment box, and we will be happy to email a proof before"
							ctext = ctext + " processing your order.</p>"	
				
							document.getElementById('tdpersitems').style.backgroundColor="#eaffff";
							document.getElementById('tdcontent').innerHTML=ctext;
							//remove the color of other if set
							document.getElementById('tdshpchg').style.backgroundColor="#ffffff";
							document.getElementById('tddeldate').style.backgroundColor="#ffffff";
							document.getElementById('tdretploicy').style.backgroundColor="#ffffff";
							document.getElementById('tdsecstat').style.backgroundColor="#ffffff";
							document.getElementById('tdprivpolicy').style.backgroundColor="#ffffff";
							document.getElementById('tdcustserv').style.backgroundColor="#ffffff";
							document.getElementById('tdright').style.backgroundColor="#ffffff";
							document.getElementById('tdleft').style.backgroundColor="#ffffff";
							break;
							
			case 'Privacy':var link="<a href=\"#\" onclick=\"javascript:void(window.open('" + url + "/checkout/privacypolicy.asp" + "','mywindow','menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,top=25,left=25,width=600,height=600'));\">"
						ctext = "<p>Birthday in a Box is committed to protecting your privacy and that of your children."
						ctext += "We will not sell, share or lease your personal information outside the Kaboose family for any purpose except as set forth in our " 
						ctext += link + "<font color='navy'>Privacy Policy</font></a>.</p>"	
							
							
							document.getElementById('tdprivpolicy').style.backgroundColor="#eaffff";
							document.getElementById('tdright').style.backgroundColor="#eaffff";
							document.getElementById('tdcontent').innerHTML=ctext;
							//remove the color of other if set
							document.getElementById('tdshpchg').style.backgroundColor="#ffffff";
							document.getElementById('tddeldate').style.backgroundColor="#ffffff";
							document.getElementById('tdretploicy').style.backgroundColor="#ffffff";
							document.getElementById('tdpersitems').style.backgroundColor="#ffffff";
							document.getElementById('tdsecstat').style.backgroundColor="#ffffff";
							document.getElementById('tdcustserv').style.backgroundColor="#ffffff";
							document.getElementById('tdleft').style.backgroundColor="#ffffff";
							break;
							
			case 'CSR':ctext = "<p>Our customer service staff is ready to assist you by phone or email. <a href='mailto:customerservice@birthdayinabox.com'><font color='navy' >Email us</font></a> or call 800-989-9506 or 301-956-1616.</p>"
			
						document.getElementById('tdcustserv').style.backgroundColor="#eaffff";
						document.getElementById('tdleft').style.backgroundColor="#eaffff";								
						document.getElementById('tdcontent').innerHTML=ctext;
						//remove the color of other if set
						document.getElementById('tdshpchg').style.backgroundColor="#ffffff";
						document.getElementById('tddeldate').style.backgroundColor="#ffffff";
						document.getElementById('tdretploicy').style.backgroundColor="#ffffff";
						document.getElementById('tdpersitems').style.backgroundColor="#ffffff";
						document.getElementById('tdprivpolicy').style.backgroundColor="#ffffff";
						document.getElementById('tdsecstat').style.backgroundColor="#ffffff";
						document.getElementById('tdright').style.backgroundColor="#ffffff";
						break;
	}
	
}

function CopyAllBillFieldsToShipFields() {

	document.getElementById('ship_to_first_name').value = document.getElementById('bill_to_first_name').value;
	document.getElementById('ship_to_last_name').value = document.getElementById('bill_to_last_name').value;
	document.getElementById('ship_to_street').value = document.getElementById('bill_to_street').value;
	document.getElementById('ship_to_street2').value = document.getElementById('bill_to_street2').value;

	if (document.getElementById('bill_to_po').checked) {
		document.getElementById('ship_to_po').checked = true;
	} else {
		document.getElementById('ship_to_po').checked = false;
	}

	document.getElementById('ship_to_city').value = document.getElementById('bill_to_city').value;
	document.getElementById('ship_to_state').value = document.getElementById('bill_to_state').value;
	document.getElementById('ship_to_zip').value = document.getElementById('bill_to_zip').value;
	document.getElementById('ship_to_country').value = document.getElementById('bill_to_country').value;
	document.getElementById('ship_to_phone').value = document.getElementById('bill_to_phone').value;
	document.getElementById('ship_to_phone_eve').value = document.getElementById('bill_to_phone_eve').value;

	return 1; // success
	
} // CopyAllBillFieldsToShipFields()

function DisableAllShipFields() {

	document.getElementById('ship_to_first_name').disabled = true;
	document.getElementById('ship_to_last_name').disabled = true;
	document.getElementById('ship_to_street').disabled = true;
	document.getElementById('ship_to_street2').disabled = true;
	document.getElementById('ship_to_po').disabled = true;
	document.getElementById('ship_to_city').disabled = true;
	document.getElementById('ship_to_state').disabled = true;
	document.getElementById('ship_to_zip').disabled = true;
	document.getElementById('ship_to_country').disabled = true;
	document.getElementById('ship_to_phone').disabled = true;
	document.getElementById('ship_to_phone_eve').disabled = true;

} // DisableAllShipFields()


function ClearAllShipFields() {

	document.getElementById('ship_to_first_name').value = "";
	document.getElementById('ship_to_last_name').value = "";
	document.getElementById('ship_to_street').value = "";
	document.getElementById('ship_to_street2').value = "";

	document.getElementById('ship_to_po').checked = false;
	// document.getElementById('ship_to_po').value = '';

	document.getElementById('ship_to_city').value = "";
	document.getElementById('ship_to_state').value = "";
	document.getElementById('ship_to_zip').value = "";
	// document.getElementById('ship_to_country').value = "";
	document.getElementById('ship_to_phone').value = "";
	document.getElementById('ship_to_phone_eve').value = "";

} // ClearAllShipFields()


function EnableAllShipFields() {

	document.getElementById('ship_to_first_name').disabled = false;
	document.getElementById('ship_to_last_name').disabled = false;
	document.getElementById('ship_to_street').disabled = false;
	document.getElementById('ship_to_street2').disabled = false;
	document.getElementById('ship_to_po').disabled = false;
	document.getElementById('ship_to_city').disabled = false;
	document.getElementById('ship_to_state').disabled = false;
	document.getElementById('ship_to_zip').disabled = false;
	document.getElementById('ship_to_country').disabled = false;
	document.getElementById('ship_to_phone').disabled = false;
	document.getElementById('ship_to_phone_eve').disabled = false;

} // EnableAllShipFields()


/* 
 * Because AutoFill and AutoComplete sometimes do an end-run around the onChange and onBlur events that normally copy
 * data from the bill-to fields to the ship-to fields, we do the following, just in case:
 * When the page is submitted, if the "same as" checkbox is checked, 
 * enable all the ship-to fields and copy all the bill-to data into them.
 */
function CopyBillFieldsOnSubmit() {
	if (document.getElementById('altbilling').checked) {
		EnableAllShipFields();
		CopyAllBillFieldsToShipFields();
	}
}

/* CopyBillInfo():
   When the user checks the "shipping address same as billing address" checkbox,
   this function copies the values in the bill-to fields to the corresponding ship-to fields, and disables all the ship-to fields.
   When the user unchecks that checkbox, this function empties out and re-enables all the ship-to fields.
   [function name is legacy and should probably be renamed.]
*/

function CopyBillInfo() {
  
	if(document.getElementById('altbilling').checked) {
		// copy bill-to info to ship-to fields and disable ship-to fields so user can't mess it up
		CopyAllBillFieldsToShipFields();
		DisableAllShipFields();
	} else {	
    // clear and enable all fields for separate ship-to info
		ClearAllShipFields();
		EnableAllShipFields();
	} // if altbilling.checked
	
} // function CopyBillInfo()


function enableShipToFields(bEnable) {

  sDisabled = ((bEnable == 1) ? false : true);
  
	if (bEnable == 1) {

		/* If enabling, figure out whether the fields are *already* enabled;
			 if they are, don't overwrite the ship_to_po checkbox. */
		ship_to_po = document.getElementById('ship_to_po');
		if (ship_to_po.disabled == true) {

			ship_to_po.disabled = sDisabled;
			ship_to_po.checked = document.getElementById('bill_to_po').checked;
			// ship_to_po.value = document.getElementById('bill_to_po').value;

		} else {

			// if NOT already enabled, AND if ship-to country is empty, then set these default values for ship-to address:
			if (document.getElementById('ship_to_country').value == '') {
				document.getElementById('ship_to_country').value = document.getElementById('bill_to_country').value;
			}

		} // if ship_to_po_disabled == true
		
	} // bEnable == 1
  
	document.getElementById('ship_to_first_name').disabled = sDisabled;
	document.getElementById('ship_to_last_name').disabled = sDisabled;
	document.getElementById('ship_to_street').disabled = sDisabled;
	document.getElementById('ship_to_street2').disabled = sDisabled;
	document.getElementById('ship_to_city').disabled = sDisabled;
	document.getElementById('ship_to_state').disabled = sDisabled;
	document.getElementById('ship_to_zip').disabled = sDisabled;
	document.getElementById('ship_to_country').disabled = sDisabled;
	document.getElementById('ship_to_phone').disabled = sDisabled;
	document.getElementById('ship_to_phone_eve').disabled = sDisabled;
  
  return true;
}

function CopyBillFieldToShipField(billField) {
  
	if(document.getElementById('altbilling').checked) {
	  shipToFieldID = 'ship_to' + billField.id.substr(7);
		document.getElementById(shipToFieldID).value = billField.value;
	}
}

function UpdateStateField(country_field) {
	stateFieldID = country_field.id.substr(0,8) + 'state';
	stateField = document.getElementById(stateFieldID);
	if ((country_field.value != 'United States') && (country_field.value != 'Canada')) {
		// set corresponding state field to "Outside US/Canada"
		stateField.value = 'XX';
		if (country_field.id == 'bill_to_country') {
			CopyBillFieldToShipField(stateField);
			CopyBillFieldToShipField(country_field);
		}
	} else {
		if (stateField.value = 'XX') {
			stateField.value = '';
			if (country_field.id == 'bill_to_country') {
				CopyBillFieldToShipField(stateField);
				CopyBillFieldToShipField(country_field);
			}
		}
	}
}

function UpdateCountryField(state_field) {
	if ((state_field.value != '') && (state_field.value != 'XX')) {
		// set corresponding country field to US or Canada
		countryFieldID = state_field.id.substr(0,8) + 'country';
		countryField = document.getElementById(countryFieldID);
		provinces = '|AB|BC|MB|NB|NF|NS|NT|ON|PE|QC|SK|YT';
		if (provinces.indexOf(state_field.value) > 0) {
			countryField.value = 'Canada';
			if (state_field.id == 'bill_to_state') {
				CopyBillFieldToShipField(state_field);
				CopyBillFieldToShipField(countryField);
			}
		} else {
			countryField.value = 'United States';
			if (state_field.id == 'bill_to_state') {
				CopyBillFieldToShipField(state_field);
				CopyBillFieldToShipField(countryField);
			}
		}
	}
}

function CopyBillToCheckbox(billToCheckbox) {
	if(document.getElementById('altbilling').checked) {
	  shipToCheckboxID = 'ship_to' + billToCheckbox.id.substr(7);
		document.getElementById(shipToCheckboxID).checked = billToCheckbox.checked;
		// document.getElementById(shipToCheckboxID).value = billToCheckbox.value;
	}
}

function setvalnew() {
	if (document.getElementById('txthidnew')) {
		document.getElementById('txthidnew').value = "1";
		//return false;
	}
}

function ClickImg()
{
	window.location="http://www.birthdayinabox.com";
}

function PrintOrder(val1)
{
	//alert(val1);
	var url="printorder.asp?ordid=" + val1;
	//alert(url)
	window.open(url,"mywindow","menubar=1,resizable=1,scrollbars=1");
}

function keydownship()
{
	if (event.keyCode == 13)
	{
		if (oButton = document.getElementById('continuebutton')) {
			oButton.click();
			return false;
		}
	}
	return true;
}

function keydownship()
{
	if (event.keyCode == 13)
	{
		if (oButton = document.getElementById('continuebutton')) {
			oButton.click();
			return false;
		}
	}
	return true;
}

function keydownpmt()
{
	if (event.keyCode == 13)
	{
		if (oButton = document.getElementById('processorderbutton')) {
			oButton.click();
			return false;
		}
	}
	return true;
}

function keydownpmtoff()
{
	if (event.keyCode == 13)
	{
		if (oButton = document.getElementById('processholdbutton')) {
			oButton.click();
			return false;
		}
	}
	return true;
}

// END checkout.js ==================================================

