
function SwapMenu(object) {document.getElementById(object).style.fontWeight = 'bold'; document.getElementById(object).style.color = '#FFFFFF';}
function SwapMenuRestore(object) {
if ((object != "MenuHome" & dts("Jewellery Supplies and Handmade Costume Jewellery from Glitzy Bits") > -1) | (object != "MenuAbout" & dts("About") > -1) | (object != "MenuCustomise" & dts("Customise") > -1) | (object != "MenuEvents" & dts("Events") > -1) | (object != "MenuLinks" & dts("Link Exchange") > -1) | (object != "MenuTerms" & dts("Terms") > -1) | (object != "MenuContact" & dts("Contact") > -1) | (object != "MenuHelp" & dts("Help") > -1) | dts("Cookies") > -1 | dts("Send") > -1 | dts("Mailing") > -1 | url("shop") > -1 | dts("Found") > -1 | dts("Map") > -1 | dts("General") > -1 | dts("Link Exchange Confirmation") > -1 | url("links/") > -1) {
document.getElementById(object).style.fontWeight = 'normal'; document.getElementById(object).style.color = '#000000';
}}
function SwapSideMenu(object) {document.getElementById(object+"bg").bgColor = "#9900FF";} 
function SwapSideMenuRestore(object) {document.getElementById(object+"bg").bgColor = "";}
function SwapSideMenuUnder(object) {document.getElementById(object).style.textDecoration = "underline"; document.getElementById(object).style.color = '#FFFFFF'; document.getElementById(object).style.fontWeight = 'bold';}
function SwapSideMenuUnderRestore(object) {document.getElementById(object).style.textDecoration = "none"; document.getElementById(object).style.color = '#000000'; document.getElementById(object).style.fontWeight = 'normal';}
function SwapSidePanelMenu(object) {document.getElementById(object).style.color = "#FFFFFF";} 
function SwapSidePanelMenuRestore(object) {document.getElementById(object).style.color = "";}
function SwapAddToBasket(object) {document.getElementById(object).style.color = '#0000FF';}
function SwapAddToBasketRestore(object) {document.getElementById(object).style.color = '#9900FF';}
function SwapOutOfStock(object) {document.getElementById(object).style.color = '#0000FF';}
function SwapOutOfStockRestore(object) {document.getElementById(object).style.color = '#000000';}
function SwapLarger(object) {document.getElementById(object).style.color = '#9900FF';}
function SwapLargerRestore(object) {
if ((object != "BottomHome" & dts("Jewellery Supplies and Handmade Costume Jewellery from Glitzy Bits") > -1) | (object != "BottomAbout" & dts("About") > -1) | (object != "BottomCustomise" & dts("Customise") > -1) | (object != "BottomEvents" & dts("Events") > -1) | (object != "BottomLinks" & dts("Link Exchange") > -1 ) | (object != "BottomTerms" & dts("Terms") > -1) | (object != "BottomContact" & dts("Contact") > -1) | (object != "BottomHelp" & dts("Help") > -1) | dts("Cookies") > -1 | dts("Send") > -1 | dts("Mailing") > -1 | url("shop") > -1 | dts("Found") > -1 | dts("Map") > -1 | dts("General") > -1 | dts("Link Exchange Confirmation") > -1 | url("links/") > -1) {
document.getElementById(object).style.color = '#000000';
}}
function SwapLargerE(object) {document.getElementById(object).src = 'egg.jpg';}
function SwapLargerERestore(object) {
pic = object.split("Img")[1].toLowerCase();
document.getElementById(object).src = "images/"+pic+"med.jpg";
}
function SwapView(object) {document.getElementById(object).style.color = '#FFFFFF';}
function SwapBasket(object) {document.getElementById(object).style.color = '#0000FF';}
function SwapBasketRestore(object) {document.getElementById(object).style.color = '#9900FF';}
function SwapBasketMain(object) {document.getElementById(object+"bg").bgColor = "#9900FF"; document.getElementById(object).style.color = '#FFFFFF';}
function SwapBasketMainRestore(object) {document.getElementById(object+"bg").bgColor = ""; document.getElementById(object).style.color = '#9900FF';}
function SwapRemove(object) {document.getElementById(object).style.color = '#FF0000';}
function SwapRemoveRestore(object) {document.getElementById(object).style.color = '#000000';}

function dts(searchtitle) {
return(document.title.search(searchtitle));
}

function url(searchurl) {
locationsearch=window.location.href;
return(locationsearch.search(searchurl));
}

function findCookie(){
//alert('findCookie');
if(document.cookie) {index = document.cookie.indexOf("glitzybits");
if (index != -1) {namestart = (document.cookie.indexOf("=", index) + 1); nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}}} else {index = -1; namestart = 0; nameend = 0;}
if (index > -1) {cookiepresent = 1;} else {cookiepresent = 0;}
}

function roundAmount(n) {
 var s = "" + Math.round(n * 100) / 100;
 var i = s.indexOf('.');
 if (i < 0) return s + ".00";
 var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3);
 if (i + 2 == s.length) t += "0";
 return t;
}

function changeCalcLink() {
document.getElementById("calclink").href = "http://www.glitzy-bits.co.uk/basket.php?action=calculate&promcode=" + document.PromotionForm.promcode.value;
}

function changeCollLink() {
document.getElementById("colllink").href = "http://www.glitzy-bits.co.uk/basket.php?action=collect&promcode=" + document.CollectForm.promcode.value.toUpperCase();
}

function ProdQuanPriceAdd(ProdCode) {
ProdCode1 = ProdCode; ProdCode2 = ProdCode;
if (ProdCode.search("Side") > -1) {ProdCode2 = ProdCode2.substring(4,ProdCode2.length);}
document.getElementById(ProdCode1+"href").href = "http://www.glitzy-bits.co.uk/basket.php?add=" + ProdCode2 + "_" + document.getElementById("ProdQuanPrice"+ProdCode1).value + "n";
}

function moving() {
//alert('moving');
if (dts("Basket") == -1 & dts("Checkout") == -1 & dts("Written") == -1 & dts("Postal") == -1 & dts("Online") == -1 & dts("Canceled") == -1 & dts("Receipt") == -1 & dts("Confirmation") == -1) {
if (window.location.href.search("http") > -1 & cookiepresent == 1 & document.cookie.search("hide") == -1) {document.PromotionForm.promcode.value = document.cookie.substring(document.cookie.indexOf("prom"),nameend).split("%2C")[1];}
}
activateMenus();
BottomHeight = 0;
if (document.body.clientWidth > 780) {
leftval = (document.body.clientWidth-780)/2;
if (dts("Basket") == -1 & dts("Checkout") == -1 & dts("Written") == -1 & dts("Postal") == -1 & dts("Online") == -1 & dts("Canceled") == -1 & dts("Receipt") == -1 & dts("Confirmation") == -1) {
document.getElementById("BasketLayer").style.left = leftval + 573;
}
if (dts("Glitzy Bits - Handmade") > -1 | dts("Terms") > -1 | dts("Checkout") > -1) {
document.getElementById("PayPalLayer").style.left = leftval + 40;
}
if (dts("Basket") > -1) {
document.getElementById("GoogleSearchLayer").style.left = leftval + 235;
} else if (dts("Checkout") == -1 & dts("Secure") == -1 & dts("Receipt") == -1 & dts("Postal") == -1 & dts("Online") == -1 & dts("Canceled") == -1) {
document.getElementById("GoogleSearchLayer").style.left = leftval + 235;
}
} else {
document.getElementById("BasketLayer").style.left = 573;
if (dts("Glitzy Bits - Handmade") > -1 | dts("Terms") > -1 | dts("Checkout") > -1) {
document.getElementById("PayPalLayer").style.left = 40;
}
if (dts("Basket") > -1) {
} else if (dts("Checkout") == -1 & dts("Secure") == -1 & dts("Receipt") == -1) {
document.getElementById("GoogleSearchLayer").style.left = 235;
}}
if (typeof ShopValue != "undefined") {document.getElementById("MainArea").innerHTML = ShopValue;}
if (dts("Basket") > -1) {
if (cookiepresent == 1) {
document.getElementById("compresshref").blur();
document.getElementById("orderhref").blur();
document.getElementById("checkouthref").blur();
}
} else if (dts("Postal") > -1) {
if (cookiepresent == 1) {CalcVouchers();}
} 
}

function GB_goToURL() {
  var i, args=GB_goToURL.arguments; document.GB_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function doRefresh() {
window.location.reload();
}

function goBack() {
setTimeout('history.go(-1);',1);
}

function activateMenus() {
//alert('activateMenus');
if (dts("Jewellery Supplies and Handmade Costume Jewellery from Glitzy Bits") > -1) {SwapMenu('MenuHome'); SwapLarger('BottomHome'); document.getElementById("MenuHome").style.cursor = "default"; document.getElementById("BottomHome").style.cursor = "default";} else
if (dts("About") > -1) {SwapMenu('MenuAbout'); SwapLarger('BottomAbout'); document.getElementById("MenuAbout").style.cursor = "default"; document.getElementById("BottomAbout").style.cursor = "default";} else
if (dts("Customise") > -1) {SwapMenu('MenuCustomise'); SwapLarger('BottomCustomise'); document.getElementById("MenuCustomise").style.cursor = "default"; document.getElementById("BottomCustomise").style.cursor = "default";} else
if (dts("Events") > -1) {SwapMenu('MenuEvents'); SwapLarger('BottomEvents'); document.getElementById("MenuEvents").style.cursor = "default"; document.getElementById("BottomEvents").style.cursor = "default";} else
if (dts("Link Exchange") > -1 & dts("Confirmation") == -1) {SwapMenu('MenuLinks'); SwapLarger('BottomLinks'); document.getElementById("MenuLinks").style.cursor = "default"; document.getElementById("BottomLinks").style.cursor = "default";} else
if (dts("Terms") > -1) {SwapMenu('MenuTerms'); SwapLarger('BottomTerms'); document.getElementById("MenuTerms").style.cursor = "default"; document.getElementById("BottomTerms").style.cursor = "default";} else
if (dts("Contact") > -1) {SwapMenu('MenuContact'); SwapLarger('BottomContact'); document.getElementById("MenuContact").style.cursor = "default"; document.getElementById("BottomContact").style.cursor = "default";} else
if (dts("Help") > -1) {SwapMenu('MenuHelp'); SwapLarger('BottomHelp'); document.getElementById("MenuHelp").style.cursor = "default"; document.getElementById("BottomHelp").style.cursor = "default";}
}

function CalcVouchers() {
//alert('CalcVouchers');
counter = 0; RedeemedString = ""; WrongString = ""; DuplicateString = ""; VoucherValue = 0; StringCounter = 0; StringBreakCounter = 0;
if (dts("Postal") > -1) {
voucherString = document.getElementById("VoucherArea").value.split(";");
} else if (dts("Secure") > -1) {
voucherString = VouchersUsed.split(";");
} else {
voucherString = document.CheckoutForm.VoucherArea.value.split(";");
}
//voucher1 = "1234567812345678"; voucher1value = 100;
//voucher2 = "8765432187654321"; voucher2value = 10;
//voucher3 = "8877665544332211"; voucher3value = 10;
//voucher4 = "1122334455667788"; voucher4value = 20;
//voucher5 = "1111222233334444"; voucher5value = 5;
//voucher6 = "4444333322221111"; voucher6value = 10;
while (typeof voucherString[counter] != "undefined") {
//if (voucher1 == voucherString[counter] & RedeemedString.search(voucher1) > -1 & DuplicateString.search(voucher1) == -1) {DuplicateString = DuplicateString + voucher1 + "\n";}
//if (voucher1 == voucherString[counter] & RedeemedString.search(voucher1) == -1) {RedeemedString = RedeemedString + voucher1 + " = " + CurrencySymbol + voucher1value + ", "; VoucherValue = VoucherValue + voucher1value; StringCounter = StringCounter + 1;}
//if (voucher2 == voucherString[counter] & RedeemedString.search(voucher2) > -1 & DuplicateString.search(voucher2) == -1) {DuplicateString = DuplicateString + voucher2 + "\n";}
//if (voucher2 == voucherString[counter] & RedeemedString.search(voucher2) == -1) {RedeemedString = RedeemedString + voucher2 + " = " + CurrencySymbol + voucher2value + ", "; VoucherValue = VoucherValue + voucher2value; StringCounter = StringCounter + 1;}
//if (voucher3 == voucherString[counter] & RedeemedString.search(voucher3) > -1 & DuplicateString.search(voucher3) == -1) {DuplicateString = DuplicateString + voucher3 + "\n";}
//if (voucher3 == voucherString[counter] & RedeemedString.search(voucher3) == -1) {RedeemedString = RedeemedString + voucher3 + " = " + CurrencySymbol + voucher3value + ", "; VoucherValue = VoucherValue + voucher3value; StringCounter = StringCounter + 1;}
//if (voucher4 == voucherString[counter] & RedeemedString.search(voucher4) > -1 & DuplicateString.search(voucher4) == -1) {DuplicateString = DuplicateString + voucher4 + "\n";}
//if (voucher4 == voucherString[counter] & RedeemedString.search(voucher4) == -1) {RedeemedString = RedeemedString + voucher4 + " = " + CurrencySymbol + voucher4value + ", "; VoucherValue = VoucherValue + voucher4value; StringCounter = StringCounter + 1;}
//if (voucher5 == voucherString[counter] & RedeemedString.search(voucher5) > -1 & DuplicateString.search(voucher5) == -1) {DuplicateString = DuplicateString + voucher5 + "\n";}
//if (voucher5 == voucherString[counter] & RedeemedString.search(voucher5) == -1) {RedeemedString = RedeemedString + voucher5 + " = " + CurrencySymbol + voucher5value + ", "; VoucherValue = VoucherValue + voucher5value; StringCounter = StringCounter + 1;}
//if (voucher6 == voucherString[counter] & RedeemedString.search(voucher6) > -1 & DuplicateString.search(voucher6) == -1) {DuplicateString = DuplicateString + voucher6 + "\n";}
//if (voucher6 == voucherString[counter] & RedeemedString.search(voucher6) == -1) {RedeemedString = RedeemedString + voucher6 + " = " + CurrencySymbol + voucher6value + ", "; VoucherValue = VoucherValue + voucher6value; StringCounter = StringCounter + 1;}

if (voucherString[counter] != "") {WrongString = WrongString + voucherString[counter] + "\n";}// & voucher1 != voucherString[counter]  & voucher2 != voucherString[counter] & voucher3 != voucherString[counter] & voucher4 != voucherString[counter] & voucher5 != voucherString[counter] & voucher6 != voucherString[counter]
counter = counter + 1;
if (StringCounter == 3) {RedeemedString = RedeemedString + "<br>"; StringCounter = 0; StringBreakCounter = StringBreakCounter + 1;}
}
subRedeemedString = RedeemedString.substring(RedeemedString.length-4,RedeemedString.length);
if (subRedeemedString == "<br>") {RedeemedString = RedeemedString.substring(0,RedeemedString.length-4); StringBreakCounter = StringBreakCounter - 1;}
if (DuplicateString != "" | WrongString != "") {
if (DuplicateString != "") {DuplicateStringText = "The following codes have been entered more than once:\n\n"+DuplicateString+"\nA gift voucher can only be redeemed once.\n\n";} else {DuplicateStringText = "";}
if (WrongString != "") {WrongStringText = "The following codes have not been recognised:\n\n"+WrongString+"\nEither the codes or separators have been entered incorrectly or the voucher has already been redeemed.\nPlease check the codes and enter again.\nIf you believe the codes have been entered correctly please contact Glitzy Bits before submitting an order.";} else {WrongStringText = "";}
alert(DuplicateStringText + WrongStringText);//DO NOT DELETE
}
DeliveryValue = document.delform.delopt.value;
DeliveryType = document.delform.delopt[document.delform.delopt.selectedIndex].innerHTML;
if (DeliveryType.search("Outside")>-1) {DeliveryType=" (Outside UK)";}
else if (DeliveryType.search("Class")>-1) {DeliveryType=" (1st Class UK)";}
else if (DeliveryType.search("Standard")>-1) {DeliveryType=" (Standard UK)";}
if (dts("Postal") > -1) {
if (DeliveryValue == "FREE") {DeliveryValue = 0;}
document.getElementById("Del1").innerHTML = "<font size=2 face='Comic Sans MS'>Delivery:&nbsp;" + CurrencySymbol + roundAmount(DeliveryValue) + DeliveryType + "</font>";
}
TotalToPay = roundAmount(new Number(TotalValue) + new Number(DeliveryValue) - new Number(VoucherValue));
if (RedeemedString == "") {RedeemedString = "None";}
if (dts("Postal") > -1) {document.getElementById("VUsed").innerHTML = RedeemedString;}
if (TotalToPay < 0) {
TotalToPayText = "Total&nbsp;Credit&nbsp;to&nbsp;use&nbsp;on&nbsp;this&nbsp;order:&nbsp;" + CurrencySymbol + new String(TotalToPay).split("-")[1] + "&nbsp;&nbsp;&nbsp;Total&nbsp;to&nbsp;Pay:&nbsp;" + CurrencySymbol + "0.00&nbsp;(-" + CurrencySymbol + new String(TotalToPay).split("-")[1] + ")";
TotalToPayAlertText = "-" + CurrencySymbolAlert + new String(TotalToPay).split("-")[1];
NegativeTotalText = "<br>Please note : The Total To Pay is " + CurrencySymbol + "0.00 (" + TotalToPayAlertText + "). No credit can be given on part vouchers.<br>Please add more items to the basket to the full voucher value (Optional).<br>The order will be accepted with a negative total.<br>";
} else {
TotalToPayText = "Total&nbsp;to&nbsp;Pay:&nbsp;" + CurrencySymbol+ TotalToPay;
TotalToPayAlertText = CurrencySymbol + TotalToPay;
NegativeTotalText = "";
}
if (dts("Postal") > -1) {
if (NegativeTotalText != "") {
document.getElementById("T2Pay1").innerHTML = "<font size=3 face='Comic Sans MS'>" + TotalToPayText + "</font><br><div align=center class=font3><font color=#9900FF><b>" + NegativeTotalText + "</b></font></div>";
document.getElementById("postalpayment").innerHTML = "By Post - Please print out this order form and send it to Glitzy Bits, 17 Trent Road, Ipswich, Suffolk, IP30QL, England, UK. Please include redeemed vouchers.<br><br>"
} else {
document.getElementById("T2Pay1").innerHTML = "<font size=3 face='Comic Sans MS'>" + TotalToPayText + "</font>";
document.getElementById("postalpayment").innerHTML = "By Post - Please print out this order form and send it with a cheque or postal order, for " + CurrencySymbol + TotalToPay + ", made payable to 'L Ashworth', to Glitzy Bits, 17 Trent Road, Ipswich, Suffolk, IP30QL, England, UK.<br>Please include redeemed vouchers.";
}}
if (dts("Postal") == -1 & dts("Secure") == -1) {
if (NegativeTotalText != "") {
document.getElementById("T2Pay2").innerHTML = "<font size=3 face='Comic Sans MS'>" + TotalToPayText + "</font><br><div align=center class=font3><font color=#9900FF><b>" + NegativeTotalText + "</b></font></div>";
} else {
document.getElementById("T2Pay2").innerHTML = "<font size=3 face='Comic Sans MS'>" + TotalToPayText + "</font>";
}}
if (TotalToPay < 0 & dts("Secure") == -1) {
if (dts("Postal") > -1) {
document.getElementById("SidePanelBottom").innerHTML = "<table width=207 border=0 cellpadding=0 cellspacing=0><tr><td width=207 height=60></td></tr></table><table width=207 border=0 cellpadding=0 cellspacing=0 background=http://www.glitzy-bits.co.uk/bottom1.gif><tr><td width=207 height=9></td></tr></table>";
}
alert('The Total To Pay is ' + CurrencySymbolAlert + '0.00 (' + TotalToPayAlertText + '). No credit can be given on part vouchers.\nPlease add more items to the basket to the full voucher value (Optional).\nThe order will be accepted with a negative total.');
} else if (NegativeTotalText == "") {
if (dts("Postal") > -1) {
document.getElementById("SidePanelBottom").innerHTML = "<table width=207 border=0 cellpadding=0 cellspacing=0 background=http://www.glitzy-bits.co.uk/bottom1.gif><tr><td width=207 height=9></td></tr></table>";
}}}

function showPayPalInfo() {
document.getElementById("PayPalLayer").style.visibility = "visible";
}

function closePayPalInfo() {
document.getElementById("PayPalLayer").style.visibility = "hidden";
}