﻿// JScript File

var VideoAdProvider = function (player)
{
    this.videoAdProvider = null;
    this.videoAdSOAP  = null;
    this.videoAd = null;
    this.mainPlayer = null;
    this.player = player;
    this.onProcessResponseEnd = onProcessResponseEnd;
    this.getVideoAdSOAP =getVideoAdSOAP;
    this.getVideoAdEngine = getVideoAdEngine;
    this.runFunction = runFunction;
    this.stopFunction = stopFunction;
    this.setAdZoneDim =setAdZoneDim;
    //alert(this.player.url);
   this.videoAdSOAP = new VideoAdSOAP(this.player.url);
    var selfobject = this;
   this.videoAdSOAP.setProcessResponseEndEventListener(function(){selfobject.onProcessResponseEnd();});
   this.videoAdSOAP.send();
    //XSS 
    //this.onProcessResponseEnd()
   }
function getVideoAdSOAP()
{
    return this.videoAdSOAP;
}
function getVideoAdEngine()
{
    return this.videoAdEngine;
}
function onProcessResponseEnd()
{
    var selfobject = this;
    this.videoAd = this.getVideoAdSOAP().getVideoAd();
    this.videoAdEngine = new VideoAdEngine(this.videoAd);
    this.videoAdEngine.setPlayer(this.player);
    //this.setAdZoneDim();
    this.videoAdEngine.setStopAdEventListener(function(){selfobject.stopFunction();});
    this.videoAdEngine.setRunAdEventListener(function(){selfobject.runFunction();});
    this.videoAdEngine.updateProgressBar();
}

function setAdZoneDim()
{
    var width = parseInt(40);//this.getVideoAdEngine().getAd().getWidth();
    var height = this.getVideoAdEngine().getAd().getHeight();
    $(adDiv).width(width);
    $(adDiv).height(height);
 }

function runFunction()
{
    //adSpan.innerHTML = "OK";//this.getVideoAdEngine().getAd().getAdCode();
    //$(adSpan).show(0);
    //$(adSpan).animate({opacity: "0.8"}, 500);
    adSpan.innerHTML = this.getVideoAdEngine().getAd().getAdCode();
    window.setTimeout("$(adSpan).show(0);$(adSpan).animate({opacity: \"0.8\"}, 500); ",1000);
    
}

function stopFunction()
{
    $(adSpan).animate({opacity: "0.0"}, 500); 
    window.setTimeout("$(adSpan).hide(0);",500);
}
