window.commonLayout = new function() {

	eval(estrada.namespace);
	this.layout = null;
	tilt.attachEvent(document, "layout", function() {
		
		//estrada.layoutView.set(true);
			
		////////////////////////////////////////////
		// create common layout
		////////////////////////////////////////////
		commonLayout.layout = frame("page",
			frame("main-frame",
				frame("header-holder",
					area("top")
				),
				area("heading"),
				frame("upper",
					cols(
						frame("left-center-frame",
							cols(
								area("left"),
								area("center")
							)
						),
						area("right")
					)
				),
				area("lower"),
				frame("footer-holder",
					area("bottom")
				)
			)
		).build(document.body);
	});
}
window.profileInfo = new function() {
	this.intNumberOfProfiles = 0;
	this.intCurrentProfileNumber = 0;
	this.arrProfileImages = [];
	this.arrProfileLinks = [];
	this.arrProfiles = [];
	
	/////////////////////////////////////////////////////////////////////////
	// profile navigation methods
	/////////////////////////////////////////////////////////////////////////
	this.nextProfile = function() {
		profileInfo.adjustProfileNumber(1);
	}
	this.prevProfile = function() {
		profileInfo.adjustProfileNumber(-1);
	}
	this.hideProfiles = function() {
		if (profileInfo.arrProfiles && profileInfo.arrProfiles.length > 0) {
			foreach(map(profileInfo.arrProfiles), function(oProfile) {
				oProfile.style.display="none";
			});
		} else {
			foreach(map(profileInfo.arrProfileImages), function(oProfileImage) {
				oProfileImage.style.display="none";
			});
			foreach(map(profileInfo.arrProfileLinks), function(oProfileLink) {
				oProfileLink.style.display="none";
			});
		}
	}
	this.adjustProfileNumber = function(intAdjustment) {
		profileInfo.hideProfiles();
		switch (intAdjustment) {
			case 0:
				profileInfo.intCurrentProfileNumber = 0;
				break;
			case -1:
				if (--profileInfo.intCurrentProfileNumber < 0) {
					profileInfo.intCurrentProfileNumber =
						profileInfo.intNumberOfProfiles - 1;
				}
				break;
			case 1:
				if (++profileInfo.intCurrentProfileNumber >=
						profileInfo.intNumberOfProfiles) {
					profileInfo.intCurrentProfileNumber = 0;
				}
				break;
			default:
				profileInfo.intCurrentProfileNumber =
					profileInfo.intNumberOfProfiles - 1;
				break;
		}
		profileInfo.showProfile(
			profileInfo.intCurrentProfileNumber);
	}
	this.showProfile = function(intProfileNumber) {
		if (profileInfo.arrProfiles && profileInfo.arrProfiles.length > 0) {
			var oProfile = profileInfo.arrProfiles[intProfileNumber];
			if (oProfile) {
				oProfile.style.display = "block";
			}
		} else {	
			if (profileInfo.arrProfileImages && profileInfo.arrProfileImages.length > 0) {
				var oProfileImage = profileInfo.arrProfileImages[intProfileNumber];
				if (oProfileImage) {
					oProfileImage.style.display = "block";
				}
			}
			if (profileInfo.arrProfileLinks && profileInfo.arrProfileLinks.length > 0) {
				var oProfileLink = profileInfo.arrProfileLinks[intProfileNumber];
				if (oProfileLink) {
					oProfileLink.style.display = "block";
				}
			}
		}
	}
}

