/* onLoad event function handler. Simon Willison. http://simon.incutio.com/archive/2004/05/26/addLoadEvent */

//RANDOM QUOTES
var random_quote_type = new Array();
var random_quote_content = new Array();

//QUOTE TYPES
// 1 -> OUR TEAM
// 2 -> OUR APPROACH
// 3 -> REAL IMPACT
// 4 -> WORDS OF SUPPORT

random_quote_type[0] = 1;
random_quote_content[0] = "<p>Our business advisors and volunteer consultants leverage the strengths of our partners and other team members to offer world-class business advice to entrepreneurs in the developing world.</p><p><a href=\"/who_we_are/our_team/default.aspx\">Meet Our Team &raquo;</a></p>";


random_quote_type[1] = 4;
random_quote_content[1] = "<blockquote><p><p>\"Tanzania has many people with entrepreneurial spirit whose dreams can be turned into reality with the kind of support to be provided by Google and TechnoServe.\"</p></p></blockquote><p class=\"attribution\"><strong>H.E. JAKAYA KIKWETE</strong><br />President of Tanzania</p>";

random_quote_type[2] = 4;
random_quote_content[2] = "<blockquote><p><p>\"TechnoServe continues to be an industry leader and innovator when it comes to producing scalable models that offer greater business opportunities for African entrepreneurs.\"</p></p></blockquote><p class=\"attribution\"><strong>ARMANDO GUEBUZA</strong><br />President of Mozambique, 2005</p>";

random_quote_type[3] = 2;
random_quote_content[3] = "<p>TechnoServe makes a commitment to businesses and industries, working in the field with entrepreneurs and other industry stakeholders to build enterprises able to thrive on their own and generate continuing benefits for the rural poor.</p><p><a href=\"/who_we_are/ourapproach.aspx\">Learn More About Our Approach &raquo;</a></p>";

random_quote_type[4] = 4;
random_quote_content[4] = "<blockquote><p><p>\"They are a thoughtful organization that is fighting poverty with a very effective market-based, business-oriented methodology. The sustainability of TechnoServe's work is evident in the communities where they have worked and the lives of the people they have benefited.\"</p></p></blockquote><p class=\"attribution\"><strong>PAUL APPLEGARTH</strong><br />Fellow of the German Marshall Fund and former CEO of the Millennium Challenge Corporation</p>";

random_quote_type[5] = 4;
random_quote_content[5] = "<blockquote><p><p>\"What struck me &#151; once more &#151; was the pragmatic approach to development that TechnoServe is using across its programs &#151; rather than taking the easy path of merely disbursing aid.\"</p></p></blockquote><p class=\"attribution\"><strong>A. SHEKHAR</strong><br />Senior Managing Director, Olam International Limited</p>";

random_quote_type[6] = 3;
random_quote_content[6] = "<p>TechnoServe has helped more than 2,000 businesses, transforming the lives of millions of people in more than 30 countries.</p>";

random_quote_type[7] = 4;
random_quote_content[7] = "<blockquote><p><p>\"They are a thoughtful organization that is fighting poverty with a very effective market-based, business-oriented methodology. The sustainability of TechnoServe's work is evident in the communities where they have worked and the lives of the people they have benefited.\"</p></p></blockquote><p class=\"attribution\"><strong>PAUL APPLEGARTH</strong><br />Fellow of the German Marshall Fund and former CEO of the Millennium Challenge Corporation</p>";

random_quote_type[8] = 4;
random_quote_content[8] = "<blockquote><p><p>\"What struck me &#151; once more &#151; was the pragmatic approach to development that TechnoServe is using across its programs &#151; rather than taking the easy path of merely disbursing aid.\"</p></p></blockquote><p class=\"attribution\"><strong>A. SHEKHAR</strong><br />Senior Managing Director, Olam International Limited</p>";

random_quote_type[9] = 4;
random_quote_content[9] = "<blockquote><p><p>\"To me TechnoServe has always been distinguished by its long-term commitment to building cooperatives and businesses from the bottom up in a way that makes sense for the individuals.\"</p></p></blockquote><p class=\"attribution\"><strong>PATRICIA M. CLOHERTY</strong><br />Chairman and CEO, Delta Private Equity Partners</p>";


//ROTATOR
var rotator_iter = 0;
var rotator_array = new Array();
rotator_array[0] = "1.jpg";
rotator_array[1] = "2.jpg";
rotator_array[2] = "3.jpg";
rotator_array[3] = "4.jpg";
rotator_array[4] = "5.jpg";


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function searchroll() {
	if (document.getElementById("SearchBox_submitsearch") != null) {	
		var button = document.getElementById("SearchBox_submitsearch");
		button.onmouseover = function() {
			this.src = "/images/global/search-go-on.gif";
		}
		button.onmouseout = function() {
			this.src = "/images/global/search-go.gif";
		}
		
		button.onclick = function() {
			if (document.getElementById("SearchBox_searchQuery") != null) {
				var field = document.getElementById("SearchBox_searchQuery");
				if (field.value == "search")
					field.value = "";
			}
		}

	}		
}

function searchempty() {
	if (document.getElementById("SearchBox_searchQuery") != null) {
		var field = document.getElementById("SearchBox_searchQuery");
		field.value = "search";
		field.onfocus = function() { 
			this.value = "";
		}
		field.onblur = function() {
			if (this.value == "") 
				this.value = "search";
		} 		
	}
}

function rotatorinit() {
	if (document.getElementById("rotator-img") != null) {
		var left = document.getElementById("rotator-left");
		var right = document.getElementById("rotator-right");
		var image = document.getElementById("rotator-img");
		left.onclick = function() {
			rotator_iter--;
			if (rotator_iter < 0) { rotator_iter = rotator_array.length-1; }
			image.src = "/assets/images/rotator/impact/" + rotator_array[rotator_iter];
			return false;
		}
		right.onclick = function() {
			rotator_iter++;
			if (rotator_iter >= rotator_array.length) { rotator_iter = 0; }
			image.src = "/assets/images/rotator/impact/" + rotator_array[rotator_iter];
			return false;
		}		
	}		
}

function quoteinit() {
	if (document.getElementById("random-quote") != null) {
		var quote_headers = new Array();
			quote_headers[0] = '<h4 class="article-category ac-our-team">&nbsp;</h4>';
			quote_headers[1] = '<h4 class="article-category ac-our-approach">&nbsp;</h4>';
			quote_headers[2] = '<h4 class="article-category ac-real-impact">&nbsp;</h4>';
			quote_headers[3] = '<h4 class="article-category ac-words-of-support">&nbsp;</h4>';	
		var which = Math.floor(Math.random()*random_quote_type.length);
		var quote = document.getElementById("random-quote");
		quote.innerHTML = quote_headers[random_quote_type[which]-1];
		quote.innerHTML += random_quote_content[which];
	}
}


function change_regions( obj ) {
	var base_url = "";
	if (obj.value != "") {
		window.location = base_url + obj.value;	
	}
}

function init() {
	searchroll();
	searchempty();
	quoteinit();
	rotatorinit();
}

addLoadEvent(init);