var clength,prdata,prlength,areadata,arealength,locationdata,locationlength, prextra,arextra,locextra,indextra
clength=prlength=arealength=locationlength=industrylength=null;
	function initialisedropdowns() {
	// initialise the dropdowns
		if (clength != null) {
			var coindex = document.getElementById('countryid').selectedIndex;
			var	country = document.getElementById('countryid').options[coindex].value;
		 	setcountrydata(country);
		}
	}
	function setcountrydata(country) {
		showprovincedata(country);
		showctryareadata(country);
		showctrylocationdata(country);
	}
	function setprovincedata(province) {
		showprareadata(province);
		showprlocationdata(province);
	}
	function setareadata(area) {
		showarlocationdata(area);
	}
	function showprovincedata(country) {
		// check here to see if we actually have a drop down to rebuild
		if (prlength != null) {
		// rebuild the Province drop down
			var prselect = document.getElementById("provinceid");
			prselect.options.length=0;
			if ( prextra != "" ) {
				prselect.options[0] = new Option (prextra,"",false,false);
			}
			for (i=0;i<=prlength;i++) {
				if (prdata[i*5+0]==country) {
					prselect.options[prselect.length] = new Option(prdata[i*5+2],prdata[i*5+1],false,false);
				}
			}
			if (prselect.multiple) {
				if (prselect.options.length < 4)
					prselect.size = prselect.options.length;
				else
					prselect.size = 4;
			}
		}
	}
	function showctryareadata(country) {
		// check here to see if we actually have a drop down to rebuild
		if (arealength != null) {
		// now rebuild the Area drop down
			var arselect = document.getElementById("areaid")
			arselect.options.length=0;
			if ( arextra != "" ) {
				arselect.options[0] = new Option (arextra,"",false,false);
			}
			var area = 0
			for (i=0;i<=arealength;i++) {
				if (areadata[i*5+0]==country) {
					if (areadata[i*5+2] != area) {
						area = areadata[i*5+2];
						arselect.options[arselect.length] = new Option(areadata[i*5+3],areadata[i*5+2],false,false);
					}
				}
			}
			if (arselect.options.length == 0 )
				arselect.options[0] = new Option("","",false,false);
			if (arselect.multiple) {
				if (arselect.options.length < 4)
					arselect.size = arselect.options.length;
				else
					arselect.size = 4;
			}
			
		}
		
	}
	function showprareadata(province) {
		// check here to see if we actually have a drop down to rebuild
		if (arealength != null) {
		// now rebuild the Area drop down
			var arselect = document.getElementById("areaid")
			arselect.options.length=0;
			if ( arextra != "" ) {
				arselect.options[0] = new Option (arextra,"",false,false);
			}
			for (i=0;i<=arealength;i++) {
				if (areadata[i*5+1]==province) {
					arselect.options[arselect.length] = new Option(areadata[i*5+3],areadata[i*5+2],false,false);
				}
			}
			if (arselect.options.length == 0 )
				arselect.options[0] = new Option("","",false,false);
			if (arselect.multiple) {
				if (arselect.options.length < 4)
					arselect.size = arselect.options.length;
				else
					arselect.size = 4;
			}
		}
		
	}
	function showctrylocationdata(country) {
		// check here to see if we actually have a drop down to rebuild
		if (locationlength != null) {
		// now rebuild the Location drop down
			var locselect = document.getElementById("locationid")
			locselect.options.length=0;
			if ( locextra != "" ) {
				locselect.options[0] = new Option (locextra,"",false,false);
			}
			var locid = 0
			for (i=0;i<=locationlength;i++) {
				if (locationdata[i*5+0]==country) {
					if (locationdata[i*5+3] != locid) {
						locid = locationdata[i*5+3];
						locselect.options[locselect.length] = new Option(locationdata[i*5+4],locid,false,false);
					}
				}
			}
			if (locselect.options.length == 0 )
				locselect.options[0] = new Option("","",false,false);

		}
	}
	function showprlocationdata(province) {
		// check here to see if we actually have a drop down to rebuild
		if (locationlength != null) {
		// now rebuild the Location drop down
			var locselect = document.getElementById("locationid")
			locselect.options.length=0;
			if ( locextra != "" ) {
				locselect.options[0] = new Option (locextra,"",false,false);
			}
			var locid = 0
			for (i=0;i<=locationlength;i++) {
				if (locationdata[i*5+1]==province) {
					if (locationdata[i*5+3] != locid) {
						locid = locationdata[i*5+3];
						locselect.options[locselect.length] = new Option(locationdata[i*5+4],locid,false,false);
					}
				}
			}
			if (locselect.options.length == 0 )
				locselect.options[0] = new Option("","",false,false);

		}
	}
	function showarlocationdata(area) {
		// check here to see if we actually have a drop down to rebuild
		if (locationlength != null) {
		// now rebuild the Location drop down
			var locselect = document.getElementById("locationid")
			locselect.options.length=0;
			if ( locextra != "" ) {
				locselect.options[0] = new Option (locextra,"",false,false);
			}
			var locid = 0
			for (i=0;i<=locationlength;i++) {
				if (locationdata[i*5+2]==area) {
					if (locationdata[i*5+3] != locid) {
						locid = locationdata[i*5+3];
						locselect.options[locselect.length] = new Option(locationdata[i*5+4],locid,false,false);
					}
				}
			}
			if (locselect.options.length == 0 )
				locselect.options[0] = new Option("","",false,false);

		}
	}