	var httpCgiPath = "<!--$HttpCgiPath-->";
	var httpRelativeFragmentsRoot = "<!--$HttpRelativeFragmentsRoot-->";
	var httpRelativeWebRoot = "<!--$HttpRelativeWebRoot-->";
	var SearchResults = new Array();
	var SavedSearches =  new Array();
			
	function display_dynamiccontentsingle(containerIndex,searchResults,resultCount,TitleText)
   	{
		var containerIdBase = "CollapsiblePanelSingle" + containerIndex + "_Base";
		var ContainerID = "CollapsiblePanelSingle" + containerIndex;
	
		document.write('<div style="margin:0px 0px 0px 0px; border-left:none;border-right:none;border-top:none; border-bottom:none;">' +
			'<div id="' + containerIdBase + '"></div>' +
	   	   '</div>');
	 
	
	document.write();
	
	
	var resultdiv = document.getElementById(containerIdBase);
	window.RESULTDIV = resultdiv;
	
	if(resultdiv)
	{
		drawCatSearchResults(ContainerID,searchResults,containerIndex,resultCount,TitleText);
	}
}

function refreshPaneResults(container,index)
{
	var htmlStr = "";
	var items = SavedSearches[index-1];
	//loop through results and show
	for(var i=0; i<items.length; i++)
	{
		htmlStr += makeResultHtml(items[i]);
	}
	
	//container.style.height = "250px";
	container.style.overflow = "auto";
	container.innerHTML = htmlStr;
}


function fillResultsArray(DocTitle,Comments,FileURL,dID,Extension,DocName,Type,Edate,Sdate)
{
	//build results array
	//create a doc object
	var doc = new Object();
	doc.title = DocTitle;
	doc.comments = Comments;
	doc.URL = FileURL;
	doc.dID = dID;
	doc.extension = Extension;
	doc.dDocName = DocName;
	doc.type = Type;
	doc.eDate = Edate;
	doc.sDate = Sdate;
	//add doc object to the SearchResults array
	SearchResults.push(doc);
}

// extract the search results and
// draw them to the page in collapsible panels
function drawCatSearchResults(containerId,searchResults,containerIndex,resultCount,titleText)
{
	

	var htmlStr = '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td>';
	
	if(searchResults == null)
	{
		htmlStr += "";
	}
	else //extract and categorize results then build html to draw them
	{
		htmlStr += makeResultsHtml(searchResults,containerId,containerIndex,resultCount,titleText);
	}
	
	htmlStr += '</td></tr></tbody></table>';

	window.RESULTDIV.innerHTML = htmlStr;
	//if the pane is collapsible pane
}


function makeResultsHtml(items,containerId,ContainerIndex,resultCount,titleText)
{
	var htmlStr = "";
	var containerArrow = containerId + "_arrow";
	var numResultsToDisplay;//number of results to display in a pane
	var showMoreLink;//boolean determines whether to show the 'Show All ...' link at the end of a pane

	//if(items.length==0)
	//{
	//	htmlStr = "";
	//	return htmlStr;
	//}

	//find out how many results to show in a pane an if a 'More ...' link is required
			if(items.length > resultCount && false){
				numResultsToDisplay = resultCount;
				showMoreLink = true;
			}else{
				numResultsToDisplay = items.length;
				showMoreLink = false;
			}

		htmlStr += '<div id="'+ containerId + '" class="nonCollapsiblePanel">';
		//htmlStr += '<div class="HeadingText">';
		//htmlStr += titleText + ' (' + items.length + ') </div>';
		//htmlStr += titleText +'</div><br>';

	//htmlStr += '<div class="CollapsiblePanelContent" style="height:auto;overflow:visible;">';


	//loop through results and show
	//for(var i=0; i<items.length; i++)
	for(var i=0; i<numResultsToDisplay; i++)
	{
		htmlStr += makeResultHtml(items[i]);
	}
	if(showMoreLink){

				htmlStr += '<div style="text-align:right;cursor:pointer;" onclick="refreshPaneResults(this.parentNode,' + ContainerIndex +')">Show All ...</div>';
			}
	htmlStr += '</div>';
	//htmlStr += '</div>';
	return htmlStr;
}

function makeResultHtml(item)
{
	var isEvent = item.type == "Events" || item.type == "Tradeshows" || item.type == "Campaign Materials";
	var htmlStr = '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
	htmlStr += '<tr valign="top">';
	//htmlStr += '<td width="30">';
	//htmlStr += '<table width="100%" cellspacing="0" cellpadding="2" border="0">';
	//htmlStr += '<tbody>';
	
	var showDetails = "false";		
	//htmlStr += '<tr valign="top">';
	//htmlStr += '<td>';
	//htmlStr += '<img border="0" width="26" height="26" alt="" style="cursor:pointer;" src="'+ httpRelativeFragmentsRoot +'ss_it_fr_dynasingle/images/' + getImageFilename(item.extension) + '" onclick="navigate(\'<!--$httpCgiPath-->?IdcService=GET_FILE&dID=' + item.dID + '&dDocName=' + item.dDocName + '\')"/>';

    //htmlStr += '<img border="0" width="22" height="22" alt="" src="'+ httpRelativeFragmentsRoot +'ss_it_fr_dynasingle/images/' + getImageFilename(item.extension) + '"/>';
    //htmlStr += '<img border="0" width="22" height="22" alt="" src="'+ httpRelativeWebRoot +'groups/webasset/@wbasst/@extranet/documents/webasset/' + getImageFilename(item.extension) + '"/>';
	//htmlStr += '</td>';
	//htmlStr += '</tr>';
	//htmlStr += '</tbody>';
	//htmlStr += '</table>';
	//htmlStr += '</td>';
	htmlStr += '<td>';
	htmlStr += '<table width="100%" cellspacing="0" cellpadding="6" border="0">';
	htmlStr += '<tbody>';
	htmlStr += '<tr valign="top">';
	htmlStr += '<td>';
	if(item.type != "Partner Information"){
		if(isEvent){
			if(item.type == "Events" || item.type == "Tradeshows"){
				htmlStr += '<div class="HeadingText" style="padding:0px 0px 4px 0px;">'+ item.title +'</div>';
			}else{
				htmlStr += '<div style="padding:0px 0px 4px 0px;"><a class="HeadingText" href="' + item.URL + '">'+ item.title +'</a></div>';
			}
		}else{
			htmlStr += '<span class="portlet-table-header"><a class=class="portlet-table-header" href = "javascript:popup(\'' + '<!--$HttpCgiPath-->?IdcService=GET_FILE&dID=' + item.dID + '&dDocName=' + item.dDocName + '\')" />'+ item.title +'</a>&nbsp;&nbsp;</span>';
		}
		//htmlStr += '<span class="ViewAsPDF"><a class="ViewAsPDF" href="' + item.URL + '" target="_blank">Preview</a>&nbsp;&nbsp;</span>';
						
		if(!isEvent){
			//htmlStr += '<span class="ViewAsPDF"><a class="ViewAsPDF" href = "javascript:popup(\'' + item.URL + '\')" /> Preview</a>&nbsp;&nbsp;</span>';
			//htmlStr += '<span class="subscribe"><a class="subscribe" href="<!--$HttpCgiPath-->?dID=' + item.dID + '&dDocName=' + item.dDocName + '&dDocTitle=' + item.title + '&dSubscriptionType=Basic' + '&dSubscriptionEmail=' + item.UserName + '&unsubscribeService=UNSUBSCRIBE' + '&subscribeService=MV_SUBSCRIBE' + '&IdcService=MV_SUBSCRIBE_FORM' +'" target="_blank">Subscribe</a>&nbsp;&nbsp;</span>';
		}else{
			htmlStr += '<span class="eventDates">';
			htmlStr += getFullDate(item.sDate,item.eDate);
			htmlStr += '</span><br>';
		}
		if (item.comments)
		{
			if(!isEvent){
				htmlStr += '<span class="portlet-section-header">Description&nbsp:&nbsp;</span>';
			}
			
			str = unescape(item.comments);
			htmlStr += '<span class="eventDates">' + str;
			htmlStr += '<br/>';
			if(isEvent){htmlStr += '</span>';}
		}
	}else{
		if(item.extension == "xml" || item.extension == "hcsp"){
			//htmlStr += '<span class="portlet-table-header"><a class="portlet-table-header" href = "../List/PartnerInfo/'+item.dDocName+'" /> '+ item.title +'</a>&nbsp;&nbsp;';
			htmlStr += '<a href = "' + item.URL + '" /> '+ item.title +'</a>&nbsp;&nbsp;</span>';
		}else{	
			htmlStr += '<a href = "javascript:popup(\'' + '<!--$HttpCgiPath-->?IdcService=GET_FILE&dID=' + item.dID + '&dDocName=' + item.dDocName + '\')" />- '+ item.title +'</a>&nbsp;&nbsp;';
		}
	}
	htmlStr += '</td>';
	htmlStr += '</tr>';
	htmlStr += '</tbody>';
	htmlStr += '</table>';
	htmlStr += '</td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	
	return htmlStr;
}

function getImageFilename(extension){
		switch(extension.toLowerCase())
		{
			case "doc": return "icon_doc_imag.gif"; 
			case "exe": return "icon_exe_imag.gif";
			case "gif": return "icon_image_imag.gif";
			case "bmp": return "icon_image_imag.gif";
			case "jpg": return "icon_image_imag.gif";
			case "jp2": return "icon_image_imag.gif";
			case "jpeg": return "icon_image_imag.gif";
			case "png": return "icon_image_imag.gif";
			case "pcx": return "icon_image_imag.gif";
			case "svg": return "icon_image_imag.gif";
			case "ai": return "icon_image_imag.gif";
			case "pdf": return "icon_pdf_imag.gif";
			case "ppt": return "icon_ppt_imag.gif";
			case "swf": return "icon_swf_imag.gif";
			case "vsd": return "icon_vsd_imag.gif";
			case "xls": return "icon_xls_imag.gif";
			case "zip": return "icon-zip_imag.gif";
			default: 	return "icon_misc_imag.gif";
		}
		return "icon_misc_imag.gif";
	}

	function navigate(loc){
		window.location = loc;
	}


