Ext.onReady(function() {
extend = ['shareText','widgetsTop'];
	footerType="small";
	footerBusy = false;
	lastMessageID=0;
	Ext.fly("messages_down").on('click', function(ev) {
		boxScroll('messageBox','down',80);
	});
	
	Ext.fly("messages_up").on('click', function(ev) {
		boxScroll('messageBox','up',80);
	});
	
	Ext.fly("shareText").on('click', function(ev) {
		divExtend('widgetsTop','width',7, 197,0.80);
		divExtend('shareText','width',230, 40,0.80);
	});
	
	Ext.fly("profilesTopbar").on('click', function(ev) {
		if(resizebleFooter) 
		{
			resizeFooter(.8,166);
		}
	});
	
	resizeFooter = function(d, ch)
	{
		if(!footerBusy)
		{
			footerBusy = true;
			ele = Ext.fly('whiteFooter');
			sizes = getPageSize();
			
			if(footerState=='expanded')
			{
					ct= 0 + ch;
					ch= 0 - ch;
					
					mb= -120;
					footerState = 'collapsed';
					
					nhf=sizes[1]-60;
					Ext.fly('btnRSS').hide();
					Ext.fly('btnFan').hide();
					Ext.fly('btnActies').show();

					document['minus_icon'].src="/images/layout/ICON_greenplus.png";
			}else {
					ct= 0 - ch;
					ch= 0 + ch;
					mb= 120;
					footerState = 'expanded';
					
					nhf=sizes[1]-226;
					Ext.fly('btnRSS').show();
					Ext.fly('btnFan').show();
					Ext.fly('btnActies').hide();

					document['minus_icon'].src="/images/layout/ICON_minus.png";
			}
			
			ele.animate({
		    	height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
			

			Ext.fly('SmallBottomFooter').animate({
				height: {by: ch, unit:'px'}
		    },d, function(){footerBusy = false;}, 'easeOut', 'run');
			
			Ext.fly('whiteFooter').animate({
				height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
			
			Ext.fly('youtubeBox').animate({
				height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
			
			
			Ext.fly('centerWidgets').animate({
				height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
			
			Ext.fly('widgetsMiddle').animate({
				height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
			
			Ext.fly('messageBox').animate({
				height: {by: mb, unit:'px'}
		    },d, null, 'easeOut', 'run');
			
			Ext.fly('messagesMiddle').animate({
				height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
			
			Ext.fly('boxScrollbar').animate({
				height: {by: ch, unit:'px'}
		    },d, null, 'easeOut', 'run');
		}
	}
	

	
//	openItem = function () {
//		sizes = getPageSize();
//		nh=sizes[3]-53-60;
//		
//		
//		resizeFooter(.8,160);
//		resizeSlider(.8,nh);
//		//fillSlider();
//		//fillFlash();
//	}
	
	openItem = function () {
		sizes = getPageSize();
		nh=sizes[3]-53-60;
		
		//resizeFooter(.8,160);
		//resizeSlider(.8,nh);
		//fillSlider(60);
//		moveFooter();
//		fillFlash();
	}
		
	message_fetcher = function() {
		Ext.Ajax.request({
			  url: linkprefix + 'XML/messages.php',
			  success: parseMessages,
			  params:{lastID:lastMessageID}
		});
	}
	
	profiles_fetcher = function() {
		Ext.Ajax.request({
			   url: linkprefix + 'XML/profiles.php',
			   success: parseProfiles,
			   params:{end:'8'}
			});
	}

	onResize = function()
	{
		if(risizeState[resizeId] == true)
		{
			resizeId = resizeId+1;
			risizeState[resizeId] = false;
			
			setTimeout ( "fillSlider(60)",20);
			setTimeout ( "moveFooter()",20);
			setTimeout ( "fillFlash()",30);
			
			setTimeout ( "risizeState[resizeId] = true;window.onresize = null;window.onresize = onResize;",70 );
		}	
	}

	
	message_fetcher();
	profiles_fetcher();
	window.onresize =onResize;
});