var currentPhoto = 0;
var startFade = 1;
var FADE_STEP = 2;
var FADE_INTERVAL = 50;
var MAX_OPACITY = 500;
var MIN_OPACITY = 2;
var currentOpacity = MAX_OPACITY;

var imageArray = new Array();
imageArray[0] = "\"How truly beautiful is a well-groomed young woman who is clean in body and mind. She is a daughter of God in whom her Eternal Father can take pride. How handsome is a young man who is well groomed. He is a son of God worthy of holding the priesthood of God\"<br><br><font size='2' style='float:right;padding-right:3em'>President Gordon B. Hinckley</font>";
imageArray[1] = "\"Modesty is an attitude of humility and decency in dress, grooming, language, and behavior. If you are modest, you do not draw undue attention to yourself.  Instead, you seek to glorify God in your body, and in your spirit\"<br><br><font size='2' style='float:right;padding-right:5em'>True to the Faith</font>";
imageArray[2] = "\"I do not hesitate to say that you can be attractive without being immodest. You can be refreshing and buoyant and beautiful in your dress and behavior. Your appeal to others will come of your personality, which is the sum of your individual characteristics\"<br><br><font size='2' style='float:right;padding-right:3em'>President Gordon B. Hinckley</font>";
imageArray[3] = "\"Young men, be clean in dress and manner. I do not expect you to look like missionaries all of the time, [however] the age in which we are living now has become an age of sloppy dress and sloppy manner\"<br><br><font size='2' style='float:right;padding-right:3em'>President Gordon B. Hinckley</font>";
imageArray[4] = "\"Young women, choose your clothing the way you would choose your friends - in both cases choose that which improves you and would give you confidence standing in the presence of God. Good friends would never embarrass you, demean you, or exploit you. Neither should your clothing\"<br><br><font size='2' style='float:right;padding-right:3em'>Elder Jeffrey R. Holland</font>";
imageArray[5] = "\"The way you dress is a reflection of what you are on the inside. Your dress and grooming send messages about you to others and influence the way you and others act\"<br><br><font size='2' style='float:right;padding-right:3em'>For the Strength of Youth</font>";
imageArray[6] = "\"Your body is God&acute;s sacred creation. Respect it as a gift from God, and do not defile it in any way. Through your dress and appearance, you can show the Lord that you know how precious your body is. You can show that you are a disciple of Jesus Christ\"<br><br><font size='2' style='float:right;padding-right:3em'>For the Strength of Youth</font>";
imageArray[7] = "\"We can create a style of our own. We must be different. We need not do anything we do not wish to do. We can create our own style and standards. We can influence the patterns among our own people, and we can also help to develop proper community patterns.\"<br><br><font size='2' style='float:right;padding-right:3em'>President Spencer W. Kimball</font>";

function fadeInit() {
	mHTML="";
	mHTML+="<div style=\"padding: 0 2.5em; text-align:left; font-size:1.6em; font-family: Georgia, 'Times New Roman', Times, serif; color:#3b4872\" id=\"photo\" name=\"photo\">" + imageArray[currentPhoto]  +"</div>";
	document.getElementById("codeContainer").innerHTML = mHTML;    
	mInterval = setInterval("crossFade()",FADE_INTERVAL);
}
function crossFade() {
	var loadPicture = 0;
		
	if(startFade == 1) {		
		currentOpacity-=FADE_STEP;	
		if(document.all){
			document.getElementById("codeContainer").style.filter = "alpha(opacity=" + currentOpacity + ")";
		}else{
			document.getElementById("codeContainer").style.MozOpacity = currentOpacity/101;
		}
		//document.getElementById("codeContainer").style.KhtmlOpacity = currentOpacity/100;
		//document.getElementById("codeContainer").style.opacity = currentOpacity/100;
				
		if(currentOpacity <= MIN_OPACITY){
			startFade = 0;
			loadPicture = 1;		
		}
	}
	 
	if(loadPicture == 1){
		loadPicture = 0;
		
		if(currentPhoto<imageArray.length - 1){currentPhoto++;}
		else {currentPhoto=0;}		
		
		mHTML="";
		mHTML+="<div style=\"padding: 0 2.5em; text-align:left; font-size:1.6em;font-family: Georgia, 'Times New Roman', Times, serif; color:#3b4872\" id=\"photo\" name=\"photo\">" + imageArray[currentPhoto]  +"</div>";
		document.getElementById("codeContainer").innerHTML = mHTML;
				
	}
	
	if(startFade == 0){
		currentOpacity+=FADE_STEP;		
		if(document.all){
			document.getElementById("codeContainer").style.filter = "alpha(opacity=" + currentOpacity + ")";
		}else{
			document.getElementById("codeContainer").style.MozOpacity = currentOpacity/101;
		}
		
		if(currentOpacity >= MAX_OPACITY){
			startFade = 1;
			loadPicture = 1;			
		}
	}

}
