function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}

function doSubmit(type)
{
	if(document.getElementById("sousuo").value==""||document.getElementById("sousuo").value=="请输入商品条形码、名称、品牌型号..."){

		document.getElementById("sousuo").focus();
		return false;
	}
	if(type==1)
		document.form1.submit();
}

//添加到收藏夹，兼容火狐和ie
function addBookmark(url,title) {
if (window.sidebar) {
   window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
   window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
   return true;
}
}

//函数名：chkDecimal  
  /*  
  *判定输入的数据是否为数字  
  *lengths   输入数据总长度  
  *digits//小数位数,如果输入数据没有小数位，也认为是正确的。  
  *flag   //是否允许为空，1   可以为空   0不能为空  
  */  
  function   chkDecimal(OBJ,lengths,   digits,   flag   )  
  {  
      var   checkStr="0123456789.";  
      var   temp=OBJ.value;  
      if   (temp=="")  
      {  
            if   (flag==0)  
            {  
                
   
                return   false;  
    }  
    else  
      {   return   true;}  
      }  
      for   (i=0;i<temp.length;i++)//判断是否含有非数字(小数点,-号不是非数字字符)  
          {  
  if   (checkStr.indexOf(temp.charAt(i))<0)  
      {  
       
   
        return   false;  
      }  
  }  
        if   (temp.indexOf(".")!=temp.lastIndexOf("."))//小数点是否唯一  
      {  
                
   
  return   false;  
        }  
        if   (temp.indexOf(".")>0)//小数位数是否满足要求  
          {  
                if   ((temp.length-temp.indexOf(".")-1)>digits)  
                {  
                    //alert("length:"+temp.length);  
    //alert("小数:"+temp.indexOf("."));  
    
                    return   false;  
  }  
            }  
        //判断输入值的整数位数是否合法，对于正数及负数分别校验  
        //var   tmp   =   parseFloat(temp)   ;  
        //alert(temp.indexOf("."));  
        if   (parseFloat(temp)   >=   0)  
        {  
        //有小数点  
        if   (temp.indexOf(".")   ==   -1   )  
        {  
        if   (temp.length   >   lengths   -   digits)  
        {  
     
                              return   false;    
        }  
        }  
        else  
                {  
            if   (temp.indexOf(".")   >   (lengths   -   digits)   )  
            {  
                       
                        return   false;  
            }  
        }  
        }  
        else  
        {  
                if   (temp.indexOf(".")   >   (lengths   -   digits   +   1)   )  
        {  
                       
                        return   false;  
        }  
        }  
        return   true;  
  }   
var dialogFirst=true;
// Lee dialog 1.0 http://www.xij.cn/blog/?p=68  
	function dialog(title,content,width,height,cssName){
	
	if(dialogFirst==true){
	  var temp_float=new String;
	  temp_float="<div id=\"floatBoxBg\"></div>";
	  temp_float+="<div id=\"floatBox\" class=\"floatBox\">";
	  temp_float+="<div class=\"title\"><h4></h4><span>关闭</span></div>";
	  temp_float+="<div class=\"content\"></div>";
	  temp_float+="</div>";
	  $("body").append(temp_float);
	  dialogFirst=false;
	  
	  $("#floatBox .title span").click(function(){
	    $("#floatBoxBg").hide();
	    $("#floatBox").hide();
	  });
	}
	
	$("#floatBox .title h4").html(title);
	contentType=content.substring(0,content.indexOf(":"));
	content=content.substring(content.indexOf(":")+1,content.length);
	switch(contentType){
	  case "url":
	  var content_array=content.split("?");
	  $("#floatBox .content").ajaxStart(function(){
	    $(this).html("loading...");
	  });
	  $.ajax({
	    type:content_array[0],
	    url:content_array[1],
	    data:content_array[2],
		error:function(){
		  $("#floatBox .content").html("error...");
		},
	    success:function(html){
	      $("#floatBox .content").html(html);
	    }
	  });
	  break;
	  case "text":
	  $("#floatBox .content").html(content);
	  break;
	  case "id":
	  $("#floatBox .content").html($("#"+content+"").html());
	  break;
	  case "iframe":
	  $("#floatBox .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
	}
	 $("#floatBox").css("top",$(document).scrollTop());//-----fanfan add 20091006  
	 $("#floatBox").css("display","block");//-----fanfan add 20091006  
	 $("#floatBoxBg").show();  
	 $("#floatBoxBg").animate({opacity:"0.5"},"normal");  
	 $("#floatBox").attr("class","floatBox "+cssName);  
	 //$("#floatBox").css({display:"block",left:(($(document).width())/2-(parseInt(width)/2))+"px",top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px",width:width,height:height});//-----the origin  
	 $("#floatBox").animate({top:($(document).scrollTop()+50)+"px"},"normal");
	 $("#floatBoxBg").css({display:"block",height:$(document).height()});  
	//$("#floatBoxBg").css({display:"block",height:$(document).height()});
	//$("#floatBox").removeClass();
	//$("#floatBox").attr("class","floatBox "+cssName);
	//$("#floatBox").css({display:"block",left:(($(document).width())/2-(parseInt(width)/2))+"px",top:($(document).scrollTop()+50)+"px",width:width,height:height});
	}