<!--
//var root='http://elucidportal.co.uk/joebrowns/';
var root='';
var root = document.domain;
if (root == '') { root = parent.window.location.href; }
if (root.search('elucidportal.co.uk') == -1)
 { root = 'http://www.joebrowns.co.uk/'; }
 else
 { root = 'http://elucidportal.co.uk/joebrowns2/'; }
//
var nan=navigator.appName;
var NS4 = (nan=='Netscape') ? 1 : 0;
var IE4 = (nan.substring(0,9)=='Microsoft') ? 1 : 0;
//alert('NS4=' + NS4 + '   --  IE4=' + IE4);
var bbb;
var duration;
var bn = new Array(20);
var bl = new Array(20);
bn[1] = "banners/aaaaa.gif";
bn[2] = "banners/bbbbbb.gif";
bl[1] = root+"default.asp?submit=Home";
bl[2] = root+"default.asp?prod=10";

   function noback() {
      document.location.replace(root+'login.asp?submit=Logout');
   }

   function clearEl() {}

   function activateEl() {}

//   function gotoPage(el,sub) {
//      var e = el.name;
//      if (e != 'perpage') {
//         for (var i = 0; i < el.options.length; i++) {
//            if (el.options[i].selected) var val = el.options[i].value;
//         }
//      }
//      var r = document.jump1.perpage;
//      var urlx = 'prodpage.asp?sub=' + sub + '&type=prod&page=' + val;
//      if (r != undefined) {
//         var pp = document.jump1.perpage.length;
//         if (pp>0) {
//            for (var i = 0; i < pp; i++) {
//              if (document.jump1.perpage.options[i].selected) var pv = document.jump1.perpage.options[i].value;
//            }
//            urlx = 'prodpage.asp?sub=' + sub + '&type=prod&page=' + val + '&perpage='+pv;
//         }
//      }
//      location = urlx;
//   }
//   function gotoPage(el,sub,link) {
//     var e = el.name;
//      var i;
//      if (e != 'perpage') {
//         for (i = 0; i < el.options.length; i++) {
//            if (el.options[i].selected) var val = el.options[i].value;
//         }
//      }
//      var urlx = 'prodpage.asp?'+link + '&page=' + val;
//      var r = document.jump1.perpage;
//      if (r != undefined) {
//         var pp = document.jump1.perpage.length;
//         if (pp>0) {
//            for (i = 0; i < pp; i++) {
//               if (document.jump1.perpage.options[i].selected) var pv = document.jump1.perpage.options[i].value;
//            }
//            urlx = root+'prodpage.asp?'+ link + '&page=' + val + '&perpage='+pv;
//         }
//      }
//      location = urlx;
//   }

   function gotoPage(el,sub,link) {
      var e = el.name;
      for (var i = 0; i < el.options.length; i++) {
         if (el.options[i].selected) var val = el.options[i].value;
      }
      if (e == 'page') {
         var j = link.indexOf('page=');
         var n = 5;
      }
      if (e == 'perpage') {
         var j = link.indexOf('perpage=');
         var n = 8;
      }
      if (j==-1) {
         var urlx = root+'prodpage.asp?'+link+'&'+e+'='+val;
      } else {
         var k = link.indexOf('&',j+1);
         if (k < 0) { k = link.length; }
         var l = link.length;
         var urlx = root+'prodpage.asp?'+link.substr(0,j+n)+val+link.substr(k,l-k);
      }
      location = urlx;
   }

   function login() {
      location = root+"default.asp?submit=login"
   }

   function rotate(i) {
   	duration = 2000;
      ++i;
      if (i > 2) i = 1;
      document.images.banner.src = bn[i];
      document.links["blink"].href.value = bl[i];
      bbb = "window.setTimeout('rotate("+i+");',"+duration+");"
      eval(bbb);
   }

   function buyItem(f) {
//      if (NS4) {var x = "document.frm"+f+".submit()";}
//      eval(x);
   }

   function buyMe(f) {
      if (NS4) {var x = "document.frm"+f+".submit()";}
      eval(x);
   }

   function getPrice(what,which) {
      var xurl = "";
      var exp1 = "document."+what+".sp"+which+".length";
      var exp2 = "document."+what+".sp"+which+".options[i].selected";
      var exp3 = "document."+what+".sp"+which+".options[i].value";
      for (var i=0; i<eval(exp1); i++) {
         if (eval(exp2)) {
            xurl = eval(exp3);
         }
      }
     location = xurl;
   }

   function gotoProcess(what) {
      var xurl = ""
      var exp1 = "document.sidebar."+what+".length"
      var exp2 = "document.sidebar."+what+".options[i].selected"
      var exp3 = "document.sidebar."+what+".options[i].value"
      for (var i=0; i<eval(exp1); i++) {
         if (eval(exp2)) {
            xurl = eval(exp3)
         }
      }
     location = xurl
   }

   function bigpix(what,wd,ht) {
      if (wd=="") {wd=400};
      if (ht=="") {ht=500};
      wd=770; ht=760;
     	var a = root+"bigpix.asp?what="+what
     	var b = "picwin"
     	var c = "width="+wd+",height="+ht+",resizable,scrollbars=yes"
      var w = window.open(a,b,c);
      try {
        w.moveTo(50, 50)
      }
      catch(err)
      {}
   }


   function emailfriend(what,wd,ht) {
      if (wd=="") {wd=500};
      if (ht=="") {ht=600};
   	var a = root+"email_a_friend.asp?what="+what
   	var b = "picwin"
   	var c = "width="+wd+",height="+ht+",resizable,scrollbars=yes"
     var w = window.open(a,b,c);
     w.moveTo(50, 50)
   }

   function bigpix2(what,w,h) {
      if (w=="") {w=300};
      if (h=="") {h=200};
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open("","BigPix",x);
         win.document.write("<html><title>The BIG picture</title><head></head>");
         win.document.write("<body><img src="+what+" border=no onClick='self.close()'><br><br><font face=Arial size=2 color=darkblue>Click in window to close</font></body></html>");
         win.moveTo(50,0);
         }
   }

   function colorSelector(what,name) {
      var w = window.open(root+"color.asp?what="+what+"&name="+name,"colorwin","width=349,height=134");
      w.moveTo(420, 230)
   }

   function specialpopup(what,w,h) {
      if (w=="") {w=500};
      if (h=="") {h=300};
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open(root+"specials.asp?what="+what,"Special",x);
         win.moveTo(50, 350);
         }
   }

   function orderpopup(what,w,h) {
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open(root+"order_details.asp?order="+what,"Details",x);
         win.moveTo(100, 100);
         }
   }

   function configpopup(what,w,h) {
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open(root+"config_show.asp?what="+what,"Details",x);
         win.moveTo(100, 100);
         }
   }

   function friendpopup(part,w,h) {
      if (part!="") {
         w=760; h=465;
         var x = "width="+w+",height="+h+",resizable=no,scrollbars=no,statusbar=no";
         var win = window.open(root+"friend.asp?part="+part+"&mode=ask","Email_a_friend",x);
         win.moveTo(100, 100);
         }
   }


   function windowpopup(html,title,w,h) {
      if (html!="") {
         if (w=="") {w=500};
         if (h=="") {h=300};
     var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open(html,title,x);
         win.moveTo(100, 100);
         }
   }



   function sortByPrice(url) {
      var sort;
      var pp = document.filter_by.sortBy.length;
      if (pp>0) {
         for (i = 0; i < pp; i++) {
            if (document.filter_by.sortBy.options[i].selected) sort = document.filter_by.sortBy.options[i].value;
         }
      }
      if (!sort) { return }
      var i = url.indexOf('&sortby=');
      if (i>-1) url = url.substring(0,i);
      url = url+'&sortby='+sort;
      location=url;
   }

   function doTextRemoveUpdate(x) {
      var z = document.getElementById("submitX");
      z.value = x;
//      document.bsktForm.innerHTML = document.bsktForm.innerHTML + "<input type=hidden name=submitX value='" + x +"'>";
      document.bsktForm.submit();
   }


   function config_errors(what,w,h) {
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open(root+"config_errors.asp?what="+what,"Errors",x);
         win.moveTo(100, 100);
      }
   }

   function buypopup() {
      var w = window.open("","Cart","width=350,height=180");
      w.document.write("<style>#s1 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: blue;}");
      w.document.write("#s2 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: red;}</style>");
      w.document.write("<body><center><br><span id=s1>Product added to your basket</span></center></body>");
      w.moveTo(350, 100)
   }

   function cartpopup(what) {
      var w = window.open("","Cart","width=350,height=180");
      w.document.write("<style>#s1 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: blue;}");
      w.document.write("#s2 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: red;}</style>");
      w.document.write("<head><title>Your cart still contains items from last visit</title></head>");
      var i = "";
      if (what > 1) {i = "s"}
      w.document.write("<body><center><br><span id=s1>Your shopping trolley still contains<br><br><span id=s2>"+what+"</span><br><br>item"+i+" from your last visit.</span></center></body>");
      w.moveTo(350, 100)
   }

   function noCookies() {
      var w = window.open("","Cookies","width=500,height=200");
      w.document.write("<style>#s0 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: white;}</style>");
      w.document.write("<style>#s1 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: red;}</style>");
      w.document.write("<head><title>Your browser is NOT cookie enabled.</title></head>");
      w.document.write("<body><center><br><span id=s1>This site requires a cookie enabled browser to operate correctly.<br><br>Please enable your browser and visit us again or use one that is enabled, if you desire to purchase from this site.<br><br>Thank you very much.</span></center></body>");
      w.moveTo(220, 180)
   }

   function deletePages(what) {
   	 var x = document.infoPages.num.value
      var p = "num="+x
      for(var i = 0; i < x*3; i++) {
         var e = document.infoPages.elements[i];
         if (e.type=="checkbox") {
         	p = p + "&" + e.name + "=" + e.checked
         }
         if (e.type!="checkbox") {
         	p = p + "&" + e.name + "=" + e.value
         }
      }
      var w = window.open(root+"del_info_pages.asp?"+p,"deleteInfo","width=350,height=200,scrollbars=yes");
      w.moveTo(200, 200)
   }

   function debugWindow() {
      var hw = window.open(root+"debug.asp","Debug","width=650,height=450,scrollbars");
      hw.moveTo(158, 55)
   }

   function helpWindow() {
      var hw = window.open(root+"HowToUse.asp","Help","width=615,height=484,scrollbars");
      hw.moveTo(158, 55)
   }

   function viewProm(what) {
      var url = root+"maintain_promotions.asp?submit=View&what="+what
      document.promotions.id.value = what;
      location = url;
   }

   function viewDisc(what) {
      var url = root+"maintain_discounts.asp?submit=View&what="+what
      document.discounts.id.value = what;
      location = url;
   }

   function submit_func() {
      document.forms[0].submit();
   }

   function submit_head(form) {
      document.head.submit();
   }

   function submit_login(form) {
      document.login.submit();
   }

   function submit_feat(form) {
      document.feat.submit();
   }

   function submit_select(form) {
      document.select.submit();
   }

   function submit_art(form) {
      document.selart.submit();
   }

   function submit_prod(form) {
      document.selprod.submit();
   }

   function submit_divs(form) {
      document.divs.submit();
   }

   function uploadPix() {
      var pix = window.open("upload.htm","upload","width=520,height=200");
      pix.moveTo(170, 250)
   }

   function uploadPix(name) {
   	   var url = root+'graphic.asp?pic=' + name
   	   var pix = window.open(url,"upload","width=520,height=100");
      pix.moveTo(170, 250)
   }

   function isblank(s)
   {
      for(var i = 0; i < s.length; i++) {
         var c = s.charAt(i);
         if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
      }
      return true;
   }

   function verify(f)
   {
      var msg;
      var later = "n";
      var inv = "n";
      var empty_fields = "";
      var errors = "";
      var arr;
      var ia;
      var i;

    // Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(i = 0; i < f.length; i++) {
        var g = f.elements[i];
        if ((g.type == "checkbox") && (g.name == "later")) {
           if (g.checked == true) later = "y";
        }
    }
    for(i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea") || (e.type == "file")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                if (later != "y") {
                	empty_fields += "\n          " + e.name;
                }
                else if (e.name != "Graphic") {
                	empty_fields += "\n          " + e.name;
                }
                continue;
            }
            if (e.name == "Email") {
               var email1 = e.value
               arr = email1.split(" ")
               for(ia = 0; ia < arr.length; ia++) {
                  if (arr[ia] != " ") {
                  	email1 = arr[ia]
                  }
               }
            }
            if (e.name == "Emailchk") {
               email2 = e.value
               arr = email2.split(" ")
               for(ia = 0; ia < arr.length; ia++) {
                  if (arr[ia] != " ") {
                  	email2 = arr[ia]
                  }
               }
               if (email1 != email2)
                  errors += "\n email address error"
            }
            // Now check for fields that are supposed to be numeric.
            if (e.numeric || (e.min != null) || (e.max != null)) {
                var v = parseFloat(e.value);
                if (isNaN(v) ||
                    ((e.min != null) && (v < e.min)) ||
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null)
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null)
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted.
    // Otherwise return true.
    if (!empty_fields && !errors) return true;

    msg  = "__________________________________________________\n\n"
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "          Please correct these error(s) and re-submit.\n";
    msg += "__________________________________________________\n\n"

    if (empty_fields) {
        msg += "- The following required field(s) are empty:\n"
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

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) { //v3.0
  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); 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 search() {
   var what = document.find.searchwhat.value;
   if (what != '') {
     document.search.searchwhat.value = what;
     document.search.submit();
   }
   else {
      alert('Please enter a keyword to search on');
   }
}

function searchI() {
   var what = document.find.searchwhat.value;
   if (what != '') {
     document.search.searchwhat.value = "item:"+what;
     document.search.submit();
   }
   else {
      alert('Please enter a keyword to search on');
   }
}

function searchP() {
   var lo = document.find.lo.value;
   var hi = document.find.hi.value;
  document.search.searchwhat.value = "price:"+lo+"#"+hi;
  document.search.submit();
}

function initialize() {
//      MM_preloadImages('NewSidebar/wrtinsbut2.gif','NewSidebar/bar2.gif','NewSidebar/calendar2.gif','NewSidebar/clocks2.gif','NewSidebar/clothing2.gif','NewSidebar/conference2.gif','NewSidebar/executive2.gif','NewSidebar/golf2.gif','NewSidebar/keytag2.gif','NewSidebar/leather2.gif','NewSidebar/mugs2.gif','NewSidebar/novelties2.gif','NewSidebar/stationery2.gif','NewSidebar/sweda2.gif','NewSidebar/custservice2.gif','NewSidebar/checkout2.gif','NewSidebar/howtoorder2.gif','NewSidebar/viewcart2.gif');
}

function M_over(n,i) {
   if (document.images)
      document.images[n].src = i
}

function M_out(n,i) {
   if (document.images)
      document.images[n].src = i
}

var buywin;
function PopCartMsg() {
   buywin = window.open("","buyme","width=430,height=120");
   buywin.document.write("<html><style>#s1 {font-family: Arial, sans-serif; font-size: 10px; font-weight: bold; color: blue;}</style>");
   buywin.document.write("<head><title>One-time buy message</title>");
   buywin.document.write('</script>');
   buywin.document.write("</head>");
   buywin.document.write('<body topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0 marginwidth=0 marginheight=0>')
   buywin.document.write('<center><br><span id=s1>The product you have selected has been added to your shopping trolley. <br><br>')
   buywin.document.write('The number of items in the trolley will be shown at the top right of this page. <br><br>')
   buywin.document.write('The shopping trolley may be viewed later by clicking on the link at top of the page<br><br>')
   buywin.document.write('This message will be shown only once during your visit.')
   buywin.document.write('<FORM><INPUT TYPE="button" VALUE="Close Window" onClick="window.close()"></FORM>')
   buywin.document.write('</span></center></body></html>');
   buywin.moveTo(420, 230);
   setTimeout("shutIt()",20000);
}

function shutIt() {
   buywin.close();
}

function SCSbuy(f) {
   var errors = "";
   var msg = "";
   var x = "";
   var a = "";
   for (var i = 0; i < f.length; i++) {
      var e = f.elements[i];
      if (e.type == "text" && e.name != "dum") {
   	    var v = parseFloat(e.value);
   	    if (isNaN(v)) {
    	   	  x = "";
    	   	  a = "";
    	   	  a += e.name;
   	       x += a.substring(3,a.length);
    	       errors += x+" NOT numeric = "+e.value+".\n";
    	    }
      }
   }
   if (!errors) return true;
   msg = "The following errors were found - Please correct and try again.\n\n";
   msg += errors;
   alert(msg);
   return false;
}

function dobgcolors() {
//  if (NS4) {
//      var obj = eval('document.forms["prc"].elements["ie_plenty"]');
//alert(obj);
//      obj.bgcolor = "#A5F7E7";
//   }
}

var v = new Array();
function act(w) {
   var a = w.name;
   var b = a.substr(0,1);
   var n = a.substr(1,2);
   var num = parseFloat(document.matrix.elements["number"].value);
   for (var j=0; j<num; j++) {
      var m = j+(n-1)*(num)+2;
      if (b=="c") {
         var y = document.matrix.elements[m];
         v[j] = y.value;
      }
      if (b=="p") {
         document.matrix.elements[m].value = v[j];
      }
      if (b=="d") {
         document.matrix.elements[m].value = 0;
      }
   }
}

var lbDiv = null;
var lbLocation = '';
var timer1 = null;

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}

function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function lightBoxClose()
{
  clearTimeout(timer1);
  lbDiv.style.display='none';
//alert(lbLocation);
  if (lbLocation != '') {  location = lbLocation; }
}

function showLightBox(x, myEvent)
{
  if (lbDiv == null)
  {
     lbDiv = document.createElement('div');
     lbDiv.setAttribute('id', 'lbDiv');
     lbDiv.className = 'lightBox';
     lbDiv.position = 'absolute';
     lbDiv.innerHTML = '<div></div>';
     document.body.appendChild(lbDiv);
  }

  var ver = navigator.appVersion.toLowerCase();
  var ie6 = (ver.indexOf('msie 6.') !=-1 ? true : false);
  if (ie6 == true)
    { lbDiv.style.backgroundImage = "url('assets/images/buypopup.jpg')"; }
  
  el = lbDiv;
  el.style.left = mouseX(myEvent)-320 + 'px';
  el.style.top = mouseY(myEvent)-100 + 'px';
  el.innerHTML = '<div id="lbBtn">'+
                 '<a class="a" onClick="lightBoxClose(\''+x+'\');"></a>'+
                 '</div>'+
                 '<div id="lbTxt">'+x+'</div>';
  el.style.display = 'block';
  timer1 = window.setTimeout("lightBoxClose()",5000);
}
//
function buyCheck(x, myEvent)
{
   var a;
   var b;
   var c;
   var d;
   var e;
   var f;

   a = 'document.prc.qty'+x+'.value';
   e = document.prc.fcnt.value;
   b = eval(a);
   a = 'document.prc.sp'+x+'.value';
   c = eval(a);
   d = c.split('~');
   f = 'bad~0~'+d[2];
   a = "document.prc.sp"+x+".value='"+f+"'";
   parseInt(b);
   if (isNaN(b) || b<=0) {
      alert('ERROR - quantity entered - '+b+' - is INVALID');
      c = eval(a);
      return false;
   } else {
      if (d[0]=='bad') {
         alert('Please choose, both, a colour and size.');
         c = eval(a);
         return false;
      } else {
         if (d[0]=='0') {
            alert('This item is OUT of STOCK and cannot be purchased.');
            f = '0~0~0';
            a = "document.prc.sp"+x+".value='"+f+"'";
            c = eval(a);
            return false;
         } else {
            f = d[0]+'~'+b+'~'+d[2];
            a = "document.prc.sp"+x+".value='"+f+"'";
            c = eval(a);
//            if (addmsg=='yes') alert("Adding to basket .....");
//            location = "default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
            lbLocation = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;  // needs iB?.x=? adding
            if (addmsg=='yes') { showLightBox(x+' of '+d[0], myEvent); }
                           else  { location = lbLocation; }
            return false;
         }
      }
   }
}

function buyDD(x)
{
   var a;
   var b;
   var c;
   var d;
   var e;
   var f;

   a = "document.prc.qty"+x+".value";
   e = document.prc.fcnt.value;
   b = eval(a);
   parseInt(b);
   if (isNaN(b)) {
      alert("ERROR - quantity entered - "+b+" - is INVALID");
      back();
   } else {
      a = "document.prc.sp"+x+".value";
      c = eval(a);
      d = c.split('~');
      if (d[0]=='bad') {
         alert('Please choose, both, a colour and size.');
         return false;
      } else {
         f = d[0]+"~"+b+"~"+d[2];
         a = "document.prc.sp"+x+".value='"+f+"'";
         c = eval(a);
         if (addmsg=='yes') alert("Adding to basket .....");
         location = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
      }
   }
}

function buySome(x, myEvent)
{
   var a = "document.prc.qty"+x+".value";
   var b = eval(a);
   parseInt(b);
   if (isNaN(b)) {
      alert("ERROR - quantity entered - "+b+" - is INVALID");
      return false;
   } else {
      a = "document.prc.sp"+x+".value";
      var e = document.prc.fcnt.value;
      var c = eval(a);
      var d = c.split('~')
      var f = d[0]+"~"+b+"~"+d[2];
      a = "document.prc.sp"+x+".value='"+f+"'";
      c = eval(a);
//      if (addmsg=='yes') alert("Adding to basket .....");
//      location.href = "default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
      lbLocation = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e+'&iB'+x+'.x=20';
      if (addmsg=='yes') { showLightBox(b+' of '+d[0], myEvent); }
                   else  { location = lbLocation; }
      return false; // dh dont let it post the form
   }
}

function buyOne(x, myEvent)
{
// other ones test addmsg==yes -- dont know why this one doesnt DH sept 2008
  lbLocation = root+"default.asp?submit=BuyOne&part="+x;
  showLightBox(x,myEvent);
//  alert('Adding one ' + x + ' to basket.');
//  location = "default.asp?submit=BuyOne&part="+x;
}

// Some date functions.

var datefield;
var dateUS;                //  This is used because JS seems to use US format internally for day of the week calcs
var daterror;
var datenum;
function checkdate(dat,num) {
   var strDayArray = new Array(7);
   strDayArray[0] = "Sunday";
   strDayArray[1] = "Monday";
   strDayArray[2] = "Tuesday";
   strDayArray[3] = "Wednesday";
   strDayArray[4] = "Thursday";
   strDayArray[5] = "Friday";
   strDayArray[6] = "Saturday";
   datefield = dat;
   if (datefield=='') {return true;}
   if (Date.parse(datefield.value)) {
   } else {
      datefield.select();
      alert("You did not enter a valid required delivery date.\n\nPlease try again.");
      datefield.focus();
      return false;
   }
   datenum = num;
   if (chkdate(dat) == false) {
      datefield.select();
      alert(daterror+"\n\nPlease try again.");
      datefield.focus();
      return false;
   }
   else {
      var d = new Date(dateUS);
      var dd = parseInt(d.getDay(), 10);
      if (dd == 0 | dd == 1 | dd == 6) {
         alert(strDayArray[dd]+" "+daterror+"\n\n"+"Unfortunately we cannot deliver on the day selected. \n\nPlease see our Terms & Conditions - then select another date.");
         datefield.focus();
         return false;
      } else {
         var longDate ="Your goods will be delivered to arrive by \n\n"+strDayArray[dd]+" "+daterror+"\n\n"+"For further information see our Terms and Conditions.";
         alert(longDate);
         var e = "document.carrier.dDateLong"+num+".value = strDayArray[dd]+' '+daterror;";
         var x = eval(e);
         return true;
      }
   }
}

function chkdate(dat) {
//var strDatestyle = "US"; //United States date format
   datefield = dat;
   var strDatestyle = "UK";  //UK date format
   var strDate;
   var strDateArray;
   var strDay;
   var strMonth;
   var strYear;
   var intday;
   var intMonth;
   var intYear;
   var today = new Date();
   var booFound = false;
   var strSeparatorArray = new Array("-"," ","/",".");
   var intElementNr;
   var strMonthArray = new Array(12);
   strMonthArray[0] = "January";
   strMonthArray[1] = "February";
   strMonthArray[2] = "March";
   strMonthArray[3] = "April";
   strMonthArray[4] = "May";
   strMonthArray[5] = "June";
   strMonthArray[6] = "July";
   strMonthArray[7] = "August";
   strMonthArray[8] = "September";
   strMonthArray[9] = "October";
   strMonthArray[10] = "November";
   strMonthArray[11] = "December";
   strDate = datefield.value;
   if (strDate.length < 1) {
      return true;
   }
   for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
      if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
         strDateArray = strDate.split(strSeparatorArray[intElementNr]);
         if (strDateArray.length != 3) {
            daterror = 1;
            return false;
         }
         else {
            strDay = strDateArray[0];
            strMonth = strDateArray[1];
            strYear = strDateArray[2];
         }
         booFound = true;
      }
   }

   if (booFound == false) {
      if (strDate.length>5) {
         strDay = strDate.substr(0, 2);
         strMonth = strDate.substr(2, 2);
         strYear = strDate.substr(4);
      }
   }

   if (strYear.length == 2) {
      strYear = '20' + strYear;
   }

   if (strDatestyle == "US") {
      strTemp = strDay;
      strDay = strMonth;
      strMonth = strTemp;
   }

   intday = parseInt(strDay, 10);
   if (isNaN(intday)) {
      daterror = "Invalid date.";
      return false;
   }

   intMonth = parseInt(strMonth, 10);
   if (isNaN(intMonth)) {
      for (i = 0;i<12;i++) {
         if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
            intMonth = i+1;
            strMonth = strMonthArray[i];
            i = 12;
         }
      }
      if (isNaN(intMonth)) {
         daterror = "Invalid date.";
         return false;
      }
   }

   intYear = parseInt(strYear, 10);
   if (isNaN(intYear)) {
      daterror = "Invalid date.";
      return false;
   }

   var todayYear1 = today.getFullYear()+1;
   if (intYear > todayYear1) {
      daterror = "This date is too far in the future";
      return false;
   }

   if (intMonth>12 || intMonth<1) {
      daterror = "Invalid date - month NOT between 1 and 12.";
      return false;
   }

   if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
      daterror = "Invalid date - day Not between 1 and 31.";
      return false;
   }

   if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
      daterror = "Invalid date - day NOT between 1 and 30.";
      return false;
   }

   if (intMonth == 2) {
      if (intday < 1) {
         daterror = "Invalid date - day less than 1.";
         return false;
      }
      if (LeapYear(intYear) == true) {
         if (intday > 29) {
            daterror = "Invalid date - day > 29.";
            return false;
         }
      }
      else {
         if (intday > 28) {
            daterror = "Invalid date - day > 28.";
            return false;
         }
      }
   }

   if (strDatestyle == "US") {
      datefield.value = intMonth + "/" + intday+"/" + strYear;
   }
   else {
      datefield.value = intday + "/" + intMonth + "/" + strYear;
   }
   daterror = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
   dateUS = intMonth + "/" + intday+"/" + strYear;                                   //  This is used because JS seems to use US format internally for day of the week calcs
//alert(Date.parse(dateUS));
//alert(Date.parse(today));
   if (Date.parse(dateUS) <= Date.parse(today)) {
      daterror = "This date is NOT in the future";
      return false;
   }
   return true;
}

function LeapYear(intYear) {
   if (intYear % 100 == 0) {
      if (intYear % 400 == 0) { return true; }
   }
   else {
      if ((intYear % 4) == 0) { return true; }
   }
   return false;
}

function formatCurrency(num) {
   num = num.toString().replace(/\$|\,/g,'');
   if(isNaN(num)) num = "0";
   sign = (num == (num = Math.abs(num)));
   num = Math.floor(num*100+0.50000000001);
   cents = num%100;
   num = Math.floor(num/100).toString();
   if(cents<10)
   cents = "0" + cents;
   for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
   num = num.substring(0,num.length-(4*i+3))+','+
   num.substring(num.length-(4*i+3));
   return (((sign)?'':'-') + num + '.' + cents)
}

function printPage() {
  if (window.print) {
    window.print();
  } else {
	alert("To print this page click OK then command+P")
  }
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function goTo(url) {
   location=url;
}

function remindme(url) {
   var e = document.login.email.value;
   url = root+"login.asp?submit=remindme&email="+e
   location=url;
}

   function ecusWindow(who,what) {
   	var a = root+"ecusWindow.asp?delyref="+who+"&which="+what
   	var b = "picwin"
   	var c = "width=500,height=400,resizable,scrollbars=yes"
      var w = window.open(a,b,c);
      w.moveTo(50, 50)
   }

   function LTrim(sString) {
      while (sString.substring(0,1) == ' ') {sString = sString.substring(1, sString.length);}
      return sString;
   }

   function RTrim(sString) {
      while (sString.substring(sString.length-1, sString.length) == ' ') {sString = sString.substring(0,sString.length-1);}
      return sString;
   }

   function Trim(sString) {
      while (sString.substring(0,1) == ' ') {sString = sString.substring(1, sString.length);}
      while (sString.substring(sString.length-1, sString.length) == ' ') {sString = sString.substring(0,sString.length-1);}
      return sString;
   }

   function addressFindpopup(what,num,w,h) {
      var x = "width="+w+",height="+h+",toolbar=no,location=no,resizable,scrollbars=no";
      if (what=='register') num='';
         var a;
         var ax;
         a = document.getElementById('postcode'+num);
         var aa = a.value;
         if (aa.length>2) {
            var px = a.value;
            var pl = px.length;
            var pz ='';
            for (var i=0; i<pl; i++) pz = pz+ String.fromCharCode(65 + Math.round(Math.random() * 25))+String.fromCharCode(97 + Math.round(Math.random() * 25))+px.charAt(i);
            ax = ax+'&customer='+pz;
            var win = window.open(root+"addressLookup.asp?This_function_allows_one_to_select_an_address_from_a_dropdown_list=&calledBy="+what+"&num="+num+ax,"Details",x);
            win.moveTo(100, 100);
         } else {
         	 alert('Please enter a postcode.');
      }
   }

-->