
 var innerWidth= 320;
      var innerHeight= 440;
//the following function will read the text file and will return the response Text as string.
function readTextFile(pPath)
{
    var file = pPath;
    var allText = "nil"
    var rawFile = new XMLHttpRequest();
    rawFile.overrideMimeType("text/plain; charset=x-user-defined");
    rawFile.open("GET", file, true);
    rawFile.onreadystatechange = function ()
    {
        if(rawFile.readyState === 4)
        {
            if(rawFile.status === 200 || rawFile.status == 0)
            {
                allText = rawFile.responseText;
                console.log("path for text file is ", pPath);
                // alert(allText);
                // var myArray = new Array()
                // myArray = allText.split(',');
                setGameLevelString(allText)
            }
        }
    }
    
    rawFile.send();
    
}

// var pTimerText1, pTimerText2

function createNumber(lNumber, pX, pY) {
    // console.log("lnumber is ", lNumber)
    
    var lNumber1, lNumber2
    lNumber1=lNumber%10; lNumber=Math.floor(lNumber/10)
    lNumber2=lNumber%10;
    console.log("the two numbers are ", lNumber2, lNumber1)
    if(lNumber2!=0) {
        var pTimerText1 = Crafty.e("2D, DOM, number"+lNumber2).attr({x:pX+15, y:pY+30});    
    }
    
    var pTimerText2 = Crafty.e("2D, DOM, number"+lNumber1).attr({x:pX+30, y:pY+30});
    if(lNumber2==0) {
      
      pTimerText2.x=pX+25;  
    } 

}

function setScreenScale()
{   
    console.log("total width and height of the window ", Crafty.viewport.width, Crafty.viewport.height)
    
   var scale = window.innerWidth / Crafty.viewport.width;
        
        scale = window.innerWidth / Crafty.viewport.width;
            //make sure it's not bigger than the height
        if (scale * Crafty.viewport.height > window.innerHeight) {
            scale = window.innerHeight / Crafty.viewport.height;
            }
        var stageStyle = Crafty.stage.elem.style;
            stageStyle.transformOrigin = stageStyle.webkitTransformOrigin = stageStyle.mozTransformOrigin = "0 0";
            stageStyle.transform = stageStyle.webkitTransform = stageStyle.mozTransform = "scale(" + scale + ")";
        /*console.log("width and height placem", Crafty.viewport.width/2-320/2, Crafty.viewport.height/2-480/2)
        console.log("x and y is ", Crafty.viewport.x, Crafty.viewport.y)
        var lScaleX = Crafty.viewport.width/320
        var lScaleY = Crafty.viewport.height/480
        var lScale
        if(lScaleX < lScaleY) { lScale = lScaleX } else { lScale = lScaleY }
//         if(Crafty.viewport.width > lScale*320) {
      //   var lScaleX = Crafty.viewport.width/320
        console.log("scale is ", lScale, lScaleX, lScaleY);
        Crafty.viewport.scale(lScale)
        Crafty.viewport.x = -(Crafty.viewport.width/2-320/2)*lScale  //-320/lScale
        Crafty.viewport.y =  -(Crafty.viewport.height/2-480/2)*lScale  //-480/lScale
        console.log("x and y is ", Crafty.viewport.x, Crafty.viewport.y)
//         }*/
    }


