function getAvailabilityStatus(productCode,quantity){
	
	$.post(sitePath+"availabilitystatus.htm",
	{	
		productCode:productCode,
		quantity:quantity
	},
	function(data)
	{			
		eval(data);
		var productCodeDiv = "#"+productCode+"Avail";		
		$(productCodeDiv).html(obj.message);	
	},
	"html" );
}

function addToBasket(productCode,productId){	
	var qtyObj = document.getElementById(productId);
	if(qtyObj.value==""){
		alert("Please enter the quantity for each product you would like to add to the basket");
		qtyObj.focus();
	}
	else if(!isNum(qtyObj)){
		qtyObj.value="";
		alert("'The quantity you have entered appears to be invalid. Could you please re-enter the quantity");
		qtyObj.focus();
	}
	else{
		//addToBasktDivHide(productCode);
		$.post(sitePath+"availabilitystatus.htm",
				{	
					productCode:productCode,
					quantity:qtyObj.value
				},
				function(data)
				{			
					eval(data);
					var productCodeDiv = "#"+productCode+"Avail";					
					$(productCodeDiv).html(obj.message);
					if(obj.message=="Sold Out"){
						alert(obj.message);
					}
					else{
						var showBasket = true;
						if(obj.message != "In Stock"){
							showBasket = true;
							//if(confirm(obj.message)){
								//showBasket = true;
							//}
						}		
							
						if(showBasket == true){
							$.post(sitePath+"additemtobasket.htm",
							{	
								productCode:productCode,
								quantity:qtyObj.value
							},
							function(data)
							{			
								//addToBasktDivShow(productCode);
								basketboxwrite();
								//alert("Light box starts from product page ....");
								eval(data);	
								//alert(data);
						  		var code = obj.code;
						  		var qty = obj.qty;
						  		//alert(code +" && "+qty)	
								tb_show('The following item has been added to your basket',''+sitePath+'showbasketlightbox.htm?productCode='+code+'&productQuantity='+qty+'&keepThis=true&amp;TB_iframe=true&amp;height=100&amp;width=430');
			
								//scrollBasketDown();
							},
							"html" );
							
							//document.location.href= sitePath+ "additemtobasket.htm?productCode="+productCode+"&quantity="+qtyObj.value;
						}
					}
				},
		"html" );
	}
}

function setPromoCode(){
	//alert("PromoCode::"+trim(document.frmPromoCode.promoCode.value));
	if(trim(document.frmPromoCode.promoCode.value)!="" && trim(document.frmPromoCode.promoCode.value)!="Promotional Code" ){
    	$.post(sitePath+"checkvalidpromocode.htm",
    	{	
    		promoCode:trim(document.frmPromoCode.promoCode.value)
    	},
    	function(data)
    	{			
    		eval(data);
    		//alert(obj.checkValidPromo);
    		if(obj.checkValidPromo=='true'){
    			document.frmPromoCode.submit();
    		}
    		else{
    			alert("Please Enter the Valid Promo Code");
    		}
    	},
    	"html" );
		
	}
	else{
		alert("Please Enter the Promo Code");
	}
}

