function addToCart(npid) {
	DWREngine._execute (_cfscriptLocation, null, "addToCart", npid, getResultAddToCart);
	if (document.getElementById(npid).src == 'http://www.remixjunkee.com/images/addtocart_sm.png') { document.getElementById(npid).src = '/images/addtocartworking_sm.png'; }
	else { document.getElementById(npid).src = '/images/addtocartworking.png'; }
	//document.getElementById(npid).src = '/images/addtocartworking.png';
	//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
		if (document.getElementById(imgName).src == 'http://www.remixjunkee.com/images/addtocartworking_sm.png') { document.getElementById(imgName).src = '/images/inyourcart_sm.png'; }
		else { document.getElementById(imgName).src = '/images/inyourcart.png'; }
		updateCartDisplay = 1;
		document.getElementById(imgName).onclick = function(){};
        break;
	
	case "3":
        //alert('Already Added');
		imgName = result[1]; // 2nd array element contains product id which is also id of add to cart img
		if (document.getElementById(imgName).src == 'http://www.remixjunkee.com/images/addtocartworking_sm.png') { document.getElementById(imgName).src = '/images/inyourcart_sm.png'; }
		else { document.getElementById(imgName).src = '/images/inyourcart.png'; }
 		document.getElementById(imgName).onclick = function(){};
        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.remixjunkee.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.remixjunkee.com/account/video_section_request.cfm';
		//window.location.href=redirectUrl;
        break;
		
    default:
        redirectUrl = 'http://www.remixjunkee.com/detail/?npid=' + result[1];
		window.location.href=redirectUrl;
		//alert('unknown result');
        break;
    }
	
	if (updateCartDisplay == 1) {
		document.getElementById("cartItemCountDisplay").innerHTML = result[3];
		//document.getElementById("cartItemAddedDisplay").innerHTML = ' Updated';
	}
}