﻿//show and hideBox shows and hides boxes and set the cookie
Element.implement({
     hide: function() {
        this.style.display = 'none';
        return this;
    },
    show: function(){
        this.style.display ='';
        return this;
    },
    toggle: function(){
        this.style.display=='none'?this.style.display='':this.style.display='none';
        return this;
    },
    //slides an element in and out, also fixes the height issue bug
    toggleSlide:function(){       
       this.set('slide',{onComplete: (function(){this.removeClass('nemHidden'); this.removeHeight();_nemWidgetPanel.updateCookie();}).bind(this)});
       this.slide('toggle');
    },
    //slides an element out but with no transition (required if you want to slide it back in later)
    toggleNoSlide:function(){
        this.set('slide',{duration: 10});
        this.slide('hide');
    },
    //fixes a bug which sets the wrong height on an element on update
    removeHeight:function(){
        if(this.parentNode.style.height!='0px')
            this.parentNode.style.height='';   
    },
    ajax:function(location){
        var updateRequest = new Request({method:'get',async:true,url:location,onSuccess: (function(txt) {this.set('html', txt);}).bind(this)});
        updateRequest.send("date="+Date());
    },
    //re-initialises any widgets within the element
    //NEW WIDGETS SHOULD BE ADDED TO THIS FUNCTION OR THEY WILL NOT BE INITIALISED
    initWidgets:function(){
        //do nemExpandables
        this.getElements('.nemExpandable').each(
                                function(el,i){
                                    var tempExpandable = new nemExpandable(el);
                                }
                                );
        //do nemTabs
        this.getElements('.nemTabs').each(
                                function(el,i){
                                    var tempTab = new nemTabs(el);
                                }
                                );  
        //do nemRotators
        this.getElements('.nemRotator').each(
                                function(el,i){
                                    var tempRotator = new nemRotator(el);
                                }
                                );
        //do nemScrollboxes   
        this.getElements('.nemScrollbox').each(
                                function(el,i){;
                                    var tempScrollbox = new nemScrollbox(el);
                                }
                                );         
        //do nemTickers 
        this.getElements('.nemTicker').each(
                                function(el,i){;
                                    var tempTicker = new nemTicker(el);
                                }
                                );                                 
    }
});