if (typeof (Zone) != 'undefined' && Zone != '' && typeof (Agent) != 'undefined' && Agent != ''){

    check = false;
    try{
        _banner = eval('Banner' + Zone);
        check = true;
    } catch (e) {  }

    if (check && typeof (_banner) == 'object'){
        _follow = '';
        if (_banner.follow == '0') { _follow = ' rel="nofollow"'; }

        _str = '';
        if (Zone == 'A'){
            _str = '<div class="slidetop_body"><div data-slidetop="1" class="active">';
        }
        _str += '<div style="z-index:999" id="Banner' + Zone + '" banner_id="' + _banner.banner_id + '" category_id="' + _banner.category_id + '" zone="' + _banner.zone + '">';
        
        if (_banner.photo_url != ''){
            if (Zone != 'A'){
                _str += '<a href="' + _banner.url + '" target="_blank"' + _follow + '><img src="' + _banner.photo_url + '" alt="' + _banner.banner_title + '" width="100%" /><\/a>';
            } else {
                if (Platform != 'iphone' && Platform != 'ipad' && Platform != 'android'){
                    _str += '<a href="' + _banner.url + '" target="_blank"' + _follow + '><img src="' + _banner.photo_url + '" alt="' + _banner.banner_title + '" width="1280" height="400" /><\/a>';
                } else {
                    _str += '<a href="' + _banner.url + '" target="_blank"' + _follow + '><img src="' + _banner.photo_url + '" alt="' + _banner.banner_title + '" width="100%" /><\/a>';
                }
            }
        } else if (_banner.script != ''){
            _output = _banner.script.split('[br]').join('\r\n');
            _dom = Parser.parseFromString(_output, 'text/html');
            _str += _dom.body.textContent;

            // if( typeof(_crk) != 'undefined'){
            //   _str = _str.replace("_keyword_", _crk.keyword);
            //   _str = _str.replace("_brand_", _crk.brand);
            //   _str = _str.replace("_model_", _crk.model);
            // }else{
            _str = _str.replace("_keyword_", '');
            _str = _str.replace("_brand_", '');
            _str = _str.replace("_model_", '');
            // }
            _str = _str.replace("_url_", window.location.href);
        }

        _str += '<\/div>';

        if (Zone == 'A'){
            _str += '</div></div>';
        }
        document.writeln(_str);

        Collection.push({
            banner_id: _banner.banner_id,
            category_id: _banner.category_id,
            zone: _banner.zone,
            page: window.location.href,
        });

        if (Zone == 'POPUP'){
            $('#Banner' + Zone).on('click', 'a', { banner: _banner }, function (e){
                $.post(UrlClicks,{
                    'rand': Math.random(),
                    'banner_id': e.data.banner.banner_id,
                    'category_id': e.data.banner.category_id,
                    'zone': e.data.banner.zone,
                    'page': window.location.href,
                });
            });
        } else {
            $('#Banner'+Zone).on('click', function(e){
                // console.log('click Banner ' + $(this).attr('zone') + ' ' + $(this).attr('banner_id') );
                $.post(UrlClicks,{
                    'rand': Math.random(),
                    'banner_id': $(this).attr('banner_id'),
                    'category_id': $(this).attr('category_id'),
                    'zone': $(this).attr('zone'),
                    'page': window.location.href,
                });
            });
        }
    }
    Zone = _banner = '';
}
