var _FAQ_Q = new Array(
    'How are we saving rainforests exactly?',
    'Where can I learn more about the Nature Conservancy?',
	'Why is the money not donated to another program aimed at rainforest protection and restoration?',
	'When will the money be donated?',
	'How does this application work?',
	'Can I give plants to my (Lil) Green Patch?',
	'My friend sent me a plant that I don\'t see on the Send Plants page anymore? Where did that plant come from?',
	'I don\'t get sent enough plants. What can I do to get more plants?',
	'Why don\'t you have a way to...?'
);

var _FAQ_A = new Array(

    'The developers of (Lil) Green Patch are using sponsorship revenue from advertisers to make donations to the Nature Conservancy\'s Adopt an Acre program. Adopt an Acre is a program that provides critical funds for rainforest protection and restoration. You can visit the following site to learn more about this program:  <br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.nature.org/joinanddonate/adoptanacre/about/" target="_blank">http://www.nature.org/joinanddonate/adoptanacre/about/</a>',

    '&nbsp;&nbsp;&nbsp;<a href="http://www.nature.org" target="_blank">http://www.nature.org</a>',

	'The (lil) Green Patch team is committed to finding and helping green causes.  At this time the target of our donation is the Nature Conservancy. However, we\'d love to hear your feedback about other organizations that are consistent with the goals of the application.',
	
	'The application makes its donation on the last day of every month based on the number of square feet saved by the (Lil) Green Patch community. We are proud to announce that together, the (Lil) Green Patch community has saved more than 59,098,167 Sqft of Rainforest on the Osa Peninsula of Costa Rica. You can learn more about the donation by checking out the Top Donors leaderboard at this location:<p> &nbsp;&nbsp;&nbsp;<a href="http://apps.facebook.com/causes/hall_of_fame/2979" target="_blank">http://apps.facebook.com/causes/hall_of_fame/2979</a>',

	'Pretty simple. Users start by either sending plants to their friends or by accepting plants from their friend. The plants given by your friends are displayed in your (Lil) Green Patch. There is a whole lot more coming in this application - Marketplace, Store, Gifts, themes, decorations, games and much more. We suggest you explore the application and find more!',
	
	'This application aims to provide a light weight interaction mechanism with your friends. At this time, the only way one can get plants in their (Lil) Green Patch is by receiving plants from their friends.',
	
	'The application introduces certain Limited Edition plants that are available to be sent to friends for a limited time. Chances that these plants will return are exceptionally low or none. We suggest you watch for new plants and collect them before they are history too!',
	
	'The only way for a user to receive plants in their (Lil) Green Patch is to receive them from their friends. We suggest you send plants to your friends who have (Lil) Green Patch, invite your friends who don\'t have the application to join or find some new friends on the discussion board who might want a few more friends.',

	'Just ask and we\'ll see what we can do.'
);

function onClickFAQ() {
		var html = generateFAQ();
		document.getElementById('body').innerHTML = html;
		gadgets.window.adjustHeight();
}

function generateFAQ() {
		var html = '';

		html += '<div>'; 
		html += '<table width="100%">';
		html += '  <tr>';
		html += '    <td width="5%">';
		html += '    </td>';
		html += '    <td width="90%">';
		html += '      <table width="100%" align="left">';

		for(var i = 0; i < _FAQ_Q.length; i++) {
				html += generateFAQ_Q(i);
				html += generateFAQ_A(i);
		}

		html += '      </table>';
		html += '    </td>';
		html += '    <td width="5%">';
		html += '    </td>';
		html += '  </tr>';
		html += '</table>';
		html += '</div>';

		return html;
}

function generateFAQ_Q(i) {
		var html = '';

		html += ' <tr id="faqQ' + i + '" width="100%" align="left">';
		html += '   <td width="100%" align="left">';
		html += '     <div style="color:#006600;font-size:12px; font-family:Verdana, Arial,Helvetica, sans-serif;">';
		html += '       <b>Q: ' +_FAQ_Q[i] + '</b>';
//		html += '       <a href="javascript:void(0);toggleA(' + i + ');" <b>Q: ' +_FAQ_Q[i] + '</b></a>';
		html += '     </div>';
		html += '   </td>';
		html += ' </tr>';      
		return html;
}

function generateFAQ_A(i) {
		var html = '';
		html += ' <div id="faqA' + i + '">' + generateFAQ_A_td(i) + '</div>';
		return html;
}

function generateFAQ_A_td(i) {
	var html = '';
	html += ' <tr width="100%" align="left">'; 
	html += '   <td width="100%" align="left">';
	html += '     <div style="color:#000000;font-size:12px; font-family:Verdana, Arial,Helvetica, sans-serif;">';
	html += '       <b>A:</b> ' + _FAQ_A[i] + '<BR/><BR/>';
	html += '     </div>';
	html += '   </td>';
	html += ' </tr>';
	return html;
}


//function toggleA(i) {
//
//	var faqA = document.getElementById('faqA' + i);
//	    
//	if(faqA.style.visibility == "visible") {
//		faqA.style.visibility = "hidden";
//	}
//	else {
//		faqA.style.visibility = "visible";
//	}
//}

function toggleA(i) {

	var ele = 'faqA' + i;
	//alert (ele);
	
	var answer = document.getElementById(ele);
	
	var html = answer.innerHTML;
	
	//alert ('current -> '  + html);
	if(html.length == 0) {
		//alert("A");
		html = generateFAQ_A_td(i);
		}
	else {
		//alert("B");
		html = "";
	}
	
	//alert('after processing -> ' + html);
	document.getElementById(ele).innerHTML = html;
	gadgets.window.adjustHeight();
}
