$( function() {
	$("#newsletter-signup").click( function() {
		$.facebox({ajax : "ajax/newsletter-signup.asp"});
	});
});

function showMiniFreightCharges()
{
	$.facebox({ajax : "freightcharges.asp" });
}

function applyCode(type, code)
{
	$.post("ajax/applycode.asp", { type: type, code: code }, function (xml) {
		if ($("status", xml).text() == "ok") {
			alert("Your " + type + " code has been applied successfully, please wait while we update your total.");
			location.reload();
		}  else {
			alert("Your " + type + " code could not be found.");
		}
	});
}

function viewCart()
{
	$.post("ajax/viewcart.asp?v=1", function(html) {
		$.facebox(html);
	});
}

function removeItem(index)
{
	$.post("ajax/removeitem.asp", { index : index }, viewCart);
}

function updateCart()
{
	$("#cart-summary-popup").submit( function() {
		var url = $(this).attr("action");
		var data = $(this).serialize();
		$.post(url, data, function() {
			$("#cart-summary-message").html("Your cart has been updated.");
		});
		return false;
	});
}

function payByPayPal()
{
	$.post("ajax/paybypaypal.asp", function(html) {
		$.facebox(html);
	});
}

function PayPal(country)
{
	if( $.trim(country) != "" ) {
		location.href = "orderprocess.asp?paypal=true&country=" + country;
	} else {
		alert("Please select a country.");
	}
}

function showBigImage(name)
{
	$(".big-image").attr("src", "images/xlimage/" + name);
}
