<!--

// set up global variables

var item_name, first_name="", last_name="",coname1="";
InvoiceNumber = GenerateInvoiceNumber();


<!-- Copyright 2000 William Bontrager


// STEP 1:
// The JavaScript functions need to know how many items you
//   have for sale on your page. Change the number below to
//   the number of items you have for sale:

NumberOfItemsForSale = 11;


// Do not change the next eleven lines.
function MakeStringArray(n) {
	n++;
	this.length = n;
	for (var i = 1; i<=n; i++) { this[i] = new String(); }
	return this;
}

HiddenFieldNameForItemID = new MakeStringArray(NumberOfItemsForSale);
DescriptionForItemID = new MakeStringArray(NumberOfItemsForSale);
ItemCost = new MakeStringArray(NumberOfItemsForSale);
ItemHowManyFieldName = new MakeStringArray(NumberOfItemsForSale);
ItemSubTotalFieldName = new MakeStringArray(NumberOfItemsForSale);


// STEP 2
// The order form has hidden fields to relay identification
//   to your credit card processing service.
// Enter the hidden field names here, between quotes.
// The first hidden field name follows [1] and so forth, up
//   to the number of items you specified in step 1. The
//   sequential numbers are in brackets.

HiddenFieldNameForItemID[1] = "desc_premltd";
HiddenFieldNameForItemID[2] = "desc_regoff";
HiddenFieldNameForItemID[3] = "desc_cs";
HiddenFieldNameForItemID[4] = "desc_nom";
HiddenFieldNameForItemID[5] = "desc_namemon";
HiddenFieldNameForItemID[6] = "desc_remchvote";
HiddenFieldNameForItemID[7] = "desc_direnh";
HiddenFieldNameForItemID[8] = "desc_dorm";
HiddenFieldNameForItemID[9] = "desc_logodesign";
HiddenFieldNameForItemID[10] = "desc_virt";
HiddenFieldNameForItemID[11] = "desc_stationerydesign";
// STEP 3
// Each item you have for sale must also be identified by
//   description when it is ordered. The identification
//   can be with an item number, name, and/or narrative
//   description. It is for you, so you can recognize it
//   for what it is when you receive order confirmations
//   from your credit card authorization service. (In
//   step 2 you specified the hidden fields that will
//   relay this identification to your credit card
//   processing service.)
// Some credit card authorization services email your
//   customer with confirmation, in which case these
//   item descriptions should be clear enough for your
//   customers to understand what was ordered.
// Descriptions are typed between quotes. Therefore,
//   quotes within the ID must be preceeded with a back
//   slash. I.E.:
//           "The tome, \"Happy Happy\" by I.M. Writer";
// The sequential numbers are in brackets. Type the item
//   description in the same order as you typed the hidden
//   field names in setp 2, so that DescriptionForItemID[1]
//   is the description of the item in
//   HiddenFieldNameForItemID[1], and so forth.

DescriptionForItemID[1] = "#Prem Ltd";
DescriptionForItemID[2] = "#Reg Office";
DescriptionForItemID[3] = "#IncWise Company Secretary";
DescriptionForItemID[4] = "#Nominee Shareholder";
DescriptionForItemID[5] = "#Name Monitoring";
DescriptionForItemID[6] = "#Remove Chairmans Casting vote";
DescriptionForItemID[8] = "#Logo design";
DescriptionForItemID[9] = "#Virtual Office";
DescriptionForItemID[7] = "#Registered Office";
DescriptionForItemID[10] = "#Stationery";
DescriptionForItemID[11] = "#Stationery Design";


// STEP 4
// Specify the cost of each item you have for sale.
// Type the item cost in the same order as you typed the
//   the hidden field names in setp 2, so that ItemCost[1]
//   is the cost of the item in HiddenFieldNameForItemID[1],
//   and so forth.

ItemCost[1] = 55.00;
//ItemCost[2] = 111.63;
//ItemCost[3] = 176.25;
//ItemCost[4] = 176.25;
//ItemCost[5] = 176.25;
//ItemCost[6] = 29.38;
//ItemCost[7] = 29.38;
//ItemCost[8] = 205.63;
//ItemCost[9] = 176.25;
//ItemCost[10] = 411.25;
//ItemCost[11] = 58.75;
ItemCost[2] = 109.25;
ItemCost[3] = 172.5;
ItemCost[4] = 172.5;
ItemCost[5] = 172.5;
ItemCost[6] = 28.75;
ItemCost[7] = 28.75;
ItemCost[8] = 201.25;
ItemCost[9] = 172.5;
ItemCost[10] = 402.5;
ItemCost[11] = 57.5;


// STEP 5
// Specify the form field name where the customer will type
//   the quantity being ordered. Field names should contain
//   only letter, number, and underscore characters. I.E.:
//          <input type="text" name="num_tshirts" size="3">
// In the above example, the form field name is "num_tshirts".
// Type the field names in the same order as you typed the
//   the hidden field names in step 2.
// Form field names are typed between quotes.

ItemHowManyFieldName[1] = "prem_ltd";
ItemHowManyFieldName[2] = "registered_office";
ItemHowManyFieldName[3] = "company_secretary";
ItemHowManyFieldName[4] = "nominee_shareholder";
ItemHowManyFieldName[5] = "name_monitoring";
ItemHowManyFieldName[7] = "director_enhanced";
ItemHowManyFieldName[6] = "remove_chair_vote";
ItemHowManyFieldName[9] = "logo_design";
ItemHowManyFieldName[8] = "dormant_company";
ItemHowManyFieldName[10] = "virtual_office";
ItemHowManyFieldName[11] = "stationery_design";


// STEP 6
// Specify the form field name line subtotals, where the
//   product total will be displayed after the customer
//   types in how many they want. Field names should
//   contain only letter, number, and underscore
//   characters. I.E.:
//          <input type="text" name="sub_tshirts" size="3">
// In the above example, the form field name is "sub_tshirts".
// Type the field names in the same order as you typed the
//   hidden field names in step 2.
// Form field names are typed between quotes.

ItemSubTotalFieldName[1] = "sub_premltd";
ItemSubTotalFieldName[2] = "sub_regoff";
ItemSubTotalFieldName[3] = "sub_cs";
ItemSubTotalFieldName[4] = "sub_nom";
ItemSubTotalFieldName[5] = "sub_namemon";
ItemSubTotalFieldName[6] = "sub_remchvote";
ItemSubTotalFieldName[7] = "sub_direnh";
ItemSubTotalFieldName[8] = "sub_dorm";
ItemSubTotalFieldName[9] = "sub_logodesign";
ItemSubTotalFieldName[10] = "sub_stat";
ItemSubTotalFieldName[11] = "sub_stationerydesign";


// STEP 7
// Here is where you specify your shipping charges. You
//   can specify either by base price (could be flat rate)
//   or a percentage of the product total or both. Both of
//   the below two lines must have a value, which may be
//   0 (zero). If both are larger than 0, then the program
//   will calculate both into the shipping/handling charge.

BaseShippingCharge = 75;
ShippingChargeByPercentage = 0;




// STEP 8
// Here is where you specify your tax rate and whether or
//   not you collect tax on shipping/handling charges. Both
//   of the below two lines must have values -- the value
//   on the second line is within quotes. The first value
//   is the tax percentage you are collecting, which may be
//   0 (zero). The second value is either "yes" or "no".

TaxRate = 0;
CollectTaxOnShipping = "no";




// STEP 9
// Type in the name of the field name that will hold the
//   total amount to be charged to your customer's credit
//   card. This is the same field name you used on the form.
//   The field name is within quotes.

TotalAmountFieldName = "total_amount";

// No more customization is necessary.


function Image(url,w,h,tl,bgcolor,textcolor) {
// url of image, width of image, height of image, title text, background color, text color --
//    the first three must have values, the last three may be null.
	var title = '<br><b>' + tl + '</b>';
	var hh = String(parseInt(h,10)+67);
	if(tl.length <1) title = '';
	else hh = String(parseInt(hh) + parseInt((tl.length / (parseInt(w) / 7)) + 1) * 18);
	var bbc = ' bgcolor="' + bgcolor + '"';
	if(bgcolor.length <1) bbc = '';
	var ttc = ' text="' + textcolor + '"';
	if(textcolor.length <1) ttc = '';
	var Properties = 'height=' + hh + ',width=' + String(parseInt(w,10)+25);
	var pPicture = window.open('','',Properties);
	pPicture.document.writeln('<html><head><title>' + tl + '<\/title>');
	pPicture.document.writeln('<script language="JavaScript">');
	pPicture.document.writeln('<!-- ');
	pPicture.document.writeln('function CloseMe() {');
	pPicture.document.writeln('self.close();');
	pPicture.document.writeln('}');
	pPicture.document.writeln('\/\/ -->');
	pPicture.document.writeln('<\/script>');
	pPicture.document.write('<\/head><body ' + bbc + ttc + '" onBlur="CloseMe()"><center>');
	pPicture.document.write('<IMG SRC="' + url + '" width="' + w + '" height="' + h + '" border="0">');
	pPicture.document.write(title);
	pPicture.document.write('<p><form><input type="button" onClick="window.close()" value="Close Window"><\/form>');
	pPicture.document.writeln('<\/center><\/body><\/html>');
}

function Description(url,w,h) {
// url of web page, width of popup, height of popup --
//    all must have values.
	var attributes = 'resizable=yes,scrollbars=yes,' + 
	'width=' + w + ',height=' + h;
	window.open(url,"DescPopup",attributes);
}

function GenerateInvoiceNumber() {
	var d = new Date();
	return d.getTime();
}

function moneytize(n) {
	n = (n * 100) + .005;
	var s = n + 'z';
	n = parseInt(s);
	n /= 100;
	s = new String(n);
	var l = s.length;
	if(s.indexOf('.') == -1) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	if(s.indexOf('.') == (s.length - 1)) { s += '00'; }
	return s;
}


function initialize() {
	var counter = 1;
	var ii = 0;
	var sumof4=0;
	var csstr = getCSstring();
	var rostr = getROstring();

// Potentially multiple nominee shareholders, but only one charge per company
// Find whether there are any.
	var nomsh = 0;
	for (j=1; j<=document.forms[0].blocks.value; j++) {
		eval ("ns = (document.forms[0].nsdir"+j+".checked) ? 1 : 0;");
		if (ns) {nomsh++;}
	}

	for(counter = 1; counter <= NumberOfItemsForSale; counter++)
	{
		if(counter<50)
		{
			var ti=0;

			if ((counter==1 && document.contactb.prem_ltd.checked)
			|| (counter==2 && rostr=="Use IncWise")
			//|| (counter==3 && document.contactb.company_secretary.checked)
			|| (counter==3 && csstr=="Use IncWise")
			|| (counter==4 && nomsh>0)
			// ||(counter==5 && document.contactb.name_monitoring.checked)
			||(counter==6 && document.contactb.remove_chair_vote.checked)
			||(counter==7 && document.contactb.director_enhanced.checked)
			//||(counter==8 && document.contactb.dormant_company.checked)
			||(counter==8 && csstr=="Use Dormant")
			||(counter==9 && document.contactb.logo_design.checked)
			||(counter==10 && document.contactb.virtual_office.checked)
			||(counter==11 && document.contactb.stationery_design.checked)
			)

				{var ti=1;}
			else
				{var ti=0;}
		}
		else
		{
			var tss = '';
			var s = 'document.contactb.' + ItemHowManyFieldName[counter] + '.value';
			var ti = 0;
			var ts = 'parseInt(' + s + ')';

			ti = eval(ts);
		}

		if(isNaN(ti) || (ti < .01)) {
			ts = s + '="0"';
			ti = eval(ts);
			ti = 0;
			tss = 'document.contactb.' + HiddenFieldNameForItemID[counter] + '.value = ""';
		}
		else {
			tss = 'document.contactb.' + HiddenFieldNameForItemID[counter] + '.value = DescriptionForItemID[' + counter + ']';
		}
		tss = eval(tss);
		ts = 'ti = ' + ti + ' * parseFloat(' + ItemCost[counter] + ')';
		ti = eval(ts);
		tss = moneytize(ti);
		ii += parseFloat(tss);
		ts = new String(tss);
		if(ts.substring(0,1) == '.') { tss = '0' + tss; }
		ts = 'document.contactb.' + ItemSubTotalFieldName[counter] + '.value = tss';
		ts = eval(ts);
	}

	document.contactb.subtotal.value = "0.00";
	document.contactb.shipping.value = "0.00";
	document.contactb.tax.value = "0.00";
	ts = 'document.contactb.' + TotalAmountFieldName + '.value = "0.00"';
	document.contactb.total_amount1.value="0.00";
	document.contactb.total_amount2.value="0.00";
//	document.contactb.total_amount3.value="0.00";
	ts = eval(ts);
	return ii;
}


function calc() {
	var T = initialize();
	if(T < 0.01) { T=0; }
	T = moneytize(T);
	document.contactb.subtotal.value = T;
	var ti = (ShippingChargeByPercentage / 100) * parseFloat(T);
	ti += BaseShippingCharge;
	document.contactb.shipping.value = moneytize(ti);
//	if(document.contactb.charge_tax.checked)
	{
		var tax_s = new String(CollectTaxOnShipping);
		if((tax_s.substring(0,1) == 'y') || (tax_s.substring(0,1) == 'Y')) {
			document.contactb.tax.value = ((TaxRate / 100) * (T + parseFloat(document.contactb.shipping.value))) + .005;
		}
		else { document.contactb.tax.value = ((TaxRate / 100) * T) + .005; }
	}
//
	document.contactb.tax.value = moneytize(document.contactb.tax.value);
	ti = parseFloat(T) + parseFloat(document.contactb.shipping.value) + parseFloat(document.contactb.tax.value);
	ti = moneytize(ti);
	s = 'document.contactb.' + TotalAmountFieldName + '.value = "' + ti + '"';
	ti = eval(s);
	document.contactb.total_amount1.value=ti;
	document.contactb.total_amount2.value=ti;
//	document.contactb.total_amount3.value=ti;
//	document.contactb.total_amount4.value=ti;

	return ti;
}


//Process page
function processpage() {
//get timestamp
//Create new date object
	var date = new Date();
//Setup variables
	var year = date.getYear();
	var month = date.getMonth();
	var days = date.getDate();
	var hours = date.getHours();
	var mins = date.getMinutes();
	var secs = date.getSeconds();
//format variables for output
	year = year - 2000;
	month = month + 1;
	if(year < 10) year = "0" + year;
	if(month < 10) month = "0" + month;
	if(days < 10) days = "0" + days;
	if(hours < 10) hours = "0" + hours;
	if(mins < 10) mins = "0" + mins;
	if(secs < 10) secs = "0" + secs;
	item_name = year + month + days + hours + mins + secs;
	document.contactb.item_name.value = item_name;

//checkcookies

//set expiration time 10 seconds from now
	today = new Date();
	today.setTime(today.getTime() + 1000 * 10);
	var IncWiseicookie = "IncWiseicookie";
//	document.cookie = IncWiseicookie + ((today == null) ? "" : ";expires=" + today.toGMTString());
//	var readcookie = document.cookie;
//	readcookie = unescape(readcookie);
//	if(readcookie == "IncWiseicookie"){
		//do nothing
//	}else{
//		alert("check Your broswer may not have cookies enabled.  Please make a note of this reference number before continuing: " + item_name);
//	}
	//delete cookie by setting earlier date
//	today.setTime(today.getTime() - 1000);
//	document.cookie = IncWiseicookie + ((today == null) ? "" : ";expires=" + today.toGMTString());
//write form details to cookie
}


function writecookie(){
		//get form data
		first_name = document.contactb.ccfirstname.value;
		last_name = document.contactb.ccsurname.value;
		item_name = document.contactb.item_name.value;
		price_value=document.contactb.total_amount1.value;
		//set expiration time 1 minute from now
		var today = new Date();
		today.setTime(today.getTime() + 1000 * 60);
		var IncWiseicookie = "IncWiseicookie";
		//populate cookie variables
		IncWiseicookie = "NAME=IncWiseicookie" + escape("first_name=" + first_name + ";" + "last_name=" + last_name + ";" + "item_name=" + item_name + ";" + "price_value=" + price_value + ";");
		document.cookie = IncWiseicookie + ((today == null) ? "" : ";expires=" + today.toGMTString());
		var readcookie = document.cookie;
		readcookie = unescape(readcookie);
		//alert("Your broswer may not have cookies enabled.  Please make a note of this reference number before continuing: " + item_name);
		if(document.cookie.length > 0){
	//	alert("we have cookies");
		} else {
			alert("Your broswer may not have cookies enabled.  Please make a note of this reference number before continuing: " + item_name);
		}
//alert ("Cookie written");
}


function trim(str){
// Removes leading and trailing spaces from string
	if (str.length < 1) return "";
	str = ltrim (str);
	str = rtrim (str);
	return (str == "") ? "" : str;
}

function ltrim(str){
	while (str.substring(0, 1) == " ") {
		str = str.substring(1, str.length);
	}
	return str;
}

function rtrim(str){
	while (str.substring(str.length-1, str.length) == " ") {
		str = str.substring(0, str.length-1);
	}
	return str;
}


function checkform(contactb){
// Initial stuff - find number of directors and shareholders + blocks to check
// Sets up arrays of block locations for directors & shareholders
	calc();
	var dirarray = new Array();
	var shareholders = 0;

	blocks = contactb.blocks.value;
	var ct=0;
	for (i=1; i<=blocks; i++)
	{
		is_director = eval ("contactb.isdir"+i+".checked");
		is_shareholder = eval("contactb.isshdir"+i+".checked");
		num_shares = eval("contactb.sharesdir"+i+".value");
		if (is_director) {
			dirarray[ct] = i;
			ct++;
		}
		if (is_shareholder) {
			shareholders++;
		}
	}

	var checkcontact = contactb.entercontact.value;

// Company Secretary / Registered office checking flags
	var csstr = getCSstring();
	var rostr = getCSstring();
	var csincwise = (csstr == 'Use IncWise') ? true : false;
	var roincwise = (rostr == 'Use IncWise') ? true : false;

// Add variables to form for cross-checking
	contactb.numdir.value = dirarray.length;
	contactb.numsh.value = shareholders;

// Company name
	if (trim(contactb.coname1.value) == "") {
		alert("Please enter your proposed new company name.");contactb.coname1.focus();
		return false;
	}

	// Sensitive words
	if (ends_limited(contactb.coname1.value)) {
		stripped = stripltd(trim(contactb.coname1.value));
		dostrip = confirm("You do not need to enter the word \"Limited\" - we will do it for you.\n\nClick OK if you want the company name "+stripped+" Limited, or click Cancel to choose a different name.");
		if (dostrip) {
			contactb.coname1.value = stripped;
		} else {
			contactb.coname1.focus;
			return false;
		}

	}

	if (ends_limited(contactb.coname2.value)) {
		stripped = stripltd(trim(contactb.coname2.value));
		dostrip = confirm ("You do not need to enter the word \"Limited\" - we will do it for you.\n\nClick OK if you want the company name "+stripped+" Limited as your second choice, or click Cancel to choose a different name.")
		if (dostrip) {
			contactb.coname2.value = stripped;
		} else {
			contactb.coname2.focus;
			return false;
		}
	}

	if (is_sensitive(contactb.coname1.value)) {
		alert ("Your chosen company name contains a \"sensitive word\".  This means that you would need special permission to use this name.  Please choose a different name.\n\nTo see a list of sensitive words and expressions, click OK then click on the link in the right hand box.");
		contactb.coname1.focus;
		return false;
	}
	if (is_sensitive(contactb.coname2.value)) {
		alert ("One of your chosen company names contains a \"sensitive word\".  This means that you would need special permission to use this name.  Please choose a different name.\n\nTo see a list of sensitive words and expressions, click OK then click on the link in the right hand box.");
		contactb.coname2.focus;
		return false;
	}
// Check number of director and shareholder blocks
	if (dirarray.length == 0) {
		alert ("You must have at least one company director.");
		contactb.isdir_dir1.focus();
		return false;
	}

	if (shareholders == 0) {
		alert("You must have at least one shareholder holding one or more shares.");
		contactb.issh_dir1.focus();
		return false;
	}

// Registered office
	if (!roincwise) {		// Skip if IncWise is registered office
		if (trim(contactb.add1ro.value) == "") {
			alert("Please enter a registered office.");contactb.add1ro.focus();
			return false;
		}

		if (trim(contactb.townro.value) == "") {
			alert("Please enter a town for the registered office.");contactb.townro.focus();
			return false;
		}

		if (trim(contactb.postcodero.value) == "") {
			alert("Please enter a postcode for the registered office.");contactb.postcodero.focus();
			return false;
		}
	}


// Directors and shareholders - common details

	totest = new Array (
		'firstname',
		'surname',
		'add1',
		'town',
		'postcode',
		'eye',
		'townbirth',
		'mname');

	toinsert = new Array (
		'first name',
		'surname',
		'address',
		'address town',
		'postcode',
		'eye colour',
		'town of birth',
		'mother\'s maiden name');

	for (j=1; j<=blocks; j++) {
		expr = 'dir'+j;

		for (k=0; k<totest.length; k++) {
			tempobj = eval ("contactb."+totest[k]+expr);
			if (trim(tempobj.value) == "") {
				alert ("Please enter director / shareholder "+j+"\'s "+toinsert[k]+".");
				tempobj.focus();
				return false;
				}
		}
	}

// Directors only
	dirtotest = new Array (
		'na',
		'oc',
		'dobyear');

	dirtoinsert = new Array (
		'nationality',
		'occupation',
		'date of birth');

	for (m=0; m<dirarray.length; m++) {
		num = dirarray[m];	// Gives number of director / shareholder
		expr = 'dir'+num;

		// Compulsory fields
		for (n=0; n<dirtotest.length; n++) {
			tempobj = eval ("contactb."+dirtotest[n]+expr);
			if (trim(tempobj.value) == "") {
				alert ("Please enter director / shareholder "+num+"\'s "+dirtoinsert[n]+".");
				tempobj.focus();
				return false;
				}
		}

		// Date of birth
		eval ("testday = (contactb.dobday"+expr+".value)*1;");
		eval ("testmonth = (contactb.dobmonth"+expr+".value)*1;");
		eval ("testyear = (contactb.dobyear"+expr+".value)*1;");
		if (!valid_date(testday, testmonth, testyear)) {
			alert ("Please enter a valid date of birth for director / shareholder "+num);
			eval ("contactb.dobday"+expr+".focus();");
			return false;
		}

		// Other directorships - if there's a number, there must be a name
		for (p=1; p<=5; p++) {
			eval("conum = trim(contactb.cono"+p+expr+".value);");
			eval("coname = trim(contactb.coname"+p+expr+".value);");
			switch (true) {
				case (('' == conum) && ('' == coname)):
					break;
				case (('' != conum) && ('' != coname)):
					break;
				case (('' == conum) && ('' != coname)):
					alert ("Please enter a company number for director / shareholder "+num+"'s other directorship.");
					eval ("contactb.cono"+p+expr+".focus();");
					return false;
				case (('' != conum) && ('' == coname)):
					alert ("Please enter a company name for director / shareholder "+num+"'s other directorship.");
					eval ("contactb.coname"+p+expr+".focus();");
					return false;
			}
		}
	}

// Company secretary
	nocosec = ((trim(contactb.csfirstname.value) == "") && (trim(contactb.cssurname.value) == ""));
	if (!csincwise && !nocosec) {
		/* DEPRECATED
		if (dirarray.length == 1) {
			soledirfirstname = eval ("contactb.firstnamedir"+dirarray[0]);
			soledirsurname = eval ("contactb.surnamedir"+dirarray[0]);
			if (trim(contactb.csfirstname.value) == trim(soledirfirstname.value) &&
				trim(contactb.cssurname.value) == trim(soledirsurname.value)) {
				alert("If the company only has one director, that person cannot also be the company secretary.  If you do not have anyone to act as the company secretary, you can ask us to do it for you, by selecting \"Use IncWise Company Secretary Service\".");contactb.csfirstname.focus();
				return false;
			}
		}
		*/

		if (trim(contactb.csfirstname.value) == "") {
			alert("Please enter your company secretary's first name.  If you do not have anyone to act as the company secretary, you can ask us to do it for you, by selecting \"Use IncWise Company Secretary Service\".");contactb.csfirstname.focus();
			return false;
		}

		if (trim(contactb.cssurname.value) == "") {
			alert("Please enter your company secretary's surname.");contactb.cssurname.focus();
			return false;
		}

		if (trim(contactb.csadd1.value) == "") {
			alert("Please enter your company secretary's address.");contactb.csadd1.focus();
			return false;
		}

		if (trim(contactb.cstown.value) == "") {
			alert("Please enter your company secretary's address town.");contactb.cstown.focus();
			return false;
		}

		if (trim(contactb.cspostcode.value) =="") {
			alert("Please enter your company secretary's postcode.");contactb.cspostcode.focus();
			return false;
		}

		if (trim(contactb.cseye.value) == "") {
			alert("Please enter your company secretary's eye colour.");contactb.cseye.focus();
			return false;
		}

		if (trim(contactb.cstownbirth.value) =="") {
			alert("Please enter your company secretary's town of birth.");contactb.cstownbirth.focus();
			return false;
		}

		if (trim(contactb.csmname.value) == "") {
			alert("Please enter your company secretary's mother's maiden name.");contactb.csmname.focus();
			return false;
		}
	}

// Contact details
	if (checkcontact) {
		if (trim(contactb.ccfirstname.value) == "") {
			alert("Please enter your first name.");contactb.ccfirstname.focus();
			return false;
		}

		if (trim(contactb.ccsurname.value) == "") {
			alert("Please enter your surname.");contactb.ccsurname.focus();
			return false;
		}

		if (!valid_email(contactb.ccemail.value)) {
			alert ("Please enter a valid e-mail address.");
			contactb.ccemail.focus();
			return false;
		}

		if (trim(contactb.ccadd1.value) == "") {
			alert("Please enter your address.");contactb.ccadd1.focus();
			return false;
		}

		if (trim(contactb.cctown.value) == "") {
			alert("Please enter your address town.");contactb.cctown.focus();
			return false;
		}

		if (trim(contactb.ccpostcode.value) == "") {
			alert("Please enter your postcode.");contactb.ccpostcode.focus();
			return false;
		}

		if (trim(contactb.cccountry.value) == "") {
			alert("Please enter your country.");contactb.cccountry.focus();
			return false;
		}
	}

// Terms of business

	if (!contactb.agree_terms.checked) {
		alert( "Please check the box to indicate that you have read and accept our terms of business.");contactb.agree_terms.focus();
		return false;
	}

// If this point is reached, the form is deemed ok.
//alert ("About to write cookie");
	writecookie();
	return true;
}

// Short form used in 1-click incorporation
function check1click(contactb){
	calc();

// Company name
	if (trim(contactb.coname1.value) == "") {
		alert("Please enter your proposed new company name.");contactb.coname1.focus();
		return false;
	}

	// Sensitive words
	if (ends_limited(contactb.coname1.value)) {
		stripped = stripltd(trim(contactb.coname1.value));
		dostrip = confirm("You do not need to enter the word \"Limited\" - we will do it for you.\n\nClick OK if you want the company name "+stripped+" Limited, or click Cancel to choose a different name.");
		if (dostrip) {
			contactb.coname1.value = stripped;
		} else {
			contactb.coname1.focus();
			return false;
		}

	}

	if (is_sensitive(contactb.coname1.value)) {
		alert ("Your chosen company name contains a \"sensitive word\".  This means that you would need special permission to use this name.  Please choose a different name.\n\nTo see a list of sensitive words and expressions, click OK then click on the link in the right hand box.");
		contactb.coname1.focus();
		return false;
	}

	if (!valid_email(contactb.ccemail.value)) {
		alert ("Please enter a valid e-mail address.");
		contactb.ccemail.focus();
		return false;
	}

// Terms of business

	if (!contactb.agree_terms.checked) {
		alert( "Please check the box to indicate that you have read and accept our terms of business.");contactb.agree_terms.focus();
		return false;
	}

// If this point is reached, the form is deemed ok.
	writecookie();
	return true;
}

// Subsidiary functions
// Validate a date
// Assumes date, month and year submitted as integers
function valid_date(day, month, year) {
	switch (month) {
		case 4:
		case 6:
		case 9:
		case 11:
			maxdays = 30;
			break;
		case 2:
			if (Math.floor(year/4) == (year/4))		// Will work until 2118!
				maxdays = 29;
			else maxdays = 28;
			break;
		default:
			maxdays = 31;
	}
	if (day <= maxdays) return true;
		else return false;
}

function valid_email(email) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
	if (filter.test(email)) return true;
	else return false;
}


function is_sensitive(co) {
	sensitivewords = new Array (
		'abortion',
		'anzac',
		'apothecary',
		'apothecaries',
		'architect',
		'association',
		'assurance',
		'assurer',
		'authority',
		'benevolent',
		'board',
		'british',
		'chamberofbusiness',
		'chambersofbusiness',
		'chamberofcommerce',
		'chambersofcommerce',
		'chamberofenterprise',
		'chambersofenterprise',
		'chamberofindustry',
		'chambersofindustry',
		'chamberoftrade',
		'chambersoftrade',
		'charitable',
		'charity',
		'charter',
		'chemist',
		'chiropodist',
		'contactlens',
		'cooperative',
		'council',
		'creditunion',
		'dental',
		'dentist',
		'dietician',
		'drug',
		'duke',
		'england',
		'english',
		'european',
		'federation',
		'foundation',
		'friendlysociety',
		'fund',
		'genevacross',
		'greatbritain',
		'group',
		'healthcentre',
		'healthservice',
		'healthvisitor',
		'hermajesty',
		'hismajesty',
		'holding',
		'industrialandprovidentsociety',
		'institute',
		'insurer',
		'international',
		'intl',
		'ireland',
		'irish',
		'king',
		'limited',
		'medicallaboratory',
		'midwife',
		'national',
		'nursing',
		'occupationaltherapist',
		'olympiad',
		'olympian',
		'olympic',
		'opthalmic',
		'optician',
		'optometrist',
		'orthoptist',
		'patent',
		'pharmaceutical',
		'pharmaceutist',
		'pharmacist',
		'pharmacy',
		'pharmacies',
		'physiotherapist',
		'plc',
		'police',
		'polytechnic',
		'postoffice',
		'pregnancy',
		'prince',
		'queen',
		'radiographer',
		'reassurer',
		'redcrescent',
		'redcross',
		'redlionandsun',
		'register',
		'remedialgymnast',
		'royal',
		'scotland',
		'scottish',
		'sheffield',
		'society',
		'specialschool',
		'stockexchange',
		'technician',
		'termination',
		'tradeunion',
		'trust',
		'unitedkingdom',
		'university',
		'vet',
		'wales',
		'welsh',
		'windsor');

	co = stripchars(co);
	match = false;
	limit = sensitivewords.length;
	for (i=0; i<limit; i++) {
		if (co.indexOf(sensitivewords[i]) != -1) {
			match = true;
			break;
		}
	}
	if (match) return true;
	else return false;
}

function ends_limited(str) {
	str = trim(str);
	len = str.length;
	if ((str.lastIndexOf('ltd.') == (len-4) && len>4)
		|| (str.lastIndexOf('ltd') == (len-3) && len>3)
		|| (str.lastIndexOf('limited') == (len-7) && len>7))
		return true;
	else return false;
}

function stripchars(str) {
	str = str.toLowerCase();
	str = str.replace(/ /g,"");
	str = str.replace(/-/g,"");
	str = str.replace(/&/g,"and");
	return str;
}

function stripltd(str) {
	str = trim(str);
	len = str.length;
	if (str.lastIndexOf('ltd.') == (len-4))
		str = str.substr(0, len-4);
	else if (str.lastIndexOf('ltd') == (len-3))
		str = str.substr(0, len-3);
	else if (str.lastIndexOf('limited') == (len-7))
		str = str.substr(0, len-7);
	return trim(str);
}

function getCSstring() {
	if (typeof(document.forms[0].cs.value) == 'string') {
		return document.forms[0].cs.value;
	} else {
		for (i=0;i<document.forms[0].cs.length;i++)
		{
			if (document.forms[0].cs[i].checked)
			{
				return document.forms[0].cs[i].value;
			}
		}
	}
	return false;
}

function getROstring() {
	if (typeof(document.forms[0].registered_office) == 'string') {
		return document.forms[0].registered_office.value;
	} else {
		for (i=0;i<document.forms[0].registered_office.length;i++)
		{
			if (document.forms[0].registered_office[i].checked)
			{
				return document.forms[0].registered_office[i].value;
			}
		}
	}
	return false;
}

//-->
