var Article = Class.create({
    lightview: false,
    initialize: function() {
        
        
        this.url               = '/modules/articles/front/server.php';
        this.destination_id    = "contentcontent";
        this.destination_el    = $(this.destination_id);
        this.source_id         = "article_container_full";
        this.source_class      = "article_container_full";
        this.source_el         = null;

    },
	collapse: function(id,collapse){
		
		var el = $('facebook_'+id);
		
		if (collapse) {
			el.down('div.item_main').show();
			el.down('div.item_intro').down('div.item_readmore').hide();
		}
		else {
			el.down('div.item_main').hide();
			el.down('div.item_intro').down('div.item_readmore').show();
		}
	},
    create:function(){
        

              
           /* if(this.source_el){
                this.source_el.show(); 
            }
            else{*/
            if (this.source_el) {
            
            }
            else {
                this.source_el = new Element('div', {
                    'id': this.source_id,
                    'class': this.source_class
                });
				
                this.inner_el = new Element('div', {
                    'id': 'article_container_inner',
                    'class': 'article_container_inner'
                });				
				this.inner_el.innerHTML = '';
                
				Element.extend(this.source_el);

				this.source_el.insert(this.inner_el);
				
                
                this.source_el.clonePosition(this.destination_el, {
                    'setTop': false,
                    'setHeight': false,
                    'setWidth': false,
                    'setLeft': false
                });
                                
                Element.insert(this.destination_el,{'after':this.source_el} );
                

            }
            //}
            
            if(this.destination_el){
                this.destination_el.hide();
            }                            

            scroll(0,0);    
            
            return this.inner_el;         
    },
    
    close: function(){
            if(this.destination_el){
                this.destination_el.show();
            }
                                                             
            if(this.source_el){
                this.source_el.hide();                                                    
            } 
            scroll(0,0); 
    },
    open: function(moduleinstance,vid,detail){

        var el = this.create();
           
        var params=$H(
        {
            moduleinstance:moduleinstance,
            vid:vid,
            detail:detail,
            sid:Math.random()
        }
        ).toQueryString();
        
        el.ajaxUpdate(   
            this.url, {
                method: 'get',
                parameters: params,                 
                onSuccess: function(transport){
                    this.source_el.show();
                }.bind(this)
            }
        );

    }
});



