/* * This function is used by the publicationsnew AO. * It's used to pre-populate the publication sub-type drop-down box in the search form. * Author: Remy Sharp, modified by Chris Kobrzak (Pixl8) */$(function(){	var publication_type = $("select#select-documenttype");	publication_type.change(function() { 		if($(this).val()) {		  	$(".ajax-indicator").remove();		  	$("select#select-documentsubtype").html('');		  	$(this).attr("disabled", "disabled").after('<img src="/graphics/indicator.gif" class="ajax-indicator"/>');			$.getJSON(		    	"/aoc/ajax/get_document-sub-type.cfm",		    	{		    		id: $(this).val(),		    		ajax: 'true'		    	},		    	function(jResult) {		  		  publication_type.removeAttr("disabled").next().remove();		  		  var longest = 0;			      var aOption = '<option value="">Narrow publication type to a sub-type</option>';			      for (var i = 0; i < jResult.length; i++) {			        aOption += '<option value="' + jResult[i].sKey + '"';			      	if(jResult[i].sKey == $("#hidden-selected-subcategory").val()) {			      		 aOption += ' selected="selected"';			      	}	        			        aOption += '">' + jResult[i].sVal + '</option>';			        // Fix ie6 dropdown width					if(jResult[i].sVal.length > longest) {						longest = jResult[i].sVal.length;					}			      }				  if(longest < 38) {					longest = 38;				  }			      			      $("select#select-documentsubtype").html(aOption).width(longest*6);			})		} else {			$("select#select-documentsubtype").html('');		}	});	/* Select sub-category */  	if(typeof(publication_type.val()) != 'undefined' && publication_type.val() != '') {		publication_type.trigger('change');	}});
