function initKeyWrodsBindEvt(defaultvalue){
	$("form[name='form1'] :text[name='keyword']").bind("keyup",{defaultValue:defaultvalue},searchKeyWords);
	$("form[name='form1'] :text[name='keyword']").keyup();
}

function initConfirmDateBindEvt(){
	if($.browser.msie){//ie
		$("#sfrqTabContent").bind("mouseleave",function(){
			$('#sfrqTabContent').hide();
		});
	}else{
		$("#sfrqTabContent").bind("mouseout",function(e){
			if(isMouseLeaveOrEnter(e,this)){
				$('#sfrqTabContent').hide();
			}
		});
	}
}

function isMouseLeaveOrEnter(event, elementObj) {
	event = event || window.event;
	if (event.type != 'mouseout' && event.type != 'mouseover') return false;
	var reltg = event.relatedTarget ? event.relatedTarget : event.type == 'mouseout' ? event.toElement : event.fromElement;
	while (reltg && reltg != elementObj)
		reltg = reltg.parentNode;
	return (reltg != elementObj);
}

function searchKeyWords(event){
	var kwd = $.trim($(":text[name='keyword']").val());
	if($.trim($("form[name='form1'] input:hidden[name='funtype']").val()) != '0000' && $.trim($("form[name='form1']  input:hidden[name='funtype']").val()) !=''){	
		if(!kwd || event.data.defaultValue == kwd){
			var values = $("input:hidden[name='funtype']").val().split(",");
			return searchFunctypeKeyWords(values,event.data.defaultValue);
		}else{
			$("#wrapSearchKeyWrods").children("div").hide();
			return false;
		}
	}

	if(!kwd || event.data.defaultValue == kwd){
		$("#wrapSearchKeyWrods").children("div").hide();
		return false;
	}
	if(!s_key_words){
		$("#wrapSearchKeyWrods").children("div").hide();
		return false;
	}
	var hasKwd = false;
	for(var t in s_key_words){
		if(t == kwd){
			hasKwd = true;
			break;
		}
	}
	if(hasKwd){
		var words = s_key_words[t].split("|");
		var str_html = "";
		for(var i=0;i<words.length;i++){
			if(words[i]){
				str_html += "<a class='duckblue' href='javascript:void(0)' onclick=\"searchKeyWordsSubmit( this.innerHTML ,'"+ event.data.defaultValue +"');return false;\">"+ words[i] +"</a>&nbsp;&nbsp;";	
			}
		}
		if(str_html){
			$("#searchKeyWrods").html(str_html);
		}else{
			return false;
		}
		$("#wrapSearchKeyWrods").children("div").show(1,function(){});
	}else{
		$("#wrapSearchKeyWrods").children("div").hide();
	}
	return true;
}

function searchFunctypeKeyWords(values,defaulevalue){
	if(values.length == 0){
		$("form[name='form1'] :text[name='keyword']").keyup();
	}
	var kwd = $.trim($("form[name='form1'] :text[name='keyword']").val());
	if(kwd && defaulevalue != kwd){
		$("#wrapSearchKeyWrods").children("div").hide();
		return false;
	}
	if(typeof(funct_key_words)=='undefined' || !funct_key_words){
		$("#wrapSearchKeyWrods").children("div").hide();
		return false;
	}
	if($.trim($("form[name='form1']  input:hidden[name='funtype']").val()) == '0000' || $.trim($("form[name='form1'] input:hidden[name='funtype']").val()) ==''){
		return false;
	}
	var hasKwd = false;
	var funcKeys = "";
	for(var v in values){
		for(var t in funct_key_words){
			if(t == ft[values[v]]){
				hasKwd = true;
				if(funcKeys){
					funcKeys += "|"+funct_key_words[t];
				}else{
					funcKeys = funct_key_words[t];
				}
			}
		}
	}
	if(hasKwd){
		var words = funcKeys.split("|");
		words.unique();
		var str_html = "";
		for(var i=0;i<words.length && i< 16;i++){
			if(words[i]){
				str_html += "<a class='duckblue' href='javascript:void(0)' onclick=\"searchKeyWordsSubmit( this.innerHTML ,'"+ defaulevalue +"');return false;\">"+ words[i] +"</a>&nbsp;&nbsp;";	
			}
		}
		if(str_html){
			$("#searchKeyWrods").html(str_html);
		}else{
			return false;
		}
		$("#wrapSearchKeyWrods").children("div").show(1,function(){});
	}else{
		$("#wrapSearchKeyWrods").children("div").hide();
	}
	return true;
}

function searchKeyWordsSubmit( content ,defaultValue){
	var kwd = $.trim($("form[name='form1'] :text[name='keyword']").val());
	if(kwd && defaultValue != kwd){
		var words = kwd.split(/\s+/);
		words.push(content);
		words.unique();
		$("form[name='form1'] :text[name='keyword']").val(words.join(" "));
	}else{
		$("form[name='form1'] :text[name='keyword']").val(content);
	}
	$("form[name='form1'] :image[name='image']").click();
}