/**********************************************
 * YUI Lightbox 
 *********************************************/

function panelInit() {
	// Instantiate a Panel from markup
	lightbox = new YAHOO.widget.Panel("fundraiserfaqpanel",{
		zIndex: "100",
		width:"550px",
		height:"625px",
		visible:false,
		close:true,
		underlay:"matte",
		modal:true,
		fixedcenter:true});

	lightbox.setHeader("close");
	lightbox.render();
}


var AjaxObject = {

	handleSuccess:function(o){
		// Success handler
		lightbox.setBody(o.responseText);
		lightbox.render();
		lightbox.show();
	},

	handleFailure:function(o){
		// Failure handler
		lightbox.setBody('Error retrieving data.');
		lightbox.render();
		lightbox.show();
	},

	startRequest:function(sUrl) {
	   YAHOO.util.Connect.asyncRequest('GET', sUrl, handleFundraiserFAQ );
	}

};


var handleFundraiserFAQ = {
	success:AjaxObject.handleSuccess,
	failure:AjaxObject.handleFailure,
	scope: AjaxObject
};

YAHOO.util.Event.addListener(window, "load", panelInit);

var totalFAQs = 20;
var lbinit = false;
function lightboxFAQInit(){
	xpanel = document.getElementById('fundraiserfaqpanel');
	closetxt = xpanel.firstChild;
	closetxt.style.position = "relative";
	closebtn = xpanel.firstChild.nextSibling;
	closebtn.onmouseup = function(){
		restoreLB();
	}
	lbinit = true;
}

function closeAllFAQs(){
	for(i=1; i<=totalFAQs;i++){
		document.getElementById('ans'+i).style.display = "none";
	}
}

function restoreLB(){
		closetxt.style.left = "0px";
		closebtn.style.right = "6px";
		document.getElementById('fundraiserfaqpanel_c').style.width = "555px";
		document.getElementById('fund-faq-lightbox-container').style.width = "545px";
		document.getElementById('fundraiserfaqpanel_c').style.left = "300px";
		document.getElementById('fund-faq-lightbox-answers').style.display = "none";
		closeAllFAQs();
}

function toggleLBFAQ(id){
	if(lbinit == false){
		lightboxFAQInit();
	}
	if(document.getElementById('ans'+id).style.display == "none"){
		closetxt.style.left = "338px";
		closebtn.style.right = "-338px";
		document.getElementById('fundraiserfaqpanel_c').style.width = "880px";
		document.getElementById('fund-faq-lightbox-container').style.width = "870px";
		document.getElementById('fundraiserfaqpanel_c').style.left = "150px";
		document.getElementById('fund-faq-lightbox-answers').style.display = "block";
		closeAllFAQs();
		document.getElementById('ans'+id).style.display = "block";
		
	}else{
		restoreLB();
	}
	return false;
}