//Postit-JavaScriptDocument
//CopyRight(c) http://www.pixib.net/ All Rights Reserved.
//二次利用・二次配布禁止
//E-mail: next1249@yahoo.co.jp :: Japanese Only
CV.prototype.GetLeft=function(B){var A=0;while(B){A+=B.offsetLeft;B=B.offsetParent;}return A;};CV.prototype.GetTop=function(B){var A=0;while(B){A+=B.offsetTop;B=B.offsetParent;}return A;};CV.prototype.getMousePoint=function(B){var A=new Object();if(B){A.x=B.pageX;A.y=B.pageY;}else{A.x=event.x+document.body.scrollLeft;A.y=event.y+document.body.scrollTop;}return A;};CV.prototype.EC=function(F,B,A,G,E,D){var C=document.createElement("div");C.id=F;C.style.zIndex=E;C.style.backgroundRepeat="no-repeat";C.style.backgroundImage="url("+B+")";C.style.overflow="hidden";C.style.position="absolute";C.style.margin=G+"px 0 0 "+A+"px";switch(D){case 1:C.style.width="146px";C.style.height="146px";break;case 2:C.style.width="25px";C.style.height="181px";break;case 3:C.style.width="146px";C.style.height="146px";break;case 4:C.style.width="181px";C.style.height="25px";break;case 5:C.style.width="146px";C.style.height="146px";break;case 6:C.style.width="25px";C.style.height="181px";break;case 7:C.style.width="146px";C.style.height="146px";break;default:C.style.width="181px";C.style.height="25px";break;}this.canvas.appendChild(C);};CV.prototype.EM=function(D,A,E,C){var B=document.getElementById(D);B.style.margin=E+"px 0 0 "+A+"px";B.style.zIndex=C;};CV.prototype.OM=function(B,A,D,C){img_obj[B].xxx=A;img_obj[B].yyy=D;img_obj[B].zzz=C;};function BF(B,C,A,E,D){this.i=B;this.e_id=C;this.x=A;this.y=E;this.z=D;}CV.prototype.MV=function(){var A=this;this.active=false;A.canvas.onmousedown=function(F){if(A.active==false){var B=A.GetLeft(A.canvas);var I=A.GetTop(A.canvas);var H=A.getMousePoint(F).x;var G=A.getMousePoint(F).y;var D=H-B;var C=G-I;if(D<A.cw&&C<A.ch&&D>0&&C>0){for(var E=0;E<img_obj.length;E++){if(A.active==false){switch(img_obj[E].aaa){case 3:if((img_obj[E].xxx+111)<D&&D<(img_obj[E].xxx+145)&&img_obj[E].yyy<C&&C<(img_obj[E].yyy+34)){A.canvas.style.cursor="pointer";buffer=new BF(E,img_obj[E].e_id,(img_obj[E].xxx-D),(img_obj[E].yyy-C),img_obj[E].zzz);A.active=true;}else{}break;case 4:if((img_obj[E].xxx+147)<D&&D<(img_obj[E].xxx+181)&&img_obj[E].yyy<C&&C<(img_obj[E].yyy+34)){A.canvas.style.cursor="pointer";buffer=new BF(E,img_obj[E].e_id,(img_obj[E].xxx-D),(img_obj[E].yyy-C),img_obj[E].zzz);A.active=true;}else{}break;case 5:if((img_obj[E].xxx+111)<D&&D<(img_obj[E].xxx+145)&&(img_obj[E].yyy+111)<C&&C<(img_obj[E].yyy+145)){A.canvas.style.cursor="pointer";buffer=new BF(E,img_obj[E].e_id,(img_obj[E].xxx-D),(img_obj[E].yyy-C),img_obj[E].zzz);A.active=true;}else{}break;case 6:if(img_obj[E].xxx<D&&D<(img_obj[E].xxx+34)&&(img_obj[E].yyy+147)<C&&C<(img_obj[E].yyy+181)){A.canvas.style.cursor="pointer";buffer=new BF(E,img_obj[E].e_id,(img_obj[E].xxx-D),(img_obj[E].yyy-C),img_obj[E].zzz);A.active=true;}else{}break;case 7:if(img_obj[E].xxx<D&&D<(img_obj[E].xxx+34)&&(img_obj[E].yyy+111)<C&&C<(img_obj[E].yyy+145)){A.canvas.style.cursor="pointer";buffer=new BF(E,img_obj[E].e_id,(img_obj[E].xxx-D),(img_obj[E].yyy-C),img_obj[E].zzz);A.active=true;}else{}break;case 0:case 1:case 2:default:if(img_obj[E].xxx<D&&D<(img_obj[E].xxx+34)&&img_obj[E].yyy<C&&C<(img_obj[E].yyy+34)){A.canvas.style.cursor="pointer";buffer=new BF(E,img_obj[E].e_id,(img_obj[E].xxx-D),(img_obj[E].yyy-C),img_obj[E].zzz);A.active=true;}else{}break;}}}}}};A.canvas.onmousemove=function(E){var B=A.GetLeft(A.canvas);var H=A.GetTop(A.canvas);var G=A.getMousePoint(E).x;var F=A.getMousePoint(E).y;var D=G-B;var C=F-H;if(A.active==true&&D<(A.cw-10)&&C<(A.ch-10)&&D>10&&C>10){A.EM(buffer.e_id,(buffer.x+D),(buffer.y+C),buffer.z);A.OM(buffer.i,(buffer.x+D),(buffer.y+C),buffer.z);A.canvas.style.cursor="pointer";}};A.canvas.onmouseup=function(B){delete buffer;A.canvas.style.cursor="move";A.active=false;};};CV.prototype.PM=function(){for(var A=0;A<img_obj.length;A++){this.EC(img_obj[A].e_id,img_obj[A].url,img_obj[A].xxx,img_obj[A].yyy,img_obj[A].zzz,img_obj[A].aaa);}};CV.prototype.ST=function(){this.canvas=document.getElementById("canvas");this.cw=parseInt(this.canvas.style.width);this.ch=parseInt(this.canvas.style.height);};function CV(){this.ST();this.PM();this.MV();}window.onload=function WO(){new CV();};
