YAHOO.namespace("Estalea.util");

YAHOO.Estalea.util.Pop = function(cfg){

    this.shouldPop = true;
    this.url = cfg.url;
    this.width = cfg.width;
    this.height = cfg.height;
    this.type = cfg.type;
    this.features = "location=0,menubar=0,resizable=yes,scrollbars=yes,width="+this.width+",height="+this.height;
    
    this.eventType = 'load';
    if (this.type == 'EXIT_POP') {
        this.eventType = 'unload';
    }
    pFlag = true; // reset pFlag upon initial registering   
    YAHOO.util.Event.on(window, this.eventType, this.popupWindow, this, true);
};


YAHOO.Estalea.util.Pop.prototype = {

    popupWindow : function(event){
    
        if (this.type != 'EXIT_POP' || pFlag) {
            YAHOO.util.Event.stopEvent(event);
            var newPopupWindow = window.open(this.url, '_blank', this.features);
            
            if(newPopupWindow) {
                if(this.type == 'POPBEHIND') {
                    newPopupWindow.blur();
                    window.focus();
                } else if (this.type == 'EXIT_POP') {
                    newPopupWindow.focus();
                }
            }
            return newPopupWindow;
        }
    }
};


YAHOO.Estalea.util.Pixel = function(cfg){

    this.url = cfg.url;
    YAHOO.util.Event.on(window, "load", this.addPixel, this, true);
};


YAHOO.Estalea.util.Pixel.prototype = {

    addPixel : function(event){
        var img = document.createElement('img');
        img.width = "1";
        img.height = "1";
        img.src = this.url;    
        document.body.appendChild(img);
    }
};

