/*
	Started on June 6, 2008 with code from

		Jeffrey Jordan Way, a Web Developer from Nashville, TN
			detacheddesigns.com in a post called " Why Aren't You Using jQuery: PART 3"

		http://www.detacheddesigns.com/blog/blogSpecific.aspx?BlogId=62
		http://www.detacheddesigns.com/blog/files/jQueryImageGallery.zip
		http://www.detacheddesigns.com/blog/samples/jQueryImageGallery/gallery.htm

	This revision by David Van Vickle - http://www.davidvanvickle.com

		Added
			Randomness
			Shuffling
			Automatic transitions
		Removed
			Thumbnails

*/

// change these paths for your text
var myText = [
'"You folks are such professionals, and it is a pleasure working with you. You definitely produce the goods." -John Scissons, Consultant, Canadian Automotive Repair and Service, 2009 Labour Market Update Study',
'"It is a true pleasure working on projects with you." -Jodie Bezdzietny, Research and Program Development Analyst, Manitoba Lotteries Corporation',
'"I have enjoyed my interaction with you and your team on this project and I look forward to having the opportunity to work with you and your team on other projects in the future." -Allen Sturko, Industrial Technology Advisor, IRAP West',
'"Your patience, persistence and diligence helped us successfully complete this project and produce a very valuable document." -Christine Da Prat, Vice President, Sectoral Partnership, Association Strategy Group',
'"Thank you for your diligent attention to our survey needs and for quick responses and turn-around times." -Laurel Martin, Research Manager, Manitoba Public Insurance',
'"Thanks again for your diligence in helping us see our industry through this particular lens." -Sam Baardman, Baardman Consulting ',
'"I have rarely worked on a project where the consulting team has provided such collaborative support and problem-solving when the inevitable bumps arose." -Cheryl Paradowski, Executive Director, Canadian Grocery HR Council',
'"As the project manager I felt very reassured in knowing that you and your team of experts always had a solution to any of the challenges encountered and were very flexible in dealing with our requests outside of the proverbial box, of which there seemed to be many." -Patti Galbraith, Project Manager, Canadian Food industry Council',
'"I have been very impressed with the work kisquared accomplished for us on the Biomedical Skills Study.  The information will be extremely useful in building a much needed program and service component based on your findings." -Sophie Gaska, Senior Project Manager, Life Science Association of Manitoba / Economic Innovation and Technology Council',
'"Thanks again for your grace under pressure.  I appreciate your work and the value you have added to this research." -Dave McVetty, Social Science Manager, Parks Canada',
'"I can always count on receiving excellent service and great data from kisquared, and I am never disappointed." -Richard Zieba, Director, Tourism & Parks',
'"Not only was it an excellent report but the whole process to get there was very professional, well done to you and your team." -Graham Moore, Manufacturing Manager, Transcontinental',
'"Katherine, I’ve seen quite a few moderators and you truly are top notch." -Javier Schwersensky, Director of Marketing, Sales and Programs, The Manitoba Museum',
'"Although kisquared set high expectations, they met them with flying colors.  Our entire executive team was ecstatic with the methodology, execution and final presentation." -Clayton B. Cracklen, Vice President, Sales and Marketing, SPECTRA Property Management Software',
'"Personally I wouldn’t, for even a moment, consider using a firm other than kisquared for our future research projects." -Clayton B. Cracklen, Vice President, Sales and Marketing, SPECTRA Property Management Software',
'"You were terrific to work with, and made the process painless.  You did a fantastic job of guiding us through unfamiliar territory." -Cheryl Moore, Communication Services, River East Transcona School Division',
'"We were all impressed with the presentation of the report, its quality and your firm’s responsiveness." -Peter de Graaf, Manager of Community By-law Enforcement Services, City of Winnipeg'
]

// how many times should the photo change per page load
var maxChanges = myText.length * 2;

// shuffle text so each time page loads, the photos show in different order
var do_shuffle = true;

// use simple randomness instead of shuffling (tends to repeat text too often)
var do_randomly = false;

// number of seconds between photo changes
var seconds_between_changes = 6;

// name of DIV to load photos into
var div_name = "footer";


var changes = 0;
var timer;
var thisTxt = myText.length - 1;

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/shuffle [v1.0]

shuffle = function(o){ //v1.0
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

// shuffling is better than random because of less potential repetition
if (do_shuffle) {
	myText = shuffle(myText);	
}

function nextText() {
	
	var low = 0;
	var high = myText.length - 1;
	var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
	
	thisTxt++;
	changes++;
	if (thisTxt==myText.length) {
		thisTxt = 0;
	}
	if (changes==maxChanges) {
		clearInterval(timer);
	}
	if (do_randomly) {
		thisTxt = rand_no;
		return myText[rand_no];
	} else {
		return myText[thisTxt];
	}
}

function changeText() {
	
	var t = myText[thisTxt];
	var n = nextText();
	
	if (t != n) {
		showText(n);
	} else { 
		changeText();
	}
}

// this function does the work of displaying
function showText(txt) {
	$("#footer").text(txt);
}

function checkForLoaded () {
	if (document.getElementById(div_name) != null) {
//		alert("loaded");
		clearInterval(timer);
//		changeText();
//		timer = setInterval(changeText, (seconds_between_photos * 1000));
	}
}

// check every second to see if DIV exists, when it does, start photo changing timer
//timer = setInterval(checkForLoaded, 500);

