var numbers=new Array("One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten");function addToCart(itemID,price,description,code,title,released,boxShotUrl,preOwned,element){GameFunctions.AddToCart(itemID,preOwned,function(result){var splitresults=result.split("|");var itemTotal=parseInt(splitresults[0]);var numItems=$("numCartItems").childElements()[0];var cartTotal=$("cartTotal").childElements()[0];var lastItemTitle=$("last-item-text").childElements()[1];var lastItemPlatform=$("last-item-text").childElements()[2];var lastItemImg=$("last-item-image").childElements()[0];var boxShotImg=splitresults[5];var lastItemQuantity=splitresults[6];if(itemTotal>0){$("last-item").down().style.display="block"}if(itemTotal>1){numItems.innerHTML=itemTotal+" items"}else{numItems.innerHTML=itemTotal+" item"}cartTotal.innerHTML=splitresults[1];lastItemTitle.innerHTML=splitresults[3];lastItemPlatform.innerHTML=splitresults[4];lastItemImg.writeAttribute("height","45");lastItemImg.writeAttribute("src",boxShotImg);var sb=$("SpeechBubble");var sb_middle=sb.childElements()[1];var sb_msg=sb_middle.childElements()[1];var hasHave="have";if(splitresults[2]=="Max Quantity"){sb_msg.innerHTML="You have reached the maximum allowed quantity for purchase and will be unable to purchase any additional copies of this item."}else{var quantityNumber;if(lastItemQuantity<=10){quantityNumber=numbers[lastItemQuantity-1]}else{quantityNumber=lastItemQuantity}if(lastItemQuantity==1){hasHave="has"}sb_msg.innerHTML=quantityNumber+" "+splitresults[3]+" "+hasHave+" been added to your cart!"}element=$(element);var buttonWidth=element.getWidth();var buttonHeight=element.getHeight();var buttonOffset=element.cumulativeOffset();var bubbleWidth=sb.getWidth();var bubbleHeight=sb.getHeight();var containerOffset=$("container").cumulativeOffset();var bubbleBottom=buttonOffset[1]-containerOffset[1]-bubbleHeight+10;var bubbleLeft=buttonOffset[0]+(buttonWidth/2)-(bubbleWidth/2)-containerOffset[0];sb.setStyle({top:bubbleBottom+"px",left:bubbleLeft+"px"});sb.show()})};
