
function reCode(doFocus) {
	document.getElementById("codeimg").src = 'assets/code_img_out.php?regen&' + Math.random();
	if (doFocus) document.getElementById("code").focus();
}

var newsletter = new Object();

newsletter.subscribe = function(formnumber) {
	var element = document.getElementById("ea"+formnumber);
	if (element.value == "email address") {
		window.location = r+"subscribe";
	} else {
		document.getElementById("subscribeform"+formnumber).submit();
	}
}

newsletter.focus = function(formnumber) {
	var element = document.getElementById("ea"+formnumber);
	if (element.value == "email address") {
		element.value = "";
	}
	element.className = "subscribe_input2";
}

newsletter.blur = function(formnumber) {
	var element = document.getElementById("ea"+formnumber);
	if (element.value == "") {
		element.className = "subscribe_input1";
		element.value = "email address";
	}
}

newsletter.waiting = function() {
	document.getElementById("contactform").style.display = "none";
	document.getElementById("formwait").style.display = "block";
}

var cart = new Object();

cart.clear = function() {
	$.post("cart_submit.php", { action: "clear" }, function(data){
		window.location = r+"cart";
	});
}

cart.donate = function(id) {
	amount = parseFloat($('#donateamount').val());
	if (isNaN(amount)) {
		alert("Please enter an amount first!");
		$('#donateamount').focus();
	} else {
		$.post("cart_submit.php", { action: "add", additem: id, "amount": amount}, function(data){
			window.location = r+"cart";
		});
	}
}

cart.add = function(id) {
	$.post("cart_submit.php", { action: "add", additem: id}, function(data){
		window.location = r+"cart";
	});
}

cart.update = function() {
	postdata = $('#cartform').serialize();
	postdata += "&action=update";
	$.post("cart_submit.php", postdata, function(data){
		window.location = r+"cart";
	});
}

cart.remove = function(id) {
	$.post("cart_submit.php", { action: "remove", removeitem: id }, function(data){
		window.location = r+"cart";
	});
}


