好库网
?jQuery(document).ready(function() {
	<!--城市切换-->
	$("#changecity").bind("click",function(){			
		if (!jQuery("#morecity").is(":hidden")) {				
			jQuery("#morecity").css("display", "none");
		}
		else{			 	
			jQuery("#morecity").css("display", "");	
		}
		return false;
	});
	
	$("body").bind("click",function(){
		jQuery("#morecity").css("display", "none");
	});	
	
	$("a",$("#morecity")).click(function(){
		var value = $(this).attr("href").replace("../../../default.htm","");
		$.cookie("city",value,{path:"/",domain:".链接已屏蔽",expires:30});
	});
	
	<!---退出-->
	$("#logout").bind("click",function(){
		$.cookie('www58com',null,{ expires: 0, path: '../../../default.htm', domain: '链接已屏蔽'});				
		window.location.href="../../../default.htm";	
	});	
	//头部邮件订阅
	$("#headerMailInput").click(function(){
		if($(this).val() == "输入Email,订阅每日团购信息")
			$(this).val("");
	}).blur(function(){
	    var self = $(this);
		var email = self.val();
		if (email ==''){
			self.val("输入Email,订阅每日团购信息");
		}
	}).keydown(function(e){
		if(e.keyCode==13){
			return false;
		}
	});
	$("#headerMailInput").autoComplete();
	$("#headerMailButton").click(function(){
		$("#email_error").hide();
	    $.ajax({
			url:'../../../getcitylist',
			dataType:'json',
			type:'POST',
			data:{},
			success:function(data){
				var c = "";
				$.each(data.cityList, function(i, field){
					c += '<option value="'+field.cityenname+'">'+field.cityname+'</option>';
				});
				$("#dy_city_email").empty().append(c);				
				$("#dy_city_email").val($("#cityenname_email").val());								
				jQuery.colorbox({inline:true,innerWidth:530, href:"#yjdy1", overlayClose:false});
			}
		});	    
	});	
	
	$("#submit_emailsub_1").click(function(){		
		var email =$("#headerMailInput").val();
		var city = $("#dy_city_email").val();
		if(email!=undefined && checkEmail(email) && city!=undefined){
			$.get("../../../emailsub.do",{email:email,city:city},function(data){
				if(data=="true"){										
					jQuery.colorbox({inline:true,innerWidth:530, href:"#yjdy2", overlayClose:false,onOpen:setTimeout($.colorbox.close, 3000)});			
				}else{						
					alert("非常遗憾您订阅失败了,请重新订阅.");
				}
			});
		}
	});	
	
	$(".cancel").click(function(){
		$.colorbox.close();		
	});
	
	//频道下拉
	$("#chn").bind("mouseover",function(){
		$("#chn").addClass("downlist hover");
	});
	$("#chnct").bind("mouseout",function(){
		$("#chn").removeClass("downlist hover");
		$("#chn").addClass("downlist");
	});
	$("#dingyue").click(function(){
	    var email =$("#email").val();
		var city = $("#cityid").val();
		dosubemail(email,city);		
	});
	
	//表格滑动背景
	$(".d_table>table>tbody>tr").mouseover(function(e){
		$(this).addClass("bj_1");
	});
	
	$(".d_table>table>tbody>tr").mouseout(function(e){
		$(this).removeClass("bj_1");
	});
	$(".m_table>table>tbody>tr").mouseover(function(e){
		$(this).addClass("bj_1");
	});
	
	$(".m_table>table>tbody>tr").mouseout(function(e){
		$(this).removeClass("bj_1");
	});
 });
function checkAll(){
		if($("#checkall").attr("checked") == true){
			$("input[name='hobby_email']").each(function(){$(this).attr("checked",true);});			
		}else{
			$("input[name='hobby_email']").each(function(){$(this).attr("checked",false);});
		}
}
function initconfig(email){		
    $.ajax({
		url:'../../../getEmailSub',
		dataType:'json',
		type:'POST',
		data:'email='+email+'&a='+Math.random(),
		success:function(data){
			$("input[type='checkbox'][name='hobby_email']").each(function(){
				$(this).attr("checked", false);
			});
			if(data.result == 1){
				var hobbies = data.emailsubscribe.hobbies.split(",");
				for(var i=0; i<hobbies.length; i++){
					$("input[type='checkbox'][name='hobby_email'][value='"+hobbies[i]+"']").attr("checked", true);
				}
				$("#localname").val(data.emailsubscribe.localname);
			}
		}
	});
}
function createElement(tag,values){
	var Field = document.createElement(tag);
	for (var property in values){
		if (values.hasOwnProperty(property)){
			var value = values[property];
			Field.setAttribute(property,value);
		}
	}
	return Field;
}
function postToURL(url, values){
	values = values || {};
	var form = createElement("form", {action: url,
				  method: "POST",
				  style: "display: none"});
	for (var property in values){
		if (values.hasOwnProperty(property)){
			var value = values[property];
			if (value instanceof Array){
				for (var i = 0, l = value.length; i < l; i++){
					form.appendChild(createElement("input", {type: "hidden",
									 name: property,
															 value: value[i]}));
				}
			}else{
				form.appendChild(createElement("input", {type: "hidden",
														 name: property,
														 value: value}));
			}
		}
	}
	document.body.appendChild(form);
	form.submit();
	document.body.removeChild(form);
}

function checkEmail(email){
	if(!/^(?:[\w\d_.-]+)@(?:[\da-z.-]+)\.(?:[a-z\.]{2,6})$/.test(email)){
		$("#email_error").text("请正确输入Email地址.").show();
		return false;
	}
	return true;
}
function testEmail(email){
	if(!/^(?:[\w\d_.-]+)@(?:[\da-z.-]+)\.(?:[a-z\.]{2,6})$/.test(email)){
            
		msg("email格式错误","请正确输入订阅的email地址");
		jQuery.colorbox({inline:true,innerWidth:320, href:"#yjdy", overlayClose:false});
		// window.setTimeout(function(){ self.focus(); }, 0);
		return false;
	}else{
		jQuery.colorbox({inline:true,innerWidth:360, href:"#sub_email_dy3", overlayClose:false});
	}
	return true;
}

function msg(title,msg,href) {
	$("#yjdy h2").html(title);	
	$("#yjdy p").html(msg);
	$("#baimingdan").remove();
	$("#yjdy").append(href);
}

function islogin(city){
	if($.cookie("www58com")==null)
	{
		$("#dingdan").show();
		$("html,body").animate({scrollTop: $("#dingdan").offset().top}, 1000);  
		return false;
	}else{
		return true;
	}
}
function addfavorite()
{
	if (document.all){ 
		window.external.addFavorite('../../../../链接已屏蔽#39;,'链接已屏蔽');
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel('链接已屏蔽', '../../../../链接已屏蔽#39;, ""); 
	} 
}

//短信订阅窗口
$(function(){
	$('#ch').click(function(){
		$('#vcodeImg').removeAttr('src').attr({'src':'../../../generatecheckcode@a='+Math.random()});
		return false;
	});
	$('#sub_dy').click(function(){
		var hcityname = $('#hcityname').val();			
		$('#vcodeImg').removeAttr('src').attr({'src':'../../../generatecheckcode@a='+Math.random()});
		$('#canel').empty().append('1');
		$('#canel1').empty().append('1');
		$("#verify_dy").val("");
		$("#vrc").val("");
		$(this).nyroModalManual({
			bgColor: '#000000',
			zIndexStart:9999
		});
		return false;
	});


	$('#sub_td').click(function(){
		$('#vcodeImg').removeAttr('src').attr({'src':'../../../generatecheckcode@a='+Math.random()});
		$('#canel').empty().append('2');
		$('#canel1').empty().append('2');
		$("#verify_dy").val("");
		$("#vrc").val("");
		$(this).nyroModalManual({
			bgColor: '#000000',
			zIndexStart:9999
		});
		return false;
	});

	$('#sub_dyc1').click(function(){
		var mobile = $('#mobile_dy').val();
		var smsvrcode = $('#verify_dy').val();
		var type = $('#canel').text();   //此处为判断类型(订阅短信或取消短信订阅)
		var partten = /^1[3458]\d{9}$/;
		var cityenname = $('#cityenname').val();	
		if(mobile == ''){
			alert('手机号码不能为空');
			return false;
		}else if(!partten.test(mobile)){
			alert('请输入正确的电话号码');
			return false;
		}else if(smsvrcode == ''){
			alert('请输入验证码');
			return false;
		}else{
			$.ajax({
				url:'../../../smsvrcode@a='+Math.random(),
				dataType:'text',
				type:'POST',
				data:'mobile='+mobile+'&smsvrcode='+smsvrcode+'&type='+type+'&cityenname='+cityenname+'&a='+Math.random(),
				async:true,
				success:function(data){
					if(data == 1){
						alert('手机不正确');
						$.nyroModalRemove();
						return false;
					}else if(data == 2){
						//发送验证码
						if(type==1){
							$('#sub_dyc1').attr("title", '请输入短信订阅验证码');
						}else{
							$('#sub_dyc1').attr("title", '请输入取消订阅验证码');
						}
						$('#mobile1_dy').empty().append(mobile);	
						$("#pop_sub_dy2").click();
					}else if(data == 3){ //表示该用户已经订阅
                         $('#con').empty().append(data);
					}else if(data == 4){
						alert('验证码不正确');
						return false;
					}else{            
						$('#con').empty().append(data);
						$('#sub3').nyroModalManual({
							bgColor: '#000000',
							zIndexStart:9999,
							width: null, // default Width If null, will be calculate automatically
							height: null,
							minWidth: 400, // Minimum width
							minHeight: 10, // Minimum height
							autoSizable: true
						});
					}
				}
			});
		}
	});

	$('#sub_dyc2').click(function(){
		var m = $('#mobile1_dy').text();
		var vr = $('#vrc').val();
		var hcityname = $('#hcityname').val();
		var cityenname = $('#cityenname').val();
		var type = $('#canel1').text();
		if(vr==''){
			alert('请输入验证码');
			return;
		}else{
			$('#vrc').val('');
			$.ajax({
				url:'../../../smsvrfcode',
				dataType:'json',
				type:'POST',
				data:'mobile='+m+'&vr='+vr+'&type='+type+'&cityname='+hcityname+'&cityenname='+cityenname+'&a='+Math.random(),
				success:function(data){
					if(data.result == 1){
						$("#sex").val(data.smsSubscribe.sex);
						var birthday = "1980";
						if(data.smsSubscribe.birthday!=null){
							var date = new Date(data.smsSubscribe.birthday.time);
							birthday = date.getFullYear();
						}
						$("#birthday").val(birthday);
						$("input[type='checkbox'][name='hobby']").each(function(){
							$(this).attr("checked", false);
							$(this).attr("defaultChecked", false);
						});
						var hobbies = data.smsSubscribe.hobbies.split(",");
						for(var i=0; i<hobbies.length; i++){
							$("input[name='hobby'][type='checkbox'][value='"+hobbies[i]+"']").attr("checked", true);
							$("input[name='hobby'][type='checkbox'][value='"+hobbies[i]+"']").attr("defaultChecked", true);
						}
						$("#pop_sub_dy3").click();
					}else if(data.result == 2){
						$("#pop_sub_td3").click();
					}else if(data.result == 3){
						alert('操作类型错误!');
						return;
					}else if(data.result == 4){
						alert('验证码错误!');
						return;
					}
				}
			});
		}
	});

//个性化设置防止提交
	$('#sub_tdc2').click(function(){
	  $("#message").empty();
	  var chbelements =document.getElementsByName("hobby")
	  var chblen =chbelements.length;
//	  alert("chblen:"+chblen);
	  var num=0;
	  if(chblen>0){
			for(i=0;i<chblen;i++)
			{
			  if(chbelements[i].checked==true)
			  {
				  num++;
			  }
			}
	   }

	   if(num==0){
		  // alert("请选择一个");
		  $("#message").html("请选择您选择兴趣爱好!");
		  return false;
	   }

	   
		$.ajax({
			url:'../../../smssubadd',
			type:'POST',
			dataType:'json',
			data:jQuery('#personalityForm').serialize(),
			success:function(data){
//	                alert("data:"+data);
				if(data==1){  //处理完成后,把个性化填写数据输入初始化。
					$("#hobby").empty();
//						$("#sex").empty();
//						$("#birthday").empty();
					$("#pop_sub_dy4").click();
				}
			}
		});
	   
	});


	$('#sub_submit').click(function(){
		var sub_email = $('#rss_email').val();
		var testEmail = /^[A-Za-z0-9](([_\.\+\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;
		var city_id = $('#city_sub_id').val();
		var sub_id= $('#sub_id').val();
		if(!testEmail.test(sub_email)){
			alert('请输入正确的电子邮件地址');
		}else{
			$.ajax({
				url:'../../../ajax/sub_email.php',
				type:'POST',
				dataType:'json',
				data:'email='+sub_email+'&city_id='+city_id+'&sub_id='+sub_id,
				success:function(data){
					if(data==3){
						alert('缺少必要参数');
					}else if(data==4){
						alert('你已经订阅了该城市');
					}else if(data==1){
						$('#show_sub').nyroModalManual({
							bgColor: '#000000',
							zIndexStart:9999,
							width: null, // default Width If null, will be calculate automatically
							height: null,
							minWidth: 400, // Minimum width
							minHeight: 10, // Minimum height
							autoSizable: true
						});
						$('#set_sub_email').val(sub_email);
					}else if(data==2){
alert('执行出错');
					}
				}
			});
		}
		return false;
	});


	if($.cookie("lashou_patron") == null && $('#sell').length == 0){
	$('#header_tip').show();
	}else if($('#sell').length > 0 && $.cookie("lashou_patron") == null){
		$('#header_tip').hide();
	}else if($.cookie("lashou_patron") == 1){
			$('#header_tip').hide();
	}
	$('#ct').click(function(){
			$.cookie('lashou_patron',1,{expires:2592000});
			$('#header_tip').hide();
			return false;
	});
	
	
	
	
	
	
	//**************************团购搜索的JS********************************
	$("#tooltipdiv").mouseover(function(){
		boolClose = false;
	});
	$("#tooltipdiv").mouseout(function(){
		boolClose = true;
	});
});
//**************************团购搜索的JS********************************
var boolClose = true;
var searchNum = 1;

//把搜索结果添加到tooltipdiv的DIV里面

function replaceHtml(varhtml)
{
	varhtml = varhtml.replace(/(<b>|<B>|<\/b>|<\/B>)/g,"");
	return varhtml;
}
//假如点击了搜索词,则往输入框添加搜索词,并自动跳转
function addSearchWord(id , cityenname)
{
	$("#tooltipdiv").css({"display":"none"});
	var myhtml = $("#" + id).html();
	myhtml = replaceHtml(myhtml);
	myhtml = replaceAllSymbol(myhtml);
	var textId = "";
	if(searchNum == 1)
	{
		textId = "indexSearchForm";
		$("#searchW").val(myhtml);
	}
	else
	{
		textId = "searchForm";
		$("#kw2").val(myhtml);
	}
	document.getElementById(textId).action="../../../"+ cityenname +"../../../g_s/" + encodeURI(myhtml)  + "/";
	document.getElementById(textId).submit();
		
	$("#tooltipdiv").html("");
	boolClose = true;
}
//liArray是 $("#tooltipdivUl").find("li");
function geiIposOfClassIsSelected(liArray)
{
	var liArrayClass = "";
	var ipos = -1;
	var size = liArray.length;
	for(i=0;i<size;i++)
	{
		liArrayClass = $("#" + liArray[i].id).attr("class");
		if(liArrayClass == "selected")
		{
			ipos = i;
			break;
		}
	}
	return ipos;
}
//鼠标滑动到li上时添加class
function addLiClass(id)
{
	var liArray = $("#tooltipdivUl").find("li");
	var ipos = -1;
	var size = liArray.length;
	ipos = geiIposOfClassIsSelected(liArray);
	if(ipos != -1)
	{
		$("#" + liArray[ipos].id).attr("class","");
		ipos = -1;
	}
	$("#" + id).addClass("selected");
}
function addLiClassById(id)
{
	$("#" + id).attr("class","selected")
}
function keyUpOfById(event , ids)
{
	if(event == null)
		event = window.event;
	if ((event.keyCode != 38) && (event.keyCode != 40) && (event.keyCode != 13)) { 
		var value = $.trim($('#' + ids).val());
		if("" != value && "请输入商品、商家名称" != value)
		{
			addSearchTipHtml($("#" +  ids).val());
		}
		else{
			$("#tooltipdiv").css({"display":"none"});
			$("#tooltipdiv").html("");
			boolClose = true;
		}
	}
	else 
	{
		var liArray = $("#tooltipdivUl").find("li");
		var liArrayClass = "";
		var ipos = -1;
		var size = liArray.length;
		if(event.keyCode == 38)
		{
			ipos = geiIposOfClassIsSelected(liArray);
			if(ipos == -1)
			{
				$("#" + liArray[size-1].id).attr("class","selected");
				ipos = size-1;
			}
			else if(ipos > 0 )
			{
				$("#" + liArray[ipos-1].id).attr("class","selected");
				$("#" + liArray[ipos].id).attr("class","");
				ipos = ipos-1;
			}
			else
			{
				$("#" + liArray[size-1].id).attr("class","selected");
				$("#" + liArray[ipos].id).attr("class","");
				ipos = size-1;
			}
			var hitWord = $("#searchid" + ipos).html();
			hitWord = replaceHtml(hitWord);
			$("#" + ids).val(hitWord);
			ipos = -1;
		}
		else if(event.keyCode == 40)
		{
			ipos = geiIposOfClassIsSelected(liArray);
			if(ipos == -1)
			{
				$("#" + liArray[0].id).attr("class","selected");
				ipos = 0;
			}
				
			else if(ipos < (size-1) )
			{
				$("#" + liArray[ipos+1].id).attr("class","selected");
				$("#" + liArray[ipos].id).attr("class","");
				ipos = ipos + 1;
				var hitWord = $("#searchid" + ipos).html();
				hitWord = replaceHtml(hitWord);
				$("#searchW").val(hitWord);
				
			}
			else
			{
				$("#" + liArray[0].id).attr("class","selected");
				$("#" + liArray[ipos].id).attr("class","");
				ipos = 0;
			}
			var hitWord = $("#searchid" + ipos).html();
			hitWord = replaceHtml(hitWord);
			$("#" + ids).val(hitWord);
			ipos = -1;
		}
		else if(event.keyCode == 13)
		{
			var value = $.trim($('#' + ids).val());
			if("" != value && "请输入商品、商家名称" != value)
			{
				var position = null;
				if(searchNum == 1)
					position = $("#searhbar").offset();
				else
					position = $("#l_search").offset();
				$("#tooltipdiv").css({"left":position.left+"px","top":position.top+32+"px","display":"block"});
				addSearchTipHtml($("#" + ids).val());
				position =  null;
			}
			else{
				$("#tooltipdiv").css({"display":"none"});
				$("#tooltipdiv").html("");
				boolClose = true;
			}
		}
		
	}
}
function idBlur(ids)
{
	var value = $.trim($('#' + ids).val());
	if(value == "")
	{
		if($("#" + ids).parentNode != null)
			$('#' + ids).parentNode.className='';
		$('#' + ids).val("请输入商品、商家名称");
	}
	if(boolClose == false)
	{
			var position = null;
			if(searchNum == 1)
				position = $("#searhbar").offset();
			else
				position = $("#l_search").offset();
			$("#tooltipdiv").css({"left":position.left+"px","top":position.top+32+"px","display":"block"});
	}
	else{
		$("#tooltipdiv").css({"display":"none"});
		$("#tooltipdiv").html("");
	}
	boolClose = true;
}
function idFocus(ids)
{
	if(ids == "searchW")
		searchNum = 1;
	else
		searchNum = 2;
	var value = $.trim($('#' + ids).val());
	if(value == "请输入商品、商家名称")
	{
		$('#' + ids).val("");
	}
	document.getElementById(ids).parentNode.className='hover';
}
function replaceAllSymbol(value)
{
	value = value.replace(/[`|~|!|…|!|¥|@|#|$|%|^|*|&|\(|\)|(|)|、|{|}|\[|\]|:|"|:|“|”|‘|’|;|,|。|?|《|》|、|,|<|>|\?\|../../../]/g , "");
	return value;
}
function myloadtuangou(url , id){
	$.getJSON(url ,function(data) {
		var size0 = 0;
		if(data != null && typeof(data) != "undefined")
			size0 = data.length;
		var content ;
		if(size0 > 0)
		{
			content = "<h3>猜您喜欢的</h3><ul>";
			for(ipos=0;ipos<size0;ipos++)
			{
				content = content + "<li><h2><a title=\""+data[ipos].title
					+"\" href=\""+data[ipos].url+"\" ><img width=\"210\" height=\"131\" alt=\""+data[ipos].title+"\" src=\""+data[ipos].pic+"\">"+data[ipos].title+"</a></h2>";
				
				content = content + "<p><a href=\""+data[ipos].url+"\">去看看</a>团购价:<span>"+data[ipos].price+"</span></p></li>";
			}
			content = content + "</ul>";
			$("#" + id).html(content);
		}
	});
}
var suffixArr=new Array("@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽", "@链接已屏蔽","@链接已屏蔽");
(function(){
        $.fn.autoComplete=function(arg){
        	
            var opt={
                subBox:"#mail_auto",/*提示框ID*/
                subOp:"li",/*操作对象*/
                id:"#headerMailInput",/*文本框ID*/
                suffixArr:suffixArr,//数组对象
                hoverClass:"li:hover"/*选中效果*/
            };
          
           var option=$.fn.extend(opt,arg);
           var _cur=-1;
           
           $(option.id).keyup(function(e){
                if(e.keyCode==40 || e.keyCode==38){
                    return false;
                }
                var _that=$(this);
                if(_that.val()!=""){                	
                    if(e.keyCode!=38 && e.keyCode!=40 && e.keyCode!=13 && e.keyCode!=27){
                        var _inputVal=_that.val();
                        $(option.id).unbind("blur").removeAttr("onblur");
                        $.fn.autoComplete.tipFun(_inputVal,_that);
                    }
                }else{
                    $(option.subBox).hide() 
                }
             });
           
           //tipFun函数
           $.fn.autoComplete.tipFun=function(_v,o){
               var _that=o;              
               $(option.subBox).show();               
               var str="<ul>";
               str += '<p style="color:#999;font-size: 12px;" id="e_type">&nbsp;&nbsp;请选择您的邮箱类型</p>';
               var e=_v.indexOf("@");
               if(e==-1){
                          $.each(option.suffixArr,function(s,m){
                          str+='<li id="e'+s+'" title="'+ _v + m +'">' + _v + m + "</li>";
                      })
                }else {
                         var _sh=_v.substring(0,e)
                         var _se=_v.substring(e);
                         $.each(option.suffixArr, function (s,m) {
                            if(m.indexOf(_se)!=-1){
                                    str += '<li id="e'+s+'" title="'+ _sh + m + '">' + _sh + m + "</li>" 
                            }
                        });
                         if(str.indexOf("<li id=")==-1){
                        	 str+='<li>'+ _v +'</li>'
                         }
                }
                str+="</ul>";
                $(option.subBox).html(str); 
                    $(option.subBox).find(option.subOp).hover(function(){
                            var _that=$(this);
                        },function(){
                            var _that=$(this);
                        });
                    /*绑定click事件*/
                    $(option.subBox).find(option.subOp).each(function(){
                        $(this).click(function(e){
                            if($(e.target).attr("id")!="e_type"){
                                $(option.id).val($(e.target).html());                               
                                $(option.subBox).hide();
                                e.stopPropagation();
                            }
                        });                                           
                    })
            };
            /*点击页面其他地方关闭提示层*/
            $(document).bind("click",function(e){
            	if(!$(option.subBox).is(":hidden")){
            		_cur=-1;
                    $(option.subBox).hide();                    
            	}
            });			
            $.fn.autoComplete.itemFun=function(){
                var _tempArr=$(option.subBox).find(option.subOp);               
                var _size=_tempArr.size();
                    for(var i=0;i<_size;i++){
                        _tempArr.eq(i).css({color:"black", background: "white"});
                    }
                    if(_size>2){
                        if(_cur>_size-1){
                            _cur=0;
                            $(option.subBox).scrollTop(0); 
                        }
                        if(_cur<0){
                            _cur=_size-1;   
                        }
                        if(_cur>=4){
                        	$(option.subBox).scrollTop(_cur*24);
                        }
                        _tempArr.eq(_cur).css({ color:"white", background: "#ABC553"});
                    }else{
                        _cur=0; 
                    }
            };
        $(document).keydown(function(e){
                switch(e.keyCode){
                      case 40://下键
                           _cur++;
                           $.fn.autoComplete.itemFun();
                           e.stopPropagation();
                           break;
                      case 38://上键
                           _cur--;
                           $.fn.autoComplete.itemFun();
                           e.stopPropagation();
                           break;
                      default:
                           break;
                }
            })     
        /*文本框keydown*/
        $(option.id).keydown(function(e){			
            var _temp=$(option.subBox).find(option.subOp);
            if(e.keyCode==13){				
                $(this).val(_temp.eq(_cur).text());
                $(option.subBox).hide();
                _cur=-1;                 
            }                             
        });    
        return this;    
    }
})(jQuery);
/*截取字符串显示长度*/
function subviewstr(str, len) {
        if (!str || !len) { return ''; }
        var a = 0;
        var i = 0;
        var temp = '';
        for (i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) > 255) {
                a += 2;
            }
            else {
                a++;
            }
            if (a > len) { return temp; }
            temp += str.charAt(i); 

        }
        return str;

    }