
function _openwin(page){
 window.open(page, 'helpWindow', 'location=no,scrollbars=yes,toolbar=no,width=300,height=400');
}

function _open_telwin(page){
 telwin=window.open(page+'&ref='+window.location, "tel", 'location=no,scrollbars=yes,toolbar=no,status=yes,width=473,height=400,resizable=yes');
 telwin.window.focus();
}

function sure(text){
 if (confirm(text)) 
	  return (true); 
  else 
	  return (false);
}

function updQuant(i){
	var f="prodform"+i;
	var e="quant"+i;
	p=document.getElementById(f);
	q=document.getElementById(e);
	p.quant.value=q.value;
	p.submit();
}

function frmsubmit(func) {
	//alert(func);
	document.basket.func.value = func;
	document.basket.submit();
}

function _opensecwin(url){
secwin=window.open(url, 'securewin', 'location=yes,scrollbars,width=786,height=600');
 secwin.window.focus();
}

function _openemailpagewin(){
	epagewin=window.open('emailpage.html', 'epwin', 'location=no,scrollbars,status=no,width=500,height=350');
	epagewin.window.focus();
}


function launchcalculator(prod_id,formid,quantid){
calcwin=window.open('calculator5445.html?id='+prod_id+'&form='+formid+'&quant='+quantid, 'calcwin', 'location=no,scrollbars=yes,toolbar=no,status=no,resizable=no,width=345,height=460');
 calcwin.window.focus();
}


function validateForm(){
 if(document.sp_form.email.value==""){
	alert("Please type in your email address");
	document.sp_form.email.focus();
	document.sp_form.email.style.backgroundColor='ffff00';
	return false;
}else if(document.sp_form.email.value!=document.sp_form.email2.value){
	alert("Please type in your email address the same both times");
	document.sp_form.email.focus();
	document.sp_form.email.style.backgroundColor='ffff00';
	return false;
 } else if (!valid_email(document.sp_form.email.value)){
		alert("You must enter a valid e-mail address");
		document.sp_form.email.focus();
		document.sp_form.email.style.backgroundColor='ffff00';
		return (false);
 }else{
	return true;
 }
}

function valid_email(addr) {
	if (matchit(addr)==null){
		//alert("This is not a genuine e-mail address.");
		return (false);
	} else {
		return (true);
	}
}

function matchit(email){
	var result= email.match(/(^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$)/gi);
	return result;
}

function validateRegForm() {
	if (document.regform.email.value == ""){
		document.regform.email.style.backgroundColor='ffff00';
		alert("You must enter your e-mail address");
		document.regform.email.focus();
		return (false);
	}else if (!valid_email(document.regform.email.value)){
		document.regform.email.style.backgroundColor='ffff00';
		alert("You must enter a valid e-mail address");
		document.regform.email.value="";
		document.regform.email.focus();
		return (false);
	}else if (document.regform.firstname.value == ""){
		document.regform.firstname.style.backgroundColor='ffff00';
		alert("You must enter your firstname");
		document.regform.firstname.focus();
		return (false);
	}else if (document.regform.lastname.value == ""){
		document.regform.lastname.style.backgroundColor='ffff00';
		alert("You must enter your last name");
		document.regform.lastname.focus();
		return (false);
	}else if (document.regform.pass.value == ""){
		document.regform.pass.style.backgroundColor='ffff00';
		alert("You must enter a password");
		document.regform.pass.focus();
		return (false);
	}else if (document.regform.pass2.value == ""){
		document.regform.pass2.style.backgroundColor='ffff00';
		alert("You must re-enter your password");
		document.regform.pass2.focus();
		return (false);
	}else if (document.regform.pass2.value != document.regform.pass.value){
		document.regform.pass.style.backgroundColor='ffff00';
		document.regform.pass2.style.backgroundColor='ffff00';
		document.regform.pass2.value='';
		document.regform.pass.value='';
		alert("Your passwords must be exactly the same each time you type them in.");
		document.regform.pass.focus();
		return (false);
	}else {
		document.regform.submit();
		return (true);
	}
}

function validateForm2() {
	if (document.finform.firstname.value == ""){
		document.finform.firstname.style.backgroundColor='ffff00';
		alert("You must enter your firstname");
		document.finform.firstname.focus();
		return (false);
	}else if (document.finform.lastname.value == ""){
		document.finform.lastname.style.backgroundColor='ffff00';
		alert("You must enter your last name");
		document.finform.lastname.focus();
		return (false);
	}else if (document.finform.addr1.value == ""){
		document.finform.addr1.style.backgroundColor='ffff00';
		alert("You must enter an address");
		document.finform.addr1.focus();
		return (false);
	}else if (document.finform.town.value == ""){
		document.finform.town.style.backgroundColor='ffff00';
		alert("You must enter a town");
		document.finform.town.focus();
		return (false);
	}else if (document.finform.postcode.value == ""){
		document.finform.postcode.style.backgroundColor='ffff00';
		alert("You must enter a postcode");
		document.finform.postcode.focus();
		return (false);
	}else if (document.finform.country.selectedIndex == 0){
		alert("You must select a country");
		document.finform.country.focus();
		return (false);
	}else if (document.finform.tel.value == ""){
		document.finform.tel.style.backgroundColor='ffff00';
		alert("You must enter a telephone number");
		document.finform.tel.focus();
		return (false);
	}else {
		document.finform.submit();
		return (true);
	}
}

function validateLoginForm(){
 if(document.loginform.email.value==""){
	alert("Please type in your email address");
	document.loginform.email.focus();
	document.loginform.email.style.backgroundColor='ffff00';
	return false;
 } else if (!valid_email(document.loginform.email.value)){
		alert("You must enter a valid e-mail address");
		document.loginform.email.focus();
		document.loginform.email.style.backgroundColor='ffff00';
		return (false);
}else if (document.loginform.pass.value == ""){
		document.loginform.pass.style.backgroundColor='ffff00';
		alert("You must enter a password");
		document.loginform.pass.focus();
		return (false);
 }else{
	return true;
 }
}