function buycheck(product,formname) {
if (document.buy.option.value == '') {
alert('please what type of ' + product + ' you wish to buy');
} else {
document.buy.submit();
}
}
var answer;
function quantity(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function delcheck(deltype,url) 
{ 
answer = confirm("You have selected "+deltype+"\n Is this correct?")
if (answer !=0) 
{ 
location = url; 
} 
}
function detailaddress () {
}
function popup2(url,width,height)
{
	newwindow=window.open(url,'name','height='+height+',width='+width+',scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function checkform()
{
	if(!document.details.name.value) {
		alert ("Please fill in your name");
		document.details.name.focus()
		return false;
	} else if(!document.details.email.value) {
		alert ("Please fill in your email address");
		document.details.email.focus()
		return false;
	} else if(!document.details.address1.value) {
		alert ("Please fill in your address");
		document.details.address1.focus()
		return false;
	} else if(!document.details.city.value) {
		alert ("Please fill in your city");
		document.details.city.focus()
		return false;
	} else if(!document.details.country.value) {
		alert ("Please select a country");
		return false;
	} else if(!document.details.postcode.value) {
		alert ("Please fill in your postcode");
		document.details.postcode.focus()
		return false;
	} else { 
	return true;
	}
	return false;
}
var xmlhttp=false; 
/*@cc_on @*/ 
/*@if (@_jscript_version >= 5) 
// JScript gives us Conditional compilation, we can cope with old IE versions. 
// and security blocked creation of the objects. 
  try { 
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch (e) { 
   try { 
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
   } catch (E) { 
    xmlhttp = false; 
   } 
  } 
@end @*/ 
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
  xmlhttp = new XMLHttpRequest(); 
} 
function quickadd(prod,sp,cat_num) {
		day = new Date();
	id = day.getTime();
	var url = "includes/quickadd.php?cartnum="+cat_num+"&prodnum="+prod+"&time="+id;
	
		 xmlhttp.open("GET", url); 
    xmlhttp.onreadystatechange = function() { 
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
	   if (!xmlhttp.responseText) {
		document.getElementById(sp).innerHTML = "<a href=\"cart.php\" style=\"text-transform:none; color:#333333;\">Added to Cart</a>";
	  }
	}	 
	}
    xmlhttp.send(null);

}
function subform1() {
	document.step1.action = "detailcollect.php?fp=1";
	submain1();
}
function subform2() {
	document.step1.action = "detailcollect.php?si=1";
	submain1();
}
function subform3() {
	document.step1.action = "detailcollect.php?su=1";
	submain1();
}
function subform3a() {
	document.step1.action = "detailcollect-admin.php?su=1";
	document.step1.submit();
}
function subform5() {
	document.step1.action = "customer.php?si=1";
	submain2();
}
function subform6() {
	document.step1.action = "customer.php?fp=1";
	submain2();
}
function submain1() {
		var emailfilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (document.step1.action == "detailcollect.php?fp=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value)) {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			} else {
			document.step1.submit();
		}
		return false;	
	} else if (document.step1.action == "detailcollect.php?si=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value) && document.step1.got_email.value != "admin") {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			}else if (!document.step1.got_password.value) {
			alert ("Please enter an password");
			document.step1.got_password.focus();
			return false;
		} else{
			document.step1.submit();
		}
		
	} else if (document.step1.action == "detailcollect.php?su=1") {
		if (!document.step1.new_email.value) {
			alert ("Please enter an email address");
			document.step1.new_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.new_email.value)) {
		alert ("Please enter a valid email address");
		document.step1.new_email.focus();
		return false;
			}else if (!document.step1.new_fname.value) {
			alert ("Please enter a First Name");
			document.step1.new_fname.focus();
			return false;
		} else if (!document.step1.new_lname.value) {
			alert ("Please enter a Last Name");
			document.step1.new_lname.focus();
			return false;
		} else if (!document.step1.new_phone.value) {
			alert ("Please enter a Phone Number");
			document.step1.new_phone.focus();
			return false;
		} else if (!document.step1.new_pass.value) {
			alert ("Please enter a Password");
			document.step1.new_pass.focus();
			return false;
		}  else if (document.step1.new_pass.value != document.step1.new_confirm.value) {
			alert ("The password does not match the confirmed password");
			document.step1.new_pass.focus();
			return false;
		} else {
			document.step1.submit();
		}
	} else {
		return false;
	}
	return false;
}
function submain2() {
		var emailfilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (document.step1.action == "customer.php?fp=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value)) {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			} else {
			document.step1.submit();
		}
		return false;	
	} else if (document.step1.action == "customer.php?si=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value) && document.step1.got_email.value != "admin") {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			}else if (!document.step1.got_password.value) {
			alert ("Please enter an password");
			document.step1.got_password.focus();
			return false;
		} else{
			document.step1.submit();
		}
		
	} else {
		return false;
	}
	return false;
}
function subbill() {
	if (!document.bill.street.value) {
		alert ("Please enter a House Number & Street");
		document.bill.street.focus();
		return false;
	} else if (!document.bill.town.value) {
		alert ("Please enter a Town");
		document.bill.town.focus();
		return false;
	} else if (!document.bill.county.value) {
		alert ("Please enter a County");
		document.bill.county.focus();
		return false;
	} else if (!document.bill.postcode.value) {
		alert ("Please enter a Postcode");
		document.bill.postcode.focus();
		return false;
	} else {
		return true;
	}
}
function subdel() {
var myOption
for (i=document.del.payment_type.length-1; i > -1; i--) {
if (document.del.payment_type[i].checked) {
var myOption = 1;
}
}

	if (!document.del.street2.value) {
		alert ("Please enter a House Number & Street");
		document.del.street2.focus();
		return false;
	} else if (!document.del.town2.value) {
		alert ("Please enter a Town");
		document.del.town2.focus();
		return false;
	} else if (!document.del.county2.value) {
		alert ("Please enter a County");
		document.del.county.focus();
		return false;
	} else if (!document.del.postcode2.value) {
		alert ("Please enter a Postcode");
		document.del.postcode2.focus();
		return false;
	} else if (!document.del.deliveryadd2.checked) {
		alert ("Please accept our terms and conditions");
		document.del.deliveryadd2.focus();
		return false;
	} else if (!document.del.deliveryadd2.value) {
		alert ("Please accept our terms and conditions");
		return false;
	} else if (!myOption) {
		alert("You must select a Payment Type");
		return false;
	} else {
		return true;
	} return false;
}
var newwindow;
function popimage(url, height, width,scrollbars) {
	if (scrollbars == 1) {
		var scrollba = "yes";
	} else {
		var scrollba = "no";
	}
	newWindow = window.open(url,'name','height=' + height + ',width=' + width + ',scrollbars='+scrollba);
}
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
if (checkIt('msie')) {
if (detect.charAt(place + thestring.length) < 7) {
	document.write('<link href="explorer.css" rel="stylesheet" type="text/css">');
}}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
function freebrochurecontact2() {
	document.getElementById("sideform").style.margin="-275px 0px 0px 0px";
	document.getElementById("fb1").style.display="inline";
	document.getElementById("fb2").style.display="inline";
	document.getElementById("fb3").style.display="inline";
	document.getElementById("qc4").style.display="inline";
	document.getElementById("qc1").style.display="none";
	document.getElementById("qc2").style.display="none";
	document.getElementById("qc3").style.display="none";
}
function questioncontact() {
	document.getElementById("sideform").style.margin="-300px 0px 0px 0px";
	document.getElementById("fb2").style.display="inline";
	document.getElementById("fb2").style.display="inline";
	document.getElementById("qc1").style.display="inline";
	document.getElementById("qc2").style.display="inline";
	document.getElementById("qc3").style.display="inline";
	document.getElementById("qc4").style.display="inline";
	document.getElementById("fb1").style.display="none";
	document.getElementById("fb3").style.display="none";
}
function contactsubmit() {
	document.forms[0].action = "quickcontact.php";
		document.forms[0].target = "Quick Contact";
		openTarget(document.forms[0], 'width=350,height=250,resizable=0,scrollbars=0');
		//document.forms[0].submit();
		return true;
}
function openTarget (form, features, windowName) {
  if (!windowName) {
    windowName = 'formTarget' + (new Date().getTime());
  }
  form.target = windowName;
  open ('', windowName, features);
}
function emptyfield(field, initial) {
	if (document.getElementById(field).value == initial) {
		document.getElementById(field).value = "";
	}
}