var gnpQuotes =  {	gnpQuoteData: [
	{text: 'We are not to throw away those things which can benefit our neighbor.', author: 'Clement of Alexandria'},
	{text: 'The human race is challenged more than ever before to demonstrate our mastery, not over nature but of ourselves', author: 'Rachel Carson'},
	{text: 'Ecological devastation is the excrement, so to speak, of man\'s power worship', author: 'Ernest Becker'},
	{text: 'We must strive to become good ancestors', author: 'Ralph Nader'},
	{text: 'Waste is a terrible thing to mind -- Recycle', author: 'U.S. bumper sticker'},
	{text: 'Trash: there are no rugs left to sweep it under', author: 'Milwaukee Journal, 19 Apr 70'},
	{text: 'Use it up, wear it out, make it do, or do without', author: 'New England proverb'},
	{text: 'Man is a complex being; he makes deserts bloom - and lakes die', author: 'Gil Stern'},
	{text: 'I am I plus my surroundings and if I do not preserve the latter, I do not preserve myself', author: 'Jose Ortega Y Gasset'},
	{text: 'The mastery of nature is vainly believed to be an adequate substitute for self-mastery', author: 'Reinhold Niebuhr'},
	{text: 'It strikes me as being morally repulsive and intellectually absurd that people die of want in a world of surplus', author: 'Bob Geldof'},
	{text: 'The most common trait of all primitive peoples is a reverence for the life-giving earth', author: 'Stewart L. Udall'},
	{text: 'All the Javascript was written by me and my bud, Zappy', author: 'Greg Hildebrand'},
	]	
};

var gnpObject = function ( obj, elem1, elem2 ) {
	var gnp_name 		= obj;
	var gnp_cnt 		= 0;
	var gnp_arr 		= [1,0,0,0];
	var gnp_cycler  	= elem1;
	var gnp_tabular  	= elem2;
	
	function getAQuote() {
		if( document.getElementsByTagName('blockquote')[0] ) {
			var blkQuote = document.getElementsByTagName('blockquote')[0];
			var blkNum = Math.floor(Math.random() * 12);
			blkQuote.innerHTML =' ' + gnpQuotes.gnpQuoteData[blkNum].text + '<p align=\"right\" > - ' + gnpQuotes.gnpQuoteData[blkNum].author + '</p>';
		}	
		return true;
	};
	
	/*GNP Rotating News Code*/
	function rotatingNews_cycle() {
		gnp_cnt++;
		rotatingNews_show();
		return true;
	};

	function rotatingNews_show() {
		if (gnp_cycler != null) {
			if ( gnp_cnt < gnp_arr.length ) {
				gnp_arr[(gnp_cnt-1)] = 0;
				gnp_arr[gnp_cnt] = 1;
			}
			else {
				gnp_arr[(gnp_cnt-1)] = 0;
				gnp_cnt = 0;
				gnp_arr[0] = 1;
			}
			gnp_cycler.style.backgroundImage = "url('images/gnp-image-0" + (gnp_cnt+1) + ".jpg')";
			//gnp_cycler.getElementsByTagName('span')[0].innerHTML = document.getElementsByTagName('dt')[gnp_cnt].childNodes[0].nodeValue;
			//gnp_cycler.getElementsByTagName('span')[1].innerHTML = document.getElementsByTagName('dt')[gnp_cnt].childNodes[0].nodeValue;
		}	
	return true;//window.status = gnp_arr.toString() + ' ' + gnp_name ;
	};
	/*GNP Rotating News Code*/
	
	function tabContent_show( arg1 ) {
	 if (gnp_tabular != null) {
			var gnp_tabular_span_cnt = gnp_tabular.getElementsByTagName('div').length;
			for (var x=0; x < gnp_tabular_span_cnt; x++) {
				gnp_tabular.getElementsByTagName('div')[x].style.visibility='hidden';
				gnp_tabular.getElementsByTagName('div')[x].style.display='none';
			}
			gnp_tabular.getElementsByTagName('div')[arg1].style.visibility='visible';
			gnp_tabular.getElementsByTagName('div')[arg1].style.display='block';
		}	
		return true;
	};
	
	var publicUI = {  };
	publicUI.init = function() {
		 //getAQuote();
		 rotatingNews_show();
		 tabContent_show( 0 );
		 return true;
	};
	publicUI.about = function() {
		 tabContent_show( 0 );
		 return true;
	};
	publicUI.certify = function() {
		 tabContent_show( 0 );
		 return true;
	};
	publicUI.cycle = function() {
		return rotatingNews_cycle();
	};
	publicUI.tab = function( arg1 ) {
		return tabContent_show( arg1 );
	};
	return publicUI;
}
