// JScript File
function toggleSectionCollapse(section,targetState)
{
    if (section=='school')
    {
        if (targetState=='expand')
        {
            if ($('#SSPrev') != null) $('#SSPrev').hide();
            if ($('#SSFull') != null) $('#SSFull').show();
        }
        else
        {
            if ($('#SSFull') != null) $('#SSFull').hide();
            if ($('#SSPrev') != null) $('#SSPrev').show();
        }
        
        var moreLink = $('#schoolSaysMore');
        var lessLink = $('#schoolSaysLess');
    }
    else if (section=='student')
    {
        if (targetState=='expand')
        {
            if ($('#StudentsSPrev') != null) $('#StudentsSPrev').hide();
            if ($('#StudentsSFull') != null) $('#StudentsSFull').show();
        }
        else
        {
            if ($('#StudentsSFull') != null) $('#StudentsSFull').hide();
            if ($('#StudentsSPrev') != null) $('#StudentsSPrev').show();
        }
        
        var moreLink = $('#studentsSayMore');
        var lessLink = $('#studentsSayLess');
    }
    else if (section=='major')
    {
        if (targetState=='expand')
        {
            if ($('#majorPrev') != null) $('#majorPrev').hide();
            if ($('#majorFull') != null) $('#majorFull').show();
        }
        else
        {
            if ($('#majorFull') != null) $('#majorFull').hide();
            if ($('#majorPrev') != null) $('#majorPrev').show();
        }
        
        var moreLink = $('#majorMore');
        var lessLink = $('#majorLess');
    }
    
    else { return; }

    if (targetState=='expand')
    {
        if (moreLink!=null) moreLink.addClass('hidden');
        if (lessLink!=null) lessLink.removeClass('hidden');
    }
    else
    {
        if (moreLink!=null) moreLink.removeClass('hidden');
        if (lessLink!=null) lessLink.addClass('hidden');
    }
}
function toggleDataSection(tblID,state)
{
    var t = document.getElementById(tblID+'Tbl');
    
    if (t!=null)
    {
        for(var iCurrentRow = 3; iCurrentRow < t.rows.length; iCurrentRow++)
        {
		    var row = t.rows[iCurrentRow];
    		
		    if (state=='expand')
		    {
		        $(row).removeClass('hidden');
		    }
		    else if (state=='collapse')
		    {
		        $(row).addClass('hidden');
		    }
		    else
		    {
		        alert('nay');
		    }
        }
    
        var exp = $('#'+tblID+'Exp');
        var col = $('#'+tblID+'Col');
        
        if (exp!=null && col!=null)
        {
            if (t.rows.length<=3)
            {
                exp.addClass('hidden');
                col.addClass('hidden');
                return;
            }
            
            if (state=='expand')
            {
                exp.addClass('hidden');
                col.removeClass('hidden');
            }
            else
            {
                col.addClass('hidden');
                exp.removeClass('hidden');
            }
        }
    }
}
function OpenWindow(url, title)
{
    title = title.replace(' ', '_');
    window.open(url,title);
}

var SchoolPhotoShow = 
{
    Next: function()
    {
        var oldIndex = parseInt(document.getElementById('currPhoto').value);
        var maxIndex = parseInt(document.getElementById('maxPhoto').value);
        var newIndex = ((oldIndex==maxIndex)? 0 : oldIndex+1);
        this.Advance(oldIndex,newIndex);
    },
    
    Prev: function()
    {
        var oldIndex = parseInt(document.getElementById('currPhoto').value);
        var maxIndex = parseInt(document.getElementById('maxPhoto').value);
        var newIndex = ((oldIndex==0)? maxIndex : oldIndex-1);
        this.Advance(oldIndex,newIndex);
    },
    
    JumpTo: function(newIndex)
    {
        var oldIndex = parseInt(document.getElementById('currPhoto').value);
        var maxIndex = parseInt(document.getElementById('maxPhoto').value);
        SchoolPhotoShow.SlideShow.Enabled = false; 
        
        if ( !(newIndex>=0 && newIndex<=maxIndex) )
        {
            return;
        }
        else
        {
            this.Advance(oldIndex,newIndex);
        }
    },
    
    Advance: function(oldIndex,newIndex) 
    {
        this.UpdateNav(oldIndex,newIndex);
        this.UpdatePhoto(oldIndex,newIndex);
    },
    
    UpdateNav: function(oldIndex,newIndex)
    {
        var currPhotoText = document.getElementById('currPhotoDisp');
        currPhotoText.innerHTML = (newIndex+1) + ' ';
        this.Thumbs.UpdateSelection(oldIndex,newIndex);
    },
    
    UpdatePhoto: function(oldIndex,newIndex)
    {
        var maxIndex = parseInt(document.getElementById('maxPhoto').value);
        
        if ( !(newIndex>=0 && newIndex<=maxIndex) )
        {
            return; 
        }
        else
        {
            document.getElementById('currPhoto').value = newIndex;
            $('#schoolPhoto'+oldIndex).fadeOut(200, function() {$('#schoolPhoto'+newIndex).fadeIn(300);} );
        }
    },
    
    Init: function() {
       if(document.getElementById('currPhoto') != null)
        {
            document.getElementById('currPhoto').value=0;
            this.SlideShow.Start();
        }
    }, 
    
    Thumbs: 
    {
        ThumbWidth: 52, 
        
        VisibleThumbCount: 4,
        
        UpdateSelection: function(oldIndex,newIndex)
        {
            $('#thumb_'+oldIndex).removeClass('selected');
            $('#thumb_'+newIndex).addClass('selected');
        },

        ScrollThumbs: function(direction, scrollingContainerId) 
        {
            var thumbScroller = $('#'+scrollingContainerId)[0];
            if (thumbScroller!=null)
            {
                var start = thumbScroller.scrollLeft;
                var end = (direction=='right')? start+(this.ThumbWidth*this.VisibleThumbCount): start-((this.ThumbWidth*this.VisibleThumbCount));
	            this.ScrollStart(thumbScroller, start, end);
	        }
	    },
    	
	    _scrollControl: 
	    {
	        time:0, begin:0, change:0.0, duration:0.0, element:null, timer:null
	    },
    	
	    ScrollStart: function(elem, start, end)
        {
	        if (this._scrollControl.timer != null) 
	        {
		        clearInterval(this._scrollControl.timer);
		        this._scrollControl.timer = null;
	        }
	        
	        this._scrollControl.time = 0;
	        this._scrollControl.begin = start;
	        this._scrollControl.change = end - start;
	        this._scrollControl.duration = 15;
	        this._scrollControl.element = elem;
	        this._scrollControl.timer = setInterval("SchoolPhotoShow.Thumbs.ScrollAnim();", 15);
        },
        
        CalcMove: function(time, begin, change, duration)
        {
            return -change/2 * (Math.cos(Math.PI*time/duration) - 1) + begin;
        },
        
        ScrollAnim: function()
        {
	        if (this._scrollControl.time > this._scrollControl.duration) 
	        {
		        clearInterval(this._scrollControl.timer);
		        this._scrollControl.timer = null;
	        }
	        else 
	        {
		        move = this.CalcMove(this._scrollControl.time, this._scrollControl.begin, this._scrollControl.change, this._scrollControl.duration);
		        this._scrollControl.element.scrollLeft = move;
		        this._scrollControl.time++;
	        }
        }
    },
    
    SlideShow: 
    {
        Delay: 7500, 
        
        IntervalID1:0,
        
        Enabled: false,
        
        Start: function()
        {
            SchoolPhotoShow.SlideShow.Enabled = true;
            SchoolPhotoShow.SlideShow.IntervalID1 = setTimeout(SchoolPhotoShow.SlideShow.TimedAutoAdvanceClosure(), SchoolPhotoShow.SlideShow.Delay);
        },
        
        TimedAutoAdvanceClosure: function()
        {
            return function()
            {
                setTimeout("SchoolPhotoShow.SlideShow.AutoAdvance();", 0);
                if (SchoolPhotoShow.SlideShow.Enabled)
                    SchoolPhotoShow.SlideShow.IntervalID1 = setTimeout(SchoolPhotoShow.SlideShow.TimedAutoAdvanceClosure(), SchoolPhotoShow.SlideShow.Delay);
            };
        }, 
        
        AutoAdvance: function()
        {
            if (this.Enabled) SchoolPhotoShow.Next();
        },
        
        Stop: function()
        {
            clearInterval(SchoolPhotoShow.SlideShow.IntervalID1);
            SchoolPhotoShow.SlideShow.Enabled = false;
        }
    }
};








