<!--
//************ Start Default Commands ************
var h = "hidden";
var v = "visible";
var dn = "none";
var db = "block";
var graphic = "";   
var isNS4 = 0; var isIE4 = 0; var isNS6 = 0; var isNew = 0;
var docObj, styleObj, currObj, cstyleObj;

var bVer = (parseInt(navigator.appVersion));
var bName = navigator.appName;
var brow = ((navigator.appName) + (parseInt(navigator.appVersion)));

if (bName == "Netscape" && bVer >= 3) version = "js";
else if (bName == "Microsoft Internet Explorer" && bVer >= 4) version = "js";
else if (bName == "Netscape" && bVer == 2) version = "no";
else if (bName == "Microsoft Internet Explorer" && bVer >= 2) version = "no";

if (parseInt(navigator.appVersion >= 5)){isNew = 1}
else if (brow == "Netscape4") {isNS4 = 1;}
else if (brow == "Netscape5") {isNS6 = 1;}
else if (brow == "Microsoft Internet Explorer4") {isIE4 = 1;}
				
if (isNS4||isNS6||isIE4||isNew) {
  if(isNS4){ docObj = "document."; }
  else if(isNS6){ docObj = "document.getElementById('"; }
  else { docObj = "document.all."; }

  if(isNS4){ styleObj = ""; }
  else if(isNS6){ styleObj = "').style"; }
  else { styleObj = ".style"; }
  
  if(isNS4){ cstyleObj = ""; }
  else if(isNS6){ cstyleObj = "').currentStyle"; }
  else { cstyleObj = ".currentStyle"; }
}

function getQuery(val){
  var querystring = location.search.substring(1,location.search.length);
  var o = "";
  var tSec = querystring.indexOf(val+"=");
  var tStr = querystring.substring( (tSec+(val.length+1)),querystring.length);
  
  if(tSec != -1){
    if(tStr.indexOf('&') != -1){
      o = tStr.substring(0,tStr.indexOf('&'));
    } else {
      o = tStr;
    }
  }
  return o;
}

function replaceSubstring(s,f,w){
  rtn = "";
  flg = 0;
  
  for(i = 0; i < s.length; i++){
    if(s.substr(i,f.length) == f){
      rtn += w;
      i += (f.length - 1);
    } else {
      rtn += s.charAt(i);
    }
  }
  
  return (rtn);
}

function writeFlash(fName,bg,w,h){
  if( (navigator.appName == "Netscape") && (parseInt(navigator.appVersion) <= 4) ){
    document.write('<embed src="' + fName + '" quality="high" bgcolor="#' + bg + '" WIDTH="' + w + '" HEIGHT="' + h + '" NAME="header" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />');
  } else {
    document.write('<OBJECT data="' + fName + '" width="' + w + '" height="' + h + '" id="header" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" codetype="application/x-shockwave-flash">');
    document.write(' <PARAM NAME="movie" VALUE="' + fName + '" />');
    document.write(' <PARAM NAME="quality" VALUE="high" />');
    document.write(' <PARAM NAME="bgcolor" VALUE="#' + bg + '" />');
    document.write('</OBJECT>');
  }
}

function openPopup(URL,id,width,height){
  window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=yes");
}

function openPopupLocked(URL,id,width,height){
  window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=no");
}

function goPage(u){
  location.href = u;
}

function layerChange(tmpLayer,tmpVisible) {
  if (isNS4||isNS6||isIE4||isNew) { eval(docObj + tmpLayer + styleObj + '.visibility = ' + tmpVisible) }
}

function displayChange(tmpLayer,tmpVisible) {
  if (isNS4||isNS6||isIE4||isNew) { eval(docObj + tmpLayer + styleObj + '.display = ' + tmpVisible) }
}

function rollover(graphic,state) {
  if(state==1){ if (version == "js") { document[graphic].src = "graphics/" + graphic + "_dn.gif" } }
  if(state==0){ if (version == "js") { document[graphic].src = "graphics/" + graphic + "_up.gif" } }
}

function imageover(graphic,filename,state) {
  if(state==1){ if (version == "js") { document[graphic].src = "graphics/" + filename } }
  if(state==0){ if (version == "js") { document[graphic].src = "graphics/" + filename } }
}

//************ End Default Commands ************

//** Create global variable to control auto hide layers
var menus = new Array('nav_customer','nav_about');
var timers = new Array();
var timercnt = 0;
var timermnu = "";

function changeNav(n){
  var nav = document.getElementById( n );
  if (!nav) return;
  if(nav) nav.className = nav.className=="dt_nav" ? "dt_nav_sel" : "dt_nav";
}

function hideNav(l){
  menu = document.getElementById( "id_" + l );
  if(menu) menu.className="a_nav_section";
  layerChange(l,'h');
}

function showNav(l){
//** Clear auto hide if menu is visible.
  if( timermnu == l ){
    timermnu = "";
    for(var i = 0; i < timers.length; i++){
      if(timers[i] != null) clearTimeout(timers[i]);
    }
  }

//** Change layer visiblity based on variables 'l' and 's'
  for(i = 0; i < menus.length; i++){
    if(menus[i] != l){
      hideNav(menus[i]);
    } else {
      layerChange(menus[i],'v');
      menu = document.getElementById( "id_" + l );
      if(menu) menu.className = "a_nav_section_sel";
    }
  }
}

function menuTimeout(l){
//** Function to auto hide menu if menu is opened but not used.
  timermnu = l;
  timers[timercnt++] = setTimeout("hideNav('" + l + "')", 1000);
}

function replaceImage(n,x,unid){
  if (version == "js") { document['img_large'].src = n }
  document.forms['order' + unid + 'top'].xlrg.value = x;
}

function openLargeImage(l,unid){
  var img = document.forms['order' + unid + 'top'].xlrg.value;
  var u = "PopupImageProducts.asp?recnumber=" + unid + "&img=" + img;
  openPopup(u,'Image','400','400');
}

function openMore(unid){
  var u = "MoreProducts.asp?recnumber=" + unid;
  openPopup(u,'more','500','400');
}

function resizeImage(n){
  if(document.images[n]){
    var img = document.images[n];
    var w = img.width;
    var h = img.height;

    this.resizeTo((w+80),(h+177));
  }
}

function addToWishList(i){
  var partno = document.forms['order' + i + 'top'].partno.value;
  location.href = "code/AddToWishList.asp?recid=" + i + "&partno=" + partno;
}

function submitSearch(){
  var doc = document.SearchForm;
  var txt = replaceSubstring(doc.SearchText.value,' ','+');
  
  //-- Get Category
  if(doc.searchbox4.selectedIndex > 0){
    var cat = "&searchbox4=" + doc.searchbox4.options[doc.searchbox4.selectedIndex].value;
  } else {
    var cat = "";
  }
  
  //-- Get Price Range
  if(doc.searchbox5.selectedIndex > 0){
    var price = "&searchbox5=" + doc.searchbox5.options[doc.searchbox5.selectedIndex].value;
  } else {
    var price = "";
  }
  
  if( (doc.searchbox4.selectedIndex <= 0) && (doc.searchbox5.selectedIndex <= 0) && (doc.SearchText.value == "Enter keyword")){
    alert('You must select something to search');
  } else {
    location.href = "/search.asp?searchtext=" + txt + cat + price;
  }
}

function updateDelivery(si){
  var doc = document.forms['navigation'];
  if(si == 1){
    document.getElementById('updatedelivery').innerText = "£3.95";
  } else if(si == 2){
    document.getElementById('updatedelivery').innerText = "£8.95";
  } else {
    document.getElementById('updatedelivery').innerText = "£3.95";
  }
}

function testEmail(f,frm){
  var a = document.forms[frm].elements[f].value;
  var at = a.indexOf("@")
  var name = a.substring(0, at)
  var isp = a.substring(at + 1, a.length)
  var dot = a.lastIndexOf(".")

  if (at == -1 || at == 0 || name == "" || isp == "" || dot == -1 || dot == (a.length - 1)) {
    alert('You must enter an Email address to join up')
  } else {
    return true;
  }
}

function submitNewsletter(){
  var doc = document.newsletter_form;
  
  if( testEmail('email','newsletter_form') ){
    doc.submit();
    openThanks();
  }
  
}

function openThanks(){
  var u = "popup.asp?sitepages=NewsletterThanks";
  openPopup(u,'thanks','400','400');
}


function goProduct(n){
  var cat = "";
  var npos = -1;
  var pos = -1;
  
  if( (prodAry.length > 0) && (recid != "") && (catid != "") ){
    if(catid == "1"){
      cat = "Eat";
    } else if(catid == "2"){
      cat = "Live";
    } else if(catid == "3"){
      cat = "Pamper+%26+Treat";
    }
    
    for(i=0; i < prodAry.length; i++){
      if(prodAry[i] == recid){
        npos = i;
      }
    }
    
    pos = (npos + n);

    if(pos > (prodAry.length - 2)){
      pos = 0;
    } else if(pos < 0){
      pos = (prodAry.length - 2);
    }

    location.href = "/products.asp?category=" + cat + "&recnumber=" + prodAry[pos];
  }
}

function doWishList(x){
  var doc = document.forms[x];
  var q = doc.quantity;
  var qv = doc.quantityV.value;
  var p = doc.partno.value;
  
  if(q.value == "" ){
    alert("Please enter a valid number in quantity");
    q.focus();
  } else if ( (q.value*1) <= 0 ){
    alert("Quantity cannot be zero or less");
    q.focus();
  } else {
    if(q.value != qv){
      location.href = "code/AddToWishList.asp?partno=" + p + "&qty=" + q.value;
    }
  }
}

function checkWishList(){
  if(document.forms['wishlist'].friendsemails.value.length <= 0){
    alert("You must enter at least one email address");
  } else {
    if(document.forms['wishlist'].friendsemails.value.indexOf('@') > -1){
      document.forms['wishlist'].submit();
    } else {
      alert("Please enter a valid email address");
    }
  }
}

function dosubmitList(x,q){
  if (isNaN(parseInt(eval("document ['" + x + "'].quantity.value")))){
    alert("Please enter a valid number in quantity ");
    return;
    eval("document ['" + x + "'].quantity.focus()");
  } else {
    if (eval("document ['" + x + "'].quantity.value") <= 0 ){
      alert("Quantity cannot be zero or less");
      return;
      eval("document ['" + x + "'].quantity.focus()");
    }
  }

  document.forms[x].quantity.value = document.forms[q].quantity.value;
  eval("document ['" + x + "'].submit()"); 
}


//-->