var IE = document.all?true:false; var tempX = 0; var tempY = 0; var tempAX = 0; var tempAY = 0; var mintempAX = 999999; var mintempAY = 999999; var maxtempAX = 0; var maxtempAY = 0; var clickcount=0; var reloc=0; var moveit=0; var resizeit=0; var overimage=0; var oversquare=0; var AnchorX = 0; var AnchorY = 0; var firstclick=0; var mousestate=0; function do_load_square(){ if (!IE){ document.captureEvents(Event.MOUSEMOVE); document.captureEvents(Event.MOUSEDOWN); document.captureEvents(Event.MOUSEUP); } document.onmousemove = getMouseXY; document.onmousedown = mousestateon; //getMouseXY; document.onmouseup = mousestateoff; //getMouseXY; document.Show.square.height=1; // document.Show.thumbheight.value; document.Show.square.width=1; //document.Show.thumbwidth.value; document.Show.capturewidth.value=document.Show.thumbwidth.value; document.Show.captureheight.value=document.Show.thumbheight.value; document.Show.square.style.pixelTop-=(parseInt(document.Show.imgmap.height/2)+document.Show.thumbheight.value); document.Show.square.style.pixelLeft+=(parseInt(document.Show.imgmap.width/2)-(document.Show.thumbwidth.value/2)); } function mousestateon(){ firstclick=1; document.Show.mousestate.value=1; if(oversquare==1 || overimage==1){ if(moveit==0){ moveit=1; if(overimage==1 && oversquare==0){ resizeit=1; AnchorX=parseInt(tempAX); AnchorY=parseInt(tempAY); document.Show.square.style.pixelTop=tempAY-parseInt(document.Show.imgmap.height)+1; document.Show.captureX.value = document.Show.square.style.pixelLeft=tempAX+1; //-parseInt(document.Show.imgmap.width)-(document.Show.square.height/2); document.Show.captureY.value = parseInt(document.Show.square.style.pixelTop)+parseInt(document.Show.imgmap.height); } } } } function mousestateoff(){ document.Show.mousestate.value=0; moveit=0; resizeit=0; } function do_mousedown_square(){ //position the square var width; if(moveit=='1' && resizeit==0 ){ document.Show.square.style.pixelTop=tempAY-parseInt(document.Show.imgmap.height)-(document.Show.captureheight.value/2); document.Show.captureX.value = document.Show.square.style.pixelLeft=tempAX-(document.Show.capturewidth.value/2); document.Show.captureY.value = parseInt(document.Show.square.style.pixelTop)+parseInt(document.Show.imgmap.height); } if(resizeit==1){ width=parseInt(Math.abs(AnchorX-tempAX)); height=(Math.abs(AnchorX-tempAX)*document.Show.thumbheight.value)/document.Show.thumbwidth.value; document.Show.capturewidth.value=width; document.Show.captureheight.value=height; document.Show.square.width=width; document.Show.square.height=height; if(parseInt(tempAX)>parseInt(AnchorX)){ //right side of anchor if(parseInt(tempAY)>parseInt(AnchorY)){ //quad 3 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height); document.Show.square.style.pixelLeft=AnchorX; document.Show.captureX.value = AnchorX; document.Show.captureY.value = AnchorY; //parseInt(document.Show.imgmap.height); }else{//quad 2 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height)-height; document.Show.square.style.pixelLeft=AnchorX; document.Show.captureX.value = AnchorX; document.Show.captureY.value = AnchorY-height; //parseInt(document.Show.imgmap.height); } }else{ //left side if(parseInt(tempAY)>parseInt(AnchorY)){ //quad 4 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height); document.Show.square.style.pixelLeft=AnchorX-width; document.Show.captureX.value = AnchorX-width; document.Show.captureY.value = AnchorY; //parseInt(document.Show.imgmap.height); }else{//quad 1 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height)-height; document.Show.square.style.pixelLeft=AnchorX-width; document.Show.captureX.value = AnchorX-width; document.Show.captureY.value = AnchorY-height; //parseInt(document.Show.imgmap.height); } } //if (IE) return false; } } function do_mousedown_image(){ //position the square var width; if(resizeit==1){ width=parseInt(Math.abs(AnchorX-tempAX)); height=(Math.abs(AnchorX-tempAX)*document.Show.thumbheight.value)/document.Show.thumbwidth.value; document.Show.capturewidth.value=width; document.Show.captureheight.value=height; document.Show.square.width=width; document.Show.square.height=height; if(parseInt(tempAX)>parseInt(AnchorX)){ //right side of anchor if(parseInt(tempAY)>parseInt(AnchorY)){ //quad 3 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height); document.Show.square.style.pixelLeft=AnchorX; document.Show.captureX.value = AnchorX; document.Show.captureY.value = AnchorY; //parseInt(document.Show.imgmap.height); }else{//quad 2 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height)-height; document.Show.square.style.pixelLeft=AnchorX; document.Show.captureX.value = AnchorX; document.Show.captureY.value = AnchorY-height; //parseInt(document.Show.imgmap.height); } }else{ //left side if(parseInt(tempAY)>parseInt(AnchorY)){ //quad 4 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height); document.Show.square.style.pixelLeft=AnchorX-width; document.Show.captureX.value = AnchorX-width; document.Show.captureY.value = AnchorY; //parseInt(document.Show.imgmap.height); }else{//quad 1 document.Show.square.style.pixelTop=AnchorY-parseInt(document.Show.imgmap.height)-height; document.Show.square.style.pixelLeft=AnchorX-width; document.Show.captureX.value = AnchorX-width; document.Show.captureY.value = AnchorY-height; //parseInt(document.Show.imgmap.height); } } //if (IE) return false; } } function do_oversquare(){ //oversquare=1; } function do_squareout(){ //oversquare=0; } function do_imageout(){ overimage=0; } function do_overimage(){ overimage=1; mintempAX=document.Show.imgmap.offsetLeft; mintempAY=document.Show.imgmap.offsetTop; maxtempAY=document.Show.imgmap.height; maxtempAX=document.Show.imgmap.width; document.Show.square.height=document.Show.captureheight.value; document.Show.square.width=document.Show.capturewidth.value; //if (IE) return false; } function do_overbutton(){ overimage=0; oversquare=0; moveit=0; resizeit=0; } // Main function to retrieve mouse x-y pos.s function getMouseXY(e) { if(mintempAX!=999999){ if (IE) { // grab the x-y pos.s if browser is IE tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { // grab the x-y pos.s if browser is NS tempX = e.pageX; tempY = e.pageY; } tempAX = tempX-mintempAX; tempAY = tempY-mintempAY; // catch possible negative values in NS4 if (tempX < 0){tempX = 0} if (tempY < 0){tempY = 0} // show the position values in the form named Show // in the text fields named MouseX and MouseY if (tempX < mintempAX){tempAX = 0} if (tempY < mintempAY){tempAY = 0} if (tempAX>maxtempAX){tempAX=maxtempAX} if (tempAY>maxtempAY){tempAY=maxtempAY} document.Show.areaposx.value = tempAX; document.Show.areaposy.value = tempAY; document.Show.MouseX.value = tempX; document.Show.MouseY.value = tempY; if(firstclick){ if(tempAX>document.Show.captureX.value && tempAX<(parseInt(document.Show.captureX.value)+parseInt(document.Show.capturewidth.value)) && tempAY>document.Show.captureY.value && tempAY<(parseInt(document.Show.captureY.value)+parseInt(document.Show.captureheight.value)) ){ oversquare=1; }else{ oversquare=0; } } //window.status='rs='+resizeit+' os='+oversquare+' oi='+overimage+' mv='+moveit+'t='+(parseInt(document.Show.captureX.value)+parseInt(document.Show.capturewidth.value)); window.status = 'tempX: ' + tempX + ' tempY: ' + tempY + ' mintempAX: ' + mintempAX + ' mintempAY: ' + mintempAY + ' maxtempAX: ' + maxtempAX + ' maxtempAY: ' + maxtempAY; if (IE) return false; } } function ResetBox(theWidth, theHeight) { document.Show.thumbwidth.value = theWidth; document.Show.capturewidth.value = theWidth; document.Show.thumbheight.value = theHeight; document.Show.captureheight.value = theHeight; document.Show.MouseX.value = 0; document.Show.MouseY.value = 0; document.Show.areaposx.value = 0; document.Show.areaposy.value = 0; document.Show.captureX.value = 0; document.Show.captureY.value = 0; document.Show.mousestate.value = 0; }