
var x=600;
var level=1;
var trial=1;
var number_to_analyze=Math.floor(Math.random()*900+199);

var obj=new Array(100);
var trial=1;
var mousex=0, mousey=0;
var ready_for_a_new_trial="false";
var number_to_extract_temp=100;
var sentence1="";
var str1=" ";
var trialminus1=0;
var number_animation_time_counter=0;
var number_animation_time_counter_active="false";
var wrong_achadot="false";
var wrong_achadot_timer=0;
var wrong_asarot="false";
var wrong_asarot_timer=0;
var wrong_meot="false";
var wrong_meot_timer=0;
var wrong_alaphim="false";
var wrong_alaphim_timer=0;
var lasttemprand=8;

var pic=new Array(30);

var aySound = new Array();

	pic[0]= new Image(36,69); pic[0].src="../images/numbers_set_1/0_clr_e0.gif"; 
	pic[1]= new Image(36,69); pic[1].src="../images/numbers_set_1/1_clr_e0.gif"; 
	pic[2]= new Image(36,69); pic[2].src="../images/numbers_set_1/2_clr_e0.gif"; 
	pic[3]= new Image(36,69); pic[3].src="../images/numbers_set_1/3_clr_e0.gif"; 
	pic[4]= new Image(36,69); pic[4].src="../images/numbers_set_1/4_clr_e0.gif"; 
	pic[5]= new Image(36,69); pic[5].src="../images/numbers_set_1/5_clr_e0.gif"; 
	pic[6]= new Image(36,69); pic[6].src="../images/numbers_set_1/6_clr_e0.gif"; 
	pic[7]= new Image(36,69); pic[7].src="../images/numbers_set_1/7_clr_e0.gif"; 
	pic[8]= new Image(36,69); pic[8].src="../images/numbers_set_1/8_clr_e0.gif"; 
	pic[9]= new Image(36,69); pic[9].src="../images/numbers_set_1/9_clr_e0.gif"; 
							  
	pic[10]= new Image(36,69); pic[10].src="../images/numbers_set_1/0_clr_e0_first.gif"; 
	pic[11]= new Image(36,69); pic[11].src="../images/numbers_set_1/1_clr_e0_first.gif"; 
	pic[12]= new Image(36,69); pic[12].src="../images/numbers_set_1/2_clr_e0_first.gif"; 
	pic[13]= new Image(36,69); pic[13].src="../images/numbers_set_1/3_clr_e0_first.gif"; 
	pic[14]= new Image(36,69); pic[14].src="../images/numbers_set_1/4_clr_e0_first.gif"; 
	pic[15]= new Image(36,69); pic[15].src="../images/numbers_set_1/5_clr_e0_first.gif"; 
	pic[16]= new Image(36,69); pic[16].src="../images/numbers_set_1/6_clr_e0_first.gif"; 
	pic[17]= new Image(36,69); pic[17].src="../images/numbers_set_1/7_clr_e0_first.gif"; 
	pic[18]= new Image(36,69); pic[18].src="../images/numbers_set_1/8_clr_e0_first.gif"; 
	pic[19]= new Image(36,69); pic[19].src="../images/numbers_set_1/9_clr_e0_first.gif";


   	pic[22]= new Image(120,5); pic[22].src="./collecttheships_images/edboat01.gif";
   	pic[23]= new Image(120,5); pic[23].src="./collecttheships_images/edboat07.gif";
   	pic[24]= new Image(120,5); pic[24].src="./collecttheships_images/naut003.gif";
   	pic[25]= new Image(120,5); pic[25].src="./collecttheships_images/schiff.gif";
   	pic[26]= new Image(120,5); pic[26].src="./collecttheships_images/tubboat.gif";
   	pic[27]= new Image(120,5); pic[27].src="./collecttheships_images/bateau_21.gif";
   	pic[28]= new Image(120,5); pic[28].src="./collecttheships_images/liner.gif";
   	pic[29]= new Image(120,5); pic[29].src="./collecttheships_images/edboat01.gif";
   	pic[30]= new Image(120,5); pic[30].src="./collecttheships_images/tubboat.gif";
   	pic[31]= new Image(120,5); pic[31].src="./collecttheships_images/bateau_21.gif";

   	pic[32]= new Image(120,5); pic[32].src=pic[22].src;
   	pic[33]= new Image(120,5); pic[33].src=pic[23].src;
   	pic[34]= new Image(120,5); pic[34].src=pic[24].src;
   	pic[35]= new Image(120,5); pic[35].src=pic[25].src;
   	pic[36]= new Image(120,5); pic[36].src=pic[26].src;
   	pic[37]= new Image(120,5); pic[37].src=pic[27].src;
   	pic[38]= new Image(120,5); pic[38].src=pic[28].src;
   	pic[39]= new Image(120,5); pic[39].src=pic[29].src;
   	pic[40]= new Image(120,5); pic[40].src=pic[30].src;
   	pic[41]= new Image(120,5); pic[41].src=pic[31].src;
	
	pic[43]= new Image(1022,620); pic[43].src="./collecttheships_images/chicago1.jpg"; 
	pic[44]= new Image(1022,620); pic[44].src="./collecttheships_images/black_background.gif"; 




function init_main(){




//	document.onmousemove=handlemousemove;
	document.onmousedown=handlemousedown;
	document.onmouseup=handlemouseup;

	document.getElementById("div_exittomenu").style.visibility="visible";


//	document.getElementById("image_background").src=pic[33].src;
	document.body.style.background="url('"+pic[43].src+"') black top left no-repeat fixed "

	document.getElementById("img_black_background").src=pic[44].src;
	document.getElementById("div_black_background").style.visibility="visible";

	for (i=1; i<=20; i++){
		document.getElementById("image_smiley"+i).src=pic[21+i].src;
	}

//	document.getElementById("div_background").style.visibility="visible";
	document.getElementById("div_instructions").style.visibility="hidden";
	document.getElementById("div_imgthumb").style.visibility="hidden";
	document.getElementById("div_linkbacktomenu").style.visibility="hidden";
	document.getElementById("div_linkbacktomathgames").style.visibility="hidden";






	for (i=1; i<=20; i++) {
		obj[i]=new obj_prototype();	
	}

	
	document.getElementById("div_achadot1").style.visibility="visible";
	document.getElementById("div_asarot1").style.visibility="visible";
	document.getElementById("div_meot1").style.visibility="visible";
	document.getElementById("div_alaphim1").style.visibility="visible";
	document.getElementById("btnrunfirsttime").style.visibility="hidden";
	document.getElementById("div_btnrunfirsttime").style.visibility="hidden";
	document.getElementById("btnrestart").style.visibility="hidden";
	document.getElementById("btnbacktomenu").style.visibility="hidden";

	
	document.getElementById("div_sentence1").style.visibility="visible";
	document.getElementById("div_sentence2").style.visibility="hidden";



	init_this_task_variables();

	assign_divs_and_images_to_objects();	

	run_main_animation();

}

function init_this_task_variables(){

	for (i=1; i<=20; i++){

		// SET LOCATIONS FOR THE feedback ITEMS

//		obj[i].feedback_x=Math.floor(Math.random()*50+950);
//		obj[i].feedback_y=Math.floor(Math.random()*50+250);

			obj[i].feedback_x=1030;



		document.getElementById("div_feedback"+i).style.left=obj[i].feedback_x;	
		document.getElementById("div_feedback"+i).style.top=obj[i].feedback_y;	
//		document.getElementById("div_feedback"+i).style.visibility="visible";	

		obj[i].feedback_target_x=-100;

		obj[i].feedback_target_y=430;



		//EXTRACT THE NUMBERS INTO DIGITS - ACHADOT, ASAROT, MEOT
		number_to_extract_temp=obj[i].number_to_click_on;

		obj[i].achadot=number_to_extract_temp%10;
		number_to_extract_temp=number_to_extract_temp-obj[i].achadot;
		number_to_extract_temp=number_to_extract_temp/10;

		obj[i].asarot=number_to_extract_temp%10;
		number_to_extract_temp=number_to_extract_temp-obj[i].asarot;
		number_to_extract_temp=number_to_extract_temp/10;

		obj[i].meot=number_to_extract_temp%10;
		number_to_extract_temp=number_to_extract_temp-obj[i].meot;
		number_to_extract_temp=number_to_extract_temp/10;

		obj[i].alaphim=number_to_extract_temp%10;
		number_to_extract_temp=number_to_extract_temp-obj[i].alaphim;
		number_to_extract_temp=number_to_extract_temp/10;



	}


		obj[1].feedback_y=370;	
		obj[2].feedback_y=360;
		obj[3].feedback_y=480;
		obj[4].feedback_y=330;
		obj[5].feedback_y=380;
		obj[6].feedback_y=440;
		obj[7].feedback_y=330;
		obj[8].feedback_y=460;
		obj[9].feedback_y=390;
		obj[10].feedback_y=450;
		obj[11].feedback_y=370;

		obj[1].feedback_speed=0.8;
		obj[2].feedback_speed=1.1;
		obj[3].feedback_speed=0.3;
		obj[4].feedback_speed=0.7;
		obj[5].feedback_speed=0.5;
		obj[6].feedback_speed=1;
		obj[7].feedback_speed=0.3;
		obj[8].feedback_speed=2;
		obj[9].feedback_speed=0.7;
		obj[10].feedback_speed=1;

		obj[11].feedback_y=370;	
		obj[12].feedback_y=360;
		obj[13].feedback_y=480;
		obj[14].feedback_y=330;
		obj[15].feedback_y=380;
		obj[16].feedback_y=440;
		obj[17].feedback_y=330;
		obj[18].feedback_y=460;
		obj[19].feedback_y=390;
		obj[20].feedback_y=450;


		obj[12].feedback_speed=0.7;
		obj[13].feedback_speed=0.3;
		obj[14].feedback_speed=0.6;
		obj[16].feedback_speed=1;
		obj[17].feedback_speed=0.3;
		obj[18].feedback_speed=2;
		obj[19].feedback_speed=0.7;
		obj[20].feedback_speed=1;




	
}


function assign_divs_and_images_to_objects(){   //THIS IS RELEVANT TO A SPECIFIC TRIAL


		if(obj[trial].sifra_lilchots=="achadot") {str1="ONES"}
		if(obj[trial].sifra_lilchots=="asarot") {str1="TENS"}
		if(obj[trial].sifra_lilchots=="meot") {str1="HUNDREDS"}
		if(obj[trial].sifra_lilchots=="alaphim") {str1="THOUSANDS"}

		sentence2=str1;
		sentence1="Please click the "+str1+" digit";	
		document.getElementById("txbx_sentence1").value=sentence1;	
		document.getElementById("txbx_sentence1").style.textAlign='left';	
		document.getElementById("txbx_sentence1").style.fontSize=30;	
		document.getElementById("txbx_sentence1").style.height=50;	
		document.getElementById("txbx_sentence1").style.color='#0000aa';	

//		document.getElementById("txbx_sentence2").value=sentence2;	
		document.getElementById("txbx_sentence2").style.textAlign='center';	
		document.getElementById("txbx_sentence2").style.fontSize=30;	
		document.getElementById("txbx_sentence2").style.height=40;	
		document.getElementById("txbx_sentence2").style.color='#8888cc';
		document.getElementById("txbx_sentence2").style.background='#000022';


		
			document.getElementById("div_achadot1").style.visibility="visible";
			document.getElementById("div_achadot1").style.left=obj[trial].achadot_x;
			document.getElementById("div_achadot1").style.top=obj[trial].achadot_y; 

			for (i=0; i<=20; i++){
				if (obj[trial].achadot==i) {	document.getElementById("image_achadot1").src=pic[i+10].src;} 
			}



			document.getElementById("div_asarot1").style.left=obj[trial].asarot_x;
			document.getElementById("div_asarot1").style.top=obj[trial].asarot_y; 

			for (i=0; i<=20; i++){
				if (obj[trial].asarot==i) {	document.getElementById("image_asarot1").src=pic[i+10].src;} 
			}



			document.getElementById("div_meot1").style.left=obj[trial].meot_x;
			document.getElementById("div_meot1").style.top=obj[trial].meot_y; 


			for (i=0; i<=20; i++){
				if (obj[trial].meot==i) {	document.getElementById("image_meot1").src=pic[i+10].src;} 
			}


			document.getElementById("div_alaphim1").style.left=obj[trial].alaphim_x;
			document.getElementById("div_alaphim1").style.top=obj[trial].alaphim_y; 


			for (i=0; i<=20; i++){
				if (obj[trial].alaphim==i) {	document.getElementById("image_alaphim1").src=pic[i+10].src;} 
			}


		


}





function obj_prototype(){
	temprand=Math.floor(Math.random()*9000+999);

	this.number_to_click_on=temprand;
	this.number_to_extract_temp=temprand;

	this.timer1=0;
	
	do{
		temprand=Math.floor(Math.random()*4);
	}
	while (temprand==lasttemprand);
	lasttemprand=temprand;

	if (temprand==0) {this.sifra_lilchots="achadot";}
	if (temprand==1) {this.sifra_lilchots="asarot";}
	if (temprand==2) {this.sifra_lilchots="meot";}
	if (temprand==3) {this.sifra_lilchots="alaphim";}

	temprandx=Math.floor(Math.random()*400+280);
	temprandy=80;


	this.achadot=0;
	this.achadot_x=temprandx;
	this.achadot_y=temprandy;

	this.asarot=0;
	this.asarot_x=temprandx-30;
	this.asarot_y=temprandy;

	this.meot=0;
	this.meot_x=temprandx-60;
	this.meot_y=temprandy;

	this.alaphim=0;
	this.alaphim_x=temprandx-90;
	this.alaphim_y=temprandy;


	this.visibility="false";

	this.feedback_speed=0.5;

	this.feedback_visibility="true";

	this.feedback_x=600;			
	this.feedback_y=600;			

	this.feedback_is_on_its_way="false";

	this.feedback_movespeed1=0;
	this.feedback_origin_x=700;
	this.feedback_origin_y=430;
	this.feedback_target_x=100;
	this.feedback_target_y=100;



}



function run_main_animation(){

	// IF THERE IS A CORRECT CLICK

	if ((checkforcontact(obj[trial].sifra_lilchots)=="true") && (ready_for_a_new_trial=="true")) {

		mousex=0; mousey=0;

		document.getElementById("div_feedback"+trial).style.visibility="visible";
//		obj[trial].feedback_x=obj[trial].feedback_origin_x;
//		obj[trial].feedback_y=obj[trial].feedback_origin_y;


		ready_for_a_new_trial="false";

		playSound(0);
	
		obj[trial].feedback_is_on_its_way="true";

		animate_the_numebrs();

		// preparing the new trial
		trial=trial+1;

		
		
		obj[trial].timer1=160;
		
	}



// animating the wrong feedback	

if(wrong_achadot_timer>0){
	document.getElementById("div_answerfeedback").style.visibility="visible";
	mousex=0; mousey=0;
	wrong_achadot_timer=wrong_achadot_timer-1;

	document.getElementById("txtarea_answerfeedback").style.width="270";
	document.getElementById("txtarea_answerfeedback").value="You clicked the ONES.\nPlease try again.";		

		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_achadot_timer + ')';
		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_achadot_timer + ')';


} else {
	document.getElementById("div_answerfeedback").style.visibility="hidden";

  }


  if(wrong_asarot_timer>0){
	  
	document.getElementById("div_answerfeedback").style.visibility="visible";
	mousex=0; mousey=0;
	wrong_asarot_timer=wrong_asarot_timer-1;

	document.getElementById("txtarea_answerfeedback").style.width="270";
	document.getElementById("txtarea_answerfeedback").value="You clicked the TENS.\nPlease try again.";		

		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_asarot_timer + ')';
		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_asarot_timer + ')';

  }


if(wrong_meot_timer>0){
	
	document.getElementById("div_answerfeedback").style.visibility="visible";
	mousex=0; mousey=0;
	wrong_meot_timer=wrong_meot_timer-1;

	document.getElementById("txtarea_answerfeedback").style.width="300";
	document.getElementById("txtarea_answerfeedback").value="You clicked the HUNDREDS.\nPlease try again.";		

		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_meot_timer + ')';
		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_meot_timer + ')';

	}


if(wrong_alaphim_timer>0){
	
	document.getElementById("div_answerfeedback").style.visibility="visible";
	mousex=0; mousey=0;
	wrong_alaphim_timer=wrong_alaphim_timer-1;



	document.getElementById("txtarea_answerfeedback").style.width="320";
	document.getElementById("txtarea_answerfeedback").value="You clicked the THOUSANDS.\nPlease try again.";		

		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_alaphim_timer + ')';
		document.getElementById("div_answerfeedback").style.filter = 'alpha(opacity=' + wrong_alaphim_timer + ')';

	}






		// animate the elements (digits and feedbacks)

	for (i4=1; i4<=20; i4++){

		if (obj[i4].timer1>1) {obj[i4].timer1=obj[i4].timer1-1;}

		if (obj[i4].timer1==1) {
			assign_divs_and_images_to_objects();			
			obj[i4].timer1=0;

			// if sent all 20 ships - end of game

			if (i4==20) {

				document.getElementById("div_sentence1").style.visibility="hidden"; 
				document.getElementById("div_achadot1").style.visibility="hidden"; 
				document.getElementById("div_asarot1").style.visibility="hidden"; 
				document.getElementById("div_meot1").style.visibility="hidden"; 
				document.getElementById("div_alaphim1").style.visibility="hidden"; 
				document.getElementById("div_sentence2").style.visibility="visible"; 

				document.getElementById("div_btnrestart").style.visibility="visible"; 
				document.getElementById("btnrestart").style.visibility="visible"; 
				document.getElementById("div_backtomenu").style.visibility="visible"; 
				document.getElementById("div_exittomenu").style.visibility="hidden"; 
				document.getElementById("btnbacktomenu").style.visibility="visible"; 
				document.getElementById("div_btnrestart").style.left=10; 
				document.getElementById("div_backtomenu").style.left=10; 
				document.getElementById("btnrestart").style.width=160; 
				document.getElementById("btnbacktomenu").style.width=160; 
				document.getElementById("btnrestart").style.fontSize=20; 
				document.getElementById("btnbacktomenu").style.fontSize=20; 
				document.getElementById("btnrestart").value="Restart"; 
				





			} else {ready_for_a_new_trial=="true";}
		}
			

//		animating the ships

		if (obj[i4].feedback_is_on_its_way=="true") {


//			document.getElementById("txbx_sentence1").value=i4;	

				//move the feedback on the x axis towards its target.
		if(obj[i4].feedback_x>-180) {	obj[i4].feedback_x=obj[i4].feedback_x-obj[i4].feedback_speed;}
			else {			document.getElementById("div_feedback"+i4).style.visibility="hidden";  }



			document.getElementById("div_feedback"+i4).style.left=obj[i4].feedback_x;
			document.getElementById("div_feedback"+i4).style.top=obj[i4].feedback_y;
		

		}
	}




	setTimeout('run_main_animation()',1);
}




         
function animate_the_numebrs(){


	for (i3=0; i3<=20; i3++){

		if (obj[trial].sifra_lilchots=="achadot"){
			if (obj[trial].achadot==i3) {	document.getElementById("image_achadot1").src=pic[i3].src;} 
		}

		if (obj[trial].sifra_lilchots=="asarot"){
			if (obj[trial].asarot==i3) {	document.getElementById("image_asarot1").src=pic[i3].src;} 
		}

		if (obj[trial].sifra_lilchots=="meot"){
			if (obj[trial].meot==i3) {	document.getElementById("image_meot1").src=pic[i3].src;} 
		}

		if (obj[trial].sifra_lilchots=="alaphim"){
			if (obj[trial].alaphim==i3) {	document.getElementById("image_alaphim1").src=pic[i3].src;} 
		}
	} 


}





function handlemousedown(evt) {

	var e = (window.event) ? window.event : evt; 

	

	if (e.pageX)  {  				//firefox

		mousex=e.pageX; //event.clientX;
		mousey=e.pageY; //event.clientY;
	} else {  					//IE
		mousex=event.clientX;
		mousey=event.clientY;

	}

	

//	if (checkforcontact(obj[trial].sifra_lilchots)=="false"&&e.target!="[object HTMLInputElement]")	{ playSound(1); }

	return true;
}

function handlemouseup(evt) {

	ready_for_a_new_trial="true";


	return true;
}


function checkforcontact(what_to_check){

var rtemp="false";

	if (what_to_check=="achadot"){
		x1=obj[trial].achadot_x; x2=obj[trial].achadot_x+32;
		y1=obj[trial].achadot_y; y2=obj[trial].achadot_y+68;
	}

	if (what_to_check=="asarot"){
		x1=obj[trial].asarot_x; x2=obj[trial].asarot_x+32;
		y1=obj[trial].asarot_y; y2=obj[trial].asarot_y+68;
	}

	if (what_to_check=="meot"){
		x1=obj[trial].meot_x; x2=obj[trial].meot_x+32;
		y1=obj[trial].meot_y; y2=obj[trial].meot_y+68;
	}

	if (what_to_check=="alaphim"){
		x1=obj[trial].alaphim_x; x2=obj[trial].alaphim_x+32;
		y1=obj[trial].alaphim_y; y2=obj[trial].alaphim_y+68;
	}

		x3=mousex; 	x4=mousex+2;
		y3=mousey; 	y4=mousey+2;
	
		if(x3>x1&&x3<x2&&y3>y1&&y3<y2) rtemp="true";
		if(x4>x1&&x4<x2&&y3>y1&&y3<y2) rtemp="true";
		if(x3>x1&&x3<x2&&y4>y1&&y4<y2) rtemp="true";
		if(x4>x1&&x4<x2&&y4>y1&&y4<y2) rtemp="true";
		
		if(x2>x3&&x2<x4&&y2>y3&&y2<y4) rtemp="true";
		if(x1>x3&&x1<x4&&y2>y3&&y2<y4) rtemp="true";
		if(x2>x3&&x2<x4&&y1>y3&&y1<y4) rtemp="true";
		if(x1>x3&&x1<x4&&y1>y3&&y1<y4) rtemp="true";	



	if (wrong_achadot_timer==0&&(what_to_check=="asarot"||what_to_check=="meot"||what_to_check=="alaphim")){
		wrong_achadot="false";
	
		x5=obj[trial].achadot_x; x6=obj[trial].achadot_x+32;
		y5=obj[trial].achadot_y; y6=obj[trial].achadot_y+68;

		if(x3>x5&&x3<x6&&y3>y5&&y3<y6) wrong_achadot="true";
		if(x4>x5&&x4<x6&&y3>y5&&y3<y6) wrong_achadot="true";
		if(x3>x5&&x3<x6&&y4>y5&&y4<y6) wrong_achadot="true";
		if(x4>x5&&x4<x6&&y4>y5&&y4<y6) wrong_achadot="true";
		
		if(x6>x3&&x6<x4&&y6>y3&&y6<y4) wrong_achadot="true";
		if(x5>x3&&x5<x4&&y6>y3&&y6<y4) wrong_achadot="true";
		if(x6>x3&&x6<x4&&y5>y3&&y5<y4) wrong_achadot="true";
		if(x5>x3&&x5<x4&&y5>y3&&y5<y4) wrong_achadot="true";	

		if (wrong_achadot=="true"){  if (navigator.appName=="Netscape")	{wrong_achadot_timer=300; playSound(1);} else {wrong_achadot_timer=230; playSound(1);}
		}

	}

	if (wrong_asarot_timer==0&&(what_to_check=="achadot"||what_to_check=="meot"||what_to_check=="alaphim")){
		wrong_asarot="false";
	
		x5=obj[trial].asarot_x; x6=obj[trial].asarot_x+32;
		y5=obj[trial].asarot_y; y6=obj[trial].asarot_y+68;

		if(x3>x5&&x3<x6&&y3>y5&&y3<y6) wrong_asarot="true";
		if(x4>x5&&x4<x6&&y3>y5&&y3<y6) wrong_asarot="true";
		if(x3>x5&&x3<x6&&y4>y5&&y4<y6) wrong_asarot="true";
		if(x4>x5&&x4<x6&&y4>y5&&y4<y6) wrong_asarot="true";
		
		if(x6>x3&&x6<x4&&y6>y3&&y6<y4) wrong_asarot="true";
		if(x5>x3&&x5<x4&&y6>y3&&y6<y4) wrong_asarot="true";
		if(x6>x3&&x6<x4&&y5>y3&&y5<y4) wrong_asarot="true";
		if(x5>x3&&x5<x4&&y5>y3&&y5<y4) wrong_asarot="true";	

		if (wrong_asarot=="true"){  if (navigator.appName=="Netscape")	{wrong_asarot_timer=300; playSound(1);} else {wrong_asarot_timer=230; playSound(1);}
		}

	}

	if (wrong_meot_timer==0&&(what_to_check=="achadot"||what_to_check=="asarot"||what_to_check=="alaphim")){
		wrong_meot="false";
	
		x5=obj[trial].meot_x; x6=obj[trial].meot_x+32;
		y5=obj[trial].meot_y; y6=obj[trial].meot_y+68;

		if(x3>x5&&x3<x6&&y3>y5&&y3<y6) wrong_meot="true";
		if(x4>x5&&x4<x6&&y3>y5&&y3<y6) wrong_meot="true";
		if(x3>x5&&x3<x6&&y4>y5&&y4<y6) wrong_meot="true";
		if(x4>x5&&x4<x6&&y4>y5&&y4<y6) wrong_meot="true";
		
		if(x6>x3&&x6<x4&&y6>y3&&y6<y4) wrong_meot="true";
		if(x5>x3&&x5<x4&&y6>y3&&y6<y4) wrong_meot="true";
		if(x6>x3&&x6<x4&&y5>y3&&y5<y4) wrong_meot="true";
		if(x5>x3&&x5<x4&&y5>y3&&y5<y4) wrong_meot="true";	

		if (wrong_meot=="true"){  if (navigator.appName=="Netscape")	{wrong_meot_timer=300; playSound(1);} else {wrong_meot_timer=230; playSound(1);}
		}

	}

	if (wrong_alaphim_timer==0&&(what_to_check=="achadot"||what_to_check=="asarot"||what_to_check=="meot")){
		wrong_alaphim="false";

		x5=obj[trial].alaphim_x; x6=obj[trial].alaphim_x+32;
		y5=obj[trial].alaphim_y; y6=obj[trial].alaphim_y+68;

		if(x3>x5&&x3<x6&&y3>y5&&y3<y6) wrong_alaphim="true";
		if(x4>x5&&x4<x6&&y3>y5&&y3<y6) wrong_alaphim="true";
		if(x3>x5&&x3<x6&&y4>y5&&y4<y6) wrong_alaphim="true";
		if(x4>x5&&x4<x6&&y4>y5&&y4<y6) wrong_alaphim="true";
		
		if(x6>x3&&x6<x4&&y6>y3&&y6<y4) wrong_alaphim="true";
		if(x5>x3&&x5<x4&&y6>y3&&y6<y4) wrong_alaphim="true";
		if(x6>x3&&x6<x4&&y5>y3&&y5<y4) wrong_alaphim="true";
		if(x5>x3&&x5<x4&&y5>y3&&y5<y4) wrong_alaphim="true";	

		if (wrong_alaphim=="true"){  if (navigator.appName=="Netscape")	{wrong_alaphim_timer=300; playSound(1);} else {wrong_alaphim_timer=230; playSound(1);}
		}

	}
	
	
	return rtemp;
}	




					// Sound Script


						var aySound = new Array();
						// Below: source for sound files to be preloaded
						aySound[0] = "../sounds/DingLing.wav";
						aySound[1] = "../sounds/Buzz01.wav";

						// DO NOT edit below this line
						document.write('<BGSOUND ID="auIEContainer">')
						IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
						NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
						ver4 = IE||NS? 1:0;
						onload=auPreload;

						function auPreload() {
						if (!ver4) return;
						if (NS) auEmb = new Layer(0,window);
						else {
						Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
						document.body.insertAdjacentHTML("BeforeEnd",Str);
						}
						var Str = '';
						for (i=0;i<aySound.length;i++)
						Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
						if (IE) auEmb.innerHTML = Str;
						else {
						auEmb.document.open();
						auEmb.document.write(Str);
						auEmb.document.close();
						}
						auCon = IE? document.all.auIEContainer:auEmb;
						auCon.control = auCtrl;
						}
						function auCtrl(whSound,play) {
						if (IE) this.src = play? aySound[whSound]:'';
						else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
						}
						function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
						function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }



