function setStates(formname,fieldname,selectedval,page)
{
	
	var array1 = 54;
	var states = new Array(array1);
	states[0] = "Alabama";
	states[1] = "Alaska";
	states[2] = "Arizona";
	states[3] = "Arkansas";
	states[4] = "California";
	states[5] = "Colorado";
	states[6] = "Connecticut";
	states[7] = "D.C.";
	states[8] = "Delaware";
	states[9] = "Florida";
	states[10] = "Georgia";
	states[11] = "Guam";
	states[12] = "Hawaii";
	states[13] = "Idaho";
	states[14] = "Illinois";
	states[15] = "Indiana";
	states[16] = "Iowa";
	states[17] = "Kansas";
	states[18] = "Kentucky";
	states[19] = "Louisiana";
	states[20] = "Maine";
	states[21] = "Maryland";
	states[22] = "Massachusetts";
	states[23] = "Michigan";
	states[24] = "Minnesota";
	states[25] = "Mississippi";
	states[26] = "Missouri";
	states[27] = "Montana";
	states[28] = "Nebraska";
	states[29] = "Nevada";
	states[30] = "New Hampshire";
	states[31] = "New Jersey";
	states[32] = "New Mexico";
	states[33] = "New York";
	states[34] = "North Carolina";
	states[35] = "North Dakota";
	states[36] = "Ohio";
	states[37] = "Oklahoma";
	states[38] = "Oregon";
	states[39] = "Pennsylvania";
	states[40] = "Puerto Rico";
	states[41] = "Rhode Island";
	states[42] = "South Carolina";
	states[43] = "South Dakota";
	states[44] = "Tennessee";
	states[45] = "Texas";
	states[46] = "The Virgin Islands";
	states[47] = "Utah";
	states[48] = "Vermont";
	states[49] = "Virginia";
	states[50] = "Washington";
	states[51] = "West Virginia";
	states[52] = "Wisconsin";
	states[53] = "Wyoming";
	var a=0;
	
	if (page)
	document.forms[formname].elements[fieldname].options[a] = new Option ("Any", "any");
	else document.forms[formname].elements[fieldname].options[a] = new Option ("Please Select", "def");
    a=a+1;
 	for(var i=0;i<array1;i++) 
 	{
  		document.forms[formname].elements[fieldname].options[a] = new Option (states[i], states[i]);
  		a=a+1;
 	} 	
 	
 	if (selectedval)
 	{
 		for (i=0;i<document.forms[formname].elements[fieldname].length;i++)
 		if (document.forms[formname].elements[fieldname].options[i].value==selectedval)
 		document.forms[formname].elements[fieldname].selectedIndex=i; 		
 	}
}



function setCounties(formname,fieldname,selectedval,page){
var array1 = 94;
var county = new Array(array1);
county[0] = "Aberdeenshire";
county[1] = "Angus";
county[2] = "Anglesey";
county[3] = "Argyllshire";
county[4] = "Avon";
county[5] = "Ayrshire";
county[6] = "Banffshire";
county[7] = "Bedfordshire";
county[8] = "Berkshire";
county[9] = "Berwickshire";
county[10] = "Breconshire";
county[11] = "Buckinghamshire";
county[12] = "Buteshire";
county[13] = "Caernarvonshire";
county[14] = "Caithness";
county[15] = "Cambridgeshire";
county[16] = "Cardiganshire";
county[17] = "Carmarthenshire";
county[18] = "Cheshire";
county[19] = "Clackmannanshire";
county[20] = "Clwyd";
county[21] = "Cornwall";
county[22] = "Cumbria";
county[23] = "Denbighshire";
county[24] = "Derbyshire";
county[25] = "Devon";
county[26] = "Dorset";
county[27] = "Dumfries";
county[28] = "Dunbarton";
county[29] = "Durham";
county[30] = "Dyfed";
county[31] = "East Lothian";
county[32] = "Essex";
county[33] = "Fifeshire";
county[34] = "Flintshire";
county[35] = "Glamorgan";
county[36] = "Gloucestershire";
county[37] = "Greater Manchester";
county[38] = "Gwent";
county[39] = "Gwynedd";
county[40] = "Hampshire";
county[41] = "Hereford & Worcester";
county[42] = "Hertfordshire";
county[43] = "Humberside";
county[44] = "Inverness-shire";
county[45] = "Isle of Wight";
county[46] = "Kent";
county[47] = "Kincardine";
county[48] = "Kinross";
county[49] = "Kirkcudbrightshire";
county[50] = "Lanarkshire";
county[51] = "Lancashire";
county[52] = "Leicestershire";
county[53] = "Lincolnshire";
county[54] = "London";
county[55] = "Merionethshire";
county[56] = "Merseyside";
county[57] = "Midlothian";
county[58] = "Monmouthshire";
county[59] = "Montgomeryshire";
county[60] = "Morayshire";
county[61] = "Nairn";
county[62] = "Norfolk";
county[63] = "North Yorkshire & Teesside";
county[64] = "Northamptonshire";
county[65] = "Northern Ireland";
county[66] = "Northumbria";
county[67] = "Nottinghamshire";
county[68] = "Orkney Islands";
county[69] = "Oxfordshire";
county[70] = "Peeblesshire";
county[71] = "Pembrokeshire";
county[72] = "Perthshire";
county[73] = "Powys";
county[74] = "Radnorshire";
county[75] = "Renfrewshire";
county[76] = "Ross and Cromarty";
county[77] = "Roxburghshire";
county[78] = "Selkirkshire";
county[79] = "Shetland Islands";
county[80] = "Shropshire";
county[81] = "Somerset";
county[82] = "South & West Yorkshire";
county[83] = "Staffordshire";
county[84] = "Stirlingshire";
county[85] = "Suffolk";
county[86] = "Surrey";
county[87] = "Sussex";
county[88] = "Sutherlandshire";
county[89] = "Warwickshire";
county[90] = "West Lothian";
county[91] = "West Midlands";
county[92] = "Wigtownshire";
county[93] = "Wiltshire";
	var a=0;
	
	if (page)
	document.forms[formname].elements[fieldname].options[a] = new Option ("Any", "any");
	else  document.forms[formname].elements[fieldname].options[a] = new Option ("Please Select", "def");
    a=a+1;
 	for(var i=0;i<array1;i++) 
 	{
  		document.forms[formname].elements[fieldname].options[a] = new Option (county[i], county[i]);
  		a=a+1;
 	} 	 	
 	
 	if (selectedval)
 	{
 		for (i=0;i<document.forms[formname].elements[fieldname].length;i++)
 		if (document.forms[formname].elements[fieldname].options[i].value==selectedval)
 		document.forms[formname].elements[fieldname].selectedIndex=i; 		
 	}
}

function checkCountry(formname,regionfieldname,countryfieldname,selectedval,page)
{
	document.forms[formname].elements[regionfieldname].options.length=0;
	var cIndex = document.forms[formname].elements[countryfieldname].selectedIndex;	
 	var country = document.forms[formname].elements[countryfieldname].options[cIndex].value;
	
    if(country=="164") 
    {
   		setStates(formname,regionfieldname,selectedval,page); 
    }
    else 
    if(country=="163") 
    {
   		setCounties(formname,regionfieldname,selectedval,page); 
    }
    else 
    { 
    	document.forms[formname].elements[regionfieldname].options[0]=new Option ("Not Available", "any");    	
    	document.forms[formname].elements[regionfieldname].selectedIndex=0;
  	} 
}


function setCountry(formname,countryfieldname,selectedval)
{
	for (i=0;i<document.forms[formname].elements[countryfieldname].length;i++)
	if (document.forms[formname].elements[countryfieldname].options[i].value==selectedval)
	document.forms[formname].elements[countryfieldname].selectedIndex=i; 	
}

