﻿// JScript File

function zp_replaceFunctions(sUrl, sTargetName, sHostUrl) {
    zp_target = sTargetName;
    zp_hostUrl = sHostUrl;
    
    // "Foregående ordrer"
    if( sUrl.indexOf("page=purchasecart") != -1 ) {
        if( sUrl.indexOf("zaction=") != -1 ) {    
            //Reload cart
            document.location.href = sHostUrl + "?zpider.target=main,cart&zpider.raw-action=" + 
                escape("main.aspx?page=purchasecart") + ";" +
                escape("main.aspx?page=shoppingcart");
        } else {
            // Replace function
            AddToShoppingCart = function(page, lineno, amount) {        
                zp_AddToShoppingCart(page, lineno, amount, sUrl, sTargetName, sHostUrl);
            }    
        }
    }
}



function zp_AddToShoppingCart(page, lineno, amount, sUrl, sTargetName, sHostUrl)
      {         
        var sArgs = "";              
         if (lineno)
         {
            sArgs += '&zaction=addline&cartlineno=' + lineno + '&amount=' + amount;            
         }
         else
         {
            sArgs += '&zaction=addall';            
         }                  

         document.sd.action = sHostUrl + "?zpider.target=" + sTargetName + "&zpider.raw-action=" 
            + escape("main.aspx?page=purchasecart" + sArgs);
         
         document.sd.submit();
      }