/**
 * Created with JetBrains WebStorm.
 * User: ankit.goel
 * Date: 10/31/12
 * Time: 10:45 AM
 * To change this template use File | Settings | File Templates.
 */

ig.module(
    'game.entities.textBoxAnimation'
)
    .requires(
    'impact.entity'
)
    .defines(
    function () {
        EntitytextBoxAnimation = ig.Entity.extend({
            size:{x:665, y:447},
            animSheet:new ig.AnimationSheet('media/end_text_popup.png',665,447),
            temp:0,
            init:function (x, y, settings) {
                this.parent(x, y, settings);
                this.addAnim('score1', 1, [0]);
                this.maxVel.x = 500;
                this.maxVel.y = 500;
                },
            update:function (){
                if(this.scaleCount==0){
              }
                else{
                    this.scaleCount=this.scaleCount-2;
                    if(!this.isScaleTrigger)
                    {   this.scaleCountFadeIn=this.scaleCountFadeIn+2;
                        this.setScale(this.scaleCountFadeIn/250,this.scaleCountFadeIn/250);
                        this.pos.x=Math.floor((ig.system.width- this.size.x)/2);
                        this.pos.y=Math.floor((ig.system.height-this.size.y)/2);
                        if( this.scaleCount==250){
                            this.isScaleTrigger=true;
                        }
                    }
              
               }
                    if(this.isScaleTrigger && this.okTrigger){//Ok button creation code
             
				var a=document.getElementById('ok_trigger');
				$('#ok_trigger')
				.css({'margin-left':'547px','margin-top':'401px','z-index':'1000','position':'absolute','cursor':'pointer','display':'block'})
				.click(function(){location.reload()});		
				       this.okTrigger=false;
                  }

             this.parent();
            },
            okTrigger:true,
            scaleCountFadeOut:250,
            scaleCountFadeIn:0,
            scaleCount:500,
            isScaleTrigger:false
     });

    });