/* Footer */

function initFooter(){
	hideFooter();
	bindFooterMouseover();
	bindFooterMouseout();
}

function bindFooterMouseover(){
	$('div.actions').bind('mouseenter',	function(){ showFooter(); });
}

function bindFooterMouseout(){
	$('div.actions').bind('mouseleave',	function(){	hideFooter(); });
}

function showFooter(){
	pos = $('div.actions').css('bottom'); if(pos != '-95px'){ return; }
	$('div.actions').animate({'bottom':'0px'}, 200, function(){ $('div.actions').css('display','block'); });	
}

function hideFooter(){
	pos = $('div.actions').css('bottom'); if(pos != '0px'){ return;	}
	$('div.actions').animate({'bottom':'-95px'}, 200, function(){ $('div.actions').css('display','block'); });
}


$(document).ready(function(){
	initFooter();
	$('div.actions').fadeIn();
});




















//function initFooter(){
//	hideFooter();
//	bindFooterMouseover();
//	bindFooterMouseout();
//	initCloseTrigger();
//}
//
//function initCloseTrigger(){
//	$('#hide_footer_trigger').bind('mouseover', function(){ setTimeout("hideFooter();", 500); })
//}
//
//function bindFooterMouseover(){
//	$('#footer').bind('mouseenter',
//					function(){
//					   	showFooter();
//					}
//				);
//}
//
//function bindFooterMouseout(){
//	/*$('#footer').bind('mouseleave',
//					function(){
//					   	hideFooter();
//					}
//				);*/
//}
//
//function showFooter(){
//	pos = $('#footer').css('bottom');
//	if(pos != '-47px'){
//		return;
//	}
//	$('#all_usage_label').animate({ 'top':'21px'}, 200, function(){
//																 $('#usage_chart_wrap').animate({ 'right':'1px'}, 200, function(){
//																			$('#indicator_label_wrap').slideDown(200);
//																			$('#footer').animate({'bottom':'0px'}, 200, function(){
//																																 $('#device_display_status').fadeIn(200);
//																																});
//																			$('#device_graphic').animate({'top':'5px'}, 200);
//																			});
//																 });
//	
//	$('#device_display_name').animate({'left':'65px'}, 200, function(){
//																	$('#device_display_name').animate({'top':'15px'}, 200);
//																	});
//	
//	$('#device_display_name').addClass('open');
//	$('#all_usage_indicator').fadeOut();
//}
//
//function hideFooter(){
//	pos = $('#footer').css('bottom');
//	if(pos != '0px'){
//		return;
//	}
//	$('#footer').animate({'bottom':'-47px'}, 200, function(){
//														   	$('#indicator_label_wrap').slideUp(200);
//															$('#usage_chart_wrap').animate({ 'right':'133px'}, 200, function(){
//																															 $('#all_usage_label').animate({ 'top':'1px'}, 200);
//																															 });
//															});
//	$('#device_display_name').animate({'top':'5px'}, 200, function(){
//																   $('#device_display_name').animate({'left':'87px'}, 200);
//																   $('#device_display_status').fadeOut(200);
//																   });
//	$('#device_display_name').removeClass('open');
//	$('#device_graphic').animate({'top':'-13px'}, 200);
//	$('#all_usage_indicator').fadeIn();
//	
//}
//
//function initFooterChart(){
//	$('#footer').css('display', 'block');
//	var chartW = $('#usage_chart').width();
//	$('#footer').css('display', 'none');
//	for(var i=0; i<usage.length; i++){
//		blockW = (usage[i].percentage*chartW)/100;
//		blockW = Math.floor(blockW);
//		usage[i].width = blockW;
//		$('#usage_chart .'+usage[i].name).width(blockW);
//	}
//	
//	var left = 0;
//	var totalWidth = 0;
//	for(var j=0; j<usage.length; j++){
//		$('#usage_chart .'+usage[j].name).css('left', left+'px');
//		if(usage[j].width > 0){	
//			left += usage[j].width;
//			totalWidth += left;
//			left += 2;
//		}
//	}
//	$('#usage_chart .all').css('width', left+'px');
//}
//
//$(document).ready(function(){
//	initFooterChart();
//	$('#footer').fadeIn();
//	showFooter();
//
//	setTimeout("footerPingServer();", 120000); // every two minutes
//});
//
//
//// this function updates the footer usage info every two minutes
//
//function footerPingServer() {
//
//    $.ajax({
//        type: 'post',
//        url: 'settings/system_usage',
//        dataType: "json",
//        success: function(data) {
//
//            originalHtml = $('#all_usage_label').html();            
//
//            temp = originalHtml.split('>');
//            string1 = temp[0] + '>';
//            temp2 = temp[1].split('<');
//            string2 = '<' + temp2[1] + '>' + temp[2] + '>' + temp[3] + '>';
//            temp3 = temp[4].split('<');
//            string3 = '<' + temp3[1] + '>' + temp[5] + '>';
//
//            sizeInTb = data.size / 1024.;
//            sizeInTb = Math.round(sizeInTb * 10) / 10; // round to 1 decimal
//            newHtml = string1 + data.usage + ' ' + string2 + sizeInTb + ' ' + string3;
//
//            
//            $('#all_usage_label').html(newHtml);
//
//            setTimeout("footerPingServer();", 120000);
//            
//        },
//        error: function(request, status, error) {
//            setTimeout("footerPingServer();", 120000);
//        }
//    }); 
//}
