var WCAPartNoQuery = Class.create();

Object.extend(WCAPartNoQuery.prototype, PartNoQuery.prototype);
Object.extend(WCAPartNoQuery.prototype, {
	setQueryParam : function(name,value) {
		if (typeof(this.queryParams)=="undefined") {
			this.queryParams = new Array();
		}
		this.queryParams[name] = value;
		return this;
	},
	setPartType : function(partType) {
		// Major Part : 1, Project Part : 2
		this.partType = partType;
		return this;
	},
	btnClick : function() {
		if (this.args==null) {
			alert("pls set query info first!!!");
			return false;
		}
		// 20060731 RickyChiang, Add how to process that inputField is empty and partType is project part 
		if (this.inputField.value.trim()=="" && this.partType=="2") {
			// if partType is Project Part (2) and inputField value is empty, show H001 Message
			CommonMessage.showNotification("H001");
			
			Field.activate(this.inputField);
			return false;
		}
		else if (this.inputField.value.trim()=="") {
			// Popup Bomiq 
			commonCodePopupUrl = "Wcacommon.ModelPageCheckList.mvc";
		}
		else {
			if (this.partType==null || this.partType=="1") {
				commonCodePopupUrl = 
					((this.args.mvcName==null)?"Common.CommonCodeList.mvc":this.args.mvcName);
			}
			else {
				commonCodePopupUrl = "Wcacommon.ProjectPartList.mvc";
			}
		}
		commonCodePopupUrl += (commonCodePopupUrl.indexOf("?")<0)?"?":"&";
		commonCodePopupUrl = commonCodePopupUrl 
			+ "c_" + this.args.P1.replace(/[.]/g, "_")+ "=" + this.inputField.value 
			+ "&queryClass=" + this.args.P0
			+ "&popupProperty=" + escape(this.args.props)
			+ "&popupTitle=" + escape(this.args.titles);
		// Add Query Parameter.....WCA NEED.....
		if (typeof(this.queryParams)!="undefined") {
			for (name in this.queryParams) {
				if (typeof(this.queryParams[name])!="string") { continue; }
				commonCodePopupUrl += "&" + name + "=" + escape(this.queryParams[name]);	
			}
		}
			
		var returnValue = DialogCall(commonCodePopupUrl);
		if (returnValue==null) {
			//???e?p?G?^?????O null, ???B?z
			this.inputField.value = "";
			this.displayField.innerHTML = "&nbsp;";
			return false;
		}
		else if (!returnValue) {
			// ???? messageCode ?]?w?????~?T??
			CommonMessage.showNotification(this.messageCode);
			// ?n???]?w???e?????? Focus?A?~?i?H?]?w???e???????????? focus
			window.focus();
			
			this.inputField.value = "";
			this.displayField.innerHTML = "&nbsp;";
			Field.activate(this.inputField);
			return false;
		}
		else {
			try {
				this.inputField.value = eval("returnValue."+this.args.P1);
			}
			catch(E) {}
			// 20060512 Ricky Chiang Add clear "undefined" value
			if (this.inputField.value=="undefined") {
				this.inputField.value = "";
			}
			try {
				this.displayField.innerHTML = eval("returnValue."+this.args.P2) + "&nbsp;";
			}
			catch(E) {}
			// 20060512 Ricky Chiang Add clear "undefined" value
			if (this.displayField.innerText=="undefined") {
				this.displayField.innerHTML = "&nbsp;";
			}
		}
		
		if (this.returnProc && this.inputField.value != "") {
			this.returnProc.call(
				this, 
				new CommonCodeQuery.ReturnObj(this, returnValue)
			);
		}
	}
});