Tanks, this works perfectly.
And by adding +, -, / or * in the end of line 10 to 13, I could adjust the shape of the box.
Ex :
top = Math.min(ul1[1], ul2[1]) – margin-10;
bottom = Math.max(lr1[1], lr2[1]) + margin+15;
left = Math.min(ul1[0], ul2[0]) – margin-60;
right = Math.max(lr1[0], lr2[0]) + margin+60;
By adding round corners, Color Emboss and a texture, this is the final :