﻿
//Main
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3 b;3 c=[0,0];3 7=6.d?e:5;f(7){3 8=[4.g,4.h,6.9.i,6.9.j]}k{3 8=[4.l,4.m,4.n,4.o]}p();3 q=[["#r","#s","#t","#u","#v"],["#w","#x","#y","#z","#A"],["#B","#C","#D","#E","#F"],["#G","#H","#I","#J","#K"],["#L","#M","#N","#O","#P"],["#Q","#R","#S","#T","#U"],["#V","#W","#X","#Y","#Z"]];3 10;3 11,12,13=1,14=1/15;3 16=17 18();3 19=1a;3 1b=5;3 1c,1d,1e;3 1f=5;3 1g=5;3 1h=5;3 1i;3 1j=0;3 1k=0;3 a=0;3 1l=1m.1n*2;3 1o=0;1p();1q();3 1r;',62,90,'|||var|window|false|document|isIE|stage|documentElement||canvas|delta|attachEvent|true|if|screenLeft|screenTop|clientWidth|clientHeight|else|screenX|screenY|innerWidth|innerHeight|getBrowserDimensions|themes|920035|ed145b|f26d7d|f5989d|fcc4c7|32004b|662d91|8560a8|a186be|d6b7f7|790000|9e0b0f|ed1c24|f26c4f|ffa68b|362f2d|534741|736357|998675|c7b299|0b0b0b|464646|898989|b7b7b7|ebebeb|04448d|1a91de|38b5eb|6bddf8|abeff9|65a528|82bc2a|90bf36|afc950|daf996|theme|worldAABB|world|iterations|timeStep|20|walls|new|Array|wall_thickness|200|wallsSetted|bodies|elements|text|createMode|destroyMode|isMouseDown|mouseJoint|mouseX|mouseY|PI2|Math|PI|timeOfLastTouch|init|play|G_vmlCanvasManager'.split('|'),0,{}))
function init() {eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8=1.e(\'8\');1.f=g;1.h=i;1.j=k;1.l=m;n(o){1.4(\'p\',9);1.4(\'q\',a);1.4(\'r\',b)}s{1.5(\'t\',9,6);1.5(\'u\',a,6);1.5(\'v\',b,6)}2=7 w();2.x.c(-3,-3);2.y.c(d.z+3,d.A+3);B=7 C(2,7 D(0,0),E);F();G();',43,43,'|document|worldAABB|200|attachEvent|addEventListener|false|new|canvas|onDocumentTouchStart|onDocumentTouchMove|onDocumentTouchEnd|Set|screen|getElementById|onmousedown|onDocumentMouseDown|onmouseup|onDocumentMouseUp|onmousemove|onDocumentMouseMove|ondblclick|onDocumentDoubleClick|if|isIE|ondragstart|ondrag|ondragend|else|touchstart|touchmove|touchend|b2AABB|minVertex|maxVertex|width|height|world|b2World|b2Vec2|true|setWalls|reset'.split('|'),0,{}))}
function play(){setInterval(loop,25);setInterval(rr,100)}function rr(){if(isIE){if(a!=1){a++;reset()}}}
function reset() {

	if (bodies) {

		for (i = 0; i < bodies.length; i++) {

			var body = bodies[i]
			canvas.removeChild( body.GetUserData().element );
			world.DestroyBody(body);
			body = null;
		}
	}


	theme = themes[ Math.random() * themes.length >> 0 ];
	document.body.style['backgroundColor'] = theme[0];
	var element = document.getElementById('slider');
	element.style['backgroundColor'] = theme[1];

	bodies = new Array();
	elements = new Array();	

	createInstructions();
	
	for(var i = 0; i < 5; i++)
		{
		createBall();
		}
}
function onDocumentMouseDown() {isMouseDown = true;return false;}
function onDocumentMouseUp() {isMouseDown = false;return false;}
function onDocumentMouseMove(event) {eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6(7){1=2.0.3;4=2.0.5}8{1=0.3;4=0.5}',9,9,'event|mouseX|window|clientX|mouseY|clientY|if|isIE|else'.split('|'),0,{}))}
function onDocumentDoubleClick() {reset();}
function onDocumentTouchStart( event ) {eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4(l){4(2.8==1){7.2.9();a 3=b c().d();4(3-6<e){f();g}6=3;h=7.2.5[0].m;i=7.2.5[0].n;j=k}}o{4(2.5.8==1){2.9();a 3=b c().d();4(3-6<e){f();g}6=3;h=2.5[0].p;i=2.5[0].q;j=k}}',27,27,'||event|now|if|touches|timeOfLastTouch|window|length|preventDefault|var|new|Date|getTime|250|reset|return|mouseX|mouseY|isMouseDown|true|isIE|offsetX|offsetY|else|pageX|pageY'.split('|'),0,{}))}
function onDocumentTouchMove( event ) {

	if(event.touches.length == 1) {

		event.preventDefault();
		
		mouseX = event.touches[0].pageX;
		mouseY = event.touches[0].pageY;
	}
}

function onDocumentTouchEnd( event ) {

	if(event.touches.length == 0) {

		event.preventDefault();
		isMouseDown = false;
	}
}



function createInstructions() {eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('e b=r;e 7=i.s(\'j\');7.x=b;7.y=b;7.6.t=\'z\';7.6.u=-g+\'k\';7.6.v=-g+\'k\';7.6.K="L";7.6.M=\'N\';w.l(7);O.A(7);e 9=i.s(\'w\');9.x=b;9.y=b;i.P("w").l(9);Q(R B!="S"){B.T(9)}e d=9.U(\'V\');d.W=h[3];d.X();d.Y(b*.5,b*.5,b*.5,0,Z,10);d.11();d.12();d.13();7.l(9);8=i.s(\'j\');8.14=15;8.16=\'<m 6="n:\'+h[0]+\';C-b:17;">18!</m><c /><c /><m 6="n:\'+h[1]+\'!D;C-b:19;"><E 6="n:\'+h[1]+\'!D;">1a 1b 1c 1d 1e:</E><c /><c />1. 1f a 1g.<c />2.&o;1h&o;1i&o;1j&o;1k.<c />3. 1l 1m 1n.<c />4. 1o 1p.<c />5. 1q!</m><a 1r="1s://F.1t" 1u="" 1v=""><j 1w="F-1x"></j></a>\';8.6.n=h[1];8.6.t=\'z\';8.6.u=\'G\';8.6.v=\'G\';8.6.1y=\'1z\';8.6.1A=\'1B\';7.l(8);8.6.u=((r-8.1C)/2)+\'k\';8.6.v=((r-8.1D)/2)+\'k\';e f=H 1E();e 9=H 1F();9.1G=b/2;9.1H=1;9.1I=0.3;9.1J=0.3;f.1K(9);f.1L={7:7};f.t.I(p.q()*1M[2],p.q()*-g);f.1N.I(p.q()*J-g,p.q()*J-g);1O.A(1P.1Q(f));',62,115,'||||||style|element|text|circle||size|br|graphics|var|b2body|200|theme|document|div|px|appendChild|span|color|nbsp|Math|random|250|createElement|position|left|top|canvas|width|height|absolute|push|G_vmlCanvasManager|font|Important|strong|khatana|0px|new|Set|400|cursor|default|zIndex|100|elements|getElementById|if|typeof|undefined|initElement|getContext|2d|fillStyle|beginPath|arc|PI2|true|closePath|fill|save|onSelectStart|null|innerHTML|40px|Hello|15px|This|is|how|it|works|Drag|ball|Click|on|the|background|Shake|your|browser|Double|click|Play|href|http|in|title|alt|id|logo|fontFamily|Georgia|textAlign|center|clientWidth|clientHeight|b2BodyDef|b2CircleDef|radius|density|friction|restitution|AddShape|userData|stage|linearVelocity|bodies|world|CreateBody'.split('|'),0,{}))}
function createBall(x,y) {eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=(x!=h)?x:9.a()*t[2];7 y=(y!=h)?y:9.a()*-e;7 8=(9.a()*u>>0)+v;7 6=j.w("f");6.z=8;6.A=8;6.g[\'k\']=\'B\';6.g[\'C\']=-e+\'l\';6.g[\'D\']=-e+\'l\';j.E("f").m(6);F(G n!="H"){n.I(6)}7 b=6.J("K");7 o=9.a()*10>>0;L(7 i=8;i>0;i-=(8/o)){b.M=N[(9.a()*4>>0)+1];b.O();b.P(8*.5,8*.5,i*.5,0,Q,R);b.S();b.T()}f.m(6);U.p(6);7 c=q V();7 d=q W();d.X=8>>1;d.Y=1;d.Z=0.3;d.11=0.3;c.12(d);c.13={6:6};c.k.r(x,y);c.14.r(9.a()*s-e,9.a()*s-e);15.p(16.17(c));',62,70,'||||||element|var|size|Math|random|graphics|b2body|circle|200|canvas|style|null||document|position|px|appendChild|G_vmlCanvasManager|num_circles|push|new|Set|400|stage|100|20|createElement|||width|height|absolute|left|top|getElementById|if|typeof|undefined|initElement|getContext|2d|for|fillStyle|theme|beginPath|arc|PI2|true|closePath|fill|elements|b2BodyDef|b2CircleDef|radius|density|friction||restitution|AddShape|userData|linearVelocity|bodies|world|CreateBody'.split('|'),0,{}))}
function loop() {eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8(E){8(g())h();2[0]+=(0-2[0])*.5;2[1]+=(0-2[1])*.5;7.a.x=0+2[0];7.a.y=j+2[1];k();7.l(m,n);o(i=0;i<b.p;i++){9 4=b[i];9 3=q[i];3.6.r=(4.c.x-(3.s>>1))+\'d\';3.6.t=(4.c.y-(3.u>>1))+\'d\';8(3.v==\'w\'){z=(4.A*B.C);D(e,z,1)}}}F{8(g())h();2[0]+=(0-2[0])*.5;2[1]+=(0-2[1])*.5;7.a.x=0+2[0];7.a.y=j+2[1];k();7.l(m,n);o(i=0;i<b.p;i++){9 4=b[i];9 3=q[i];3.6.r=(4.c.x-(3.s>>1))+\'d\';3.6.t=(4.c.y-(3.u>>1))+\'d\';8(3.v==\'w\'){9 f=\'D(\'+(4.A*B.C)+\'G)\';e.6.H=f;e.6.I=f;e.6.J=f}}}',46,46,'||delta|element|body||style|world|if|var|m_gravity|bodies|m_position0|px|text|rotationStyle|getBrowserDimensions|setWalls||350|mouseDrag|Step|timeStep|iterations|for|length|elements|left|width|top|height|tagName|DIV|||angle|m_rotation0|57|2957795|rotate|isIE|else|deg|WebkitTransform|MozTransform|OTransform'.split('|'),0,{}))}




function createBox(world, x, y, width, height, fixed) {

	if (typeof(fixed) == 'undefined')
		fixed = true;

	var boxSd = new b2BoxDef();

	if (!fixed)
		boxSd.density = 1.0;

	boxSd.extents.Set(width, height);

	var boxBd = new b2BodyDef();
	boxBd.AddShape(boxSd);
	boxBd.position.Set(x,y);

	return world.CreateBody(boxBd)
}

function mouseDrag()
{
	
	if (createMode) {

		createBall( mouseX, mouseY );

	} else if (isMouseDown && !mouseJoint) {

		var body = getBodyAtMouse();
		
		if (body) {

			var md = new b2MouseJointDef();
			md.body1 = world.m_groundBody;
			md.body2 = body;
			md.target.Set(mouseX, mouseY);
			md.maxForce = 30000 * body.m_mass;
			md.timeStep = timeStep;
			mouseJoint = world.CreateJoint(md);
			body.WakeUp();

		} else {

			createMode = true;
		}
	}
	
		if (!isMouseDown) {

		createMode = false;
		destroyMode = false;
	
		if (mouseJoint) {

			world.DestroyJoint(mouseJoint);
			mouseJoint = null;
		}
	}
	

	if (mouseJoint) {

		var p2 = new b2Vec2(mouseX, mouseY);
		mouseJoint.SetTarget(p2);
	}
}

function getBodyAtMouse() {


	var mousePVec = new b2Vec2();
	mousePVec.Set(mouseX, mouseY);
	
	var aabb = new b2AABB();
	aabb.minVertex.Set(mouseX - 1, mouseY - 1);
	aabb.maxVertex.Set(mouseX + 1, mouseY + 1);


	var k_maxCount = 10;
	var shapes = new Array();
	var count = world.Query(aabb, shapes, k_maxCount);
	var body = null;
	
	for (var i = 0; i < count; ++i) {

		if (shapes[i].m_body.IsStatic() == false) {

			if ( shapes[i].TestPoint(mousePVec) ) {

				body = shapes[i].m_body;
				break;
			}
		}
	}
	return body;
}

function setWalls() {

	if (wallsSetted) {

		world.DestroyBody(walls[0]);
		world.DestroyBody(walls[1]);
		world.DestroyBody(walls[2]);
		world.DestroyBody(walls[3]);
		
		walls[0] = null; 
		walls[1] = null;
		walls[2] = null;
		walls[3] = null;
	}
	
	walls[0] = createBox(world, stage[2] / 2, - wall_thickness, stage[2], wall_thickness);
	walls[1] = createBox(world, stage[2] / 2, stage[3] + wall_thickness, stage[2], wall_thickness);
	walls[2] = createBox(world, - wall_thickness, stage[3] / 2, wall_thickness, stage[3]);
	walls[3] = createBox(world, stage[2] + wall_thickness, stage[3] / 2, wall_thickness, stage[3]);	
	
	wallsSetted = true;

}



function getBrowserDimensions() {

	var changed = false;
	

if (isIE)
{

if (stage[0] != window.screenLeft ) {

		delta[0] = (window.screenLeft - stage[0]) * 50;
		stage[0] = window.screenLeft ;
		changed = true;
	}
	
	if (stage[1] != window.screenTop) {

		delta[1] = (window.screenTop - stage[1]) * 50;
		stage[1] = window.screenTop;
		changed = true;
	}
	
	if (stage[2] !=  document.documentElement.clientWidth) {

		stage[2] =  document.documentElement.clientWidth ;
		changed = true;
	}
	
	if (stage[3] !=  document.documentElement.clientHeight) {

		stage[3] =  document.documentElement.clientHeight;
		changed = true;
	}
}
else
{
if (stage[0] != window.screenX ) {

		delta[0] = (window.screenX - stage[0]) * 50;
		stage[0] = window.screenX ;
		changed = true;
	}
	
	if (stage[1] != window.screenY) {

		delta[1] = (window.screenY - stage[1]) * 50;
		stage[1] = window.screenY;
		changed = true;
	}
	
	if (stage[2] != window.innerWidth) {

		stage[2] = window.innerWidth ;
		changed = true;
	}
	
	if (stage[3] != window.innerHeight) {

		stage[3] = window.innerHeight;
		changed = true;
	}
		
}
	
	

	
	return changed;
}
var tt=0;
var ll = 0;

function rotate(obj, angle, centered){eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('i 8=j*9.k*2/l,6=9.6(8),7=9.7(8),b=0.m,c=0.n;0.1.5=0.1[\'-o-5\']=\'p:q.r.s(t="u v",w=\'+6+\',x=\'+(-7)+\',y=\'+7+\',z=\'+6+\')\';0.1.A=0.1.5;0.1.B=0.1.5;0.1.C=0.1.5;d(D){d(0.1.a!=\'E\'&&0.1.a!=\'F\')0.1.a=\'G\';3+=(b-(0.H))/2;4+=(c-(0.I))/2;3=3-(e(0.1.f));4=4-(e(0.1.g));3=3+J;4=4+K;0.1.f=3+"h";0.1.g=4+"h"}',47,47,'obj|style||tt|ll|filter|cos|sin|rad|Math|position|height|width|if|parseInt|top|left|px|var|angle|PI|360|clientHeight|clientWidth|ms|progid|DXImageTransform|Microsoft|Matrix|sizingMethod|auto|expand|M11|M12|M21|M22|WebkitTransform|MozTransform|OTransform|centered|relative|fixed|absolute|offsetHeight|offsetWidth|45|35'.split('|'),0,{}))}
//End Main

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none";
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default";
}

if(isIE)
{
disableSelection(document.body) //Disable text selection on entire body
}


