YAHOO.namespace("addToBasket.container");

function initNotify() {
	var handleSuccessEmpty = function() {
	};
	var handleFailure = function(o) {
		addedProdOptionID = 0;
		alert("Submission failed: " + o.status);
	};
	YAHOO.notifyWhenOutOfStockContainer = new YAHOO.widget.Dialog(
			"notifyWhenOutOfStockPopup", {
				width : "360px",
				fixedcenter : true,
				visible : false,
				constraintoviewport : true,
				modal : true,
				zindex : 10000
			// , buttons: [ { text:"CONTINUE SHOPPING", handler:handleCancel } ]
			});
	YAHOO.notifyWhenOutOfStockContainer.callback = {
		success : handleSuccessEmpty,
		failure : handleFailure
	};
	YAHOO.notifyWhenOutOfStockContainer.render();
}

YAHOO.util.Event.onDOMReady(initNotify);

var AjaxObjectNotify = {
	handleSuccess : function(o) {
		var response = o.responseText;
		YAHOO.util.Dom.addClass('notifyContent', 'hidden');
		YAHOO.util.Dom.removeClass('notifyThankYou', 'hidden');
	},
	handleFailure : function(o) {
	},
	startRequest : function(url, formData) {
		YAHOO.util.Connect.asyncRequest('POST', url, callbackNotify);
	}
};
var callbackNotify = {
	success : AjaxObjectNotify.handleSuccess,
	failure : AjaxObjectNotify.handleFailure,
	scope : AjaxObjectNotify,
	argument : [ 'selectaction', 'notifyId', 'notifyIdType' ]
};
function ActSubmitNotify(val, baseURL) {
	YAHOO.util.Dom.removeClass('ajaxNotifyLoader', 'hidden');
	var url = baseURL + "store/notifyWhenOutOfStock.cfm?shipHTML";
	var formData = YAHOO.util.Connect.setForm('notifyWhenOutOfStockForm');
	AjaxObjectNotify.startRequest(url, formData);
}
function EmailMeWhenAvailable(id, idType, name) {
	var productNameContainer = document.getElementById('notifyProductName');
	var notifyForm = document.getElementById('notifyWhenOutOfStockForm');
	notifyForm.notifyId.value = id;
	notifyForm.notifyIdType.value = idType;
	notifyForm.notifyName.value = name;
	productNameContainer.innerHTML = name;
	YAHOO.util.Dom.addClass('notifyThankYou', 'hidden');
	YAHOO.util.Dom.addClass('ajaxNotifyLoader', 'hidden');
	YAHOO.util.Dom.removeClass('notifyContent', 'hidden');
	YAHOO.notifyWhenOutOfStockContainer.cfg.setProperty("fixedcenter", true);
	YAHOO.util.Dom.removeClass('notifyWhenOutOfStockPopup', 'hidden');
	YAHOO.notifyWhenOutOfStockContainer.show();
	YAHOO.notifyWhenOutOfStockContainer.cfg.setProperty("fixedcenter", false);
}

