function PreRollAds(timer, flashObjID, OnTimeEnd)/*seconds*/
{
    this.timer = timer;
    this.stuck = 0;
    this.flashObjID = flashObjID;    
    this.onTimeEnd = OnTimeEnd;       
}

PreRollAds.prototype.SetGameFocus = function()
{
	window.focus();
	var gameFlash = this.GetFlashObj(this.flashObjID);
	if (gameFlash) gameFlash.focus();
	this.stuck = 0;
}

PreRollAds.prototype.KeepGameFocus = function(){
  return;
	if (this.timer < 0 && this.stuck == 0){
	    this.stuck = 1;
	    var that = this;
	    setTimeout(function() { that.ShowTime() }, 500);
	}
}
PreRollAds.prototype.ShowTime = function() {
    var content = '<div class="popUp_Game_timer">Your game will start in ' + this.timer + ' seconds</div><div class="popUp_Game_aMessageFree">A message from our sponsor<br> who keeps Great Day Games FREE!</div>';
    jQuery.ark.gamePlayPageUIWizard.UpdateDivTimerObjContent(content);
    this.timer--;
    if (this.timer < 0) {
        if (this.onTimeEnd) {
            if (typeof (this.onTimeEnd) == 'function') { this.onTimeEnd(); }
            else if (typeof (this.onTimeEnd == 'string')) { new Function('action', this.onTimeEnd)(); }
            else { alert('Actions of type "' + typeof (this.onTimeEnd) + '" are not supported!'); }
        }
        else {
            jQuery.ark.gamePlayPageUIWizard.HideTimerAndAdv();
            this.InitGame();
        }
    } else {
        var that = this;
        setTimeout(function() { that.ShowTime() }, 1000);
    }
}

PreRollAds.prototype.InitGame = function() {    
    jQuery.ark.gamePlayPageUIWizard.ShowDivGame();
    var gameObj = this.GetFlashObj(this.flashObjID);
    if (gameObj) gameObj.focus();
}

PreRollAds.prototype.InitGameAddIn = function(content)
{
    jQuery.ark.gamePlayPageUIWizard.LoadAddInAndShowDivGame(content);
    var gameObj = this.GetFlashObj(this.flashObjID);
    if (gameObj) gameObj.focus();
}


PreRollAds.prototype.GetFlashObj = function(objName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return document.getElementById(objName);
    } else {
        return document[objName];
    }
}


  
