//3 jan
var Crossword={};
var Utils={};
Utils.Path='';
Utils.mobileDeviceFlag=false;
var questionId=0,startTime=0,scoredMarks=0,totalMarks=10,resId=0,correctCnt=0,totalNos=0;
$(document).ready(function()
{
	$(".se-pre-con").fadeOut("slow");
	if(navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i))
		Utils.mobileDeviceFlag=true;
	//if(Utils.mobileDeviceFlag)
		//Utils.Path=Android.getMediaPath("CrossWord"); 
	setTimeout(function()
	{
		Crossword.setImages();
		document.body.style.backgroundImage="url("+'images/skin/Cover.png'+")";
	},200);
});
//initialise variables //
Crossword.initialiseVariables=function()
{
	Crossword.questionArr=[];
	Crossword.setWordArray=[];
	Crossword.divsArr=[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];
	Crossword.selectedLetterId=[];
	Crossword.exitCounter=0;
	Crossword.allSplitWordArr=[];
	Crossword.time=60;
	Crossword.selectedLetterData=[];
	Crossword.setWordDivArr=[];
	correctCnt=0;
	Crossword.timeTaken=0;
	Crossword.arr=[];
	Crossword.questionCnt=0;
	Crossword.timer=null;
	Crossword.width=100;
	Crossword.attemptFlag=false;
	Crossword.skipFlag=true;
	Crossword.checkDataFlag=true;
	Crossword.labelWord='';
	totalNos=Crossword.Data.length;
}
//gets call on levels//
Crossword.init=function()
{
	document.getElementById('coverPage').style.display="none";
	document.getElementById('crossWordGamePage').style.display="block";
	document.getElementById('resetBtnDiv').style.display="block";
	document.getElementById('homeDiv').style.visibility="visible";
	document.body.style.backgroundImage="url("+'images/skin/bg.png'+")";
	Crossword.initNPlay();
}
//common functionalities of init and play//
Crossword.initNPlay=function()
{
	document.getElementById("progressBar").style.transition="none";
	scoreFlag=false;
	scoredMarks=0;
	document.getElementById("playSoundBack").src=Utils.Path+"sounds/bgSound.mp3";
	document.getElementById("playSoundBack").loop=true;
	document.getElementById("playSoundBack").play(); 
	clearInterval(Crossword.timer);
	clearInterval(Crossword.showModaltime);
	$('#progressBar').removeClass("progress-bar progress-bar-danger");
	$('#progressBar').addClass("progress-bar-success progress-bar");
	Crossword.width=100;
	document.getElementById("progressBar").style.width = Crossword.width + '%';
	document.getElementById('progressBarDiv').style.visibility="visible";
	clearInterval(Crossword.AutomateTimeOut);
	Crossword.initialiseVariables();
	document.getElementById('gridDiv').style.pointerEvents='auto';
	$('.ptrClass').css("pointer-events","auto");
	document.getElementById('crossWordGamePage').style.display='block';
	/*  setInterval(function() 
	{ 
	Crossword.nextQuestion();
	},200); */   
	Crossword.createDiv();
	getUniqueValArr(Crossword.Data,Crossword.questionArr,Crossword.Data.length);
	shuffleArray(Crossword.questionArr); 
	Crossword.setGridWords();
	while(Crossword.setWordArray.length<=3)
	{
	//	alert("yes");
		Crossword.initialiseVariables();
		getUniqueValArr(Crossword.Data,Crossword.questionArr,Crossword.Data.length);
		shuffleArray(Crossword.questionArr); 
		Crossword.createDiv();
		Crossword.setGridWords();
	}
	Crossword.setSearchWords();
	Crossword.setRemainingLetters();
	Crossword.setTimer();
	return 0;
}
//playAgain
Crossword.playAgain=function()
{  
	levelNumber=1;
	document.getElementById("progressBar").style.transition="none";
	$("#creditDiv").css("pointer-events","auto");
	document.getElementById("progressBarDiv").style.visibility = "visible";
	document.getElementById("resetBtnDiv").style.display = "block";
	$('#endpage').hide();	
	Crossword.initNPlay();
}
Crossword.setTimer=function()//progress bar
{
	var intervalVar=0;
	if(Crossword.timer)
	{
		clearInterval(Crossword.timer);
		Crossword.timer=null;
	}
	setTimeout(function()
	{
		document.getElementById("progressBar").style.transition="width .6s ease";
	},200);
	Crossword.timer=setInterval(function() 
	{ 
		Crossword.width-=1; 
		Crossword.timeTaken=Math.floor(60-(Crossword.width * 0.6));
		document.getElementById("progressBar").style.width = Crossword.width + '%'; 
		if(Crossword.width==30)
			$('#progressBar').addClass("progress-bar progress-bar-danger");
		if(Crossword.width<=0 || Crossword.arr.length==0)
		{
			if(Crossword.arr.length != 0)
				intervalVar=7000;
			else
				intervalVar=1000;
			setTimeout(function() 
			{ 
				if(Crossword.arr.length == 0)
				{
					document.getElementById('playSound').src=Utils.Path+"sounds/Brilent.mp3";
					document.getElementById('playSound').play();
				}
			},500);
			clearTimeout(Crossword.AutomateTimeOut);
			clearInterval(Crossword.timer);
			Crossword.timer=null;
			document.getElementById('gridDiv').style.pointerEvents='none';
			$('.ptrClass').css('pointer-events','none');
			$('#homeDiv').css('pointer-events','none');
			$('#resetBtnDiv').css('pointer-events','none');
			$('body').css("opacity","0.5");
			Crossword.highLightRemaining();
			if(Crossword.showModaltime)
			{
				clearTimeout(Crossword.showModaltime);
				Crossword.showModaltime=null;
			}
			Crossword.showModaltime=setTimeout(function()
			{
				$('body').css("opacity","");
				$('#homeDiv').css('pointer-events','auto');
				$('#resetBtnDiv').css('pointer-events','auto');
				Crossword.calculateScore();
				Crossword.showModal();//Crossword.setWordArray.length,correctCnt,timeTaken
			},intervalVar);//5000
		}
	},600);//600
}
Crossword.setImages=function()
{
	document.body.style.backgroundImage="url("+Utils.Path+"images/skin/Cover.png)";
	$("#playAgain").prop('src',Utils.Path+"images/skin/Replay.png");
	$("#credit").prop('src',Utils.Path+"images/skin/CREDITS.png");
	$("#next").prop('src',Utils.Path+"images/skin/Next.png");
	//$("#homeImg").prop('src',Utils.Path+"images/skin/Home.png");
	$("#logoImg").prop('src',Utils.Path+"images/skin/logo.png");
	$("#playImg").prop('src',Utils.Path+"images/skin/Play.png");
	$("#resetBtnImg").prop('src',Utils.Path+"images/skin/Replay.png");
//	$("#checkImg").prop('src',Utils.Path+"images/skin/Done.png");
}
// create divs
Crossword.createDiv=function()
{
	document.getElementById('gridDiv').innerHTML='';
	var mainDiv,wordDiv,idCnt=1,randomBG=0;
	for(var i=0;i<5;i++)
	{
		mainDiv=document.createElement("div");
		mainDiv.setAttribute("id","mainDiv"+i);
		mainDiv.setAttribute("class","fiveDivs noPadding col-lg-12 col-md-12 col-xs-12 col-sm-12");
		document.getElementById("gridDiv").append(mainDiv);
		for(j=0;j<5;j++)
		{
			randomBG=Math.floor(Math.random()*Crossword.bgImageData.length);
			wordDiv=document.createElement("div");
			wordDiv.setAttribute("id","wordDiv"+idCnt);
			wordDiv.style.backgroundColor=Crossword.bgImageData[randomBG];
			wordDiv.setAttribute("data",idCnt);
			wordDiv.setAttribute("bgData",Crossword.bgImageData[randomBG]);
	//		wordDiv.setAttribute("clickedColor",Crossword.clickedBgData[randomBG]);
			wordDiv.setAttribute("class","ptrClass noPadding border col-lg-2 col-md-2 col-xs-2 col-sm-2");
			wordDiv.setAttribute("onclick","Crossword.selectLetter(this.id)");
			mainDiv.append(wordDiv);
			idCnt++;
		}
	}
}
//set all words to right Div
Crossword.setSearchWords=function()
{
	var word,imgEle,finalArr=[],gliphDiv;
	homeFlag="showLevels";
	document.getElementById('imageDiv1').innerHTML='';
	document.getElementById('imageDiv2').innerHTML='';
	var d=new Date();
	startTime=d.getDate()+"-"+(d.getMonth()+1)+"-"+d.getFullYear()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds(); 
	console.log(Crossword.setWordArray);
	Crossword.skipFlag=true;
	for(var i=0;i<4;i++)
	{
		word=document.createElement('div');
		word.setAttribute('id',"word"+(i+1));
		word.setAttribute('class','imgCls noPadding col-xs-10 col-sm-10 col-lg-10 col-md-10 col-xs-offset-2 col-sm-offset-2 col-md-offset-2 col-lg-offset-2');
		gliphDiv=document.createElement('div');
		gliphDiv.setAttribute('id',"gDiv"+(i+1));
		gliphDiv.setAttribute('class','gliphyCls noPadding col-lg-12 col-md-12 col-xs-12 col-sm-12');
		imgEle=document.createElement('img');
		imgEle.setAttribute('id',"wordImg"+(i+1));
		imgEle.setAttribute('style',"object-fit:contain");
		imgEle.setAttribute('src',Utils.Path+"images/"+Crossword.setWordArray[i]+".png");
		finalArr.push(Crossword.setWordArray[i]);
		imgEle.setAttribute('class','img-responsive noPadding col-xs-11 col-sm-11 col-lg-11 col-md-11 col-xs-offset-1 col-sm-offset-1 col-md-offset-1 col-lg-offset-1');
		word.append(imgEle);
		word.append(gliphDiv);
		if(i<2)
			document.getElementById('imageDiv1').append(word);
		else
			document.getElementById('imageDiv2').append(word);
	}
	Crossword.setWordArray=[];
	Crossword.setWordArray=finalArr.slice();
	return 0;
}
// get random divs and random operation //
Crossword.setGridWords=function()
{
	var randomPosition=0,randomDiv,emptyDivLength=0,firstDiv,i;
	randomDiv=Math.floor(Math.random()*Crossword.divsArr.length);
	if(Crossword.divsArr.length == 0)
		return 0;
	randomPosition=Math.floor(Math.random()*2);
	if(randomPosition == 0)
		randomOpration= 'horizontal';
	else
		randomOpration= 'vertical';
	Crossword.checkLengthPositionWise(Crossword.divsArr[randomDiv],randomOpration);
	return 0;
}
// find empty position//
Crossword.checkLengthPositionWise=function(randomDiv,randomOpration)
{
	var nextDivCnt=0,emptyDivLength=0,firstDiv=0,reducedFlag=false;
	firstDiv = randomDiv;
	if(randomOpration == 'horizontal')
	{
		while(randomDiv % 5 != 0)
		{
			if(document.getElementById('wordDiv'+randomDiv).innerHTML == '')
			{
				emptyDivLength++;
				randomDiv+=1;
			}
			else
			{
				emptyDivLength--;
				reducedFlag=true;
				break;
			}
		}
		if(document.getElementById('wordDiv'+randomDiv).innerHTML == '')
			emptyDivLength++;
		if(reducedFlag)
		{
			reducedFlag=false;
			emptyDivLength++;	
		}	
	}
	else
	{
		while(document.getElementById('wordDiv'+randomDiv).parentElement.getAttribute('id')!='mainDiv4')
		{
			if(document.getElementById('wordDiv'+randomDiv).innerHTML == '')
			{
				emptyDivLength++;
				randomDiv+=5;
			}
			else// inner html null nasel tr tevdach length gheun baher padel
			{
				emptyDivLength--;
				reducedFlag=true;
				break;
			}
		}
		if(document.getElementById('wordDiv'+randomDiv).innerHTML == '')//when reached to 6
			emptyDivLength++;
		if(reducedFlag)
		{
			reducedFlag=false;
			emptyDivLength++;	
		}	
	}
	if(Crossword.exitCounter >= 6)
		return 0; 
	if(emptyDivLength == 1)
	{
		Crossword.exitCounter++;
		 if(Crossword.exitCounter <= 5)
			Crossword.setGridWords();
		else
			return 0; 
	}
	else
		Crossword.setWord(firstDiv,emptyDivLength,randomOpration);
	return 0;
}
// set word in empty position //
Crossword.setWord=function(firstDiv,emptyDivLength,randomOpration)
{
	var incrementBy=0,isWordSet=false,splitWord=[];
	if(randomOpration == 'horizontal')
		incrementBy=1;
	else
		incrementBy=5;
	for(i=0;i<Crossword.questionArr.length;i++)
	{
		if(emptyDivLength != 0)
		{
			if(Crossword.questionArr[i].length == emptyDivLength)
			{
				Crossword.exitCounter=0;
				isWordSet=true;
				Crossword.setWordArray.push(Crossword.questionArr[i]);
				splitWord=Crossword.questionArr[i].split('');
				Crossword.questionArr.splice(i,1);
				for(var j=0;j<splitWord.length;j++)
				{
					document.getElementById('wordDiv'+firstDiv).innerHTML=splitWord[j];
					document.getElementById('wordDiv'+firstDiv).setAttribute("divdata",randomOpration);
					Crossword.setWordDivArr.push('wordDiv'+firstDiv);//push word's div Id's that have set to grid
					Crossword.allSplitWordArr.push(splitWord[j]);
					var ind=Crossword.divsArr.indexOf(firstDiv);
					Crossword.divsArr.splice(ind,1);
					firstDiv+=incrementBy;
				}
				break;
			}
			else if(i == (Crossword.questionArr.length-1))// when word is not found that of length,then decrease emptyDivLength
			{
				Crossword.exitCounter++;
				if(Crossword.exitCounter >= 6) 
					return 0;
				else
				{
					emptyDivLength--;
					i=0;
				}
			} 
		}
		else
		{
			exitCounter=0;//
			Crossword.setGridWords();// if empty div length is 0 then  call to setGridWords
		}
	}
	if(isWordSet==true)
	{
		isWordSet=false;
		Crossword.setGridWords();
	}
	return 0;
}
// when user click on letters
Crossword.selectLetter=function(id)
{
	var operation,letter,clickedColor;
	scoreFlag=true;
	//clickedColor=document.getElementById(id).getAttribute('clickedColor');
	Crossword.skipFlag=false;
	Crossword.attemptFlag=true;
	$('#'+id).css("pointer-events","none");
	if(Crossword.AutomateTimeOut)
	{
		clearTimeout(Crossword.AutomateTimeOut);
		Crossword.AutomateTimeOut=null;
	}
	if(Crossword.checkDataFlag)
	{
		operation=document.getElementById(id).getAttribute('divdata');
		Crossword.checkDataFlag=false;
	}
	document.getElementById(id).style.backgroundColor="#f79c1d";
	Crossword.selectedLetterId.push(id);
	Crossword.selectedLetterData.push(parseInt(document.getElementById(id).getAttribute('data')));
	letter=document.getElementById(id).innerHTML;
	document.getElementById('playSound').src=Utils.Path+"sounds/"+letter+".mp3";
	document.getElementById('playSound').play();
	Crossword.AutomateTimeOut=setTimeout(function()
	{
		Crossword.joinLetter(operation);
	},1500);
}
// set remaining letters//
Crossword.setRemainingLetters=function()
{
	var randomLetter;
	for(j=1;j<=25;j++)//display remainining Letters			
	{
		if(document.getElementById("wordDiv"+j).innerHTML=="")
		{
			randomLetter=Math.floor(Math.random()*Crossword.alphabetArr.length);
			while($.inArray(Crossword.alphabetArr[randomLetter],Crossword.allSplitWordArr)!==-1)
				randomLetter=Math.floor(Math.random()*Crossword.alphabetArr.length);
			document.getElementById("wordDiv"+j).innerHTML = Crossword.alphabetArr[randomLetter];
		}
	}
	Crossword.arr=[];
	Crossword.arr=Crossword.setWordArray.slice();		
}
// get concat the clicked letter and check word//
Crossword.joinLetter=function(operation)
{
	var word='',checkFlag=false,idx,idxarr,index,bgData='';
	if(Crossword.width == 1)
		return 0;
	if(Crossword.AutomateTimeOut)
		clearTimeout(Crossword.AutomateTimeOut);
	for(var i=0;i<Crossword.selectedLetterId.length;i++)
	{
		word+=$('#'+Crossword.selectedLetterId[i]).text();
	}
	for(var k=1;k<Crossword.selectedLetterData.length;k++)
	{
		if(!((Crossword.selectedLetterData[k] - Crossword.selectedLetterData[k-1] == 5 || Crossword.selectedLetterData[k] - Crossword.selectedLetterData[k-1] == 1) || (Crossword.selectedLetterData[k-1] - Crossword.selectedLetterData[k] == 5 || Crossword.selectedLetterData[k-1] - Crossword.selectedLetterData[k] == 1)))
			checkFlag=true;
	}
	if(Crossword.arr.includes(word) && checkFlag==false)
	{
		for(var j=0;j<Crossword.selectedLetterId.length;j++)//for right Ans
		{
			document.getElementById(Crossword.selectedLetterId[j]).style.backgroundColor='rgb(4, 86, 27)';
			$('#'+Crossword.selectedLetterId[j]).css("pointer-events","auto");
			document.getElementById(Crossword.selectedLetterId[j]).setAttribute('colorData','color');
		}
		console.log(word,totalNos,"word");
		if(Utils.mobileDeviceFlag)
			Android.addLearntData(word,totalNos,"word"); 
		Crossword.labelWord=Crossword.labelWord+word+',';
		document.getElementById('playSound').src=Utils.Path+"sounds/"+word+".mp3";
		document.getElementById('playSound').play();
		correctCnt++;
		scoredMarks += 10;
		idx=Crossword.setWordArray.indexOf(word);
		idxarr=Crossword.arr.indexOf(word);
		Crossword.selectedLetterId=[];
		Crossword.arr.splice(idxarr,1);
		$('#'+'gDiv'+(idx+1)).addClass('glyphicon glyphicon-ok');
		document.getElementById('gDiv'+(idx+1)).style.visibility = "visible";
	}
	else if(!(Crossword.setWordArray.includes(word)) || checkFlag==true)// for wrong answer
	{
		
		for(var j=0;j<Crossword.selectedLetterId.length;j++)
		{
			document.getElementById(Crossword.selectedLetterId[j]).style.backgroundColor="red";
		}
		Crossword.removeBackgroundClr=setTimeout(function()
		{
			for(var i=0;i<Crossword.selectedLetterId.length;i++)
			{
				$('#'+Crossword.selectedLetterId[i]).css("pointer-events","auto");
				bgData=document.getElementById(Crossword.selectedLetterId[i]).getAttribute('bgData');
				document.getElementById(Crossword.selectedLetterId[i]).style.backgroundColor=bgData;
			}
			Crossword.selectedLetterId=[];
		},500);
	}
	else//
	{
		for(var i=0;i<Crossword.selectedLetterId.length;i++)
		{
			document.getElementById(Crossword.selectedLetterId[i]).style.backgroundColor='rgb(4, 86, 27)';
			$('#'+Crossword.selectedLetterId[i]).css("pointer-events","auto");
		}
		Crossword.selectedLetterId=[];
	}
	Crossword.selectedLetterData=[];
	checkFlag=false;
}
// highlight Words//
Crossword.highLightRemaining=function()
{
	var colorName='',splitWord='',data='',incrementBy=0,temp,word='',divIdArr=[],wordFlag=false,bgFlag=false,colorData='';
	colorArray=['rgb(128,0,128)','rgb(255,0,255)','rgb(0,0,128)','rgb(220,20,60)','rgb(139,100,46)','rgb(32,178,170)','rgb(128,0,0)','rgb(70,130,180)','rgb(255,165,0)','rgb(25,25,112)','rgb(255,153,255)','rgb(179,255,179)','rgb(255,128,0)','rgb(191,255,0)'];
	Crossword.arr.sort(function(a, b){return b.length - a.length});

	for(var i=0;i<Crossword.arr.length;i++)
	{
		randomColor=Math.floor(Math.random()*colorArray.length);
		colorName=colorArray[randomColor];
		colorArray.splice(randomColor,1);
		splitWord='';
		splitWord=Crossword.arr[i];
		for(var j=1;j<=25;j++)
		{
			word='';
			
			if(document.getElementById('wordDiv'+j).innerHTML == splitWord[0])
			{
				divIdArr=[];
				temp=j;
				data=document.getElementById('wordDiv'+j).getAttribute("divdata");
				if(data == "horizontal")
					incrementBy=1;
				else
					incrementBy=5;
				for(var k=0;k<splitWord.length;k++)
				{
					divIdArr.push('wordDiv'+j)
					if(document.getElementById('wordDiv'+j).innerHTML != '')
					{
						word=word+document.getElementById('wordDiv'+j).innerHTML;
						bgColor=$('#wordDiv'+j).css("background-color");
					}
					j=j+incrementBy;
					if(j>25)
						break;
				}
				console.log(word);
				if(word == splitWord && bgColor != 'rgb(4, 86, 27)')//'rgba(0, 0, 0, 0)')
				{
					wordFlag=true;
					for(var l=0;l<divIdArr.length;l++)
					{
						document.getElementById(divIdArr[l]).style.backgroundColor=colorName;
						document.getElementById(divIdArr[l]).style.color='white';
						//document.getElementById(divIdArr[l]).style.opacity='0.8';
						document.getElementById(divIdArr[l]).setAttribute('colorData','color');
					}
				}
				if(wordFlag == true)
				{
					wordFlag=false;
					break;
				}
				else
					j=temp;
			}
		}
		
	}
	for(var m=1;m<=25;m++)
	{
		colorData=document.getElementById('wordDiv'+m).getAttribute('colorData');
		if(colorData != 'color')
		{
			document.getElementById('wordDiv'+m).style.backgroundColor="#f5f5f5c7";
			document.getElementById('wordDiv'+m).style.color="black";
			document.getElementById('wordDiv'+m).style.opacity='0.8';
		}
	}  
	console.log(Crossword.arr);
}
//nextQuestion
Crossword.nextQuestion=function()
{
	document.getElementById('playSound').pause();
	if(scoredMarks < 10)
	{
		if(Crossword.attemptFlag)
		{
			scoredMarks=0;
			Crossword.attemptFlag=false;
			Crossword.calculateScore();
		}
		if(Crossword.skipFlag)
		{
			scoredMarks=-1;
			Crossword.calculateScore();
		}
	}
	else
		Crossword.calculateScore();
	Crossword.playAgain();
}
Crossword.calculateScore=function()
{
	Crossword.attemptFlag=false;
	console.log(resId, 0, scoredMarks, 40,2,startTime,Crossword.labelWord);
	 if(Utils.mobileDeviceFlag)
		Android.addScore(resId,0,scoredMarks,40,1,startTime,Crossword.labelWord);  
}
Crossword.showModal=function()//totalWords,correctCnt,timeTaken
{
	clearInterval(Crossword.timer);
	document.getElementById("endpage").style.display = "block";
	document.getElementById("resetBtnDiv").style.display = "none";
	document.getElementById("crossWordGamePage").style.display = "none";
	document.getElementById("progressBarDiv").style.visibility = "hidden";
	$("#gameOver").text(Crossword.hardcoded.gameOver);
	document.getElementById('starDiv').style.visibility="visible";
	document.getElementById('nextDiv').style.display='block';
	$('#nextDiv').addClass('blink_me');
	 if(Utils.mobileDeviceFlag) 
		Android.StudentCertification(correctCnt,Crossword.setWordArray.length,"7"); 
	Crossword.createStars();
	Crossword.giveStars();
}
Crossword.callHome=function()
{
	if(Crossword.attemptFlag)
	{
		Crossword.attemptFlag=false;
		Crossword.calculateScore();
	}
	location.reload();
}
Crossword.showCredits=function()								//Acknowledgement Details
{
	var ackDiv;
	$("#creditDiv").css("pointer-events","none");
	document.getElementById("acknowledgementDiv").style.display="block";
	$("#ScorePage").hide();
	$("#acknowledgementDiv").show();
	for(var i=0;i<Object.keys(Crossword.ackData).length;i++)
	{
		ackDiv= document.createElement("div");
		ackDiv.setAttribute("id","ack"+i); 
		ackDiv.setAttribute("class","noPadding firstLetter text-center fontClass col-sm-12 col-lg-12 col-md-12 col-xs-12"); 
		ackDiv.innerHTML=Object.keys(Crossword.ackData)[i]+" : "+Object.values(Crossword.ackData)[i];
		document.getElementById("acknowledgementDiv").appendChild(ackDiv);
	}
}
Crossword.createStars=function()
{
	var newImage,newDiv,i,numberOfStars=4;
	for(i=1;i<=numberOfStars;i++)
	{
		newDiv= document.createElement("div");
		newDiv.setAttribute("id","starDiv"+i); 
		newDiv.setAttribute("class","noPadding stars col-xs-2 col-md-2 col-lg-2 col-sm-2"); 

		newImage= document.createElement("img");
		newImage.setAttribute("id","starImg"+i); 
		newImage.setAttribute("class","img-responsive noPadding col-sm-12 col-lg-12 col-md-12 col-xs-12"); 
		newImage.setAttribute("src",Utils.Path+"images/skin/star1.png");
		$(newDiv).append(newImage);
		$("#starDiv").append(newDiv);
	}
	$("#starDiv").css("visibility","hidden");
}
Crossword.giveStars=function()
{
	
	var i,numberOfStars=correctCnt;
	for(i=1;i<=numberOfStars;i++)
		document.getElementById("starImg"+i).setAttribute("src",Utils.Path+"images/skin/star2.png");
	if(numberOfStars!=0)
	{
		document.getElementById('playSound').src=Utils.Path+'sounds/instruction/Star'+numberOfStars+'.mp3';
		document.getElementById('playSound').play();
	}
	$("#starDiv").css("visibility","visible");
}
Crossword.showNextGame=function()
{
	if(Utils.mobileDeviceFlag)
		Android.GotoNextGame();
}