var NoneArray = new Array("('---------','None')");

var G =new Array("('Global','G',true,true)");
var G1 =  new Array(	"('Asia(ALL)','G1',true,true)",
							"(' North Asia','G11')",
							"(' South Asia','G12')",
							"(' Southeast Asia(ALL)','G13')",
							"('    Indochina(ALL)','G131')",
							"('       Burma','G1311')",	
							"('       Laos','G1312')",
							"('       Vietnam','G1313')",
							"('       Thailand','G1314')",
							"('       Cambodia','G1315')",	
							"('    Papuasian','G132')",
							"('    Sundaic(ALL)','G133')",
							"('       Malay Peninsula/Singapore','G1331')",	
							"('       Borneo','G1332')",
							"('       Sumatra','G1333')",
							"('       Java/Bali','G1334')",	
							"('    Wallacean(ALL)','G134')",
							"('       Philippines','G1341')",	
							"('       Sulawesi','G1342')",
							"('       Maluku','G1343')",
							"('       Lesser Sundas','G1344')");					
	var G2 =  new Array("('Australasia','G2',true,true)");
	var G3 =  new Array("('Africa','G3',true,true)");						
	var G4 =  new Array("('Antartica','G4',true,true)");							
	var G5 =  new Array("('North America','G5',true,true)");	
	var G6 =  new Array("('Oceania/Pacific','G6',true,true)");	
	var G7 =  new Array("('South America','G7',true,true)");	
	var G8 =  new Array("('Tropical','G8',true,true)");	
	var G9 =  new Array("('Europe','G9',true,true)");	

//	subject scope	
	var S1 = new Array("('Production Systems(ALL)','S1',true,true)",
						"(' Agriculture(ALL)','S11')",
						"('    Agroforestry','S111')",
						"('    Crop Breeding','S112')",
						"('    Domestication','S113')",
						"('    Pest Resistance','S114')",
						"('    Crop Production','S115')",
						"('    Livestock Production','S116')",
						"(' Fishery(ALL)','S12')",	
						"('    Aquaculture','S121')",
						"('    Assessment and Development','S122')",
						"('    Management','S123')",
						"('    Captive Techniques','S124')",
						"(' Forestry(ALL)','S13')",	
						"('    Logging','S131')",
						"('    Genetic Labeling','S132')",
						"('    Non Timber Forest Products','S133')",
						"('    Reforestation','S134')",
						"('    Silviculture','S135')",
						"('    Social Forestry','S136')");								
	var S2 = new Array("('Geography(ALL)','S2',true,true)",
	"(' Climate','S21')",
	"(' Geology','S22')",
	"(' Land Form','S23')",
	"(' Oceanography','S24')",
	"(' Plate Tectonics','S25')",
	"(' Soils','S26')",
	"(' Hydrology','S27')",
	"(' Biogeography','S28')");
var S3= new Array("('Biology(ALL)','S3',true,true)",
	"(' Botany(ALL)','S31')",
	"('    Plant Systematics and Taxonomy','S311')",
	"('    Plant Anatomy/Morphology','S312')",
	"('    Ethnobotany and Pharmacology','S313')",
	"('    Plant Physiology','S314')",
	"('    Plant Pathology','S315')",
	"('    Plant Genetics','S316')",	
	"(' Zoology(ALL)','S32')",
	"('    Animal Systematics and Taxonomy','S321')",
	"('    Animal Anatomy/Morphology','S322')",
	"('    Animal Physiology','S323')",
	"('    Animal Pathology','S324')",
	"('    Animal Genetics','S325')",
	"('    Veterinary','S326')",	
	"(' Biochemistry','S33')",
	"(' Microbiology','S34')",
	"(' Paleontology','S35')",
	"(' Parasitology','S36')");
	
var S4= new Array("('Ecology(ALL)','S4',true,true)",
	"(' Autecology','S41')",
	"(' Synecology','S42')",
	"(' Behavioural Ecology(ALL)','S43')",
	"('    Feeding Ecology','S431')",
	"('    Reproductive Ecology','S432')",
	"('    Ranging Ecology','S433')",	
	"(' Ecosystem Ecology','S44')",
	"(' Phenology','S45')",	
	"(' Evolutionary Ecology','S46')",
	"(' Restoration Ecology','S47')",
	"(' Ecotoxicology','S48')");
	
var S5= new Array("('Environmental Policy and Planning(ALL)','S5',true,true)",
	"(' Environmental Issues(ALL)','S51')",
	"('    Environmental Economics/Valuation','S511')",
	"('    Environmental Quality/Pollution(ALL)','S512')",	
	"('       Climate Change','S5121')",
	"('       Biosafety','S5122')",
	"('       Environmental Health','S5123')",
	"('    Business and Biodiversity','S513')",
	"('    Bioprospecting/Access to Genetic Resources','S514')",	
	"(' Environmental Policy/Legal(ALL)','S52')",
	"('    Environmental Laws','S521')",
	"('    International Convention','S522')",
	"('    Trade Control/CITES','S523')",
	"('    Wildlife Protection','S524')",	
	"(' Environmental Planning(ALL)','S53')",
	"('    Land Use Planning','S531')",
	"('    Environmental Impact Assessment','S532')");

var S6= new Array("('Environmental Conservation and Management(ALL)','S6',true,true)",
	"(' Ecomanagement(ALL)','S61')",
	"('    Captive Breeding/Reintroduction','S611')",
	"('    Fire Management','S612')",
	"('    Pest Control','S613')",
	"('    Protected Areas(ALL)','S614')",
	"('       System Planning','S6141')",
	"('       Management and Management Planning','S6142')",
	"('       Integrated Conservation and Development Projects','S6143')",
	"('       Enforcement and Protection','S6144')",
	"('       Survey and Monitoring','S6145')",
	"('    Wildlife/Species Management','S615')",
	"('    Alien Invasive Species Management','S616')",
	"('    Conservation Project Management','S617')",
	"('    Recreation and Tourism','S618')",	
	"('    Watershed Management','S619')",
	"(' Technical(ALL)','S62')",
	"('    Biotechnology','S621')",
	"('    Information Management','S622')",
	"('    Genetically Modified Organisms','S623')",
	"('    GIS and Remote Sensing','S624')",
	"('    Scientific Collections','S625')",
	"('    Zoos/Botanic Gardens','S626')",
	"('    Gene Bank','S627')",
	"('    Field Recognition/Studies(ALL)','S628')",
	"('       Dendrology','S6281')",
	"('       Conservation Status','S6282')",
	"('       Distribution Studies','S6283')",
	"('       Field Survey/Inventory','S6284')",	
	"('    Mapping/Cartography','S629')",	
	"(' Communities and Conservation(ALL)','S63')",
	"('    Socio Economic Assessment','S631')",
	"('    Participatory Techniques','S632')",
	"('    Collaborative/Community Management','S633')",
	"('    Gender Issues','S634')",	
	"('    Indigenous Knowledge Systems','S635')",	
	"(' Training and Education(ALL)','S64')",
	"('    Academic Teaching/Supervision','S641')",
	"('    School Teaching','S642')",
	"('    Vocational Short Courses','S643')",
	"('    Course/Curriculum Development','S644')",
	"('    Community Awareness/Outreach','S645')",
	"('    Training Trainers','S646')",	
	"('    Extension','S647')",	
	"(' PR, Media and Awareness(ALL)','S65')",
	"('    Journalism/Media','S651')",
	"('    Public Relations','S652')",
	"('    Awareness/Interpretation','S653')",
	"('    Film/Video','S654')",	
	"(' Project Planning(ALL)','S66')",
	"('    Conservation Project Design','S661')",
	"('    Project Proposals','S662')",
	"('    Fund Raising','S663')",
	"('    Project Evaluation','S664')");
	
//Taxonomic Scope
var T = new Array("('All Wildlife','T',true,true)")
var T1=  new Array("('Freshwater Life(ALL)','T1',true,true)",
	"(' Fish','T11')",
	"(' Invertebrates','T12')",
	"(' Waterbirds','T13')",
	"(' Vegetation','T14')",
	"(' Microorganisms','T15')");
	
var T2 =  new Array("('Marine Life(ALL)','T2',true,true)",
	"(' Cephalopods','T21')",
	"(' Fish','T22')",
	"(' Marine Mammals','T23')",
	"(' Plankton','T24')",
	"(' Corals','T25')",
	"(' Molluscs','T26')",
	"(' Crustaceans','T27')",
	"(' Other Marine Life','T28')");
	
var T3 =  new Array("('Terrestrial Life(ALL)','T3',true,true)",
	"(' Animals(ALL)','T31')",
	"('    Invertebrates','T311')",
	"('    Arachnids','T312')",
	"('    Crustaceans','T313')",
	"('    Insects','T314')",
	"('    Mollusks','T315')",
	"('    Other Invertebrates','T316')",	
	"(' Vertebrates(ALL)','T32')",
	"('    Amphibians','T321')",
	"('    Birds','T322')",
	"('    Fish','T323')",
	"('    Mammals','T324')",
	"('    Reptiles','T325')",	
	"(' Microorganisms(ALL)','T33')",
	"('    Fungi','T331')",
	"('    Other Micro-organism','T332')",
	"(' Plants(ALL)','T34')",
	"('    Crops','T341')",
	"('    Ferns','T342')",
	"('    Grass','T343')",
	"('    Herbs','T344')",
	"('    Medicinal Plants','T345')",
	"('    Non-vascular','T346')",
	"('    Ornamentals','T347')",
	"('    Palms','T348')",
	"('    Trees','T349')",
	"('    Vines/Lianas','T340')");
	
var T4= new Array("('Habitat Based(ALL)','T4',true,true)",
	"(' Marine/Coastal(ALL)','T41')",
	"('    Coastal Reefs','T411')",
	"('    Mangroves','T412')",
	"('    Coastal Wetlands','T413')",
	"('    Shoreline','T414')",	
	"('    Estuarine','T415')",	
	"('    Seagrass Beds','T416')",	
	"('    Deep Sea','T417')",	
	"(' Fresh Water(ALL)','T42')",
	"('    Lakes','T421')",
	"('    Rivers','T422')",
	"('    Wetlands','T423')",
	"(' Grasslands/Savanahh','T43')",
	"(' Forests(ALL)','T44')",
	"('    Moist','T441')",
	"('    Dry','T442')",
	"('    Montane','T443')",
	"(' Man-made Habitats','T45')",
	"('    Croplands','T451')",
	"('    Rangelands','T452')",	
	"('    Urban Habitats','T453')",	
	"(' Deserts','T46')",
	"(' Mountains','T47')",
	"(' Limestone/Karst/Cave','T48')",
	"(' Degraded Habitats','T49')");
	
	
function LoadValues(f){
		PlaceCombo(f.cbomaingeog,f.cbosubgeog,f.cbomaingeog.options[f.cbomaingeog.selectedIndex].value);
		PlaceCombo(f.cbomainsubj,f.cbosubsubj,f.cbomainsubj.options[f.cbomainsubj.selectedIndex].value);
		PlaceCombo(f.cbomaintaxo,f.cbosubtaxo,f.cbomaintaxo.options[f.cbomaintaxo.selectedIndex].value);
		if(Number(f.select_subject.value)!=-1)
			f.cbosubsubj.options[Number(f.select_subject.value)].selected=true;
		if(Number(f.select_geographic.value)!=-1)	
			f.cbosubgeog.options[Number(f.select_geographic.value)].selected=true;
		if(Number(f.select_taxonomic.value)!=-1)	
			f.cbosubtaxo.options[Number(f.select_taxonomic.value)].selected=true;
	
	}
function Validate(f){				
		if(f.txt_title.value=="" && f.txt_author.value=="" && f.geogcode.value=="" &&  f.subjcode.value=="" && f.taxocode.value=="" ) { 
			alert('Please Fill At Least One Blank ')
			return false		
		}
		else {
			
			return true
		}	
	}

function PlaceValue(frm_object){
		//alert(frm_object.name+"selected"+frm_object.options[frm_object.selectedIndex].value+"Index"+frm_object.selectedIndex+"text" +document.frm_search.geogcode.value)
		if(frm_object.selectedIndex!=-1)
			switch (frm_object.name){
				case 'cbosubsubj':  document.frm_search.subjcode.value=frm_object.options[frm_object.selectedIndex].value;break;
				case 'cbosubtaxo':  document.frm_search.taxocode.value=frm_object.options[frm_object.selectedIndex].value;break;
				case 'cbosubgeog':  document.frm_search.geogcode.value=frm_object.options[frm_object.selectedIndex].value;break;
			}		
		else
				switch (frm_object.name){
				case 'cbosubsubj':  document.frm_search.subjcode.value="";break;
				case 'cbosubtaxo':  document.frm_search.taxocode.value="";break;
				case 'cbosubgeog':  document.frm_search.geogcode.value="";break;
			}		
	}		
function PlaceCombo(source,target){ // call to place values from main combo box to target list
	
	if(source.selectedIndex!=-1){		
		var selected=source.options[source.selectedIndex].value						
		if(selected!="None"){
			var	selectdArray = eval(selected);
			if(target.selectedIndex!=-1)
				while (selectdArray.length < target.options.length ) //empty target obj
					target.options[(target.options.length-1)]=null;					
			for (var i=0; i < selectdArray.length; i++) 
					eval("target.options[i]=" + "new Option" + selectdArray[i]);				
		}			
		else			
			for (i=target.options.length-1;i>=0;i--)			
				target.options[i]=null		
		target.focus()				
	}	
}	

function InitValue(f){
	f.cbomaingeog.selectedIndex=0
	f.cbomainsubj.selectedIndex=0
	f.cbomaintaxo.selectedIndex=0
	f.cbosubgeog.selectedIndex=0
	f.cbosubsubj.selectedIndex=0
	f.cbosubtaxo.selectedIndex=0
	f.geogcode.value=""
	f.subjcode.value=""
	f.taxocode.value="" 
}
function AssignValues(f){
	f.keyword.value=f.txt_author.value=f.txt_keyword.value;
	 //assign selected index # to variables to retain the previously selected criteria
	f.select_geographic.value=f.cbosubgeog.selectedIndex;
	f.select_subject.value=f.cbosubsubj.selectedIndex;
	f.select_taxonomic.value=f.cbosubtaxo.selectedIndex;
	//assign the selected criteria to hidden text
	if(f.cbosubgeog.selectedIndex!=-1 && String(f.cbosubgeog.options[f.cbosubgeog.selectedIndex].value)!='None' && String(f.cbosubgeog.options[f.cbosubgeog.selectedIndex].value)!='undefined' && String(f.cbosubgeog.options[f.cbosubgeog.selectedIndex].value)!='null')
		f.geogcode.value=f.cbosubgeog.options[f.cbosubgeog.selectedIndex].value
	else
		f.geogcode.value=''
	
	if(f.cbosubsubj.selectedIndex!=-1 && String(f.cbosubsubj.options[f.cbosubsubj.selectedIndex].value)!='None' && String(f.cbosubsubj.options[f.cbosubsubj.selectedIndex].value)!='undefined' && String(f.cbosubsubj.options[f.cbosubsubj.selectedIndex].value)!='null')
		f.subjcode.value=f.cbosubsubj.options[f.cbosubsubj.selectedIndex].value
	else
		f.subjcode.value=''
	if(f.cbosubtaxo.selectedIndex!=-1 && String(f.cbosubtaxo.options[f.cbosubtaxo.selectedIndex].value)!='None' && String(f.cbosubtaxo.options[f.cbosubtaxo.selectedIndex].value)!='undefined' && String(f.cbosubtaxo.options[f.cbosubtaxo.selectedIndex].value)!='null')
		f.taxocode.value=f.cbosubtaxo.options[f.cbosubtaxo.selectedIndex].value
	else
		f.taxocode.value=''
}
function deleteItem(thelist) {   //to empty the select box
	var j=Number(thelist.length)
	while(thelist.length!=0){
		thelist.options[0]=null   
		//document.write(i)
	}	
	thelist.options[0]=new Option('---------','None',true,true)
}

function SearchValue(submitform,sourceform){
		
	if(sourceform.geogcode.selectedIndex!=-1)
		if( sourceform.geogcode.options[sourceform.geogcode.selectedIndex].value!="None" )
			submitform.geogcode.value=sourceform.geogcode.options[sourceform.geogcode.selectedIndex].value	
		else
			submitform.geogcode.value=""
	else
		submitform.geogcode.value=""		
	if (sourceform.subjcode.selectedIndex!=-1 )	
		if (sourceform.subjcode.options[sourceform.subjcode.selectedIndex].value!="None")	
			submitform.subjcode.value=sourceform.subjcode.options[sourceform.subjcode.selectedIndex].value
		else
			submitform.subjcode.value=""
	else
		submitform.subjcode.value=""		

	if(sourceform.taxocode.selectedIndex!=-1 )	
		if (sourceform.taxocode.options[sourceform.taxocode.selectedIndex].value!="None")	
			submitform.taxocode.value=sourceform.taxocode.options[sourceform.taxocode.selectedIndex].value	
		else
			submitform.taxocode.value=""	
	else
		submitform.taxocode.value=""			
		
	// Starts here 	
	if(sourceform.org.checked)
		submitform.o.value=true
	else 
		submitform.o.value=false
	if(sourceform.specialists.checked)
		submitform.s.value=true
	else 
		submitform.s.value=false	
	if(sourceform.trd.checked)
		submitform.t.value=true
	else 
		submitform.t.value=false	
	if(sourceform.proj.checked)
		submitform.p.value=true
	else 
		submitform.p.value=false	
		
	if (sourceform.org.checked && sourceform.specialists.checked &&  sourceform.trd.checked )
		submitform.page.value=7	 //org, spec and trd
	else
		if (!sourceform.org.checked && sourceform.specialists.checked &&  sourceform.trd.checked )
			submitform.page.value=6  //spec and trd only
		else
			if (sourceform.org.checked && !sourceform.specialists.checked &&  sourceform.trd.checked )
				submitform.page.value=5 //org and trd
			else
				if (sourceform.org.checked && sourceform.specialists.checked &&  !sourceform.trd.checked )
					submitform.page.value=4  //search org and spec only
				else
					if (!sourceform.org.checked && !sourceform.specialists.checked &&  sourceform.trd.checked )
						submitform.page.value=3	 //search training resources only						
					else
						if (!sourceform.org.checked && sourceform.specialists.checked &&  !sourceform.trd.checked )
							submitform.page.value=2 //search specialists only	
						else
							submitform.page.value=1 // search org only		
   
   if (sourceform.specialists.checked)
   		submitform.s.value=true
   if (sourceform.org.checked)
   		submitform.o.value=true	
   if (sourceform.trd.checked)
   		submitform.t.value=true	
   if (sourceform.proj.checked)
   		submitform.p.value=true	
      
   submitform.lname.value=sourceform.keyword.value //for specialists
   submitform.fname.value=sourceform.keyword.value
   
   submitform.orgname.value=sourceform.keyword.value //for org
   submitform.acro.value=sourceform.keyword.value
   
   submitform.title.value=sourceform.keyword.value
   submitform.author.value=sourceform.keyword.value
   submitform.proj_title.value=sourceform.keyword.value
}

function LoadSubCombo(f,f1){
	var i=0	
	if(f.cbomaingeog.selectedIndex>0){	
		PlaceCombo(f.cbomaingeog,f.geogcode)		
		for (i=0;i<f.geogcode.length && f.geogcode.options[i].value!=f1.geogcode.value;i++);//select the appropriate option						
		if(i< f.geogcode.length){
			f.geogcode.options[0].selected=false
			f.geogcode.options[i].selected=true
		}
		else
			f.geogcode.options[0].selected=true
	}									
	if(f.cbomainsubj.selectedIndex>0){		
		PlaceCombo(f.cbomainsubj,f.subjcode)	
		for (i=0;i<f.subjcode.length && f.subjcode.options[i].value!=f1.subjcode.value;i++);//select the appropriate option		
		if(i<f.subjcode.length){
			f.subjcode.options[0].selected=false
			f.subjcode.options[i].selected=true
		}
		else
			f.subjcode.options[0].selected=true	
	}		
	if(f.cbomaintaxo.selectedIndex>0){
		PlaceCombo(f.cbomaintaxo,f.taxocode)	
		for (i=0;i<f.taxocode.length && f.taxocode.options[i].value!=f1.taxocode.value;i++);//select the appropriate option		
		if(i<f.taxocode.length){
			f.taxocode.options[0].selected=false
			f.taxocode.options[i].selected=true	
		}
		else
			f.taxocode.options[0].selected=true	
	}		
}

function SubmitForm(f){
	SearchValue(document.frm_submit,document.frm_search)
	if (f.specialists.checked==false && f.org.checked==false && f.trd.checked==false){
		alert("Select the Database to Search")
		return false
	}	
	if(f.keyword.value=="" && f.geogcode.options[f.geogcode.selectedIndex].value=="None" && f.subjcode.options[f.subjcode.selectedIndex].value=="None" && f.taxocode.options[f.taxocode.selectedIndex].value=="None" ){	
		alert("Please Enter Search Parameters")
		return false
	}	
	return true
}
function clearsubcombo(f){
	deleteItem(f.subjcode)
	deleteItem(f.geogcode)
	deleteItem(f.taxocode)
}

