<html>
<head>
  <title>Point mapping through 3D transforms</title>
  <script src="point-mapping-helpers.js" type="text/javascript" charset="utf-8"></script>
  
  <script type="text/javascript" charset="utf-8">
    
    function test()
    {
      dispatchEvent(44, 44, 'box1', 2, 2);
      dispatchEvent(69, 55, 'box2', 2, 2);
      dispatchEvent(165, 182, 'box2', 96, 96);
      dispatchEvent(333, 79, 'box7', 2, 2);
      dispatchEvent(87, 325, 'box10', 2, 2);
      dispatchEvent(196, 467, 'box10', 98, 98);
      dispatchEvent(333, 325, 'box13', 2, 2);
      dispatchEvent(353, 352, 'box14', 2, 2);
      dispatchEvent(472, 507, 'box14', 97, 97);
    }
    
  </script>
  <style type="text/css" media="screen">
  
    body {
      margin: 0;
      border: 1px solid black;
      cursor: crosshair;
    }

	.one {
      top: 1px;
      left: 1px;
	}
	.two {
      top: 1px;
      left: 247px;
	}
	.three {
      top: 247px;
      left: 1px;
	}
	.four {
      top: 247;
      left: 247px;
	}
	
    .test {
      position: absolute;
      height: 200px;
      width: 200px;
      border: 1px solid black;
      margin: 20px;
    }

    .box {
      height: 100px;
      width: 100px;
      -webkit-box-sizing: border-box;
      background-color: #DDD;
      border: 1px solid black;
    }

    .box:hover {
      outline: 3px solid orange;
    }
    
    .container {
      height: 140px;
      width: 140px;
      margin: 20px;
      border: 1px solid black;
      -webkit-box-sizing: border-box;
      -webkit-perspective: 400;
    }
    
    .transformed {
      position: relative;
      height: 100px;
      width: 100px;
      padding: 20px;
      margin: 20px;
      border: 1px solid black;
      background-color: #AAA;
      -webkit-box-sizing: border-box;
      -webkit-transform: translateZ(100px) rotateY(-40deg);
    }

    .behind {
      position: absolute;
      -webkit-transform: translateZ(110px) rotateY(-40deg);
      background-color: red;
    }

    .layer {
      padding: 20px;
      background-color: #C0D69E;
    }

    .inner {
      background-color: blue;
    }
    
    #results {
      position: absolute;
      left: 30px;
      top: 500px;
    }
    
    #mousepos {
      position: absolute;
      left: 30px;
      top: 700px;
      color: gray;
      font-size: smaller;
    }
  </style>
</head>
<body onclick="clicked(event)">

<div id="results"></div>

<div class="test one">
  <!-- Simple transformed div in perpsective -->
  <div class="container box" id="box1">
    <div class="transformed box behind"></div>
    <div class="transformed box" id="box2">
    </div>
  </div>
</div>

<div class="test two">
  <!-- Transformed div in perpsective with non-layer child -->
  <div class="container box" id="box5">
    <div class="transformed box" id="box6">
      <div class="inner box" id="box7">
      </div>
    </div>
  </div>
</div>

<div class="test three">
  <!-- Transformed div in perpsective with layer child -->
  <div class="container box" id="box8">
    <div class="transformed box" id="box9">
      <div class="inner box" style="position: relative" id="box10">
      </div>
    </div>
  </div>
</div>

<div class="test four">
  <!-- Transformed div in perpsective with child having layer child -->
  <div class="container box" id="box11">
    <div class="transformed box" id="box12">
      <div class="layer box" id="box13">
        <div class="inner box" style="position: relative" id="box14">
        </div>
      </div>
    </div>
  </div>
</div>

<div id="mousepos"></div>

</body>
</html>
