Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/examples/lessons/6_Maths_lowestCommonMultiple/js/lesson.js
blob: 8af8e323eea9ba914ff351463e1f7935fc946347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
$(document).ready(function(){     
	var k = Karma({
		audio: [{'name':'correct','file':'correct.wav'},
			    {'name':'incorrect','file':'incorrect.wav'},
			  ]});
	
	k.ready(function(){
		var i,j,s,t,x,flag,y,m,h;
		var currentLesson;  //variable to keep track of the current lesson
		var clickCounter;  //count the next button clicks for the particular lesson
		var cutCounter;
		var currentTopButton,currentLeftButton;
		var TOTAL_QUES = 5;
		var imgFrogCounter,frogJmpCount;
		var imgRabbitCounter,rabbitJmpCount;
		var timeLineLeft,timeLineInsCount;
		var posCounter = [];  // array Storing the positions of the frogs 0- frog and 1- rabbit
 		var scoreboard;
 		var lcmMethCounter;
 		var flag_frog; //flag is set if frog reaches the rabbit point
 		var maxHtFrogTop,maxHtFrogLeft,baseFrogTop,baseFrogLeft;
 		var maxHtRabbitTop,maxHtRabbitLeft,baseRabbitTop,baseRabbitLeft;
 		var currentTopButton,currentLeftButton;
 		var clickCounter; //store the click for the current lesson
 		var currentExercise;
 		var romanNums = ['i','ii','iii','iv','v'];
 		var randNumbers = [];
 		var numNumbers; //number of numbers in each quesBox
 		var levelNumbers = [45,50,3,6,7,4,24,18,15,25,24,2,20,16,8,4,11,17,12,6,7,10,18,5,2,16,5,12,9,15,
 		                    13,65,21,49,37,6,28,84,243,27,248,29,95,25,65,15,25,40,105,35,300,125,900,60,76,30,31,310,225,50,
 		                    17,34,51,27,28,36,6,36,216,9,81,243,2,3,4,5,3,90,64,8,1,2,56,14,12,16,18,6,2,98,70,14,49,65,13,26,78,12,9,69,4,30,60,70,40
 		                    ];
 		var answers = [];
 		var currentSection; //var to store the current section inside a particular exercise
 		var currentInpBox;
 		var flag_section; //flag to show the section is active

 		var checkTime = function(timePara){
		    if (timePara<10 ){
		    	timePara="0" + timePara;
		    }
		    return timePara;
		};

		var stopTimer = function(){
			s = 0;
			clearTimeout(t);
		};
		var startTimer = function(){
			s = 0;
			m = 0;
			h = 0;
			s=checkTime(s);					
			$('#timerBox1').html(s);
			increaseTime();					
		};
		

		var increaseTime = function(){		    
			if(s>59){
			    m++;
			    m=checkTime(m);
			    $('#timerBox2').html(m);
			    s = 0;
			}
			if(m>59){
			    h++; 
			    h=checkTime(h);
			    $('#timerBox3').html(h);			    
			    m=0;
			}
				
				s=checkTime(s);				
				$('#timerBox1').html(s);
				s++;
		    	t=setTimeout(function(){increaseTime();},1000);
		   
		    
		};
	function hcf(text1,text2){
		  var gcd=1;
		  if (text1>text2) {text1=text1+text2; text2=text1-text2; text1=text1-text2;}
		  if ((text2==(Math.round(text2/text1))*text1)) {gcd=text1}else {
		   for (var i = Math.round(text1/2) ; i > 1; i=i-1) {
		    if ((text1==(Math.round(text1/i))*i))
		     if ((text2==(Math.round(text2/i))*i)) {gcd=i; i=-1;}
		   }
		  }
		  return gcd;
		}

	function lcm(t1,t2){
	  var cm=1;
	  var f=hcf(t1,t2);
	  cm=t1*t2/f;
	  return cm;
	}	
 	var genRandNumbers=function (level){
	  	var lowerLimit,upperLimit;
 		if(level === 0){
	  		numNumbers = 2;
	  		lowerLimit = 0;
	  		upperLimit = 14;
	  	}else if(level === 1){
	  		numNumbers = 2;
	  		lowerLimit = 15;
	  		upperLimit = 29;
	  	}else{
	  		numNumbers = 3;
	  		lowerLimit = 30;
	  		upperLimit = 74;
	  	}
 		
 		randNumbers[0] = k.rand(0,14);
		
 		for(i=0; i<= 14; i++){
				do{
					flag = 0;
					randNumbers[i] =  k.rand(0,14);
					for(j=0; j<i; j++){
						if(randNumbers[i] === randNumbers[j]){
							flag++;
						}
					}
				}while(flag != 0 );  //end of do while loop	
			}
			
	};	
	var delayObject = function(delayId){
		document.delayForm.delayval.value = 1;
		//clearTimeout(t);
		if(delayId === 0){
			animateFrog();
		}else if(delayId === 1){
			animateRabbit();
		}else if(delayId === 2){
			showLCMmethod();
		}
		else{
			animateFrog();
			animateRabbit();
		}
		
	};
	
	
	var assignLevelButtons = function(imgId){
		var bottomPos = 0.5;
		var leftPos =20+i*15;
		var incI = imgId+1;
		$('#content').append('<div class="exerciseButtons" id="exercise'+incI+'"></div>');
		var exercisebtncss = {
				'bottom': bottomPos+'em',
				'left': leftPos+'em'
				
			};
		$('#exercise'+incI).css(exercisebtncss).bind({
				click : function(){
					currentExercise = imgId;
					startExercise();
		         }
		});
	};
	function assignQuestions(quesId){
		$('#exerciseContainer').append('<div id="ques'+quesId+'" class="questions"></div>');
		$('#ques'+quesId).append('<div class="romanNums">'+romanNums[quesId]+' )</div>');
		$('#ques'+quesId).append('<div id="numbers'+quesId+'" class="numbersBox"></div>');	
		$('#ques'+quesId).append('<div class="inpBox"><input type="text" id="ans'+quesId+'" class="ansBox" /></div>');
		$('#ques'+quesId).append('<div id="display'+quesId+'" class="displayBox"></div>');
		var numCntr = randNumbers[numCounter]*numNumbers;
		for(j = 0; j< numNumbers; j++){
			if(j === numNumbers - 1){
				$('#numbers'+quesId).append(levelNumbers[numCntr]);
			}else{
				$('#numbers'+quesId).append(levelNumbers[numCntr]).append(',');
			}
			numCntr++;
		}
	
		$('#ans'+quesId).addClass('default');
		var ans;
		if(currentExercise === 2){
			ans = lcm(lcm(levelNumbers[numCntr-3],levelNumbers[numCntr-2]),levelNumbers[numCntr-1]);
			
		}else{
			ans = lcm(levelNumbers[numCntr-2],levelNumbers[numCntr-1]);
		}
		answers[numCounter] = ans;
		numCounter++;	
	}
	function nextSection(){
		
		$('#content').html('').append('<div id="exerciseContainer"></div>');
		$('#exerciseContainer').append('<img class="exerciseTitle" src="assets/image/exerciseTitle.png" />');
		if(currentExercise === 0){
			$('#exerciseContainer').append('<img class="exerciseTitle" src="assets/image/exercise1Title.png" />');
		}else{
			$('#exerciseContainer').append('<img class="exerciseTitle" src="assets/image/exerciseRestTitle.png" />');
		}
		//generate the boxes
			
		genRandNumbers(currentExercise);		
	
		scoreboard.scoreboard('reset');
		scoreboard.scoreboard('incTotal',5);

		for(var x = 0; x< TOTAL_QUES;x++){
			assignQuestions(x);
		}
		
		focus_blur();
		$('input[type="text"]:first').focus();
		$('#content').append('<div id="checkButton"></div>');
		showText('checkButton','checkAns3',14,29,'<div id="chckAns3" class="checkAns"></div>');
		showText('checkButton','showAns3',18,0,'<div id="showAns3" class="showAns"></div>');
		showText('checkButton','moreQuesBtn',18,38,'<div id="moreQues"></div>');
		$('#chckAns3').hide();$('#showAns3').hide();$('#moreQues').hide();
		check_show();
		if(currentExercise === 0){
			$('#exerciseContainer').append('<div id="giveOptions"></div>');
			for(var y = 0;y<5;y++){
				$('#giveOptions').append('<div id="opt'+y+'" class="options"></div>');
				var section = (5*currentSection)+y;
				$('#opt'+y).text(answers[section]);
			}
		}
		if(currentExercise != 0){
			$('#timerBar').show();
			startTimer();
		}
	}
	function startExercise(){
		flag_section = 1;
		$('#score_box').show();
		scoreboard = $('#score_box').scoreboard({'layout':'horizontal', 
		       'winningScore': TOTAL_QUES});		
		currentSection = 0;
		numCounter = 0;	
		
		nextSection();
	}
	var nextLesson = function(){
		
		clearTimeout(t);
		flag_section = 0;
		$('#score_box').hide();
		$('#linkShowAns').hide();
		$('#linkCheckAns').hide();
		$('#timerBar').hide();
		$('#content').html('').removeClass('backOpaque');
		$('#gameOver').hide()
		clickCounter = 0;
		
		if(currentLesson === 2){
			showPicture('lesson3ImgDef0','lesson3ImgDef0',0,8);		
			showPicture('lesson3ImgDef1','lesson3ImgDef1',7,25);		
			currentTopButton = 18;
			currentLeftButton = 35;
			showNextButton();
			showText('content','exerciseClickTitle',17,16,'Exercise --- अभ्यास ','FF0000');
			showText('exerciseClickTitle','line',-.5,-3.5,'_____________________');
			for( i = 0;i<3;i++){
				assignLevelButtons(i);
			}
		}
		if(currentLesson === 1){
			showPicture('lesson2ImgDef0','lesson2ImgDef0',0,1);		
			currentTopButton = 5;
			currentLeftButton = 80;
			showNextButton();
		}
		else if(currentLesson === 0){
			$('#linkNextLesson').hide();
			 maxHtFrogTop = .1;
			 baseFrogTop = 2.5;
			 imgFrogCounter = 0;
			 frogJmpCount = 0;
			 
			 maxHtRabbitTop = 9;
			 baseRabbitTop = 10;
			 imgRabbitCounter = 0;
			 rabbitJmpCount = 0;

			 flag_frog = 0;
			 timeLineInsCount = 0;
			showPicture('imgFrogTimeline','timeLine',5,1);
			showPicture('imgFrogAnim','frog0',2.5,2.7);
			
			showPicture('imgRabbitTimeline','timeLine',14.5,1);
			showPicture('imgRabbitAnim','rabbit0',10,2.7);
			
			t=setTimeout(function(){delayObject();},1000);	//gives a complete animation
		}		
	};

	function game(){		
		currentLesson = 0;
		$('#linkNextLesson').show();
		$('#linkPrevLesson').hide();
		nextLesson();
	}	
	
	//function to display the text and fraction symbols inside a div 
	function showText(parentDiv,divName,topPos,leftPos,numText,color){ 
		var textCss = {
				'position':'absolute',
				'top':topPos+'em',
				'left':leftPos+'em',
				'font':'2em arial,verdana,geneva,helvetica',
				'color':'#'+color,
				'z-index':'5',
				'white-space':'pre'
				};
		$('#'+parentDiv).append('<div id="'+divName+'"></div>');
		$('#'+divName).css(textCss).html(numText);
	}
	function makeAnimContainer(divName,topPos,leftPos,width,height,bgColor){
		var fracAnimContainer = {
			'position':'absolute',
			'top': topPos+'em',
			'left': leftPos+'em',
			'width': width+'em',
			'height': height+'em',
			'background-color': '#'+bgColor
		};
		$('#content').append('<div id="'+divName+'"></div>');
		$('#'+divName).css(fracAnimContainer);			
	}
	
	
		//function that keeps the photos at a given place absolute position
	function showPicture(divName,imgName,topPos,leftPos){
		var imgCss = {
				'position':'absolute',
				'top':topPos+'em',
				'left':leftPos+'em',
			};
		$('#content').append('<div id="'+divName+'"></div>');
		$('#'+divName).css(imgCss).html('<img src="assets/image/'+imgName+'.png" />');
	}
	
	 function showNextButton(){
			$('#content').append('<div class="nextBtn"></div>');
			$('.nextBtn').show();	
			var nextbtncss = {
				'top': currentTopButton+'em',
				'left': currentLeftButton+'em'				
			};
			
			$('.nextBtn').css(nextbtncss);//html('<img src="assets/image/nextBtn.png"/>');
			$('.nextBtn').click(function(){
				manageClicks();
			});
					
		}
	 function hideNextButton(){
		$('.nextBtn').hide();
	}
		
		
		function showLCMmethod(){
			if(lcmMethCounter === 0){
				showPicture('lesson2Sign2','lesson2ImgSign',34.1,15);
				showText('lesson2Sign2','lesson2Text2',-.1,-.6,'2   2,4');
			}else if(lcmMethCounter === 1){
				showText('lesson2Sign2','lesson2Text3',1,.8,'1,2');			
			}else if(lcmMethCounter === 2){
				showPicture('lesson2ImgDef7','lesson2ImgDef7',32,25);			
			}else if(lcmMethCounter === 3){
				showPicture('lesson2ImgDef8','lesson2ImgDef8',34.5,25);			
			}else if(lcmMethCounter === 4){
				showPicture('lesson2ImgDef9','lesson2ImgDef9',39,20);			
			}
			lcmMethCounter++;
			t=setTimeout(function(){delayObject(2);},1000);  //text lcm
			
		}
		function animateFrog(){	
			
			baseFrogLeft = 2.7 + frogJmpCount*9;
			showPicture('imgFrogAnim','frog1',baseFrogTop-2,baseFrogLeft);
			baseFrogLeft = 6 + frogJmpCount*9;
			imgAnimateFrog('imgFrogAnim',maxHtFrogTop,baseFrogLeft,1000);
			
		}
		function animateRabbit(){	
			baseRabbitLeft = 4 + rabbitJmpCount*14;
			showPicture('imgRabbitAnim','rabbit1',baseRabbitTop+1,baseRabbitLeft);
			baseRabbitLeft = 10 + rabbitJmpCount*14;
			imgAnimateRabbit('imgRabbitAnim',maxHtRabbitTop,baseRabbitLeft,1000);
		}
		function imgAnimateFrog(divName,topPos,leftPos,duration){
			$('#'+divName).animate(
					{top:topPos+'em',left:leftPos+'em'},duration,
					function(ev){
							if(imgFrogCounter === 0){
								baseFrogLeft = 11.4 + frogJmpCount * 9;
								imgFrogCounter++;
								imgAnimateFrog('imgFrogAnim',baseFrogTop-2,baseFrogLeft,1000);
						
							}else if(imgFrogCounter === 1){
								showPicture('imgFrogAnim','frog0',baseFrogTop,baseFrogLeft);
								showPicture('frogRing'+frogJmpCount,'timeRing',baseFrogTop+1.5,baseFrogLeft+1.2);
								frogJmpCount++;
								imgFrogCounter = 0;
								if(frogJmpCount != 10){
									if(frogJmpCount%3 != 0){
										flag_frog = 0;
										t=setTimeout(function(){delayObject(0);},1000);  //frog
									}
									else{
										flag_frog = 1;
									}	
									if(flag_frog === 1){	
										flag_frog = 0;
										timeLineLeft = 31.5 + timeLineInsCount*27;
										showPicture('imgTimeLineIntersect'+timeLineInsCount,'timeLineIntersect',0,timeLineLeft);
										if(frogJmpCount != 9){
											t=setTimeout(function(){delayObject(0);},2000);  //frog
											t=setTimeout(function(){delayObject(1);},2000); //rabbit
										}
										else{
											//start the lcm defintion process
											currentTopButton = 21;
											currentLeftButton = 80;
											showNextButton();
											showPicture('imgLesson1ImgDef0','lesson1ImgDef0',21,18);
										}
										timeLineInsCount++;
									}
								}
							
							}
					});	
		}
			
		function imgAnimateRabbit(divName,topPos,leftPos,duration){
			$('#'+divName).animate(
					{top:topPos+'em',left:leftPos+'em'},duration,
					function(ev){
							if(imgRabbitCounter === 0){
								baseRabbitLeft = 15.5 + rabbitJmpCount * 13.5;
								imgRabbitCounter++;
								imgAnimateRabbit('imgRabbitAnim',baseRabbitTop,baseRabbitLeft,1000);
							}else if(imgRabbitCounter === 1){
								showPicture('imgRabbitAnim','rabbit0',baseRabbitTop,baseRabbitLeft);
								showPicture('imgRabbitAnim'+rabbitJmpCount,'timeRing',baseRabbitTop+3.5,baseRabbitLeft+1.5);
								rabbitJmpCount++;
								imgRabbitCounter = 0;
								if(rabbitJmpCount%2 != 0 ){
									t=setTimeout(function(){delayObject(1);},1000);  //frog
								}
							}
							
					});	
		}

		function manageClicks(){
			if(currentLesson === 2){
				if(clickCounter === 0){
					showPicture('lesson3ImgDef2','lesson3ImgDef2',9,0);
					showText('lesson3ImgDef2','lesson3inputText1',5,0,'<input type="text" id="lesson3input1" class="inputBox"  />');
					showText('lesson3ImgDef2','symChecked1',5,4,'');
					focus_blur();
					$('#lesson3input1').focus();
					showText('lesson3ImgDef2','checkAns1',6.5,-1,'<div id="chckAns1" class="checkAns"></div>');
					showText('lesson3ImgDef2','shownAns1',6.5,4,'<div id="showAns1" class="showAns"></div>');
					check_show();
					hideNextButton();
				}else if(clickCounter === 1){
					showPicture('lesson3ImgDef3','lesson3ImgDef3',9,65);
					showText('lesson3ImgDef3','lesson3inputText2',5,0,'<input type="text" id="lesson3input2" class="inputBox"  />');
					showText('lesson3ImgDef3','symChecked2',5,4,'');
					focus_blur();
					$('#lesson3input2').focus();				
					showText('lesson3ImgDef3','checkAns2',6.5,-1,'<div id="chckAns2" class="checkAns"></div>');
					showText('lesson3ImgDef3','shownAns2',6.5,4,'<div id="showAns2" class="showAns"></div>');
					check_show();
					hideNextButton();
				}else if(clickCounter === 2){
					showPicture('lesson3ImgDef4','lesson3ImgDef4',22,28);
				}
				else if(clickCounter === 3){
					showPicture('lesson3ImgDef5','lesson3ImgDef5',28,15);
					hideNextButton();
				}
			}
			else if(currentLesson === 1){
				if(clickCounter === 0){
					showPicture('lesson2ImgDef1','lesson2ImgDef1',10,1);
				}else if(clickCounter === 1){
					showPicture('lesson2ImgDef2','lesson2ImgDef2',13,1);
				}else if(clickCounter === 2){
					showPicture('lesson2ImgDef3','lesson2ImgDef3',15.5,1);
				}else if(clickCounter === 3){
					showPicture('lesson2ImgDef4','lesson2ImgDef4',25,1);
				}else if(clickCounter === 4){
					showPicture('lesson2ImgDef5','lesson2ImgDef5',27,1);
				}else if(clickCounter === 5){
					showPicture('lesson2ImgDef6','lesson2ImgDef6',29.5,10);
				}else if(clickCounter === 6){
					lcmMethCounter =0;
					showPicture('lesson2Sign1','lesson2ImgSign',32,15);
					showText('lesson2Sign1','lesson2Text1',-.1,-.6,'2   4,8');
					t=setTimeout(function(){delayObject(2);},1000);  //text lcm
					hideNextButton();
				}			
			}
			
			else if(currentLesson === 0){
				if(clickCounter === 0){
					$('#linkNextLesson').show();
					showPicture('imgLesson1ImgDef1','lesson1ImgDef1',24.5,18);
				}else if(clickCounter === 1){
					showPicture('imgLesson1ImgDef2','lesson1ImgDef2',28,18);
				}else if(clickCounter === 2){
					showPicture('imgLesson1ImgDef3','lesson1ImgDef3',31.5,18);
				}else if(clickCounter === 3){
					showPicture('imgLesson1ImgDef4','lesson1ImgDef4',36,20);
					hideNextButton();
				}
			}
			clickCounter++;
		}
		
		function check_show(){
			$('.checkAns').click(function(){
				var checkId = $(this).attr('id');
				var checkId =  parseInt(checkId.substring(7));;
				if(checkId === 1){
					if($('#lesson3input1').val() == '7'){
						k.audio.correct.play();
						$('#symChecked1').html('<img src="assets/image/correct.png" />');
					}else{
						k.audio.incorrect.play();
						$('#symChecked1').html('<img src="assets/image/incorrect.png" />');
					}
				}else if(checkId === 2){
					if($('#lesson3input2').val() == '1,3,7'){
						k.audio.correct.play();
						$('#symChecked2').html('<img src="assets/image/correct.png" />');
					}else{
						k.audio.incorrect.play();
						$('#symChecked2').html('<img src="assets/image/incorrect.png" />');
					}
				}else if(checkId === 3){
					for( i = 0; i<5;i++){
						var section = (5*currentSection)+i;
						var answer =  $('#ans'+i).val();
						if(answers[section] == answer){
							$('#display'+i).html('<img src="assets/image/correct.png" />');
							scoreboard.scoreboard('inc');
						}else{
							$('#display'+i).html('<img src="assets/image/incorrect.png" />');
						}
					}
					$('#chckAns3').hide();
					$('#showAns3').show();
					if(currentSection != 2){
						$('#moreQues').show();
					}
					stopTimer();
				}
			});
			
			
			$('.showAns').click(function(){
				var showId = $(this).attr('id');
				var showId =  parseInt(showId.substring(7));
				if(showId === 1){	
					$('#lesson3input1').val(7)
					$('#symChecked1').html('<img src="assets/image/correct.png" />');
					showNextButton();
				}else if(showId === 2){
					$('#lesson3input2').val('1,3,7')
					$('#symChecked2').html('<img src="assets/image/correct.png" />');
					showNextButton();
				}else if(showId === 3){				
					for( i = 0; i<5;i++){
						var section = (5*currentSection)+i;
						$('#ans'+i).val(answers[section]);
						$('#display'+i).html('<img src="assets/image/correct.png" />');
					}
					$('#showAns3').hide();
				}
				
			});
			
			$('#moreQues').click(function(){
				currentSection++;
				nextSection();
				$('#moreQues').hide();
			});
		}
		
		
		function focus_blur(){
			$('input[type="text"]')
			.focus(function() {
				
			    $(this).addClass("focus");
			   
			    currentInpBox =  $(this).attr("id");
			    currentInpBox =  parseInt(currentInpBox.substring(3));
			  
			})
			.blur(function() {
				var countBox = 0;
			    $(this).removeClass("focus");
			    for(i = 0;i<5;i++){
					if($('#ans'+i).val() != ''){
						countBox++;
					}
				}
			    if(countBox === 5){
			    	//show check button
			    	$('#chckAns3').show();
			    }
			})
			.keypress(function(event) {
				if(event.which === 13){
					//$(this).removeClass("focus");
					if(currentInpBox != 4){
						$('#ans'+currentInpBox).blur();
					}
					var currentInpBoxnext = currentInpBox+1;
					$('#ans'+currentInpBoxnext).focus();
				}
			});
			
		}
		$('#linkNextLesson').click(function(){
			currentLesson++;
			if(currentLesson === 2){
				$('#linkNextLesson').hide();
				$('#linkPrevLesson').show();
			}
			else{
				$('#linkNextLesson').show();
				$('#linkPrevLesson').show();
			}
		
			nextLesson();
		});
		$('#linkPrevLesson').click(function(){
			
			if(currentLesson === 2 && flag_section === 1){
				currentLesson = 2;	
				nextLesson();
			}else{
				currentLesson--;
				if(currentLesson === 0){					
					$('#linkPrevLesson').hide();
				}
				else{
					$('#linkNextLesson').show();
					$('#linkPrevLesson').show();
				}
				nextLesson();
			}
			
			
		});

		$('#linkStart').click(function(){
			game();
		});
		
		$('#linkPlayAgain').click(function(){
			//nextLesson();
			nextLesson();
		});
				

		
		$('#linkShowAns').hide();
		$('#linkCheckAns').hide();
		$('#linkNextLesson').hide();
		$('#linkPrevLesson').hide();
		$('#linkHelp').click(function(){
			$('#help').slideDown(2000);
		})
		.mouseout(function(){
			$('#help').slideUp(2000);
		});	
		
	
		

			
	}); //end of k.ready
});	//end of document.read