var MoveDiv = function(){};
MoveDiv.Move=function(id)
{    var float_des="float_des"+id;
    var o=document.getElementById(float_des);
    o.onmousedown = function(e) {
	    e = e||window.event;
        var x=e.layerX||e.offsetX;
        var y=e.layerY||e.offsetY;
        x=x-document.body.scrollLeft;
        y=y-document.body.scrollTop;
        document.onmousemove = function(e)
        {
	      e=e||window.event;
            o.style.left=(e.clientX-x);
            o.style.top=(e.clientY-y);
		    o.style.left=e.clientX+document.body.scrollLeft-document.body.clientLeft;
			o.style.top=e.clientY+document.body.scrollTop-document.body.clientTop;
	 
        };
            document.onmouseup=function()
        {
			var pos_left = o.style.left ;
			var pos_top=o.style.top ;
			var pos_left = o.offsetLeft;
			var pos_top=o.offsetTop;
			
		 	//计算红包是否放到了正确的位置Calc.num.value
			var istrue;
			 for (var i=1;i<=Calc.count.value;i++){
 				var box_p="box_place"+i;
  				var goal_pos= document.getElementById(box_p);
				var goal_pos_left=goal_pos.offsetLeft;
				//var goal_pos_top=getabspoint(document.getElementById(box_p));
				 var goal_pos_top=goal_pos.getBoundingClientRect().left;
				 alert(goal_pos_top);
				  alert(pos_top);
				  if(pos_left > goal_pos_left && pos_top > goal_pos_top && ((pos_left - goal_pos_left) <=20) && ((pos_top - goal_pos_top) <=20))
				  {
					document.getElementById(box_p).innerHTML=o.innerText;
					 o.style.display="none";
					 istrue=1;
					 break;
				 }
				 else{ istrue=0; }
			
				 }	
				 
				 if(istrue==1)
				 { if (id<=7){
					 var num=id+1;
					 alert(num);
					 addmove(num);
					 }
		            }
			  else{
				 alert("放的位置不正确，请拖入到提示框内!");
				}
     
		};
    };
}

function  getabspoint(e){
	var x=e.offsetLeft;
	var y=e.offsetTop;
	while (e=e.offsetParent){
	x+=e.offsetLeft;
	y+=e.offsetTop;
		}
		return (y)
		}
		
		
function x_tuo_text(id)
 {    var div_tuo=id;
 	  var des1="float_des"+id;
      var img1="float_img"+id;
	  var box1="box_float"+id;
 	  document.getElementById(des1).style.top=document.getElementById(img1).offsetTop;
	  document.getElementById(des1).style.left=document.getElementById(img1).offsetLeft;
 	  document.getElementById(des1).style.display="block";
	  document.getElementById(img1).style.display="none";
	  
	 }