function navon(ref) {
var elem = document.getElementById(ref);
if (elem) {
elem.style.color="rgb(120,207,250)";
	}
}
function navout(ref) {
var elem = document.getElementById(ref);
if (elem) {
elem.style.color="rgb(1,1,1)";
	}
}

function winN(url,ref) {
var elem = document.getElementById("sg" + ref);
for (var rf=1;rf<30;rf++) {
var el3 = document.getElementById("sg" + rf + "");
if (el3 && rf != ref) {
el3.style.display="none";
el3.style.visibility="hidden";
	}
}
if (elem) {
elem.style.display = "block";
elem.style.visibility = "visible";
	}
else {
//window.open(url,"_top");
	}
}

function winH(ref) {
var elem = document.getElementById("sgl" + ref + "1");
if (elem) {
//alert("hello");
	}
else {
window.open("cat.asp?idg=" + ref + "","_top");
	}
}

function win(url) {
window.open(url,"_top");
}

function swop(ref,im) {
var simg = document.getElementById(ref);
var wimg = im;
if (simg) {
simg.src = "img/build/" + wimg + ""
	}
}

function unswop(ref,im) {
var simg = document.getElementById(ref);
var wimg = im;
if (simg) {
simg.src = "img/build/" + wimg + ""
	}
}


function sbm(nme) {
var pge = $(nme);
if ($(nme)) {
pge.submit();
}

}




function checkadd() {
var frm = document.billing;
if (frm.fname.value.length == 0) {
alert("Please enter your first name.");
    frm.fname.focus();
    frm.fname.select();
return false;
}
if (frm.surname.value.length == 0) {
alert("Please enter your last name.");
    frm.surname.focus();
    frm.surname.select();
return false;
}
if (frm.add1.value.length == 0) {
alert("Please enter an address.");
    frm.add1.focus();
    frm.add1.select();
return false;
}
if (frm.town.value.length == 0) {
alert("Please enter the city or town.");
    frm.town.focus();
    frm.town.select();
return false;
}
if (frm.pc.value.length == 0) {
alert("Please enter your zip or postcode.");
    frm.pc.focus();
    frm.pc.select();
return false;
}
if (frm.country.value == "") {
alert("Please select your country.");
    frm.country.focus();
    frm.country.select();
return false;
}
// check to see if the email is valid
if (!validEmail(frm.eml.value)) {
alert("We require a valid email address.");
    frm.eml.focus();
return false;
}

if (!frm.tc.checked){
alert("Please confirm you agree to our terms and conditions.");
    frm.tc.focus();
    frm.tc.select();
return false;
        }
if(!frm.deladd.checked){
if (confirm("You have not checked the box to confirm this is the delivery address.\n Click 'OK' to be directed to the delivery address page or 'Cancel' to confirm."))
return true;
else
return false;
  }

return true;
}



function checkdeladd() {
var frm = document.delivery;
if (frm.cname.value.length == 0) {
alert("Please enter a contact name.");
    frm.cname.focus();
    frm.cname.select();
return false;
}

if (frm.add1.value.length == 0) {
alert("Please enter an address.");
    frm.add1.focus();
    frm.add1.select();
return false;
}
if (frm.town.value.length == 0) {
alert("Please enter the city or town.");
    frm.town.focus();
    frm.town.select();
return false;
}
if (frm.pc.value.length == 0) {
alert("Please enter your zip or postcode.");
    frm.pc.focus();
    frm.pc.select();
return false;
}
if (frm.country.value == "") {
alert("Please select your country.");
    frm.country.focus();
    frm.country.select();
return false;
}

return true;
}

function testall() {
var frm = $("contact");
if (frm.cname.value.length == 0) {
alert("Please enter a contact name.");
    frm.cname.focus();
    frm.cname.select();
return false;
}

if (!validEmail(frm.eml.value)) {
alert("We require a valid email address.");
    frm.eml.focus();
return false;
}

if (frm.tel.value == "") {
alert("Please enter a contact telephone no..");
    frm.tel.focus();
    frm.tel.select();
return false;
}

return true;
}


function testoffer() {
var frm = $("offer");
if (frm.cname.value.length == 0) {
alert("Please enter a contact name.");
    frm.cname.focus();
    frm.cname.select();
return false;
}

if (!validEmail(frm.eml.value)) {
alert("We require a valid email address.");
    frm.eml.focus();
return false;
}

if (frm.tel.value == "") {
alert("Please enter a contact telephone no..");
    frm.tel.focus();
    frm.tel.select();
return false;
}



if (isNaN(frm.offer.value) || frm.offer.value == "") {
alert("Please enter your offer.\n It must be a number.");
    frm.offer.focus();
    frm.offer.select();
return false;
}

if (frm.delcountry.value == "") {
alert("Please enter the delivery country.");
    frm.delcountry.focus();
    frm.delcountry.select();
return false;
}

return true;
}




function accinfo() {
var frm = document.account;

if (frm.accountname.value.length == 0) {
alert("Please enter an account.");
    frm.accountname.focus();
return false;
}

if (frm.cname.value.length == 0) {
alert("Please enter a contact name.");
    frm.cname.focus();
return false;
}

if (!validEmail(frm.eml.value)) {
alert("We require a valid email address.");
    frm.eml.focus();
return false;
}

if (frm.tel.value == "") {
alert("Please enter a contact telephone no..");
    frm.tel.focus();
return false;
}

return true;
}

function cardinfo() {
var frm = document.card;

if (frm.cname.value.length == 0) {
alert("Please enter a contact name.");
    frm.cname.focus();
return false;
}

if (!validEmail(frm.eml.value)) {
alert("We require a valid email address.");
    frm.eml.focus();
return false;
}

if (frm.tel.value == "") {
alert("Please enter a contact telephone no..");
    frm.tel.focus();
return false;
}

if (frm.add1.value == "") {
alert("We require a delivery address.");
    frm.add1.focus();
return false;
}

if (frm.pc.value == "") {
alert("Please enter a zip or postcode.");
    frm.pc.focus();
return false;
}

return true;
}


function checkmail(cde) {
var pge = document.cform

  // make sure they enter their company name
  if (pge.company.value.length == 0)
    {
    alert("Please enter your company name.");
    pge.company.focus();
    return false;
    } 
    
    // make sure they enter their business type
  if (pge.industry.value.length == 0)
    {
    alert("Please enter a business type.");
    pge.industry.focus();
    return false;
    }
    
  // make sure they enter their name
  if (pge.cname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.cname.focus();
    return false;
    }

  // make sure they enter their telephone
  if (pge.tel.value.length == 0)
    {
    alert("Please enter your telephone no.");
    pge.tel.focus();
    return false;
    }
    
    // check to see if the email is valid
  if (!validEmail(pge.email.value)) {
    alert("We require a valid email address.");
    pge.email.focus();
    return false;
    }  

  if (pge.nosm.value != cde)
    {
    alert(" Invalid Code.\n Enter the characters as shown in red.");
    pge.nosm.focus();
    return false;
    }
  pge.submit();
}


// EMail Checker

function validEmail(email) {
  invalidChars = " /:,;"

  if (email == "") {// cannot be empty
    return false;
  }
  for (i=0; i<invalidChars.length; i++) {  // does it contain any invalid characters?
    badChar = invalidChars.charAt(i)
    if (email.indexOf(badChar,0) > -1) {
      return false;
    }
  }
  atPos = email.indexOf("@",1)// there must be one "@" symbol
  if (atPos == -1) {
    return false;
  }
  if (email.indexOf("@",atPos+1) != -1) {  // and only one "@" symbol
    return false;
  }
  periodPos = email.indexOf(".",atPos)
  if (periodPos == -1) {// and at least one "." after the "@"
    return false;
  }
  if (periodPos+3 > email.length) {// must be at least 2 characters after the "."
    return false;
  }
  return true;
}










function Is() {
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) &&
(agent.indexOf('spoofer') == -1) &&
(agent.indexOf('compatible') == -1) &&
(agent.indexOf('opera') == -1) &&
(agent.indexOf('webtv') == -1) &&
(agent.indexOf('hotjava') == -1));
this.ns2 = (this.ns && (this.major == 2));
this.ns3 = (this.ns && (this.major == 3));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = ((agent.indexOf("msie") != -1) &&
(agent.indexOf("opera") == -1));
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 4") != -1));
this.ie5 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 5.") != -1) &&
(agent.indexOf("msie 5.5") == -1) &&
(agent.indexOf("mac") == -1));
this.iem5 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 5.") != -1) &&
(agent.indexOf("mac") != -1));
this.ie55 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 5.5") != -1));
this.ie6 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 6.") != -1));
this.ie7 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 7.") != -1));
this.nsdom = (this.ns4 || this.ns6);
this.ie5dom = (this.ie5 || this.iem5 || this.ie55);
this.iedom = (this.ie4 || this.ie5dom || this.ie6);
this.w3dom = (this.ns6 || this.ie6 ||this.ie7);
}



function enquire(ref) {
if (ref) {
location.replace("content.asp?pge=3&ref=" + ref + "");
}
}




function win(url) {
window.open(url,"_top");
}

function win2(url) {
window.open(url,"new");
}


function viewtxt(bx) {
var box = document.getElementById(bx);
box.style.visibility="visible";
}

function notxt(bx) {
var box = document.getElementById(bx);
box.style.visibility="hidden";
}

function wht(i,j) {
var isDOM = (document.getElementById ? true : false);
var isIE = ((document.all) ? true : false);
  if (isIE) {
var e1 = document.all["lne" + i + ""];
var e2 = document.all["lne" + j + ""];
 e1.src = "img/build/sqWht.png";
 e2.src = "img/build/sqWht.png";
   }
 if (isDOM) {
var imgA = document.getElementById("lne" + i + "");
var imgB = document.getElementById("lne" + j + "");
imgA.src = "img/build/sqWht.png";
imgB.src = "img/build/sqWht.png";
  }
}

function blk(i,j) {
 var isDOM = (document.getElementById ? true : false);
 var isIE = ((document.all) ? true : false);
if (isIE){
var e1 = document.all["lne" + i + ""];
var e2 = document.all["lne" + j + ""];
 e1.src = "img/build/sqBlk.png";
 e2.src = "img/build/sqBlk.png";

   }
if (isDOM) {
var imgA = document.getElementById("lne" + i + "");
var imgB = document.getElementById("lne" + j + "");
 imgA.src = "img/build/sqBlk.png";
 imgB.src = "img/build/sqBlk.png";
  }
}



function remove(ref) {
var msg = "Do you wish to remove this item from your basket?";
if (confirm(msg)) {
location.replace("xcart.asp?idc=" + ref + "");
	}
}

function skey(which) {
if (which == "a") {
var frm = document.searchKey.key;
}
else {
var frm = document.searchPro.prokey;
}

if (frm.value.length < 3 || frm.value == "Keyword Search" || frm.value == "Product Search") {
alert("Minimum of 3 characters required.")
frm.focus();
return false;
	}
return true;
}

function chkfind() {
var frm = document.getElementById("searchbox");

if (frm.pcode.value.length < 3  && frm.pname.value.length < 3) {
alert("Please enter either a code number and/or a product name. \n Minimum of 3 characters required.");
return false;}
else {
return true;}

}


function mkDataBox(v) {
var el = 1;
while (el<20) {
if (el != v) {
var Xdbx = document.getElementById("xdata" + el + "");
var Ximgloc = document.getElementById("sign" + el + "");
var Ximgneg = document.getElementById("neg" + el + "");
if (Xdbx) {
Ximgloc.style.visibility="visible";
Ximgloc.style.display="block";
Xdbx.style.visibility = "hidden";
Xdbx.style.display = "none";
Ximgneg.style.visibility="hidden";
Ximgneg.style.display="none";
 }
}
el++;
}
var dbx = document.getElementById("xdata" + v + "");
dbx.style.visibility = "visible";
dbx.style.display = "block";
var imgloc = document.getElementById("sign" + v + "");
imgloc.style.visibility="hidden";
imgloc.style.display="none";
var imgneg = document.getElementById("neg" + v + "");
imgneg.style.visibility="visible";
imgneg.style.display="block";
}

function wipe2(v) {
var dbx = document.getElementById("xdata" + v + "");
var imgloc = document.getElementById("sign" + v + "");
imgloc.style.visibility="visible";
imgloc.style.display="block";
dbx.style.visibility = "hidden";
dbx.style.display = "none";
var imgneg = document.getElementById("neg" + v + "");
imgneg.style.visibility="hidden";
imgneg.style.display="none";
}



function showIt(ref, nol) {
nol = nol + 1
var el = 1;
while (el < nol) {
if (el != ref) {
var plus = document.getElementById("p" + el + "");
var cont = document.getElementById("f" + el + "");
var minu = document.getElementById("m" + el + "");
if (plus) {
plus.style.visibility="visible";
plus.style.display="block";
minu.style.visibility = "hidden";
minu.style.display = "none";
cont.style.visibility="hidden";
cont.style.display="none";
 }
}
el++;
}

var elm = document.getElementById("f" + ref + "");
var plus = document.getElementById("p" + ref + "");
var minus = document.getElementById("m" + ref + "");
elm.style.visibility = "visible";
elm.style.display = "block";
plus.style.visibility = "hidden";
plus.style.display = "none";
minus.style.visibility = "visible";
minus.style.display = "block";
}

function noshowIt(ref, nol) {
nol = nol + 1
var el = 1;
while (el < nol) {
if (el != ref) {
var plus = document.getElementById("p" + el + "");
var cont = document.getElementById("f" + el + "");
var minu = document.getElementById("m" + el + "");
if (plus) {
plus.style.visibility="visible";
plus.style.display="block";
minu.style.visibility = "hidden";
minu.style.display = "none";
cont.style.visibility="hidden";
cont.style.display="none";
 }
}
el++;
}

var elm = document.getElementById("f" + ref + "");
var plus = document.getElementById("p" + ref + "");
var minus = document.getElementById("m" + ref + "");
elm.style.visibility = "hidden";
elm.style.display = "none";
plus.style.visibility = "visible";
plus.style.display = "block";
minus.style.visibility = "hidden";
minus.style.display = "none";
}