function addToCart(npid) {
	DWREngine._execute (_cfscriptLocation, null, "addToCart", npid, getResultAddToCart);
	document.getElementById(npid).src = '/checkout/images/adding_to_cart.gif';
	//alert('addToCart() ran: ' + npid);
}

function getResultAddToCart(result) {
	//alert ("getResultAddToCart running");
	//alert('Cart Count: ' + result[3]);
	//alert('imageid:' + result[1]);
	var updateCartDisplay = 0;
	
	switch (result[0]) {
    case "0":
        alert('Action Failed, Please try again.');
        break;
		
	case "1":
        alert('Fail');
        break;

    case "2":
        //alert('Success');
		// modify add to cart image
		imgName = result[1]; // 2nd array element contains product id which is also id of add to cart img
		document.getElementById(imgName).src = '/checkout/images/added_to_cart.gif';
		updateCartDisplay = 1;
        break;
	
	case "3":
        //alert('Already Added');
		imgName = result[1]; // 2nd array element contains product id which is also id of add to cart img
		document.getElementById(imgName).src = '/checkout/images/added_to_cart.gif';
        break; 
	
	case "4":
        alert('Exception');
        break;
		
	case "5":
        //alert('To purchase this product, specific Options are required, press OK to be redirected to product page');
		redirectUrl = 'http://www.yourremix.com/detail/index.cfm?npid=' + result[1] + '&err=errOptionRequired&missingoptions=2';
		window.location.href=redirectUrl;
		//redirect to detail page as options required (result[1])
        break;
	
	case "6":
		redirectUrl = 'http://www.yourremix.com/account/video_section_request.cfm';
		window.location.href=redirectUrl;
        break;
		
    default:
        redirectUrl = 'http://www.yourremix.com/detail/index.cfm?npid=' + result[1];
		window.location.href=redirectUrl;
		//alert('unknown result');
        break;
    }
	
	if (updateCartDisplay == 1) {
		document.getElementById("cartContentsDisplay").innerHTML = result[4];
	}
}