var selectedRegion = 0;

function array() { }
regionListing = new array();
regionListing[0] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;No Region Selected</p>";
regionListing[1] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;Scotland</p><ul><li>Aberdeen City<li>Aberdeenshire<li>Angus<li>Argyll and Bute<li>Scottish Borders<li>Clackmannanshire<li>West Dunbartonshire<li>Dumfries and Galloway<li>Dundee City<li>East Ayrshire<li>East Dunbartonshire<li>East Lothian<li>East Renfrewshire<li>City of Edinburgh<li>Falkirk<li>Fife<li>Glasgow City<li>Highland<li>Inverclyde<li>Midlothian<li>Moray<li>North Ayrshire<li>North Lanarkshire<li>Orkney Islands<li>Perth and Kinross<li>Renfrewshire<li>Shetland Islands<li>South Ayrshire<li>South Lanarkshire<li>Stirling<li>West Lothian<li>Comhairle nan Eilean Siar</ul>";
regionListing[2] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;North East</p><ul><li>Hartlepool<li>Middlesbrough<li>Redcar and Cleveland<li>Stockton-on-Tees<li>Darlington<li>Tyne and Wear<li>Northumberland<li>Durham</ul>";
regionListing[3] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;North West</p><ul><li>Halton<li>Warrington<li>Blackburn and Darwen<li>Blackpool<li>Greater Manchester<li>Merseyside<li>Cumbria<li>Lancashire<li>Cheshire</ul>";
regionListing[4] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;Yorkshire and The Humber</p><ul><li>Kingston upon Hull, City of<li>East Riding of Yorkshire<li>North East Lincolnshire<li>North Lincolnshire<li>York<li>South Yorkshire<li>North Yorkshire<li>West Yorkshire</ul>";
regionListing[5] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;East Midlands</p><ul><li>Derby<li>Leicester<li>Rutland<li>Nottingham<li>Derbyshire<li>Nottinghamshire<li>Lincolnshire<li>Leicestershire<li>Northamptonshire</ul>";
regionListing[6] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;West Midlands</p><ul><li>Herefordshire, County of<li>Telford and Wrekin<li>Stoke-on-Trent<li>Shropshire<li>Staffordshire<li>Warwickshire<li>Worcestershire<li>West Midlands</ul>";
regionListing[7] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;South West</p><ul><li>Bath and North East Somerset<li>Bristol, City of<li>North Somerset<li>South Gloucestershire<li>Plymouth<li>Torbay<li>Bournemouth<li>Poole<li>Swindon<li>Cornwall and Isles of Scilly<li>Devon<li>Dorset<li>Gloucestershire<li>Somerset<li>Wiltshire</ul>";
regionListing[8] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;South East</p><ul><li>Medway<li>Bracknell Forest<li>West Berkshire<li>Reading<li>Slough<li>Windsor and Maidenhead<li>Wokingham<li>Milton Keynes<li>Brighton and Hove<li>Portsmouth<li>Southampton<li>Isle of Wight<li>Buckinghamshire<li>East Sussex<li>Hampshire<li>Kent<li>Oxfordshire<li>West Sussex<li>Surrey</ul>";
regionListing[9] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;London</p><ul><li>City of London<li>Barking and Dagenham<li>Barnet<li>Bexley<li>Brent<li>Bromley<li>Camden<li>Croydon<li>Ealing<li>Enfield<li>Greenwich<li>Hackney<li>Hammersmith and Fulham<li>Haringey<li>Harrow<li>Havering<li>Hillingdon<li>Hounslow<li>Islington<li>Kensington and Chelsea<li>Kingston upon Thames<li>Lambeth<li>Lewisham<li>Merton<li>Newham<li>Redbridge<li>Richmond upon Thames<li>Southwark<li>Sutton<li>Tower Hamlets<li>Waltham Forest<li>Wandsworth<li>Westminster</ul>";
regionListing[10] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;East of England</p><ul><li>Peterborough<li>Luton<li>Southend-on-Sea<li>Thurrock<li>Bedfordshire<li>Cambridgeshire<li>Norfolk<li>Hertfordshire<li>Suffolk<li>Essex</ul>";
regionListing[11] = "<p class='Hdr2'>&nbsp;&nbsp;&nbsp;Wales</p><ul><li>Isle of Anglesey<li>Gwynedd<li>Conwy<li>Denbighshire<li>Flintshire<li>Wrexham<li>Powys<li>Ceredigion<li>Pembrokeshire<li>Carmarthenshire<li>Swansea<li>Neath Port Talbot<li>Bridgend<li>Vale of Glamorgan, The<li>Rhondda, Cynon, Taff<li>Merthyr Tydfil<li>Caerphilly<li>Blaenau Gwent<li>Torfaen<li>Monmouthshire<li>Newport<li>Cardiff</ul>";

function newImage(arg) 
{
	if (document.images) 
    {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() 
{
	if (document.images && (preloadFlag == true)) 
	{
		for (var i=0; i<changeImages.arguments.length; i+=2) 
        	{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
	if ( changeImages.arguments[0] == "boundaryMap" )
	{
		imageName = changeImages.arguments[1];
		imageName = imageName.substring(imageName.length-6, imageName.length);
		imageName = imageName.substring(0,2);
		if ( isNaN(imageName) )
		{
			imageName = imageName.substring(1,2);
		}
		selectedRegion = imageName;
	}
}

var preloadFlag = false;
function preloadNavImages() 
{
	if (document.images) 
	{
		companyinfo_01_over  = newImage("images/companyinfo_01-over.gif");
		contact_01_over      = newImage("images/contact_01-over.gif");
		products_01_over     = newImage("images/products_01-over.gif");
		demonstrator_01_over = newImage("images/demonstrator_01-over.gif");
		downloads_01_over    = newImage("images/downloads_01-over.gif");
		news_01_over         = newImage("images/news_01-over.gif");
		preloadFlag = true;
	}
}

function acceptLicense()
{
	window.location.href="sampleRequest.htm";
}

function rejectLicense()
{
	alert("You must agree to the license terms in order to proceed with your request for access to the Sample Data");
	window.location.href="products4.htm";
}

function submitFeedback()
{
	if ( document.feedbackForm.name.value == "" ||
		document.feedbackForm.email.value == "" ||
		document.feedbackForm.company.value == "" ||
		document.feedbackForm.comment.value == "" )
	{
		alert("Please supply your name, e-mail address and company name as minimal details before submitting your feedback.");
	} else {
		if ( document.feedbackForm.email.value.lastIndexOf("@") == -1 ||
			document.feedbackForm.email.value.lastIndexOf("@") == (document.feedbackForm.email.value.length-1) )
		{
			alert("It doesn't look as if you the email address you have specified is valid.  Please check it and resubmit your form.");
		} else {
			document.feedbackForm.action="/pointx/contact.jsp";
			document.feedbackForm.method="post";
			document.feedbackForm.submit();
		}
	}
}

function submitRequest()
{
	if ( document.sampleRequestForm.name.value == "" ||
		document.sampleRequestForm.email.value == "" ||
		document.sampleRequestForm.jobtitle.value == "" ||
		document.sampleRequestForm.company.value == "" ||
		document.sampleRequestForm.address1.value == "" ||
		document.sampleRequestForm.county.value == "" ||
		document.sampleRequestForm.postcode.value == "" ||
		document.sampleRequestForm.telephone.value == "" )
	{
		alert("Please complete all the fields in the form before submitting your request.");
	} else {
		if ( document.sampleRequestForm.email.value.lastIndexOf("@") == -1 ||
			document.sampleRequestForm.email.value.lastIndexOf("@") == (document.sampleRequestForm.email.value.length-1) )
		{
			alert("It doesn't look as if you the email address you have specified is valid.  Please check it and resubmit your form.");
		} else {
			document.sampleRequestForm.action="/pointx/sampleRequest.jsp";
			document.sampleRequestForm.method="post";
			document.sampleRequestForm.submit();
		}
	}
}

function listRegion()
{
	
	regionWin=open("", "regionWindow", "width=336,height=500,status=no,toolbar=no,menubar=no,scrollbars=yes");
	regionWin.document.open();
	
	regionWin.document.writeln("<HTML><HEAD><TITLE>PointX</TITLE><LINK REL='stylesheet' TYPE='text/css' HREF='style.css'></HEAD><BODY topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' border='0'>");
	regionWin.document.writeln("<TABLE BORDER=0 WIDTH='100%' cellspacing=0 cellpadding=0><TR><TD bgcolor='black'><IMG SRC='images/logo.gif' ALT='PointX Logo' BORDER=0></td></tr>");
	regionWin.document.writeln("<tr><td><img src='images/header.gif' border=0, alt='Our data takes you straight to the point'></td></tr>");
	regionWin.document.writeln("<tr><td><br>");
	regionWin.document.writeln(regionListing[selectedRegion]);
	regionWin.document.writeln("</td></tr>");
	regionWin.document.writeln("<tr><td>&nbsp;</td></tr>");
	regionWin.document.writeln("<tr><td align='right'><a class='regionLink' href='javascript:window.close();'><img src='images/close.gif' border=0 alt='Close Window'>&nbsp;&nbsp;&nbsp;</a></td></tr>");
	regionWin.document.writeln("</table></body></html>");
	
	regionWin.document.close();
}

function getPDF(filename)
{
	pdfWin=open("","pdfWindow","width=500,height=400,resizable=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes");
	pdfWin.document.open();
	pdfWin.document.writeln("<html><head><link rel='stylesheet' href='style.css' type='text/css'><meta HTTP-EQUIV='REFRESH' CONTENT='3; URL=" + filename +"'></head><body>");
	pdfWin.document.writeln("<h1>The document is being downloaded - this may take a few minutes<h1>");
	pdfWin.document.writeln("</body></html>");
	pdfWin.document.close();
}

function popupWindow(filename)
{
	popupWin=open("","popupWindow","width=500,height=400,resizable=no,status=no,toolbar=no,menubar=no,scrollbars=yes");
	popupWin.document.open();
	popupWin.document.writeln("<html><head><link rel='stylesheet' href='style.css' type='text/css'><meta HTTP-EQUIV='REFRESH' CONTENT='0; URL=" + filename +"'></head><body>");
	popupWin.document.writeln("<h1>The document is being downloaded - this may take a few minutes<h1>");
	popupWin.document.writeln("</body></html>");
	popupWin.document.close();
}

// selects all classes on the page
// since the only checkboxes are for the classes, it is enough to select 
// all checkboxes
function selectAllClasses()
{
	// Loop through all elements of form, setting all checkboxes
	for ( var i=0;i<document.forms[0].elements.length;i++)
	{
		if ( document.forms[0].elements[i].type  == 'checkbox' )
			document.forms[0].elements[i].checked = true;
	}
}
