//
// AdvertTan
//
FVWebComponent.AdvertTan = function(id, config) {
    this.placementId = "";
    this.origAp = "";
    this.destAp = "";
    this.viewport = null;    
    this.placementId = null;
    
    this.init(id, config);
}

FVWebComponent.AdvertTan.prototype = new FVWebComponent.Advert;

FVWebComponent.AdvertTan.prototype.init = function (id, config) {
    FVWebComponent.Advert.prototype.init.call(this, id, config);
    
    this.placementId = config["placementId"];
    
    // Look for the viewport.
    var allIframes = this.container.getElementsByTagName("iframe");
    this.viewport = allIframes[0];
}

FVWebComponent.AdvertTan.prototype.handleFVWebComponentEvent = function (type, args, me) {
    //alert("AdvertTan (" + me.id + ") is handling event: " + args[0].toString());
}

FVWebComponent.AdvertTan.prototype.clear = function () {
    this.viewport.src = "about:blank";
}


FVWebComponent.AdvertTan.prototype.refresh = function () {
    if (this.isVisible()) {
        var useOrigAp, useDestAp;
        if (this.destAp != "" && this.destAp != null) {
            useDestAp = this.destAp;
        } else {
            useDestAp = "ZZZ";            
        }
        
        if (this.origAp != "" && this.origAp != null) {
            useOrigAp = this.origAp;
        } else {
            useOrigAp = useDestAp;
        }
        
        
        this.viewport.src = "http://www.traveladvertising.com/Live/SearchAds.aspx?PlacementId=" + this.placementId
                                + "&OrigAp=" + useOrigAp + "&DestAp=" + useDestAp;
    }
}