var cartid = ""; // First, check the address bar for a cart_id var STDIN = unescape(location.search.replace(/\+/g,' ')); STDIN = STDIN.substring(1).split('&'); for(i=0; i < STDIN.length; i++){ STDIN[i] = STDIN[i].split('='); if(STDIN[i][0] == "cart_id" || STDIN[i][0] == "cartid"){ cartid = STDIN[i][1]; } } if(cartid == ""){ // If it's empty, see if the cart_id is set in the ip file or cookie // using the cartid.cgi script cartid = "<!--#include virtual="/cgi-bin/cartid.cgi" -->"; } if(cartid != ""){ // If we have a cart_id, add it to ALL the links on the current page for(i = 0;i < document.links.length;i++){ // Get the link href var myLink = document.links[i].href; var sPage = myLink.substring(myLink.lastIndexOf('/') + 1); // skip mailto and javascript links if(sPage.substring(0,6) == "Mailto" || sPage.substring(0,6) == "mailto"){ continue; } if(sPage.substring(0,10) == "javascript" || sPage.substring(0,10) == "Javascript"){ continue; } if(sPage.substring(0,13) == "quikstore.pl"){ // If this is a link to the quikstore.cgi, just add it to the end document.links[i].href = myLink + "&cart_id=" + cartid; } else{ // Otherwise, add it to the page name document.links[i].href = myLink + "?cart_id=" + cartid; } } // Add the cart_id to any hidden fields in forms on the page for(i = 0;i < document.forms.length;i++){ if(document.forms[i]["cart_id"]){ document.forms[i]["cart_id"].value = cartid; } } } 