home *** CD-ROM | disk | FTP | other *** search
- function setCookie(name, value, expire) {
- document.cookie = name + "=" + escape(value) + "; path=/" + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
- }
-
- function createRequestObject(){
- var request = new Object(); // Creates a new request object.
- var nameVal = ""; // Holds array for a single name-value pair.
- var inString = location.search; // Strips query string from URL.
- var separator = ","; // Character used to separate multiple values.
-
- // If URL contains a query string, grabs it.
-
- if (inString.charAt(0) == "?")
- {
- // Removes "?" character from query string.
- inString = inString.substring(1, inString.length);
- // Separates query string into name-value pairs.
- keypairs = inString.split("&");
- // Loops through name-value pairs.
- for (var i=0; i < keypairs.length; i++)
- {
- // Splits name-value into array (nameVal[0]=name, nameVal[1]=value).
- nameVal = keypairs[i].split("=");
- // Replaces "+" characters with spaces and then unescapes name-value pair.
- for (a in nameVal)
- {
- nameVal[a] = nameVal[a].replace(/\+/g," ");
- nameVal[a] = unescape(nameVal[a]);
- }
- // Checks to see if name already exists in request object
- // (since select lists may contain multiple values).
- if (request[nameVal[0]])
- {
- request[nameVal[0]] += separator + nameVal[1];
- }
- else
- {
- request[nameVal[0]] = nameVal[1];
- }
- }
- }
- return request;
- }
-
- function getTrackingID(){
- request = createRequestObject();
- if(request.itrackingid){
- setCookie("source",request.itrackingid);
- }
- }
-
- function getPOI(){
- request = createRequestObject();
- if(request.poi){
- setCookie("product",request.poi);
- }
- }
-
-
- function getCookie(Name) {
- var search = Name + "=";
- if (document.cookie.length > 0) { // if there are any cookies
- offset = document.cookie.indexOf(search);
- if (offset != -1) { // if cookie exists
- offset += search.length;
- // set index of beginning of value
- end = document.cookie.indexOf(";", offset);
- // set index of end of cookie value
- if (end == -1)
- end = document.cookie.length;
- return unescape(document.cookie.substring(offset, end))
- }
- }
- }
-
- getTrackingID();
- getPOI();