dojo.declare("DojoSupportFeedback", DojoAjax, 
{
	//the DojoSupportFeedback constructor that takes the following parameters:
	//namespace - the encoded namespace of the portlet
	constructor: function(namespace)
	{
		this.namespace = namespace;
	},
	 
	// This function expands or collapses the twistie containing the surveys
	// and studies links.
	switchTwistieGroup: function(surveysTwistieId)
	{	
		var surveyLink;
		var surveyLinkStyle;
		var twistieStyle;
		var surveysTwistie = dojo.byId(surveysTwistieId);
		if(surveysTwistie != null)
		{
			var surveysTwistieSrc = surveysTwistie.src;
			var fileNamePosition = surveysTwistieSrc.indexOf("/images");
			
			// Change the image of the twistie from hide to show or vice versa.
			if (surveysTwistieSrc.substring(fileNamePosition) == "/images/sh_open.gif")
			{
				surveysTwistie.src = surveysTwistieSrc.replace(/sh_open.gif/, "sh_closed.gif");
				surveyLinkStyle = "none";
			}
			else
			{
				surveysTwistie.src = surveysTwistieSrc.replace(/sh_closed.gif/, "sh_open.gif");
				surveyLinkStyle = "block";	
			}			
			
			// Now, based on whether we did a hide or show, adjust the visbility of
			// the survey/study links accordingly.
			var index = 1;
			surveyLink = dojo.byId(this.namespace + "_surveyLink_" + index);
			while(surveyLink != undefined)
			{
				surveyLink.style.display = surveyLinkStyle;
				index++;
				surveyLink = dojo.byId(this.namespace + "_surveyLink_" + index);
			}
		}
		
		return false;							
	}
	
});