<!--
// JavaScript Document
function bName() {
  // return 1 for Internet Explorer
  if (navigator.appName == "Microsoft Internet Explorer")
    return 1;

  // return 2 for Navigator
  if (navigator.appName == "Netscape")
    return 2;

  // return 0 for other browsers
  return 0;
}

function bVer() {
  // return version number (e.g., 4.03)
  return parseFloat(navigator.appVersion)
}

var nameCode = bName();
var versionCode = bVer();
if ((nameCode == 2) && (versionCode >= 4) && (versionCode < 5)) document.write('<link rel="stylesheet" href="' + ns4_css + '" type="text/css">');
//else if ((nameCode == 2) && (versionCode >= 5)) document.write('<link rel="stylesheet" href="' + ns6_css + '" type="text/css">');
else document.write('<link rel="stylesheet" href="' + ie_css + '" type="text/css">');

function resizeBoxes(){
if(nameCode==1 ){
document.contactfrm.name.size=33;
document.contactfrm.email.size=33;
document.contactfrm.company.size=33;
document.contactfrm.position.size=33;
document.contactfrm.tel.size=33;
document.contactfrm.enquiry.cols=32;}
else if(versionCode>=5){
document.contactfrm.name.size=33;
document.contactfrm.email.size=33;
document.contactfrm.company.size=33;
document.contactfrm.position.size=33;
document.contactfrm.tel.size=33;
document.contactfrm.enquiry.cols=30;}
}

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];}
}
var popWin = null;

//start of shopping cart methods
function addToCart(frm)
{
	var midScreenWidth = (screen.availWidth)/2; // find the mid width
	var midScreenHeight = (screen.availHeight)/2; // find the mid height
	var l = midScreenWidth - 225; // position left
	var t = midScreenHeight - 150; // position top
	var quantity = frm.quantity.value;
	var product = frm.product.value;
	var charlen = quantity.length + product.length;
	var winFeatures = ("width=450,height=350,left="+l+",top="+t+",scrollbars=1,resizeable=1");
	var winURL = "addcart.asp?cartaction=add&product="+product+"&quantity="+quantity+"&charlen="+charlen;
	
	if(!popWin || popWin.closed)
	{
  		popWin = window.open(winURL, 'popWin', winFeatures);
 	}
 	else
	{
  		popWin.location = winURL;
  		popWin.focus();
 	}
}

function moreInfo(frm)
{
	frm = eval("document."+frm)
	var midScreenWidth = (screen.availWidth)/2; // find the mid width
	var midScreenHeight = (screen.availHeight)/2; // find the mid height
	var l = midScreenWidth - 225; // position left
	var t = midScreenHeight - 150; // position top
	var product = frm.product.value;
	var winFeatures = ("width=450,height=350,left="+l+",top="+t+",scrollbars=1,resizeable=1");
	var winURL = "moreinfo.asp?id="+product;
	
	if(!popWin || popWin.closed)
	{
  		popWin = window.open(winURL, 'popWin', winFeatures);
 	}
 	else
	{
  		popWin.location = winURL;
  		popWin.focus();
 	}
}

//----------------------------
// utility function to test for invalid input
//---------------------
function checkCartQuantities(frm)
{
	var elQuant, i;
	var upperLimit = (frm.productLines.value) - 1;
	for(i=1; i <= upperLimit; i++)
	{
		//alert(i);
		//alert(eval('frm.uQuantity'+i+'.value'));
		elQuant = eval('frm.uQuantity'+i);
		if (isNaN(elQuant.value) || elQuant.value < 1 || elQuant.value == "")
		{
			alert("Please enter a numeric value.");
			elQuant.select();
			return false;
		}/**/
	}
	return true;
}

function updateCartOnSubmit(frm)
{
	return checkCartQuantities(frm);
}

//end of shopping cart methods
function resizeBoxes2(){
if (document.cart.cartaction)
{
	if (document.cart.cartaction.value == "emptycart"){}
	if (document.cart.cartaction.value == "checkout2")
		{	
		if(nameCode==1 ){
			document.cart.bname.size=25;
			document.cart.baddress.cols=24;
			document.cart.btown.size=25;
			document.cart.bcounty.size=25;
			document.cart.bpostcode.size=10;
			document.cart.bemail.size=25;
			document.cart.btel.size=25;
			document.cart.bfax.size=25;}
		else if(versionCode>=5){
			document.cart.bname.size=25;
			document.cart.baddress.cols=24;
			document.cart.btown.size=25;
			document.cart.bcounty.size=25;
			document.cart.bpostcode.size=10;
			document.cart.bemail.size=25;
			document.cart.btel.size=25;
			document.cart.bfax.size=25;}
	}
	if (document.cart.cartaction.value == "checkout3")
	{	
		if(nameCode==1 ){
			document.cart.dname.size=25;
			document.cart.daddress.cols=24;
			document.cart.dtown.size=25;
			document.cart.dcounty.size=25;
			document.cart.dpostcode.size=10;
			document.cart.dtel.size=25;}
		else if(versionCode>=5){
			document.cart.dname.size=25;
			document.cart.daddress.cols=24;
			document.cart.dtown.size=25;
			document.cart.dcounty.size=25;
			document.cart.dpostcode.size=10;
			document.cart.dtel.size=25;}
	}
	if (document.cart.cartaction.value == "checkout4")
	{	
		if(nameCode==1 ){
			document.cart.comments.cols=20;}
		else if(versionCode>=5){
			document.cart.comments.cols=20;}
	}
	if (document.cart.cartaction.value == "processemail")
	{	
		if (document.cart.bemail){
			if(nameCode==1 ){
				document.cart.bemail.size=25;}
			else if(versionCode>=5){
				document.cart.bemail.size=25;}
		}
	}
	if (document.cart.cartaction.value == "thankyou"){}
}
}


function contactForm(){
var submit_me=0;
var my_form=document.contactfrm;
if(my_form.name.value=="" || my_form.name.value==" "){
	alert("Please enter your name.");
	my_form.name.focus();
	submit_me=1;}
if((my_form.tel.value=="" || my_form.tel.value==" ") && submit_me==0){
	alert("Please enter your telephone number.");
	my_form.tel.focus();
	submit_me=1;}
if((my_form.enquiry.value=="" || my_form.enquiry.value==" ") && submit_me==0){
	alert("Please specify your enquiry.");
	my_form.enquiry.focus();
	submit_me=1;}		
if(my_form.email.value!="") {
	if(notValidEmail(my_form.email.value) && submit_me==0){
		alert("Please enter a valid e-mail address.")
		my_form.bemail.focus();
		submit_me=1;}
}
if(submit_me==0){my_form.submit();}
}

function bvalid(){
var submit_me=0;
var my_form=document.cart;
if(my_form.bname.value=="" || my_form.bname.value==" "){
	alert("Please enter your name.");
	my_form.bname.focus();
	submit_me=1;}
if((my_form.baddress.value=="" || my_form.baddress.value==" ") && submit_me==0){
	alert("Please enter your address.");
	my_form.baddress.focus();
	submit_me=1;}
if((my_form.btown.value=="" || my_form.btown.value==" ") && submit_me==0){
	alert("Please enter your town name.");
	my_form.btown.focus();
	submit_me=1;}
if((my_form.bpostcode.value=="" || my_form.bpostcode.value==" ") && submit_me==0){
	alert("Please enter your postcode.");
	my_form.bpostcode.focus();
	submit_me=1;}	
if((my_form.btel.value=="" || my_form.btel.value==" ") && submit_me==0){
	alert("Please enter your telephone number.");
	my_form.btel.focus();
	submit_me=1;}		
if(my_form.bemail.value!="") {
	if(notValidEmail(my_form.bemail.value) && submit_me==0){
		alert("Please enter a valid e-mail address.\nIf you don't have an e-mail address please leave the field empty.")
		my_form.bemail.focus();
		submit_me=1;}
}
if(submit_me==0){my_form.submit();}
}

function dvalid(){
var submit_me=0;
var my_form=document.cart;
if(my_form.dname.value=="" || my_form.dname.value==" "){
	alert("Please enter your name.");
	my_form.dname.focus();
	submit_me=1;}
if((my_form.daddress.value=="" || my_form.daddress.value==" ") && submit_me==0){
	alert("Please enter your address.");
	my_form.daddress.focus();
	submit_me=1;}
if((my_form.dtown.value=="" || my_form.dtown.value==" ") && submit_me==0){
	alert("Please enter your town name.");
	my_form.dtown.focus();
	submit_me=1;}
if((my_form.dpostcode.value=="" || my_form.dpostcode.value==" ") && submit_me==0){
	alert("Please enter your postcode.");
	my_form.dpostcode.focus();
	submit_me=1;}	
if((my_form.dtel.value=="" || my_form.dtel.value==" ") && submit_me==0){
	alert("Please enter your telephone number.");
	my_form.dtel.focus();
	submit_me=1;}
if(submit_me==0){my_form.submit();}
}

function notValidEmail(pString){
var dotpos=pString.indexOf('.');
var atpos=pString.indexOf('@');
	if(atpos == -1 || (pString=="") || (pString==" ") || (pString.length < 6)){
		return true;
	}
	else if(dotpos + 1 == atpos){
		return true;
	}
	else{
		var emailterm=pString.substring(atpos, (pString.length));
		if(emailterm.indexOf('.')==-1 || emailterm.length < 2){
			return true;}
		else return false;
	}

}

/*
This script is written by Eric (Webcrawl@usa.net)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

var popWin = null;
function popUp(popUrl, popWinName, popWidth, popHeight)
{
 if(!popWin || popWin.closed) {
  popWin = window.open(popUrl, popWinName,
config="width="+popWidth+",height="+popHeight+",scrollbars=yes,resizable=yes");
 }
 else {
  popWin.location = popUrl;
  popWin.resizeTo(popWidth, popHeight);
  popWin.focus();
 }
}

//-->