var i,s,w,my={};my.drag={x:0,y:0};function placeitMain(){glevel=12;gdt=24;gboardwidth=400;gcolor=new Array();gleft=20;gtop=20;gdrag=false;gcellid="";a="";gblocks="";gzmax=0;var s='';s+='
';s+='
Recreate the square from the crazy pieces...
';s+='Choose No. of Pieces: ';s+=' ';s+='';s+='
';s+='
';s+=' ';s+='';s+='';s+='
Drag the pieces onto the square using the mouse...
';s+='';s+='
';s+='
';s+=optPopHTML();document.write(s);populateColor();var div=document.body;div.addEventListener('mousemove',onMouseMove);div.addEventListener('mouseup',onMouseUp);div.addEventListener('touchmove',onTouchMove,false);div.addEventListener('touchend',onTouchEnd,false);}
function storeBlocks(){var i;gblocks=new Array(glevel);for(i=0;ithis.right)this.right=c.right;if(c.bottom>this.bottom)this.bottom=c.bottom;k++;}}
this.width=this.right-this.left;this.height=this.bottom-this.top;}
function clsCell(num,index){var c;this.id="a"+index;c=eval(this.id);this.block=num;this.object=c;this.id=c.id;this.left=c.style.pixelLeft;this.top=c.style.pixelTop;this.right=c.style.pixelRight;this.bottom=c.style.pixelBottom;this.x=c.style.pixelLeft;this.y=c.style.pixelTop;this.z=c.style.zIndex;}
function populateColor(){var r,g,b,l,n;var arr=new Array("cc","33","ff");l=arr.length;n=0;for(r=0;rglevel-1)nx=glevel-1;n=y*glevel+x+nx;if(a[n]==-1)a[n]=a[cn];}
ny=unit();if(ny!=0){if(y+ny<0)ny=0;else if(y+ny>glevel-1)ny=glevel-1;n=(y+ny)*glevel+x;if(a[n]==-1)a[n]=a[cn];}}
function shuffle(){for(i=0;i';}
gzmax=glevel;board.style.width=(glevel*gdt)+'px';board.style.height=(glevel*gdt)+'px';board.innerHTML=s;}
function quitGame(){divSub.style.display="none";divMain.style.display="block";}
function optPopHTML(){var s='';s+='
';s+='
';s+='
';s+='Success!';s+='
';s+='
';s+='You have done it!';s+='
';s+='
';s+='Play Again?';s+='
';s+='
';s+='
';s+='';s+='';s+='
';s+='
';return s;}
function optPop(){var wd=300;var ht=100;var pop=document.getElementById('optpop');pop.style.transitionDuration="0.3s";pop.style.opacity=1;pop.style.zIndex=100;var width=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width;var height=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;pop.style.left=((width/2)-(wd/2))+'px';pop.style.top=((height/2)-(ht/2)+50)+'px';}
function optYes(){var pop=document.getElementById('optpop');pop.style.opacity=0;pop.style.zIndex=1;pop.style.left='-999px';createBlocks();}
function optNo(){var pop=document.getElementById('optpop');pop.style.opacity=0;pop.style.zIndex=1;pop.style.left='-999px';quitGame();}
Array.prototype.add=ArrayAdd;function ArrayAdd(val){this[this.length]=val;}