function NewsPopupManager(puId, titleId, ccId, autoPosition, positionStyle, top, left, urm)
{
    this.hasPopup=false;
    this.popupId=puId;
    this.titleId=titleId;
    this.contentContainerId=ccId;
    this.urlManager=urm;
    this.fadeSpeed='normal';
    this.currentNewsId=-1;
    this.autoPosition=autoPosition;
    this.positionStyle=positionStyle;
    this.top=top;
    this.left=left;
}

NewsPopupManager.prototype.showNewsPopup=function(sender, newsId, ccId)
{
    if (newsId==this.currentNewsId && this.hasPopup)
    {
        this.closeNewsPopup();
    }
    else
    {
        var target=this.urlManager.getJSONServiceUrl('NewsContent.ashx');
        var npm=this;
        $.getJSON(target, { ID: newsId }, function(json) 
        { 
            if (npm.hasPopup && 2==1)
            {
                $('#' + npm.popupId).fadeOut(this.fadeSpeed);
            }
            $('#' + npm.contentContainerId).html(json.Content);
            $('#' + npm.titleId).html('<a href="' + json.Link + '">' + json.Title + '</a>');
            if (npm.autoPosition)
            {
                var pu=$('#' + npm.popupId);
                switch (npm.positionStyle)
                {
                    case 'left':           
                        pu.css('left', npm.left - sender.offsetLeft)
                        pu.css('top', npm.top + sender.offsetTop);
                        pu.css('position','absolute');
                        break;
                    case 'right': 
                        pu.css('left', (sender.offsetLeft + sender.offsetWidth) - npm.left);
                        pu.css('top', npm.top + sender.offsetTop);
                        pu.css('position','absolute');
                        break;
                    case 'static':
                        pu.css('left', npm.left);
                        pu.css('top', npm.top);
                        pu.css('position', 'absolute');
                }
                
            }
            $('#' + npm.popupId).css('display', 'block').fadeIn(this.fadeSpeed, function(){ npm.hasPopup=true; npm.currentNewsId=newsId; } );
        });
    }
}


NewsPopupManager.prototype.doShowPopup=function(json)
{
    $('#' + this.contentContainerId).html(json.Content);
    $('#' + this.titleId).html('<a href="' + json.Link + '">' + json.Title + '</a>');
    if (!this.hasPopup)
    {
        $('#' + this.popupId).fadeIn(this.fadeSpeed, function(){ this.hasPopup=true; } );
    }
}


NewsPopupManager.prototype.closeNewsPopup=function()
{
    if (this.hasPopup)
    {
        var npm=this;
        $('#' + this.popupId).fadeOut(this.fadeSpeed, function() { npm.hasPopup=false; npm.currentNewsId=-1; });
    }
}