// dmap_routines.js : routines for dynamic map construction and display
// (C)2006 Martin Baxter

// Consitutency names, co-ordinates and shapes
DataBlock = new Array(
	"Aberavon", "5710571158105910BCB6",
"Aberconwy", "421143114312441256F6",
"Aberdeen North", "06160617061806196C94",
"Aberdeen South", "07160717071807196CC7",
"Aberdeenshire West and Kincardine", "07140715081508166F67",
"Airdrie and Shotts", "1419142015191520BE6C",
"Aldershot", "6929693070297030BF6C",
"Aldridge-Brownhills", "35543654365536561694",
"Altrincham and Sale West", "2651275128512951BBB6",
"Alyn and Deeside", "43134314431543166CCC",
"Amber Valley", "4325432644254426BF6C",
"Angus", "0813081409130914BF6C",
"Arfon", "4411451145124513B6CC",
"Argyll and Bute", "1311141115101511BB2C",
"Arundel and South Downs", "79327933793479356CCC",
"Ashfield", "4229432944294529BBB6",
"Ashford", "7547764576467647B6CC",
"Ashton under Lyne", "21552156225622576F6C",
"Aylesbury", "62316232623363336CF6",
"Ayr Carrick and Cumnock", "1915201420152016B6CC",
"Ayrshire Central", "19111912191319146CCC",
"Ayrshire North and Arran", "18091810181118126CCC",
"Banbury", "5829583059295930BF6C",
"Banff and Buchan", "041404150514061454B6",
"Barking", "60676068616862686FB6",
"Barnsley Central", "2261226223612362BF6C",
"Barnsley East", "2164226322642363BBC6",
"Barrow and Furness", "2517261626172618B2CC",
"Basildon and Billericay", "6543664367436744BB6C",
"Basildon South and East Thurrock", "6942704170427043B6CC",
"Basingstoke", "7026702771267127BF6C",
"Bassetlaw", "3930393140304031BF6C",
"Bath", "6819682069196920BF6C",
"Batley and Spen", "1760185918601861B6CC",
"Battersea", "6459655865596659B6F6",
"Beaconsfield", "65326533653466346CF6",
"Beckenham", "69646965696669676CC7",
"Bedford", "5636573658365936BBB6",
"Bedfordshire Mid", "5735583559356035BBB6",
"Bedfordshire North East", "5537563757375837BBB6",
"Bedfordshire South West", "61356136623663366FB6",
"Bermondsey and Old Southwark", "6361636264616462BF6C",
"Berwick-upon-Tweed", "2023202421232124BF6C",
"Berwickshire, Roxburgh and Selkirk", "1828192619271928A6C7",
"Bethnal Green and Bow", "6065616361646165B6CC",
"Beverley and Holderness", "323333323333333416C4",
"Bexhill and Battle", "7747774878477947BCB6",
"Bexleyheath and Crayford", "6370646864696470A6C7",
"Birkenhead", "27392740274128416C83",
"Birmingham Edgbaston", "4352435344524552BCB6",
"Birmingham Erdington", "3855395540554056BB6C",
"Birmingham Hall Green", "43554356445645566FB6",
"Birmingham Hodge Hill", "4155415641574255BC76",
"Birmingham Ladywood", "41534154425443546FB6",
"Birmingham Northfield", "4453445444554553BCC6",
"Birmingham Perry Barr", "38533854395440546FB6",
"Birmingham Selly Oak", "4554455546544655BF6C",
"Birmingham Yardley", "42564257435744576FB6",
"Bishop Auckland", "2520252126202720BCB6",
"Blackburn", "3220322133193320BC6C",
"Blackley and Broughton", "21532154225422556F6C",
"Blackpool North and Cleveleys", "2816281729162917BF6C",
"Blackpool South", "2918301630173018B6CC",
"Blaenau Gwent", "5216521753165317BF6C",
"Blaydon", "30033004300530066CCC",
"Blyth Valley", "21252126212721286CC7",
"Bognor Regis and Littlehampton", "80318032803381326FC6",
"Bolsover", "4026412641274128B6CC",
"Bolton North East", "185018511950205059B6",
"Bolton South East", "2149215022482249BC6C",
"Bolton West", "18481849194920492EB6",
"Bootle", "23402341244124426F6C",
"Boston and Skegness", "4536453746364637BD67",
"Bosworth", "52285229532953306F6C",
"Bournemouth East", "7422752276227722BBB6",
"Bournemouth West", "7321742175217621BBB6",
"Bracknell", "67296730683068316F6C",
"Bradford East", "1458145915581559BF6C",
"Bradford South", "1659166017581759BC6C",
"Bradford West", "1557165716581757BBC6",
"Braintree", "5843584459435944BD6C",
"Brecon and Radnorshire", "4717481749175017BBB6",
"Brent Central", "5658575757585857BBC6",
"Brent North", "5656565757565856BCB6",
"Brentford and Isleworth", "6253625462556353BCC6",
"Brentwood and Ongar", "6843684469436944BF6C",
"Bridgend", "5811591160106011BB6C",
"Bridgwater and West Somerset", "701370147015711359C6",
"Brigg and Goole", "3531363136323633B6CC",
"Brighton Kemptown", "7844794480448144BBB6",
"Brighton Pavilion", "78427843794380436FB6",
"Bristol East", "6619662067196720BF6C",
"Bristol North West", "641665166517651856CC",
"Bristol South", "6617661867176718BF6C",
"Bristol West", "66156616671567165F6C",
"Broadland", "48404841494149422E6C",
"Bromley and Chislehurst", "6666666767666866BCB6",
"Bromsgrove", "57215722572357246CCC",
"Broxbourne", "6640664167406741BF6C",
"Broxtowe", "4629472948294830BB6C",
"Buckingham", "5932603160326131BBC6",
"Burnley", "3222322333223323BF6C",
"Burton", "4624472448244825BB6C",
"Bury North", "17521852185319525BC6",
"Bury South", "1951205120522053B6CC",
"Bury St Edmunds", "5342544255425642BBB6",
"Caerphilly", "5414551456145714BBB6",
"Caithness Sutherland and Easter Ross", "061106120711081159B6",
"Calder Valley", "17551756185618572F6C",
"Camberwell and Peckham", "6561656266616662BF6C",
"Camborne and Redruth", "76047704780479045BB3",
"Cambridge", "5539563957395839BBB6",
"Cambridgeshire North East", "5339543954405540B6F6",
"Cambridgeshire North West", "5037513752375337BBB6",
"Cambridgeshire South", "5738583859385939BB6C",
"Cambridgeshire South East", "5640574058405940BBB6",
"Cannock Chase", "50225023502451246CF6",
"Canterbury", "7349735074487449BC6C",
"Cardiff Central", "5915601460156115B6F6",
"Cardiff North", "58125813581458156CCC",
"Cardiff South and Penarth", "6114621262136214B6C7",
"Cardiff West", "5913591460136113BCB6",
"Carlisle", "23172318241825186FB6",
"Carmarthen East and Dinefwr", "51145115511651176CCC",
"Carmarthen West and Pembrokeshire South", "51075108510951102CCC",
"Carshalton and Wallington", "7058715871597259B6F6",
"Castle Point", "6845694570447045BB67",
"Ceredigion", "50135014501550162999",
"Charnwood", "4833483449334934BF6C",
"Chatham and Aylesford", "7244724573447345BF6C",
"Cheadle", "2754285429532954BB67",
"Chelmsford", "6243634363446443BBC6",
"Chelsea and Fulham", "6358635964576458BC6C",
"Cheltenham", "6124612562246225BF6C",
"Chesham and Amersham", "6234633464336434BB6C",
"Chester, City of", "42164217431744176FB6",
"Chesterfield", "4227422843274328BF6C",
"Chichester", "7831783278337931BCC6",
"Chingford and Woodford Green", "54665467556755682864",
"Chippenham", "6522662266236723B6F6",
"Chipping Barnet", "54605461556055615F6C",
"Chorley", "3317331834173418BF6C",
"Christchurch", "7223732374237523BBB6",
"Cities of London and Westminster", "62596260626163606FC6",
"Clacton", "6146614762466247BD67",
"Cleethorpes", "3733383238333933B6D6",
"Clwyd South", "45144515451645176CCC",
"Clwyd West", "40124112421242135B6C",
"Coatbridge, Chryston and Bellshill", "1418151816171618BB6C",
"Colchester", "6043604461436144BF6C",
"Colne Valley", "20582059215922596FB6",
"Congleton", "4320432144204421BF6C",
"Copeland", "23152316241624172F6C",
"Corby", "5136523653365436BBB6",
"Cornwall North", "720873077308740755C6",
"Cornwall South East", "7408750775087607BBC3",
"Cotswolds, The", "63236324632563266CCC",
"Coventry North East", "44604560456146611683",
"Coventry North West", "43594459455946591BB6",
"Coventry South", "4660475847594760B6C7",
"Crawley", "7838793679377938B6CC",
"Crewe and Nantwich", "4319441945194520BB6C",
"Croydon Central", "70627063706471636F73",
"Croydon North", "6959705970607061B6CC",
"Croydon South", "7160716171627260BCC3",
"Cumbernauld, Kilsyth and Kirkintilloch East", "13151316131713186CCC",
"Cynon Valley", "5213531354135513BBB6",
"Dagenham and Rainham", "6069616962696270BB67",
"Darlington", "2623272127222723B6CC",
"Dartford", "7141724172427342B6F6",
"Daventry", "5532563156325731BBC6",
"Delyn", "4114411542144215BF6C",
"Denton and Reddish", "2355235624552555BCB6",
"Derby North", "4525452646254626BF6C",
"Derby South", "4827482849274928BF6C",
"Derbyshire Dales", "4124422443244424BBB6",
"Derbyshire Mid", "4427452746274727BBB6",
"Derbyshire North East", "4025412542254226BB6C",
"Derbyshire South", "47254726482649266FB6",
"Devizes", "6724672567266824BCC6",
"Devon Central", "7111721072117212B6CC",
"Devon East", "7316741675167517BB6C",
"Devon North", "701070117012711229E6",
"Devon South West", "7311741174127512B6F6",
"Devon West and Torridge", "71097110720973095CB6",
"Dewsbury", "2160216121622260BCC6",
"Don Valley", "2367236824672567B7A3",
"Doncaster Central", "22652266226722686CC7",
"Doncaster North", "21652166216721682994",
"Dorset Mid and Poole North", "7219722072217319BCC6",
"Dorset North", "7122712372227322BCB6",
"Dorset South", "7419751875197619B6F6",
"Dorset West", "7317731874177418BF6C",
"Dover", "7351745074517550BB73",
"Dudley North", "40484049405041496FC6",
"Dudley South", "42484249434843495F6C",
"Dulwich and West Norwood", "6762686269616962BB6C",
"Dumfries and Galloway", "2017201820192117BCC6",
"Dumfriesshire, Clydesdale and Tweeddale", "1823192319241925B6CC",
"Dunbartonshire East", "14141415141614176CCC",
"Dunbartonshire West", "1312141214131513B6F6",
"Dundee East", "09150916101611166FB6",
"Dundee West", "1014101511141115BF6C",
"Dunfermline and West Fife", "11181119112011216CCC",
"Durham North", "2221222222232321BCC6",
"Durham North West", "2220232024202421BB6C",
"Durham, City of", "2224232223232324B6CC",
"Dwyfor Meirionnydd", "46104611461246132CCC",
"Ealing Central and Acton", "5956605560566155BBC6",
"Ealing North", "5954595560536054BC6C",
"Ealing Southall", "6052615261536154B6CC",
"Easington", "24222423242425246CF6",
"East Ham", "6167626562666267B6CC",
"East Kilbride, Strathaven and Lesmahagow", "19191920192119226CCC",
"East Lothian", "15281628162917291683",
"Eastbourne", "7746784679468046BBB3",
"Eastleigh", "73257326732774266FC6",
"Eddisbury", "4218421943184418BCB6",
"Edinburgh East", "1426142715261527586C",
"Edinburgh North and Leith", "14241425152415255E6C",
"Edinburgh South", "1627172617271728B6CC",
"Edinburgh South West", "16241625162617256FC6",
"Edinburgh West", "1523162317231724BB6C",
"Edmonton", "55635564556555666CCC",
"Ellesmere Port and Neston", "40154016411641176E6C",
"Elmet and Rothwell", "11641264136414641AA3",
"Eltham", "6465646665656566BF6C",
"Enfield North", "53635463546454651699",
"Enfield Southgate", "53615362546255622EB6",
"Epping Forest", "6642674268416842BB6C",
"Epsom and Ewell", "76357636763776386CCC",
"Erewash", "4428452846284728BBB6",
"Erith and Thamesmead", "63666367636863696CCC",
"Esher and Walton", "7434753475357634BBC6",
"Exeter", "73127313731473156CCC",
"Falkirk", "12181219122013196F73",
"Fareham", "7427752776277727BBB6",
"Faversham and Kent Mid", "7446744775457546BC6C",
"Feltham and Heston", "62516252635264526FB6",
"Fife North East", "091709181017111754B6",
"Filton and Bradley Stoke", "63176318641764185E6C",
"Finchley and Golders Green", "5659566056615759BCC6",
"Folkestone and Hythe", "7548754976487649BF67",
"Forest of Dean", "5919601860196119B6F6",
"Fylde", "31163117311831196CCC",
"Gainsborough", "41344135413642356F76",
"Garston and Halewood", "2745274628442845B767",
"Gateshead", "2806280729062907BF6C",
"Gedling", "4433453346334733BBB6",
"Gillingham and Rainham", "7246724773467347BF6C",
"Glasgow Central", "14031404140514066CCC",
"Glasgow East", "1307130814071408BD67",
"Glasgow North", "12041205130413055E6C",
"Glasgow North East", "12061207120813065946",
"Glasgow North West", "12021203130213035E6C",
"Glasgow South", "15031504150516056CD3",
"Glasgow South West", "1402150216021603BB67",
"Glenrothes", "10181019102010216999",
"Gloucester", "6122612362226223BF6C",
"Gordon", "0515051605170615B946",
"Gosport", "7428752876287728BBB6",
"Gower", "5208520953085309BF6C",
"Grantham and Stamford", "4634473447354835B6F6",
"Gravesham", "71427143724373436FB6",
"Great Grimsby", "39344034403540361694",
"Great Yarmouth", "49455045504651461683",
"Greenwich and Woolwich", "6364636564636464BC6C",
"Guildford", "7533763377337734BB6C",
"Hackney North and Stoke Newington", "5863586458655963BCC6",
"Hackney South and Shoreditch", "5964596560636064BC6C",
"Halesowen and Rowley Regis", "4251435144514551BBB6",
"Halifax", "1858195719581959B6CC",
"Haltemprice and Howden", "3331343034313432B6CC",
"Halton", "3818391840174018BB6C",
"Hammersmith", "6156625662576357B6F6",
"Hampshire East", "7028712871297130B6CC",
"Hampshire North East", "68266827692769286F6C",
"Hampshire North West", "6825692569267025BBC6",
"Hampstead and Kilburn", "5858585959575958BC6C",
"Harborough", "5233523453325333BC6C",
"Harlow", "6242634264426542BBB6",
"Harrogate and Knaresborough", "3026302731253126BC6C",
"Harrow East", "555555565655575559B6",
"Harrow West", "57535754585458556F6C",
"Hartlepool", "24252426242725276CF6",
"Harwich and North Essex", "59456045604660471694",
"Hastings and Rye", "7749784878497948AB73",
"Havant", "73297330743075306FB6",
"Hayes and Harlington", "59515952605161515CB6",
"Hazel Grove", "2655265627552855B7A3",
"Hemel Hempstead", "6337643664376537B6F6",
"Hemsworth", "18631864196420646DA3",
"Hendon", "5459555755585559529C",
"Henley", "6130623063306430BBB6",
"Hereford and South Herefordshire", "5718581858195918BBC6",
"Herefordshire North", "5519561856195719B6F6",
"Hertford and Stortford", "6241634164416541BBB6",
"Hertfordshire North East", "5841594160416141BBB6",
"Hertfordshire South West", "6235633564356535BBB6",
"Hertsmere", "66376638673867396F6C",
"Hexham", "2021202221212122BF6C",
"Heywood and Middleton", "17531754185418552E6C",
"High Peak", "3824392439254024BBC6",
"Hitchin and Harpenden", "6139623963396340BB6C",
"Holborn and St Pancras", "5860596060606160BBB6",
"Hornchurch and Upminster", "59716071617061711A67",
"Hornsey and Wood Green", "5662576057615762B6CC",
"Horsham", "78347835783678376CCC",
"Houghton and Sunderland South", "3108320832093309B6D3",
"Hove", "7741784179417942BB6C",
"Huddersfield", "1960196120602061BF6C",
"Hull East", "3635373537363836A683",
"Hull North", "3433343435323533B76C",
"Hull West and Hessle", "3534353536343734B4B6",
"Huntingdon", "54375438553856386FB6",
"Hyndburn", "3022302331223123BF6C",
"Ilford North", "5668566957685769B86C",
"Ilford South", "5868586959685969BF6C",
"Inverclyde", "16091610170917105F6C",
"Inverness Nairn Badenoch and Strathspey", "0712071308120912BCB6",
"Ipswich", "5543554456435644BF6C",
"Isle of Wight", "80268027802881272E43",
"Islington North", "5861586259615962BF6C",
"Islington South and Finsbury", "6061606261616162BF6C",
"Islwyn", "5415551556155715BBB6",
"Jarrow", "2808280929082909BF6C",
"Keighley", "14561457155616565CB6",
"Kenilworth and Southam", "5728572957305828BCC6",
"Kensington", "6057615761586258B6F6",
"Kettering", "5235533453355435B6F6",
"Kilmarnock and Loudoun", "1817191619171918B6CC",
"Kingston and Surbiton", "6555665567556855BBB6",
"Kingswood", "6419651965206521B6CC",
"Kirkcaldy and Cowdenbeath", "10221023112211235867",
"Knowsley", "22422243224422452999",
"Lanark and Hamilton East", "18191820182118226CCC",
"Lancashire West", "321533153316341656F6",
"Lancaster and Fleetwood", "28182819282028216CCC",
"Leeds Central", "1562166116621761BBC6",
"Leeds East", "1563156416631664BF6C",
"Leeds North East", "1362136314621463BF6C",
"Leeds North West", "12601261126212632999",
"Leeds West", "1361146115601561BB6C",
"Leicester East", "5033503451335134BF6C",
"Leicester South", "5132523152325331BBC6",
"Leicester West", "51295130513152306FC6",
"Leicestershire North West", "4929502850295128BBC6",
"Leicestershire South", "54305431543255316FC6",
"Leigh", "2348244824492549B6F6",
"Lewes", "7845794580458145BBB3",
"Lewisham Deptford", "6563656466636664BF6C",
"Lewisham East", "6665676467656865B6F6",
"Lewisham West and Penge", "6763686368646963BBC6",
"Leyton and Wanstead", "5766576758665867BF6C",
"Lichfield", "4925502550265027B6CC",
"Lincoln", "4234433443354434BBC6",
"Linlithgow and East Falkirk", "14211422142315222E96",
"Liverpool Riverside", "25422543264327436FB6",
"Liverpool Walton", "23422343234424436FC6",
"Liverpool Wavertree", "2444254426442744BBB6",
"Liverpool West Derby", "2445254525462645BBC6",
"Livingston", "1521162116221722B6F6",
"Llanelli", "501251115112511356CC",
"Loughborough", "4932503050315032B6CC",
"Louth and Horncastle", "4236433644364437AA64",
"Ludlow", "5318541854195518BBC6",
"Luton North", "5937603660376038B6CC",
"Luton South", "6137613862376238BF6C",
"Macclesfield", "4022402341224123BF6C",
"Maidenhead", "6531663066316731B6F6",
"Maidstone and The Weald", "7444744575437544BC6C",
"Makerfield", "2147224622472347B2F6",
"Maldon", "64446445644665466C86",
"Manchester Central", "21512152225222536F6C",
"Manchester Gorton", "2354245224532454B6CC",
"Manchester Withington", "25512552255325546CCC",
"Mansfield", "41294130423043306FB6",
"Meon Valley", "7228722972307328BCC6",
"Meriden", "42584358445845581BB6",
"Merthyr Tydfil And Rhymney", "5214521553145315BF6C",
"Middlesbrough", "2526262626272628B6CC",
"Middlesbrough South and Cleveland East", "2629263027292730B867",
"Midlothian", "18241825182618276CCC",
"Milton Keynes North", "5834593359346033BBC6",
"Milton Keynes South", "6034613261336134B6CC",
"Mitcham and Morden", "68566857685869586CF6",
"Mole Valley", "77357736773777386CCC",
"Monmouth", "5417551756175717BBB6",
"Montgomeryshire", "46144615461646176CCC",
"Moray", "03130413051306131BB6",
"Morecambe and Lunesdale", "27162717271827196CCC",
"Morley and Outwood", "1762176318621962BCB6",
"Motherwell and Wishaw", "16191620172017216F6C",
"Na h-Eileanan An Iar (Western Isles)", "040904100509060954A3",
"Neath", "5210521153105311BF6C",
"New Forest East", "7724772578247825BF6C",
"New Forest West", "7524762376247723BBC6",
"Newark", "4132423242334333B6F6",
"Newbury", "6426652666266627BB6C",
"Newcastle upon Tyne Central", "2705280529042905BB6C",
"Newcastle upon Tyne East", "2607270627072708B6CC",
"Newcastle upon Tyne North", "270428032804290355C6",
"Newcastle-under-Lyme", "4620472048204821BB6C",
"Newport East", "5817591760176117BBB3",
"Newport West", "5816591660166116BBB6",
"Newton Abbot", "74137414741575156CF6",
"Norfolk Mid", "50405041504251416FC6",
"Norfolk North", "48424843484449442986",
"Norfolk North West", "49394940503850395C2C",
"Norfolk South", "5145524452455246B6C7",
"Norfolk South West", "51395140524052416F6C",
"Normanton, Pontefract and Castleford", "15651665176417651A67",
"Northampton North", "5433543455335534BF6C",
"Northampton South", "5633573357345833BBC6",
"Northamptonshire South", "5732583158325931BBC6",
"Norwich North", "4943504350445144B6F6",
"Norwich South", "5142514352425243BF6C",
"Nottingham East", "4432453246324732BBB6",
"Nottingham North", "4430443145304531BF6C",
"Nottingham South", "4630463147304731BF6C",
"Nuneaton", "53275328542854296F6C",
"Ochil and South Perthshire", "12141215121612176CCC",
"Ogmore", "54105411551156116FB6",
"Old Bexley and Sidcup", "6467656765686569B6C7",
"Oldham East and Saddleworth", "21572158225823586FB3",
"Oldham West and Royton", "19531954205420556F6C",
"Orkney and Shetland", "01180217021803171573",
"Orpington", "6668676767686867AB73",
"Oxford East", "6029603061296229BCB6",
"Oxford West and Abingdon", "5928602861286228BBB6",
"Paisley and Renfrewshire North", "1512161116121613B6CC",
"Paisley and Renfrewshire South", "17111712171317146CCC",
"Pendle", "2924302431243224BBB6",
"Penistone and Stocksbridge", "2360246024612561B6F6",
"Penrith and The Border", "2020211921202219BBC6",
"Perth and North Perthshire", "1012101311121113BF6C",
"Peterborough", "5138523852395338BBC6",
"Plymouth Moor View", "7310740974107509BBC6",
"Plymouth Sutton and Devonport", "7510751176107611BF6C",
"Pontypridd", "5612561357125713BF6C",
"Poole", "7320742075207620BBB6",
"Poplar and Limehouse", "62626263626463636FC6",
"Portsmouth North", "7429752976297630BB6C",
"Portsmouth South", "7729773078297830BF6C",
"Preseli Pembrokeshire", "50085009501050112999",
"Preston", "3020302131203121BF6C",
"Pudsey", "125913591360146056F6",
"Putney", "64556456655665576F6C",
"Rayleigh and Wickford", "6544654566446645BF6C",
"Reading East", "6529653066286629BC6C",
"Reading West", "6427642865276528BF6C",
"Redcar", "2428242925282529B867",
"Redditch", "5823582459235924BF6C",
"Reigate", "7439753875397639B6F6",
"Renfrewshire East", "18131814181518166CCC",
"Rhondda", "5212531254125512BBB6",
"Ribble South", "32163217321832196CCC",
"Ribble Valley", "2822282329222923BF6C",
"Richmond", "28242825282628276CCC",
"Richmond Park", "6354635563566454BCC6",
"Rochdale", "19551956205620576F6C",
"Rochester and Strood", "71447145714671476C94",
"Rochford and Southend East", "654766466647674716D3",
"Romford", "57705870597060701AB6",
"Romsey and Southampton North", "7024712472247324BBB6",
"Ross Skye and Lochaber", "0911101111111211BBB6",
"Rossendale and Darwen", "3321341934203421B6CC",
"Rother Valley", "2666266727652766B767",
"Rotherham", "2465256525662665BBC6",
"Rugby", "5529553056295630BF6C",
"Ruislip, Northwood and Pinner", "5554565256535654529C",
"Runnymede and Weybridge", "7131713272317232BF6C",
"Rushcliffe", "4831483249304931BC6C",
"Rutherglen and Hamilton West", "17171718171918186FC6",
"Rutland and Melton", "4935503550365135BBC6",
"Saffron Walden", "5842594260426142BBB6",
"Salford and Eccles", "2250225123492350BC6C",
"Salisbury", "6823692369247023BBC6",
"Scarborough and Whitby", "28282829283028316CC4",
"Scunthorpe", "3932403240334133B6F6",
"Sedgefield", "2522252326212622BC6C",
"Sefton Central", "20402140224022415B6C",
"Selby and Ainsty", "31293130323033306FB6",
"Sevenoaks", "7340734174407441BF6C",
"Sheffield Brightside and Hillsborough", "2462246324642562BCC6",
"Sheffield Central", "2563256426632664BF6C",
"Sheffield Hallam", "26612662276228626FB6",
"Sheffield Heeley", "2763276428632963BCB6",
"Sheffield South East", "2864286529642965BD67",
"Sherwood", "4131423143314332BB6C",
"Shipley", "11581258135713581B2C",
"Shrewsbury and Atcham", "4918501851185218BBB6",
"Shropshire North", "4518461846194718BBC6",
"Sittingbourne and Sheppey", "714972487249734815C6",
"Skipton and Ripon", "2925292629273025BCC6",
"Sleaford and North Hykeham", "4435453445354635B6F6",
"Slough", "6633673367346834B6F6",
"Solihull", "4557465646574658B6CC",
"Somerset North", "68156816681768186CCC",
"Somerset North East", "6621672168216921BBB6",
"Somerton and Frome", "7020702171207121BF6C",
"South Holland and The Deepings", "4736483649364937AA64",
"South Shields", "28102910291130111683",
"Southampton Itchen", "7526762677267826BBB3",
"Southampton Test", "74247425752576256FB6",
"Southend West", "67456746684669466FA3",
"Southport", "194119422041214154A3",
"Spelthorne", "6931693270317032BF6C",
"St Albans", "6338643864396538BBC6",
"St Austell and Newquay", "74067506760677065BB3",
"St Helens North", "23452346244624476F6C",
"St Helens South and Whiston", "2547254826462647BC67",
"St Ives", "77027703780278035E6C",
"Stafford", "4823492249234924B6CC",
"Staffordshire Moorlands", "4223432243234423B6F6",
"Staffordshire South", "5120522053205420BBB6",
"Stalybridge and Hyde", "2357245624572556BB73",
"Stevenage", "60396040614062406FB6",
"Stirling", "12121213131313146F6C",
"Stockport", "2653265427532853BCB6",
"Stockton North", "2525262426252724BBC6",
"Stockton South", "27252726272727286CCC",
"Stoke-on-Trent Central", "4521462146224623B6CC",
"Stoke-on-Trent North", "4422452245234524B6CC",
"Stoke-on-Trent South", "47214722472348226FC6",
"Stone", "4920492150205021BF6C",
"Stourbridge", "4350444944504550B6F6",
"Stratford-on-Avon", "5725582559255926BB6C",
"Streatham", "6761686068616960BBC6",
"Stretford and Urmston", "2351235223532451BCC6",
"Stroud", "6120612162206221BF6C",
"Suffolk Central and Ipswich North", "5343534454435444BF6C",
"Suffolk Coastal", "5545564557445745AA67",
"Suffolk South", "5641574157425743B6CC",
"Suffolk West", "53405341544155416FB6",
"Sunderland Central", "3009301031093110BF67",
"Surrey East", "7540764077397740BB6C",
"Surrey Heath", "7331743175317532BB6C",
"Surrey South West", "7631763277317732BF6C",
"Sussex Mid", "7839784079397940BF6C",
"Sutton and Cheam", "6956695770567057BF6C",
"Sutton Coldfield", "3856395639574057A683",
"Swansea East", "5510560956105709BBC6",
"Swansea West", "5408540955085509BF6C",
"Swindon North", "6423642464256523BCC6",
"Swindon South", "6524652566246625BF6C",
"Tamworth", "5125512651275225BCC6",
"Tatton", "4121422042214222B6CC",
"Taunton Deane", "71147115711671176CCC",
"Telford", "5019511952195319BBB6",
"Tewkesbury", "60256026612662266FB6",
"Thanet North", "7151715272507251592C",
"Thanet South", "71537252725373521B73",
"Thirsk and Malton", "29292930293129326CC4",
"Thornbury and Yate", "6219631963206420B6F6",
"Thurrock", "68396840694069416F6C",
"Tiverton and Honiton", "72137214721572166CCC",
"Tonbridge and Malling", "7442744375417542BC6C",
"Tooting", "6658675867596859B6F6",
"Torbay", "7513751476137614BF67",
"Torfaen", "5416551656165716BBB6",
"Totnes", "7612771177127713B6C7",
"Tottenham", "5663566457635764BF6C",
"Truro and Falmouth", "75057605770578055BB3",
"Tunbridge Wells", "76417642764376446CCC",
"Twickenham", "6453655365546654B6F6",
"Tynemouth", "25082608260927091683",
"Tyneside North", "2506250726052606592C",
"Uxbridge and South Ruislip", "5752585258535953B6F6",
"Vale of Clwyd", "39134013401441131B96",
"Vale of Glamorgan", "5912601261116112BB6C",
"Vauxhall", "6460656066606760BBB6",
"Wakefield", "1963206220632163B6F6",
"Wallasey", "253926382639264012C4",
"Walsall North", "355336523653375255C6",
"Walsall South", "37533754375537566CC7",
"Walthamstow", "5665566656675765BCC6",
"Wansbeck", "20252026202720286CC7",
"Wantage", "63276328632964296CF6",
"Warley", "4052415242524253BB6C",
"Warrington North", "38193820382139216CF6",
"Warrington South", "39193920402040216F6C",
"Warwick and Leamington", "5726572758265827BF6C",
"Warwickshire North", "5226522753255326BC6C",
"Washington and Sunderland West", "3007300831063107BC6C",
"Watford", "6536663566366735BBC6",
"Waveney", "5345534654455446BD67",
"Wealden", "77427743774477456CCC",
"Weaver Vale", "4019411841194120B6CC",
"Wellingborough", "5535553656345635BC6C",
"Wells", "70167017701870196CCC",
"Welwyn Hatfield", "6440653965406639BBC6",
"Wentworth and Dearne", "23642365236624666CF6",
"West Bromwich East", "3852395239534053B6F6",
"West Bromwich West", "4051415041514250BBC6",
"West Ham", "5966596760666166BCB6",
"Westminster North", "5959605860596159B6F6",
"Westmorland and Lonsdale", "2319241925192619BBB6",
"Weston-Super-Mare", "69156916691769186CCC",
"Wigan", "1948204720482148B2F6",
"Wiltshire North", "6321632264216422BF6C",
"Wiltshire South West", "6722682269227022BBB6",
"Wimbledon", "6656665767566757BF6C",
"Winchester", "7125722572267227B6CC",
"Windsor", "6632673268326833BB6C",
"Wirral South", "2840293929402941B6C7",
"Wirral West", "27372738283828392F6C",
"Witham", "6145624462456345B6F3",
"Witney", "5927602761276227BBB6",
"Woking", "7332733374327433BF6C",
"Wokingham", "67276728682868296F6C",
"Wolverhampton North East", "36503651375037515E6C",
"Wolverhampton South East", "3850385139503951BF6C",
"Wolverhampton South West", "38483849394839495E6C",
"Worcester", "5821582259216021BCB6",
"Worcestershire Mid", "5922602260236024B6CC",
"Worcestershire West", "5720582059206020BBB6",
"Workington", "2118221622172218B2CC",
"Worsley and Eccles South", "2450255026502750BBB6",
"Worthing East and Shoreham", "80368037803880396CC7",
"Worthing West", "8034803581338134BC67",
"Wrekin, The", "4719481848194919B6F6",
"Wrexham", "44134414441544166CCC",
"Wycombe", "6331633264316432BF6C",
"Wyre and Preston North", "2919292029213019BCC6",
"Wyre Forest", "5520552156205621BF6C",
"Wythenshawe and Sale East", "2652275228522952BBB6",
"Yeovil", "7118711972177218BC6C",
"Ynys Mon", "39093910400940105867",
"York Central", "30293030303131316CF6",
"York Outer", "2928302831273128BB6C",
"Yorkshire East", "3032313232313232AA6C"
);

var numseats = DataBlock.length / 2;	// number of seats
var NumRows = 82;
var NumCols = 71;
var newflag = 1;						// show new prediction to start with

// Co-ordinates of grey squares for metropolitan areas
var GreySquares = new Array(
"1514B1515F1516F1517C161461615F1616F171561716C",	// Glasgow
"2225B2226F2227F2228D232562326C2327C23287",		// Tyne & Wear
"3225B3226F3227F3228F3229F332463325F3326F3327F3328F3329F3425B3426F3427F3428F3429F352563526F3527F3528F3529F3530F362663627C3628C3629C3630C", // W.Yorks
"3415B3515B3516F3517F3518F361563616C3617F3618F3717B3718C3719C381513817B3915339176",	// Merseyside
"3422B3423F3424F3519B3520F3521F3522F3523F3524F361963620F3621F3622F3623F3624F3625F372063721C3722F3723F3724C3725C3822B3823F392263923C", // Gt.Manchester
"3726B3727F3728F3729F3730F3731F3732C382563826F3827F3828F3829F3830C3831C392663927F3928F3929F402764028C4029C",	// S.Yorks
"5121B5122F5123F5221B5222F5223F5224F5321B5322F5323F5324F542165422F5423F5424F5425F5426F5427F5522B5523F5524F5525F5526F5527F5528F562265623C5624C5625C5626C5627C5628C",	// W.Midlands
"6736B6737F6835B6836F6837F6838F693466935F6936F6937F6938F6939F7035B7036F7037F7038F7039F7040F713567136C7137C7138C7139C7140C",	// N.London
"6933B7033B7034F7133B7134F723367234F7235F7236F7237F7238F7239F7240C733467335F7336F7337F7338F7339C743567436F7437F7438C753667537C"	// S.London
);

// converts coded colour string, such as "R02B05" and newflag into HTML colour such as "#2020FF" 
function SqColour(colcode, newflag)
{
	var colstr = (newflag ? colcode.substr(3, 3) : colcode.substr(0, 3) );
	var colour = colstr.substr(0,1);
	var maxhue = 150;
	var basecol = Math.round(maxhue*(1.0 - Number(colstr.substr(1,2))/40.0) );
	if (basecol < 0.0) { basecol = 0.0; }

	var red = basecol;
	var green = basecol;
	var blue = basecol;
	if (colour == 'R') { red = 255; }
	else if (colour == 'G') { green = 255; }
	else if (colour == 'B') { blue = 255; }
	else if (colour == 'Y') { red = 255; green = 255; }
	red = (red < 16 ? '0' : '') + red.toString(16);
	green = (green < 16 ? '0' : '') + green.toString(16);
	blue = (blue < 16 ? '0' : '') + blue.toString(16);
	var htmlcol = '#' + red + green + blue;
	//document.write('<BR>' + colcode + ' = ' + htmlcol + ' Colstr = ' + colstr + ' Colour = ' + colour);
	return htmlcol;
}

// recolours map switching between old and new election results
function ReColourMap(title)
{
	status = 'Recolouring map, please wait...';
	newflag = !newflag;
	if (newflag)
	{
		document.getElementById("header").innerHTML = "Dynamic Electoral Map : " + title;
		document.getElementById("button").innerHTML = "Switch to 2010 result";
	}
	else
	{
		document.getElementById("header").innerHTML = "Dynamic Electoral Map : 2010 Election Result";
		document.getElementById("button").innerHTML = "Switch to Prediction";
	}

	tablepointers();
	for (var seat = 0; seat < numseats; seat++)
	{
		var seatname = DataBlock[2*seat];
		var seatdata = DataBlock[2*seat+1];
		var seatcolours = ColBlock[seatname];
		var newcolour = SqColour(seatcolours, newflag);

		for (sq = 0; sq <= 3; sq++)
		{
			squareptrs[4*seat+sq].style.backgroundColor = newcolour;
		}
	}
	status = '';
	return;
}


// Description of "missing" squares because of spanning elements
// (x, y, wd, ht) : means omit squares from (x, y) to (x+ht-1, y+wd-1)
var VoidData = new Array(
	23,  3, 10, 2,	// Tyne & Wear
	10,  2,  8, 2,	// Glasgow
	39, 59, 10,	2,	// West Midlands 
	30, 38, 10,	2,	// Merseyside
	15, 45, 10,	2,	// Gt.Manchester
	 9, 55, 10, 2,	// West Yorks
	30, 60, 10,	2,	// South Yorks
	51, 57,  8,	2,	// London 
	 6, 26, 20,	4,	// Instructions
	 3, 25,  5, 2,  // Con blob
	 3, 31,  5, 2,	// Lab blob
	 3, 37,  5, 2,  // Lib blob
	 3, 43,  5, 2	// Nat blob
);

var numvoids = VoidData.length / 4;

// Void flags: 0 number of voids on this row, followed by up to four indexes
var VoidRowFlags = new Array(NumRows*5);

for (var i=0;i < NumRows;i++)
{
	VoidRowFlags[i*5] = 0;
}
for (var i=0;i < numvoids;i++)
{
	var firstrow = VoidData[i*4];
	var numrows = VoidData[i*4+3];
	for (var row=0;row < numrows;row++)
	{
		var rowindex = 5*(firstrow+row-1);
		var voidcount = VoidRowFlags[rowindex] + 1;
		VoidRowFlags[rowindex] = voidcount;
		VoidRowFlags[rowindex+voidcount] = i;
	}
} 

// Converts from logical y co-ordinate to cells-index in table
// Only necessary for rows which contain void
function ycoord_convert(row, column)
{
	var numvoids = VoidRowFlags[5*(row-1)];
	if (numvoids == 0)
	{
		return column;
	}
	var adjust = 0;
	for (var i=0;i < numvoids;i++)
	{
		var voidex = VoidRowFlags[5*(row-1)+i+1];
		if (column > VoidData[4*voidex+1])
		{
			adjust = adjust + VoidData[4*voidex+2];
			if (row == VoidData[4*voidex])
			{
				adjust = adjust-1;
			}
		}
	}
	return column - adjust;
}

// define array for table pointers (populated later by function call)
var squareptrs = new Array(4*numseats);

// Get pointers to table elements
function tablepointers()
{
	if ('undefined' != typeof squareptrs[0])
	{
		return;	// already created
	}
	var tableptr = document.getElementById("map").tBodies[0];
	// store pointers to squares
	for (var seat = 0;seat < numseats;seat++)
	{
		var seatdata = DataBlock[2*seat+1];
		for (var sq = 0; sq <= 3; sq++)
		{
			var thissq = seatdata.substr(4*sq,4);
			var row = Number(thissq.substr(0,2));
			var column = Number(thissq.substr(2,2));
			column = ycoord_convert(row, column);
			squareptrs[4*seat+sq] = tableptr.rows[row-1].cells[column-1];
		}
	}
	return;
}

// strings for converting the number 2 into the string "02"
var numstrs = new Array(100);
for (count = 0;count<10;count++)
{
	numstrs[count] = "0" + count;
}
for (count = 10;count<100;count++)
{
	numstrs[count] = "" + count;
}

// main array used to construct table
var squares = new Array();

function make_squares(path)
{
	// create squares which are part of seats
	for (seat = 0; seat < numseats; seat++)
	{
		var seatname = DataBlock[2*seat];
		var seatdata = DataBlock[2*seat+1];
		var seatcolours = ColBlock[seatname];
		if ("string" != typeof seatcolours)
		{
			document.write('<BR>' + seatname + ' not found');
		}
		var colour = SqColour(seatcolours, 1);

		for (sq = 0; sq <= 3; sq++)
		{
			var thissq = seatdata.substr(4*sq,4);
			var thisshape = seatdata.substr(16+sq,1);

			squares[thissq] = '<TD BGCOLOR=' + colour + '><IMG SRC="' + path + 'h_' + thisshape + '.gif" BORDER=0 TITLE="' + seatname + '"></TD>';
		}
	}

	// set grey squares
	for (count = 0; count < GreySquares.length; count++)
	{
		var NumGreySqs = GreySquares[count].length / 5
		for (i = 0;i < NumGreySqs;i++)
		{
			var thissq = GreySquares[count].substr(5*i,4);
			var thisshape = GreySquares[count].substr(5*i+4,1);
			squares[thissq] = '<TD BGCOLOR=C0C0C0><IMG SRC="' + path + 'h_' + thisshape + '.gif" BORDER=0></TD>';
		}
	}

	// set void squares
	for (count = 0; count < numvoids; count++)
	{
		var startrow = VoidData[count*4];
		var startcol = VoidData[count*4+1];
		var rowht = VoidData[count*4+3];
		var colwd = VoidData[count*4+2];
		for (i = 0; i < rowht; i++)
		{
			for (j = 0; j < colwd; j++)
			{ 
				var thissq = numstrs[startrow+i] + numstrs[startcol+j];
				squares[thissq] = 0;
			}
		} 
	}

	// set legends for metropolitan areas
	squares["2303"] = "<TD COLSPAN=10 ROWSPAN=2>Tyne & Wear</TD>";
	squares["1002"] = "<TD COLSPAN=8 ROWSPAN=2>Glasgow</TD>";
	squares["3959"]	= "<TD COLSPAN=10 ROWSPAN=2>West Midlands</TD>";
	squares["3038"] = "<TD COLSPAN=10 ROWSPAN=2>Merseyside</TD>";
	squares["1545"] = "<TD COLSPAN=10 ROWSPAN=2>Gt Manchester</TD>";
	squares["0955"] = "<TD COLSPAN=10 ROWSPAN=2 ALIGN=right>West Yorkshire</TD>";
	squares["3060"] = "<TD COLSPAN=10 ROWSPAN=2>South Yorkshire</TD>";
	squares["5157"] = "<TD COLSPAN=8 ROWSPAN=2 ALIGN=center>London</TD>";

	// party legends
	var PartyCols = new Array( "#6060ff", "#ff6060", "#ffff60", "#60ff60" );
	var PartyNames = new Array( "&nbsp;&nbsp;Con", "Labour", "LibDem", "Reg/Oth" );
	for (var party=0;party < 4;party++)
	{
		var thiscol = 26 + party*6;
		var commontext = '<TD BGCOLOR=' + PartyCols[party] + '><IMG SRC="' + path;		// "> dummy close
		squares["01"+numstrs[thiscol]] = commontext + 'h_5.gif" BORDER=0></TD>';
		squares["01"+numstrs[thiscol+1]] = commontext + 'h_8.gif" BORDER=0></TD>';
		squares["02"+numstrs[thiscol]] = commontext + 'h_6.gif" BORDER=0></TD>';
		squares["02"+numstrs[thiscol+1]] = commontext + 'h_7.gif" BORDER=0></TD>';
		squares["03"+numstrs[thiscol-1]] = '<TD COLSPAN=5 ROWSPAN=2>' + PartyNames[party] + '</TD>';
	}
	squares["0626"] = '<TD class=discreet COLSPAN=20 ROWSPAN=4>Safer seats have stronger colours<BR>Hover cursor over seat for name</TD>';
	
	return;
}


function dmap_make(path)
{
	make_squares(path);

	document.write("<TABLE BORDER=0 WIDTH=710 CELLSPACING=0 CELLPADDING=0 ID=map>");
	for (row = 1;row<=NumRows;row++)
	{
		document.write("<TR>");
		for (col = 1;col<=NumCols;col++)
		{
			var thissq = numstrs[row] + numstrs[col];
			var sqtype = typeof squares[thissq];

			if ('string' == sqtype)
			{
				document.write(squares[thissq]);
			}
			else if ('number' != sqtype)
			{
				var htstr = (col==1 ? " HEIGHT=5" : "");
				var wdstr = (row==NumRows ? " WIDTH=8" : "");
				document.write("<TD" + htstr + wdstr + "></TD>");
			}
		}
		document.write("</TR>");
	}
	document.write("</TABLE>");
	return;
}
