
function xmlhttpPost2(ID, strURL){

		var target = document.forms[2];

			for (i=0; i < target.length; i++) {
						if ( target[i].value == '' && target[i].name != 'subscribeMO' ) {
								element = document.getElementById("submitVoteForm");
								target[i].style.background = '#FFE303';
								target[i].focus();
								return false;
						} else {
							target[i].style.backgroundColor = '#ffffff';
							// ("#idFour").css("background-color","#FFF7DE");
						}
			}

			$("#loading").ajaxStart(function() {
				$("#loading").show();
			});

			$.ajax({
				type: "POST",
				url: strURL,
				data: "userFirstName=" + target.userFirstName.value + "&userSurname=" + target.userSurname.value + "&userEmail=" + target.userEmail.value + "&nominationID=" + target.nominationID.value + "&moSubscribe=" + target.subscribeMO.checked,
				dataType: "xml",
				success: function(xmlR) {

					var _errorcode;
					var _errortext;
					var _regionid;
					var _newPageTitle;

					$(xmlR).find('stuff').each(function(){

						_errorcode = $("errorcode", this).text();
						_errortext = $("errortext", this).text();
						_regionid = $("regionid", this).text();
						_newPageTitle = $("windowtitle", this).text();

					});


					Boxy.get(target).setTitle(_newPageTitle);


					// Success
					if ( _errorcode == "2" ) {

						$("#loading").hide();
						updatepageSuccess(_errortext);

						$("#ajaxVoteFormResults").css('font-size', '20px');
						$("#ajaxVoteFormResults").css('text-align', 'center');
						$("#ajaxVoteFormResults span").css('text-align', 'left');
						$("#ajaxVoteFormResults span").css('font-size', '15px');

						$('#ajaxVoteFormResults').append('<BR /><br /><span style="font-size:15px;">Winners will be announced in September.<BR /><BR />To get more support for your Battler, email this link to your friends:<BR /><a href="http://kiwibattler.com/regions/' + _regionid + '">www.kiwibattler.com/regions/' + _regionid + '</a></span>');

						for (i=0; i < target.length; i++) {
								target[i].disabled = true;
						}

						$("#loading").hide();
						return true;


					// Already voted
					} else if ( _errorcode == "1" ) {

						$("#loading").hide();
						updatepageSuccess(_errortext);

						for (i=0; i < target.length; i++) {
								target[i].disabled = true;
						}

					} else { 

						/* We've found an error */

						$("#loading").hide();
						$("#ajaxVoteFormResultsError").show();
						updatePageError(_errortext); 
						target.userEmail.style.background = '#FFE303';
						target.userEmail.focus();
				
						return false;
					}

				}

			});

}

function updatepageSuccess(str) {
    document.getElementById("ajaxVoteFormResults").innerHTML = str;
}

function updatePageError(str) {
    document.getElementById("ajaxVoteFormResultsError").innerHTML = str;
}


function toggleCheckbox() {

	if ( $('input[name=subscribeMO]').is(':checked') ) 
		$('input[name=subscribeMO]').attr('checked', false);
	else 
		$('input[name=subscribeMO]').attr('checked', true);

}


