//designed and prepared for LDWA Kent - Michael Headley - April 2010
var events=[
["West from Chilham","21 ml","11 Feb 2012","TR066536",9023,0],
["*Round Robertsbridge Ramble","16 ml","19 Feb 2012","TQ737235",9120,0],
["The Four Pits Walk","40 ml","3 Mar 2012","TR179598",9024,0],
["North from Kemsing","21 ml","10 Mar 2012","TQ555586",9025,0],
["*Dithering around Ditchling Again","20 ml","17 Mar 2012","TQ337181",9122,0],
["37th Sevenoaks Circular","30/20/<br>15 ml","25 Mar 2012","TQ534550",9372,2],
["*South Downs Marathon","28 ml<br>","1 Apr 2012","TV557977",8883,2],
["A South Downs Way Loop","26/20 ml","6 Apr 2012","TV600972",9026,0],
["Foreland to Foreland","23 ml","8 Apr 2012","TR398701",9027,0],
["*Eastbourne Circular","20 ml","8 Apr 2012","TQ610110",9246,0],
["Tonbridge to Tunbridge Wells","22 ml","14 Apr 2012","TQ587460",9028,0],
["Fullers Follies 2","20 ml","15 Apr 2012","TQ714262",9380,0],
["Cinque Ports Challenge","100k<br>start","21 Apr 2012","TR333576",9057,2],
["Cinque Ports Challenge","100k<br>finish","22 Apr 2012","TQ815096",9057,2],
["*A Different Direction From Stonegate","20 ml","5 May 2012","TQ659272",9693,0],
["St Mary's North Downs Challenge Walks","20/15/<br>11 ml","12 May 2012","TQ555587",9341,2],
["A Plod around the Parks","20 ml","13 May 2012","TR234539",9731,0],
["Duck Pond Alley","20 ml","27 May 2012","TR337562",9979,0],
["*Let's Do Some Hill Work In Kent","18 ml","27 May 2012","TQ502616",9880,0],
["*LDWA Games 100","100 ml<br>start","2 Jun 2012","TQ365846",-1,2],
["*Kent Group Checkpoint for LDWA Games 100","Biggin<br>Hill","2 Jun 2012","TQ421590",-2,2],
["*Darenth Valley Circular","22 ml","1 Jul 2012","TQ535649",9997,0],
["*South Downs Way Loop","18 ml","7 Jul 2012","TQ590115",9698,0],
["Andredsweald Circuit","26/15<br>ml","8 Jul 2012","TQ425353",10034,2],
["Fish & Chips - Yet Another Helping","21 ml","15 Jul 2012","TR090275",9980,0],
["*Lingfield Out & Back, Out & Back","25 ml","15 Jul 2012","TQ388435",9766,0],
["*Forest Row","21 ml","22 Jul 2012","TQ426349",9699,0],
["*Greensand Way Linear Walk Part 6","21 ml","22 Jul 2012","TQ670452",0,0],
["Another Far Thing from the Common","23 ml","29 Jul 2012","TR136404",9733,0],
["*Polegate","20 ml","4 Aug 2012","TQ582048",9700,0],
["Cream Tea Walk","20 ml","12 Aug 2012","TQ872488",9840,0],
["The Sholden Casuals","20 ml","19 Aug 2012","TR356525",9981,0],
["*The East Surreys Meet","17 ml","23 Aug 2012","TQ395559",9543,0],
["South Downs Thirty","32 ml","25 Aug 2012","TV600972",9841,0],
["White Cliffs Challenge","52/18<br>ml","22 Sep 2012","TR374515",10026,2],
["*Gatliff Marathon","50/35/<br>20 km","25 Nov 2012","TQ440459",10030,2]
];

var days=['Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
var months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','January','February','March','April','May','June','July','August','September','October','November','December'];

var wcpdfs=['Results:','2011','2010','2009','2008'];
var scpdfs=['Results:','2011','2010','2009','2008','2004','2003','1995','1994','1993','1992','1991','1990','1989','1987','1986','1985','1984','1983','1981','1980','1979'];
var hwpdfs=['Results:','2011','2010','2009','2008','2007','2006','2005','2004','2003','2002','2000','1999','1998','1997','1996','1995','1994','1984'];
var wwpdfs=['Results:','2003','2002','2000','1998','1996','1995','1994','1993','1992','1991','1990','1989','1988','1985','1983','1981'];

var zI=0,oi;
var set,pic=0,thispic;
var occasion=["<strong>High Weald Challenge,</strong> 13th July 2008, 26 or 14 miles","<strong>Summer French Challenge,</strong> 4th July 2009","<strong>White Cliffs Challenge,</strong> 12th-13th September 2009, 54 or 22 miles","<strong>Sevenoaks Circular,</strong> 21st March 2010, 30, 20 or 15 miles","<strong>St Mary's North Downs Challenge,</strong> 15th May 2010, 20, 15, 11 or 5 miles","<strong>Heart of Scotland 100,</strong> 29th-31st May 2010, 104.4 miles","<strong>Summer French Challenge,</strong> 3rd July 2010","<strong>High Weald Challenge,</strong> 11th July 2010","<strong>Fish and Chips - Another Helping,</strong> 18th July 2010","<strong>White Cliffs Challenge,</strong> September 2010, 30 or 15 miles","<strong>Greensand Way Walks,</strong> 2011","<strong>Summer French Challenge,</strong> 11th June 2011","<strong>Champagny (Set 2),</strong> June 2011","<strong>Champagny (Set 1),</strong> June 2011","<strong>High Weald Challenge,</strong> 10th July 2011","<strong>White Cliffs Challenge (Set 2)</strong>, September 2011","<strong>White Cliffs Challenge (Set 1)</strong>, September 2011"];
var picset=["High Weald Challenge, July 2008","Summer French Challenge, July 2009","White Cliffs Challenge, September 2009","Sevenoaks Circular, March 2010","St Mary's North Downs Challenge, May 2010","Heart of Scotland 100, May 2010","Summer French Challenge, July 2010","High Weald Challenge, July 2010","Fish and Chips - Another Helping, July 2010","White Cliffs Challenge, September 2010","Greensand Way Walks, 2011","Summer French Challenge, June 2011","Champagny (Set 2), June 2011","Champagny (Set 1), June 2011","High Weald Challenge, July 2011","White Cliffs Challenge (Set 2), September 2011","White Cliffs Challenge (Set 1), September 2011"];
var photos_by=["Eric Rolfe","Eric Rolfe","Eric Rolfe","Eric Rolfe","Eric Rolfe","Eileen Warr","Eric Rolfe","Eric Rolfe","Claire Betts","Eric Rolfe","Eric Rolfe","Eric Rolfe","Michael Headley","Nathan Powell","Eric Rolfe","Ingfrid Neumann","Eric Rolfe"];
var picdir=['HW08/KS','France09/sml/KF0','WC09/WC09_','SC10/sml/IMGP','SM10/sml/STMK','HoS100/sml/','France10/sml/IMGP0','HW10/sml/KW2010_','Fish&Chips10/sml/CNV000','WC10/sml/WC2010_','GW11/sml/IMGP','France11/sml/IMGP0','Champagny2/sml/m_','Champagny1/sml/n_','HW11/sml/KS11_','WC11b/sml/','WC11a/sml/WC'];
var pics=[
['101','102','103','104','105','106','107','108','109','110','201','202','203','204','205','206','207','208','209','210','301','302','303','304','305','306','307','308','309','310','311','312','313','314','315','316','317','318','319','320','321','401','402','403','404','405','406','407','408','409','410','411','412','413','414','415','416','417','418','419','420','421','422','423','424','425','426','427','428','429','430','431','432','433','434','501','502','503','504','505','506','507','508','509','510','511','512','513','514','515','516','517','518','519','520','521','522','523','524','601','602','603','604','605','606','607','608','609','610','611','612','701','702','703','704','705','706','707','708','709','710','711','712','713','714','715','716','717','718','719','720','721','722','723','724','725','726','727','728','729','730','731','732','733','734','735','736','737','738','739','740','741','742','743','744','745','746','747','748','749','801'
],
['002','010','020','030','040','060','080','090','100','110','120','130','140','170','180','190','200','210','220','230','290','340','350','360','370','380','390','400','410','430','440','450','460','470','480','530','550','560','570','580','630','660','670','680','690','700','740','750','760','798'
],
['00030','00060','00120','00150','00180','00190','00210','00240','00250','00300','00330','00340','00370','00400','00420','00430','00450','00460','00510','00520','00560','00570','00590','00600','00620','00650','00660','00680','00710','00720','00740','00770','00800','00830','00860','00890','00900','00920','00960','00980','00990','01010','01020','01040','01050','01080','01100','01110','01130','01140','01160','01170','01190','01210','01220','01230','01260','01270','01280','01290','01300','01310','01320','01340','01350','01400','01440','01450','01470','01490','01500','01530','01540','01550','01560','01570','01590','01620','01630','01640','01670','01680','01690','01700','01720','01740','01750','01770','01780','01800','01810','01830','01840','01860','01870','01890','01900','01920','01930','01940','01960','01970','01980','01990','02010','02020','02040','02050','02060','02120','02130','02140','02150','02170','02180','02190','02200','02220','02230','02240','02250','02260','02280','02290','02310','02320','02350','02360','02380','02400','02410','02420','02440','02460','02470','02490','02500','02520','02530','02550','02560','02580','02590','02610','02620','02640','02680','02700','02710','02740','02760','02770','02790','02810','02830','02850','02880','02910','02930','02940','02950','02960','02990','03020','03040','03070','03100','03120','03130','03170','03200','03250','03290','03291','03320','03330','03340','03400','03410','03420','03490','03500','03510','03530','03540','03550','03560','03570','03590','03600','03610','03630','03640','03650','03660','03670','03690','03700','03720','03730','03740','03750','03760','03770','03780','03790','03810','03820','03840','03850','03860','03870','03890','03900','03910','03930','03960','03970','03980','03990','05010','05030','05260','05270','05280','05980','05990','06000','06010','06030','06031','06270','06320','06340','06350','06370','06380','06400','06420','06430','06440','06450','06460','06470','06480','06510','06540','06550','06570','06580','06600','06610','06630','06640','06660','06670','06690','06720','06730','06740','06760','06770','06780','06800','06810','06840','06850','06860','06870','06880','06900','06910','06920','06930','06940','06950','06960','06980','06990','07000','07010','07020','07030','07040','07050','07060','07070','07080','07090','07100','07110','07120','07130','07140','07150','07160','07170','07180','07190','07200','07210','07220','07230','07240','07250','07260','07270','07280','07290','07291','07300','07310','07400','07410','07440','07441','07450','07460','07470','07480','07490','07500','07510','07580','07590','07610','07620','07630','07650','07660','07670','07680','07690','07700','07760','07770','07780','07790','07800','07810','07820','07840','07850','07870','07890','07900','07910','07970','07980','07981'
],
['3927','3928','3931','3932','3941','3943','3946','3953','3960','3964','3971','3972','3977','3979','3981','3982','3986','3989','3990','3991','3993','3998','4002','4009','4012','4014','4016','4019','4023','4025','4033','4034','4039','4046','4049','4053','4056','4063','4066','4067','4071','4075','4077','4078','4082','4084','4091','4095','4101','4103','4111','4116','4121','4124','4128','4129','4131','4133','4136','4139','4141','4143','4147','4149','4152','4155','4160','4163','4173','4176','4181','4183','4186','4189','4193','4196','4198','4204','4210','4217','4220','4221','4225','4231','4234','4238','4247','4248','4258','4265','4270','4275','4278','4282','4284','4288','4291','4301','4305','4308','4317','4318','4329','4330','4335','4341','4343','4346','4349','4351','4354','4357','4360','4364','4371','4373','4379','4383','4384','4394','4397','4399','4407','4408','4413','4416','4417','4421','4424','4427','4431','4436','4440','4442','4450','4453','4460','4463','4466','4473','4479','4485','4491','4493','4500','4509','4511','4515','4521','4523','4527','4529','4531','4535','4538','4545','4549','4555','4558','4560','4567','4572','4580','4583','4587','4590','4594','4599','4601','4603','4606','4610','4614','4619','4622','4623','4625','4626','4627','4628','4629','4631','4633','0029','0030','0031','0032','0033','0034','0035','0037','0039','0040','0041','0042','0043','0046','0047','0049','0052','0053','0054','0055','0056','0057','0058','0060','0062','0063','0064'
],
['1010','1030','1040','1060','1070','1080','1090','1100','1110','1120','1130','1150','1160','1170','1190','1210','1220','1230','1240','1260','1270','1280','1290','1300','1310','1320','1330','1340','1350','1360','1370','1400','1410','1420','1430','1440','1470','1490','1540','1550','1570','1590','1600','1620','1650','1660','1680','1690','1700','1720','1740','1750','1760','1770','1780','1790','1800','1810','1820','1830','1850','1899'
],
['026','027','028','029','031','033'
],
['1730','1732','1734','1740','1760','1770','1772','1774','1815','1820','1840','1845','1850','1860','1870','1890','1900','1910','1920','1930','1940','1945','1950','1970','1980','2000','2020','2030','2035','2040','2050','2060','2070','2080','2090','2100','2120','2140','2150','2165','2170','2175','2180','2195','2200','2210','2230','2240','2250','2260','2270','2280','2290','2300','2330','2340','2360','2370','2380','2420','2430','2440','2470','2490','2500','2520','2540','2550','2560','2580','2590','2600','2620','2630','2640','2645'
],
['0010','0020','0030','0090','0110','0130','0160','0180','0190','0210','0220','0240','0250','0255','0257','0260','0280','0290','0300','0310','0320','0330','0340','0350','0355','0360','0370','0380','0390','0400','0410','0420','0430','0440','0450','0460','0470','0475','0490','0520','0560','0570','0740','0780','0790','0800','0810','0820','0830','0850','0860','0870','0880','0890','0900','0910','0920','0930','0940','0950','0960','0970','0980','0990','1000','1010','1020','1030','1040','1050','1060','1070','1080','1090','1100','1110','1120','1130','1140','1150','1160','1170','1180','1190','1200','1210','1220','1230','1240','1250','1260','1270','1280','1290','1300','1310','1320','1330','1340','1350','1360','1370','1380','1390','1400','1410','1420','1430','1440','1450','1460','1470','1480','1490','1500','1510','1520','1530','1550','1560','1570','1580','1590','1600','1610','1620','1630','1640','1650','1660','1670','1680','1690','1730','1740','1760','1805','1820','1825','1830','1840','1850','1860','1870','1880','1890','1900','1910','1920','1930','1940','1950','1960','1970','1980','1990','2000','2010','2020','2030','2040','2050','2060','2070','2080','2090','2100','2110','2120','2130','2140','2150','2160','2170','2180','2190','2210','2220','2230','2240','2250','2260','2270','2280','2290','2300','2310','2320','2330','2340','2350','2360','2370','2380','2390','2400','2410','2420','2430','2440','2450','2460','2470','2480','2490','2500','2510','2520','2530','2540','2550','2560','2570','2580','2590','2600','2610','2620','2630','2640','2650','2660','2670','2680','2690','2700','2710','2720','2730','2740','2750','2760','2770','2780','2790','2800','2810','2820','2830','2840','2850','2860','2870','2880','2890','2900','2910','2920','2930','2940','2950','2960','2970','2980','2990','2995'
],
['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42'
],
['0010','0020','1010','1020','1030','1040','1050','1060','1070','1080','1090','1100','1110','1120','1130','1140','1150','1160','1170','1180','1190','2005','2030','2033','2035','2040','2050','2060','2100','2110','2115','2120','2130','2140','2150','2160','2170','2180','2190','2200','2210','2220','2230','2240','2250','2260','2270','2280','2300','2320','2330','3005','3010','3020','3030','3040','3050','3060','3070','3080','3090','3100','3110','3120','3140','3150','3155','3160','3170','3175','3180','3200','3210','3220','3230','3240','3250','3260','3270','3280','3290','3300','3310','3320','3330','3340','3350','3360','3370','3380','3390','3400','3410','3420','3430','3450','3460','3470','3480','3490','3500','3510','3520','3530','3550','3560','3570','3580','3590','3600','3610','3620','3640','3650','3660','3670','3680','3690','3700','3710','3720','3730','3740','3750','4005','4010','4020','4030','4040','4050','4060','4070','4080','4090','4100','4110','4120','4130','4140','4150','4160','4170','4180','4190','4200','4210','5005','5010','5020','5030','5040','5050','5060','5070','5080','5090','5100','5110','5120','5130','5140','5150','5160','5170','5180','5190','5200','5210','5220','5230','5240','5250','5260','5270','5280','5290','5300','5310','5320','5330','5340','5350','5360','5370','8001','8010','8020','8030','8040','8050','8060','8070','8080','8090','8100','9991','9992'
],
['1127','1128','1129','1131','1133','1135','1136','1137','1138','1139','1140','1141','1142','1143','1145','1146','1147','1148','1149','1150','1151','1152','1153','1155','1156','1157','1159','1160','1161','1162','1166','1168','1170','1173','1174','1175','1176','1177','1178','1180','1181','1182','1183','1184','1185','1187','1188','1190','1191','1192','1193','1194','1195','1196','1197','1198','1199','1202','1203','1204','1205','1206','1207','1210','1211','1213','1214','1215','1216','1217','1218','1221','1222','1229','1230','1231','1232','1234','1235','1236','1237','1239','1242','1243','1245','1246','1248','1249','1250','1252','1253','1254','1255','1256','1257','0001','0010','0027','0028','0030','0033','0035','0036','0037','0038','0040','0043','0044','0170','0171','0172','0173','0174','0175','0177','0178','0180','0181','0182','0183','0184','0186','0187','0188','0189','0190','0191','0192','0194','0195','0196','0197','0198','0200','0201','0209'
],
['010','020','048','052','058','059','064','065','066','068','069','070','074','075','076','077','078','079','080','081','082','083','084','085','086','087','090','091','092','094','095','096','097','098','100','101','102','103','104','106','107','108','109','110','111','113','115','117','118','119','120','123','125','126','129','131','133','140','142','143','145','147','148','149','150','151','152','153','155','156','157','159','160','161','162','163','165','166','168','169'
],
['404','405','406','407','408','409','410','411','412','413','414','415','416','417','418','419','420','421','422','423','424','425','426','427','428','429','430','431','432','433','434','435','436'
],
['010','011','012','013','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','036','037','038','039','040','041','042','043','044','045','046','047','048','049','050','051','052','053','054','055','056','057','058','059','060','061','062','063','064','065','066','067','068','069','070','071','072','073','074','075','076','077','078','079','080','081','082','083','084','085','086','087','088','089','090','091','092','093','094','095','096','097','098','099','100','101','102','103','104','105','106','107','108','109','110','111','112','113','114','115','116','117','118','119','120','121','122','123','124','125','126','127','128','129','130','131','132','133','134','135','136','137','138','139','140','141','142','143','144','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192'
],
['1100D','1102D','1110D','1120D','1130D','1140D','1150D','1160D','1170D','1180D','1190W','1200W','1210W','1220W','1230W','1240W','1250W','1255D','1260D','1270D','1280D','1290D','1300D','1310D','1320D','1330D','1340D','1350D','1360D','1370D','1380D','1390D','1400D','1410D','1420D','1430D','1440D','1450D','1460D','1470D','1480W','1490W','1500D','1540D','1545W','1570W','1580W','1590W','1595D','1600D','1610D','1620D','1640D','1650D','1660D','1670D','1680D','1690D','1700D','1710D','1720D','1730D','1740D','1750D','1760D','1770D','1780D','1790D','1800D','1810D','1820D','1830D','1840D','1850D','1860D','1880D','1890D','1900D','1910D','1920D','1930D','1940D','1950D','1960D','1970D','1980D','1990D','2000D','2010D','2020D','2030D','2040D','2050D','2060D','2070D','2080D','2090D','2100D','2110D','2120D','2130D','2140D','2150D','2160D','2170D','2180D','2190D','2200D','2210D','2220D','2230D','2240D','2260D','2270D','2280D','2285D','2290D','2300D','2310D','2320D','2330D','2340D','2350D','2360D','2370D','2380D','2390D','2400D','2410D','2420D','2430D','2440D','2450D','2460D','2470D','2480D','2490D','2500D','2510D','2520D','2530D','2540D','2550D','2560D','2570D','2580D','2590D','2600D','2610D','2620D','2630D','2640D','2650D','2660D','2670D','2680D','2710D','2720D','2730D','2740D','2750D','2760D','2770D','2775D','2780D','2800D','2830D','2840D','2850D','2860D','2870D','2873W','2875W','2880W','2890W','2900W','2910D','2920D','2930D','2940D','2950D','2960D','2970D','2980D','2990D','3000D','3010D','3020D','3030D','3040D','3050D','3060D','3070D','3080D','3090D','3100D','3110D','3120D','3130D','3140D','3150D','3160D','3170D','3180D','3190D','3200D','3210D','3220D','3230D','3240D','3250D','3260D','3270D','3280D','3290D','3300D','3310D','3320D','3330D','3340D','3350D','3360D','3370D','3380D','3390D','3400D','3410D','3420D','3430D','3440D','3460W','3470W','3480D','3490D','3500D','3510D','3520D','3530D','3540D','3550D','3560D','3570D','3580D','3590D','3600D','3610D','3620D','3630D','3640D','3650D','3660D','3670D','3680D','3690D','3700D','3710D','3720D','3730D','3740D','3750D','3760D','3770D','3780D','3790D','3800D','3810D','3820D','3830D','3840D','3850D','3860W','3870W','3880W','3885W','3890W','3900W','3910W','3920W','3930D','3940D'
],
['1010I','1018I','1020I','1050I','1060I','1070I','1080I','1090I','1100I','1110I','1120I','1140I','1150I','1160I','1180I','1190I'],
['1020','1025','1030','1050','2010','2020','2030','2040','2060','2070','2080','2090','2100','2110','2120','2130','2140','2150','2160','2170','3010','3020','3060','3100','3140','3160','3180','3220','3240','3260','3280','3300','3320','3340','3360','3380','3400','3420','3440','3460','3480','3500','3520','3540','3560','3580','3600','3620','3640','3660','3680','3700','4005','4010','4020','4030','4040','4050','4060','4070','4080','4090','4100','4110','4120','4130','4140','4150','4160','4180','4210','4240','4250','4260','4280','4300','4310','5010','5015','5020','5030','5090','5100','5120','5130','5140','5180','5190','5210','5220','5240','5250','5260','5270','5280','5310','5320','5330','5340','5350','5370','5390','5400','5410','5420','5430','5440','5450','5460','5470','5480','5490','5500','5510','5520','5530','5540','5550','5560','5570','5580','5590','5600','5610','5620','5630','5640','5650','5660','5670','5680','5690','5720','5730','5740','5750','5760','5770','5780','5800','5810','5820','5830','5840','5850','5860','5870','5880','5890','5900','5910','5920','5930','5940','5950','5960','5970','6010','6020','6030','6040','6060','6070','6080','7050','7055'
]
];

function getParams()//http://javascript.internet.com/forms/passing-values.html
{	var idx = document.URL.indexOf('?');
	var params = new Array();
	if (idx != -1)
	{	var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
		for (var i=0; i<pairs.length; i++)
		{	nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
		}
	}
	return params;
}
function mhInitPics()
{	var i;
	set=(unescape(getParams()['set']));
	if ( set=='undefined' ) set=pics.length-1;
	for ( i=0 ; i<picset.length ; i++ )
	{	document.forms['form1']['photoset'].options[picset.length-1-i]=new Option(picset[i],i);
	}
	document.form1.photoset.value=(set*=1);
	mhShowPics();
	window.setTimeout("mhShowPics()",500);
	document.getElementById("occasion").innerHTML=occasion[set];
	document.getElementById("photos_by").innerHTML="photos by "+photos_by[set];
	if ( set==0 || set==2 ) document.getElementById("res_msg").innerHTML="";
}
function mhShowPics()
{	mhPopulatePics(0);
}
function mhPopulatePics(n)
{	var i,j,jx,id,px,h,w,xx;
	px=pics[set].length;
	for ( i=0 ; i<5 ; i++ )
	{	id=document.getElementById("pic"+i);
		id.src="./gallery/"+picdir[set]+pics[set][j=mhWrap(n+i-2)]+(set==4?".jpg":".JPG"); //case sensitive
		if ( i==1 || i==3 )
		{	xx=100;
			id.removeAttribute("width");
			id.removeAttribute("height");
			if ( (h=id.height)>(w=id.width) )
			{	id.height=xx;
				id.width=parseInt((xx*w)/h);
			}
			else
			{	id.width=xx;
				id.height=parseInt((xx*h)/w);
			}
		}
		id.title="Image "+(j+1)+" of "+px;
		if ( i==2 && (set==1 || set>2) )
		{	thispic=id.src;
			id.title+='. Click for full-size image.';
		}
		else if ( i!=2 ) id.title+='. Click to enlarge.';
	}
}
function mhWrap(n)
{	if ( n>=pics[set].length ) n-=pics[set].length;
	if ( n<0 ) n+=pics[set].length;
	return n;
}
function mhNextPic(n)
{	mhPopulatePics(mhWrap(pic+=n));
}
function mhRefreshPics()
{	mhNextPic(0);
}
function mhThisPic()
{	mhOpenWindow(thispic.replace(/sml/,'lge'));
}
function mhNextSet()
{	location.href='gallery.html?set='+(document.form1.photoset.value);
}
function mhInitPDFs()
{	var a,i;
	for ( i=0,a=wcpdfs ; i<a.length ; i++ )
	{	document.forms['wc']['pdf'].options[i]=new Option(a[i],(a[i].substring(2,4)));
	}
	for ( i=0,a=scpdfs ; i<a.length ; i++ )
	{	document.forms['sc']['pdf'].options[i]=new Option(a[i],(a[i].substring(2,4)));
	}
	for ( i=0,a=hwpdfs ; i<a.length ; i++ )
	{	document.forms['hw']['pdf'].options[i]=new Option(a[i],(a[i].substring(2,4)));
	}
	for ( i=0,a=wwpdfs ; i<a.length ; i++ )
	{	document.forms['ww']['pdf'].options[i]=new Option(a[i],(a[i].substring(2,4)));
	}
}
function mhOpenPDF(s)
{	mhOpenWindow('pdf/'+document.forms[s].pdf.value+s+'-results.pdf');
	document.forms[s].reset();
}
function getElementsByClass(searchClass,node,tag)// thanks to http://www.dustindiaz.com/top-ten-javascript/
{	var i,j,classElements = new Array();
	if ( node == null ) node = document;
	if ( tag == null ) tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = j = 0; i < elsLen ; i++ )
	{	if ( pattern.test(els[i].className) )
		{	classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function mhGeograph(gr)
{	mhOpenWindow('http://www.geograph.org.uk/gridref/'+gr);
}
function mhGridRefs(gr)
{	return [gr.substring(0,2),gr.substring(2,5),gr.substring(5,8)];
}
function mhStreetMap(gr)
{	var refs=mhGridRefs(gr),x,y;
	switch (refs[0])
	{	case 'SD':
			x='3';
			y='4';
			break;
		case 'SX':
			x='2';
			y='0';
			break;
		case 'SZ':
			x='4';
			y='0';
			break;
		case 'TV':
			x='5';
			y='0';
			break;
		case 'TQ':
			x='5';
			y='1';
			break;
		case 'TR':
			x='6';
			y='1';
			break;
	}
	mhOpenWindow('http://www.streetmap.co.uk/idgc.srf?x='+x+refs[1]+'00&y='+y+refs[2]+'00');
}
function mhMap(gr)
{	mhStreetMap(gr);
	//mhOpenWindow('./gmaps.html?postcode='+gr);
	//mhOpenWindow('http://www.bing.com/maps/?where1='+gr+'&sty=s');
}
function mhShowMap() //adapted from http://sequence7.net/2010/01/17/add-a-google-map-to-your-website/
{ 	var postcode=(unescape(getParams()['postcode']));
	var geocoder = new google.maps.Geocoder();
	var myOptions =
	{   zoom: 15,
		mapTypeId: google.maps.MapTypeId.HYBRID //Choose from ROADMAP/SATELLITE/HYBRID/TERRAIN
	}
	var map = new google.maps.Map(document.getElementById("mapCanvas"), myOptions);
	document.title="View of " + postcode;
	geocoder.geocode({ 'address': postcode }, function(results, status)
	{	if (status == google.maps.GeocoderStatus.OK)
		{	map.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({map: map,position: results[0].geometry.location});
		}
		else
		{	alert("Geocode was not successful for the following reason: " + status);
		}
	});
}
/*function mhMultimap(gr)
{	mhOpenWindow('http://www.multimap.com/maps/?hloc=GB|'+gr+'&zoom=15&dp=os');
}*/
function mhShowEvent()
{	var i,thisi,thisid,tags=getElementsByClass('start',document,'*');
	for ( i=0; i<tags.length; i++ )
	{	tags[i].pnum=i;
		tags[i].onclick = function()
		{	thisid=document.getElementById('start'+(thisi=this.pnum));
			if ( thisid.style.zIndex==zI && zI>0 ) mhSeeWalk(events[thisi][4]);
			else mhBringForward(thisi);
		}
	}
}
function mhSeeWalk(n)
{	if (n>0) mhOpenWindow('http://www.ldwa.org.uk/challenge_events/show_event.php?event_id='+n);
	else if (n==-1) mhOpenWindow('http://www.ldwa.org.uk/2012Hundred');
	else if (n==-2) mhOpenWindow('http://www.ldwa.org.uk/2012Hundred/S/2042/biggin-hill-spitfire-centre.html');
}
function mhBringForward(i)
{	var id=document.getElementById('start'+oi);
	id.style.backgroundColor=events[oi][5]?"#ffeeee":"#eeffee";
	id=document.getElementById('start'+(oi=i));
	id.style.zIndex=++zI;		
	id.style.backgroundColor=(events[i][0].substring(0,1)=="*")?"#44eedd":"#ffff99";
}
function mhOpenWindow(f)
{	window.open(f,'','width=900,height=600,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,location=yes');
}
function mhPopulateMap()
{	var a,c,d,i,id,x,y,w=772,h=494,dw=28,dh=26,refs,str;
	id=document.getElementById('map1');
	id.style.width=w+dw+'px';
	id.style.height=h+dh+'px';
	d=new Date().getTime()-(24*60*60*1000);
	for ( i=events.length-1 ; i>=0 ; i-- )
	{	if ( new Date(events[i][2])>d )
		{	id=document.getElementById('start'+(oi=i));
			id.title=events[i][0];
			a=events[i][2].split(" ");
			id.innerHTML=events[i][1]+'<br>'+a[0]+" "+a[1];
			refs=mhGridRefs(events[i][3]);
			x=((refs[0]=="TR"?1000:0)+(refs[1]*1)-250)*w/1190;
			id.style.left=parseInt((x>w?w:x)-30+dw/2,10)+'px';
			y=((refs[0]=="TV"?1000:0)+810-(refs[2]*1))*h/710;
			id.style.top=parseInt((y>h?h:(y<-5?-5:y))-25+dh/2,10)+'px';
	   		id.style.cursor='pointer';
			id.style.visibility='visible';
			id.style.zIndex=++zI;		
			if ( (c=events[i][5])!=0 )
			{	id.style.backgroundColor=c>0?"#ffeeee":"#663300";
				id.style.borderColor=id.style.color=c>0?"#990000":"#663300";
				if ( c>1||c<-1 ) id.style.lineHeight='16px';
			}
		}
	}
	mhBringForward(oi);
}
function mhNextWalk()
{	var d,i,t,ddd,dddd,mmm,mmmm,n;
	for ( d=new Date(),i=0 ; i<events.length?((n=new Date(events[i][2]))<=d) || (events[i][0].substring(0,1)=="*") || (events[i][5]!=0):0; i++ ){}
	if ( i<events.length )
	{	ddd=(n+" ").substring(0,3);
		dddd=days[mhInArray(days,ddd)+7];
		mmm=(n+" ").substring(4,7);
		mmmm=months[mhInArray(months,mmm)+12];		
		t="Our next Kent Group walk is <a href='walklist.html'>"+events[i][0]+"</a> on "+dddd+" "+events[i][2].replace(mmm,mmmm)+".";
		document.getElementById("nextwalk").innerHTML=t;
	}
}
function mhInArray(a,t)
{	for( var i = 0 ; i < a.length; i++ )
	{	if( a[i]===t) return i;
 	}
	return false;
}
function addLoadListener(fn)// this needs attribution:
{	if (typeof window.addEventListener != 'undefined')
	{	window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined')
	{	document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{	window.attachEvent('onload', fn);
	}
	else
	{	return false;
	}
	return true;
}
addLoadListener(mhShowEvent);
