//17 jan
var MeriDukan={};
var Utils={};
Utils.Path='';
Utils.mobileDeviceFlag=false;
MeriDukan.homeClickFlag=false;
var resId=0,quesId=0,startTime=0,scoredMarks=0,totalMarks=10;
var arr=["ATM","Bank","ATM","Bank","ATM","Bank","ATM","Bank","ATM","Bank","ATM","Bank","ATM","Bank"];
$(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("MeriDukan");  */
	setTimeout(function()
	{
		MeriDukan.setImages();
		// if(MeriDukan.hardCodedData['languageFont']!=null)
		// 	setFontFamilyForLang("fonts/"+MeriDukan.hardCodedData['languageFont']);		
	},200);
});

MeriDukan.setImages=function()
{
	document.body.style.backgroundImage="url("+Utils.Path+MeriDukan.coverImage+")";
	document.getElementById("homeImg").src=Utils.Path+"images/Home.png";
	document.getElementById("logoImg").src=Utils.Path+"images/logo.png";
	document.getElementById('playVideoBtn').src="images/playAgain.png";
	MeriDukan.createMenu();
//	document.getElementById("playImg").src=Utils.Path+"images/Play.png";
	//document.getElementById("playAgainImg").src=Utils.Path+"images/playAgain.png";
}

MeriDukan.playGame=function()
{
	document.getElementById('coverpage').style.display="none";
	document.getElementById('homeImg').style.visibility="visible";
	document.getElementById('gamepage').style.display="block";
	document.getElementById("homeImg").style.display = "block";
	
}
MeriDukan.createMenu=function()
{
	var menuDiv;
	for(var i=0;i<arr.length;i++)
	{
		menuDiv=document.createElement('div');
		menuDiv.setAttribute('id',"menu"+(i+1));
		menuDiv.setAttribute('class','menu btn text-center col-xs-10 col-sm-10 col-lg-10 col-md-10 col-sm-offset-1 col-lg-offset-1 col-md-offset-1 col-xs-offset-1 noPadding');
		menuDiv.setAttribute('onclick','MeriDukan.showHeader(this.id)');
		menuDiv.innerHTML=arr[i];
		menus.appendChild(menuDiv);
	}
}
MeriDukan.showHeader=function(id)
{
	var menu;
	menu=document.getElementById(id).innerHTML;
	document.getElementById("menuName").innerHTML=menu;
	MeriDukan.showVideo();
}

MeriDukan.showVideo=function()
{
	MeriDukan.homeClickFlag=true;
	document.getElementById('clickedMenuName').style.visibility='visible';
	document.getElementById('menuPage').style.display='none';
	document.getElementById('video').style.display='block';
	document.getElementById('playVideoBtnDiv').style.display='none';
	document.getElementById('videoQuestionPage').style.display='block';
	document.getElementById('question').style.display='none';
	$("#question").empty();
	document.getElementById('playVideo').src="../video/tangramgame.mp4";
	document.getElementById('playVideo').play();
}
MeriDukan.displayQuestion=function()
{
	document.getElementById('video').style.display='none';
	document.getElementById('playVideoBtnDiv').style.display='block';
	document.getElementById('question').style.display='block';
	MeriDukan.question();
}
MeriDukan.question=function()
{
	var queDiv;
	for(var i=0;i<MeriDukan.data.length;i++)
	{
		queDiv=document.createElement('div');
		queDiv.setAttribute('id',"menu"+(i+1));
		queDiv.setAttribute('class',' text-center questions col-xs-11 col-sm-11 col-lg-11 col-md-11 col-sm-offset-1 col-lg-offset-1 col-md-offset-1 col-xs-offset-1 noPadding');
		queDiv.innerHTML="Q"+(i+1)+"."+" "+MeriDukan.data[i]+" ?";
		question.appendChild(queDiv);
	}
}
MeriDukan.callHome=function()
{
	if(MeriDukan.homeClickFlag)
	{
		document.getElementById('clickedMenuName').style.visibility='hidden';
		MeriDukan.homeClickFlag=false;
		document.getElementById('menuPage').style.display="block";
		document.getElementById('videoQuestionPage').style.display="none";
	}
	else
	{
		location.reload(true);
	}
		
}