var PortfolioCollectionView = new Class({
	
	
	initialize : function(docElement) {
	
		if (!docElement) return;
	
		trace('PortfolioCollectionView.initialize(' + docElement +  '{ id=' + docElement.getProperty('id') + ' })');
		
		this.docElement = docElement;
		this.collection = docElement.getChildren();
				
		this.itemViews = [];
		this.currentIndex = -1;
		
		this.createChildren();
	},
	
	
	createChildren : function() {
		
		// hide child elements...
		var i = 0;
		var len = this.collection.length;
		for (; i < len; ++i) this.collection[i].setStyle('visibility', 'hidden');
		
		// initialize one child at a time for performance...
		this.createChild();
	},
	
	
	createChild : function() {
	
		trace('PortfolioCollectionView.createChild()');
		
		this.currentIndex++;
		
		if (this.currentIndex == this.collection.length) { 
		
			this.createChildrenComplete();
		
		} else {
		
			var itemElement = this.collection[this.currentIndex];
			itemElement.addEvent('onCreateComplete', this.createChildComplete.bindWithEvent(this));
		
			var item = new PortfolioItemView(itemElement);
			this.itemViews.push(item);

		}
	},
	
	
	createChildComplete : function() {
	
		trace('PortfolioCollectionView.createChildComplete()');
		
		this.createChild.delay(100, this);
	},
	
	
	createChildrenComplete : function() {
		
	},
		
	
	toString : function() {
		return "[PortfolioCollectionView]";
	}
	
});
