var Checkout = {
	modal : undefined,
	showLoginBox : function(focusElement) {
		Checkout.modal = $("#checkoutLoginBox").modal({
			close:false,
			overlayId:'checkoutLoginBoxOverlay',
			containerId:'checkoutLoginBoxContainer',
			persist:true
		});
		// this Div doesn't exist until the above runs
		$('#checkoutLoginBoxOverlay').click(function() {
			Checkout.modal.close();
		});

		$(focusElement).each(function()
		{
			this.focus()
		});

	},
	popupWindow : popUp,
	shippingModal : undefined,
	showShippingWarning : function() {
		Checkout.shippingModal = $("#shippingRestrictionWarningBox").modal({
			overlayId:'shippingRestrictionOverlay',
			close:false
		});
	}
};

$(function(){
	$("ul.delivery_options a.shipMethodName").hoverIntent(
		function(){
			$($(this).parents("li")[0]).find(".extraInfo").fadeIn("fast");
		},
		function(){
			$($(this).parents("li")[0]).find(".extraInfo").fadeOut("fast");
		}
	);
	$(".deliveryEstimate p a").hoverIntent(
		function(){
			$(this).parent().parent().find(".learnMore").fadeIn("fast");
		},
		function(){
			$(this).parent().parent().find(".learnMore").fadeOut("fast");
		}
	);
});


$(function(){
	if (($("#collectinstorecurrentsetting").attr("value")) == "true" && ($("#collectinstorelastsetting").attr("value") == "false"))
	{
		$("#collect_in_store").slideDown('normal');
	}
	else if (($("#collectinstorecurrentsetting").attr("value")) == "false" && ($("#collectinstorelastsetting").attr("value") == "true"))
	{
		$("#collect_in_store").slideUp('normal');
	}
	/*else if (($("#collectinstorecurrentsetting").attr("value")) == "true" && ($("#collectinstorelastsetting").attr("value") == "true"))
	{
		$("#collect_in_store").show();
	}*/

});

function submitFormOnEnter(field,e, button)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;

	if (keycode == 13)
	{
		button.click();
		//field.form.submit();
	}
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=577,height=500,left = 680,top = 350');");
}

