var productImages = [];
// Preloaded image. ID = 1482
productImages[1482] = new Image();
productImages[1482].src="/image/product/medium/jungle-tort-profile.jpg";
productImages[1482].alt = "Otis Flux Otis Flux Jungle Tort with Cool Grey Lens";
// Preloaded image. ID = 1483
productImages[1483] = new Image();
productImages[1483].src="/image/product/medium/jungle-tort-front.jpg";
productImages[1483].alt = "Otis Flux Otis Flux Jungle Tort with Cool Grey Lens";
// Preloaded image. ID = 1484
productImages[1484] = new Image();
productImages[1484].src="/image/product/medium/jungle-tort-side.jpg";
productImages[1484].alt = "Otis Flux Otis Flux Jungle Tort with Cool Grey Lens";
// Preloaded image. ID = 1485
productImages[1485] = new Image();
productImages[1485].src="/image/product/medium/black-brown-profile-1.jpg";
productImages[1485].alt = "Otis Flux Black Brown with Grey Polarised Lens";
// Preloaded image. ID = 1486
productImages[1486] = new Image();
productImages[1486].src="/image/product/medium/black-brown-front-1.jpg";
productImages[1486].alt = "Otis Flux Black Brown with Grey Polarised Lens";
// Preloaded image. ID = 1487
productImages[1487] = new Image();
productImages[1487].src="/image/product/medium/black-brown-side-1.jpg";
productImages[1487].alt = "Otis Flux Black Brown with Grey Polarised Lens";
// Preloaded image. ID = 1931
productImages[1931] = new Image();
productImages[1931].src="/image/product/medium/black-profile-6.jpg";
productImages[1931].alt = "Otis Flux Black with Cool Grey Lens";
// Preloaded image. ID = 1932
productImages[1932] = new Image();
productImages[1932].src="/image/product/medium/black-front-6.jpg";
productImages[1932].alt = "Otis Flux Black with Cool Grey Lens";
// Preloaded image. ID = 1933
productImages[1933] = new Image();
productImages[1933].src="/image/product/medium/black-side-6.jpg";
productImages[1933].alt = "Otis Flux Black with Cool Grey Lens";
// Preloaded image. ID = 1934
productImages[1934] = new Image();
productImages[1934].src="/image/product/medium/zebra-tort-profile-1.jpg";
productImages[1934].alt = "Otis Flux Zebra Tort with Tropical Brown Lens";
// Preloaded image. ID = 1935
productImages[1935] = new Image();
productImages[1935].src="/image/product/medium/zebra-tort-front-1.jpg";
productImages[1935].alt = "Otis Flux Zebra Tort with Tropical Brown Lens";
// Preloaded image. ID = 1936
productImages[1936] = new Image();
productImages[1936].src="/image/product/medium/zebra-tort-side-1.jpg";
productImages[1936].alt = "Otis Flux Zebra Tort with Tropical Brown Lens";
// Preloaded image. ID = 1937
productImages[1937] = new Image();
productImages[1937].src="/image/product/medium/ebony-profile-1.jpg";
productImages[1937].alt = "Otis Flux Ebony with Tropical Brown Lens";
// Preloaded image. ID = 1938
productImages[1938] = new Image();
productImages[1938].src="/image/product/medium/ebony-front-1.jpg";
productImages[1938].alt = "Otis Flux Ebony with Tropical Brown Lens";
// Preloaded image. ID = 1939
productImages[1939] = new Image();
productImages[1939].src="/image/product/medium/ebony-side-1.jpg";
productImages[1939].alt = "Otis Flux Ebony with Tropical Brown Lens";
// Preloaded image. ID = 1940
productImages[1940] = new Image();
productImages[1940].src="/image/product/medium/white-profile-1.jpg";
productImages[1940].alt = "Otis Flux White with Cool Grey Lens";
// Preloaded image. ID = 1941
productImages[1941] = new Image();
productImages[1941].src="/image/product/medium/white-front-1.jpg";
productImages[1941].alt = "Otis Flux White with Cool Grey Lens";
// Preloaded image. ID = 1942
productImages[1942] = new Image();
productImages[1942].src="/image/product/medium/white-side-1.jpg";
productImages[1942].alt = "Otis Flux White with Cool Grey Lens";
var productData = [];
var fromPrice = new Array();
var fromMemberPrice = new Array();
productData[2301] = [{19: 1397}, {"price":199.95, "memberPrice":199.95, "exception":'FALSE', "isSpecial":'FALSE', "specialPrice":199.95, "stock":0, "imageId":1937} ];
fromPrice[2301] = 199.95;
fromMemberPrice[2301] = 199.95;
productData[2302] = [{19: 1404}, {"price":199.95, "memberPrice":199.95, "exception":'FALSE', "isSpecial":'FALSE', "specialPrice":199.95, "stock":0, "imageId":1931} ];
fromPrice[2302] = 199.95;
fromMemberPrice[2302] = 199.95;
productData[2303] = [{19: 1444}, {"price":199.95, "memberPrice":199.95, "exception":'FALSE', "isSpecial":'FALSE', "specialPrice":199.95, "stock":0, "imageId":1934} ];
fromPrice[2303] = 199.95;
fromMemberPrice[2303] = 199.95;
productData[2304] = [{19: 1446}, {"price":199.95, "memberPrice":199.95, "exception":'FALSE', "isSpecial":'FALSE', "specialPrice":199.95, "stock":0, "imageId":1940} ];
fromPrice[2304] = 199.95;
fromMemberPrice[2304] = 199.95;
productData[2306] = [{19: 1456}, {"price":199.95, "memberPrice":199.95, "exception":'FALSE', "isSpecial":'FALSE', "specialPrice":199.95, "stock":0, "imageId":1482} ];
fromPrice[2306] = 199.95;
fromMemberPrice[2306] = 199.95;
productData[2796] = [{19: 1782}, {"price":319.95, "memberPrice":319.95, "exception":'FALSE', "isSpecial":'FALSE', "specialPrice":319.95, "stock":0, "imageId":1485} ];
fromPrice[2796] = 319.95;
fromMemberPrice[2796] = 319.95;
var attribSets = [19];
// Find the variant selected.
function findVariant()
{
found = false; // Found flag.
variantIndex = 0; // The index of the found variant element.
// This just scans for a match and if found it sets the flags and breaks.
// If one mismatch is detected it just breaks the loop.
for (variant in productData) // Loop through the variant array, called 'productData'.
{
for (set in attribSets) // Now loop through the sets.
{
// Get a refference to a attribute set select box.
attrib = document.getElementById("attributes"+attribSets[set]);
// Check to see if the value of that attribute select box is in the productData attribute array.
if (productData[variant][0][attribSets[set]]==attrib.value) { found = true; } else { found = false; break; }
}
if (found==true) { variantIndex = variant; break; }
}
if (variantIndex!=0)
{
var data = productData[variantIndex][1];
data["var_id"] = variantIndex;
return data;
}
else { return false; }
}
// This enables and disables the submit button.
function submitButtonEnable(enabled)
{
if (enabled==false) { document.getElementById("submitButton").disabled = true; }
else { document.getElementById("submitButton").disabled = false; }
}
function specialRowEnabled(enable) {
if (enable==false) {
document.getElementById("specialRow").style.display="none";
document.getElementById("memberPriceRow").style.display="block";
}
else {
document.getElementById("specialRow").style.display="block";
document.getElementById("memberPriceRow").style.display="none";
}
}
// Display stock indicator
function displayStock() {
// Don't show stock
return true;
// Get the selected variant.
variant = findVariant();
if (variant["stock"] < 0) {
stockString = "Made upon ordering";
}
else if (variant["stock"] ==0) {
stockString = "Out of stock";
}
else if (variant["stock"] > 0) {
stockString = "In stock & ready to ship";
}
document.getElementById("stock").innerHTML = stockString;
}
// This is the function that gets called when the user changes the selection.
function changeVariant() {
var member = false;
// Get the selected variant.
variant = findVariant();
// Not a variant, show a from price and disable add to cart
if(!variant) {
var toprice = getToPrice();
var fromprice = getFromPrice();
if(toprice == fromprice)
{
document.getElementById("price").innerHTML = "RRP from AUD$ " + fromprice;
}
else
{
document.getElementById("price").innerHTML = "RRP from AUD$ " + fromprice + " to AUD$ " + toprice;
}
if(member) {
document.getElementById("memberPrice").innerHTML = "";
}
submitButtonEnable(false);
specialRowEnabled(false);
}
// Check if it is an exception.
else if (variant["exception"]=="FALSE") { // See if it is on special.
if (variant["isSpecial"]=="TRUE")
{ // Display the special price with the old price with strike through font.
document.getElementById("price").innerHTML = "RRP: AUD$ " + variant["price"].toFixed(2) + "";
document.getElementById("specialPrice").innerHTML = variant["specialPrice"].toFixed(2) + getDiscountPercentage(variant["price"], variant["specialPrice"]);
specialRowEnabled(true);
} // Just show the normal price.
else
{
if(member) {
document.getElementById("price").innerHTML = "RRP: AUD$ " + variant["price"].toFixed(2) + "";
}
else {
document.getElementById("price").innerHTML = "RRP: AUD$ " + variant["price"].toFixed(2);
}
specialRowEnabled(false);
}
if(member) {
document.getElementById("memberPrice").innerHTML = "Member's Price: AUD$ " + variant["memberPrice"].toFixed(2) + getDiscountPercentage(variant["price"], variant["memberPrice"]);
}
// Stock
displayStock();
if (variant["imageId"]!=0)
{
// Swapping image was confusing the users
//swapImage(variant["imageId"]);
}
submitButtonEnable(true); // Enable the submit button.
}
else {
// Variant must be an exception so display some text and disable the submit button.
document.getElementById("price").innerHTML = "Not Available";
document.getElementById("memberPrice").innerHTML = "";
submitButtonEnable(false);
specialRowEnabled(false);
}
}
function swapImage(image) {
document.prodImageMain.src = productImages[image].src;
document.getElementById("prodImageMainAlt").innerHTML = productImages[image].alt;
}
/**
* Sort the prices for the product
* @return lowest price
*/
function getFromPrice() {
fromPrice.sort(function(a,b){return a - b});
return fromPrice[0].toFixed(2);
}
/**
* Sort the prices for the product
* @return highest price
*/
function getToPrice() {
fromPrice.sort(function(a,b){return b - a});
return fromPrice[0].toFixed(2);
}
/**
* Percentage off
* @param price Original product price
* @param specialPrice on special/sale price
* @return Str Text string displaying percentage if percentage is greater than 0%
*/
function getDiscountPercentage(price, specialPrice) {
var discount;
// Make sure there is a difference in price
if(price - specialPrice <= 0) {
return ' (No Discount)';
}
discount = ((price - specialPrice)/price)*100;
discount = Math.round(discount);
if(discount > 0) {
return ' (' + discount + '% off)'
}
return '';
}