function AddPhoto( url ) {
	var HomePhotos = document.getElementById( "HomePhotos" );

	if( !HomePhotos.aURLS ) {
		HomePhotos.aURLS = new Array();
		HomePhotos.Index = 0;
	}
	
	HomePhotos.aURLS.push( url );
}

function AppendPhoto( Opacity ) {
	var HomePhotos = document.getElementById( "HomePhotos" );

	var img = document.createElement( "img" );
	img.Opacity = Opacity;
	with( img ) {
		src = HomePhotos.aURLS[HomePhotos.Index];
		width = HomePhotos.clientWidth;
		height = HomePhotos.clientHeight;
		with( style ) {
			opacity = Opacity;
			filter = "alpha(opacity='" + ( Opacity * 100 ) + "')";
			padding = 0;
			border = 0;
			margin = 0;
			position = "absolute";
		}
	}
	HomePhotos.appendChild( img );
}

function ShowPhotos() {
	var HomePhotos = document.getElementById( "HomePhotos" );

	if( !HomePhotos.aURLS ) return;
	if( HomePhotos.aURLS.length == 0 ) return;
	
	AppendPhoto( 1 );
	NextPhoto();
}

function NextPhoto() {
	var HomePhotos = document.getElementById( "HomePhotos" );

	HomePhotos.Index++;
	if( HomePhotos.Index >= HomePhotos.aURLS.length ) HomePhotos.Index = 0;
	
	AppendPhoto( 0 );
	setTimeout( "ChangeHomePhotos()", 5000 );	
}

function ChangeHomePhotos() {
	var HomePhotos = document.getElementById( "HomePhotos" );

	if( !HomePhotos.firstChild.nextSibling.complete ) {
		setTimeout( "ChangeHomePhotos()", 10 );
		return;
	}

	HomePhotos.firstChild.Opacity -= 0.03;
	if( HomePhotos.firstChild.Opacity >= 0 ) {
		with( HomePhotos.firstChild.style ) {
			opacity = HomePhotos.firstChild.Opacity;
			filter = "alpha(opacity='" + ( HomePhotos.firstChild.Opacity * 100 ) + "')";
		}
	}

	HomePhotos.firstChild.nextSibling.Opacity += 0.03;
	if( HomePhotos.firstChild.nextSibling.Opacity <= 1 ) {
		with( HomePhotos.firstChild.nextSibling.style ) {
			opacity = HomePhotos.firstChild.nextSibling.Opacity;
			filter = "alpha(opacity='" + ( HomePhotos.firstChild.nextSibling.Opacity * 100 ) + "')";
		}
	}
	
	if( HomePhotos.firstChild.Opacity > -1 ) {
		setTimeout( "ChangeHomePhotos()", 10 );
		return;
	}
	
	HomePhotos.firstChild.nextSibling.Opacity = 1;
	HomePhotos.removeChild( HomePhotos.firstChild );
	NextPhoto();
}

