function DM_onSegsAvailable(rsinetsegs, csid) {
    if ("f11195" == csid && rsinetsegs != null) {
        var segQS = '';
        var cssStyle = /Opera/.test(navigator.userAgent) ? "position:absolute;left:-999em;top:-999em;" : "display:none;";
        var adServerCallProtocol = ("https:" == window.location.protocol) ? "https://secure" : "http://pixel";
        var asCall = "";
        for ( var i = 0; i < rsinetsegs.length; i++) {
            segQS += "|" + rsinetsegs[i].split("_")[1];
        }
        segQS = segQS.replace(/(^\|)|(\|$)/g, "");
        asCall += '<im';
        asCall +='g  height="0" width="0" style="' + cssStyle + '" ';
        asCall += 'src="'+adServerCallProtocol+'.traveladvertising.com/Live/AS.aspx?SegmentIds=' + escape(segQS) + '">';
        asCall += '</im';
        asCall += 'g>';
        document.writeln(asCall);
    }
};
function TM_onBKAvailable(){
     var bkCall = '';
     var bkIds = [];
     if(typeof(bk_results) != "undefined" && bk_results != null && bk_results.campaigns != null && bk_results.campaigns.length > 0) {
         for(var i=0; i<bk_results.campaigns.length; i++){
            for(var j=0; j<bk_results.campaigns[i].categories.length; j++){
                bkIds.push(bk_results.campaigns[i].categories[j].categoryID);
            }
         }
     }
     var cssStyle = /Opera/.test(navigator.userAgent) ? "position:absolute;left:-999em;top:-999em;" : "display:none;";
     var tm_imgEl = document.createElement('im' + 'g');
     tm_imgEl.height = 0;
     tm_imgEl.width = 0;
     tm_imgEl.style.cssText=cssStyle;
     tm_imgEl.src = ('https:' == document.location.protocol ? 'https://secure' : 'http://pixel') +'.traveladvertising.com/Live/BlueKai/?BlueKaiId=' + escape(bkIds.join("|"));
     document.getElementsByTagName('body')[0].appendChild(tm_imgEl);
};
(function() {
    var TAN_AD = "TAN_AD";
    var TAN_AD_DATA = "TAN_AD_DATA";
    var AdFactory = {};

    AdFactory.Ad = function(id, adTagImplementationTypeId, adIndex) {
        var _ad = this;
        var _adIndex = adIndex;
        var _adServerTypeId = null;
        var _adServerUrl = null;
        var _adTagImplementationTypeId = adTagImplementationTypeId;
        var _audienceActive = true;
        var _hasOptOut = false;
        var _id = id;
        var _maxAdHeight = null;
        var _maxAdWidth = null;
        var _minAdHeight = null;
        var _minAdWidth = null;
        var _segmentIds = null;
        var _trackingCode = null;

        _ad.createAdElement = function() {
            var tagElement = null;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    var scriptElements = document.getElementsByTagName('scr' + 'ipt');

                    if (scriptElements != null) {
                        for (var i = 0, j = 0; tagElement == null && i < scriptElements.length; i++) {
                            var scriptElement = scriptElements[i];
                            var scriptSrc = scriptElements[i].src;

                            if (scriptSrc.match('TanAdx.js|SearchAdx.js')) {
                                if (j == adIndex) {
                                  tagElement = scriptElement;
                                }
                                j++;
                            }
                        }
                    }
                    break;
            }

            var parentElement = null;

            if (tagElement != null) {
                parentElement = tagElement.parentNode;
            }
            else {
                var bodyElements = document.getElementsByTagName('bo' + 'dy');

                if (bodyElements != null && bodyElements.length > 0) {
                    parentElement = bodyElements[0];
                }
            }

            var divElementId =  _ad.getAdElementId();
            var divElementStyle = 'font-size:1px; height:0px; position:relative; visibility:hidden; width:' + _maxAdWidth + 'px;';

            if (parentElement != null) {
                var divElement = document.createElement('di' + 'v');

                divElement.setAttribute("id", divElementId);
                divElement.style.cssText = divElementStyle;
                parentElement.appendChild(divElement);
            }
            else {
                document.writeln('<div id="' + divElementId + '" style="' + divElementStyle + '"></div>');
            }
        };

        _ad.createPageId = function(key, previousPageId, defaultPageId) {
            var newPageId;

            if (typeof previousPageId == "undefined" || !previousPageId || previousPageId == defaultPageId) {
                newPageId = Math.round(Math.random() * 10000000000);
            }
            else {
                newPageId = previousPageId;
            }

            return newPageId;
        };
        
        _ad.createAnalytics = function() {
            if (_hasOptOut == null) {_hasOptOut = false;}
            if (_trackingCode != null && _trackingCode != '' && !_hasOptOut) {
                var analyticsCall = _ad.getSessionValue("analyticsCall" + _trackingCode, _ad.getCount, -1, true);
                if (analyticsCall == 1) {
                    var aScript = "var _gaq = _gaq || [];";
                    aScript += "_gaq.push(['b._setAccount', '" +  _trackingCode + "']);";
                    aScript += "_gaq.push(['b._trackPageview']);";
                    aScript += "(function() {"; 
                    aScript += "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;";
                    aScript += "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';";
                    aScript += "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);";
                    aScript += "})();";
    
                    var headElements = document.getElementsByTagName('he' + 'ad');
                    if (headElements != null && headElements.length > 0) {
                        headElement = headElements[0];
                        if (headElement != null) {
                            var scriptElement = document.createElement('scr' + 'ipt');
                            scriptElement.type = 'text/javascript';
                            scriptElement.text = aScript;
                            headElement.appendChild(scriptElement);
                        }
                    }
                }
            }
        };

        _ad.getAdElementId = function() {
            return "tan_" + _id + "_" + _adIndex;
        };

        _ad.getAdServerCall = function() {
            var adServerCall = "";

            if (_id != null) {
                var adServerCallProtocol = ("https:" == window.location.protocol) ? "https://" : "http://";
                var adServerCallUrl = adServerCallProtocol + _adServerUrl;
                var screenSize = _ad.getScreenSize();
                var screenSizeValue = '0x0';
                if(screenSize != null) screenSizeValue = escape(screenSize.width + "x" + screenSize.height);
                adServerCallUrl = adServerCallUrl.replace('$foldPosition$', escape(_ad.getFoldPosition()));
                adServerCallUrl = adServerCallUrl.replace('$horizontalPosition$', escape(_ad.getHorizontalPosition()));
                adServerCallUrl = adServerCallUrl.replace('$page$', escape(_ad.getPageId()));
                adServerCallUrl = adServerCallUrl.replace('$randomNumber$', Math.round(Math.random() * 10000000000));
                adServerCallUrl = adServerCallUrl.replace('$security$', escape(_ad.getSecurity()));
                adServerCallUrl = adServerCallUrl.replace('$tile$', escape(_ad.getTile()));
                adServerCallUrl = adServerCallUrl.replace('$verticalPosition$', escape(_ad.getVerticalPosition()));
                adServerCallUrl = adServerCallUrl.replace('$screenResolution$', screenSizeValue );
                adServerCallUrl = adServerCallUrl.replace('$iframeDetection$', escape( _ad.getIframeDetection()));

                adServerCall += '<scr';
                adServerCall += 'ipt type="text/javascript" src="' + adServerCallUrl + '">';
                adServerCall += '</scr';
                adServerCall += 'ipt>';
            }
            return adServerCall;
        };

        _ad.getAdServerTypeId = function() {
            return _adServerTypeId;
        };

        _ad.setAdServerTypeId = function(adServerTypeId) {
            _adServerTypeId = adServerTypeId;
        };

        _ad.getAdServerUrl = function() {
            return _adServerUrl;
        };

        _ad.setAdServerUrl = function(adServerUrl) {
            _adServerUrl = adServerUrl;
        };

        _ad.getAdTagImplementationTypeId = function() {
            return _adTagImplementationTypeId;
        };
        _ad.setAudienceActive = function(audienceActive) {
            _audienceActive = audienceActive;
        };
        _ad.getElementPosition = function(id) {
            var elementPosition = null;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    var xPos = 0;
                    var yPos = 0;

                    try {
                        var el = document.getElementById(id);

                        while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
                            xPos += el.offsetLeft - el.scrollLeft;
                            yPos += el.offsetTop - el.scrollTop;
                            el = el.offsetParent;
                        }

                        var temp = self;

                        while (temp != top && temp != null && temp.frames != null && temp.parent.frames.length > 0) {
                            el = temp.frameElement;

                            if (el) {
                                while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
                                    xPos += el.offsetLeft - el.scrollLeft;
                                    yPos += el.offsetTop - el.scrollTop;
                                    el = el.offsetParent;
                                }
                            }

                            temp = temp.parent;
                        }

                        elementPosition = {x:xPos, y:yPos};
                    }
                    catch (e) {
                        elementPosition = null;
                    }
                    break;
            }

            return elementPosition;
        };

        _ad.getFoldPosition = function() {
            var foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].UNKNOWN;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    var adElementId = _ad.getAdElementId();
                    var adPosition = _ad.getElementPosition(adElementId);
                    var screenSize = _ad.getScreenSize();

                    if (adPosition == null || screenSize == null) {
                        foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].UNKNOWN;
                    }
                    else if (adPosition.x >= screenSize.width ||
                                 adPosition.y >= screenSize.height ||
                                 adPosition.x + _maxAdWidth <= 0 ||
                                 adPosition.y + _maxAdHeight <= 0) {
                        foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].BELOW;
                    }
                    else if (adPosition.x + _maxAdWidth <= screenSize.width &&
                                 adPosition.y + _maxAdHeight <= screenSize.height) {
                        foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].ABOVE;
                    }
                    else {
                        var adHeightAboveFold;
                        var adWidthAboveFold;

                        if (adPosition.x < 0) {
                            adWidthAboveFold = _maxAdWidth + adPosition.x;
                        }
                        else {
                            if (adPosition.x + _maxAdWidth > screenSize.width) {
                                adWidthAboveFold = screenSize.width - adPosition.x;
                            }
                            else {
                                adWidthAboveFold = _maxAdWidth;
                            }
                        }

                        if (adPosition.y < 0) {
                             adHeightAboveFold = _maxAdHeight + adPosition.y;
                        }
                        else {
                            if (adPosition.y + _maxAdHeight > screenSize.height) {
                                adHeightAboveFold = screenSize.height - adPosition.y;
                            }
                            else {
                                adHeightAboveFold = _maxAdHeight;
                            }
                        }

                        if ((adWidthAboveFold * adHeightAboveFold) / (_maxAdWidth * _maxAdHeight) >= 0.5) {
                            foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].ABOVE;
                        }
                        else {
                            foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].BELOW;
                        }
                    }
                    break

                default:
                    foldPosition = AdFactory.TAN_FOLD_POSITION[_adServerTypeId].UNKNOWN;
                    break;
            }

            return foldPosition;
        };

        _ad.getHeight = function() {
            return _maxAdheight;
        };

        _ad.setHeight = function(height) {
            _maxAdHeight = height;
            _minAdHeight = height;
        };

        _ad.getHorizontalPosition = function() {
            var horizontalPosition = AdFactory.TAN_HORIZONTAL_POSITION[_adServerTypeId].UNKNOWN;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    var adElementId = _ad.getAdElementId();
                    var adPosition = _ad.getElementPosition(adElementId);
                    var screenSize = _ad.getScreenSize();

                    if (adPosition == null || screenSize == null) {
                        horizontalPosition = AdFactory.TAN_HORIZONTAL_POSITION[_adServerTypeId].UNKNOWN;
                    }
                    /* If ad more to left than right then horizontal position is left */
                    else if (adPosition.x < screenSize.width - adPosition.x - _maxAdWidth) {
                        horizontalPosition = AdFactory.TAN_HORIZONTAL_POSITION[_adServerTypeId].LEFT;
                    }
                    /* Otherwise horizontal position is right */
                    else {
                        horizontalPosition = AdFactory.TAN_HORIZONTAL_POSITION[_adServerTypeId].RIGHT;
                    }
                    break;

                default:
                    horizontalPosition = AdFactory.TAN_HORIZONTAL_POSITION[_adServerTypeId].UNKNOWN;
                    break;
            }

            return horizontalPosition;
        };

        _ad.getId = function() {
            return _id;
        };
        
        _ad.getIframeDetection = function() {
            if (top === self) {
                return AdFactory.TAN_IFRAME_DETECTION[_adServerTypeId].JS;
            } else {
                return AdFactory.TAN_IFRAME_DETECTION[_adServerTypeId].IFRAME;
            }
        };
        
        _ad.getMaxAdHeight = function() {
            return _maxAdHeight;
        };

        _ad.setMaxAdHeight = function(maxAdHeight) {
            _maxAdHeight = maxAdHeight;
        };

        _ad.getMaxAdWidth = function() {
            return _maxAdWidth;
        };

        _ad.setMaxAdWidth = function(maxAdWidth) {
            _maxAdWidth = maxAdWidth;
        };

        _ad.getMinAdHeight = function() {
            return _minAdHeight;
        };

        _ad.setMinAdHeight = function(minAdHeight) {
            _minAdHeight = minAdHeight;
        };

        _ad.getMinAdWidth = function() {
            return _minAdWidth;
        };

        _ad.setMinAdWidth = function(minAdWidth) {
            _minAdWidth = minAdWidth;
        };

        _ad.getPageId = function() {
            return _ad.getSessionValue("pageId", _ad.createPageId, -1, true);
        };
        
        _ad.setOptOut = function(pHasOptOut) {
            _hasOptOut = pHasOptOut;
        };
        
        _ad.getParentUrl = function() {
            var url = window.location.href;
            if(_ad.getIframeDetection() == AdFactory.TAN_IFRAME_DETECTION[_adServerTypeId].IFRAME) {
                url = document.referrer;
            }
            return url && url.length > 0 ? url : window.location.href;
        };

        _ad.getReferrerUrl = function() {
            var referrer = document.referrer.toString();
            if(_ad.getIframeDetection() == AdFactory.TAN_IFRAME_DETECTION[_adServerTypeId].IFRAME) {
                referrer = "";
            }
            return referrer;
        };

        _ad.getScreenSize = function() {
            var screenSize = null;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    try {
                        var w = 0;
                        var h = 0;

                        // IE
                        if (!window.innerWidth) {
                            if (!(document.documentElement.clientWidth == 0)) {
                                w = top.document.documentElement.clientWidth;
                                h = top.document.documentElement.clientHeight;
                            }
                            else {
                                w = top.document.body.clientWidth;
                                h = top.document.body.clientHeight;
                            }
                        }
                        else { //w3c
                            w = top.innerWidth;
                            h = top.innerHeight;
                        }

                        screenSize = {width:w, height:h};
                    }
                    catch (e) {
                        screenSize = null;
                    }
                    break;
            }

            return screenSize;
        };

        _ad.getSecurity = function() {
            var security = AdFactory.TAN_SECURITY[_adServerTypeId].UNKNOWN;

            if ("https:" == window.location.protocol) {
                security = AdFactory.TAN_SECURITY[_adServerTypeId].SECURE;
            }
            else {
                security = AdFactory.TAN_SECURITY[_adServerTypeId].NOT_SECURE;
            }

            return security;
        };

        _ad.setSegmentIds = function(staticIds,dynamicIds) {
            var segmentIds = [];

            if (staticIds != null && staticIds.length > 0) {
                segmentIds = segmentIds.concat(staticIds);
            }

            if (dynamicIds != null && dynamicIds.length > 0) {
                segmentIds = segmentIds.concat(dynamicIds);
            }
            _segmentIds = segmentIds;
        }

        _ad.getSessionValue = function(key, newValueFunction, defaultValue, findFirst) {
            var sessionValue = defaultValue;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    if (window[TAN_AD_DATA] && window[TAN_AD_DATA][key]) {
                        sessionValue = window[TAN_AD_DATA][key];
                    }
                    break;

                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.IFRAME:
                    var topWindow = top;

                    for (var i = 0; i < topWindow.frames.length; i++) {
                        try {
                            var frame = topWindow.frames[i];

                            if (frame[TAN_AD_DATA] && frame[TAN_AD_DATA][key]) {
                                sessionValue = frame[TAN_AD_DATA][key];

                                if (findFirst) {
                                    break;
                                }
                            }
                        }
                        catch(e) {
                        }
                    }
                    break;
            }

            sessionValue = newValueFunction(key, sessionValue, defaultValue);
            window[TAN_AD_DATA][key] = sessionValue;

            return sessionValue;
        };
        
        _ad.setTrackingCode = function(pTrackingCode) {
            _trackingCode = pTrackingCode;
        };

        _ad.getNewTile = function(key, previousTile, defaultTile) {
            var newTile;

            if (typeof previousTile == "undefined" || !previousTile || previousTile == defaultTile) {
                newTile = 1;
            }
            else {
              newTile = previousTile + 1;
            }

            return newTile;
        };

        _ad.getTile = function() {
            var tile = 0;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.IFRAME:
                    tile = _ad.getSessionValue("tile", _ad.getNewTile, -1, false);
                    break;

                default:
                    tile = _adIndex + 1;
                    break;
            }

            return tile;
        };      
        _ad.getVerticalPosition = function() {
            var verticalPosition = AdFactory.TAN_VERTICAL_POSITION[_adServerTypeId].UNKNOWN;

            switch (_adTagImplementationTypeId) {
                case AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE.JAVASCRIPT:
                    var adElementId = _ad.getAdElementId();
                    var adPosition = _ad.getElementPosition(adElementId);
                    var screenSize = _ad.getScreenSize();

                    if (adPosition == null || screenSize == null) {
                        verticalPosition = AdFactory.TAN_VERTICAL_POSITION[_adServerTypeId].UNKNOWN;
                    }
                    /* If ad is more to top than middle then vertical position is top */
                    else if (adPosition.y < 2 * screenSize.height / 3 - adPosition.y - _maxAdHeight) {
                        verticalPosition = AdFactory.TAN_VERTICAL_POSITION[_adServerTypeId].TOP;
                    }
                    /* If ad is more to bottom than middle then vertical position is bottom */
                    else if (adPosition.y > screenSize.height / 3 &&
                                 adPosition.y - screenSize.height / 3 > screenSize.height- adPosition.y - _maxAdHeight) {
                        verticalPosition = AdFactory.TAN_VERTICAL_POSITION[_adServerTypeId].BOTTOM;
                    }
                    /* Otherwise vertical position is middle */
                    else {
                        verticalPosition = AdFactory.TAN_VERTICAL_POSITION[_adServerTypeId].MIDDLE;
                    }
                    break;

                default:
                    verticalPosition = AdFactory.TAN_VERTICAL_POSITION[_adServerTypeId].UNKNOWN;
                    break;
            }

            return verticalPosition;
        };

        _ad.getWidth = function() {
            return _maxAdWidth;
        };

        _ad.setWidth = function(width) {
            _maxAdWidth = width;
            _minAdWidth = width;
        };

        _ad.getCount = function(key, previousCount, defaultCount) {
            var newCount;

            if (typeof previousCount == "undefined" || !previousCount || previousCount == defaultCount) {
                newCount = 1;
            }
            else {
                newCount = previousCount + 1;
            }

            return newCount;
        };

        _ad.getSegmentCall = function() {
            var segmentCall = '';
            var segmentCallCount = _ad.getSessionValue("segmentcall", _ad.getCount, -1, true);
            var pixelUrlPrefix = ("https:" == window.location.protocol) ? "https://secure" : "http://pixel";
            var cssStyle = /Opera/.test(navigator.userAgent) ? "position:absolute;left:-999em;top:-999em;" : "display:none;";
            if (segmentCallCount == 1){
                
                var segmentParameters = _segmentIds.join(",");
                var parentUrl = _ad.getParentUrl();
                var refUrl = _ad.getReferrerUrl();
                parentUrl = encodeURIComponent(parentUrl);
                refUrl = encodeURIComponent(refUrl);
                segmentCall +=  '<img height="0" width="0" ';
                    segmentCall +=' style="' + cssStyle + '" ';
                    segmentCall += 'src="' + pixelUrlPrefix + '.traveladvertising.com/Live/Segment.aspx?PlacementId=' + segmentParameters;
                    segmentCall += '&Url=' + parentUrl;
                    segmentCall += '&Tan_Ref=' + refUrl;
                    segmentCall += '&Tan_Audience_Active=' + _audienceActive;
                    segmentCall += '"></img>';
            }
            return segmentCall;
        };

        _ad.getAudienceScienceCall = function() {

            var asCall = "";
            if (_hasOptOut == null) {_hasOptOut = false;}
            if (_audienceActive == null) {_audienceActive = true;}
            if (!_hasOptOut && _audienceActive) {
                var asCallCount = _ad.getSessionValue("ascall", _ad.getCount, -1, true);
                if (asCallCount == 1){
                    asCall = '<script src="' + ('https:' == document.location.protocol ? 'https://' : 'http://') + 'pix04.revsci.net/F11195/a6/0/0/nolog.js"></script>';
                }
            }
            return asCall;
        };
        
        _ad.getBlueKaiCall = function() {
        	if('https:' == document.location.protocol) return;
            var bkCall = '';
            var bkCallCount = _ad.getSessionValue("bkcall", _ad.getCount, -1, true);
            if(bkCallCount == 1){
                var headElements = document.getElementsByTagName('he' + 'ad');
                    if (headElements != null && headElements.length > 0) {
                        headElement = headElements[0];
                        if (headElement != null) {
                            var scriptElement = document.createElement('scr' + 'ipt');
                            scriptElement.type = 'text/javascript';
                            scriptElement.src = 'http://tags.bluekai.com/site/5054?ret=js';
                            if(scriptElement.addEventListener) {
                                scriptElement.addEventListener('load',TM_onBKAvailable,false);
                            }else{
                                scriptElement.onreadystatechange = function(){
                                    if(this.readyState=="completed" || this.readyState=="loaded") { TM_onBKAvailable.call();}
                                };
                            }
                            headElement.appendChild(scriptElement);
                        }
                    }
            }
        };

        _ad.writeAd = function() {

            _ad.createAdElement();

            var adSeverCall = _ad.getAdServerCall();
            document.writeln(adSeverCall);
            
            _ad.getBlueKaiCall();
            
            _ad.createAnalytics();

            var segmentCall = _ad.getSegmentCall();
            document.writeln(segmentCall);
            
            var audienceScienceCall = _ad.getAudienceScienceCall();
            document.writeln(audienceScienceCall);

        };
    };

    AdFactory.getAd = function(id, adTagImplementationTypeId) {
        var adIndex = 0;

        if (window[TAN_AD_DATA] && window[TAN_AD_DATA][adTagImplementationTypeId] != null) {
            adIndex = window[TAN_AD_DATA][adTagImplementationTypeId] + 1;
        }

        window[TAN_AD_DATA][adTagImplementationTypeId] = adIndex;

        var ad = new AdFactory.Ad(id, adTagImplementationTypeId, adIndex);

        return ad;
    };

    AdFactory.TAN_AD_SERVER_TYPE = {'DFP': 2};

    AdFactory.TAN_AD_TAG_IMPLEMENTATION_TYPE = {'IFRAME': 1, 'JAVASCRIPT': 2};

    AdFactory.TAN_FOLD_POSITION = {};
    AdFactory.TAN_FOLD_POSITION[AdFactory.TAN_AD_SERVER_TYPE.DFP] = {'ABOVE': 1, 'BELOW': 2, 'UNKNOWN': 3};

    AdFactory.TAN_HORIZONTAL_POSITION = {};
    AdFactory.TAN_HORIZONTAL_POSITION[AdFactory.TAN_AD_SERVER_TYPE.DFP] = {'LEFT': 1, 'RIGHT': 2, 'UNKNOWN': 3};

    AdFactory.TAN_SECURITY = {};
    AdFactory.TAN_SECURITY[AdFactory.TAN_AD_SERVER_TYPE.DFP] = {'SECURE': 1, 'NOT_SECURE': 2, 'UNKNOWN': 3};

    AdFactory.TAN_VERTICAL_POSITION = {};
    AdFactory.TAN_VERTICAL_POSITION [AdFactory.TAN_AD_SERVER_TYPE.DFP] = {'TOP': 1, 'MIDDLE': 2, 'BOTTOM': 3, 'UNKNOWN': 4};
    
    AdFactory.TAN_IFRAME_DETECTION = {};
    AdFactory.TAN_IFRAME_DETECTION [AdFactory.TAN_AD_SERVER_TYPE.DFP] = {'JS': 0, 'IFRAME': 1, 'UNKNOWN': 2};

    if (typeof window[TAN_AD] == "undefined" || !window[TAN_AD]) {
        window[TAN_AD] = AdFactory;
    }

    if (typeof window[TAN_AD_DATA] == "undefined" || !window[TAN_AD_DATA]) {
        window[TAN_AD_DATA] = new Array();
    }
})();

