// JavaScript Document
//var patrn=/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\][\]\{\}:;'\,.<>?]{0,19}$/;
/*$(window).keydown(function(){
alert($("#searchtext").val())
})*/
$(document).ready(function(){
						   $("#searchtext").val("搜索产品");
						   $("#searchtext").click(function(){
														  if ($("#searchtext").val()=="搜索产品") $("#searchtext").val("")
														  if ($("#brandtext").length == 0 && $("#sorttext").length == 0){
																$.msgbox.createsearchbox("搜索产品了!")  
															  }
														  }
												)
						   $("#searchtext").keydown(function(event){
															 var code;
															 if ($.browser.msie){
																 	code = event.keyCode;
																 }
																 else{
																	 code = event.which;
																 }

															 if (code==13){
																	 //alert($("#searchtext").val());
																	 $("#searchbutton").click();
																 } 
															 }
													)
/*$("#input_id").keydown(function(){
event.keyCode==13 && $("input[@type='submit']")[0].click();
})	*/					   
						   $("#searchbutton").click(function(){
															 if (isSearch($("#searchtext").val())){
																 	//alert(encodeURI($("#searchtext").val()))
																	window.location.href="search.html?Keywords="+encodeURI($("#searchtext").val())+"&Brand="+encodeURI($("#brandtext").val())+"&Sort="+encodeURI($("#sorttext").val());
																	//window.location.href="search.html?Keywords="+$("#searchtext").val();
																	//$("#emaillisttext").val(escape($("#searchtext").val()));
																 }else{
																	if ($("#searchtext").val()==""){
																		//$.msgbox.createmsgbox("未输入关键字!");
																		window.location.href="search.html?Keywords="+encodeURI($("#searchtext").val())+"&Brand="+encodeURI($("#brandtext").val())+"&Sort="+encodeURI($("#sorttext").val());
																	}else{
																		$.msgbox.createmsgbox("你输入的搜索字符串含有非法字符!");
																	}
																	$("#searchtext")[0].focus();
																 }
															 //
															 }
													)
						   
						   }
						   
					)




/*function document.onkeypress()
{
	alert(document.activeElement.tagName);
	if ( event.keyCode == 13 )
	{
		if ($("#searchtext").val()=="搜索产品") $("#searchtext").val("")
		if (isSearch($("#searchtext").val())){
			//alert(encodeURI($("#searchtext").val()))
			window.location.href="search.html?Keywords="+encodeURI($("#searchtext").val());
		}else{
			$.msgbox.createmsgbox("你输入的搜索字符串含有非法字符!");
		}
	}
}*/
function isSearch(s)
{
    var patrn = /^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\][\]\{\}:;'\,.<>?]{0,19}$/;
    if (!patrn.exec(s)) return false
    return true
}
