var panareawidth = 0; var panareaheight = 0; var panimagewidth = 0; var panimageheight = 0; var panimageoffsetx = 0; var panimageoffsety = 0; var panimagecenterx = 0; var panimagecentery = 0; var panposx = 0; var panposy = 0; var panliftx = 0; var panlifty = 0; var panelex = 0; var paneley = 0; var panpandragobj = null; var whichelem; function pannocascade() { return false; } function initimagepan(objectId) { whichelem = objectId; if ($("panarea_"+ whichelem)){ panareawidth = $("panarea_"+ whichelem).style.width; panareawidth = panareawidth.replace(/px/,""); panareaheight = $("panarea_"+ whichelem).style.height; panareaheight = panareaheight.replace(/px/,""); panimagewidth = $('panimage_'+ whichelem).width; panimageheight = $('panimage_'+ whichelem).height; } else { alert ("Please do not forget to wrap a contrainer around your pandrag objects"); } document.onmousemove = panupdate; panupdate(); } function panupdate(e) { panpositionnow(e); } function panpositionnow(e) { if (!e){ var e = window.event; } if (e){ if (e.pageX || e.pageY){ panposx = e.pageX; panposy = e.pageY; algor = '[e.pageX]'; } else { if (e.clientX || e.clientY){ panposx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; panposy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; algor = '[e.clientX]'; if (e.pageX || e.pageY) algor += '[e.pageX]'; } } } } function panme(origObj) { document.onmousedown = pannocascade; panpandragobj = new Object(origObj); panpandragobj.style.zIndex = 1; document.onmousemove = pandrag; document.onmouseup = pandrop; panliftx = panposx; panlifty = panposy; panelex = orix = $('panimage_'+ whichelem).offsetLeft; paneley = oriy = $('panimage_'+ whichelem).offsetTop; panupdate(); } function pandrag(e) { panimageoffsetx = $('panimage_'+ whichelem).offsetLeft; panimageoffsety = $('panimage_'+ whichelem).offsetTop; if (panpandragobj) { panelex = orix + (panposx-panliftx); paneley = oriy + (panposy-panlifty); panpandragobj.style.position = "absolute"; var maxpanx = (panimagewidth - panareawidth) * -1; var maxpany = (panimageheight - panareaheight) * -1; if (panelex <= 0 && panelex > maxpanx) { panpandragobj.style.left = (panelex).toString(10) + 'px'; } if (paneley <= 0 && paneley > maxpany) { panpandragobj.style.top = (paneley).toString(10) + 'px'; } } panupdate(e); return false; } function pandrop() { panupdate(); panpandragobj.style.zIndex = 0; document.onmousemove = panupdate; document.onmouseup = null; document.onmousedown = null; }