Ext.onReady(function() {
	Ext.get('left_nav_menu').select('li a.lDropList').on('click', showHideNav);
});

// show/hide left nav
function showHideNav() {

    var navEl = Ext.get(this);

	navEl_Parent = navEl.parent('li');

//    if (navEl_Parent.down('ul')) {

//	    var nav = navEl_Parent.select('ul:first');

		var nav = navEl_Parent.down('ul');

	    nav.setVisibilityMode(Ext.Element.DISPLAY);

	    var navId = nav.id;
	    var checkClass = Ext.fly(navId).hasClass('hidden');

	    if (checkClass) {
	        nav.removeClass('hidden');
	        nav.slideIn('t', { easing: 'easeIn', duration: .5 });
	       navEl.toggleClass('selected');
	    } else {
	
			// slide out and add the hidden class afterwards to reset
	        nav.slideOut('t', { 
	        	easing: 'easeOut',
	        	duration: .5,
	        	concurrent: false,
	        	afterCls: 'hidden'
	        });
	       
	       navEl.toggleClass('selected'); 
	    }
//	}
}

function init_NewsStories() {
	var heightArray = new Array();
    var stories = Ext.select('div.news_story').each(function() {
    
    //	heightArray[Ext.fly(this).getAttribute('id')] = Ext.fly(this).getHeight();
    
    //	alert(Ext.get(this).id + ':' + Ext.fly(this).getHeight());
    	heightArray[Ext.get(this).id] = Ext.fly(this).getHeight();
    });
    
    Ext.select('div.news_story').setStyle('height', '200px');
    
    Ext.select('div.full_story').on('click', function() {
    	
    	var thisLink = Ext.get(this);
    	var linkSID = thisLink.getAttribute('sid');
    	
    	var thisFull = Ext.fly(linkSID);
    	var height = thisFull.getStyle('height');
    	            	
    	if (height == '200px') {
    		thisFull.animate({
				height: {to: heightArray[linkSID], from: thisFull.getHeight()}
		});

			thisLink.update('click to close');
			thisLink.setStyle('background-image', 'url(/images/arrow_up.png)');

    	//	thisCloser.setStyle('height', 'auto');
    	} else {
     		thisFull.animate({
				height: {to: '200', from: thisFull.getHeight()}
			});
     	
     	//	thisCloser.setStyle('height', '200px');
     		thisLink.update('click to view complete story');
     		thisLink.setStyle('background-image', 'url(/images/arrow_down.png)');
		}
    	
    });
}

