$(document).ready(function() {
var imgObj = new Image();
imgObj.src = '/images/add-to-cart-over.jpg';
imgObj.src = '/images/checkout-over.jpg';
imgObj.src = '/images/keep-shopping-over.jpg';
imgObj.src = '/images/mailorder-over.jpg';
imgObj.src = '/images/preview-over.jpg';
imgObj.src = '/images/submit-over.jpg';
imgObj.src = '/images/updateqty-over.gif';
imgObj.src = '/images/view-gallery-btn-over.jpg';
imgObj.src = '/images/X-over.gif';

	if ($("#CURR_PAGE").val() == 'purchase') {
		$("input@[name=poid]").click(function() {
			var tmp = $(this).attr("rel").split(":");
			var price = tmp[0];
			var psize = tmp[1].split("x");
			
			$("#priceDisplay span").html(price);
			$("#preview-img").attr("src", "/phpthumb/phpThumb.php?src=/images/photos/" + $("#preview-img").attr("rel") + "&w=" + psize[0] + "&h=" + psize[1] + "&zc=1");
		});
		
		if (!$("input@[name=poid]:checked").val()) {
			$("input[@name=poid]:nth(0)").click();
		}
		
		/*
		$("a.photo").click(function(e) {
			$.ajax({
				url: './loadpic.php?pid=' + $(this).attr("rel"),
				dataType: 'script'
			});
		
			e.preventDefault();
		});
		*/
		
		$(".add2cart").click(function(e) {
			if ($("input@[name=poid]:checked").val()) {
				$.ajax({
					url: '/cart.php?do=add&pid=' + $("#currPicId").val() + '&poid=' + $("input@[name=poid]:checked").val(),
					dataType: 'script'
				});
			} else {
				alert('Please choose a size and print option');
			}
			
			e.preventDefault();
		});
		
		$(".add2cart").hover(function() {
			$(this).attr("src", "/images/add-to-cart-over.jpg");
		}, function() {
			$(this).attr("src", "/images/add-to-cart-btn.jpg");
		});
		
		$("#preview-btn").hover(function() {
			$(this).attr("src", "/images/preview-over.jpg");
		}, function() {
			$(this).attr("src", "/images/preview-btn.jpg");
		});
	}  else if ($("#CURR_PAGE").val() == 'cart') {
		$(".dellink").click(function(e) {
			if (confirm('Are you sure you want to delete this item from your cart?')) {
				var cid = $(this).attr("rel");

				$.ajax({
					url: '/cart.php?do=delete&cid=' + cid,
					dataType: 'script'
				});
			}
			
			e.preventDefault();
		});
		
		$(".qtylink").click(function(e) {
			var cid = $(this).attr("rel");
			var qty = $("#qty" + cid).val();

			$.ajax({
				url: '/cart.php?do=update_qty&cid=' + cid + '&qty=' + qty,
				dataType: 'script'
			});
			
			e.preventDefault();
		});

	} else if ($("#CURR_PAGE").val() == 'contact') {
		$("#submit-btn").hover(function() {
			$(this).attr("src", "/images/submit-over.jpg");
		}, function() {
			$(this).attr("src", "/images/submit-btn.jpg");
		});
	}
});
