function applyDiscount(productID) {
	//alert('click');
	sDiscountCode = $('.discount_code:nth(1)').val();
	//alert(sDiscountCode);
	$.ajax({
			url: 'checkCode.php',
			data: 'code='+sDiscountCode+'&product='+productID,
			dataType: 'json',
			success: handleDiscount
			});
	$('.loading').html('<img src="../images/loading-spinner.gif" alt="Loading..."> ');
}

function setLogoOption(oCheck) {
	if (oCheck.checked) {
		$('#paypal-logo').val('Yes');
	}
}

function continueOrder() {
	if ($('.logo_options:nth(1)').css('display') !== 'none') {
		//alert($('.company_name:nth(1)').val());
		if($('.company_name:nth(1)').val() == '' && $('.add_logo_yes:nth(1)').attr("checked")) {
			alert("You must enter your company name.");
			return false;
		} else {
			$('#company_option').val($('.company_name:nth(1)').val());
		}
	}
	document.forms['PayPal'].submit();
	TB_remove();
	return true;
}

function handleDiscount(jData) {
	//Kill the loading GIF
	$('.loading').html('');
	//Get the message
	sMessage = jData['message'];
	
	
	if (jData['match']) {
		$('input#paypal-price').val(jData['price']);
		sMessage = sMessage + ' <span class="price">$' + jData['price'] + '</span>';
		$('.logo_options').slideDown();
	}
	
	$('.response-message').html(sMessage);
	$('.response-message').show();
}
