// ########################################################################################## // JavaScript Cookie Shop Module, V.1 // ########################################################################################## // // Language Packs // --------------------- // You may include any language pack before freesitecart.asp in your HTML pages to change the language. // For example: // // // // Options for Programmers: OutputItemId = 'ID_'; OutputItemQuantity = 'quantity_'; OutputItemPrice = 'price_'; OutputItemname = 'name_'; OutputItemShipping = 'shipping_'; OutputItemAddtlInfo = 'ADDTLINFO_'; OutputOrderSubtotal = 'SUBTOTAL'; OutputOrderShipping = 'shipping'; OutputOrderTax = 'TAX'; OutputOrderTotal = 'TOTAL'; AppendItemNumToOutput = true; HiddenFieldsToCheckout = false; CartButtonPath = "http://www.freesitecart.com/cart/buttons/" // Language Strings // ---------------------- // These strings will not be used unless you have not included a language pack already. You should NOT modify these, but instead // modify the strings in language-**.js where ** is the language pack you are using. if ( !bLanguageDefined ) { strSorry = "I'm Sorry, your cart is full, please proceed to checkout."; strAdded = " added to your shopping cart."; strRemove = "Click 'Ok' to remove this product from your shopping cart."; strILabel = "Item"; strDLabel = "Description"; strQLabel = "Quantity"; strPLabel = "Price"; strSLabel = "Shipping"; strRLabel = "Update"; strTLabel = "Total"; strVLabel = "VAT"; strRButton= "Update"; strSUB = "Subtotal :"; strSHIP = "Delivery :"; strTAX = "VAT :"; strTOT = "Total :"; strErrQty = "Invalid Quantity."; strNewQty = 'Please enter new quantity:'; Language = 'en'; bLanguageDefined = true; } // Payment Processor Options: // PaymentProcessor = ''; // Capture Options for Everyone: if ( Currency == null ) Currency = 'GBP'; if ( GoogleCheckout != 'live' ) GoogleCheckout = 'test'; var ShipArray = new Array(); ShippingCountry = Trim(ShippingCountry,','); if ( ShippingCountry.length ) { ShipArray = ShippingCountry.split(','); } var ShipDes = new Array(); ShippingDescription = Trim(ShippingDescription,','); if ( ShippingCountry.length && ShippingDescription.length ) { ShipDes = ShippingDescription.split(','); } var ShipArrayUnique = new Array(); for (var i = 0; i < ShipArray.length; i++) { var xx = true; var ArrayVal = ShipArray[i]; for ( var j = i+1; j < ShipArray.length; j++) { if (ShipArray[j] == ArrayVal) xx = false; }; if ( xx == true ) ShipArrayUnique.push(ArrayVal) } var PostStrings = new Array(); if ( ShippingCountry.length ) { for (i=0;i 100) { CartOpacity = 60; } if (!parseInt(CartOpacitySpeed) || CartOpacitySpeed < 1 || CartOpacitySpeed > 100) { CartOpacitySpeed = 2000; } else { CartOpacitySpeed = CartOpacitySpeed * 20; } // if = 1 then instant ie no fade in if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.appVersion.indexOf("MSIE 7")!=-1) { CartOpacitySpeed = 1; } // remove the ie7 fade in/out lag if (!parseInt(CartButtonSet) || CartButtonSet < 0 || CartButtonSet > 9) { CartButtonSet = 1; } if (!CartWindowBG) { CartWindowBG = "#FFFFFF"; } if (!CartPageBG) { CartPageBG = "#FFFFFF"; } if (!parseInt(CartPageWidth)) { CartPageWidth = 700; } if (!parseInt(CartPageHeight)) { CartPageHeight = 400; } // ########################################################################################## // Initialise // ########################################################################################## document.write(""); document.write(""); document.getElementById('FreeSiteCartFramer').style.backgroundColor = CartWindowBG; document.getElementById('FreeSiteCart').style.backgroundColor = CartPageBG; document.getElementById('FreeSiteCart').style.width = CartPageWidth+'px'; document.getElementById('FreeSiteCart').style.height = CartPageHeight+'px'; document.getElementById('FreeSiteCartFooter').style.top = (CartPageHeight-44)+'px'; document.getElementById('FreeSiteCartContents').style.height = (CartPageHeight-60-44)+'px'; if (CartPageBorder) { document.getElementById('FreeSiteCart').style.borderWidth = "1px"; document.getElementById('FreeSiteCart').style.borderStyle = "solid"; document.getElementById('FreeSiteCart').style.borderColor = CartPageBorder; } var CartVisible = false; var OrderStatus = ""; //document.body.onload = function() { document.body.style.margin = "0px"; SetPage('FreeSiteCart','FreeSiteCartFramer'); } //need to set margin to 0 so framer covers whole page in IE //document.body.onresize = function() { SetPage('FreeSiteCart','FreeSiteCartFramer'); } //document.body.onscroll = function() { SetPage('FreeSiteCart','FreeSiteCartFramer'); } window.onload = function() { document.body.style.margin = "0px"; SetPage('FreeSiteCart','FreeSiteCartFramer'); } //need to set margin to 0 so framer covers whole page window.onresize = function() { SetPage('FreeSiteCart','FreeSiteCartFramer'); } window.onscroll = function() { SetPage('FreeSiteCart','FreeSiteCartFramer'); } // ########################################################################################## // FUNCTION: SetFramer // PURPOSE: Keep the Cart Framer in Full Window // ########################################################################################## function SetPage(cart,framer) { var pagesize = GetPageSize(); var arrayPageScroll = GetPageScrollTop(); if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) { yScroll = window.innerHeight + window.scrollMaxY; xScroll = window.innerWidth + window.scrollMaxX; var deff = document.documentElement; var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth; var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight; xScroll -= (window.innerWidth - wff); yScroll -= (window.innerHeight - hff); } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac yScroll = document.body.scrollHeight; xScroll = document.body.scrollWidth; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari yScroll = document.body.offsetHeight; xScroll = document.body.clientWidth; // replaced document.body.offsetWidth with clientWidth for "IE 6 without doctype" } document.getElementById(framer).style.height = yScroll+"px"; document.getElementById(framer).style.width = xScroll+"px"; document.getElementById(cart).style.left = (arrayPageScroll[0] + (pagesize[0] - CartPageWidth)/2)+"px"; document.getElementById(cart).style.top = (arrayPageScroll[1] + (pagesize[1] - CartPageHeight)/2)+"px"; } function GetPageScrollTop(){ var yScrolltop; var xScrollleft; if (self.pageYOffset || self.pageXOffset) { yScrolltop = self.pageYOffset; xScrollleft = self.pageXOffset; } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){ // Explorer 6 Strict yScrolltop = document.documentElement.scrollTop; xScrollleft = document.documentElement.scrollLeft; } else if (document.body) {// all other Explorers yScrolltop = document.body.scrollTop; xScrollleft = document.body.scrollLeft; } arrayPageScroll = new Array(xScrollleft,yScrolltop) return arrayPageScroll; } function GetPageSize(){ var de = document.documentElement; var w = document.body.clientWidth || window.innerWidth || self.innerWidth || (de&&de.clientWidth); // put the last bit in first for firefox var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight ; arrayPageSize = new Array(w,h) return arrayPageSize; } // ########################################################################################## // FUNCTION: Opacity // PARAMETERS: 'div id',opacity start,opacity end, millisecs // RETURNS: Nothing // PURPOSE: Hide or Show Basket // ########################################################################################## function Opacity(frid, fropacStart, fropacEnd, cid, copacStart, copacEnd) { //speed for each frame var speed = Math.round(CartOpacitySpeed / 100); var timer = 0; //alert (CartOpacitySpeed); //determine the direction for the blending, if start and end are the same nothing happens if(fropacStart > fropacEnd && CartVisible) { if ( CartOpacitySpeed == 1 ) { fropacStart = fropacEnd + 1; } for(i = fropacStart; i >= fropacEnd; i--) { setTimeout("changeOpac(" + i + ",'" + frid + "','down')",(timer * speed)); timer++; } setTimeout("Opacity2('" + cid + "'," + copacStart + "," + copacEnd + "," + speed + ")",CartOpacitySpeed); } else if(fropacStart < fropacEnd && !CartVisible) { if ( CartOpacitySpeed == 1 ) { fropacStart = fropacEnd - 1; } document.getElementById(frid).style.display = "inline"; for(i = fropacStart; i <= fropacEnd; i++) { setTimeout("changeOpac(" + i + ",'" + frid + "','up')",(timer * speed)); timer++; } setTimeout("Opacity2('" + cid + "'," + copacStart + "," + copacEnd + "," + speed + ")",CartOpacitySpeed); } } // force pause before second fade function Opacity2(cid, copacStart, copacEnd, speed) { var timer = 0; //alert ("cid:" + cid + " Start:" + copacStart + " End:" + copacEnd + " Speed:" + speed); //determine the direction for the blending, if start and end are the same nothing happens if(copacStart > copacEnd) { if ( CartOpacitySpeed == 1 ) { copacStart = copacEnd + 1;} for(i = copacStart; i >= copacEnd; i--) { setTimeout("changeOpac(" + i + ",'" + cid + "','down')",(timer * speed)); timer++; } } else if(copacStart < copacEnd) { if ( CartOpacitySpeed == 1 ) { copacStart = copacEnd - 1;} document.getElementById(cid).style.display = "inline"; for(i = copacStart; i <= copacEnd; i++) { setTimeout("changeOpac(" + i + ",'" + cid + "','up')",(timer * speed)); timer++; } } } //change the opacity for different browsers function changeOpac(opacity, id,direction) { var object = document.getElementById(id).style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; // IE if (direction == "down" && opacity == 0) { object.display = "none"; } } // ########################################################################################## // FUNCTION: CKquantity || // PARAMETERS: Quantity to || // RETURNS: Quantity as a number, and possible alert || // PURPOSE: Make sure quantity is represented as a number || // ########################################################################################## function CKquantity(checkString) { var strNewQuantity = ""; for ( i = 0; i < checkString.length; i++ ) { ch = checkString.substring(i, i+1); if ( (ch >= "0" && ch <= "9") || (ch == '.') ) strNewQuantity += ch; } if ( strNewQuantity.length < 1 ) strNewQuantity = "1"; return(strNewQuantity); } // ########################################################################################## // FUNCTION: AddToCart || // PARAMETERS: Form Object || // RETURNS: Cookie to user's browser, with prompt || // PURPOSE: Adds a product to the user's shopping cart || // ########################################################################################## function AddToCart(thisForm) { var TotalItems = 0; var bAlreadyInCart = false; var Notice = ""; TotalItems = GetCookie("NumberOrdered"); if ( TotalItems == null ) TotalItems = 0; if ( thisForm.item_code == null ) { item_code = ""; } else { item_code = thisForm.item_code.value; } if ( thisForm.name == null ) { name = ""; } else { name = thisForm.name.value; } if ( thisForm.price == null ) { price = "0.00"; } else { price = thisForm.price.value; } if ( thisForm.quantity == null ) { quantity = "1"; } else { quantity = CKquantity(thisForm.quantity.value); } if ( thisForm.size == null ) { size = "small"; } else { size = thisForm.size.value; } if ( thisForm.shipping == null ) { shipping = "0.00"; } else { shipping = thisForm.shipping.value; } if ( thisForm.shipping_additional == null ) { shipping_additional = "0.00"; } else { shipping_additional = thisForm.shipping_additional.value; } //Is this product already in the cart? If so, increment quantity instead of adding another. for ( i = 1; i <= TotalItems; i++ ) { NewOrder = "Order." + i; database = ""; database = GetCookie(NewOrder); Token0 = database.indexOf("|", 0); Token1 = database.indexOf("|", Token0+1); Token2 = database.indexOf("|", Token1+1); Token3 = database.indexOf("|", Token2+1); Token4 = database.indexOf("|", Token3+1); Token5 = database.indexOf("|", Token4+1); fields = new Array; fields[0] = database.substring( 0, Token0 ); // ID fields[1] = database.substring( Token0+1, Token1 ); // Qty fields[2] = database.substring( Token1+1, Token2 ); // Price fields[3] = database.substring( Token2+1, Token3 ); // Description fields[4] = database.substring( Token3+1, Token4 ); // Cost fields[5] = database.substring( Token4+1, Token5 ); // Add Cost fields[6] = database.substring( Token5+1, database.length ); // Size if ( fields[0] == item_code && fields[2] == price && fields[3] == name && fields[4] == shipping) { bAlreadyInCart = true; dbUpdatedOrder = item_code + "|" + (parseInt(quantity)+parseInt(fields[1])) + "|" + price + "|" + name + "|" + shipping + "|" + shipping_additional + "|" + size; strNewOrder = "Order." + i; DeleteCookie(strNewOrder, "/"); SetCookie(strNewOrder, dbUpdatedOrder, null, "/"); Notice = quantity + " " + name + strAdded; break; } } //end for if ( !bAlreadyInCart ) { TotalItems++; if ( TotalItems > 12 ) alert( strSorry ); else { dbUpdatedOrder = item_code + "|" + quantity + "|" + price + "|" + name + "|" + shipping + "|" + shipping_additional + "|" + size; strNewOrder = "Order." + TotalItems; SetCookie(strNewOrder, dbUpdatedOrder, null, "/"); SetCookie("NumberOrdered", TotalItems, null, "/"); Notice = quantity + " " + name + strAdded; } } ViewCart(); } // ########################################################################################## // FUNCTION: getCookieVal // PARAMETERS: offset // RETURNS: URL unescaped Cookie Value // PURPOSE: Get a specific value from a cookie // ########################################################################################## function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if ( endstr == -1 ) endstr = document.cookie.length; return(unescape(document.cookie.substring(offset, endstr))); } // ########################################################################################## // FUNCTION: FixCookieDate // PARAMETERS: date // RETURNS: date // PURPOSE: Fixes cookie date, stores back in date // ########################################################################################## function FixCookieDate (date) { var base = new Date(0); var skew = base.getTime(); date.setTime (date.getTime() - skew); } // ########################################################################################## // FUNCTION: GetCookie // PARAMETERS: name // RETURNS: Value in Cookie // PURPOSE: Retrieves cookie from users browser // ########################################################################################## function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while ( i < clen ) { var j = i + alen; if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j)); i = document.cookie.indexOf(" ", i) + 1; if ( i == 0 ) break; } return(null); } // ########################################################################################## // FUNCTION: SetCookie // PARAMETERS: name, value, expiration date, path, domain, security // RETURNS: Null // PURPOSE: Stores a cookie in the users browser // ########################################################################################## function SetCookie (name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } // ########################################################################################## // FUNCTION: DeleteCookie // PARAMETERS: Cookie name, path, domain // RETURNS: null // PURPOSE: Removes a cookie from users browser. // ########################################################################################## function DeleteCookie (name,path,domain) { if ( GetCookie(name) ) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } // ########################################################################################## // FUNCTION: MoneyFormat // PARAMETERS: Number to be formatted // RETURNS: Formatted Number - #.## format // ########################################################################################## function moneyFormat(input) { var dollars = Math.floor(input); var tmp = new String(input); for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) { if ( tmp.charAt(decimalAt)=="." ) { break; } } var cents = "" + Math.round(input * 100); cents = cents.substring(cents.length-2, cents.length) dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0; if ( cents == "0" ) { cents = "00"; } return(dollars + "." + cents); } // ########################################################################################## // FUNCTION: RemoveFromCart // PARAMETERS: Order Number to Remove // RETURNS: Null // PURPOSE: Removes an item from a users shopping cart // ########################################################################################## function RemoveFromCart(RemOrder) { if ( confirm( strRemove ) ) { NumberOrdered = GetCookie("NumberOrdered"); for ( i=RemOrder; i < NumberOrdered; i++ ) { NewOrder1 = "Order." + (i+1); NewOrder2 = "Order." + (i); database = GetCookie(NewOrder1); SetCookie (NewOrder2, database, null, "/"); } NewOrder = "Order." + NumberOrdered; SetCookie ("NumberOrdered", NumberOrdered-1, null, "/"); DeleteCookie(NewOrder, "/"); ViewCart(); } else { ViewCart(); // set value back to original value by refreshing data } } // ########################################################################################## // FUNCTION: ChangeQuantity // PARAMETERS: Order Number to Change Quantity // RETURNS: Null // PURPOSE: Changes quantity of an item in the shopping cart // ########################################################################################## function ChangeQuantity(OrderItem,NewQuantity) { if ( NewQuantity == 0 ) { RemoveFromCart(OrderItem); } else { NewQuantity = parseInt(NewQuantity); if ( isNaN(NewQuantity) ) { alert( strErrQty ); ViewCart(); } else { NewOrder = "Order." + OrderItem; database = ""; database = GetCookie(NewOrder); Token0 = database.indexOf("|", 0); Token1 = database.indexOf("|", Token0+1); Token2 = database.indexOf("|", Token1+1); Token3 = database.indexOf("|", Token2+1); Token4 = database.indexOf("|", Token3+1); Token5 = database.indexOf("|", Token4+1); fields = new Array; fields[0] = database.substring( 0, Token0 ); fields[1] = database.substring( Token0+1, Token1 ); fields[2] = database.substring( Token1+1, Token2 ); fields[3] = database.substring( Token2+1, Token3 ); fields[4] = database.substring( Token3+1, Token4 ); fields[5] = database.substring( Token4+1, Token5 ); fields[6] = database.substring( Token5+1, database.length ); dbUpdatedOrder = fields[0] + "|" + NewQuantity + "|" + fields[2] + "|" + fields[3] + "|" + fields[4] + "|" + fields[5] + "|" + fields[6]; strNewOrder = "Order." + OrderItem; DeleteCookie(strNewOrder, "/"); SetCookie(strNewOrder, dbUpdatedOrder, null, "/"); ViewCart(); } } } // ########################################################################################## // FUNCTION: RadioChecked // PARAMETERS: Radio button to check // RETURNS: True if a radio has been checked // PURPOSE: Form fillin validation // ########################################################################################## function RadioChecked( radiobutton ) { var bChecked = false; var rlen = radiobutton.length; for ( i=0; i < rlen; i++ ) { if ( radiobutton[i].checked ) bChecked = true; } return bChecked; } // ########################################################################################## // FUNCTION: QueryString // PARAMETERS: Key to read // RETURNS: value of key // PURPOSE: Read data passed in via GET mode // ########################################################################################## QueryString.keys = new Array(); QueryString.values = new Array(); function QueryString(key) { var value = null; for (var i=0;i= 0) { var argname = pairs[i].substring(0,pos); var value = pairs[i].substring(pos+1); QueryString.keys[QueryString.keys.length] = argname; QueryString.values[QueryString.values.length] = value; } } } // ########################################################################################## // FUNCTION: Trim // PARAMETERS: str - the string, char - the character to trim // ########################################################################################## function Trim(str,char) { while(str.charAt(0) == (char) ) { str = str.substring(1); } while(str.charAt(str.length-1) == char ) { str = str.substring(0,str.length-1); } return str; } // ########################################################################################## // FUNCTION: ViewCart // PARAMETERS: Null // RETURNS: Product Table Written to Document // PURPOSE: Draws current cart product table on HTML page // ########################################################################################## function ViewCart( ) { var TotalItems = 0; //Number of products ordered var RowTotal = 0; //Total row cost ( price * qty ) var BaseShipping = 0; //Used to calculate shipping fields or to establish base rate for shipping depending on ShippingCalculation var AdShipping = 0; //Used to calculate shipping_additional fields for all items var RowTax = 0; //Tax of items per row var SubTotal = 0; //SubTotal for items. var SubTax = 0; //Item Tax Total. var SubTotalTaxed = 0; //SubTotal for items inc Tax. var ShippingSelected = 0; //Shipping method selected by user var SumShipping = 0; //Total for shipping not incl tax (pre surcharge array). var ShippingSurcharge = new Array(); //ShippingSurchargeSML, ShippingSurchargeMED or ShippingSurchargeBIG depending on which is used var FinalShipping = new Array(); //Total for shipping not incl tax var FinalShippingTax = new Array(); //Shipping Tax var FinalShippingTaxed = new Array(); //Shipping incl Tax var FinalTax = new Array(); //All taxes added together var FinalTotal = new Array(); //Grand Total var strOutput = ""; //String to be written to page var strForm = ""; //The form TotalItems = GetCookie("NumberOrdered"); if ( TotalItems == null ) TotalItems = 0; ShippingSelected = GetCookie("ShippingSelected"); if ( ShippingSelected == null ) ShippingSelected = 0; OrderStatus = GetCookie("OrderStatus"); if ( GoogleUrchin != "" || GoogleUrchin != null ) { pageTracker._trackPageview('/cart/view_cart'); } strOutput = "
" if ( GoogleCheckout == "live" ) { strGoogle = "
"; //form for the live data } else { strGoogle = "
"; //form for the test data } if ( OrderStatus == "" || OrderStatus == null ) { if ( TotalItems == 0 ) { strOutput += ""; strOutput += "

Your cart is empty

"; } else { strOutput += "
"; strOutput += ""; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; var ItemSize = "small"; var g = 0; // used to iterate items for google as google doesnt support tax per item, only per row or on total for ( i = 1; i <= TotalItems; i++ ) { NewOrder = "Order." + i; database = ""; database = GetCookie(NewOrder); Token0 = database.indexOf("|", 0); Token1 = database.indexOf("|", Token0+1); Token2 = database.indexOf("|", Token1+1); Token3 = database.indexOf("|", Token2+1); Token4 = database.indexOf("|", Token3+1); Token5 = database.indexOf("|", Token4+1); fields = new Array; fields[0] = database.substring( 0, Token0 ); // Product ID fields[1] = database.substring( Token0+1, Token1 ); // Quantity fields[2] = database.substring( Token1+1, Token2 ); // Price fields[3] = database.substring( Token2+1, Token3 ); // Product name/Description fields[4] = database.substring( Token3+1, Token4 ); // Shipping Cost fields[5] = database.substring( Token4+1, Token5 ); // Shipping Additional Cost fields[6] = database.substring( Token5+1, database.length ).toLowerCase(); // Size RowTotal = (parseInt(fields[1]) * parseFloat(fields[2]) ); if ( TaxRate > 0 ) { if ( PriceIncludesTax ) { ItemPrice = moneyFormat(parseFloat(fields[2]) / (1 + (TaxRate / 100))); RowTax = parseInt(fields[1]) * moneyFormat((parseFloat(fields[2]) - (parseFloat(fields[2]) / (1 + (TaxRate / 100))))); SubTotal += (RowTotal - RowTax); SubTotalTaxed += (RowTotal); } else { ItemPrice = moneyFormat(parseFloat(fields[2])); RowTax = parseInt(fields[1]) * (parseFloat(parseFloat(fields[2]) * TaxRate / 100)); SubTotal += (RowTotal); } SubTax += (RowTax); for ( k = 1; k <= fields[1]; k++ ) { // loop to seperate each item as google tax supports only per line or total and not per item g += 1; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; // untaxed price for google strGoogle += "
"; } } else { SubTotal += (RowTotal); strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; // untaxed price for google strGoogle += "
"; } // if ( ShippingCalculation == 1 ) { BaseShipping += parseFloat(fields[4]); } // if ( ShippingCalculation == 2 ) { // If (BaseShipping <= parseFloat(fields[4])) { BaseShipping = parseFloat(fields[4]); } // } AdShipping += ((parseInt(fields[1])-1) * parseFloat(fields[5]) ); if ( fields[6] == "big" ) { ItemSize = "big" } if ( ItemSize != "big" ) { if ( fields[6] == "medium" ) { ItemSize = "medium"; } } strOutput += ""; strOutput += ""; strOutput += ""; strOutput += ""; } // end for loop if ( PriceIncludesTax ) { // then display subtotal including tax strOutput += ""; } else { strOutput += ""; } SumShipping = BaseShipping + AdShipping; // get total before working out array and tax if ( ShippingCalculation == 0 ) { SumShipping = 0 } if ( ShipArray.length ) { switch ( ItemSize ) { case "small" : if ( !ShippingSurchargeSML.length < 1 ) { ShippingSurcharge = ShippingSurchargeSML.split(','); } break; case "medium" : if ( !ShippingSurchargeMED.length < 1 ) { ShippingSurcharge = ShippingSurchargeMED.split(','); } break; default : if ( !ShippingSurchargeBIG.length < 1 ) { ShippingSurcharge = ShippingSurchargeBIG.split(','); } } } else { ShippingSurcharge[0] = 0; } if ( TaxRate > 0 ) { if ( ShippingIncludesTax ) { if ( ShipArray.length ) { j = ShipArray.length; } else { j = 1; } for ( i = 0; i <= j-1; i++ ) { ShippingSurcharge[i] = ShippingSurcharge[i]*1; FinalShippingTaxed[i] = SumShipping + ShippingSurcharge[i]; FinalShippingTax[i] = FinalShippingTaxed[i] - (FinalShippingTaxed[i] / (1 + (TaxRate / 100))); FinalShipping[i] = FinalShippingTaxed[i] - FinalShippingTax[i]; FinalTax[i] = SubTax + FinalShippingTax[i]; FinalTotal[i] = SubTotal + SubTax + FinalShipping[i] +FinalShippingTax[i]; } } else { FinalShippingTax[0] = (parseFloat(SumShipping * TaxRate / 100)); FinalShippingTaxed[0] = SumShipping + FinalShippingTax[0]; FinalTax[0] = SubTax + FinalShippingTax[0]; FinalTotal[0] = SubTotal + SubTax + SumShipping +FinalShippingTax[0]; } } if ( FinalShipping[ShippingSelected] > 0 || DisplayFreeShipping ) { strOutput += ""; } if ( TaxRate > 0 ) { if ( PriceIncludesTax ) { // then display total first and tax seperately. strOutput += "
"+strILabel+""+strDLabel+""+strQLabel+""+strPLabel+""+strTLabel+""+strRLabel+"
" + fields[0] + "" + fields[3] + ""+ moneyFormat(fields[2]) + ""+ moneyFormat(RowTotal) + "
"+strSUB+"" + moneyFormat(SubTotalTaxed) + "
"+strSUB+"" + moneyFormat(SubTotal) + "
"+strSHIP+" "; var strPostArray = ""; if ( ShipArray.length ) { strOutput += ""; strGoogle += "
"; strGoogle += "
"; var l = 0; if ( PostArray[i].length ) { for ( j = 0; j < PostArray[i].length; j++ ) { if ( PostArray[i][j].length ) { l += 1; strGoogle += "
"; strGoogle += "
"; } } } if ( l == 0 ) strGoogle += "
"; var l = 0; if ( ExclArray[i].length ) { for ( j = 0; j < ExclArray[i].length; j++ ) { if ( ExclArray[i][j].length ) { l += 1; strGoogle += "
"; strGoogle += "
"; } } } } strOutput += "" } strOutput += "
"; if ( PriceIncludesTax ) { // then display shipping including tax. if ( FinalShippingTaxed[ShippingSelected] > 0 ) { strOutput += moneyFormat(FinalShippingTaxed[ShippingSelected]) } else { strOutput += "FREE" } } else { // display shipping excluding tax if ( FinalShipping[ShippingSelected] > 0 ) { strOutput += FinalShipping[ShippingSelected] } else { strOutput += "FREE" } } strOutput += "
"+strTOT+"" + moneyFormat(FinalTotal[ShippingSelected]) + "
"; } else { // show total tax then total strOutput += "
"+strTAX+Currency+"" + FinalTax[ShippingSelected] + "
"+strTOT+Currency+"" + FinalTotal[ShippingSelected] + "
"; } strGoogle += "
"; strGoogle += "
"; strGoogle += "
"; } else { // just show total strOutput += ""+strTOT+Currency+"" + FinalTotal[ShippingSelected] + ""; } strOutput += "
All Units of Currency are in (" + Currency + ")
This Order Contains " + Currency + " " + moneyFormat(FinalTax[ShippingSelected]) + " VAT."; } strOutput += "" strOutput += "" strOutput += "" + ShippingInformation + "
" strGoogle += "
" //strGoogle = strGoogle.replace(//g,">"); strGoogle = strGoogle.replace(/<br>/g,"
"); strGoogle = strGoogle.replace(/
/g,""); //document.getElementById('FreeSiteCartContents').innerHTML=strOutput + "
" + strGoogle; document.getElementById('FreeSiteCartContents').innerHTML=strOutput; if ( GoogleID && TotalItems > 0 && FinalTax[ShippingSelected] ) { document.getElementById('FreeSiteCartCheckout').innerHTML=strGoogle; } else { document.getElementById('FreeSiteCartCheckout').innerHTML=""; } } else { if ( OrderStatus = "GoogleSubmitted" ) { strOutput += "

This basket has already been submitted to Google Checkout for Processing.

"; strOutput += "

Click here to re-instate the contents of this basket.

" strOutput += "

Click here to clear the contents of this basket.

" document.getElementById('FreeSiteCartContents').innerHTML=strOutput; } } Opacity('FreeSiteCartFramer',0,CartOpacity,'FreeSiteCart',0,100); CartVisible = true; } // ########################################################################################## // FUNCTION: MonitorUsers // PURPOSE: Writes User Checkouts to the database // ########################################################################################## function MonitorUsers( ) { // Define the location of count.asp // Using a path, you may use this code in any subfolder var StatCounteXfile='http://www.freesitecart.com/stats/count.asp'; var StatCounteXd=new Date(); var StatCounteXs=StatCounteXd.getSeconds(); var StatCounteXm=StatCounteXd.getMinutes(); var StatCounteXx=StatCounteXs*StatCounteXm; StatCounteXf='' + escape(document.referrer); if (navigator.appName=='Netscape'){StatCounteXb='NS';} if (navigator.appName=='Microsoft Internet Explorer'){StatCounteXb='MSIE';} if (navigator.appVersion.indexOf('MSIE 3')>0) {StatCounteXb='MSIE';} StatCounteXu='' + escape(document.URL); StatCounteXw=screen.width; StatCounteXh=screen.height; StatCounteXv=navigator.appName; StatCounteXfs = window.screen.fontSmoothingEnabled; if (StatCounteXv != 'Netscape') {StatCounteXc=screen.colorDepth;} else {StatCounteXc=screen.pixelDepth;} StatCounteXj=navigator.javaEnabled(); StatCounteXinfo='w=' + StatCounteXw + '&h=' + StatCounteXh + '&c=' + StatCounteXc + '&r=' + StatCounteXf + '&u='+ StatCounteXu + '&fs=' + StatCounteXfs + '&b=' + StatCounteXb + '&x=' + StatCounteXx; document.getElementById('FreeSiteCartUser').innerHTML =""; }