if(typeof(PX) == "undefined") { PX={}; }
PX.channelList = {

    // the current page
    p: 0,

    // number of pages
    np: 0,

    // height of slider area
    h: 294,

    // height of a single channel
    c: 75,

    // prepare for use
    init: function(id) {

		this.id = id;
		// calculate number of 'pages'
		this.nc = $("#"+id+" li").size() -1;
        this.np = Math.ceil( ((this.c * this.nc)  / this.h) )-1;
        this.cpp = Math.floor( this.h / this.c );

		if(this.np < 1 ) {
			return;
		}

        // navigation buttons
        this.setPageNav();
    },

    // animate one page up or down
    animate:function(dir){

        // requested page
        r = this.p + dir;

        // prevent out of range
        if(r < 0 || r > this.np) {
            return;
        }

        // confirm next page
        this.p = r;

        // animate element to new position
        $("#"+this.id).animate( {top:(this.p * this.h) * -1+"px"}, 1000, 'swing' );

        this.setPageNav();
    },


    // set appropriate state for page navigation buttons
    setPageNav: function() {

        // next page button
        if(this.np == 0 || this.p == this.np) {
            $("#video-np").removeClass("video-activenav");
        } else {
            $("#video-np").addClass("video-activenav");
        }

        // previous page button
        if(this.np == 0 || this.p == 0) {
            $("#video-pp").removeClass("video-activenav");
        } else {
            $("#video-pp").addClass("video-activenav");
        }
    }

};