﻿function Public(){
    this.expires=10;
    //获取用户对象
    this.$=function(name)
    {return document.getElementById(name);}
    ,
    //设置cookie
    this.setCookie=function(name, value) 
    { var date=new Date();
        var ms=this.expires * 60 * 60 * 1000; 
        date.setTime(date.getTime()+ms); 
        var str = name+"="+escape(value); 
        str+="; expires="+date.toGMTString(); 
        document.cookie=str;  }
    ,
    //获取cookie
    this.getCookie=function(cookieName) 
    { var value="";
          var cookieString = document.cookie;
          var start = cookieString.indexOf(cookieName + '=');
          if (start == -1){ value= null;}
          else{start += cookieName.toString.length-1;
            var end = cookieString.indexOf(';', start);
            if (end == -1) return unescape(cookieString.substring(start));
            value= unescape(cookieString.substring(start, end));}
          return value;} 
    
    //删除cookie  
    this.deleteCookie=function(name) 
    { var expdate = new Date(); 
        expdate.setTime(expdate.getTime() - (86400 * 1000 * 1)); 
        this.setCookie(name, "", expdate); 
    } 
    ,
    //判断计算机是否打开Cookies
    this.PassCookies=function()
    {
        this.setCookie('ask.bitauto.com',"yes");
        var cookies=this.getCookie('ask.bitauto.com');
        if(cookies.indexOf("yes")==-1){
            alert('请客户端cookies，才能继续操作！');
            return false;
        }
        else
        {
            return true;
        }
    }
    ,
    //获取文本控件值
    this.getText=function(name)
    {return $(name).value;}
    ,
    //获取单选框或多选框值
    this.getRadio=function(name)
    { var objId=$(name);
        var value="";
        if(objId.checked==true)
        {
            value=objId.value;
        }
        return value;}
    ,
    //获取下拉框控件值
    this.getSelect=function(name)
    {
        var value="";
        var objId=$(name);
        var index = objId.selectedIndex;
        if(index>0) 
        value = objId.options[index].value;
        return value;
    }
    ,
    //去掉左边空格 
    this.LTrim=function(str) 
    { 
	    var i; 
	    for(i=0;i<str.length;i++) 
	    { 
		    if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break; 
	    } 
	    str=str.substring(i,str.length); 
	    return str; 
    } 
    ,
    //去掉右边空格
    this.RTrim=function(str) 
    { 
	    var i; 
	    for(i=str.length-1;i>=0;i--) 
	    { 
		    if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break; 
	    } 
	    str=str.substring(0,i+1); 
	    return str; 
    }
    ,
    //去掉两边空格
    this.Trim=function(str) 
    { 
        str=this.LTrim(this.RTrim(str));
        str=str.replace(/nbsp;/g,"");
	    return str; 
    }
     ,
     //计算英文和中文字节数
    this.fucCheckLength=function(strTemp)  
    {          
         var i,sum;  
         sum=0;  
         for(i=0;i<strTemp.length;i++)  
         {  
              if((strTemp.charCodeAt(i)>=0)   &&   (strTemp.charCodeAt(i)<=255)){  
                sum=sum+1;
              }else{  
                sum=sum+2;
              }  
         }  
         return sum;  
   }
   ,
    //循环清空选择框  
    this.DeleteColls=function(name)
    {    
        var cartype=$(name); 
        for(var i=0;i<cartype.childNodes.length;i++)
        {
            cartype.removeChild(cartype.childNodes[i]);
            i--;
        }
       
    }
    ,
    //加载选择框内容
    this.RequestClaim=function(json,name,mms,ischeck,ispin,line)
    {
        var temp="";
        eval("data="+json);
        var ddlPro=$(name);
        if(mms.length >0){
            var option=new Option();
            option.value= -1;
            option.text=mms;
            ddlPro.options.add(option);
        }
        if(data.array.length > 0)
        {
            for(var i=0; i< data.array.length ; i++)
            {
                if(data.array[i].pin!=temp && ispin){
                     option=new Option();
                     option.value= -1;
                     option.text = line+data.array[i].pin+line;
                     ddlPro.options.add(option);
                     temp = data.array[i].pin;
                }
                option=new Option();
                if(ischeck && data.array[i].check=="true"){
                        option.selected  = true;
                }
                option.value=data.array[i].value;
                option.text=data.array[i].text;
                ddlPro.options.add(option);
            }
        }
       
    },
    //选择下列框
    this.SelectClaim=function(name,selectname){
        var ddlPro=$(name);
        for(var i=0;i<ddlPro.options.length;i++){
            if(ddlPro.options[i].text==selectname){
                ddlPro.options[i].selected = true;
                return;
            }
        }
    }
    
    ,
    //显示提示信息
    this.Show=function(objMessage,message,isheddin){
       if(objMessage!=null || objMessage!=undefined)
       {
            if(isheddin)
            {
                objMessage.show();
            }
            objMessage.innerHTML = message;
       }
    }
    ,
    //隐藏提示信息
    this.UnShow=function(objMessage,isheddin)
    {
        if(objMessage!=null || objMessage!=undefined)
        if(isheddin)
        {
            objMessage.hide();
        }
        objMessage.innerHTML = ""; }
    ,
    //让验证失败
    this.noEvent=function(evt)
    { if (document.all){ //IE
      evt.returnValue=false;return false;
      }else{evt.preventDefault();return false; } }
    ,
    //让验证成功
    this.YesEvent=function(evt)
    { if (document.all){ //IE
      evt.returnValue=true;return true;
      }else{return true; } }
    
    //刷新验证码
    this.iframereload=function(id,code,root){
       var src = ((root!=undefined)?root:"")+"IframePage/CheckCode.aspx?width=40&height=22&validatecodename="+code+"&fontsize=18&isdrawnoise=false&charcount=4&isusernumber=true"+"&"+Math.random();
        var loop=setTimeout(function(){
            if($(id)!=null && $(id)!=undefined){
                $(id).src= src;
            }
            clearTimeout(loop);
        },0);
          
    },
     //动态计算页面上边距
    this.getElementPositionY = function(elemID)
    {
       var offsetTrail = parent.document.getElementById(elemID);
       var offsetTop = 0;
        while(offsetTrail)
       {
          offsetTop += offsetTrail.offsetTop;
          offsetTrail = offsetTrail.offsetParent;
       }
        if (navigator.userAgent.indexOf("Mac") != -1 && 
            typeof(document.body.leftMargin) != "undefined") {
            offsetTop += document.body.topMargin;
        }
        return offsetTop;
    }
    ,
    //动态计算页面左边距
    this.getElementPositionX = function(elemID)
    {
       var offsetTrail = parent.document.getElementById(elemID);
       var offsetLeft = 0;
       while(offsetTrail)
       {
          offsetLeft += offsetTrail.offsetLeft;
          offsetTrail = offsetTrail.offsetParent;
       }
        if (navigator.userAgent.indexOf("Mac") != -1 && 
            typeof(document.body.leftMargin) != "undefined") {
            offsetLeft += document.body.leftMargin;
        }
        return offsetLeft;
    }
    ,
     //自适应高度
     this.TuneHeight=function(iframeObj)
     {
        if (document.getElementById){ 
           if (iframeObj && !window.opera){ 
            if (iframeObj.contentDocument && iframeObj.contentDocument.body.offsetHeight){ 
             iframeObj.height = iframeObj.contentDocument.body.offsetHeight; 
            }else if(document.frames[iframeObj.id].document && document.frames[iframeObj.id].document.body.scrollHeight){ 
             iframeObj.height = document.frames[iframeObj.id].document.body.scrollHeight+"px"; 
            } 
           } 
          } 
     }
    ,
     //生成显示层
    this.CreateLayer=function(id,html,width,height)
    {
        var layer=null;
        if($(id)==null){
            layer=document.createElement("DIV");
            layer.id= id;
            layer.style.height= height+"px";
            layer.style.width= width+"px";
            layer.style.position="absolute";
            layer.style.zIndex=10;
            layer.innerHTML=html; 
            document.body.appendChild(layer);
        }else{
            layer=$(id);
            layer.innerHTML=html;
            layer.style.display="block";
        }
    },
    //计算输入字数
    this.computeContent=function(name,_this,size)
    {
        
        var spareNumber= null;
        if(name.length > 0){
            spareNumber = $(name); 
        }
        //汉字长度 
        var len=_this.value.replace(/[^\x00-\xff]/gi,'xx').length;
        len=len/2; 
        var snum=parseInt(size)-len; 
        if(spareNumber!=null){
            spareNumber.innerHTML="您还可输入"+parseInt(snum)+"个汉字";
        } 
        if(snum < 0) 
        { 
            if(_this.value.length!=len) 
            { 
                if((len-_this.value.length)>(size/2)) 
                { 
                    _this.value=_this.value.substring(0,size/2); 
                } 
                else 
                { 
                    _this.value=_this.value.substring(0,size-(len-_this.value.length)); 
                } 
            } 
            else 
            { 
                _this.value=_this.value.substring(0,size); 
            }
            if(spareNumber!=null){ 
                spareNumber.innerHTML="还可输入0个汉字"; 
            }
            return; 
        } 
    }
    ,
       //截取字符串 包含中文处理 
     //(串,长度,增加...) 
     this.subString=function(str, len, hasDot) 
     { 
            var newLength = 0; 
            var newStr = ""; 
            var chineseRegex = /[^\x00-\xff]/g; 
            var singleChar = ""; 
            var strLength = str.replace(chineseRegex,"**").length; 
            for(var i = 0;i < strLength;i++) 
            { 
                singleChar = str.charAt(i).toString(); 
                if(singleChar.match(chineseRegex) != null) 
                { 
                    newLength += 2; 
                } 
                else 
                { 
                    newLength++; 
                } 
                if(newLength > len) 
                { 
                    break; 
                } 
                    newStr += singleChar; 
             } 
             if(hasDot.length > 0 && strLength > len) 
             { 
                newStr += hasDot; 
             } 
             return newStr; 
     }
     ,
     this.toBreakWord=function(strContent,intLen){
            var strTemp="";
            while(strContent.length>intLen){
                strTemp+=strContent.substr(0,intLen)+"<br />";  
                strContent=strContent.substr(intLen,strContent.length);  
            }
            strTemp+=strContent;
            return strTemp;
        }
     ,
     //获取url参数
    this.RequestParam = function(url,paras){ 
        var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");  
        var paraObj = {}  
        for (i=0; j=paraString[i]; i++){  
            paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length);  
        }  
        var returnValue = paraObj[paras.toLowerCase()];  
        if(typeof(returnValue)=="undefined"){  
            return "";  
        }else{  
            return returnValue;  
        }  
    }
    ,
    this.Redirect=function(url){
         window.location =url;
    },
    //初始化加载验证
    this.LoadMost=function(arr,func)
    {
        var array1=arr.split('|');    
        for(var i=0;i<array1.length;i++)
        {
            var array2 = array1[i].split(",");
            if((array2[1].indexOf("txt")!=-1 || array2[1].indexOf("hidden")!=-1) && (array2[0].indexOf("value")!=-1)) //文本框
            {
                map.put(array2[0],pub.getText(array2[1]));
            }else if((array2[1].indexOf("ddl")!=-1) && (array2[0].indexOf("value")!=-1)){ //下拉框
                map.put(array2[0],pub.getSelect(array2[1]));
            }else if((array2[1].indexOf("rb")!=-1) && (array2[0].indexOf("value")!=-1)){ //单选框
                map.put(array2[0],pub.getRadio(array2[1]));
            }else{
                map.put(array2[0],array2[1]);
            }
        }
        return func.Validate(map);
    },
    //标签验证
    this.TagMode = function(value,mss)
    {
        var obj=$(mss);
        if(value==""){
             obj.innerHTML="请还没输入标签，请选择1-5个标签：）";
             return false;
        }else{
           value=value.replace(/，/g,",");
           var tags=value.split(',');
           if(tags.length > 5){
             obj.innerHTML="您选择的标签太多了，标签最多只能输入1-5个哦：）";
             return false;
           }else if(tags.length <= 5){
              var error= 0;
              for(var i=0;i<tags.length;i++)
              {
                 if(pub.fucCheckLength(tags[i]) > 10 &&  error == 0)
                 {
                    error = 1;
                 }
                 else if(pub.fucCheckLength(tags[i]) == 0 && error == 0)
                 {
                    error = 2;
                 }
              }
              if(error==1){
                  obj.innerHTML="标签的字数不能多于5个汉字，请核对后调整一下字数吧:）";
              }else if(error == 2){
                  obj.innerHTML="标签中不能有空字符，请核对后调整一下字数吧:）";
              }else{
                  obj.innerHTML="";
                  return true;
              }
              return false;
           }else{
              obj.innerHTML="";
              return true;
           }
        }
    },
    //消息验证
    this.SpanMessage = function(value,obj,min,max,bname)
    {
          var len=value.replace(/[^\x00-\xff]/gi,'xx').length;
          len=len/2; 
          if(pub.Trim(value) == "" && min > 0){
                obj.innerHTML=bname+"不能为空";
                return false;
            }else if(len < min){
             obj.innerHTML="这里不能少于"+min+"个汉字";
             return false;
          }else if(len > max){
             obj.innerHTML="这里不能大于"+max+"个汉字";
             return false;
          }else{
             obj.innerHTML="";
             return true;
          }
    },
    //验证正则方法
    this.RegexText = function(str,reg){
        if (reg.test(str))
        {
            return true;
        }
        return false;
    },
    //添加样式
    this.AddClass = function(obj,classname)
    {
        if(document.all){
            obj.className = classname;
        }else{
            obj.setAttribute("class",classname);
        }
    }
}

var pub=new Public();

/******************************************************************/
//hashmap
function HashMap()
{
     /** Map 大小 **/
        var size = 0;
        /** 对象 **/
        var entry = new Object();
        /** 存 **/
    this.put = function (key , value)
    {
        if(!this.containsKey(key))
        {   
              size ++ ;
        }
        entry[key] = value;
    }
        
    /** 取 **/
    this.get = function (key)
    {
         return this.containsKey(key) ? entry[key] : null;
    }
       
    /** 删除 **/
    this.remove = function ( key )
    {
      if( this.containsKey(key) && ( delete entry[key] ) )
       {
           size --;
       }
    }
        
    /** 是否包含 Key **/
    this.containsKey = function ( key )
    {
        return (key in entry);
    }
        
    /** 是否包含 Value **/
    this.containsValue = function ( value )
    {
       for(var prop in entry)
       {
           if(entry[prop] == value)
           {
                return true;
           }
       }
       return false;
    }
     
    /** 所有 Value **/
    this.values = function ()
    {
       var values = new Array();
       for(var prop in entry)
       {
            values.push(entry[prop]);
       }
       return values;
    }
        
         /** 所有 Key **/
    this.keys = function ()
    {
        var keys = new Array();
        for(var prop in entry)
         {
            keys.push(prop);
        }
        return keys;
    }
        
    /** Map Size **/
     this.size = function ()
     {
         return size;
     }
     
    /* 清空 */
    this.clear = function ()
    {
         size = 0;
         entry = new Object();
    }
}

var map = new HashMap();

/*****************************************************************/
// JScript 文件
var back={
	blind:function(blindId,zIndex,bg,limit){//新建一个蒙板，遮住页面内容。id,bg背景,z层级,limit度数
		var scroll=document.documentElement,height=scroll.scrollHeight>document.documentElement.clientHeight?scroll.scrollHeight:document.documentElement.clientHeight;
		if(!$(blindId)){
		    var obj=document.createElement("div");
		    var iframe=document.createElement("iframe");
		    obj.id=blindId;
		    
		    iframe.id="iframe"+blindId;
		    obj.style.zIndex=zIndex;
		    iframe.style.zIndex=zIndex-1;
		    obj.style.background=bg;
		    iframe.style.width="100%";
		    obj.style.width='100%';
		    if(!/msie 6.0/i.test(navigator.userAgent)){
		        obj.style.height="100%";
		        obj.style.position="fixed";
		        iframe.style.height="100%";
		    }
		    else{
		        obj.style.position="absolute";
		        var pageheight = document.documentElement.scrollHeight;
		        var showheight = document.documentElement.clientHeight;
		        if(pageheight > showheight){
		             obj.style.height=pageheight + "px";
		             iframe.style.height=pageheight + "px";
		        }else{
		             obj.style.height=showheight + "px";
		             iframe.style.height=showheight + "px";
		        }
		        
		       
		    }
		    obj.style.left="0px";
		    iframe.style.left="0px";
		    obj.style.top="0px";
		    iframe.style.top="0px";
		    iframe.style.position="absolute";
			document.body.appendChild(iframe);
			document.body.appendChild(obj);
			this.alpha($(blindId),limit);
			this.alpha($("iframe"+blindId),limit);
		}else{

			var blin=$("iframe"+blindId).style;	
			blin.display='block';
			blin.height=height+'px';	
			blin.width=scroll.scrollWidth+'px';	
			var blin1=$(blindId).style;
			blin1.display='block';
			blin1.height=height+'px';	
			blin1.width=scroll.scrollWidth+'px';	
		}
	}
	,close:function(blindId){
	    if($("iframe"+blindId))$("iframe"+blindId).style.display="none";
	    if($(blindId))$(blindId).style.display="none";
	}
	,$:function(id){return document.getElementById(id)}//获取对象
	,alpha:function(o,num){//设置透明度	
		o.style.filter='alpha(opacity='+num+')';
		o.style.opacity=num/100;
	}
}

/****************************************************************/
//验证类
var Verify=function()
{
    //验证邮件格式
    this.visbledEmail=function(email)
    {
        var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if(!myreg.test(email))
        {
           return false;
        }
        return true;
    }
    ,
    //中文格式验证
    this.isChinese=function(str){
        var reg=/[^\u000-\u00ff]/g;
        return reg.test(str)
    }
}
var ver=new Verify();

!function (bool){
	//兼容FF一些方法
	if (bool){
		window.constructor.prototype.__defineGetter__("event", function (){//兼容Event对象
			var o=arguments.callee;
			do{
				if (o.arguments[0] instanceof Event)return o.arguments[0];
			}while (o=o.caller);
			return null;
		});
	}
}(/Firefox/.test(window.navigator.userAgent));
if (window.HTMLElement && !HTMLElement.prototype.insertAdjacentHTML)
HTMLElement.prototype.insertAdjacentHTML = function (sWhere, sHTML) {
//BlueDestiny
    var df; var r = this.ownerDocument.createRange();
    switch (String(sWhere).toLowerCase()) {
        case "beforebegin":
            r.setStartBefore(this);
            df = r.createContextualFragment(sHTML);
            this.parentNode.insertBefore(df, this);
            break;
        case "afterbegin":
            r.selectNodeContents(this);
            r.collapse(true);
            df = r.createContextualFragment(sHTML);
            this.insertBefore(df, this.firstChild);
            break;
        case "beforeend":
            r.selectNodeContents(this);
            r.collapse(false);
            df = r.createContextualFragment(sHTML);
            this.appendChild(df);
            break;
        case "afterend":
            r.setStartAfter(this);
            df = r.createContextualFragment(sHTML);
            this.parentNode.insertBefore(df, this.nextSibling);
            break;
    }
};

!function (bool){
	//兼容FF一些方法
	if (bool){
		//event
		window.constructor.prototype.__defineGetter__("event", function (){//兼容Event对象
			var o=arguments.callee;
			do{
				if (o.arguments[0] instanceof Event)return o.arguments[0];
			}while (o=o.caller);
			return null;
		});
		//outerHTML
		HTMLElement.prototype.__defineGetter__("outerHTML",function() 
		{ 
			var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
			if(a[i].specified) 
				str+=" "+a[i].name+'="'+a[i].value+'"'; 
			if(!this.canHaveChildren) 
				return str+" />"; 
			return str+">"+this.innerHTML+"</"+this.tagName+">"; 
		}); 
		HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
		{ 
			var r = this.ownerDocument.createRange(); 
			r.setStartBefore(this); 
			var df = r.createContextualFragment(s); 
			this.parentNode.replaceChild(df, this); 
			return s; 
		}); 
		HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
		{ 
			return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
		}); 
		//
	}
	
}(/Firefox/.test(window.navigator.userAgent));
if (window.HTMLElement && !HTMLElement.prototype.insertAdjacentHTML)
HTMLElement.prototype.insertAdjacentHTML = function (sWhere, sHTML) {
//BlueDestiny
    var df; var r = this.ownerDocument.createRange();
    switch (String(sWhere).toLowerCase()) {
        case "beforebegin":
            r.setStartBefore(this);
            df = r.createContextualFragment(sHTML);
            this.parentNode.insertBefore(df, this);
            break;
        case "afterbegin":
            r.selectNodeContents(this);
            r.collapse(true);
            df = r.createContextualFragment(sHTML);
            this.insertBefore(df, this.firstChild);
            break;
        case "beforeend":
            r.selectNodeContents(this);
            r.collapse(false);
            df = r.createContextualFragment(sHTML);
            this.appendChild(df);
            break;
        case "afterend":
            r.setStartAfter(this);
            df = r.createContextualFragment(sHTML);
            this.parentNode.insertBefore(df, this.nextSibling);
            break;
    }
};

/*自定义函数*/
var bit={};
bit.base={
	$:function(id){return document.getElementById(id)}//获取对 ID 标签属性为指定值的第一个对象的引用
	,tagArr:function(o,name){return o.getElementsByTagName(name)}//获取基于指定元素名称的对象集合
	,nameArr:function(name){return document.getElementsByName(name)}//根据 NAME 标签属性的值获取对象的集合
	,att:function(o,name,fun){return document.all ? o.attachEvent(name,fun) : o.addEventListener(name.substr(2),fun,false);}//给指定元素添加事件attachEvent方法
	,style:function(o){	//获取全局样式表、内嵌样式（不能设置）
		return o.currentStyle || document.defaultView.getComputedStyle(o,null);
	}
	,documentElement:function(type){//兼容DTD头
		return	document.documentElement[type] || document.body[type];
	}
	,dElement:function(){//兼容DTD头
		return	document.documentElement || document.body;
	}
	,offset:function(o,type){//元素相对于整个窗口的位置 o对象 type类型
		var intVlue=0;
		var ffObj=o[type];
		while(document.body!=o)
		{		
			intVlue+=o[type];
			o=o.parentNode;
		}
		if(document.all){
			return intVlue;
		}else{
			return ffObj;
		}
	}
	,offsetLT:function(o){//元素相对于整个窗口的位置 o对象 返回 x y
        var x = 0, y = 0;
        do { x += o.offsetLeft, y += o.offsetTop; } while (o = o.offsetParent);
        return { 'x' : x, 'y' : y };
    }
	,position:function(){//获取当前鼠标位置(x,y)
		return {
		'x':event.pageX || (event.clientX + this.documentElement('scrollLeft'))
		,'y':event.pageY || (event.clientY + this.documentElement('scrollTop'))
		}
	}
	,alpha:function(o,num){//设置透明度	
		o.style.filter='alpha(opacity='+num+')';
		o.style.opacity=num/100;
	}


	,buildTag:function(id,tagName,arr,object){//循环生成标签，附加标签样式
		var obj=document.createElement(tagName);
		if(id){obj.id=id;}
		if(arr){
			for(i=0;i<arr.length;i++){
				obj.style[arr[i][0]]=arr[i][1];
			}
		}
		object.appendChild(obj);
	}
	,selectFun:function(num){//选择 || 取消选择  ie
		document.onselectstart=num ? function(){ return true} : function(){ return false};
	}
	,capture:function(obj,num){
		if(document.all){
			num?obj.setCapture():obj.releaseCapture();
		}	
	}
	,cleanOutSelect:function(){
		try {
			document.selection.empty();
		} catch (exp) {
		try {
			window.getSelection().removeAllRanges();
		} catch (exp) {}
		}
	}


};


//拖动层
bit.inTow={};

//底层拖拽函数
bit.inTow.fun={//鼠标拖拽 top:vertical left:horizontal top&&left:both
	on:false,top:0,left:0,obj:null,placeLeft:0,placeRight:0,placeTop:0,placeBottom:0,type:null
	,base:null
	,load:function(){
		this.base=bit.base;
		var pro=this;
		var moveFun=function(){if(pro.on){pro.onMove()};};
		var upFun=function(){pro.up()};
		this.base.att(document,'onmousemove',moveFun);
		this.base.att(document,'onmouseup',upFun);//releaseCapture();this.base.selectFun(1);
		moveFun=null;
		upFun=null;
	}
	,down:function(type,o,left,right,top,bottom){
		this.type=type;
		this.base.capture(o,1);
		this.placeLeft=left;//范围:左边
		this.placeRight=right;//范围:右边
		this.placeTop=top;//范围:顶部
		this.placeBottom=bottom;//范围:底部
		this.obj=o;
		this.top=this.base.position().y-o.offsetTop;
		this.left=this.base.position().x-o.offsetLeft;
		this.on=true;
	}
	,onMove:function(){
	    this.base.cleanOutSelect();
		var y=this.base.position().y-this.top,x=this.base.position().x-this.left;
		if(y<this.placeTop){y=this.placeTop};
		if(y>this.placeBottom){y=this.placeBottom};
		if(x<this.placeLeft){x=this.placeLeft};
		if(x>this.placeRight){x=this.placeRight};
		switch (this.type) {
			case 'vertical' : this.obj.style.top=y+"px";break;
			case 'horizontal' : this.obj.style.left=x+"px";break;
			case 'both' : this.obj.style.top=y+"px";this.obj.style.left=x+"px";break;
		} 	
	}
	,up:function(){
		this.on=false;
		if(this.obj){this.base.capture(this.obj,0);}	
	}
};

//基础拖拽的变种-移动式
bit.inTow.move={
	n:0,speed:0,loop:null,parent:null,object:null
	,base:null,on:false
	,load:function(){
		this.base=bit.base;
		var pro=this;
		bit.inTow.fun.load();
		this.base.att(document,'onmouseup',function(){if(pro.on)pro.up();});
	}
	,down:function(obj,id,n,speed,css){
		var parent=obj.parentNode;
		var style=this.base.style(parent);
		var object=this.base.$(id);
		if(!object){
			this.base.buildTag(id,'div',null,document.body);
			object=this.base.$(id);			
		}else{			
			object.style.display='block';	
		}
		object.className=css;
		this.base.alpha(object,60);
		object.style.width=style.width;
		object.style.height=parent.offsetHeight+'px';
		object.style.left=this.base.offsetLT(parent).x+'px';
		object.style.top=this.base.offsetLT(parent).y+'px';
		object.style.zIndex=style.zIndex+1;
		this.n=n;
		this.speed=speed;
		this.parent=parent;
		this.object=object;
		bit.inTow.fun.down('both',this.base.$(id),0,(this.base.dElement().clientWidth-parseInt(style.width)),0,(this.base.dElement().scrollHeight-parseInt(style.height)));
		this.on=true;
	}
	,up:function(){
		clearTimeout(this.loop);
		var style=this.base.style(this.object);
		this.play(parseInt(style.left),parseInt(style.top),this.parent,null);
		this.object.style.display='none';
		this.on=false;
	}
	,play:function(x,y,obj,fun){
		var pro=this,maxX=x,maxY=y,left=0,top=0,le=0,t=0;
		left=parseInt(this.base.offsetLT(obj).x);
		top=parseInt(this.base.offsetLT(obj).y);
		le=(maxX-left)*0.01*this.n;
		t=(maxY-top)*0.01*this.n;
		le=(le>0 && le<1)?1:le;
		t=(t>0 && t<1)?1:t;
		obj.style.left=left+le+'px';
		obj.style.top=top+t+'px';
		if(left==(maxX) && top==(maxY)){
			if(fun){fun();}
			return;
		}
		this.loop=setTimeout(function(){pro.play(x,y,obj,fun)},this.speed)
	}
};


 