function PageContent(src, content) {
	this.src = src;
	this.content = content;
}

function Site(containerDiv) {
	this.containerDiv = containerDiv; //$("div#main_container");
	this.pages = new Array();
	this.currentPage = null;
}

Site.prototype.getPage = function(src) {
	for (i = 0; i < this.pages.length; i++) {
		if (this.pages[i].src == src)
			return this.pages[i];
	}
	return null;
}

Site.prototype.addPage = function(src) {
	var site = this;
	$.get(src, function(response) {
		site.containerDiv.append(response);
		var contentDiv = site.containerDiv.children("div:last");
		contentDiv.hide();
		var page = new PageContent(src, contentDiv[0]);
		site.pages.push(page);
		site.refreshContent(page);
		});
}

Site.prototype.loadContent = function(src) {
	if (this.currentPage != null && this.currentPage.src == src)
		return;
	var page = this.getPage(src);
	if (page == null) {
		this.addPage(src);
		return;
	}
	this.refreshContent(page);
}

Site.prototype.refreshContent = function(page) {
	this.hideContent();
	this.currentPage = page;
	this.showContent();
}

Site.prototype.showContent = function() {
	if (this.currentPage != null) {
		$(this.currentPage.content).fadeIn();
	}
}

Site.prototype.hideContent = function() {
	if (this.currentPage != null) {
		$(this.currentPage.content).fadeOut();
	}
}

function showPicture(url) {
	$.facebox({image: url});
}

