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

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=0,scrollbars=auto,toolbar=no,status=yes,width=650,height=600');
 secwin.window.focus();
}

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

function validateRegForm(f){
	if (f.company_name.value==""){
		alert("Please enter the full trading name of your company");
		f.company_name.focus();
		return false;
	}else if(f.company_type.value==""){
		alert("Please choose an option for your company type");
		f.company_type.focus();
		return false;
	}else if(f.contact_name.value==""){
		alert("Please enter a contact name");
		f.contact_name.focus();
		return false;
	}else if(f.email.value==""){
		alert("Please enter an email address");
		f.email.focus();
		return false;
	}else if (!valid_email(f.email.value)){
		alert("You must enter a valid e-mail address");
		f.email.value="";
		f.email.focus();
		return false;
	}else if(f.phone.value==""){
		alert("Please enter a phone number");
		f.phone.focus();
		return false;
	}else if(f.addr1.value==""){
		alert("Please enter your address");
		f.addr1.focus();
		return false;
	}else if(f.town.value==""){
		alert("Please enter your town");
		f.town.focus();
		return false;
	}else if(f.county.value==""){
		alert("Please enter your county");
		f.county.focus();
		return false;
	}else if(f.postcode.value==""){
		alert("Please enter your postcode");
		f.postcode.focus();
		return false;
	}else if(f.pw.value==""){
		alert("Please enter a password");
		f.pw.focus();
		return false;		
	}else if(f.pw.value!=f.pw2.value){
		alert("Your password was not typed in the same both times, please try again");
		f.pw.value="";
		f.pw2.value="";
		f.pw.focus();
		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;
}