	function Searcher() {
		
		this.searchResultCount = 0,
		
		
		this.valueIds = {
			searchKey 		: 'searchKey',
			searchSection 	: 'searchSection',
			searchTime 		: 'searchTime',
			searchStartTime : 'searchStartTime',
			searchRelation 	: 'searchRelation',
			sortField		: 'sortField',
			currPageNo 		: 'currPageNo',
			itemCount 		: 'itemCount',
			backwardYN       : 'backwardYN',
			searchDataType       : 'searchDataType',
			searchEndTime : 'searchEndTime',
			searchStartTimeValue : 'searchStartTimeValue',
			searchEndTimeValue : 'searchEndTimeValue'
		},
		this.valueObj ={
			searchKey		: $(this.valueIds.searchKey),
			searchSection	: $(this.valueIds.searchSection),
			searchTime		: $(this.valueIds.searchTime),
			searchStartTime	: $(this.valueIds.searchStartTime),
			searchRelation	: $(this.valueIds.searchRelation),
			sortField		: $(this.valueIds.sortField),
			currPageNo		: $(this.valueIds.currPageNo),
			itemCount		: $(this.valueIds.itemCount),
			backwardYN       : $(this.valueIds.backwardYN),
			searchDataType       : $(this.valueIds.searchDataType),
			searchEndTime : $(this.valueIds.searchEndTime),
			searchStartTimeValue	: $(this.valueIds.searchStartTimeValue),
			searchEndTimeValue	: $(this.valueIds.searchEndTimeValue)
		},
		
		this.options = {
			searchURL : '/service/SearchResultNew.action',
			searchType : 'searchonly',
			resultAction : 'setSearchResult',
			noContentAction : 'setNoContent',
			displayQuery	: 'query'
		}
	}
	
	
	Searcher.prototype = {
		
		setOptions : function(options) {
			for(var x in options) {
				this.options[x] = options[x];
				if (typeof this.options[x] != 'function') continue;
			}
		},
		
		setURL : function(url) {
			this.options.searchURL = url;
		},
	
		getParameters : function() {
			var callParms = [];
		
			for (var i in this.valueIds) {
				
				if (typeof this.valueIds[i] != 'function') {
					callParms.push(this.valueIds[i]+"="+this.valueObj[i].value);
				} else continue;
			}

			return callParms;
		},
		
		getAjaxResult : function() 
		{
			var callParms = this.getParameters();
			callParms.push("searchType=searchonly");
			
			var ajaxHelper = new net.ContentLoader( this, this.options.searchURL, "POST", [] );
			ajaxHelper.sendRequest.apply( ajaxHelper, callParms );
			return false;
		
		},
		
		ajaxUpdate : function(request) {
			
			var response = [];
			
			this.getHeader(request);
			this.setResult(request);

		},
		
		getHeader : function(request) {
			
			var text = request.responseText;
			
			var startIndex = text.indexOf("resultCount|")+ 12;
			var endIndex = text.indexOf("|resultCount");
			this. searchResultCount = parseInt(text.substring(startIndex,endIndex),10);
		},
		
		setResult : function(request) {
						
			if (this.searchResultCount > 0) {
				eval(this.options.resultAction+"(this.searchResultCount, request.responseText)");
			} else {
				// eval(this.options.resultAction+"(this.searchResultCount, request.responseText)");
				eval(this.options.noContentAction+"()");
			}
		},
		
		setValue : function(type,value) {
			if(type == "page") {
				this.valueObj.currPageNo.value = value;
			} else if (type == "section") {
				this.valueObj.currPageNo.value = 1;
				this.valueObj.searchSection.value = value;
			} else if (type == "time") {
				this.valueObj.currPageNo.value = 1;
				this.valueObj.searchTime.value = value;
			}  else if (type == "relation") {
				this.valueObj.currPageNo.value = 1;
				this.valueObj.searchRelation.value = value;
			} else if (type == "sort") {
				this.valueObj.currPageNo.value = 1;
				this.valueObj.sortField.value = value;
            } else if (type == "searchKey") {
				this.valueObj.currPageNo.value = 1;
                this.valueObj.searchKey.value = value;
            } else if ( type == "dataType") {
                this.valueObj.currPageNo.value = 1;
                this.valueObj.searchDataType.value = value;
            } else if ( type == "backwardYN") {
                this.valueObj.currPageNo.value = 1;
                this.valueObj.backwardYN.value = value;
            } else if (type == "startTime") {
                this.valueObj.currPageNo.value = 1;
                this.valueObj.searchStartTime.value = value;
            } else if (type == "endTime") {
                this.valueObj.currPageNo.value = 1;
                this.valueObj.searchEndTime.value = value;
			} else if (type == "startTimeValue") {
	            this.valueObj.currPageNo.value = 1;
	            this.valueObj.searchStartTimeValue.value = value;
	        } else if (type == "endTimeValue") {
	            this.valueObj.currPageNo.value = 1;
	            this.valueObj.searchEndTimeValue.value = value;
			}
			//this.getAjaxResult();
		},

		goSectionToday : function(sectionCode) {
			this.formReset();
			$("searchSection").value = sectionCode;
			$("searchForm").submit();
		},
		
		newQuery : function() {
		
			var query	= $(this.options.displayQuery).value;
			logger.append(query + " : " + this.valueObj.searchKey.value);
			this.valueObj.currPageNo.value = 1;
			// this.formReset();
			this.valueObj.searchKey.value = query;
/*
			this.valueObj.searchStartTime.value = "0000/00/00";
			this.valueObj.searchRelation.value = "3";
*/			
			//alert(this.valueObj.searchKey.value);
			//this.options.displayQuery.vaue = query;
		},
		
		addQuery : function(query) {
			var oldquery = this.valueObj.searchKey.value;
			this.formReset();
			this.valueObj.searchKey.value = (oldquery + " " +query);
			$(this.options.displayQuery).value = (oldquery + " " +query);
		},

        addTopicQuery : function(query) {
            var oldquery = this.valueObj.searchKey.value;
            this.valueObj.searchKey.value = query;
            //this.formReset();
         },

        clearQuery : function() {

            // this.formReset();
            this.valueObj.searchKey.value = "";
            // this.valueObj.searchStartTime.value = "0000/00/00";
            this.valueObj.searchRelation.value = "3";

            //this.options.displayQuery.vaue = query;
        },
		
		
		formReset : function() {
			
			for (var i in this.valueObj) {
				if (typeof this.valueIds[i] != 'function') {
					this.valueObj[i].value = "";
				} else continue;
			}
		},
		
	
		parseResult : function(text) {
			var contentStart = text.indexOf("CONTENT||")+ 9;
			var contnetEnd = text.indexOf("||CONTENT");
			var content = text.substring(contentStart,contnetEnd);
			
			var pagingStart = text.indexOf("PAGENAVI||")+ 10;
			var pagingEnd = text.indexOf("||PAGENAVI");
			var paging = text.substring(pagingStart,pagingEnd);
			
			return {content: content , paging:paging};
			
		},
		
		getKeyword : function() {
			return this.valueObj.searchKey.value;
		},
		
		getSection : function () {
			return this.valueObj.searchSection.value;
		},

		getCurrPageNo : function () {
			return this.valueObj.currPageNo.value;
		},
		
		search : function () {
			this.getAjaxResult();
		}
	
}
