$(document).ready(function(){
	if( $("#category_id") ){
		$("#category_id").change(function(){
			var url = location.pathname;
			if (location.hostname == 'devsys2.gaslightmedia.com') {
				var base_url = 'http://devsys2.gaslightmedia.com/www.harborspringschamber.com';
			}else if (location.hostname == '66.129.44.5') {
				var base_url = 'http://66.129.44.5';
			}else{
				var base_url = 'http://www.harborspringschamber.com';
			}
			$.ajax({
				url: base_url + "/libjs/member-search-category-sub.php",
				data: "parent_id=" + $("#category_id").val(),
				cache: false,
				success: function(html){
					if(html != ''){
						if( $("#sub_category").length ){
							$("#sub-break").remove()
							var myHtml = '<br id="sub-break">' + html;
							$("label[for=sub_category]").remove()
							$("#sub_category").replaceWith( myHtml )
						}else if( $("#bus-type-li").length ){
							$("#bus-type-li").hide('slow');
							var myHtml = '<li id="bus-type-sub-li">' + html + '</li>';
							$("#bus-type-li").html( myHtml);
							$("#bus-type-li").show('slow');
						}else{
							//var myHTML = $("#category_id").html();
							//$("#category_id").html( myHTML + '<br id="sub-break">' + html );
							$("#category_id").after( '<br id="sub-break">' + html );
						}
					}
				}	
			});
	});
	}
});
