var popup = {
    rtpop : new Array(),
    count : 0,
    ajaxUrl : 'getfile.php',
    oReg : new RegExp("^(.{0,}[/\\\\]|)([^/\\\\\\.]{0,})(\\.(.{0,})|)$"),
  
    initPopups : function()
    {
        var popups = $('a[hrefpop=true]').each(popup.createPopup);
    },
  
    createPopup : function()
    {
        var href, el, type, f;
        el = $(this);
        href = el.attr('href');
        type = popup.getType(href);
    
        if(type != 0)
        {
            el.addClass('highslide');
            this.popup = popup.count;
            f = null;
            switch(type)
            {
                case 1:
                    f = popup.imageExpand;
                    break;
        
                case 2:
                    f = popup.htmlExpand;
                    href = popup.ajaxUrl + '?type=html&url='+escape(href);
                    break;
        
                case 3:
                    f = popup.htmlExpand;
                    href = popup.ajaxUrl + '?type=text&url='+escape(href);
                    break;
        
                case 4:
                    f = popup.htmlExpand;
                    href = popup.ajaxUrl + '?type=flash&url='+escape(href);
                    break;
            }
      
      
            popup.rtpop[popup.count] = {
                src : href
            };
            this.onclick = f;
      
            popup.count++;
        }
    },
  
    getType : function(path)
    {
        var ext;
        if(res = path.match(popup.oReg))
        {
            ext = res[4].toLowerCase();
            switch(ext)
            {
                case 'jpg':
                case 'jpeg':
                case 'gif':
                case 'png':
                    return 1;
                    break;
        
                case 'htm':
                case 'html':
                    return 2
                    break;
        
                case 'txt':
                    return 3;
                    break;
        
                case 'swf':
                    return 4;
                    break;
            }
        }
    
        return 0;
    },
  
    imageExpand : function()
    {
        return hs.expand(this, {
            src: popup.rtpop[this.popup].src
            });
    },
  
    htmlExpand : function()
    {
        return hs.htmlExpand(this, {
            objectType: 'ajax',
            src: popup.rtpop[this.popup].src
            });
    }
}

jQuery(popup.initPopups);
