//Event.observe(window, 'load', doUpdatePledgeCounter, false);
//
function doOldUpdatePledgeCounter() {
	var url = '/smg/brand/grogood/common/header.jsp';
	new Ajax.PeriodicalUpdater('pledgeCounter', url, {
		method :'get',
		frequency :1
		//decay: 2
	});
}
//
function takePledgeCb() {
	var url = '/smg/brand/grogood/takePledgeForm.jsp';
	new Ajax.Updater('bd', url, {
		method :'post',
		parameters :$('pledgeForm').serialize(true),
		asynchronous :true,
		onComplete: function() {
				if($('hasErrors') == null || $('hasErrors').value == "false") {
					// track custom event in Omniture
					omnitureTrackClick('takePledge.jsp','Take The Pledge form submission');
					document.getElementById('navSpread').onclick = function(){omnitureTrackClick(this,'Thanks! - Spread The Word');};
					document.getElementById('navLearn').onclick = function(){omnitureTrackClick(this,'Thanks! - Learn More');};
					document.getElementById('navTake').onclick = function(){omnitureTrackClick(this,'Thanks! - Take The Pledge');};

					document.getElementById("bd").className = "thankyou";
				} else {
					document.getElementById("bd").className = "pledge";
				}
			doUpdatePledgeCounter();
		}
	});
}
//
function doUpdatePledgeCounter() {
	var url = '/smg/brand/grogood/common/header.jsp';
	new Ajax.Updater('pledgeCounter', url, {
		method :'get',
		asynchronous :true
	});
}
//
function doUpdateNavigation() {
	var url = '/smg/brand/grogood/common/navigation.jsp';
	new Ajax.Updater('ajax_navigation', url, {
		method :'get',
		asynchronous :true
	});
}
