function ViewChargeableHelp(chid) {

	var winWidth = 300;

	var winHeight = 300;

	var winLeft = (screen.width - winWidth)/2;

	var winTop = (screen.height - winHeight)/2;

	newWin = window.open('chargeablehelp.php?chid='+chid,'','width='+winWidth+',height='+winHeight+',left='+winLeft+',top='+winTop+',sizeable=no,toolbar=no,status=no');

}

function ChangeSelect(chid,choid) {

	box = eval("document.chargeables.charge"+chid);

	box.value = choid;

	document.chargeables.submit();

}
function ForgotPass() {
	newWin = window.open('/forgotpass.php','','width=280,height=200,toolbar=no,status=no');

}
function ViewNonchargeHelp(ncid) {

	var winWidth = 300;

	var winHeight = 300;

	var winLeft = (screen.width - winWidth)/2;

	var winTop = (screen.height - winHeight)/2;

	newWin = window.open('nonchargehelp.php?ncid='+ncid,'','width='+winWidth+',height='+winHeight+',left='+winLeft+',top='+winTop+',sizeable=no,toolbar=no,status=no');

}




function CheckThisBox(boxref) {
	box = eval("document.UserDetailsForm."+boxref);
	box.checked=!box.checked;

}
function LaunchConverter() {

	newWin = window.open('/converter.php','','width=200,height=140,left=200,top=200,sizeable=no,toolbar=no,status=no');

}

function ChangeSlat() {

	document.productpriceform.submit();

}

function GetPrice() {

	document.productpriceform.submit();

}

function GoNonCharge() {

	// POPULATE THE FORM

	document.productform.userwidth.value=document.productpriceform.userwidth.value;

	document.productform.userdrop.value=document.productpriceform.userdrop.value;

	document.productform.submit();

}


function CheckAndFillEnquiry() {

	var EnqBox = document.EnquiryForm.EnquiryBox;

	if (EnqBox.innerHTML=='') {

		EnqBox.innerHTML='Please type your enquiry here';

	}

}

function CheckAndClearEnquiry() {

	var EnqBox = document.EnquiryForm.EnquiryBox;

	if (EnqBox.innerHTML=='Please type your enquiry here') {

		EnqBox.innerHTML='';

	}

}

function ValidateEmail(strInput) {
	var x = strInput;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {return true;}
	else {return false;}
}

function ValidateEnquiry() {
	var EnqForm = document.EnquiryForm

	if (EnqForm.firstname.value=='') {
		alert('Please enter your first name to submit your enquiry');
	}
	else if (EnqForm.lastname.value=='') {
		alert('Please enter your last name to submit your enquiry');
	}
	else if (!ValidateEmail(EnqForm.email.value)) {
		alert('Please enter a valid e-mail address to submit your enquiry');
	}
	else if (EnqForm.elements['EnquiryBox'].value=='Please type your enquiry here' || EnqForm.elements['EnquiryBox'].value=='') {
		alert('Please enter your enquiry\n' + EnqForm.elements['EnquiryBox'].value);
	}
	else {
		EnqForm.submit();
	}

}

function OpenWindow(url) {
	newWin = window.open(url,'','');

}

function DoSelectCheck() {
	if(NonchargeSelectCheck()){
		document.getElementById('errMsg').display="block";
	}else{
		document.chargeables.c.value="AddToCart";
		document.chargeables.submit();
	}
}
function NonchargeSelectCheck() {

	var FoundProblem = false;
	for (a=0;a<document.chargeables.elements.length;a++) {

		if (document.chargeables.elements[a].value=="0" && document.chargeables.elements[a].className=="required") {

			document.chargeables.elements[a].style.background='#1b75bb';

			document.chargeables.elements[a].style.color='white';

			FoundProblem = true;

		}

	}

	for (a=0;a<document.chargeables.elements.length;a++) {

		if (document.chargeables.elements[a].value=="0") {

			document.chargeables.elements[a].focus();

			break;

		}

	}

	return FoundProblem;

}