
	var rowCount = 0
	
/************************************************************/
	
	function bodyOnLoad() {
		buildYearSelect()
		for (x = 0; x < rowCount; x++) {
			s = "myId" + x
			elem = document.getElementById(s)
			elem.innerHTML = getRidOfJunkCharacters(elem.innerHTML)
		}
	}
	
/************************************************************/
	
	function getRidOfJunkCharacters(s) {
		s2 = "";
		for (y = 0; y < s.length;y++) {
			if (s.charAt(y) < " " || s.charAt(y) > '~'){
				var x = s.charCodeAt(y);
				if (x == 25 || s == "'") {
					s2 += "&#39;"
				}
				else if (x == '"') {
					s2 += "&quot";
				}
				else if (x == 230) {
					s2 += "&deg;"
				}
				else if ((x == 20) || (x == 19)) {
					/* hyphen */
					s2 +=  "&#45;"
				}
				else{
					s2 += s.charAt(y);
				}
			}
			else
				s2 += s.charAt(y);
		}
		return s2;
	}
	
/************************************************************/

	function buildYearSelect() {
		/*
		Find out what year it is and work back to 1999.
		*/
		d = new Date()
		year = d.getFullYear()
		count = 2
		y_e = document.getElementById("ArchYear")
		opts = y_e.options
		for (x = year; x > 1995; x = x - 1) {
			y_e.length = y_e.length + 1
			o = new Option(x, x)
			opts[count] = o
			count = count + 1
		}
		y_e.selectedIndex = 0;
	}
	
/************************************************************/

    function goClick() {
		var title = ''
		var sql = ''
		var fflag = false;
		var o = document.getElementById('countryIs').options;

		for (var x = 2; x < o.length; x++ ){
			if (o[x].selected) {
				title = o[x].text
				sql = " cntryid like " + o[x].value + " "
				fflag = true; 
				break;
				}
			}
			
		o = document.getElementById('cropIs').options;
		for (var x = 2; x < o.length; x++ ){
			if (o[x].selected) {
				if (fflag) {
					sql += "and ";
					title += " and ";
					}
				title += o[x].text + " "
				sql += " cropid like " + o[x].value + " "
				fflag = true;
				break;
				}
			}

		title += " In The News "
		o = document.getElementById('ArchYear').options;
		for (var x = 2; x < o.length; x++ ){
			if (o[x].selected) {
				if (fflag) sql += "and ";
           		title += o[x].text
           		sql += " pub_date >= '" + o[x].value + "/01/01' and pub_date <= '" + o[x].value + "/12/31' "
           		fflag = true;
           		break;
        		}
      		}
	
		var countrySel = (document.getElementById('countryIs').selectedIndex > 1);
		var cropSel = (document.getElementById('cropIs').selectedIndex > 1);
		var yearSel = (document.getElementById('ArchYear').selectedIndex > 1);

		if (!countrySel && !cropSel && !yearSel) {
			alert('Please make a selection from the Country, Crop, or Year menus. You may select from multiple menus, if you wish.');
			return false;
			}
	
		if (document.getElementById('articles').checked) {
			sql = "select pub_date, url_link, title from pecad_topstories where " +
			sql + " order by pub_date desc"
			}
		else if (document.getElementById('briefs').checked) {
			sql = "select * from pecad_prodbriefs where " +
			sql + " order by pub_date desc"
			}
		else if (document.getElementById('both').checked) {
			temp = sql
			sql = 'select pub_date, url_link, title from pecad_topstories where ' + temp +
			'  union ' +
			"select pub_date, url_link, title from pecad_prodbriefs where " +
			temp + " order by pub_date desc"
			}
			
	document.getElementById('sqlString').value = sql;
	document.getElementById('titleString').value = title;
	document.getElementById('thisform').submit();
    }
	
/************************************************************/

