djConfig = {
	parseOnLoad: true
};
if (window.location.protocol == 'https:') {
	if (!djConfig.modulePaths) {
		djConfig.modulePaths={};
	}
	djConfig.modulePaths['dojo']='https://ajax.googleapis.com/ajax/libs/dojo/'+dojo_version+'/dojo';
	djConfig.modulePaths['dijit']='https://ajax.googleapis.com/ajax/libs/dojo/'+dojo_version+'/dijit';
	djConfig.modulePaths['dojox']='https://ajax.googleapis.com/ajax/libs/dojo/'+dojo_version+'/dojox';
}
google.setOnLoadCallback(function() {
	dojo.require("dojox.widget.Standby");
	dojo.require("dijit.Dialog");

	dojo.addOnLoad(function(){
		var mlform=dojo.byId('add-to-mailing-list');
		if (mlform) {
			dojo.connect(mlform,'onsubmit',function(e) {
				dojo.stopEvent(e);
				var standby=new dojox.widget.Standby({
					target:mlform.parentNode
				});
				mlform.parentNode.appendChild(standby.domNode);
				standby.startup();
				standby.domNode.style.position='absolute';
				var p=dojo.position(dojo.doc.body);
				standby.domNode.style.top='-5px';
				standby.domNode.style.left='-'+p.x+'px';
				standby.show();

				dojo.xhrPost({
					form: mlform,
					handleAs: 'json',
					load: function(data) {
						standby.hide();
						standby.destroyRecursive();
						if ('message' in data) {
							var d=new dijit.Dialog({
								title:'Mailing List Sign-Up',
								content:data.message
							});
							d.show();
						}
					},
					error: function() {
						standby.hide();
						standby.destroyRecursive();
						var d=new dijit.Dialog({
							title:'Mailing List Sign-Up',
							content:'There was an error adding you to our mailing list. Please try again later.'
						});
						d.show();
					}
				});
			});
		}
	});
});
google.load("dojo", dojo_version);
