
var catList = new Array();

catList['choose']         = [];
catList['Art']			  = ['---select---', 'Painting', 'Painter', 'Artist at work', 'Illustration', 'Artist', 'Artistic'];
catList['Animals']        = ['---select---', 'Farm Animals','Dogs','Horses','Cats','Wildlife','Birds', 'Fish', 'Miscellaneous', 'Pets'];
catList['Architecture']   = ['---select---', 'Bridges', 'Rail/Road', 'Interiors', 'Churches/Religious', 'Offices', 'Cityscapes', 'Skyscrapers', 'Detail', 'Exteriors','Houses', 'Monuments', 'Miscellaneous', 'Residential'];
catList['Illustration']   = ['---select---', 'Graphics','Illustration', 'Montage','Digital','Abstract','Miscellaneous'];
catList['Aviation']		  = ['---select---', 'Aircract', 'Airliner', 'Helicopter', 'Military', 'Warbird', 'Historic', 'Sailplane', 'Microlight', 'Aerobatics','Airport', 'Pilot', 'General Aviation'];
catList['Backgrounds']    = ['---select---', 'Miscellaneous', 'Scrapbooking and Stationary', 'Textures'];
catList['Business']       = ['---select---', 'Workplace','Business Headlines ','Business Man ','Business Meeting','Business People ','Business Woman ', 'Call Centre','Catering ','Conference Delegates', 'Conference Room ', 'Construction ', 'Council Worker ', 'Bankrupt ', 'Barrister ', 'Bribery', 'Builder ','Financial', 'Miscellaneous', 'Objects', 'Office', 'People', 'Property', 'Retail', 'Services', 'Banking', 'Manufacturing', 'Insurance'];
catList['City']			 = ['---select---', 'The City', 'Banking', 'Finance', 'Stock Trading', 'Insurance', 'Office Worker', 'Businessman', 'Shares'];
catList['Computers']      = ['---select---', 'Keyboard', 'Monitor', 'Networking', 'Servers', 'Fibre Optics', 'Cabling', 'Internet', 'Hardware', 'Software'];
catList['Conceptual']     = ['---select---', 'Beauty', 'Diversity', 'Fear', 'Growth', 'Happiness', 'Helping/Giving', 'Humorous', 'Leadership', 'Love', 'Luxury', 'Miscellaneous', 'Peace', 'Power', 'Risk', 'Sadness', 'Safety', 'Security', 'Speed', 'Spiritual', 'Stress', 'Success', 'Uniqueness', 'Wealth'];
catList['Construction']  = ['---select---', 'Construction', 'Building Work','Builders','DIY','Labourer','Manual Worker','Property Development','Estate Agents','Facilities services'];
catList['Education']      = ['---select---', 'Nursery', 'School', 'College', 'University', 'Graduation', 'Library', 'Miscellaneous', 'Objects', 'Preschool', 'Exams'];
catList['Events']		  = ['---select---', 'Office Part', 'Wedding', 'Party', 'Funeral', 'Birthday', 'Conference', 'Corporate', 'Concert', 'Gig'];
catList['Family']           = ['---select---','Family', 'Parents', 'Kids', 'Toddler', 'Teens', 'Children', 'Kids Playing', 'Family Playng', 'Adults', 'Mum', 'Dad', 'Father', 'Mother', 'Son', 'Daughter', 'Sister', 'Brother', 'Uncle', 'Grandparents', 'Grandfather', 'Grandmother', 'Grandpa', 'Nanny', 'Dining Room', 'Make up', 'Family', 'Face Painting', 'Granny', 'Family Holiday', 'Home Working', 'Husband and Wife', 'Bedroom', 'Kids Party', 'Lounge', 'Mother and Baby', 'Mother and Child', 'Nursery',  'Shaving', 'Shopping', 'Sports Day', 'Washing Up', 'Getting the groceries', 'Laundry'];
catList['Food']           = ['---select---', 'Fast Food', 'Breakfast', 'Dinner', 'Lunch', 'Picnic', 'Eating Out', 'Cooking', 'BBQ', 'Meat', 'Veg', 'Beverages', 'Desserts/Sweets', 'Markets', 'Miscellaneous', 'Restaurants'];
catList['Health']         = ['---select---', 'Abuse', 'Alternative', 'Diet and Nutrition', 'Dental', 'Fitness', 'Hospitals', 'Hygiene', 'Medical', 'Mental Health', 'Miscellaneous', 'Obstetrics', 'Pharmaceuticals'];
catList['Holidays']       = ['---select---', 'School Holidays','Summer Holidays','Half-Term', 'Birthday', 'Christmas', 'Easter', 'Fireworks Night', 'Halloween', 'Miscellaneous', 'New Years', 'Valentines Day', 'Weddings'];
catList['Industry']		  = ['---select---', 'Factory', 'Retail', 'Cars', 'Engineering', 'Clothing/Fashion', 'Concepts', 'Construction', 'Electronics', 'Defence', 'Timber', 'Manufacturing', 'Military', 'Miscellaneous', 'Police/Fire', 'Power and Energy'];
catList['Internet']       = ['---select---', 'Concepts', 'Web Design', 'Network','Dot Com','Online Shopping', 'Servers', 'Email', 'Online Banking', 'Miscellaneous'];
catList['Landscapes']     = ['---select---', 'Sea', 'Coast', 'Countryside', 'Hills', 'Urban', 'Clouds', 'Desert', 'Miscellaneous', 'Mountains', 'Ocean', 'Rivers', 'Rural'];
catList['Leisure']			= ['---select---', 'Hobbies', 'Cinema', 'Pubs', 'Eating Out', 'Shopping', 'Socialising','Gardening', 'DIY', 'Drawing','Painting','Exercise','Sports', 'Walking', 'Cycling', 'Reading', 'Resting'];
catList['Miscellaneous']  = ['---select---', 'Objects', 'Miscellaneous'];
catList['Music']        = ['---select---', 'Instruments', 'Band', 'Group', 'Musician', 'Brass Band', 'Orchestra', 'Gig', 'Stage', 'Concert', 'Rock group', 'Classic', 'Live Music', 'Miscellaneous'];
catList['Nature']         = ['---select---', 'Clouds', 'Sunsets', 'Countryside', 'Forests', 'Hills', 'Crops', 'Farming', 'Autumn', 'Summer', 'Spring', 'Winter', 'Flowers', 'Insects', 'Miscellaneous', 'Plants', 'Skies', 'Trees', 'Underwater'];
catList['Objects']        = ['---select---', 'Currency', 'Electronics', 'Extreme Close-Ups', 'Flags/Maps/Globes', 'Everyday', 'Industrial', 'Miscellaneous', 'Over White', 'Religious/Spiritual', 'Signs', 'Tools', 'Toys', 'Weapons'];
catList['People']         = ['---select---', 'Babies', 'Body Parts','Children', 'Couples', 'Families', 'Men', 'Miscellaneous', 'Seniors', 'Teens', 'Women'];
catList['Places']         = ['---select---', 'Aerial', 'Airports', 'Stations', 'Cities', 'Towns', 'Villages', 'Seaside', 'Beaches', 'Stately Homes', 'Farms', 'London', 'The City', 'Homes', 'Hospitals', 'Industrial', 'Landmarks/Monuments', 'The North', 'The South', 'The South East', 'The South West', 'The West', 'The Midlands', 'The North East', 'The North West', 'England', 'Scotland', 'Wales', 'Ireland', 'France', 'Germany', 'Spain', 'Italy', 'Europe', 'Russia', 'Far East', 'North America', 'South America', 'Miscellaneous', 'Rural', 'Schools', 'Travel', 'Urban', 'Winter'];
catList['Sports']         = ['---select---', 'Cricket', 'Rubgy', 'Martial Arts', 'Climbing', 'Rowing', 'Basketball', 'Cycling', 'Extreme', 'Fishing', 'Football', 'Golf', 'Miscellaneous', 'Racing', 'Skateboarding', 'Skiing', 'Snowboarding', 'Soccer', 'Surfing', 'Swimming'];
catList['Telecommunications']  = ['---select---', 'Miscellaneous', 'Internet', 'Telephone', 'Radio', 'TV', 'Broadcasting', 'Networks'];
catList['Transportation'] = ['---select---', 'Cars', 'Lorries', 'Ships', 'Boats', 'Flying', 'Airliner', 'Roads', 'Motorways', 'Underground', 'Miscellaneous', 'Motorcycles', 'Trains'];
catList['Weather']         = ['---select---', 'Storms', 'Clouds', 'Sunset', 'Fog', 'Snow', 'Rain', 'Wind', 'Sunshine'];


        





function select_item(obj, withvalue) 
{
  for(var i = 0; i < obj.length; i++) {
    if (obj.options[i].value == withvalue) {
      obj.options[i].selected = true;
      return;
    }
  }
}

function category_main_select(baseid, catval, subval, blanksub) {
  var idMain = 'cat' + baseid;
  var idSub  = 'subcat' + baseid;

  main = document.getElementById(idMain);
  sub  = document.getElementById(idSub);
  select_item(main, catval);

  BuildSubMenu(main, idSub, catList, blanksub);
  select_item(sub, subval);
}


/* 
 * obj   - the <select> object that has the value
 * subid - the html id of the submenu
 * list  - an associative array of arrays
 */
function BuildSubMenu(obj, subid, list, blanksub) {
	var subMenu = document.getElementById(subid);
	var mainCat = obj.value;

	if (! subMenu ) {
		//alert('no subcategory with id ' + subid);
		return false;
	}

	// reset sub category
	subMenu.options.length = 0;

	if (! list[mainCat] ) {
		//alert('no Category found ' + mainCat);	
		return false;
	}

	subCats = list[mainCat];
 
  var index = 0
	if (blanksub) {
		if (blanksub == true) {
			subMenu.options[0] = new Option('', '', false, false);
		} else {
			subMenu.options[0] = new Option(blanksub, '', false, false);
		}
    index++;
  }

	for(i = 0; i < subCats.length; i++) {
		catname = subCats[i];
		subMenu.options[i+index] = new Option(catname, catname, false, false);
	}

}

function AdjustRelease(obj, dupid, list, area) {

	var contain =  document.getElementById(area);
	var parent = document.getElementById(list);
	var dup = document.getElementById(dupid);

	var kids = parent.childNodes;
	var have = kids.length;
	var want = obj.value;


	if (want > have) {

		for (var i = have ; want > have; have++) {
			var newel = dup.cloneNode(true);
			newel.style.display = 'block';
			newel.id =  dup.id + i;
			parent.appendChild(newel);
		}

	} else if(want < have) {
		for (var i = have ; have > want; have--) {
			parent.removeChild(kids[have-1]);
		}
	}
	contain.style.display = have? 'block': 'none';

}

