

var Taggify = {
    apiHost : null,
    apiKey : null,
    authCode : null,
    authTicket : null,
    noLabels : 1,
    theme : 'ffffcc',
    reserved : '',
    
    onTagClick : null,
    onTagOver : null,

    Targets : {
        list : [],
        active : null,
        
        load : function() {
            var jsonp = new Taggify.JSONP(
                function(jsonpObj, responseText) { 
                    if (responseText.length > 0) {
                        eval(responseText);
                        Taggify.Targets.list = targets;
                        Taggify.Targets.render();
                    }
                    else {
                        Taggify.Targets.list = [];
                    }
                }, 
                function(jsonpObj) {
                });
            
            url = Taggify.apiHost + 'v2/service.ashx';
            query = 'key=' + Taggify.apiKey + '&verb=get&scope=' + Taggify.scope;
            jsonp.get(url, query + Taggify.reserved);
            
        },
        
        get : function(_img)
        {
            for (var i = 0; i < this.list.length; i++) {
                var _target = this.list[i];
                if (_target.url == _img || _target.img == _img) return _target;
            }
            return null;
        },
        
        render : function() {
            for (var i = 0; i < this.list.length; i++) {
                _target = this.list[i];
                _target.index = i;
                _target.img = Taggify.Utils.image(_target.url);
                if (_target.img) {
                    _target.render();
                    _target.bind();
                }
            }
        },

        show : function(targetIndex, tagIndex) {
            if (Taggify.Viewer.disabled()) return;
            this.active = this.list[targetIndex];
            if (this.active) return this.active.show(tagIndex);
        },
        
        hide : function() {
            if (Taggify.Viewer.disabled()) return;
	        Taggify.Frame.hide();
        },
        
        click : function(targetIndex, tagIndex) {
            target = this.list[targetIndex];
            if(target) target.click(tagIndex);
        }
    },
    
    Frame : {
        disabled : false,
    
        // Border
        outer : null,
        middle : null,
        inner : null,
        
        // Fade
        left : null,
        top : null,
        right : null,
        bottom : null,
        
        // Parameters
        width : 5,
        border : '#333333',
        background : '#eeeeee',
        fade: '#cccccc',
        transparency: 50,
        
        // Framed image
        image : null,
        visible : false,
        
        initialized : false,        
        init : function() {
            if (!this.initialized)
            {
                this.outer = Taggify.Utils.get('tgf_outer');
                this.middle = Taggify.Utils.get('tgf_middle');
                this.inner = Taggify.Utils.get('tgf_inner');

	            this.left = Taggify.Utils.get('tgf_fade_l');
	            this.top = Taggify.Utils.get('tgf_fade_t');
	            this.right = Taggify.Utils.get('tgf_fade_r');
	            this.bottom = Taggify.Utils.get('tgf_fade_b');
	            
                this.initialized = true;
            }
            
            this.outer.style.borderColor = this.border;
            this.inner.style.borderColor = this.border;
            this.middle.style.borderWidth = this.width + 'px';
            this.middle.style.borderColor = this.background;
            
            this.initFade(this.left);
            this.initFade(this.top);
            this.initFade(this.right);
            this.initFade(this.bottom);
        },
        
        initFade : function(pane)
        {
	        pane.style.backgroundColor = this.fade;
            pane.style.opacity = '.' + (100 - this.transparency);
            pane.style.filter = 'alpha(opacity=' + (100 - this.transparency) + ')'; 
        },
        
        set : function(img, x1, y1, x2, y2) {
            this.image = img;
            
            var fw = this.width;
            var ic = Taggify.Utils.coords(img);
            var il = ic[0];
            var it = ic[1];
            var vh = y2 - y1 + 1;
            var iw = img.offsetWidth;
            var ih = img.offsetHeight;

            // Outer border.
            this.outer.style.left = il + x1 + "px";
            this.outer.style.top = it + y1 + "px";
            this.outer.style.width = x2 - x1 - 1 + "px";
            this.outer.style.height = y2 - y1 - 1 + "px";
    
            // Middle border.
            this.middle.style.left = il + x1 + 1 + "px";
            this.middle.style.top = it + y1 + 1 + "px";
            this.middle.style.width = x2 - x1 - fw * 2 - 1 + "px";
            this.middle.style.height = y2 - y1 - fw * 2 - 1 + "px";
    
            // Inner border
            this.inner.style.left = il + x1 + fw + 1 + "px";
            this.inner.style.top = it + y1 + fw + 1 + "px";
            this.inner.style.width = x2 - x1 - fw * 2 - 3 + "px";
            this.inner.style.height = y2 - y1 - fw * 2 - 3 + "px";

            // Fade Top
	        this.top.style.left = il + "px";
	        this.top.style.top = it + "px";
	        this.top.style.width = iw + "px";
	        this.top.style.height = y1 + "px";
	        
            // Fade Bottom
	        this.bottom.style.left = il + "px";
	        this.bottom.style.top = it + y2 + 1 + "px";
	        this.bottom.style.width = iw + "px";
	        this.bottom.style.height = Math.max(ih - y2 - 1, 0) + "px";

            // Fade Left
	        this.left.style.left = il + "px";
	        this.left.style.top = it + y1 + "px";
	        this.left.style.width = x1 + "px";
	        this.left.style.height = vh + "px";

            // Fade Right
	        this.right.style.left = il + x2 + 1 + "px";
	        this.right.style.top = it + y1 + "px";
	        this.right.style.width = Math.max(iw - x2 - 1, 0) + "px";
	        this.right.style.height = vh + "px";
        },
        
        show : function() {
            if (!this.visible) {
                Taggify.Utils.show(this.outer);
                Taggify.Utils.show(this.left);
                Taggify.Utils.show(this.top);
                Taggify.Utils.show(this.right);
                Taggify.Utils.show(this.bottom);
                this.visible = true;
            }
        },
        
        hide : function() {
            if (this.visible) {
                Taggify.Utils.hide(this.outer);
                Taggify.Utils.hide(this.left);
                Taggify.Utils.hide(this.top);
                Taggify.Utils.hide(this.right);
                Taggify.Utils.hide(this.bottom);
                this.visible = false;
            }
        }
    },

    Utils : {
        get : function() {
            var ea;
            for(var i = 0; i < arguments.length; i++) {
                var e = arguments[i];
                if(typeof e == 'string') e = document.getElementById(e);
                if(arguments.length == 1) return e;
                if(!ea) ea = new Array();
                ea[ea.length] = e;
            }
            return ea;
        }, 
        image : function(url) {
            for(var i = 0; i < document.images.length; i++) {
                var img = document.images[i];
                var src = decodeURIComponent(img.src);
                if (src.substr(0, 11) == 'http://www.') src = 'http://' + src.substr(11);
                if (src == url) return img;
            }
            return null;
        },
        show : function() {
            for(var i = 0; i < arguments.length; i++) {
                var element = arguments[i];
                if (typeof element == 'string') element = this.get(element);
                if (element && element.style) element.style.display = 'block';
            }
        },
        show2 : function() {
            for(var i = 0; i < arguments.length; i++) {
                var element = arguments[i];
                if (typeof element == 'string') element = this.get(element);
   	            if (element && element.style) element.style.display = "inline";
            }
        },
        hide : function() {
            for(var i = 0; i < arguments.length; i++) {
                var element = arguments[i];
                if (typeof element == 'string') element = this.get(element);
                if (element && element.style) element.style.display = 'none';
            }
        },
        wrapNode : function (node, wrapper, cssClass) {  
            var parent = node.parentNode;  
            wrapper = document.createElement(wrapper);  
            wrapper.appendChild(node.cloneNode(true));  
            if(cssClass) wrapper.className = cssClass;
            parent.replaceChild(wrapper, node);
            return wrapper;  
        },
        getCssClass : function(name) {
	        for (var s = 0; s < document.styleSheets.length; s++) {
                if(document.styleSheets[s].rules) {
			        for (var r = 0; r < document.styleSheets[s].rules.length; r++) {
				        if (document.styleSheets[s].rules[r].selectorText == '.' + name)
					        return document.styleSheets[s].rules[r];
			        }
		        }
		        else if(document.styleSheets[s].cssRules) {
			        for (var r = 0; r < document.styleSheets[s].cssRules.length; r++) {
				        if (document.styleSheets[s].cssRules[r].selectorText == '.' + name)
					        return document.styleSheets[s].cssRules[r];
			        }
		        }
	        } 
	        return null;
        },
        addScript : function(url, charset, callback) {
            var js = document.createElement("script"); 
            if (charset) js.charset = charset;
            js.type = "text/javascript"; 
            js.src = url; 
            if (callback) js.onload = js.onreadystatechange = callback;
            var head = document.getElementsByTagName('head')[0];
            head.insertBefore(js, head.firstChild);
        },
        addStyle : function(_url, _id) {
            var link = document.createElement("link"); 
            link.type = "text/css"; 
            link.rel = "stylesheet"
            link.href = _url; 
            if(_id) link.id = _id;
            var head = document.getElementsByTagName('head')[0];
            head.insertBefore(link, head.firstChild);
        },
        _addCss : function(_css) {
            var style = document.createElement("style"); 
            style.innerHTML = _css;
            var head = document.getElementsByTagName('head')[0];
            head.insertBefore(style, head.firstChild);
        },
        addCss : function(_css) {
            var style = document.createElement("style");
            style.type = "text/css";
            if (style.styleSheet) style.styleSheet.cssText = _css;
            else style.appendChild(document.createTextNode(_css));

            var head = document.getElementsByTagName('head')[0];
            head.insertBefore(style, head.firstChild);
        },
        insertHtml : function(html) {
            var div = document.createElement("div"); 
            div.innerHTML = html;
            document.body.insertBefore(div, document.body.childNodes[0]);
        },
        addEvent : function(obj, e, handler) {
            var fn = handler;   

            if (!obj.attachedEvents) obj.attachedEvents = new Array();
            if (obj.attachedEvents[e]) this.removeEvent(obj, e);

            obj.attachedEvents[e] = fn;

            if (typeof obj.addEventListener != 'undefined') obj.addEventListener(e, handler, false);
            else if (typeof obj.attachEvent != 'undefined') obj.attachEvent('on' + e, handler);
        },
        removeEvent : function(obj, e) {
            if (!obj.attachedEvents || !obj.attachedEvents[e]) return;
            if (typeof obj.removeEventListener != 'undefined') obj.removeEventListener(e, obj.attachedEvents[e], false);
            else if (typeof obj.detachEvent != 'undefined') obj.detachEvent('on' + e, obj.attachedEvents[e]);
        },
        
        cancelEvent : function(e) {
	        var e = e ? e : window.event;
	        if(e.preventDefault) e.preventDefault();
	        if(e.stopPropagation) e.stopPropagation(); 
	        e.cancelBubble = true;
	        e.returnValue = false;
	        return false;
        },
        coords : function(obj) {
            var c = [0, 0];
            //if (obj.x) c = [obj.x, obj.y];
            //else 
            if (obj.offsetParent) {
                do { 
                    if (obj.nodeName != "TD" || obj.id.substr(0,3) != 'tgf') {
                        c[0] += obj.offsetLeft; 
                        c[1] += obj.offsetTop
                    }
                } while (obj = obj.offsetParent);
            }
            return c;
        },
        objX : function(obj) {
            var left = 0;
            //if (obj.x) left = obj.x;
            //else 
            if (obj.offsetParent) {
                do { left += obj.offsetLeft; } while (obj = obj.offsetParent);
            }
            return left;
        },
        objY : function(obj) {
            var top = 0;
            //if (obj.y) top = obj.y;
            //else 
            if(obj.offsetParent) {
                do { top += obj.offsetTop; } while (obj = obj.offsetParent);
            }
            return top;
        },
        mouseX : function(e) {
            var x = 0;
            if (!e) var e = window.event;
            if (e.pageX)x = e.pageX;
            else if (e.clientX && document.body.scrollLeft) x = e.clientX + document.body.scrollLeft;
            else if (e.clientX && document.documentElement.scrollLeft) x = e.clientX + document.documentElement.scrollLeft;
            else if (e.clientX) x = e.clientX;
            return x;
        },
        mouseY : function(e) {
            var y = 0;
            if (!e) var e = window.event;
            if (e.pageY) y = e.pageY;
            else if (e.clientY && document.body.scrollTop) y = e.clientY + document.body.scrollTop;
            else if (e.clientY && document.documentElement.scrollTop) y = e.clientY + document.documentElement.scrollTop;
            else if (e.clientY) y = e.clientY;
            return y;
        },
        docWidth : function() {
            return this._sv(window.innerWidth ? window.innerWidth : 0,
                    document.documentElement ? document.documentElement.clientWidth : 0,
                    document.body ? document.body.clientWidth : 0, true);
        },
        docHeight : function() {
            return this._sv(window.innerHeight ? window.innerHeight : 0,
                    document.documentElement ? document.documentElement.clientHeight : 0,
                    document.body ? document.body.clientHeight : 0, true);
        },
        clientWidth : function() {
            return this._sv(window.innerWidth ? window.innerWidth : 0,
                    document.documentElement ? document.documentElement.clientWidth : 0,
                    document.body ? document.body.clientWidth : 0, false);
        },
        clientHeight : function() {
            return this._sv(window.innerHeight ? window.innerHeight : 0,
                    document.documentElement ? document.documentElement.clientHeight : 0,
                    document.body ? document.body.clientHeight : 0, false);
        }, 
        scrollLeft : function() {
            return this._sv(window.pageXOffset ? window.pageXOffset : 0,
                    document.documentElement ? document.documentElement.scrollLeft : 0,
                    document.body ? document.body.scrollLeft : 0, false);
        },
        scrollTop : function() {
            return this._sv(window.pageYOffset ? window.pageYOffset : 0,
                    document.documentElement ? document.documentElement.scrollTop : 0,
                    document.body ? document.body.scrollTop : 0, false);
        },
        _sv : function(n_win, n_docel, n_body, for_doc) {
            var n_result = n_win ? n_win : 0;
            if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel;
                return n_body && (!n_result || (!for_doc && n_result > n_body)) ? n_body : n_result;
        },
        
        scrollTo : function(id) { location.hash = id; }
    },
    
    Viewer : {
        disable : false,
        
        tagsCaption : null,
        tagsBackground : null,

        timerId : null,
        
        tip : null,
        tipHideTime : 600,
        
        initialized : false,
        init : function() {
            if(!this.initialized) {
                var viewer = this;
                Taggify.Targets.load();
                Taggify.Tip.preload();
                this.initialized = true;
            }
        },
        
        activate : function() {
            this.init();
            Taggify.Frame.init();
            
            Taggify.fnTagOver = this.tagOver;
            Taggify.fnTagOut = this.tagOut;
            Taggify.fnTagClick = this.tagClick;            
            Taggify.fnImgOver = this.imgOver;
            Taggify.fnImgClick = this.imgClick;
            Taggify.fnFrameClick = this.frameClick;
            Taggify.fnFrameOver = this.frameOver;
            Taggify.fnFrameOut = this.frameOut;
            Taggify.fnTipOut = this.tagOut;
            Taggify.fnTipOver = this.tipOver;
            Taggify.fnTipClose = this.tipClose;
        },

        disabled : function() { 
            return this.disable;
        },

        tagOver : function(targetIndex, tagIndex, e) {
            var v = Taggify.Viewer;
            v.showTip(targetIndex, tagIndex);
            if (e) Taggify.Utils.cancelEvent(e);
        },
        
        tagOut : function(e) {
            var v = Taggify.Viewer;
            v.hideTip(v.tipHideTime);
            if (e) Taggify.Utils.cancelEvent(e);
        },
       
        tipOver : function(e) { 
            Taggify.Viewer.keepTip();
            if (e) Taggify.Utils.cancelEvent(e);
        },
        
        tipClose : function(e) {
            Taggify.Viewer.hideTip();
            if (e) Taggify.Utils.cancelEvent(e);
        },
        
        frameOut : function(e) {
            var _active = Taggify.Targets.active;
            var _viewer = Taggify.Viewer;
            if(_active) {
                var tagIndex = _viewer.hitTest(_active.index, e);
                if(tagIndex >= 0) {
                    _viewer.tagOver(_active.index, tagIndex, e);
                    return; 
                }
            }
            _viewer.tagOut(e);
        },
         
        tagClick : function(targetIndex, tagIndex, e) { 
            Taggify.Targets.click(targetIndex, tagIndex);
            if (e) Taggify.Utils.cancelEvent(e);
        },
        
        imgOver : function(targetIndex, e) {
            if (!Taggify.Frame.visible) {
                var tagIndex = Taggify.Viewer.hitTest(targetIndex, e);
                if (tagIndex >= 0) Taggify.onTagOver(targetIndex, tagIndex, e);
                else Taggify.onTagOut(e);            
            }
        },
        
        imgClick : function(targetIndex, e) {
            var tagIndex = Taggify.Viewer.hitTest(targetIndex, e);
            if (tagIndex >= 0) Taggify.onTagClick(targetIndex, tagIndex, e);
        },
        
        frameOver : function(e) {
            Taggify.Viewer.keepTip();
            if (e) Taggify.Utils.cancelEvent(e);
            /*
            var target = Taggify.Targets.get(Taggify.Frame.image);
            Taggify.Viewer.imgOver(target.index, e);
            */
        },
        
        frameClick : function(e) {
            var target = Taggify.Targets.get(Taggify.Frame.image);
            if (target) Taggify.onImgClick(target.index, e);
        },
        
        hitTest : function(targetIndex, e) {
            var target = Taggify.Targets.list[targetIndex];
            if (!target) return -1;

            var u = Taggify.Utils;
            var c = u.coords(target.img);
            var x = u.mouseX(e) - c[0];
            var y = u.mouseY(e) - c[1];
            
            var tags = target.tags;
            for (tagIndex = 0; tagIndex < tags.length; tagIndex++) {
                tag = tags[tagIndex];
                tag.bind(target.img);
                if (tag.contains(x, y)) return tagIndex;
            }
            return -1;
        },
        
        showTip : function(targetIndex, tagIndex) {
            var v = Taggify.Viewer;
            if(v.timerId) { clearTimeout(v.timerId); v.timerId = null;}
            var tag = Taggify.Targets.show(targetIndex, tagIndex);
            if(!this.tip) this.tip = new Taggify.Tip();
            this.tip.content(tag.title, tag.tip, tag.link, tag.theme);
            this.tip.position(tag);
            this.tip.show();
        },
        
        hideTip : function(delay) {
            var v = Taggify.Viewer;
        
            if(v.timerId) { clearTimeout(v.timerId); v.timerId = null;}
            if (delay) v.timerId = setTimeout('Taggify.Viewer.hideTip()', delay);
            else if(this.tip) {
                Taggify.Targets.hide();
                this.tip.hide();
            }
        },
        
        keepTip : function() {
            var v = Taggify.Viewer;
            if(v.timerId) { clearTimeout(v.timerId); v.timerId = null;}
        }
    },
    
    Tip : function() {
        this.create();
    },

    JSONP : function (doneHandler, failHandler) {
        this.init(doneHandler, failHandler);
    },
    
    compatible : function() {
        var b = Taggify.browser;
        var v = (b.version ? b.version.match(/(\d+(\.\d+)?)\.?/)[1] : 0);
        // IE6+, Safari 2+, Firefox 2+, Netscape 9+, Opera 9+
        return (b.msie && v >= 6) || (b.safari && v >= 419) || (b.mozilla && v >= 1.8) || (b.opera && v >= 9.24);
    },
    
    view : function() {
        // if (this.compatible()) 
        this.Viewer.activate();
    },
    
    edit : function() {
        if (!this.Editor) {
            this.Editor = { loading : true };
            this.splashId = window.setTimeout('Taggify.splash(true);', 300);
            url = Taggify.apiHost + 'v2/edit.ashx?key=' + Taggify.apiKey;
            if (Taggify.authTicket) url = url + '&ticket=' + Taggify.authTicket;
            this.Utils.addScript(url + Taggify.reserved, 'utf-8'); 
        }
        else if(typeof this.Editor.activate != 'undefined') this.Editor.activate();
    },
    
    splash : function(show) {
        if (this.splashId) { window.clearTimeout(this.splashId); this.splashId = null; }
    
        var u = Taggify.Utils;
        var p = u.get('tgf_load');
        if(show) {
            p.style.left = u.scrollLeft() + (u.docWidth() - p.clientWidth) / 2 + 'px';
            p.style.top = u.scrollTop() + (u.docHeight() - p.clientHeight) / 3 + 'px';
            u.show(p);
        }
        else u.hide(p);
    },
    
    onTagOver : function(targetIndex, tagIndex, e) { this.fnTagOver(targetIndex, tagIndex, e); },
    onTagClick : function(targetIndex, tagIndex, e) { this.fnTagClick(targetIndex, tagIndex, e); },
    onTagOut : function(e) { this.fnTagOut(e); },
    onImgOver : function(targetIndex, e) { this.fnImgOver(targetIndex, e); },
    onImgClick : function(targetIndex, e) { this.fnImgClick(targetIndex, e); },
    onFrameClick : function(e) { this.fnFrameClick(e); },
    onFrameOver : function(e) { this.fnFrameOver(e); },
    onFrameOut : function(e) { this.fnFrameOut(e); },
    onTipOver : function(e) { this.fnTipOver(e); },
    onTipOut : function(e) { this.fnTipOut(e); },
    onTipClose : function(e) { this.fnTipClose(e); }
};

Taggify.Tip.count  = 0;
Taggify.Tip.close = function(e, _index) {
    var u = Taggify.Utils;
    u.hide('tgf_tip_' + _index);
    u.cancelEvent(e);
};

Taggify.Tip.imageCache = new Array();
Taggify.Tip.preload = function() {
    var list = ['tip_b.png','tip_l.png','tip_lb.png','tip_lt.png','tip_r.png','tip_rb.png','tip_rt.png','tip_t.png','yellow/tip_a_bl.png','yellow/tip_a_br.png','yellow/tip_a_lt.png','yellow/tip_a_rb.png','yellow/tip_a_rt.png','yellow/tip_a_tl.png','yellow/tip_a_tr.png','tip_close.png','tip_glow.png'];
    var img  = document.createElement('IMG');   
    for(var i = 0; i < list.length; i++) {
        Taggify.Tip.imageCache[i] = img.cloneNode(false);
        Taggify.Tip.imageCache[i].src = Taggify.apiHost + 'images/' + list[i];
    }
};

Taggify.Tip.prototype = {
    ui : null,
    caption : null,
    cont : null,
    text : null,
    theme : null,
    anchor : null,
    index : -1,

    create : function() {
        var ns = Taggify.Tip;
        this.index = ns.count;

        var u = Taggify.Utils;
        u.insertHtml(ns.html.replace(/@/g, this.index));
        this.ui = u.get('tgf_tip_' + this.index);
        this.caption = u.get('tgf_capt_' + this.index);
        this.cont = u.get('tgf_cont_' + this.index);
        this.text = u.get('tgf_text_' + this.index);
        this.theme = u.get('tgf_theme_' + this.index);
        ns.count++;
    },
    
    setTheme : function(thm) {
        if (this.theme) this.theme.className = "tgf_" + thm;
    },
    
    move : function(pt) {
        this.ui.style.left = pt[0] + 'px';
        this.ui.style.top = pt[1] + 'px';
        
        var u = Taggify.Utils;
        if (this.anchor) u.hide(this.anchor);
        this.anchor = u.get('tgf_a' + pt[2] + '_' + this.index);
        if (this.anchor) u.show(this.anchor);
    },
    
    content : function(_caption, _text, _link, _theme) {
        this.caption.innerHTML = _caption;
        if (_link || _text) {
            this.text.innerHTML = _text;
            Taggify.Utils.show(this.cont);
        }
        else Taggify.Utils.hide(this.cont);
        if (typeof Taggify._forceTheme != 'undefined') _theme = Taggify._forceTheme;
        else if (!_theme || !_theme.length) _theme = Taggify.theme;
        this.theme.className = "tgf_" + _theme;
    },
    
    show : function() {
        this.ui.style.zIndex = 92;
        Taggify.Utils.show(this.ui);
    },
    
    hide : function() {
        Taggify.Utils.hide(this.ui);
    },
    
    position : function(tag) {
        this.move(this.calc(tag));
    },
    
    calc : function(tag) {
        var margin = 0;
        var u = Taggify.Utils;
        
        var c = u.coords(tag.img);
        imgL = c[0];
        imgT = c[1];

        this.ui.style.zIndex = -20;
        this.ui.style.display = 'block';
        this.ui.style.left = imgL + 'px';
        this.ui.style.top = imgT + 'px';
            
        x1 = imgL + tag.x1;
        x2 = imgL + tag.x2;
        y1 = imgT + tag.y1;
        y2 = imgT + tag.y2;
            
        tipW = this.ui.offsetWidth;
        tipH = this.ui.offsetHeight;
            
        scrL = u.scrollLeft(); 
        scrR = scrL + u.docWidth(); 
        scrT = u.scrollTop(); 
        scrB = scrT + u.docHeight();
            
        var distances = {
            'left' : (x1 - scrL - tipW),
            'right' : (scrR - x2 - tipW),
            'top' : (y1 - scrT - tipH),
            'bottom' : (dB = scrB - y2 - tipH)
        };        

        var horzEdge = (distances['top'] <= distances['bottom'] ? 'bottom' : 'top');
        var vertEdge = (distances['left'] <= distances['right'] ? 'right' : 'left');
        if (distances[horzEdge] <= distances[vertEdge]) {
            // Use vertical edge for docking. 
            x = (vertEdge == 'left' ? x1 - tipW - margin : x2 + margin);
            y = (Math.max(y1, scrT) + Math.min(y2, scrB)) / 2 - (horzEdge == 'top' ? tipH : 0);
            a = (vertEdge == 'left' ? 'r' : 'l') + (horzEdge == 'top' ? 'b' : 't');
        }
        else {
            // Use horizontal edge for docking. 
            y = (horzEdge == 'top' ? y1 - tipH - margin : y2 + margin);
            x = (Math.max(x1, scrL) + Math.min(x2, scrR)) / 2 - (vertEdge == 'left' ? tipW : 0);
            a = (horzEdge == 'top' ? 'b' : 't') + (vertEdge == 'left' ? 'r' : 'l');
        }
        
        return [x, y, a];
    }    
};

Taggify.Target = function(_url, _tags, _caption) {
    this.url = _url;
    this.tags = _tags;
    this.caption = _caption;
    this.img = null;
    this.index = -1;
    this.active = null;
};

Taggify.Target.prototype.bind = function() {
    for(index = 0; index < this.tags.length; index++) {
        this.tags[index].bind(this.img);
    }
};

Taggify.Target.prototype.render = function() {
    if (!this.img.id || this.img.id == '') {
        if (this.img.uniqueID) this.img.id = this.img.uniqueID;
        else this.img.id = 'tgf_' + this.index;
    }

    var u = Taggify.Utils;

    if (!Taggify.noLabels) {
        var links = new Array();
        for (i = 0; i < this.tags.length; i++) {
	        var tag = this.tags[i];
	        var args = this.index + ',' + i + ', event';
            links.push('<a href="#" onclick="Taggify.onTagClick(' + args + ')" onmouseover="Taggify.onTagOver(' + args + ');" onmouseout="Taggify.onTagOut(event);">' + tag.title + '</a>');
            alert('<a href="#" onclick="Taggify.onTagClick(' + args + ')" onmouseover="Taggify.onTagOver(' + args + ');" onmouseout="Taggify.onTagOut(event);">' + tag.title + '</a>');
        }
    
        var wrapper_id = this.img.id + '_wrap';
        var placeholder = u.get(wrapper_id);
        if (!placeholder) placeholder = this.img

        var wrapper = document.createElement('DIV');  
        wrapper.appendChild(this.img.cloneNode(true));  
        wrapper.id = wrapper_id;
        wrapper.className = 'tgf_wrap';
    
        var container = document.createElement('DIV');
        container.id = this.img.id + '_cnt';
        container.className = 'tgf_cnt';
        container.innerHTML = this.caption + ' ' + links.join(', ');
        wrapper.appendChild(container);

        placeholder.parentNode.replaceChild(wrapper, placeholder);
    }

    this.img = u.get(this.img.id);
    var idx = this.index;
    u.addEvent(this.img, 'mousemove', function(e) { if (typeof Taggify != 'undefined') Taggify.onImgOver(idx, e); });
    u.addEvent(this.img, 'click', function(e) { Taggify.onImgClick(idx, e); });
};

Taggify.Target.prototype.show = function(tagIndex) {
    this.active = this.tags[tagIndex];
    if (this.active) { 
        this.active.bind(this.img);
        this.active.show();
    }
    return this.active;
};

Taggify.Target.prototype.click = function(tagIndex) {
    tag = this.tags[tagIndex];
    if (tag) tag.click();
};

Taggify.Tag = function(_id, _bounds, _title, _text, _link, _keywords, _kind, _theme) {
    this.id = _id;
    this.bounds = _bounds;
    this.title = _title;
    this.text = _text;
    this.link = _link;
    this.keywords = _keywords;
    this.kind = _kind;
    this.tip = this.encode(_text);
    this.theme = _theme;
};

Taggify.Tag.prototype.encode = function(_text) {
    return _text.replace(/\n/g, '<br/>');
};

Taggify.Tag.prototype.bind = function(_img) {
    this.img = _img;
        
    var w = _img.offsetWidth; 
    var h = _img.offsetHeight;
    
    this.x1 = Math.min(Math.round(this.bounds[0] * w / 100), w - 1);
    this.y1 = Math.min(Math.round(this.bounds[1] * h / 100), h - 1);

	this.x2 = Math.min(Math.round(this.bounds[2] * w / 100), w - 1);
	this.y2 = Math.min(Math.round(this.bounds[3] * h / 100), h - 1);
};

Taggify.Tag.prototype.contains = function(x, y) {
    return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2);
};

Taggify.Tag.prototype.show = function() {
	Taggify.Frame.set(this.img, this.x1, this.y1, this.x2, this.y2);
	Taggify.Frame.show();
};

Taggify.Tag.prototype.click = function() {
    if(this.link) {
        if (this.link.substr(0, 7) == 'mailto:') window.open(this.link);
        else if (this.link.substr(0, 4) == 'ftp:') window.open(this.link);
        else if (this.link.substr(0, 5) == 'http:' || this.link.substr(0, 6) == 'https:') window.open(this.link);
        else window.open('http://' + this.link);
    }
};

Taggify.userAgent = navigator.userAgent.toLowerCase();
Taggify.browser = {
	version: (Taggify.userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
	safari: /webkit/.test(Taggify.userAgent),
	opera: /opera/.test(Taggify.userAgent),
	msie: /msie/.test(Taggify.userAgent) && !/opera/.test(Taggify.userAgent),
	mozilla: /mozilla/.test(Taggify.userAgent) && !/(compatible|webkit)/.test(Taggify.userAgent)
};

Taggify.JSONP.count = 0;
Taggify.JSONP.prototype = {

    onDone : null,
    onFail : null,
    completed : false,
    
    init : function (doneHandler, failHandler) {
        this.onDone = doneHandler;
        this.onFail = failHandler;
    },
    
    get : function(uri, query) {
        if (typeof query != 'string') query = this.arrayToQueryString(query);

        var jsonp = this;
        callback = 'cb' + Taggify.JSONP.count++;
        Taggify.JSONP[callback] = function(response, status, msg) {

            Taggify.JSONP[callback] = undefined;
            try { delete Taggify.JSONP[callback]; } 
            catch(e) { }
        
            if (status >= 200 && status < 300) {
                if (jsonp.onDone) jsonp.onDone(jsonp, response, status);
            } 
            else { 
                Taggify.callbackError = msg;
                if (jsonp.onFail) jsonp.onFail(jsonp, status);
            }
        };
        
        fullURI = uri + '?' + (query ? (query + '&') : '') + 'callback=Taggify.JSONP.' + callback + '&_ts=' + (new Date()).getTime();

        jsonp.completed = false;
        Taggify.Utils.addScript(fullURI, 'utf-8', function() {        
            if (!jsonp.completed && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
                jsonp.completed = true;
			    this.parentNode.removeChild(this);
            }
		}); 
    },
    
    arrayToQueryString : function(queryArray) {
        var sep = '';
        var query = "";
  
        for( var key in queryArray ) {
            query = query + sep + encodeURIComponent(key) + '=' + encodeURIComponent(queryArray[key]);
            sep = '&';
        }
        return query;
    }
};



Taggify.apiKey = '932b621ed5054a24a29f106d547ca623';
Taggify.apiHost = 'http://www.taggify.net/';
Taggify.scope = ''
Taggify.Frame.fade = '#CCCCCC';
Taggify.Frame.transparency = 50;
Taggify.Frame.border = '#ffffff';
Taggify.Frame.background = '#EEEEEE';
Taggify.Frame.width = 1;
Taggify.Tip.html = '<div id="tgf_tip_@" style="display:none;" class="tgf_tip" onmousemove="Taggify.onTipOver(event);" onmouseout="Taggify.onTipOut(event);"><div id="tgf_theme_@" class="tgf_yellow">  <div id="tgf_alb_@" class="tgf_alb"></div><div id="tgf_alt_@" class="tgf_alt"></div><div id="tgf_art_@" class="tgf_art"></div><div id="tgf_arb_@" class="tgf_arb"></div> <div id="tgf_abl_@" class="tgf_abl"></div><div id="tgf_abr_@" class="tgf_abr"></div><div id="tgf_atl_@" class="tgf_atl"></div><div id="tgf_atr_@" class="tgf_atr"></div>  <table border="0" cellpadding="0" cellspacing="0"> <tr><td class="tgf_lt"></td><td class="tgf_t"></td><td class="tgf_rt"></td></tr> <tr><td class="tgf_l"></td><td class="tgf_pan">  <a href="#" onclick="Taggify.onTipClose(event);" class="tgf_cls"><div></div></a> <div id="tgf_capt_@" class="tgf_capt"></div> <div id="tgf_cont_@" class="tgf_text"><span id="tgf_text_@"></span></div> </td><td class="tgf_r"></td></tr> <tr><td class="tgf_lb"></td><td class="tgf_b"></td><td class="tgf_rb"></td></tr> </table> </div></div> ';
Taggify.Utils.addCss('\n#tgf_outer\n{\n	z-index: 5;\n	display: none;\n	border: 1px solid #666;\n	position: absolute;\n	background-color: Transparent;\n	cursor: pointer;\n	cursor: hand;\n}\n\n#tgf_middle\n{\n	border: 5px solid #fff;\n	width: 100%;\n	height: 100%;\n	background-color: Transparent;\n	cursor: pointer;\n	cursor: hand;\n}\n\n#tgf_inner\n{\n	border: 1px solid #666;\n	width: 100%;\n	height: 100%;\n	background-color: Transparent;\n	cursor: pointer;\n	cursor: hand;\n}\n\n.tgf_fade\n{\n	font-size: 0em;\n	overflow: hidden;\n	background-color: #ccc;\n	opacity: 0.50;\n	filter: alpha(opacity=50);\n	position: absolute;\n	z-index: 2;\n	display: none;\n}\n\n.tgf_tip\n{\n	position: absolute;\n	z-index: 20;\n}\n\n.tgf_alb, .tgf_alt, .tgf_arb, .tgf_art, .tgf_abl, .tgf_atl, .tgf_abr, .tgf_atr\n{\n	position: absolute;\n	z-index: 21;\n	background-repeat: no-repeat;\n	display: none;\n	padding: 0px;\n	margin: 0px;\n}\n\n.tgf_alb, .tgf_alt, .tgf_arb, .tgf_art\n{\n	width: 30px;\n	height: 40px;\n	font-size: 0px;\n}\n.tgf_abl, .tgf_atl, .tgf_abr, .tgf_atr\n{\n	width: 40px;\n	height: 30px;\n	font-size: 0px;\n}\n\n.tgf_alt\n{\n	left: 0px;\n	top: 25px;\n}\n.tgf_alb\n{\n	left: 0px;\n	bottom: 25px;\n}\n.tgf_art\n{\n	right: 0px;\n	top: 25px;\n}\n.tgf_arb\n{\n	right: 0px;\n	bottom: 25px;\n}\n.tgf_abl\n{\n	left: 25px;\n	bottom: 0px;\n}\n.tgf_atl\n{\n	left: 25px;\n	top: 0px;\n}\n.tgf_abr\n{\n	right: 25px;\n	bottom: 0px;\n}\n.tgf_atr\n{\n	right: 25px;\n	top: 0px;\n}\n\n.tgf_lt, .tgf_t, .tgf_rt, .tgf_l, .tgf_r, .tgf_lb, .tgf_b, .tgf_rb\n{\n	width: 29px;\n	height: 29px;\n	font-size: 0px;\n}\n.tgf_lt\n{\n	background-image: url(http://taggify.net/images/tip_lt.png);\n	background-repeat: no-repeat;\n	background-position: right bottom;\n}\n.tgf_t\n{\n	background-image: url(http://taggify.net/images/tip_t.png);\n	background-repeat: repeat-x;\n	background-position: bottom;\n}\n.tgf_rt\n{\n	background-image: url(http://taggify.net/images/tip_rt.png);\n	background-repeat: no-repeat;\n	background-position: left bottom;\n}\n.tgf_r\n{\n	background-image: url(http://taggify.net/images/tip_r.png);\n	background-repeat: repeat-y;\n	background-position: left;\n}\n.tgf_rb\n{\n	background-image: url(http://taggify.net/images/tip_rb.png);\n	background-repeat: no-repeat;\n	background-position: left top;\n}\n.tgf_b\n{\n	background-image: url(http://taggify.net/images/tip_b.png);\n	background-repeat: repeat-x;\n	background-position: top;\n}\n.tgf_lb\n{\n	background-image: url(http://taggify.net/images/tip_lb.png);\n	background-repeat: no-repeat;\n	background-position: right top;\n}\n.tgf_l\n{\n	background-image: url(http://taggify.net/images/tip_l.png);\n	background-repeat: repeat-y;\n	background-position: right;\n}\n\n.tgf_capt\n{\n	font-weight: bold;\n	padding-right: 20px;\n	padding-bottom: 7px;\n}\n.tgf_pan\n{\n	background-image: url(http://taggify.net/images/tip_glow.png);\n	background-repeat: repeat-x;\n	background-position: top;\n	width: 300px;\n	padding: 10px;\n	text-align: left;\n	color: #000;\n}\n.tgf_text\n{\n	padding: 10px;\n	border-top: solid 1px #ccc;\n}\n.tgf_foot\n{\n	padding-right: 0px;\n	padding-top: 7px;\n	text-align: right;\n	border-top: solid 1px #ccc;\n	font-size: 11px;\n	color: #666;\n}\n\n.tgf_img\n{\n	display: inline;\n	text-decoration: none;\n	border: none;\n}\n\n#tgf_load\n{\n	display: none;\n	padding: 50px;\n	border: solid 1px #999;\n	background-image: url(http://taggify.net/images/indicator.gif);\n	background-repeat: no-repeat;\n	background-position: 20px 50px;\n	color: #333;\n	background-color: #fff;\n	opacity: 0.70;\n	filter: alpha(opacity=70);\n	position: absolute;\n	z-index: 15;\n}\n\na.tgf_cls div\n{\n    float:right;\n    width:14px;\n    height:14px;\n    background-image:url(http://taggify.net/images/v2/btn_cls.png);\n    background-position:center center;\n    background-repeat:no-repeat;\n    margin:1px;\n}\n\na.tgf_cls:hover div\n{\n    margin:0;\n	border:solid 1px #777;\n}\n\n.tgf_cls IMG {border:none;}\n\n.tgf_ccccff .tgf_pan { border:solid 1px #9999cc; background-color:#ccccff; }\n.tgf_ccccff .tgf_cls:hover IMG {border:solid 1px #9999cc; background-color:#ffeecc;}\n.tgf_ccccff .tgf_alb { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_lb.png); } \n.tgf_ccccff .tgf_alt { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_lt.png); } \n.tgf_ccccff .tgf_arb { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_rb.png); } \n.tgf_ccccff .tgf_art { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_rt.png); }\n.tgf_ccccff .tgf_abl { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_bl.png); } \n.tgf_ccccff .tgf_atl { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_tl.png); } \n.tgf_ccccff .tgf_abr { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_br.png); } \n.tgf_ccccff .tgf_atr { background-image:url(http://taggify.net/images/v2/ccccff/tip_a_tr.png); }\n         \n.tgf_ccffcc .tgf_pan { border:solid 1px #99cc99; background-color:#ccffcc; }\n.tgf_ccffcc .tgf_cls:hover IMG {border:solid 1px #99cc99; background-color:#ffeecc;}\n.tgf_ccffcc .tgf_alb { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_lb.png); } \n.tgf_ccffcc .tgf_alt { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_lt.png); } \n.tgf_ccffcc .tgf_arb { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_rb.png); } \n.tgf_ccffcc .tgf_art { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_rt.png); }\n.tgf_ccffcc .tgf_abl { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_bl.png); } \n.tgf_ccffcc .tgf_atl { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_tl.png); } \n.tgf_ccffcc .tgf_abr { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_br.png); } \n.tgf_ccffcc .tgf_atr { background-image:url(http://taggify.net/images/v2/ccffcc/tip_a_tr.png); }\n         \n.tgf_ccffff .tgf_pan { border:solid 1px #99cccc; background-color:#ccffff; }\n.tgf_ccffff .tgf_cls:hover IMG {border:solid 1px #99cccc; background-color:#ffeecc;}\n.tgf_ccffff .tgf_alb { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_lb.png); } \n.tgf_ccffff .tgf_alt { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_lt.png); } \n.tgf_ccffff .tgf_arb { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_rb.png); } \n.tgf_ccffff .tgf_art { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_rt.png); }\n.tgf_ccffff .tgf_abl { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_bl.png); } \n.tgf_ccffff .tgf_atl { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_tl.png); } \n.tgf_ccffff .tgf_abr { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_br.png); } \n.tgf_ccffff .tgf_atr { background-image:url(http://taggify.net/images/v2/ccffff/tip_a_tr.png); }\n         \n.tgf_dddddd .tgf_pan { border:solid 1px ##aaa; background-color:#ddd; }\n.tgf_dddddd .tgf_cls:hover IMG {border:solid 1px #aaa; background-color:#ffeecc;}\n.tgf_dddddd .tgf_alb { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_lb.png); } \n.tgf_dddddd .tgf_alt { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_lt.png); } \n.tgf_dddddd .tgf_arb { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_rb.png); } \n.tgf_dddddd .tgf_art { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_rt.png); }\n.tgf_dddddd .tgf_abl { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_bl.png); } \n.tgf_dddddd .tgf_atl { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_tl.png); } \n.tgf_dddddd .tgf_abr { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_br.png); } \n.tgf_dddddd .tgf_atr { background-image:url(http://taggify.net/images/v2/dddddd/tip_a_tr.png); }\n         \n.tgf_ffcccc .tgf_pan { border:solid 1px #cc9999; background-color:#ffcccc; }\n.tgf_ffcccc .tgf_cls:hover IMG {border:solid 1px #cc9999; background-color:#ffeecc;}\n.tgf_ffcccc .tgf_alb { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_lb.png); } \n.tgf_ffcccc .tgf_alt { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_lt.png); } \n.tgf_ffcccc .tgf_arb { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_rb.png); } \n.tgf_ffcccc .tgf_art { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_rt.png); }\n.tgf_ffcccc .tgf_abl { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_bl.png); } \n.tgf_ffcccc .tgf_atl { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_tl.png); } \n.tgf_ffcccc .tgf_abr { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_br.png); } \n.tgf_ffcccc .tgf_atr { background-image:url(http://taggify.net/images/v2/ffcccc/tip_a_tr.png); }\n         \n.tgf_ffccff .tgf_pan { border:solid 1px #cc99cc; background-color:#ffccff; }\n.tgf_ffccff .tgf_cls:hover IMG {border:solid 1px #cc99cc; background-color:#ffeecc;}\n.tgf_ffccff .tgf_alb { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_lb.png); } \n.tgf_ffccff .tgf_alt { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_lt.png); } \n.tgf_ffccff .tgf_arb { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_rb.png); } \n.tgf_ffccff .tgf_art { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_rt.png); }\n.tgf_ffccff .tgf_abl { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_bl.png); } \n.tgf_ffccff .tgf_atl { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_tl.png); } \n.tgf_ffccff .tgf_abr { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_br.png); } \n.tgf_ffccff .tgf_atr { background-image:url(http://taggify.net/images/v2/ffccff/tip_a_tr.png); }\n         \n.tgf_ffffcc .tgf_pan { border:solid 1px #cccc99; background-color:#ffffcc; }\n.tgf_ffffcc .tgf_cls:hover IMG {border:solid 1px #cc9933; background-color:#ffeecc;}\n.tgf_ffffcc .tgf_alb { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_lb.png); } \n.tgf_ffffcc .tgf_alt { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_lt.png); } \n.tgf_ffffcc .tgf_arb { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_rb.png); } \n.tgf_ffffcc .tgf_art { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_rt.png); }\n.tgf_ffffcc .tgf_abl { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_bl.png); } \n.tgf_ffffcc .tgf_atl { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_tl.png); } \n.tgf_ffffcc .tgf_abr { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_br.png); } \n.tgf_ffffcc .tgf_atr { background-image:url(http://taggify.net/images/v2/ffffcc/tip_a_tr.png); }\n         \n');
Taggify.Utils.insertHtml('<div id="tgf_outer" onclick="Taggify.onFrameClick(event);" onmousemove="Taggify.onFrameOver(event);" onmouseout="Taggify.onFrameOut(event);"><div id="tgf_middle"><div id="tgf_inner"></div></div></div><div id="tgf_fade_t" class="tgf_fade" onmousemove="Taggify.onFrameOut(event);"></div><div id="tgf_fade_l" class="tgf_fade" onmousemove="Taggify.onFrameOut(event);"></div><div id="tgf_fade_r" class="tgf_fade" onmousemove="Taggify.onFrameOut(event);"></div><div id="tgf_fade_b" class="tgf_fade" onmousemove="Taggify.onFrameOut(event);"></div><div id="tgf_load" style="display:none;">Loading...</div>');
Taggify.view();

