var PickedIt=null;
var PickedX, PickedY, PickedR, PickedB;
var lefthere;
var tophere;
var pickcheck=0;
var blocknum;
var blockpass;
var topster;
var leftster;
var denom=2
var num=0;
var left=0;
var right=0;
var bottom=0;
var bottom2=0;
var bottom3=0;
var octo6=0;
var octo7=0;
var octo8=0;


function InitIt(){

document.onmousedown=Whereit;
document.onmousemove=Dragit;

}

function Whereit(evt) {

var hereitis=(evt)?evt:((window.event)?event:null);
lefthere=hereitis.clientX;
tophere=hereitis.clientY;

}



function Move(PickedItID){


	if (pickcheck==0) {

		document.onmousemousedown=Whereit;

		document.onmousemove=Dragit;

		PickedIt=document.getElementById(PickedItID);

		document.getElementById("b1").style.zIndex=4;

		document.getElementById("b2").style.zIndex=4;

		if (document.getElementById("b3")){document.getElementById("b3").style.zIndex=4;}

		if (document.getElementById("b4")){document.getElementById("b4").style.zIndex=4;}

		if (document.getElementById("b5")){document.getElementById("b5").style.zIndex=4;}

		PickedIt.style.zIndex=99;

		PickedX = lefthere-PickedIt.offsetLeft;

		PickedY = tophere-PickedIt.offsetTop;

		PickedB = PickedIt.offsetHeight-PickedY;

		PickedR = PickedIt.offsetWidth-PickedX;

		pickcheck=1;

		PickedIt.style.cursor='move';

		return false;


	} else {


		PickedIt.style.zIndex=3;


		PickedIt.style.cursor='pointer';

		if (PickedItID=="b2"){

			if (par==1){

				if (Math.abs(PickedIt.offsetTop-132)<40&&Math.abs(PickedIt.offsetLeft-322)<40){

					PickedIt.style.top="132px";

					PickedIt.style.left="322px";

					right=1;


				} else {


				right=0;

				}


			} else if (par==2){


				if (Math.abs(PickedIt.offsetTop-137)<40&&Math.abs(PickedIt.offsetLeft-320)<40){


					PickedIt.style.top="137px";


					PickedIt.style.left="320px";


					right=1;


				} else {


				right=0;


				}


			} else if (par==3){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-340)<40){

					PickedIt.style.top="134px";

					PickedIt.style.left="340px";

					right=1;

				} else {

				right=0;

				}


			} else if (par==4){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-340)<40){


					PickedIt.style.top="134px";

					PickedIt.style.left="340px";

					right=1;

				} else {


				right=0;

				}



			} else if (par==5){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-340)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="340px";


					right=1;

				} else {


				right=0;


				}


			} else if (par==6){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					right=1;


				} else {


				right=0;

				}


			} else if (par==7){

				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){

					PickedIt.style.top="134px";

					PickedIt.style.left="190px";

					left=1;

				} else {

				left=0;

				}


			} else if (par==8){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					right=1;


				} else {


				right=0;


				}


			} else if (par==9){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					right=1;


				} else {


				right=0;

				}

			} else if (par==10){


				if (Math.abs(PickedIt.offsetTop-181)<40&&Math.abs(PickedIt.offsetLeft-347)<40){


					PickedIt.style.top="181px";


					PickedIt.style.left="347px";


					right=1;


				} else {


				right=0;

				}

			}  else if (par==11){


				if (Math.abs(PickedIt.offsetTop-274)<40&&Math.abs(PickedIt.offsetLeft-190)<40){

					PickedIt.style.top="274px";

					PickedIt.style.left="190px";

					right=1;

				} else {

				right=0;

				}


			}  else if (par==12){


				if (Math.abs(PickedIt.offsetTop-192)<40&&Math.abs(PickedIt.offsetLeft-340)<40){


					PickedIt.style.top="192px";


					PickedIt.style.left="340px";


					right=1;


				} else {


				right=0;

				}

			}


		} else if (PickedItID=="b1"){


			if (par==1){


				if (Math.abs(PickedIt.offsetTop-133)<40&&Math.abs(PickedIt.offsetLeft-192)<40){


					PickedIt.style.top="133px";


					PickedIt.style.left="192px";


					left=1;


				} else {


				left=0;

				}


			} else if (par==2){

				if (Math.abs(PickedIt.offsetTop-137)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="137px";

					PickedIt.style.left="190px";

					left=1;

				} else {

				left=0;

				}


			} else if (par==3){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					left=1;


				} else {


				left=0;


				}


			} else if (par==4){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					left=1;


				} else {


				left=0;


				}


			} else if (par==5){


				if (Math.abs(PickedIt.offsetTop-135)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="135px";

					PickedIt.style.left="190px";


					left=1;

				} else {

				left=0;


				}


			} else if (par==6){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){

					PickedIt.style.top="134px";

					PickedIt.style.left="190px";

					left=1;


				} else {

				left=0;


				}


			} else if (par==7){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					right=1;


				} else {


				right=0;


				}


			} else if (par==8){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="190px";


					left=1;


				} else {


				left=0;


				}


			}  else if (par==9){


				if (Math.abs(PickedIt.offsetTop-294)<40&&Math.abs(PickedIt.offsetLeft-249)<40){


					PickedIt.style.top="294px";


					PickedIt.style.left="249px";


					left=1;


				} else {


				left=0;


				}


			} else if (par==10){


				if (Math.abs(PickedIt.offsetTop-135)<40&&Math.abs(PickedIt.offsetLeft-347)<40){


					PickedIt.style.top="135px";


					PickedIt.style.left="347px";


					left=1;


				} else {


				left=0;


				}


			}   else if (par==11){


				if (Math.abs(PickedIt.offsetTop-133)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="133px";


					PickedIt.style.left="190px";


					left=1;


				} else {


				left=0;


				}


			} else if (par==12){


				if (Math.abs(PickedIt.offsetTop-135)<40&&Math.abs(PickedIt.offsetLeft-340)<40){


					PickedIt.style.top="135px";


					PickedIt.style.left="340px";


					left=1;


				} else {


				left=0;


				}


			}

		} else if (PickedItID=="b3"){


			if (par==2){


				if (Math.abs(PickedIt.offsetTop-286)<40&&Math.abs(PickedIt.offsetLeft-191)<40){


					PickedIt.style.top="288px";


					PickedIt.style.left="191px";


					bottom=1;


				} else {


				bottom=0;}


			} else if (par==4){


				if (Math.abs(PickedIt.offsetTop-286)<40&&Math.abs(PickedIt.offsetLeft-210)<40){


					PickedIt.style.top="285px";


					PickedIt.style.left="210px";


					bottom=1;


				} else {


				bottom=0;}


			} else if (par==5){


				if (Math.abs(PickedIt.offsetTop-286)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="285px";


					PickedIt.style.left="190px";


					bottom=1;


				} else {


				bottom=0;}


			} else if (par==7){


				if (Math.abs(PickedIt.offsetTop-264)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="264px";


					PickedIt.style.left="190px";


					bottom=1;


				} else {


				bottom=0;}


			} else if (par==9){


				if (Math.abs(PickedIt.offsetTop-246)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="246px";


					PickedIt.style.left="190px";


					bottom=1;


				} else {


				bottom=0;}


			}  else if (par==10){


				if (Math.abs(PickedIt.offsetTop-293)<40&&Math.abs(PickedIt.offsetLeft-347)<40){


					PickedIt.style.top="293px";


					PickedIt.style.left="347px";


					bottom=1;


				} else {


				bottom=0;}




			}  else if (par==12){


				if (Math.abs(PickedIt.offsetTop-288)<40&&Math.abs(PickedIt.offsetLeft-340)<40){


					PickedIt.style.top="288px";


					PickedIt.style.left="340px";


					bottom=1;


				} else {


				bottom=0;}


			} 


		} else if (PickedItID=="b4"){


			if (par==5){


				if (Math.abs(PickedIt.offsetTop-286)<40&&Math.abs(PickedIt.offsetLeft-340)<40){


					PickedIt.style.top="285px";


					PickedIt.style.left="340px";


					bottom2=1;


				} else {


				bottom2=0;


				}


			} else if (par==7){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-320)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="320px";


					bottom2=1;


				} else {


				bottom2=0;}


			} else if (par==9){


				if (Math.abs(PickedIt.offsetTop-244)<40&&Math.abs(PickedIt.offsetLeft-343)<40){


					PickedIt.style.top="244px";


					PickedIt.style.left="343px";


					bottom2=1;


				} else {


				bottom2=0;}


			} else if (par==10){


				if (Math.abs(PickedIt.offsetTop-293)<40&&Math.abs(PickedIt.offsetLeft-347)<40){


					PickedIt.style.top="293px";


					PickedIt.style.left="347px";


					bottom2=1;


				} else {


				bottom2=0;}


			} else if (par==12){


				if (Math.abs(PickedIt.offsetTop-289)<40&&Math.abs(PickedIt.offsetLeft-274)<40){


					PickedIt.style.top="289px";


					PickedIt.style.left="274px";


					bottom2=1;


				} else {


				bottom2=0;}


			}




		} else if (PickedItID=="b5"){

			if (par==9){


				if (Math.abs(PickedIt.offsetTop-133)<40&&Math.abs(PickedIt.offsetLeft-344)<40){


					PickedIt.style.top="133px";


					PickedIt.style.left="344px";


					bottom3=1;


				} else {


				bottom3=0;}


			} else if (par==10){


				if (Math.abs(PickedIt.offsetTop-293)<40&&Math.abs(PickedIt.offsetLeft-234)<40){


					PickedIt.style.top="293px";


					PickedIt.style.left="234px";


					bottom3=1;


				} else {


				bottom3=0;}


			} else if (par==12){


				if (Math.abs(PickedIt.offsetTop-288)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="288px";


					PickedIt.style.left="190px";


					bottom3=1;


				} else {


				bottom3=0;}


			}



		} else if (PickedItID=="b6"){

			if (par==10){


				if (Math.abs(PickedIt.offsetTop-293)<40&&Math.abs(PickedIt.offsetLeft-187)<40){


					PickedIt.style.top="293px";


					PickedIt.style.left="187px";


					octo6=1;


				} else {


				octo6=0;

				}

			} else if (par==12){


				if (Math.abs(PickedIt.offsetTop-190)<40&&Math.abs(PickedIt.offsetLeft-190)<40){


					PickedIt.style.top="192px";


					PickedIt.style.left="190px";


					octo6=1;


				} else {


				octo6=0;

				}

			}


		} else if (PickedItID=="b7"){

			if (par==10){


				if (Math.abs(PickedIt.offsetTop-181)<40&&Math.abs(PickedIt.offsetLeft-187)<40){


					PickedIt.style.top="181px";


					PickedIt.style.left="187px";


					octo7=1;


				} else {


				octo7=0;

				}

			} else if (par==12){


				if (Math.abs(PickedIt.offsetTop-134)<40&&Math.abs(PickedIt.offsetLeft-219)<40){


					PickedIt.style.top="134px";


					PickedIt.style.left="219px";


					octo7=1;


				} else {


				octo7=0;

				}

			}


		} else if (PickedItID=="b8"){

			if (par==10){


				if (Math.abs(PickedIt.offsetTop-135)<40&&Math.abs(PickedIt.offsetLeft-234)<40){


					PickedIt.style.top="135px";


					PickedIt.style.left="234px";


					octo8=1;


				} else {


				octo8=0;

				}

			}
		}



		num = left + right + bottom + bottom2 + bottom3 + octo6 + octo7 + octo8;


		document.getElementById("numerator").innerHTML=num;


		if (num==parted) {


			document.getElementById("equalsign").style.visibility="visible";


			document.getElementById("whole").style.visibility="visible";


			document.getElementById("smiler").src="rightsmile.gif";


			document.getElementById("type").style.visibility="visible";


		} else {

			document.getElementById("equalsign").style.visibility="hidden";


			document.getElementById("whole").style.visibility="hidden";


			document.getElementById("smiler").src="waitsmile.gif";


			document.getElementById("type").style.visibility="hidden";


		}


		PickedIt=null;


		pickcheck=0;


		return false;


	}


}


function Dragit(evt){


evt=(evt)?evt:((window.event)?event:null);


if (PickedIt){


if ((evt.clientX - PickedX)>0&&(evt.clientX + PickedR)<900){


PickedIt.style.left = (evt.clientX - PickedX) +'px';


}


if ((evt.clientY - PickedY)>0&&(evt.clientY + PickedB)<571){


PickedIt.style.top = (evt.clientY - PickedY) +'px';


}



return false;



}



}



