function PortalCategory(name, pageContent, displayType, navCapation) {
	this.name = name;
	this.pageContent = pageContent;
	this.displayType = displayType
	this.navCapation = navCapation;
	this.isInNav     = 0;
	this.index = -1;
}
PortalCategory.prototype.navItem = function (pageFrame) {
	this.isInNav = 1;
	return '<li><a href="' + pageFrame + '?category=' + this.index + '"/>' + this.navCapation + '</a></li>';
}
PortalCategory.prototype.shouldBeInNavigation = function() {
	return (this.navCapation == null || this.navCapation.length == 0) ? 0 : 1;
}
PortalCategory.prototype.isInNavigation = function() {
	return this.isInNav;
}
function PortalContent(portalCategory, navCapation, menuCaption, pageTitle, summaryCaption, summaryImage, summaryContent, pageContent) {
	this.portalCategory  = portalCategory;
	this.navCapation     = navCapation;
	this.menuCaption     = menuCaption;
	this.summaryCaption  = summaryCaption;
	this.summaryImage    = summaryImage;
	this.summaryContent  = summaryContent;
	this.pageTitle       = pageTitle;
	this.pageContent     = pageContent;
	this.index = -1;
}
PortalContent.prototype.navItem = function (pageFrame) {
	return '<li><a href="' + pageFrame + '?content=' + this.index + '"/>' + this.navCapation + '</a></li>';
}
PortalContent.prototype.menuItem = function (pageFrame) {
	return '<li><a href="' + pageFrame + '?content=' + this.index + '"/>' + this.menuCaption + '</a></li>';
}
PortalContent.prototype.pageSummary = function (pageFrame) {
	var pageSummary = '<p><a href="' + pageFrame + '?content=' + this.index + '">';
	if (this.hasSummaryImage())
		pageSummary += '<img src="images/' + this.summaryImage + '" alt="" align="right" border="0">';
	pageSummary += this.summaryCaption + '</a> ' + this.summaryContent;
	return pageSummary;
}
PortalContent.prototype.pageContent = function () {
	return '<h1>' + this.pageTitle + '</h1>' + this.pageContent;
}
PortalContent.prototype.hasSummary = function () {
	return (this.summaryContent == null || this.summaryContent.length == 0) ? 0 : 1;
}
PortalContent.prototype.hasSummaryImage = function () {
	return (this.summaryImage == null || this.summaryImage.length == 0) ? 0 : 1;
}
PortalContent.prototype.hasContent = function () {
	return (this.pageContent == null || this.pageContent.length == 0) ? 0 : 1;
}
function Portal(portalTitle, pageFrame, navigationId) {
	this.portalTitle   = portalTitle;
	this.pageFrame     = pageFrame;
	this.navigationId  = navigationId;
	this.categoryTotal = 0;
	this.categories    = new Array();
	this.contentTotal  = 0;
	this.contents      = new Array();
}
Portal.prototype.addCategory = function (category) {
	this.categories[this.categoryTotal] = category;
	this.categories[this.categoryTotal].index = this.categoryTotal++;
}
Portal.prototype.addContent = function (content) {
	this.contents[this.contentTotal] = content;
	this.contents[this.contentTotal].index = this.contentTotal++;
}
Portal.prototype.getContentId = function (failsafe) {
	return parseInt(this.getUrlParameter('content', failsafe), 10);
}
Portal.prototype.getCategoryId = function (failsafe) {
	return parseInt(this.getUrlParameter('category', failsafe), 10);
}
Portal.prototype.getUrlParameter = function (name, failsafe) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]" + name + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null)
		return "" + failsafe;
	return results[1];
}
Portal.prototype.isPageHome = function () {
	if (location.href.toLowerCase().match('index.html'))
		return 1;
	return 0;
}
Portal.prototype.isPageContent = function () {
	if (location.href.toLowerCase().match(this.pageFrame))
		return 1;
	return 0;
}
Portal.prototype.isPageCategory = function () {
	if (this.isPageContent()) {
		var id = this.getCategoryId(-1);
		if (id >= 0 && id < this.categoryTotal)
			return 1;
	}
	return 0;
}
Portal.prototype.displayNavigation = function () {
	var nav = '<ul>';
	for (var content = 0; content < this.contentTotal; ++content)
		if (this.categories[this.contents[content].portalCategory].shouldBeInNavigation() && !this.categories[this.contents[content].portalCategory].isInNavigation())
			nav += this.categories[this.contents[content].portalCategory].navItem(this.pageFrame);
		else if (this.contents[content].hasContent())
			nav += this.contents[content].navItem(this.pageFrame);
	nav += '</ul><div class="btm-bg"></div>';
	document.getElementById(this.navigationId).innerHTML = nav;
}
Portal.prototype.displayMenu = function () {
	var menu = "";
	for (var category = 0; category < this.categoryTotal; category++)
	{
		menu += '<h4><a href="' + this.pageFrame + '?category=' + category + '" style="color: #000000;">' + this.categories[category].name + '</a></h4><ul>';
		for (var content = 0; content < this.contentTotal; ++content)
			if (this.contents[content].portalCategory == category && this.contents[content].hasContent())
				menu += this.contents[content].menuItem(this.pageFrame);
		menu += "</ul>";
	}
	document.getElementById('menu_portal').innerHTML = menu;
}
Portal.prototype.displayCategoryInfo = function (category) {
	var contents = '<h1>' + this.categories[category].name + '</h1>';
	contents += this.categories[category].pageContent;
	if (this.categories[category].displayType.match('l'))
		contents += '<p><ul style="line-height:200%;">';
	for (var content = 0; content < this.contentTotal; ++content) {
		if (this.contents[content].portalCategory == category) {
			if (this.categories[category].displayType.match('s')) {
				if (this.contents[content].hasSummary())
					contents += this.contents[content].pageSummary(this.pageFrame);
			 } else
				contents += '<li><a href="' + this.pageFrame + '?content=' + content + '">' + this.contents[content].pageTitle + '</a></li>';
		}
	}
	if (this.categories[category].displayType.match('l'))
		contents += '</ul></p>';
	document.getElementById('content_portal').innerHTML = contents;
}
Portal.prototype.displayContentInfo = function(index)
{
	var contents = "";
	if (index >= 0 && index < this.contentTotal) {
		contents += '<h1>' + this.contents[index].pageTitle + '</h1>';
		contents += this.contents[index].pageContent;
	}
	else {
		contents += '<h1>Our ' + this.portalTitle + '</h1>';
		for (var category = 0; category < this.categoryTotal; ++category) {
			contents += '<p><h4><a href="' + this.pageFrame + '?category=' + category + '" style="text-decoration: none;">' + this.categories[category].name + '</a></h4>';
            contents += '<ul style="line-height:200%;">';
			for (var content = 0; content < this.contentTotal; ++content)
				if (this.contents[content].portalCategory == category && this.contents[content].hasContent())
					contents += '<li><a href="' + this.pageFrame + '?content=' + content + '">' + this.contents[content].pageTitle + '</a></li>';
			contents += '</ul></p>';
		}
	}
	document.getElementById('content_portal').innerHTML = contents;
}
Portal.prototype.display = function () {
	if (this.isPageContent()) {
		this.displayMenu();
		if (this.isPageCategory())
			this.displayCategoryInfo(this.getCategoryId(-1));
		else
			this.displayContentInfo(this.getContentId(-1));
	}
	this.displayNavigation();
}
