cAvatar = Class.create();
cAvatar.prototype = {

	initialize: function( Photo ) {
		this.Photo = Photo;
		this.Opacity = 0;
	},
	
	hide: function() {
		clearTimeout( this.ActionTO );
		with( this.style ) {
			opacity = 0.5;
			filter = "alpha(opacity=50)";
		}
		this.doHide();
	},
	
	show: function() {
		clearTimeout( this.ActionTO );
		with( this.style ) {
			opacity = 1;
			filter = "alpha(opacity=100)";
		}
		this.doShow();
	},
	
	doHide: function() {
		this.Opacity -= 5;
		if( this.Opacity < 0 ) this.Opacity = 0;
		if( this.Photo ) {
			with( this.Photo.style ) {
				opacity = this.Opacity / 100;
				filter = "alpha(opacity=" + this.Opacity + ")";
			}
		}
		if( this.Opacity != 0 ) this.ActionTO = setTimeout( "$('" + this.id + "').doHide()", 1 );
	},
	
	doShow: function() {
		this.Opacity += 5;
		if( this.Opacity > 100 ) this.Opacity = 100;
		if( this.Photo ) {
			with( this.Photo.style ) {
				opacity = this.Opacity / 100;
				filter = "alpha(opacity=" + this.Opacity + ")";
			}
		}
		if( this.Opacity != 100 ) this.ActionTO = setTimeout( "$('" + this.id + "').doShow()", 1 );
	},
	
	onmouseover: function() {
		this.parentNode.show( this );
	},
	
	onmouseout: function() {
		this.parentNode.autoShow( this );
	}
	
}

cPhotos = Class.create();
cPhotos.prototype = {

	initialize: function( Photos ) {
		this.aAvatars = this.getElementsByTagName( "img" );
		for( var i = 0; i < this.aAvatars.length; i++ ) {
			behaveAs( this.aAvatars[i], cAvatar, document.getElementById( "photo" + this.aAvatars[i].id.substr( 6 ) ) );
		}
		if( this.aAvatars.length ) this.autoShow( this.aAvatars[0] );
	},
	
	pos: function( Avatar ) {
		for( var i = 0; i < this.aAvatars.length; i++ ) {
			if( this.aAvatars[i] == Avatar ) return i;
		}
	},
	
	next: function( Avatar ) {
		var i = this.pos( Avatar );
		if( i == this.aAvatars.length - 1 ) return this.aAvatars[0];
		return this.aAvatars[i+1];
	},

	autoShow: function( Avatar ) {
		this.show( Avatar );
		this.ActionTO = setTimeout( "$('" + this.id + "').autoShow( $('" + this.next( Avatar ).id + "') )", 4000 );
	},
	
	hide: function( Avatar ) {
		for( var i = 0; i < this.aAvatars.length; i++ ) this.aAvatars[i].hide();
	},
	
	show: function( Avatar ) {
		clearTimeout( this.ActionTO );
		this.doShow( Avatar );
	},
	
	doShow: function( Avatar ) {
		this.hide();
		Avatar.show();
	}
	
}

cContentPhoto = Class.create();
cContentPhoto.prototype = {

	initialize: function( Photos ) {
		var nPhotos = Photos.getElementsByTagName( "img" ).length;

		for( var i = 0, p = this.paragraph( i ); i < nPhotos && p; i++, p = this.paragraph( i ) ) {
			this.insertBefore( Photos.getElementsByTagName( "img" )[0], p );
		}
		
	},
	
	paragraph: function( nPos ) {
		var aPs = this.getElementsByTagName( "p" );
		if( nPos >= aPs.length ) return null;
		if( aPs[nPos].innerHTML == "" ) return this.paragraph( nPos + 1 );
		return aPs[nPos];
	}
	
}
	
