﻿
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Michael J. Damato | http://developing.damato.net/ */
// State lists
var states = new Array();
 
states['Bedfordshire'] = new Array('Please select the town','Bedford','Luton');
states['Berkshire'] = new Array('Please select the town','Burnham','Newbury','Slough');
states['Bucks'] = new Array('Please select the town','Chesham','Milton Keynes');
states['Cheshire'] = new Array('Please select the town','Marple','Stockport','Poynton','Stalybridge','Warrington');
states['Cornwall'] = new Array('Bodmin');
states['County Waterford'] = new Array('Dungarven');
states['Dorset'] = new Array('Please select the town','Bournemouth','Christchurch');
states['Dublin 16'] = new Array('Dundrum');
states['E. Sussex'] = new Array('Please select the town','Eastbourne','Seaford');
states['Essex'] = new Array('Please select the town','Colchester','Leigh on Sea','Pitsea','Wickford');
states['Hampshire'] = new Array('Please select the town','Basingstoke','Lymington','Winchester','Hartley Winteny');
states['Herts'] = new Array('Please select the town','Hitchin','St.Albans','Bishops Stortford','Waltham Cross','Rickmansworth','Saint Albans');
states['Ireland'] = new Array('Please select the town','Galway','County Donegal','Cork','Dublin 1','Londonderry','Monaghan','Omagh');
states['Kent'] = new Array('Please select the town','Maidstone','Bromley','Petts wood','Broadstairs','Gravesend');
states['Lancashire'] = new Array('Please select the town','Preston','Sleaford','Blackpool','Bury','Horwich Bolton');
states['London'] = new Array('Please select the town','Epsom','Euston','Grays','Ilford','London','North Finchley','Pinner','Palmers Green','Crystal');
states['Lincs'] = new Array('Please select the town','Holbeach','Bourne','Boston','Spilsby');
states['Liverpool'] = new Array('Please select the town','Waterloo','Liverpool','Barnett','Childwall');
states['Merseyside'] = new Array('Southport');
states['Middlesex'] = new Array('Please select the town','Northwood','Pinner');
states['Northern Ireland'] = new Array('Please select the town','Belfast','Newcastle'); 
states['Nottingham'] = new Array('Newark');
states['Nottinghamshire'] = new Array('Mansfield');
states['Scotland'] = new Array('Please select the town','Aberdeen','Edinburgh','Glasgow','Perth','Nairn');
states['Somerset'] = new Array('Yeovil');
states['Suffolk'] = new Array('Please select the town','Ipswich','Woodbridge');
states['Surrey'] = new Array('Please select the town','Weybridge','Sutton');
states['West Midlands'] = new Array('Please select the town','Solihull','Wolverhampton');
states['West Sussex'] = new Array('Pulborough');
states['Cumbria'] = new Array('Please select the town','Whitehaven','Milnthorpe','Ulverston');
states['Devon'] = new Array('Paignton');
states['Staffordshire'] = new Array('Rugeley');
states['Wales'] = new Array('Cardiff');
states['Wiltshire'] = new Array('Downton');
states['Argyll'] = new Array('Dunoon');
states['Eastwood'] = new Array('Eastwood');
states['Lincolnshire'] = new Array('Sleaford');
states['Glasgow'] = new Array('Shawlands');
states['Manchester'] = new Array('Please select the town','Manchester','Chorlton');
states['Oxon'] = new Array('Banbury');
states['Lancs'] = new Array('Please select the town','Chorley','Preston');
states['Saddleworth'] = new Array('Delph');
states['Oxfordshire'] = new Array('Oxford');
states['Bristol'] = new Array('Bristol');
states['Worc'] = new Array('Bromsgrove');
states['County Durham'] = new Array('Durham');
states['Derbyshire'] = new Array('Belper');




 

function setStates() {
  cntrySel = document.getElementById('country');
  stateList = states[cntrySel.value];
  changeSelect('state', stateList, stateList); 
}
 

function changeSelect(fieldID, newOptions, newValues) {
  selectField = document.getElementById(fieldID);
  selectField.options.length = 0;
  for (i=0; i<newOptions.length; i++) {
    selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
  }
}

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
 
function validateForm(){
		if(document.storelist.country.selectedIndex==0)
		{
			alert("Please Select a Location.");
			document.storelist.country.focus();
			return false;
		}
		if(document.storelist.state.value=='Please select the town')
		{
			alert("Please select the town.");
			document.storelist.state.focus();
			return false;
		}

return true;
} 
addLoadEvent(function() {
  setStates();
}); 



