<!--

function NtoA(a) { b = new Array(); b[0] = a; return b; }
function StoA(a) { b = a.split(','); c = new Array(); for(var d in b) c[c.length] = parseInt(b[d]); return c; }
function isFunction(a) { return typeof a == 'function'; }
function isNull(a) { return typeof a == 'object' && !a; }
function isNumber(a) { return typeof a == 'number' && isFinite(a); }
function isObject(a) { return (a && typeof a == 'object') || isFunction(a); }
function isString(a) { return typeof a == 'string'; }
function isUndefined(a) { return typeof a == 'undefined'; }
function isBoolean(a) { return typeof a == 'boolean'; }
function isArray(a) { return isObject(a) && a.constructor == Array; }

function $(x){return document.getElementById(x);}

function setcid(name,value)
    {
    name = 'm'+name;
    var str = 'document.editForm.'+name+'.value = '+value+';';
    eval(str);
    }

window.defaultStatus = '';

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function confirmLink(data) { if (confirm(data)) return true; else return false; }

function popup(width,height,location,needscroll) {
    var options,top=(screen.availHeight-height)/2,left=(screen.availWidth-width)/2;
    options = "top="+top+",left="+left+",location=0,status=0,";
    options = options+"toolbar=0,menubar=0,directories=0,width=";
    if (width <= screen.availWidth) { options = options + width; }
        else { value = screen.availWidth-12; options = options + value; needscroll = true; }
    options = options + ",height=";
    if (height <= screen.availHeight) { options = options + height; }
        else { value = screen.availHeight-30; options = options + value; needscroll = true; }
    if (needscroll == true) { options = "scrollbars,resizable," + options; }
        else { options = "scrollbars=0,resizable=0," + options; }
    if (window.cwin) cwin.close();
    cwin=window.open(location,"",options);
    }


function imgPopup(width,height,location,description) {
    height+=40; width+=60;
    var options,top=(screen.availHeight-height)/2,left=(screen.availWidth-width)/2;
    popup=window.open("","Image","scrollbars=1,resizable=0,top="+top+",left="+left+",location=0,status=0,toolbar=0,menubar=0,directories=0,width="+width+",height="+height);
    popup.document.open();
    popup.document.write("<html><head><title>"+description+"</title></head><body marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" onload=\"window.focus();\"><div align=\"center\"><a href=\"javascript:window.close();\"><img src="+location+" border=\"0\" style=\"margin:20px;\" alt=\"Click image to close\" /></a></div></body></html>");
    popup.document.close();
    popup.focus();
    }

function picture(width,height,location,description) {
    var options,needscroll=false,top=(screen.availHeight-height)/2,left=(screen.availWidth-width)/2;
    options = "top="+top+",left="+left+",location=0,status=0,";
    options = options+"toolbar=0,menubar=0,directories=0,width=";
    if (width <= screen.availWidth) { options = options + width; }
        else { value = screen.availWidth-12; options = options + value; needscroll = true; }
    options = options + ",height=";
    if (height <= screen.availHeight) { options = options + height; }
        else { value = screen.availHeight-30; options = options + value; needscroll = true; }
    if (needscroll == true) { options = "scrollbars,resizable," + options; }
      else { options = "scrollbars=0,resizable=0," + options; }
    if (window.pici) pici.close();
    pici=window.open("","Picture",options);
    pici.document.open();
    pici.document.write("<html><head><title>"+description+"</title></head><body marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" onload=\"window.focus();\"><a href=\"javascript:window.close();\"><img src="+location+" border=\"0\" hspace=\"0\" vspace=\"0\" alt=\"Click image to close\" /></a></body></html>");
    pici.document.close();
    }

var tabs = { val:0, tabs:null, divs:[], cur:-1,
init: function()
    {
    this.tabs=$('productTabs').getElementsByTagName('a');
    for(var i=0;i<this.tabs.length;i++)
        {
        if (this.tabs[i].getAttribute('rel'))
            {
            var tabinstance = this;
            this.divs[this.divs.length] = this.tabs[i].getAttribute('rel');
            this.tabs[i].onclick = function() { this.blur(); tabinstance.expand(this); return false; }
            }
        }
    },
expand: function(ref)
    {
    var id = ref.getAttribute('rel');
    for(var i=0;i<this.tabs.length;i++) { this.tabs[i].className = this.tabs[i].getAttribute('rel')==id ? 'on' : ''; }
    for(var i=0;i<this.divs.length;i++) { $(this.divs[i]).style.display = this.divs[i]==id ? 'block' : 'none'; }
    }
};

function toggleVis()
    {
    var argv = toggleVis.arguments;
    for(var j=0;j<argv.length;j++)
        {
        if (document.getElementById)
            {
            document.getElementById(argv[j]).style.display = (document.getElementById(argv[j]).style.display == '') ? 'none' : '';
            }
        else if (document.all)
            {
            document.all[argv[j]].style.display = (document.all[argv[j]].style.display == '') ? 'none' : '';
            }
        }
    }

function toggleClass(str)
    {
    var divs = document.getElementsByTagName('div'); var re = new RegExp(str);
    for(var j=0;j<divs.length;j++) { if (re.test(divs[j].className)) { alert(divs[j].Id); toggleVis(divs[j].Id); } }
    }

function checkPassword(str)
    {
    var isValid = true;
    if (str == '') return 'Please enter a password';
    if (str.length < 6) isValid = false;
    // if (!(str.match(/[a-z]/))) isValid = false;
    // if (!(str.match(/[A-Z]/))) isValid = false;
    // if (!(str.match(/[0-9]/))) isValid = false;
    if (isValid) return '';
    return 'Your password must be at least 6 characters long';
    return 'Your password must be at least 8 characters and must contain a mixture of uppercase and lowercase letters and numbers';
    }

function validateCyclescheme(frm)
    {
    if (frm.CSEmployer.value == '') { alert('Please enter your employer'); frm.CSEmployer.focus(); frm.CSEmployer.select(); return false; }
    if (frm.CSEmployee.value == '') { alert('Please enter your employee ID'); frm.CSEmployee.focus(); frm.CSEmployee.select(); return false; }
    if (frm.CSVoucher.value == '') { alert('Please enter your voucher number'); frm.CSVoucher.focus(); frm.CSVoucher.select(); return false; }
    var voucherRegExp = /^[0-9]{12}$/;
    if (!(voucherRegExp.test(frm.CSVoucher.value))) { alert('Please enter a valid voucher number'); frm.CSVoucher.focus(); frm.CSVoucher.select(); return false; }
    if (frm.CSValue.value == '') { alert('Please enter the value of your voucher'); frm.CSValue.focus(); frm.CSValue.select(); return false; }
    if (parseInt(frm.CSValue.value) > 1000) { alert('The maximum voucher value is 1000 pounds'); frm.CSValue.focus(); frm.CSValue.select(); return false; }
    return true;
    }

function validateAddress(frm)
    {
    if (frm.Address1) { if (frm.Address1.value == '') { alert('Please enter the first line of your address'); frm.Address1.focus(); frm.Address1.select(); return false; } }
    if (frm.Address3) { if (frm.Address3.value == '') { alert('Please enter your town/city'); frm.Address3.focus(); frm.Address3.select(); return false; } }
    if (frm.Postcode) { if (frm.Postcode.value == '') { alert('Please enter your postcode'); frm.Postcode.focus(); frm.Postcode.select(); return false; } }
    if (!frm.CountryID.value) { alert('Please choose a country'); frm.CountryID.focus(); return false; }
    if (frm.Telephones.value == 'true' && frm.TelephoneHome.value == '' && frm.TelephoneMobile.value == '' && frm.TelephoneWork.value == '') { alert('Please enter at least one contact number'); frm.TelephoneHome.focus(); frm.TelephoneHome.select(); return false; }
    return true;
    }

function pad(number,length)
    {
    var str = '' + number;
    while (str.length < length) str = '0' + str;
    return str;
    }

function checkEmail(str)
    {
    if (str == '') return 'Please enter your email address';
    var emailRegExp = /^.+@.+\..{2,5}$/;
    if (!(emailRegExp.test(str))) return 'Please enter a valid email address';
    var illegalRegExp = /[\(\)\<\>\,\;\:\\\"\[\]]/;
    if (str.match(illegalRegExp)) return 'Please enter a valid email address';
    return '';
    }

function validateTermsConditions(frm)
    {
    if (!frm.TermsConditions.checked) { alert('Please read and agree to the Terms & Conditions'); return false; }
    return true;
    }

function validateCreate(frm)
    {
    if (!frm.SalutationID.value) { alert('Please choose your title'); frm.SalutationID.focus(); return false; }
    if (frm.Forename.value.length < 2) { alert('Please enter your forename'); frm.Forename.focus(); return false; }
    if (frm.Surname.value.length < 2) { alert('Please enter your surname'); frm.Surname.focus(); return false; }
    var error = checkPassword(frm.Password.value);
    if (error != '') { alert(error); frm.Password.focus(); frm.Password.select(); return false; }
    if (frm.Password.value != frm.Confirm.value) { alert('Your passwords do not match'); frm.Password.focus(); return false; }
    return true;
    }

function validateEmail(frm)
    {
    var error = checkEmail(frm.email.value);
    if (error != '') { alert(error); frm.email.focus(); frm.email.select(); return false; }
    return true;
    }

function validateEmailPwd(frm)
    {
    var error = checkEmail(frm.email.value);
    if (error != '') { alert(error); frm.email.focus(); frm.email.select(); return false; }
    if (frm.password.value == '') { alert('Please enter your password'); frm.password.focus(); return false; }
    return true;
    }

function validateDeliveryAddressID(frm)
    {
    var len = frm.DeliveryAddressID.length;
    if (len == undefined) if (frm.DeliveryAddressID.checked) return true;
    for(var i=0;i<len;i++) if (frm.DeliveryAddressID[i].checked) return true;
    alert('Please select a delivery address');
    return false;
    }

function validateCardID(frm)
    {
    var len = frm.CardID.length;
    if (len == undefined) if (frm.CardID.checked) return true;
    for(var i=0;i<len;i++) if (frm.CardID[i].checked) return true;
    alert('Please select a card');
    return false;
    }

function validateDeliveryLinkID(frm)
    {
    var len = frm.DeliveryLinkID.length;
    if (len == undefined) if (frm.DeliveryLinkID.checked) return true;
    for(var i=0;i<len;i++) if (frm.DeliveryLinkID[i].checked) return true;
    alert('Please select postage');
    return false;
    }

function validateCard(frm)
    {
    var thisMonth = parseInt(frm.ThisMonth.value);
    if (!frm.CardTypeID.value) { alert('Please choose a card type'); frm.CardTypeID.focus(); return false; }
    var isValid = checkCardNumber(frm.CardNumber.value,frm.CardTypeID.value);
    if (!isValid) { alert('Please enter a valid card number'); frm.CardNumber.focus(); frm.CardNumber.select(); return false; }

    var cvvLen = 0;
    if ((frm.CardTypeID.value == 7) || (frm.CardTypeID.value == 9) || (frm.CardTypeID.value == 14)) cvvLen = 3;
    if (frm.CardTypeID.value == 5) cvvLen = 4;

    if ((cvvLen > 0) && (frm.CardCVV.value.length != cvvLen))
        { alert('Please enter your '+cvvLen+' digit card security code'); frm.CardCVV.focus(); frm.CardCVV.select(); return false; }

    if (!frm.ExpiryDateMonth.value) { alert('Please select an expiry month'); frm.ExpiryDateMonth.focus(); return false; }
    if (!frm.ExpiryDateYear.value) { alert('Please select an expiry year'); frm.ExpiryDateYear.focus(); return false; }

    var cardExpiry = parseInt(frm.ExpiryDateYear.value+pad(frm.ExpiryDateMonth.value,2));
    if (cardExpiry < thisMonth) { alert('Your card expiry date is invalid'); frm.ExpiryDateMonth.focus(); return false; }

    if (frm.StartDateMonth.value && frm.StartDateYear.value)
        {
        var cardStart = parseInt(frm.StartDateYear.value+pad(frm.StartDateMonth.value,2));
        if (cardStart > thisMonth) { alert('Your card start date is invalid'); frm.StartDateMonth.focus(); return false; }
        }

    return true;
    }

function checkCardNumber(cardNumber,cardType)
    {
    var cardNumbersOnly = cardNumber.replace(/[^0-9]/g,'');
    var cardNumberRegExps = new Array(/^$/,/^(45|48|49)\d{14}$/,/^((2131|1800)\d{11}|3[0135]\d{14})$/,/^(63|67)\d{14}(\d{2,3})?$/,/^(49|56|63|67)\d{14}(\d{2,3})?$/,/^(34|37)\d{13}$/,/^6304\d{12}(\d{2,3})?$/,/^5[1-5]\d{14}$/,/^5[1-5]\d{14}$/,/^4\d{12}(\d{3})?$/,/^(41|44|45|46|49)\d{14}$/,/^(50|56|57|58|6)/,/^(30|36|38)\d{12}$/,/^(30|36|38)\d{12}$/,/^6011\d{12}$/,/^(2014|2149)\d{11}$/);
    var cardNumberRegExp = cardNumberRegExps[cardType];
    return ( cardNumberRegExp.test(cardNumbersOnly) && checkLuhn10(cardNumbersOnly) );
    }

function checkLuhn10(cardNumber)
    {
    var numberProduct, checkSumTotal = 0;
    for (digitCounter = (cardNumber.length - 1); digitCounter >= 0; digitCounter--)
        {
        checkSumTotal += parseInt (cardNumber.charAt(digitCounter));
        digitCounter--;
        numberProduct = String((cardNumber.charAt(digitCounter) * 2));
        for (var productDigitCounter = 0; productDigitCounter < numberProduct.length; productDigitCounter++)
            checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter));
        }
    return (checkSumTotal % 10 == 0);
    }

function newproductimage(img_src)
    {
    document["productimage"].src = img_src;
    }

var carousel = { carP:0,carT:0,carW:598,carA:true,carD:6000,carE:false,carS:1,carC:0,
start: function(x)
    {
    this.carC = x; $('carousel'+this.carS).className = 'on';
    if (this.carE) clearTimeout(this.carE);
    this.carE = setTimeout('carousel.next()',this.carD);
    },
resume: function()
    {
    this.carA = true; if (this.carE) clearTimeout(this.carE);
    this.carE = setTimeout('carousel.next()',this.carD);
    },
nearer: function(x)
    {
    this.carP = x; $('carouselInner').style.left = this.carP+'px';
    if (this.carP == this.carT) return;
    dif = this.carT - this.carP; inc = (dif/10);
    if (inc < 0) inc = Math.max(dif,Math.min(inc,-3));
    if (inc > 0) inc = Math.min(dif,Math.max(inc,+3));
    setTimeout('carousel.nearer('+parseInt(this.carP+inc)+')',10);
    },
slide: function(x)
    {
    $('carousel'+this.carS).className = ''; this.carS = x;
    $('carousel'+this.carS).className = 'on'; this.carT = -1 * (this.carS-1) * this.carW;
    this.carP = parseInt($('carouselInner').style.left+0); this.nearer(this.carP);
    },
next: function()
    {
    if (!this.carA) return;
    $('carousel'+this.carS).className = '';
    this.carS++; if (this.carS > this.carC) this.carS = 1;
    this.slide(this.carS); if (this.carE) clearTimeout(this.carE);
    this.carE = setTimeout('carousel.next()',this.carD);
    },
jump: function(x) { this.carA = false; this.slide(x); }
};

var tooltip=function(){
 var id = 'tt';
 var top = 5;
 var left = -150;
 var maxw = 300;
 var tt,c,h;
 var ie = document.all ? true : false;
 return{
  show:function(v,w){
   if(tt == null){
    tt = document.createElement('div');
    tt.setAttribute('id',id);
    c = document.createElement('div');
    c.setAttribute('id',id + 'cont');
    tt.appendChild(c);
    document.body.appendChild(tt);
    tt.style.display = 'none';
    document.onmousemove = this.pos;
   }
   tt.style.display = 'block';
   c.innerHTML = v;
   tt.style.width = w ? w + 'px' : 'auto';
   if(!w && ie){ tt.style.width = tt.offsetWidth; }
   if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
   h = parseInt(tt.offsetHeight) + top;
   tooltip.vis(1);
  },
  pos:function(e){
   var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
   var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
   tt.style.top = (u - h) + 'px';
   tt.style.left = (l + left) + 'px';
  },
  vis:function(d){ tt.style.display = d ? 'block' : 'none'; },
 hide:function(){ tooltip.vis(0); }
 };
}();

var map;
var mapIcons = new Array();

function mapInit(full,lat,lon,zoom)
    {
    if (!GBrowserIsCompatible()) return false;
    var m = document.getElementById('map');
    if (typeof(m) == 'undefined') return;
    map = new GMap2(m);
    if (full)
        {
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GScaleControl());
        }
        else
        {
        map.addControl(new GSmallZoomControl());
        }
    map.setCenter(new GLatLng(lat,lon),zoom);
    var colour = new Array('white','red');
    for(i=0;i<colour.length;i++)
        {
        tmp = new GIcon();
        tmp.image = '/images/googlemap_'+colour[i]+'.png';
        tmp.shadow = '/images/googlemap_shadow.png';
        tmp.iconSize = new GSize(12,20);
        tmp.shadowSize = new GSize(22,20);
        tmp.iconAnchor = new GPoint(6,20);
        tmp.infoWindowAnchor = new GPoint(5,1);
        mapIcons[colour[i]] = tmp;
        }

    }

function mapClear() { map.clearOverlays(); }

function mapIcon(lat,lon,col,data)
    {
    var marker = new GMarker(new GLatLng(lat,lon),mapIcons[col]);
    if (data)
        {
        if (isString(data))
            {
            GEvent.addListener(marker,'click',function() { marker.openInfoWindowHtml(data); });
            }
        else
            {
            var tabs = new Array();
            for (var i in data) tabs[tabs.length] = new GInfoWindowTab(i,data[i]);
            GEvent.addListener(marker,'click',function() { marker.openInfoWindowTabsHtml(tabs); });
            }
        }
    // GEvent.addListener(marker,'click',function() { marker.showMapBlowup(2); });
    map.addOverlay(marker);
    return marker;
    }

function mapOnlyIcon(lat,lon,zoom,col,data)
    {
    mapClear();
    mapIcon(lat,lon,col,data);
    map.setZoom(zoom);
    map.panTo(new GLatLng(lat,lon));
    }

var panelLast = 0;

function panelOnly(name,id)
    {
    if (panelLast) { panelHide(name+panelLast); }
    panelShow(name+id);
    panelLast = id;
    }

function panelShow(id)
    {
    if (document.getElementById) { document.getElementById(id).style.display = ''; }
    else if (document.all) { document.all[id].style.display = ''; }
    }

function panelHide(id)
    {
    if (document.getElementById) { document.getElementById(id).style.display = 'none'; }
    else if (document.all) { document.all[id].style.display = 'none'; }
    }

function panelToggle()
    {
    var argv = panelToggle.arguments;
    for(var j=0;j<argv.length;j++)
        {
        if (document.getElementById) { document.getElementById(argv[j]).style.display = (document.getElementById(argv[j]).style.display == '') ? 'none' : ''; }
        else if (document.all) { document.all[argv[j]].style.display = (document.all[argv[j]].style.display == '') ? 'none' : ''; }
        }
    }

//-->
