﻿if(!SAPO.Widget||typeof(SAPO.Widget)=='undefined')
{
    SAPO.namespace('Widget');
}



SAPO.Widget.NavVideos = function(element,dataObject,options)
{
    this.init(element,dataObject,options);
}

SAPO.Widget.NavVideos.count=0;

SAPO.Widget.NavVideos.oldLocation=document.location.hash;

SAPO.Widget.NavVideos.elements=[];

SAPO.Widget.NavVideos.refresh=function()
{
    if(SAPO.Widget.NavVideos.oldLocation!=document.location.hash) {
	
        SAPO.Widget.NavVideos.oldLocation=document.location.hash;
        
        var called=false;
        
        for(var i in SAPO.Widget.NavVideos.elements) {
			if(typeof(SAPO.Widget.NavVideos.elements[i])=='function') {
                continue;
            }
            
            SAPO.Widget.NavVideos.elements[i].initialized = false;
            
            SAPO.Widget.NavVideos.elements[i].initLoad();
            
            if(!called&&SAPO.Widget.NavVideos.elements[i].options.callback)
            {
                eval(SAPO.Widget.NavVideos.elements[i].options.callback+'()');
                called=true;
            }
        }
    }
}


SAPO.Widget.NavVideos.prototype =
{
    init: function(element,dataObject)
    {
        SAPO.Widget.NavVideos.count++;
        
        if(SAPO.Widget.NavVideos.count==1)
        {
            window.setInterval('SAPO.Widget.NavVideos.refresh()',600);
        }
        
        var options=Object.extend(
        {
            lines:2,
			columns:3,
			jump:false,
			closeElm: 'close',
			vis1: {
				navElm: 'vis1', //classe do link ( elemento html 'a', anchor ) 
				template: 'vis1Template', //id do template que se encontra no html numa div escondida
				lines: 1,
				columns: 4
			},
			vis2: {
				navElm: 'vis2',
				template: 'vis2Template',
				lines: 2,
				columns: 4
			},
			vis3: {
				navElm: 'vis3',
				template: 'vis3Template',
				lines: 3,
				columns: 4
			},
			vis4: {
				navElm: 'vis4',
				template: 'vis4Template',
				lines: 1,
				columns: 1
			},
			activeVis: 'vis2',
			navLeft:false,
			navRight:false,
			template:false,
			callback:false,
			pagesDiv:false,
			pagesDesc:false,
			ajaxData:false,
			countTotal:false,
			initOnDemand:false,
			bullet:false
        },arguments[2] || {}
		);
        
        try
        {
            this.idName='nav'+SAPO.Widget.NavVideos.count;
            
			this.id = element;
			
            this.options=options;
            
            this.countTotalVerified=false;
            
            this.ajaxCache=[];
            
            this.element = $j('#' + this.id + ' .content')[0];  //dentro do NavVideos, o element refere-se ah div em que sao inserido as fotos - com o nosso html, isso eh a div.content
			
			 if(this.options.navLeft) {
				this.elmLeft = $j('#' + this.id + ' .' + this.options.navLeft)[0];
            }
            if(this.options.navRight) {
				this.elmRight = $j('#' + this.id + ' .' + this.options.navRight)[0];
            }
			if(this.options.vis1 && this.options.vis1.navElm){
				this.elmVis1 = $j('#' + this.id + ' .' + this.options.vis1.navElm)[0];
			}
			if(this.options.vis2 && this.options.vis2.navElm){
				this.elmVis2 = $j('#' + this.id + ' .' + this.options.vis2.navElm)[0];
			}
			if(this.options.vis3 && this.options.vis3.navElm){
				this.elmVis3 = $j('#' + this.id + ' .' + this.options.vis3.navElm)[0];
			}
			if(this.options.closeElm){
				this.elmClose = $j('#' + this.id + ' .' + this.options.closeElm)[0];
			}
			
            this.dataObject=dataObject;
            
            if(this.options.template)
            {
                this.templating=new SAPO.Utility.Templating();
            }
            
            
            this.currentPage=0;
            
			this.setActiveVis(this.options.activeVis);
		
            this.totalPerPage=Number(this.options[this.options.activeVis].lines)*Number(this.options[this.options.activeVis].columns);
            
            if(!this.options.jump)
            {
                this.options.jump = Number(this.totalPerPage);
            }
            
            
            if(typeof(this.options.pagesDiv)=='string')
            {
                this.options.pagesDiv = new Array(this.options.pagesDiv);
            }
            
            
            if(typeof(this.options.pagesDesc)=='string')
            {
                this.options.pagesDesc=new Array(this.options.pagesDesc);
            }
            
            
            if(this.options.pagesDiv)
            {
                this.pagesDiv=new Array(this.options.pagesDiv.length);
                
                for(var i=0; i<this.options.pagesDiv.length; i++)
                {
                    this.pagesDiv[i]=$j('#' + this.id + ' .' + this.options.pagesDiv[i])[0];
                } 
            } else {
                this.pagesDiv=false;
            }
            
            if(this.options.pagesDesc)
            {
                this.pagesDesc=new Array(this.options.pagesDesc.length);
                
                for(var i=0; i<this.options.pagesDesc.length; i++)
                {
                    this.pagesDesc[i] = $j('#' + this.id + ' .' + this.options.pagesDesc[i])[0];
                }
            } else{
                this.pagesDesc=false;
            }
            
            if(this.options.bullet)
            {
                this.bullet=document.getElementById(this.options.bullet); 
            }
			
            this.setButtonEvents();
            
            this.initialized=false;
            
            if(!this.options.initOnDemand)
            {
                this.initLoad(); 
            }
            
            SAPO.Widget.NavVideos.elements[this.idName]=this;
        }
        catch(e)
        {}
    },
	
	initLoad:function()
    {
        if(this.initialized)
        return;
        
        this.initialized=true;
        
        this.currentPage=0;
        
        var dados=document.location.hash.substring(1);
        
        if(dados)
        {
            dados=this.parse_str(dados);
            
            for(var i in dados)
            {
                if(i==this.idName)
                {
                    this.currentPage=(parseInt(dados[i])-1)*this.totalPerPage;
                    
                    if(this.currentPage<0)
                    {
                        this.currentPage=0;   
                    }  
                }  
            }  
        }
        
        this.verifyAjax(this.currentPage/this.totalPerPage);
        
        this.writeTemplate(this.currentPage);
	
	//console.log('thumbsINIT: ' + jQuery('.iteminfothumb').length);
	if (this.options.callback) {
	    eval(this.options.callback + '()');
	}
        
    },
	
	parse_str:function(str,array)
    {
        var glue1='=';
        
        var glue2='&';
        
        var array2=str.split(glue2);
        
        var array3=[];
        
        for(var x=0; x<array2.length; x++)
        {
            var tmp=array2[x].split(glue1);
            
            array3[unescape(tmp[0])]=unescape(tmp[1]).replace(/[+]/g,' ');   
        }
 
        if(array)
        {
            array=array3; 
        }
        
        else {
            return array3;

        }
    },
	
	setButtonEvents:function()
    {
        if(this.elmLeft)
        {
            Event.observe(this.elmLeft,'click',this.goLeft.bindAsEventListener(this));
        }
        
        if(this.elmRight)
        {
            Event.observe(this.elmRight,'click',this.goRight.bindAsEventListener(this));
        }
		
		if(this.elmVis1)
        {
            Event.observe(this.elmVis1,'click',this.changeVis.bindAsEventListener(this, 'vis1'));
        }
		
		if(this.elmVis2)
        {
            Event.observe(this.elmVis2,'click',this.changeVis.bindAsEventListener(this, 'vis2'));
        }
		
		if(this.elmVis3)
        {
            Event.observe(this.elmVis3,'click',this.changeVis.bindAsEventListener(this, 'vis3'));
        }
    },
	
	writeTemplate: function(curPage)
    {
	
		this.updateTotal();
		
        this.clearElement();
        
        this.currentPage=curPage;
        
        var start=curPage;
        
        var end=curPage+this.totalPerPage;
        
        if(this.options.ajaxData)
        {
            end=this.dataObject.length; 
        }

        if(end>this.dataObject.length)
        {
            end=this.dataObject.length;   
        }

        if(curPage==0 && this.elmLeft)
        {
            //this.elmLeft.style.visibility='hidden';
			$j(this.elmLeft).addClass('inactive');
        }
        
        else if(this.elmLeft)
        {
            //this.elmLeft.style.visibility='visible';
			$j(this.elmLeft).removeClass('inactive');
        }
        
        
        if(this.options.ajaxData)
        {
            if((Math.ceil(curPage/this.totalPerPage)==Math.ceil(this.options.countTotal/this.totalPerPage)-1||this.options.countTotal==0)&&this.elmRight)
            {
                //this.elmRight.style.visibility='hidden';
				$j(this.elmRight).addClass('inactive');
            }
            
            else if(this.elmRight)
            {
                //this.elmRight.style.visibility='visible';
				$j(this.elmRight).removeClass('inactive');				
            }
        }
        
        else
        {
            if(end==this.dataObject.length&&this.elmRight)
            {
                //this.elmRight.style.visibility='hidden';
				$j(this.elmRight).addClass('inactive');
            }
            
            else if(this.elmRight)
            {
                //this.elmRight.style.visibility='visible';
				$j(this.elmRight).removeClass('inactive');
            }  
        }
        
        
        var next=curPage;
        
        if(this.options.ajaxData)
        {
            next=0;   
        }
        
        var source = '';
	var count = 0;
        do
        {
	    if (count == 0) {
		source += '<div style="float: left;" class="thumbContentLine">';
	    }
	    source += this.templating.gen(this.options[this.options.activeVis].template, this.dataObject[next]);
	    
	    count++;
	    next++;
	    
	    if (count % 4 == 0) {
		source += '</div>';
		count = 0;
	    } 
        } while(next<end);
        
	if (source) {
	    this.element.innerHTML += source;
	}
	
        this.writePagination();
        
        this.writeBullets();
    },
	
	goLeft:function(e)
    {
	
	/*Google Analytics trackPageView*/
	_gaq.push(
	    ['_setAccount', 'UA-10665902-8'],
	    ['_setDomainName', '.ua.sapo.pt'],
	    ['_trackPageview']
	);
	
		if(this.elmRight){
			if(this.elmLeft.hasClassName('inactive')){
				return;
			}
		}
		
        this.currentPage-=this.options.jump;
		
		
		// added to prevent errors that ocurred due  to going back and forth in one vis mode, then changing back to another and going left, page could be -0.5
		if (this.currentPage < 0) {
			this.currentPage = 0;
		}
		//
        
        if(this.currentPage>=0)
        {
            this.verifyAjax(this.currentPage/this.totalPerPage);
            
            this.writeTemplate(this.currentPage);
            
            if(this.options.callback)
            {
                eval(this.options.callback+'()');
            }
        }
        
        else
        {
			//shouldn't this be currentPage = 0 ???
            this.currentPage+=this.options.jump;  
        }

        this.modifyHash(); 
    },
	
	goRight:function(e)
    {
	/*Google Analytics trackPageView*/
	_gaq.push(
	    ['_setAccount', 'UA-10665902-8'],
	    ['_setDomainName', '.ua.sapo.pt'],
	    ['_trackPageview']
	);
		if(this.elmRight){
			if(this.elmRight.hasClassName('inactive')){
				return;
			}
		}
		
        var numPages=0;
        
        if(this.options.ajaxData)
        {
            numPages=Math.ceil(this.options.countTotal/this.totalPerPage);   
        }
        
        else
        {
            numPages=Math.ceil(this.dataObject.length/this.totalPerPage);  
        }
        
        this.currentPage+=this.options.jump;
		
		// added to prevent errors that ocurred due  to going back and forth in one vis mode, then changing back to another and going left, page could take strange values
		if (this.currentPage > this.totalPerPage*numPages)  {
			this.currentPage = this.totalPerPage*numPages;
		}
        
        if(this.currentPage<(this.totalPerPage*numPages))
        {
            this.verifyAjax(this.currentPage/this.totalPerPage);
            
            this.writeTemplate(this.currentPage);
            
            if(this.options.callback)
            {
                eval(this.options.callback+'()'); 
            }
        }
        
        else
        {
            this.currentPage-=this.options.jump;   
        }

        this.modifyHash();
    },
	
	goPage:function(e)
    {
        var link=Event.findElement(e,'a');
        
        var page=parseInt(link.href.substr(link.href.lastIndexOf('#')+1));
        
        this.currentPage=(page-1)*this.totalPerPage;
        
        this.verifyAjax(page-1);
        
        this.writeTemplate(this.currentPage);
        
        if(this.options.callback)
        {
            eval(this.options.callback+'()');
            
            
        }
        
        
        this.modifyHash();
        
        
    },
	
	showPage:function(page)
    {
        this.currentPage=(page-1)*this.totalPerPage;
        
        this.verifyAjax(page-1);
        
        this.writeTemplate(this.currentPage);
        
        this.modifyHash();
        
        
    },
	
	modifyHash:function()
    {
        var page=(this.currentPage/this.totalPerPage)+1;
        
        var dados=document.location.hash.substring(1);
        
        if(dados)
        {
            dados=this.parse_str(dados);
        }
       
        else
        {
            dados=[];    
        }
        
        dados[this.idName]=page;
        
        var ret='';
        
        for(var i in dados)
        {
            if(typeof(dados[i])=='function'||dados[i]=='undefined')
            {
                continue; 
            }
            
            if(ret=='')
            {
                ret+='#';  
            }
            
            else
            {
                ret+='&'; 
            }

            ret+=i+'='+dados[i];
        }
        SAPO.Widget.NavVideos.oldLocation=document.location.hash=ret;   
    },
	
	verifyAjax:function(page)
    {
        if(this.options.ajaxData)
        {
            if(this.ajaxCache[page])
            {
                eval(this.ajaxCache[page]);
                
                this.dataObject=dados_videos;
                
                if(this.countTotalVerified)
                {
                    this.options.countTotal=this.countTotalVerified;
                }
            }
            
            else
            {
                new Ajax.Request(this.options.ajaxData,
                {
                    parameters:'rd='+Math.random()+'&page='+page,method:'get',asynchronous:false,onSuccess:this.verifyAjaxSuccess.bind(this)
                }
                
                );  
            }
        } 
    },
	
	verifyAjaxSuccess:function(req)
    {
        eval(req.responseText);
        
        this.ajaxCache[this.currentPage/this.totalPerPage]=req.responseText;
        
        this.dataObject=dados_videos;
        
        if(this.dataObject.length==this.options.countTotal)
        {
            this.options.ajaxData=false;
        }
		
        if(this.countTotalVerified)
        {
            if(this.countTotalVerified< this.currentPage+dados_videos.length)
            {
                this.countTotalVerified=this.currentPage+dados_videos.length;   
            }
            this.options.countTotal=this.countTotalVerified;
        }
        if(this.currentPage>this.options.countTotal)
        {
            this.currentPage=Math.floor(this.options.countTotal/this.totalPerPage)*this.totalPerPage;
            
            this.verifyAjax(this.currentPage/this.totalPerPage);
            
            return;  
        }
        if(dados_videos.length==0&&this.currentPage>0)
        {
            this.currentPage=this.currentPage-this.totalPerPage;
            
            this.countTotalVerified=this.currentPage;
            
            this.verifyAjax(Math.floor(this.currentPage/this.totalPerPage));
            
            return;  
        }  
    },
	
	writeBullets:function(curPage)
    {
        if(this.bullet)
        {
            this.bullet.innerHTML='';
            
            var curPage=Math.floor(this.currentPage/this.totalPerPage);
            
            if(this.options.ajaxData)
            {
                countElements=this.options.countTotal;
                
                numPages=Math.ceil(this.options.countTotal/this.totalPerPage);
                
                
            }
            
            else
            {
                countElements=this.dataObject.length;
                
                numPages=Math.ceil(this.dataObject.length/this.totalPerPage);
                
                
            }
            
            
            for(var my_curr=0;
            my_curr<numPages;
            
            my_curr++)
            {
                if(my_curr==curPage)
                {
                    var li=document.createElement('li');
                    
                    li.className="active";
                    
                    this.bullet.appendChild(li);
                    
                    
                }
                
                else
                {
                    var li=document.createElement('li');
                    
                    var a=document.createElement('a');
                    
                    a.href='#'+(my_curr+1);
                    
                    a.onclick=function()
                    {
                        return false;
                        
                        
                    }
                    
                    ;
                    
                    Event.observe(a,'click',this.goPage.bindAsEventListener(this));
                    
                    li.appendChild(a);
                    
                    this.bullet.appendChild(li);
                    
                    
                }
                
                
            }
            
            
        }
        
        
    },
	
	writePagination:function(curPage)
    {
        var numPages=0;
        
        var countElements=0;
        
        if(this.options.ajaxData)
        {
            countElements=this.options.countTotal;
            
            numPages=Math.ceil(this.options.countTotal/this.totalPerPage);
            
            
        }
        
        else
        {
            countElements=this.dataObject.length;
            
            numPages=Math.ceil(this.dataObject.length/this.totalPerPage);
            
            
        }
        
        
        var curPage=Math.floor(this.currentPage/this.totalPerPage);
        
        if(this.pagesDesc)
        {
            for(var my_curr=0;  my_curr<this.pagesDesc.length; my_curr++)
            {
                if(!this.pagesDesc[my_curr])
                {
                    continue;
                    
                    
                }
                
                
                this.pagesDesc[my_curr].innerHTML='';
                
                if(numPages>1)
                {
                    var max=((curPage+1)*this.totalPerPage);
                    
                    if(countElements<max)
                    {
                        max=countElements;
                        
                        
                    }
                    
                    
                    this.pagesDesc[my_curr].innerHTML=((curPage*this.totalPerPage)+1)+'-'+max+' de '+countElements;
                    
                    
                }
                
                
            }
            
            
        }
        
        
        if(this.pagesDiv)
        {
            for(var my_curr=0;
            my_curr<this.pagesDiv.length;
            
            my_curr++)
            {
                if(!this.pagesDiv[my_curr])
                {
                    continue;
                    
                    
                }
                
                
                var aCurPages=this.pagesDiv[my_curr].getElementsByTagName('a');
                
                for(var i=(aCurPages.length-1);
                i>=0;
                
                i--)
                {
                    aCurPages[0].parentNode.removeChild(aCurPages[i]);
                    
                    
                }
                
                
                this.pagesDiv[my_curr].innerHTML='';
                
                if(curPage>4)
                {
                    var link=document.createElement('A');
                    
                    link.href='#1';
                    
                    link.innerHTML='<strong>|&lt;</strong>';
                    
                    link.onclick=function()
                    {
                        return false;
                        
                        
                    }

                    link.title='Ir para a primeira';
                    
                    Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                    
                    this.pagesDiv[my_curr].appendChild(link);
                    
                    this.pagesDiv[my_curr].appendChild(document.createTextNode(' '));
                    
                    var link=document.createElement('A');
                    
                    link.href='#'+(curPage-4);
                    
                    link.innerHTML='<strong>&lt;&lt;</strong>';
                    
                    link.onclick=function()
                    {
                        return false; 
                    }
                    
                    link.title='Recuar 5 p\341ginas';
                    
                    Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                    
                    this.pagesDiv[my_curr].appendChild(link);
                    
                    this.pagesDiv[my_curr].appendChild(document.createTextNode(' '));
                    
                    
                }
                
                
                if(numPages>5&&curPage>4)
                {
                    var link=document.createElement('A');
                    
                    link.href='#'+(curPage);
                    
                    link.innerHTML='<strong>&lt;</strong>';link.onclick=function()
                    {
                        return false; 
                    }
                    
                    link.title='Recuar 1 p\341gina';
                    
                    Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                    
                    this.pagesDiv[my_curr].appendChild(link);
                    
                    this.pagesDiv[my_curr].appendChild(document.createTextNode(' '));
                }
                
                
                for(var j=Math.floor(curPage/5)*5+1;
                j<=numPages&&j<=Math.floor(curPage/5)*5+5&&numPages>1;
                
                j++)
                {
                    if(j!=(curPage+1))
                    {
                        var link=document.createElement('A');
                        
                        link.href='#'+j;
                        
                        link.innerHTML='<strong>'+j+'</strong>';
                        
                        link.onclick=function()
                        {
                            return false;
                            
                            
                        }
                        
                        ;
                        
                        Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                        
                        this.pagesDiv[my_curr].appendChild(link);
                        
                        
                    }
                    
                    else
                    {
                        var u=document.createElement('u');
                        
                        var strong=document.createElement('strong');
                        
                        u.appendChild(strong);
                        
                        strong.appendChild(document.createTextNode(j));
                        
                        this.pagesDiv[my_curr].appendChild(u);
                        
                        
                    }
                    
                    
                    if(j!=numPages&&j!=Math.floor(curPage/5)*5+5)
                    {
                        var span=document.createElement('span');
                        
                        span.setAttribute('class','ftgreen');
                        
                        span.appendChild(document.createTextNode(' | '));
                        
                        this.pagesDiv[my_curr].appendChild(span);
                        
                        
                    }
                    
                    
                }
                
                
                if(numPages>5&&Math.floor(curPage/5)*5<numPages-5)
                {
                    var link=document.createElement('A');
                    
                    link.href='#'+(curPage+2);
                    
                    link.innerHTML='<strong>&gt;</strong>';
                    
                    link.onclick=function()
                    {
                        return false;
                        
                        
                    }
                    
                    ;
                    
                    link.title='Avan\347ar 1 p\341gina';
                    
                    Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                    
                    this.pagesDiv[my_curr].appendChild(document.createTextNode(' '));
                    
                    this.pagesDiv[my_curr].appendChild(link);
                    
                    
                }
                
                
                if(curPage<numPages-5)
                {
                    var link=document.createElement('A');
                    
                    link.href='#'+(curPage+6);
                    
                    link.innerHTML='<strong>&gt;&gt;</strong>';
                    
                    link.onclick=function()
                    {
                        return false;
                        
                        
                    }
                    
                    ;
                    
                    link.title='Avan\347ar 5 p\341ginas';
                    
                    Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                    
                    this.pagesDiv[my_curr].appendChild(document.createTextNode(' '));
                    
                    this.pagesDiv[my_curr].appendChild(link);
                    
                    
                }
                
                
                if(Math.floor(curPage/5)*5<numPages-5)
                {
                    var link=document.createElement('A');
                    
                    link.href='#'+numPages;
                    
                    link.innerHTML='<strong>&gt;|</strong>';
                    
                    link.onclick=function()
                    {
                        return false;
                        
                        
                    }
                    
                    ;
                    
                    link.title='Ir para a \372ltima';
                    
                    Event.observe(link,'click',this.goPage.bindAsEventListener(this));
                    
                    this.pagesDiv[my_curr].appendChild(document.createTextNode(' '));
                    
                    this.pagesDiv[my_curr].appendChild(link);
                    
                    
                }
                
                
            }
            
            
        }
        
        
    },
	
	appendElement:function(source)
    {
        this.element.innerHTML+=source; 
    },
	
	clearElement:function()
    {
        var elms=this.element.getElementsByTagName('*');
        
        for(var i=(elms.length-1);
        i>=0;
        
        i--)
        {
            elms[i].parentNode.removeChild(elms[i]);
            
            
        }
        
        
    },
	
	debug:function(txt)
    {},
	
	changeVis: function(elm, vis)
	{
		this.setActiveVis(vis);
		var instance = this;
		$j(this.element).fadeOut(200, function(){
			instance.writeTemplate(instance.currentPage);
		});
		$j(this.element).fadeIn(200);
	},
	
	setActiveVis: function(vis)
	{
		$j('#' + this.id + ' .' + this.options.activeVis + ':first').removeClass('active');	
		this.options.activeVis = vis;
		$j('#' + this.id + ' .' + this.options.activeVis + ':first').addClass('active');	
	},
	
	setItemNumbers: function (vis, lines, columns) 
	{
		if (typeof(vis) == 'string' && typeof(lines) == 'number' && typeof(columns) == 'number') {
			this.options[vis].lines = lines;
			this.options[vis].columns = columns;
			
			this.updateTotal();
			}
	},
	
	updateTotal: function() 
	{
		this.totalPerPage=Number(this.options[this.options.activeVis].lines)*Number(this.options[this.options.activeVis].columns);
		this.options.jump = Number(this.totalPerPage);
	},
	
	close: function()
	{
		if ($j(this.element).is(":hidden")) {
			$j(this.element).slideDown();
			$j('#'+this.id + ':first').removeClass('closed');
			$j('#'+this.id + ':first').addClass('open');
		} 
		else {
		$j(this.element).slideUp();
		$j('#'+this.id + ':first').removeClass('open');
		$j('#'+this.id + ':first').addClass('closed');
		}
	}
};


