function initPortfolio(uid){
	if(isFacebook){		
		loadHeader();
		$('#body_section').removeClass("span-12");
		$('#body_section').addClass("span-20");
	}else{
		$('#body_section').addClass("span-18");
		loadSidebar();
	}
	loadLastTrades(1, uid);
}

function removeOrder(order_id) {
	$.ajax({
		type : 'POST',
		data : 'order_id=' + order_id,
		url : baseAppUrl + '/portfolio/removeOrder',
		dataType: 'html',
		success : function(data, textStatus) {
			jQuery('#portfolioContainer').html(data);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

function loadSidebar() {
	$.ajax({
		type : 'POST',
		url : baseAppUrl + '/sidebar/portfolioSidebar',
		dataType: 'html',
		success : function(data, textStatus) {
			jQuery('#sidebarContainer').html(data);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

function loadLastTrades(page, uid){
	$.ajax({
		type : 'POST',
		url : baseAppUrl + '/portfolio/getLastTrades?userId='+uid,
		data : 'page=' + page,
		dataType: 'html',
		success : function(data, textStatus) {
			$('#lastTradesContainer').html(data);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

function loadHeader() {
	$.ajax({
		type : 'POST',
		url : baseAppUrl + '/sidebar/portfolioHeader',
		dataType: 'html',
		success : function(data, textStatus) {
			jQuery('#portfolioHeader').html(data);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

