// Survey layer

// isIE=document.all;
// isNN=!document.all&&document.getElementById;
// isN4=document.layers;
// isHot=false;
// 
// function ddInit(e){
//   topDog=isIE ? "BODY" : "HTML";
//   whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
//   hotDog=isIE ? event.srcElement : e.target;  
//   while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
//     hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
//   }  
//   if (hotDog.id=="titleBar"){
//     offsetx=isIE ? event.clientX : e.clientX;
//     offsety=isIE ? event.clientY : e.clientY;
//     nowX=parseInt(whichDog.style.left);
//     nowY=parseInt(whichDog.style.top);
//     ddEnabled=true;
//     document.onmousemove=dd;
//   }
// }

// function dd(e){
//   if (!ddEnabled) return;
//   whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
//   whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
//   return false;  
// }
// 
// function ddN4(whatDog){
//   if (!isN4) return;
//   N4=eval(whatDog);
//   N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
//   N4.onmousedown=function(e){
//     N4.captureEvents(Event.MOUSEMOVE);
//     N4x=e.x;
//     N4y=e.y;
//   }
//   N4.onmousemove=function(e){
//     if (isHot){
//       N4.moveBy(e.x-N4x,e.y-N4y);
//       return false;
//     }
//   }
//   N4.onmouseup=function(){
//     N4.releaseEvents(Event.MOUSEMOVE);
//   }
// }

// function hideMe(){
//   if (isIE||isNN) whichDog.style.visibility="hidden";
//   else if (isN4) document.theLayer.visibility="hide";
// }
// 
// function showMe(){
//   if (isIE||isNN) whichDog.style.visibility="visible";
//   else if (isN4) document.theLayer.visibility="show";
// }
// 
// document.onmousedown=ddInit;
// document.onmouseup=Function("ddEnabled=false");

function sameBilling(form)
{
if (form.billing_same.checked) {
  form["billing.first_name"].value = "$account.address.first_name";
  form["billing.last_name"].value = "$account.address.last_name";
  form["billing.company"].value = "$account.address.company";
  form["billing.address1"].value = "$account.address.address1";
  form["billing.address2"].value = "$account.address.address2";
  form["billing.city"].value = "$account.address.city";
  mySelectBox = form["billing.state"];
  for(i=0;i<mySelectBox.length;i++) {
  if (mySelectBox.options[i].text == "$account.address.state") {
  mySelectBox.options[i].selected = true; }
  }
  form["billing.zip"].value = "$account.address.zip";
  mySelectBox2 = form["billing.country"];
  for(n=0;n<mySelectBox2.length;n++) {
  if (mySelectBox2.options[n].text == "$account.address.country") {
  mySelectBox2.options[n].selected = true; }
  }
  form["billing.phone"].value = "$account.address.phone";
  form["billing.fax"].value = "$account.address.fax";
  form["billing.email"].value = "$account.email";
}
else
{
  form["billing.first_name"].value = "";
  form["billing.last_name"].value = "";
  form["billing.address1"].value = "";
  form["billing.address2"].value = "";
  form["billing.city"].value = "";
  form["billing.state"].options[0].selected = true;
  form["billing.zip"].value = "";
  form["billing.country"].options[0].selected = true;
  form["billing.phone"].value = "";
  form["billing.fax"].value = "";
  form["billing.email"].value = "";
}
}

function searchbox_Validator(theForm)
{
if (theForm.search_term.value.length < 2)
   {
   alert("Please enter a search query OR select the blue 'directory' tab to browse sites by subject.");
   theForm.search_term.focus();
   return (false);
   }
}

function cheminfosearch_Validator(theForm)
{
//if (theForm.t.value.length < 2)
//   {
//   alert("Please enter a chemical search query.");
//   theForm.t.focus();
//   return (false);
//   }
}

function pop(url) {window.open(url,"cta",'scrollbars,resizable,width=365,height=335');}


function option_selector( which ) {

 if( ! which ) { which = 'theForm' }
 var theForm = document[ which ];

 for(var i = 0; i< theForm.elements.length; i++) {
     if(theForm.elements[i].type.indexOf('select') > -1) {
        for( var j=0; j< theForm.elements[i].length; j++ ) {
           if( theForm.elements[i].options[j].value == theForm.elements[i].id ) {
               theForm.elements[i].options[j].selected = true;
           }
        }
     }
     if(theForm.elements[i].type.indexOf('checkbox') > -1 ) {
          if( theForm.elements[i].id == 'on' ) {
              theForm.elements[i].checked = true;
          }
     }
 }
}


function data_table_submit( sorter ) {

        document.theForm.sorter.value = sorter;
        document.theForm.submit();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}





function showHide(id, on, on_flag) {
		var more=document.getElementById(id);
		more.style.display=(on ? "inline" : "none");
				
		var qsLinkBox=document.getElementById("qsLinkBox");
		var hideQsBox = document.getElementById("hideQsBox");
		var form=document.getElementById("FindIn");		
		var query = document.nextSearch.query.value;
//		var heh = document.nextSearch.sector_flag_poly.value;
                menugroup = id;

				
		if (on) {
			
			qsLinkBox.style.display="none";
			hideQsBox.style.display="";
			agent99.style.display="none";
			if (on_flag=="bio_flag") {
            document.nextSearch.sector_flag_bio.value = "on";
            document.nextSearch.info_sector_flag_bio.value = "on";
            }
			if (on_flag=="poly_flag") {
            document.nextSearch.sector_flag_poly.value = "on";
            document.nextSearch.info_sector_flag_poly.value = "on";
            }
			if (on_flag=="petro_flag") {
            document.nextSearch.sector_flag_petro.value = "on";
            document.nextSearch.info_sector_flag_petro.value = "on";
            }
			if (on_flag=="agro_flag") {
            document.nextSearch.sector_flag_agro.value = "on";
            document.nextSearch.info_sector_flag_agro.value = "on";
            }
			if (on_flag=="metals_flag") {
            document.nextSearch.sector_flag_metals.value = "on";
            document.nextSearch.info_sector_flag_metals.value = "on";
            }
			if (on_flag=="supplies_flag") {
            document.nextSearch.sector_flag_supplies.value = "on";
            document.nextSearch.info_sector_flag_supplies.value = "on";
            }
			if (on_flag=="enviro_flag") {
            document.nextSearch.sector_flag_enviro.value = "on";
            document.nextSearch.info_sector_flag_enviro.value = "on";
            }
			if (on_flag=="cheminfo_flag") {
            document.nextSearch.sector_flag_cheminfo.value = "on";
            document.nextSearch.info_sector_flag_cheminfo.value = "on";
            }
			if (on_flag=="adv_flag") {
            document.nextSearch.sector_flag_adv.value = "on";
            document.nextSearch.info_sector_flag_adv.value = "on";
            }

//			document.nextSearch.sector_flag_bio.value = "on";
//			document.nextSearch.sector_flag_poly.value = "on";
//			document.nextSearch.country_id.selectedindex = 0;
			
		} else {
			
			qsLinkBox.style.display="";
			hideQsBox.style.display="none";
			agent99.style.display="";
			form.reset();
			document.nextSearch.query.value = query;
//			document.nextSearch.country_id.selectedindex = 0;

		}
		
		var searchBoxInnerDiv = document.getElementById("searchBoxInnerDiv");
		searchBoxInnerDiv.style.borderTop = (on ? "solid black 1px;" : "none");
		searchBoxInnerDiv.style.borderLeft = (on ? "solid black 1px;" : "none");
		searchBoxInnerDiv.style.borderRight = (on ? "solid black 1px;" : "none");
		//moreOptions.style.backgroundColor = (on ? "#FFFFFF;" : "#FFFFFF;");
		//moreContent.style.backgroundColor = (on ? "#FFFFFF;" : "#FFFFFF;");
		//searchBoxInnerDiv.className = (on ? "lightBlueBg" : "BannerArea");
		
		//var searchPromptBox = document.getElementById("searchPrompt");
		//searchPromptBox.innerHTML = (on ? "Search:&nbsp;&nbsp;" : searchPromptText);

}

// NEW SEARCH BOX V3 SHOW/HIDE 
function showHideOptions(on) {
	
	var moreOptions = document.getElementById("moreOptions");
	var advancedSearch = document.getElementById("advancedSearch");
	var hideQsBox = document.getElementById("hideQsBox");
	
	moreOptions.style.display = (moreOptions.style.display == "none") ? "" : "none";
	advancedSearch.style.display = (advancedSearch.style.display == "none") ? "" : "none";
	hideQsBox.style.display = (hideQsBox.style.display == "none") ? "" : "none";
	
	if (on) { 
		var curQuery = document.nextSearch.query.value;	// save & restore the current query before the "reset" below
		document.getElementById("FindIn").reset();
		document.nextSearch.query.value = curQuery;
		
	}

	var searchBoxInnerDiv = document.getElementById("searchBoxInnerDiv");
	searchBoxInnerDiv.style.borderTop = (on ? "solid black 1px" : "none");
	searchBoxInnerDiv.style.borderLeft = (on ? "solid black 1px" : "none");
	searchBoxInnerDiv.style.borderRight = (on ? "solid black 1px" : "none"); 
}

function closeAll() {
  showHide(menugroup, false);
//  showHide('moreBiotechOptions', false);
//  showHide('morePolymersOptions', false);
//  showHide('morePetrochemOptions', false);
//  showHide('moreAgroOptions', false);
//  showHide('moreMetalsOptions', false);
//  showHide('moreSuppliesOptions', false);
//  showHide('moreOptions', false);
//  showHide('moreEnviroOptions', false);
//  showHide('moreCheminfoOptions', false);
}

//function closeNshow() {
//  showHide('moreBiotechOptions', false);
//  showHide('morePolymersOptions', false);
//  showHide('morePetrochemOptions', false);
//  showHide('moreMetalsOptions', false);
//  showHide('moreSuppliesOptions', false);
//  showHide('moreEnviroOptions', false);
//  showHide('moreAgroOptions', false);
//  showHide('moreCheminfoOptions', false);
//  showHide('moreOptions', true);
//}

function changeText(d,txt) {
if (d.innerText) {
 d.innerText = txt;
}
else if (d.textContent) {
  d.textContent = txt;
}
else
{
// do nothing
}
}

function CodeData() {

    CountryCodes = {
      "Albania":"099", "Algeria":"051", "Antarctica":"039",
      "Arab Emirates":"048", "Argentina":"042", "Australia":"014",
      "Austria":"025", "Azerbaijan":"097", "Bahrain":"062",
      "Bangladesh":"074", "Belarus":"080", "Belgium":"016",
      "Bosnia-Herzegovina":"106", "Brazil":"032", "Bulgaria":"072",
      "Canada":"063", "Chile":"060", "China":"005", "Colombia":"011",
      "Costa Rica":"085", "Croatia":"068", "Cuba":"095", "Cyprus":"075",
      "Czech":"037", "Denmark":"013", "Dubai":"093", "Egypt":"052",
      "Estonia":"067", "Ethiopia":"102", "Finland":"031", "France":"015",
      "Germany":"020", "Greece":"046", "Guam":"098", "Guatemala":"103",
      "Hong Kong":"041", "Hungary":"044", "Iceland":"092", "India":"010",
      "Indonesia":"035", "Iran":"059", "Ireland":"024", "Israel":"006",
      "Italy":"026", "Jamaica":"083", "Japan":"017", "Jordan":"058",
      "Kenya":"079", "Korea":"084", "Kuwait":"054", "Latvia":"081",
      "Lebanon":"055", "Liberia":"101", "Lithuania":"043", "Luxembourg":"033",
      "Macedonia":"086", "Malaysia":"008", "Malta":"066", "Mexico":"047",
      "Moldova":"082", "Morocco":"087", "Nepal":"088", "Netherlands":"036",
      "New Zealand":"040", "Nicaragua":"100", "Niger":"071", "Nigeria":"104",
      "Norway":"038", "Pakistan":"007", "Peru":"050", "Philippines":"069",
      "Poland":"019", "Portugal":"028", "Puerto Rico":"090", "Qatar":"091",
      "Romania":"012", "Russia":"029", "Saudi Arabia":"049", "Scotland":"078",
      "Singapore":"023", "Slovak Rep.":"034", "Slovenia":"045",
      "South Africa":"022", "South Korea":"009", "Spain":"027",
      "Sri Lanka":"089", "Sweden":"000", "Switzerland":"018", "Syria":"070",
      "Taiwan":"004", "Tasmania":"077", "Thailand":"057", "Trinidad":"094",
      "Turkey":"021", "Ukraine":"030", "United Arab Emirates":"107",
      "United Kingdom":"002", "United States":"061", "Unspecified":"076",
      "Uruguay":"056", "Venezuela":"053", "Yugoslavia":"065", "Zambia":"073"
    };

    SourceCodes = {
      "Manufacturer":"01", "Distributor":"04", "Service":"02", "Org./Gov./Agency":"05",
      "Academia":"03", "Personal site":"06"
    };

    CodedCategories = {
      "1":"Portals, Forums, wiki",
      "5":"Chemical e-marketplaces", "8":"Equipment e-marketplaces",
      "11":"All industry sectors", "12":"Major chemical suppliers",
      "13":"Advanced materials",
      "16":"Agrochemicals & fertilizers", "19":"Adhesives & sealants",
      "22":"Animal health & feed",
      "27":"Biochemicals & biotech products old", "28":"Carbon products",
      "29":"Catalysts", "30":"Ceramics", "32":"Cosmetics & personal care",
      "36":"Electronic chemicals, fuel cells", "37":"Explosives",
      "42":"Fibers & textile auxiliaries", "43":"Fine & specialty chemicals",
      "45":"Fragrances & aroma", "46":"Carbohydrates, saccharides",
      "47":"Gases", "48":"Inorganic chemicals", "50":"Lubricants & oils",
      "52":"Oil & gas, energy", "53":"Oilfield chemicals",
      "54":"Organic chemicals", "56":"Paper & pulp chemicals",
      "59":"Pharmaceuticals & biotherapeutics", "61":"Photographic chemicals",
      "62":"Plastic & rubber additives", "63":"Plastic processors",
      "64":"Polymers & compounds", "65":"Solvents",
      "66":"Surfactants & formulated products", "67":"Rubbers & elastomers",
      "77":"Services", "78":"Resources", "80":"Industrial equipment",
      "83":"Organizations, gov. agencies",
      "86":"Conferences, trade shows",
      "87":"Databases", "88":"Patents",
      "89":"Contract R&D, tech. transfer", "98":"Consultants & experts",
      "106":"Analytical labs, testing",
      "107":"Training services, e-learning",
      "109":"Shipping & transportation",
      "110":"Storage & inventory management services", "117":"Used equipment",
      "118":"Equipment distributors", "119":"Process equipment & machinery old",
      "120":"Instrumentation & control", "122":"Chromatography",
      "125":"Other Chemical resources", "129":"News, reports",
      "133":"Journals", "1046":"BioFuels",
      "138":"Calculators, tools, tutorials",
      "154":"Custom manufacturing / synthesis",
      "170":"Simulation & optimization",
      "207":"Compressors, gas, vacuum equip.",
      "209":"Drying & dewatering equipment",
      "211":"Material handling",
      "212":"Waste treatment, recycling equip.",
      "214":"Piping elements, samplers", "221":"Agitators, homogenizers",
      "222":"Pumps", "224":"Feeding, weighing, solid metering",
      "225":"Halogens chemistry",
      "226":"Tanks, containers, reactors", "269":"Filters",
      "274":"Distillation & stripping equipment",
      "275":"Separation media, packing",
      "280":"Water purification, desalination",
      "308":"Pressure measurement & control", "309":"Sampling instruments",
      "315":"Temperature measurement & control",
      "316":"Recorders, monitors, displays",
      "421":"Processing, packaging",
      "429":"Pharma & biotech equipment",
      "437":"Job banks, career & HR services", "439":"Electrical equipment",
      "446":"Safety equipment & accessories", "452":"Metal compounds",
      "461":"Maintenance & shop services", "462":"Glass",
      "463":"Halogens chemistry", "482":"Packaging  equipment & auxiliaries",
      "483":"Primary machinery", "484":"Silos, hoppers, bins",
      "486":"Weight measurement & control", "487":"Lab process equipment",
      "1051":"Packaging & filling equipment, materials",
      "489":"Glass & anti-corrosion equipment", "490":"HVAC & clean rooms",
      "491":"Boilers",
      "492":"Chemical distribution",
      "493":"Coatings & surface treatment",
      "495":"Pharma intermediates, bulk drugs",
      "496":"Other software products & services",
      "514":"Size reduction equipment", "515":"Leather chemicals",
      "516":"Filling, dosing & liquid feeding", "517":"Pilot scale equipment",
      "522":"Communication & homeland security",
      "523":"Plating & coating equipment", "527":"Software",
      "530":"Metals - precious & high purity",
      "531":"Extracts & nutraceuticals", "533":"Petrochemicals",
      "534":"Exploration", "535":"Diagnostics", "540":"Cooling towers",
      "541":"Heat exchangers", "542":"Heat transfer materials",
      "544":"Centrifuges", "546":"Evaporators & crystallizers",
      "547":"Absorbents, ion exchange", "552":"Phosphorus chemistry",
      "553":"Sulphur chemistry", "554":"Pneumatic equipment",
      "556":"Process control software",
      "1049":"Heat transfer",
      "557":"LIMS",
      "1050":"Separation & drying",
      "558":"Design & CAD software", "559":"MSDS, safety, compliance",
      "560":"ERP, supply chain, Web software",
      "562":"Maintenance & testing software", "568":"Monomers",
      "570":"Silicone chemistry", "571":"Construction & installation services",
      "574":"Liquid liquid separation, columns",
      "576":"Magnetic separation, metal detectors",
      "577":"Air pollution equipment, scrubbers", "578":"Classifiers, sifters",
      "579":"Misc. separation equipment",
      "582":"Vibration equipment & accessories",
      "583":"Blenders, solid mixers",
      "589":"Cleaning & demolition",
      "590":"Documentation, publishing", "591":"Waxes & paraffins",
      "595":"Pipes, tubes, ducts - metal",
      "596":"Pipes, tubes, ducts - non metal", "597":"Valves, gates, diverters",
      "599":"Packaging materials", "600":"Operating & scale up",
      "601":"Lasers & optical equipment", "603":"Hydraulic equipment",
      "608":"Enviro., safety, compliance",
      "611":"Academic & research institutes",
      "617":"Engineering & construction",
      "620":"Modeling, imaging, drawing",
      "630":"Seals, gaskets & bearings", "631":"Custom parts, OEM",
      "633":"Contract plastics manufacturing", "634":"Nitrogen chemistry",
      "639":"Data acquisition, I/O devices",
      "640":"Control & automation systems",
      "644":"Analyzers, sensors, detectors", "646":"Dyes, pigments, inks",
      "652":"Dyes intermediates", "661":"Books & reference works",
      "663":"Research & lab chemicals",
      "673":"Plastics industry equipment",
      "674":"Ancillary machinery",
      "675":"Used equipment",
      "677":"Lab equipment", "678":"Molds and dies",
      "687":"Business, finance services",
      "691":"Water & waste treatment",
      "692":"Construction, composites",
      "693":"Construction materials",
      "695":"Gears, power transmission, belts", "696":"Generators, turbines",
      "697":"Control valves, actuators, regulators",
      "699":"Relief valves, rupture discs",
      "701":"Combustion & heating systems",
      "702":"Ovens, autoclaves",
      "703":"Chillers & cooling systems",
      "704":"Heating - electric, solar",
      "706":"Heavy equip., drilling",
      "708":"Flow measurement & control", "709":"Level measurement & control",
      "711":"Vibration, machinery monitoring", "712":"Other instruments",
      "714":"Automotive, shop products", "716":"Pesticides",
      "719":"Metals & minerals, mining", "720":"Calibration & test equipment",
      "731":"Food ingredients & additives",
      "732":"e-marketplaces & distributors",
      "738":"All lab supplies categories",
      "739":"Lab automation, synthesis",
      "740":"Elemental analysis", "741":"Lab consumables, tools",
      "1053":"Piping & safety supplies", "742":"Lab glassware",
      "1052":"Machinery", "743":"Lab construction, furniture",
      "745":"Microscopy and imaging", "746":"Particle analysis",
      "747":"Physical measuring & testing", "749":"Spectroscopy",
      "750":"Detergents & cleaning products", "754":"Conveyors",
      "755":"Batteries, power supplies", "756":"Calibration & measuring equip.",
      "758":"Lighting, plugs & misc.", "759":"Micro electronics / boards",
      "760":"Motors", "761":"Substation & MCC equipment",
      "762":"Transformers & switchgear", "763":"Wires & cables",
      "765":"Best Web site contest", "766":"On-line courses & tools",
      "767":"Portals & information hubs",
      "768":"Chemistry & engineering schools", "769":"Corporate sites",
      "770":"Bioinformatics, drug discovery",
      "1009":"Marketing & communication",
      "1010":"All Pharma & biotech categories",
      "1011":"Other biotechnology resources", "1012":"Clinical data management",
      "1013":"Healthcare providers, medical services",
      "1014":"Clinical laboratories & services",
      "1015":"Antibodies & immunochemicals",
      "1016":"All polymers & plastics",
      "1048":"All petro, oil & gas categories",
      "1017":"Proteins, peptides, amino acids",
      "1018":"Drug delivery & formulation",
      "1019":"Implants & orthopedic products",
      "1020":"Cell lines, tissue engineering",
      "1021":"Dental products", "1022":"Bioreagents & biomaterials",
      "1023":"Agrobiotechnology", "1024":"Industrial & technology parks",
      "1025":"Lipids", "1026":"Clinical research services",
      "1027":"Cleaning equipment, accessories",
      "1028":"Bio-analysis", "1054":"Mat. handling, processing",
      "1029":"Libraries, building blocks", "1030":"Genomics",
      "1031":"Oleochemicals, indust. lipids", "1032":"Environmental biotech",
      "1034":"Intellectual property, law firms",
      "1035":"Medical devices & supplies", "1040":"Blood products",
      "1042":"Medical & pharmaceutical resources"
    };

    SectorData = {
        "adv": {
              "11": {"1010":[ "1023", "22", "1015", "1022", "1040", "46",
                     "1020", "1014", "1026", "1021", "535", "1018", "1032",
                     "531", "1030", "1019", "1029", "1025", "1035", "59",
                     "495", "1017"], "1016":[ "62", "63", "64", "67"],
                     "1048":[ "1046", "50", "52", "53", "533", "591"], "5":[],
                     "492":[], "154":[], "12":[], "547":[], "19":[], "13":[],
                     "16":[], "714":[], "28":[], "29":[], "30":[], "493":[],
                     "692":[], "32":[], "750":[], "646":[], "652":[], "36":[],
                     "37":[], "42":[], "43":[], "45":[], "731":[], "47":[],
                     "462":[], "463":[], "48":[], "515":[], "719":[], "568":[],
                     "634":[], "1031":[], "54":[], "56":[], "716":[], "552":[],
                     "61":[], "570":[], "65":[], "553":[], "66":[], "691":[]},
              "80": {"693":[], "706":[], "631":[],
                     "439":[ "755", "756", "758", "759", "760", "761", "762",
                         "763"], "118":[], "8":[], "489":[],
                     "1049":[ "491", "703", "701", "540", "541", "542", "704",
                     "702"], "490":[], "120":[ "644", "720", "522", "640",
                         "697", "639", "708", "601", "709", "308", "316",
                         "309", "315", "711", "486", "712"],
                     "1052":[ "695", "696", "603"], "1054":[ "221", "583",
                         "1027", "207", "754", "211", "523", "554", "222",
                         "484", "514", "226", "597"],
                     "1051":[ "224", "516", "482", "599"], "429":[], "517":[],
                     "1053":[ "214", "595", "596", "699", "446", "630", "582"],
                     "673":[ "483", "674", "675", "677", "678"],
                     "1050":[ "577", "544", "578", "274", "209", "546", "269",
                              "574", "576", "275", "280", "579"], "117":[],
                     "212":[]},
               "738": {"1028":[], "122":[], "740":[], "739":[], "741":[],
                       "743":[], "742":[], "747":[], "487":[], "732":[],
                       "745":[], "746":[], "663":[], "749":[]},
               "527": {"770":[], "1012":[], "558":[], "560":[], "557":[],
                       "562":[], "620":[], "559":[], "556":[], "170":[],
                       "496":[]},
               "77": {"106":[], "687":[], "589":[], "98":[], "89":[], "590":[],
                      "617":[], "608":[], "1024":[], "1034":[], "437":[],
                      "461":[], "1009":[], "421":[], "109":[], "110":[],
                      "107":[]},
               "78": {"611":[], "661":[], "138":[], "87":[], "86":[], "133":[],
                      "129":[], "83":[], "88":[], "1":[], "125":[]}
        },
        "agro": {
               "11":{ "1023":[], "22":[], "16":[], "1046":[],
                      "531":[], "45":[], "731":[], "1031":[], "716":[]},
               "80":{ "1049":[], "1054":[], "1050":[]}, "738":{}, "split":{},
               "527":{}, "77":{ "106":[], "89":[], "617":[], "608":[]},
               "78":{ "87":[], "86":[], "133":[], "129":[]}
        },
        "bio":  {
               "1010":{ "1023":[], "22":[], "1015":[], "1022":[], "1040":[],
                        "46":[], "1020":[], "1024":[], "1026":[], "1021":[],
                        "535":[], "1018":[], "1032":[], "531":[], "1030":[],
                        "1019":[], "1029":[], "1025":[], "1035":[], "59":[],
                        "495":[], "1017":[]},
               "11":{ "492":[], "154":[], "32":[], "45":[]},
               "split":{}, "80":{"429":[], "117":[]},
               "738":{ "1028":[], "663":[]}, "527":{ "770":[], "1012":[]},
               "77":{ "106":[], "687":[], "617":[], "608":[],
                      "1024":[], "1034":[]},
               "78":{ "87":[], "86":[], "133":[], "129":[]}
        },
        "cheminfo": {
               "78":{ "611":[], "661":[], "138":[], "87":[], "86":[], "133":[],
                      "129":[], "83":[], "88":[], "1":[], "125":[]}, "split":{},
               "527":{ "770":[], "1012":[], "557":[], "620":[], "559":[]},
               "77":{ "98":[], "590":[], "608":[], "1034":[],
                      "1009":[], "107":[]}
        },
        "enviro": {
               "11":{ "714":[], "1046":[], "750":[], "1032":[], "691":[]},
               "80":{ "1049":[ "701", "704"], "490":[],
               "1050":[ "280", "212"]}, "738":{ "743":[]}, "split":{},
               "527":{ "559":[]}, "77":{ "106":[], "589":[], "98":[], "617":[],
                                         "608":[], "421":[], "109":[]},
               "78":{ "87":[], "86":[], "133":[], "129":[]}
        },
        "metals": {
               "11":{ "492":[], "547":[], "13":[], "28":[], "29":[], "30":[],
                      "692":[], "462":[], "48":[], "719":[], "552":[], "570":[],
                      "553":[]},
               "80":{ "693":[], "706":[], "631":[],
                      "1049":[ "491", "701", "702"], "split":{},
               "1052":[ "696"], "1054":[ "583", "754", "211", "484", "514"],
               "1053":[], "1050":[ "578", "209"]}, "738":{}, "527":{},
               "77":{ "106":[], "98":[], "617":[], "608":[], "421":[]},
               "78":{}
        },
        "petro": {
               "1048":{ "1046":[], "50":[], "52":[], "53":[],
                        "533":[], "591":[]},
               "11":{ "492":[], "5":[], "54":[], "65":[]},
               "80":{ "706":[], "1049":[], "1054":[], "1050":[], "117":[]},
               "split":{}, "738":{}, "527":{ "559":[], "556":[], "170":[]},
               "77":{ "106":[], "617":[], "608":[], "421":[]},
               "78":{ "87":[], "86":[], "133":[], "129":[]}
        },
        "poly": {
               "1016":{ "62":[], "63":[], "64":[], "67":[], "19":[],
                        "492":[], "5":[], "493":[], "692":[], "43":[],
                        "225":[], "568":[], "54":[], "570":[]},
               "80":{ "631":[], "117":[], "673":[ "483", "674", "675", "677", "678"]},
               "split":{}, "738":{}, "527":{},
               "77":{ "106":[], "617":[], "608":[], "421":[]},
               "78":{ "87":[], "86":[], "133":[], "129":[]}
        },
        "supplies": {
               "738":{ "1028":[], "122":[], "740":[], "739":[],
                       "741":[], "743":[], "742":[], "747":[],
                       "487":[], "732":[], "745":[], "746":[],
                       "663":[], "749":[]}, "11":{"13":[], "43":[]},
               "1010":{ "1015":[], "1022":[], "1030":[], "1029":[],
                        "1025":[], "1017":[]}, "split":{},
               "80":{ "120":[]}, "527":{ "557":[]},
               "77":{ "106":[], "89":[], "617":[], "608":[],
                      "1024":[], "1034":[]},
               "78":{ "87":[], "86":[], "133":[], "129":[]}
        }
    };

    return {
        "CountryCodes":CountryCodes,
        "SourceCodes":SourceCodes,
        "CodedCategories":CodedCategories,
        "SectorData":SectorData
    };
}

function MakeMenus( sector_ids ) {

  for (group in sector_ids) {

    sector = sector_ids[group];

    document.writeln ( '<div bgcolor="#FFFFFF" id="more'+group+'Options" ' +
         'style="position:absolute;display:none;margin-left:0px;' +
         'margin-right:0px;margin-top:-9px;width:470px;z-index:98;' +
         'overflow:hidden;background-color:white;">');
    document.writeln ( '<div id="moreContent" style="padding-bottom:12px;' +
         'padding-left:5px;padding-top:5px;padding-right:5px;text-align:' +
         'left;border-left:1px solid black;border-right:1px solid black;' +
         'border-bottom:1px solid black;background-color:white;"' +
         'border-top:1px solid black;background-color:white;"' +
         'class="blueGrayBg">');
    document.writeln ( '<table border=0 width="80%" cellspacing=0 cellpadding' +
         '=0><tr><td><font ID="special" color="#000099"><b>Limit search to: ' +
         '</b>&nbsp; </font></td></tr><tr><td><input name="sector_flag_' + 
         sector + '" id="sector_flag_' + sector + '" type="hidden" value="">' +
         '<select name="'+sector+'_country_id"' +
         ' ID="special" style="width:150px"><option value="">All Countries');

    codes = CodeData();
    CatCodes = codes.CodedCategories;
    for (country in codes.CountryCodes) {
        document.writeln ( '</option><option value="' + 
             codes.CountryCodes[country] + '">' + country);
    }

    document.writeln ( '</option></select> <input name="info_sector_flag_' +
         sector+'" id="info_sector_flag_'+sector+'" type="hidden" value="">' +
         '<select name="'+ sector+'_info_id" ID="special" style=' +
         '"width:150px"><option value="">All Source Types');

    for (source in codes.SourceCodes) {
        document.writeln ( '</option><option value="' + 
             codes.SourceCodes[source] + '">' + source);
    }

    if ( sector != 'adv' ) {
        document.writeln ( '</option></select></td></tr></table><div><img ' +
             'src="/images/green_table/transparent_pixel.gif" width="1" ' +
             'height="5"></div><table border=0 cellspacing=0 cellpadding=0>' +
             '<tr><td colspan="2"><div><img src="/images/green_table/' +
             'transparent_pixel.gif" width="1" height="5"></div><font ID="' +
             'special" color="#000099"><b>Select one option to limit search ' +
             'by topic:</b></font><div><img src="/images/green_table/' +
             'transparent_pixel.gif" width="1" height="5"></div></td></tr>' +
             '<tr><td width="50%" valign="top">');
    
        SectorData = codes.SectorData;
        TopLevel = SectorData[sector];
        for (topcat in TopLevel) {
            if (topcat == "split") {
                document.writeln('</td><td width="50%" valign="top">');
                continue;
            }
            document.writeln ( '<input type="radio" name="category_id" ' +
                 'value="' + topcat + '"><font ID="special"><b>' + 
                 CatCodes[topcat] + '</b>...</font></br>');
            MidLevel = TopLevel[topcat];
            var spaces = '&nbsp;&nbsp';
            for (midcat in MidLevel) {
                if (midcat == "split") {
                    document.write('</td><td width="50%" valign="top">');
                    continue;
                }
                BotLevel = MidLevel[midcat];
    
                if (BotLevel.length > 0) {
                    CatCodes[midcat] = '<b>' + CatCodes[midcat] + '</b>...';
                }
                document.writeln ( spaces + ' <input type="radio" name=' +
                     '"category_id" value="'+midcat+'"><font ID="special">' + 
                     CatCodes[midcat] + '</font></br>');
    
                for (i=0; i < BotLevel.length; ++i) {
                    
                    document.writeln ( spaces + spaces + '<input type="radio"' +
                         'name="category_id" value="' + BotLevel[i] + 
                         '"><font ID="special">' + CatCodes[BotLevel[i]] + 
                         '</font></br>');
                }
            }
        }

        document.writeln ( '</td></tr></td></tr></table></div></div>');

    } else {

        document.writeln ('</option></select></td></tr><tr><td colspan="2">' +
             '<div><img src="/images/green_table/transparent_pixel.gif" ' +
             'height="4" width="1"></div></td></tr><tr><td><div><img src=' +
             '"/images/green_table/transparent_pixel.gif" height="1" width=' +
             '"1"></div><select name="category_id" style="width: 308px;" ' +
             'id="special"><option selected="selected" value="">' +
             'All Categories</option>');

        SectorData = codes.SectorData;
        TopLevel = SectorData[sector];
        for (topcat in TopLevel) {
            document.writeln ( '<option value="' + topcat + '">' + 
                 CatCodes[topcat] + '</option>');
    
            MidLevel = TopLevel[topcat];
            var spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            for (midcat in MidLevel) {
                if (midcat == "split") {
                    document.writeln('</td><td width="50%" valign="top">');
                    continue;
                }
                BotLevel = MidLevel[midcat];
    
                if (BotLevel.length > 0) {
                    CatCodes[midcat] = '<b>' + CatCodes[midcat] + '</b>';
                }
                document.writeln ( '<option value="' + midcat +'">' + spaces +
                     CatCodes[midcat] + '</option>');
                for (i=0; i < BotLevel.length; ++i) {
                    document.writeln ( '<option value="' + BotLevel[i] + '">' +
                         spaces + spaces + CatCodes[BotLevel[i]] + '</option>');
                }
            }
        }

        document.writeln ( '</select></td></tr></table></div></div>');

    }
  }
}

function MakeSelects( ) {

    document.writeln ( '<table border=0 width="498" cellspacing=0 cellpadding=2><tr><td class="style1"><span style="text-align:left;vertical-align:middle;margin-left:18px;"><b>Limit search to:</b></span></td></tr><tr><td><span style="text-align:left;vertical-align:middle;margin-left:18px;"><select name="adv_country_id" style="width:150px"><option value="">All Countries');

    codes = CodeData();
    CatCodes = codes.CodedCategories;
    for (country in codes.CountryCodes) {
        document.writeln ( '</option><option value="' + 
             codes.CountryCodes[country] + '">' + country);
    }

    document.writeln ( '</option></select>&nbsp;<select name="adv_info_id" style="width:150px"><option value="">All Source Types');

    for (source in codes.SourceCodes) {
        document.writeln ( '</option><option value="' + 
             codes.SourceCodes[source] + '">' + source);
    }

        document.writeln ('</option></select></span></td></tr><tr><td><span style="text-align:left;vertical-align:middle;margin-left:18px;"><select name="category_id" style="width: 308px;"><option selected="selected" value="">All Categories</option>');

        SectorData = codes.SectorData;
        TopLevel = SectorData['adv'];
        for (topcat in TopLevel) {
            document.writeln ( '<option value="' + topcat + '">' + 
                 CatCodes[topcat] + '</option>');
    
            MidLevel = TopLevel[topcat];
            var spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            for (midcat in MidLevel) {
                if (midcat == "split") {
                    document.writeln('</td><td width="50%" valign="top">');
                    continue;
                }
                BotLevel = MidLevel[midcat];
    
                if (BotLevel.length > 0) {
                    CatCodes[midcat] = '<b>' + CatCodes[midcat] + '</b>';
                }
                document.writeln ( '<option value="' + midcat +'">' + spaces +
                     CatCodes[midcat] + '</option>');
                for (i=0; i < BotLevel.length; ++i) {
                    document.writeln ( '<option value="' + BotLevel[i] + '">' +
                         spaces + spaces + CatCodes[BotLevel[i]] + '</option>');
                }
            }
        }

        document.writeln ( '</select></td></tr></table>');

}

function ShowHide(groupNumber){
  $("#Short" + groupNumber).animate({"opacity": "toggle","height": "toggle"}, { duration: 300 });
  $("#Long" + groupNumber).animate({"opacity": "toggle","height": "toggle"}, { duration: 300 });
}
