function move(div)
{
document.onmousedown = function() {return false}
div.style.cursor = 'move';
document.onmousemove = function(e)
{
e=e||window.event;
if(e.pageX == null)
{
var html = document.documentElement
var body = document.body
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
}
x = e.pageX;
left = div.offsetLeft;
left = x - left;
var shelf = document.getElementById('shelf');
var slide = div.offsetWidth / 2;
var id = 0;
var bookId;
var tmp = 0;
var move = 0;
document.onmousemove = function(e)
{
e=e||window.event;
if(e.pageX == null)
{
var html = document.documentElement
var body = document.body
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
}
div.style.zIndex = 100;
x = e.pageX;
div.style.left = x - left + 'px';
toolTip(0);
var book1 = document.getElementById('book1').offsetLeft;
var book2 = document.getElementById('book2').offsetLeft;
var book3 = document.getElementById('book3').offsetLeft;
var book4 = document.getElementById('book4').offsetLeft;
if(div.offsetLeft <= shelf.offsetLeft + 5)
div.style.left = shelf.offsetLeft + 5 + 'px';
if(div.offsetLeft + div.offsetWidth >= shelf.offsetLeft + shelf.offsetWidth - 5)
div.style.left = shelf.offsetLeft + shelf.offsetWidth - div.offsetWidth - 5 + 'px';
//book1////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(div.offsetLeft + slide > book1 + slide && div.offsetLeft + slide < book1 + slide + 5) tmp = 1;
if(div.offsetLeft + slide < book1 + slide && div.offsetLeft + slide > book1 + slide - 5) tmp = 2;
if(div.offsetLeft + slide > book1 + slide + 5 && div.offsetLeft + slide < book1 + slide + 10 && tmp == 1)
{id = 1; bookId = 'book'+id; move = 1;}
if(div.offsetLeft + slide < book1 + slide - 5 && div.offsetLeft + slide > book1 + slide - 10 && tmp == 2)
{id = 1; bookId = 'book'+id; move = 1;}
//book2////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(div.offsetLeft + slide > book2 + slide && div.offsetLeft + slide < book2 + slide + 5) tmp = 1;
if(div.offsetLeft + slide < book2 + slide && div.offsetLeft + slide > book2 + slide - 5) tmp = 2;
if(div.offsetLeft + slide > book2 + slide + 5 && div.offsetLeft + slide < book2 + slide + 10 && tmp == 1)
{id = 2; bookId = 'book'+id; move = 1;}
if(div.offsetLeft + slide < book2 + slide - 5 && div.offsetLeft + slide > book2 + slide - 10 && tmp == 2)
{id = 2; bookId = 'book'+id; move = 1;}
//book3////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(div.offsetLeft + slide > book3 + slide && div.offsetLeft + slide < book3 + slide + 5) tmp = 1;
if(div.offsetLeft + slide < book3 + slide && div.offsetLeft + slide > book3 + slide - 5) tmp = 2;
if(div.offsetLeft + slide > book3 + slide + 5 && div.offsetLeft + slide < book3 + slide + 10 && tmp == 1)
{id = 3; bookId = 'book'+id; move = 1;}
if(div.offsetLeft + slide < book3 + slide - 5 && div.offsetLeft + slide > book3 + slide - 10 && tmp == 2)
{id = 3; bookId = 'book'+id; move = 1;}
//book4////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(div.offsetLeft + slide > book4 + slide && div.offsetLeft + slide < book4 + slide + 5) tmp = 1;
if(div.offsetLeft + slide < book4 + slide && div.offsetLeft + slide > book4 + slide - 5) tmp = 2;
if(div.offsetLeft + slide > book4 + slide + 5 && div.offsetLeft + slide < book4 + slide + 10 && tmp == 1)
{id = 4; bookId = 'book'+id; move = 1;}
if(div.offsetLeft + slide < book4 + slide - 5 && div.offsetLeft + slide > book4 + slide - 10 && tmp == 2)
{id = 4; bookId = 'book'+id; move = 1;}
var book = document.getElementById(bookId).offsetLeft;
if(move == 1)
{
if(tmp == 1)
{
var i = book;
if(book - shelf.offsetLeft + 5 >= div.offsetWidth + 20)
var j = book - div.offsetWidth + 20;
else
{
if(book - shelf.offsetLeft + 5 < div.offsetWidth + 20)
var j = shelf.offsetLeft + 4;
}
}
else
{
if(tmp == 2)
{
var i = book;
if(shelf.offsetLeft + shelf.offsetWidth - book - 5 >= div.offsetWidth + 20)
var j = book + div.offsetWidth - 20;
else
{
if(shelf.offsetLeft + shelf.offsetWidth - book - 5 < div.offsetWidth + 20)
var j = shelf.offsetLeft + shelf.offsetWidth - div.offsetWidth - 4;
}
}
}
if(j > shelf.offsetLeft + shelf.offsetWidth - div.offsetWidth - 4)
j = shelf.offsetLeft + shelf.offsetWidth - div.offsetWidth - 4;
t1A = new Tween(document.getElementById(bookId).style,'left',Tween.strongEaseOut,i,j,0.5,'px');
t1A.start();
tmp = 0;
move = 0;
}
}
}
}