var sample={};
Utils={};
Utils.Path = " ";
var selected_Id="";
$(document).ready(function () {
  
    if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i))&& !(window.location.href.includes('http')))
        Utils.mobileDeviceFlag = true;
        sample.LoadGame();
        sample.showQues();
});
sample.showQues = function(){
    $('#questioMark').hide();
    $('#myModal').css('display','block');
}
sample.hideQuestion = function(){
    $('#questioMark').show();
    $('#myModal').css('display','none');
}
sample.Next = function(){
    if(($("#"+selected_Id).data("data")) == "Right"){
        $("#"+selected_Id).css('border','none');
        console.log("Right answer");
    }
        
    else{
        $("#"+selected_Id).css('border','none');
        console.log("Wrong answer");
    }
        
}
sample.resetGame = function(){
    $(".optionClass").css('border','none');
    
    
}
sample.LoadGame = function(){
    selected_Id="";
    var no= Math.floor(Math.random()*sample.gamename.length);
    console.log(no);
    document.title = sample.gamename[no].GameName;
    document.getElementById("heading").innerHTML = sample.gamename[no].question;
    $("#heading").css("font-size","1em");
    document.getElementById("queNo").innerHTML = sample.gamename[no].GameName;

    var optionDiv,optionImgDiv;
     for(i=0;i<2;i++){ //questionDiv
        optionDiv = document.createElement("div");
        optionDiv.setAttribute("id","optionDivId"+i);
        optionDiv.setAttribute("class","noPadding optionClass  centerClass col-sm-5 col-xs-5 col-lg-5 col-md-5col-sm-offset-1 col-md-offset-1 col-xs-offset-1 col-lg-offset-1 ");
        optionDiv.setAttribute("onclick","sample.checkAns(this.id)");
        $(optionDiv).data("data",sample.gamename[no].option[i].sound);
         optionImgDiv = document.createElement("img");
         optionImgDiv.setAttribute("id","optionImgId"+i);
         optionImgDiv.setAttribute("class","noPadding imgborder img-responsive col-sm-12 col-xs-12 col-lg-12 col-md-12");
         optionImgDiv.src = Utils.Path+"images/"+sample.gamename[no].option[ i].image_name ;
         optionDiv.appendChild(optionImgDiv);
        document.getElementById("optionID").appendChild(optionDiv);
       }
       $(".optionClass , #textQuesId").css('background-color','white');
}
sample.checkAns = function(selected_option){
    
     $(".optionClass").css('border',' none');
     $("#"+selected_option).css('border','8px solid yellow');
     selected_Id=selected_option;
}