var Container = new Class({
	
	left   : 0,
	top    : 0,
	width  : 0,
	height : 0,
	
	initialize: function(args) {
		this.id = args.id;
		this.div = $(this.id);
		if (isSet(args.bgPath)) {
			this.bgPath = args.bgPath;
			aBGs[this.id] = new BG ( { divId : this.id, bgPath : this.bgPath, bgVertSizing : true } );
//			createDivBg (this.id);
		}
	},
	
	resize: function () {
		winCoords = bod.getCoordinates();
		
		this.top = 8; // always at the top of the window
		
		if (winCoords.height>700) { // was 664
			this.height = winCoords.height - 50;
		} else {
			this.height = 650;
		}

		var maxWidthForFixedBorder = 1532;
		var aspectRatio = .7;
		
		if (winCoords.width > maxWidthForFixedBorder) {
			this.width = parseInt(winCoords.width * aspectRatio);
			this.left = parseInt ((winCoords.width - this.width) / 2);
		} else if (winCoords.width > maxWidthForFixedBorder * aspectRatio) {
			this.width = parseInt(winCoords.width - ((winCoords.width-(maxWidthForFixedBorder * aspectRatio))) );
			this.left = parseInt ((winCoords.width - this.width) / 2);
		} else if (winCoords.width > maxWidthForFixedBorder * aspectRatio / 1.25) {
			this.width = winCoords.width;
			this.left = 0;
		} else {
			this.width = parseInt(maxWidthForFixedBorder * aspectRatio / 1.25);
			this.left = 0;
		}
		
		if (isSet(this.bgPath)) aBGs[this.id].resize( { left : this.left, top : this.top, width : this.width, height : this.height });

		var lengthExceptLast = 0;
		for (var i=0; i<aPageNavLayout.length; i++) { lengthExceptLast += aPageNavLinks[aPageNavLayout[i]].width; }
		var spaceBetween = parseInt((container.width - lengthExceptLast) / (aPageNavLayout.length - 1));
//			alert ('spaceBetween is ' + spaceBetween);
		var cursor = 0;
		for (var i=0; i<aPageNavLayout.length; i++) {
			aObjs['pageNavLink'][aPageNavLayout[i]].left = cursor;
			aObjs['pageNavLink'][aPageNavLayout[i]].resize();
			cursor += aPageNavLinks[aPageNavLayout[i]].width + spaceBetween;
		}
			
		aObjs['page'][current['page']].resize();
		
/*		$$('.mainPaneDiv').each(function(item) {	// Resize all main panes
			var w  = container.width - 165 - 2;
			var h = container.height - 157 - 2;
			item.setStyles ( { width : w, height : h } );
		});
*/				
		$$('.postContentDiv, .musicContentDiv').each(function(item) {	// Resize all main panes
			var w = container.width  - 165 - 2 - (contentPad * 2);
			var h = container.height - 157 - 2 - (contentPad * 2);
			item.setStyles ( { left : 0, top : 0, width : w, height : h } );
		});
				
		$('topNav_div').setStyles ( { left : 1, width : this.width - 2 } );
		
//		updatePopup();
	} 
	
});

