/**
 * Component container related javascript module.  It contains various 
 * dynamially loadable HTML components into another component.  It has 
 * following components:
 * 1. Author directory component
 * 2. Dialog form component
 * 3. Dialog box component
 *
 * @author Veeresh D.
 * @date March 2008
 */

var authorDirTabComponentHTML;
var dialogFormComponentHTML;

var formComponentHTML;
var formComponentHTMLID = 0;
var formComponentHTMLArrayID = new Array();
var tempFlag, tempStr;

var components =
{
/**
Returns the HTML content of a author directory tab component. It may also
get from server dynamically and it is recommented in future

@return authorDirTabComponentHTML HTML content of author tab component
*/
getAuthorDirTabHTMLComponent: function()
{
    authorDirTabComponentHTML = "<DIV id=authorTabComponent>";
	authorDirTabComponentHTML += "<TABLE cellSpacing=0 border=0 width=100% style='margin: 0px; border-collapse: collapse'>";
	authorDirTabComponentHTML += "<TR>";
	
	for( var i = 65; i < (65+26); i++)
	{
	    authorDirTabComponentHTML += "\n<TD id=authorTabId" + (i-65+1) + " class=authorTabClass onmouseover=tabAuthDir.setAuthorTabFocus(this.id) onmouseout=tabAuthDir.resetAuthorTabFocus(this.id) onclick=tabAuthDir.setAuthorTabDivdata(this.id," + (i-65+1) + ")>" + String.fromCharCode(i) + "</TD>";
	}
	
	authorDirTabComponentHTML += "</TR>";
	authorDirTabComponentHTML += "<TR style='background-color: LIGHTSTEELBLUE; color: white;'>";
	
	for( var i = 1; i <= 26; i++)
	{
	    authorDirTabComponentHTML += "<TD id=authorTabSecondCharId" + i + " class=secondCharLinks>a</TD>";
	}
	
	authorDirTabComponentHTML += "</TR>";	
	authorDirTabComponentHTML += "</TABLE>";
	authorDirTabComponentHTML += "</DIV>";	
	authorDirTabComponentHTML += "<DIV id=authorTabComponentResults style='width:100%; border: 2px solid LIGHTSTEELBLUE;'></DIV>";
	return authorDirTabComponentHTML;		
},

/**
Returns the HTML content of a form component

@return formComponentHTML HTML content of dialog form component
*/
getFormHTMLComponent: function(formTitle, formHTML)
{   
	formComponentHTMLID = formComponentHTMLID + 1; //Next unique id for form html component
	formComponentHTMLArrayID[formComponentHTMLID] = 1;
	
	formComponentHTML = "<TABLE align=center id='formPanelBoxTable' border='1' cellspacing='0' width=99%>";
	formComponentHTML += "<TR>";
	formComponentHTML += "<TD class='formPanelBoxTableHeader'>" + formTitle + "</TD>";
	formComponentHTML += "<TD class='formPanelBoxTableHeader' style='border-left: 0px; width=1%' align= right><img id=formPanelBoxTableImage" + formComponentHTMLID +" src='" + ROOT_URL + "images/arrow-up.gif' onclick=components.hideFormHTMLComopnent(" + formComponentHTMLID +") style='cursor: pointer' alt='Close this content' /></TD>";
	formComponentHTML += "</TR>";
	formComponentHTML += "<TR>";
	formComponentHTML += "<TD colspan=2 class='formPanelBoxTableFrame'>";
	formComponentHTML += "<DIV id=formPanelBoxTableDiv" + formComponentHTMLID +">" + formHTML + "</DIV>";
	formComponentHTML += "</TD>";
	formComponentHTML += "</TR>";
	formComponentHTML += "</TABLE>";	
	
	return formComponentHTML;
},

/**
Returns the HTML content of a form component

@return formComponentHTML HTML content of dialog form component
*/
getPlainFormHTMLComponent: function(formTitle, formHTML)
{   
	formComponentHTML = "<TABLE align=center id='plainFormPanelBoxTable' border='1' cellspacing='0'>";
	formComponentHTML += "<TR>";
	formComponentHTML += "<TD class='planFormPanelBoxTableHeader'>" + formTitle + "</TD>";
	formComponentHTML += "</TR>";
	formComponentHTML += "<TR>";
	formComponentHTML += "<TD colspan=2 class='formPanelBoxTableFrame'>";
	formComponentHTML += "<DIV>" + formHTML + "</DIV>";
	formComponentHTML += "</TD>";
	formComponentHTML += "</TR>";
	formComponentHTML += "</TABLE>";		
	
	return formComponentHTML;
},

/**
Returns the HTML content of a plain form component just with one top border

@return formComponentHTML HTML content of dialog form component
*/
getFormHTML2Component: function(formTitle, formHTML)
{   
	formComponentHTML = "<TABLE align=center border='0' cellspacing='0' width=99% style='padding: 0px;'>";
	formComponentHTML += "<TR>";
	formComponentHTML += "<TD style='font: bold 12px Arial;'>" + formTitle + "</TD>";
	formComponentHTML += "</TR>";
	formComponentHTML += "<TR>";
	formComponentHTML += "<TD>";
	formComponentHTML += "<DIV style='border-top: 1px solid silver;'>" + formHTML + "</DIV>";
	formComponentHTML += "</TD>";
	formComponentHTML += "</TR>";
	formComponentHTML += "</TABLE>";
	return formComponentHTML;
},

/**
Hides the HTML form component

@return formComponentHTML HTML content of dialog form eereshjcomponent
*/
hideFormHTMLComopnent: function(formHTMLID)
{
	var rem = formComponentHTMLArrayID[ Number(formHTMLID) ]%2;
	
	if ( rem == 0)
	{
	    document.getElementById("formPanelBoxTableDiv" + formHTMLID).style.display='';
	    document.getElementById("formPanelBoxTableImage" + formHTMLID).src= ROOT_URL + "images/arrow-up.gif";	    
	    document.getElementById("formPanelBoxTableImage" + formHTMLID).alt="Close this content"; 	    
	}
	else
	{
	    document.getElementById("formPanelBoxTableDiv" + formHTMLID).style.display="none";
	    document.getElementById("formPanelBoxTableImage" + formHTMLID).src= ROOT_URL + "images/arrow-down.gif";	    	    
	    document.getElementById("formPanelBoxTableImage" + formHTMLID).alt="Open this content";
	}
	formComponentHTMLArrayID[Number(formHTMLID)]++;
},

/**
Returns the Dialog box form html component

@return dialogFormComponentHTML HTML content of dialog form component
*/
getDialogBoxHTMLComponent: function()
{   
	dialogFormComponentHTML = "<table cellspacing='0' cellpadding='0' border='0'>";
	
	dialogFormComponentHTML += "<tr>";
	dialogFormComponentHTML += "<td width='10' background='images/pf-images/pf-top-left.gif'/>";
	dialogFormComponentHTML += "<td class='announce_header' id='dialogBoxDivTitleId'/>"; //  << Title of the form
	dialogFormComponentHTML += "<td class='announce_header' width='20px'>";
	dialogFormComponentHTML += "<input type='button' id='loginCloseButton' value='X' onclick='components.closeDialogBox()' />";
	dialogFormComponentHTML += "</td>";
	dialogFormComponentHTML += "<td colspan='2' width='10' align=middle background='images/pf-images/pf-top-right.gif' />";
	dialogFormComponentHTML += "</tr>";
	
	dialogFormComponentHTML += "<tr>";
	dialogFormComponentHTML += "<td background='images/pf-images/pf-middle-left.gif'/>";
	dialogFormComponentHTML += "<td class='announce_content'>";
	dialogFormComponentHTML += "<!-- External HTML content have to be imported here -->";
	dialogFormComponentHTML += "<DIV id='dialogBoxDivDataId'/>"; //  << Body part of the form
	dialogFormComponentHTML += "</td>";
	dialogFormComponentHTML += "<td class='announce_content'/>";
	dialogFormComponentHTML += "<td background='images/pf-images/pf-middle-right.gif'/>";
	dialogFormComponentHTML += "</tr>";
	
	dialogFormComponentHTML += "<tr height='12'>";
	dialogFormComponentHTML += "<td background='images/pf-images/pf-bottom-left.gif'/>";
	dialogFormComponentHTML += "<td background='images/pf-images/pf-bottom-middle.gif'/>";
	dialogFormComponentHTML += "<td background='images/pf-images/pf-bottom-middle.gif'/>";
	dialogFormComponentHTML += "<td background='images/pf-images/pf-bottom-right.gif'/>";
	dialogFormComponentHTML += "</tr>";
	
	dialogFormComponentHTML += "</table>";
	
	return dialogFormComponentHTML;
},

/**
Displays dialog box function

@param loginHTMLData HTML content of the static login page
@param title Title name of the dialog form component
@param width Width of the dialog form component
@param height Height of the dialog form component
@param left Left Left of the dialog form component
@param top Top of the dialog form component
*/
showDialogBox: function(loginHTMLData, title, dWidth, dHeight, dLeft, dTop)
{		
	//backgroundFilter();
	document.getElementById('backgroundFilter').style.height = document.body.scrollHeight;
	document.getElementById('backgroundFilter').style.width = document.body.scrollWidth;
	
	//popUp2();
	components.hideDialogBoxBackground();
	var dialogObj = document.getElementById("popupWindow");
	
	dialogObj.innerHTML = components.getDialogBoxHTMLComponent();
	dialogObj.style.display = "block";
	document.getElementById("dialogBoxDivDataId").innerHTML = loginHTMLData;
	document.getElementById("dialogBoxDivTitleId").innerHTML = title;
		
	if ( dWidth > 0 )
	    dialogObj.style.width = dWidth;
	if ( dHeight > 0 )
	    dialogObj.style.height = dHeight;	
	
	if ( getBrowserName() == "Safari" || getBrowserName() == "Mozilla"  || getBrowserName() == "Firefox" )
	    dialogObj.style.top = parseInt((screen.availHeight - dialogObj.offsetHeight)/2);
	else
	    dialogObj.style.top = parseInt((document.body.offsetHeight - dialogObj.offsetHeight)/2);	
	    
	dialogObj.style.left = parseInt((document.body.offsetWidth - dialogObj.offsetWidth)/2);		
},

/**
Hides the dialog form component's background content to graps the user's attention
*/
hideDialogBoxBackground: function()
{
    document.getElementById('backgroundFilter').style.height = document.body.scrollHeight;
	document.getElementById('backgroundFilter').style.width = document.body.scrollWidth;
	document.getElementById('backgroundFilter').style.display = "block";
},

/**
Shows the dialog form component's background content to graps the user's attention
*/
showDialogBoxBackground: function()
{
	document.getElementById('backgroundFilter').style.display = "none";
},

/*
Closes the dialog form component
*/
closeDialogBox: function()
{
    document.getElementById("popupWindow").innerHTML = "";
	document.getElementById('popupWindow').style.display = "none";
	components.showDialogBoxBackground();	
},

/*
Resizes the header background image after resize of the browser
*/
afterResize: function()
{
	document.getElementById("headerBgImage").style.height = "118px";
	//document.getElementById("headerBgImage").style.width = document.getElementById("headerBgDiv").offsetWidth - 20;
	document.getElementById("headerBgImage").style.width = "980px";
	
	var wid = "980px";
	
	/*var wid = "100%";
	if ( getBrowserName() == "Safari" || getBrowserName() == "Mozilla" || getBrowserName() == "Firefox" )
        wid = "98%";
    if ( getBrowserName() == "Opera" )        wid = "100%";*/
    
    	//Added to make the DL Template Aligned Center For Different Browsers
	var marginHorizontal = "10px";
	if ( getBrowserName() == "Safari" || getBrowserName() == "Mozilla" || 
	getBrowserName() == "Firefox" || getBrowserName() == "Opera" || getBrowserName() == "Chrome" )
	{
		marginHorizontal = "13px";
		
	}
	
	//alert("here we need to change... width=" + wid +","+ getBrowserName());
	if ( document.getElementById("curveWhite") )
	{
		document.getElementById("curveWhite").style.width = wid;	
		//document.getElementById("curveWhite").style.margin = "1%";
		document.getElementById("curveWhite").style.marginRight = marginHorizontal;
		document.getElementById("curveWhite").style.marginLeft = marginHorizontal;
		document.getElementById("curveWhite").style.marginTop = "1%";
		document.getElementById("curveWhite").style.marginBottom = "1%";
	}
	if ( document.getElementById("curveGray") )
	{
		document.getElementById("curveGray").style.width = wid;	
		//document.getElementById("curveGray").style.margin = "1%";
		document.getElementById("curveGray").style.marginRight = marginHorizontal;
		document.getElementById("curveGray").style.marginLeft = marginHorizontal;
		document.getElementById("curveGray").style.marginTop = "1%";
		document.getElementById("curveGray").style.marginBottom = "1%";
	}
	
	if ( document.getElementById("headerBgDiv") )
	{
		document.getElementById("headerBgDiv").style.marginRight = marginHorizontal;
		document.getElementById("headerBgDiv").style.marginLeft = marginHorizontal;
	}
	
	if ( getBrowserName() == "Firefox" )
	{
	    document.getElementById("logoTable").style.background = "url('images/background_header.gif') no-repeat;"; 
	    //document.getElementById("logoTable").style.width = "975px";
	    document.getElementById("logoTable").style.width = "960px";
	    document.getElementById("logoTable").style.height = "126px";
	}	
},

penel: function()
{
	/* Subclass object gets populated with seperate panel class.
	 *
	 * It is object oriented javascript programming by components architecture
	 */
}
} 
/* End of main component object */

/********************************************** BEGIN **************************************************
 * Panel class getting serving for super class: component *
 ******************************************************************************************************/
function panel()
{
	this.getCurrentIssues = getCurrentIssues;	     
	this.renderCurrentIssues = renderCurrentIssues;
	this.getMonthIssues = getMonthIssues;
	this.renderMonthIssues = renderMonthIssues;
	this.getTopArticles = getTopArticles;
	this.renderTopArticles = renderTopArticles;
	this.getOtherResources = getOtherResources;
	this.renderOtherResources = renderOtherResources;
	this.getNewsLetters = getNewsLetters;
	this.getOnlineTutorials = getOnlineTutorials;
	this.getOtherResources = getOtherResources;
	this.getHTMLPage = getHTMLPage;
	this.renderHTMLPage = renderHTMLPage;
	this.hideMonthIssues = hideMonthIssues;
	this.hideCurrentIssues = hideCurrentIssues;
	this.hideTopArticle = hideTopArticle;
	this.showMonthIssues = showMonthIssues;
	this.showCurrentIssues = showCurrentIssues;
	this.showTopArticle = showTopArticle;
	this.getHelpPages = getHelpPages;
	this.getHelpLinkPages = getHelpLinkPages;	
	this.getAds = getAds;
	this.renderAds = renderAds;
	this.hideAds = hideAds;
	this.showAds = showAds;
	this.getShoppingCartCheckoutHTMLPage = getShoppingCartCheckoutHTMLPage;
	this.getFeedbackHTMLPage = getFeedbackHTMLPage;
	this.renderFeedbackHTMLPage = renderFeedbackHTMLPage;
	this.showBanner = showBanner;
	this.hideBanner = hideBanner;
	this.loadBanner = loadBanner;
}

/**
Gets the static html content of all current issues from the server

@parameter issueHtmlFile Issues' html file name
*/
function getCurrentIssues(issueHtmlFile)
{
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
			if (ajaxRequest.status == 200) 
			{
				components.penel.renderCurrentIssues(ajaxRequest.responseText);								
			} 
			else      
			{
				alert("Unable to get response!: " + ajaxRequest.responseText);	
			}				
		}       
	}	
	ajaxRequest.open("GET", ROOT_URL + "html/" + issueHtmlFile);	
	//ajaxRequest.setRequestHeader('Content-Type', "text/xml");
	ajaxRequest.send(null);	
}
/**
Renders and loads the right issue panel component with static html content of all current issues

@param data Plain html data of issues
*/
function renderCurrentIssues(data)
{	
	var issueDetails = data.split("|");
	var issueDetailsHtml = "<P class=rightPanelIssueBoxLinksClass>";	
	
	tempFlag = 0;
	if ( data.length > 0 )
	{	
		tempFlag = 1;		
		issueDetailsHtml += data;
	}	
	issueDetailsHtml += "</P>";	
	if ( tempFlag == 0)	
	{
		document.getElementById("rightPanelIssueBoxOuterDiv").style.display = "none";
		return;
	}
	document.getElementById("rightPanelIssueBoxDiv").innerHTML = issueDetailsHtml;		
	
	components.penel.showCurrentIssues();
	searchResults.emptySearchResults();
}

/**
Gets the static html content of all current issues of the month from the server

@param issueHtmlFile Issues' html file name
*/
function getMonthIssues(issueHtmlFile)
{
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
			if (ajaxRequest.status == 200) 
			{
				components.penel.renderMonthIssues(ajaxRequest.responseText);								
			} 
			else 
			{	
				alert("Unable to get response!: " + ajaxRequest.responseText);	
			}				
		}       
	}	
	ajaxRequest.open("GET", ROOT_URL + "html/" + issueHtmlFile);	
	ajaxRequest.send(null);	
}	

/**
Renders and loads the right issue panel component with static html content of all current issues of the month

@param data Plain html data of issues of the month
*/
function renderMonthIssues(data)
{	
	var issueDetails = data.split("|");
	var issueDetailsHtml = "";          
	
	tempFlag = 0;
	if ( data.length > 0 )
	{	
		tempFlag = 1;		
		issueDetailsHtml += data;
	}	
	issueDetailsHtml += "";
	if ( tempFlag == 0)	
	{
		document.getElementById("rightPanelIssueBoxOuterDiv").style.display = "none";	//If the content is empty, then no need to show its component
		return;															
	}
    
    issueDetailsHtml = "<div style=\"background-color: whitesmoke;\"><div class=\"t\"><div class=\"b\"><div class=\"l\"><div class=\"r\"><div class=\"bl\"><div class=\"br\"><div class=\"tl\"><div class=\"tr\">" + issueDetailsHtml;
    issueDetailsHtml = issueDetailsHtml + "</div></div></div></div></div></div></div></div></div>";
    
	document.getElementById("currentMonthIssueDivId").innerHTML = issueDetailsHtml;		
	document.getElementById("currentMonthIssueDivId").style.borderColor = "red";
	components.penel.showMonthIssues();
}

/**
Gets the dynamic top most viewed articles from the sever

@param articleType Type of top articles(ex: Home, Journal, Conference, Magazine etc)
*/
function getTopArticles(articleType)
{
    var ajaxRequest = zXmlHttp.createRequest();
	showNotification('topArticlesNote', 'Loading...', 0);
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
			if (ajaxRequest.status == 200) 
			{
			    components.penel.renderTopArticles(ajaxRequest.responseText, articleType);
			} 
			else 
			{	
                hideNotification('topArticlesNote');
                showFallBackNotification('rightPanelTopArticleBoxDiv',"Unable to get top articles from server" ,"components.penel.getTopArticles(\"" + articleType + "\")");
			}
		}   
	}
	ajaxRequest.open("GET", ROOT_DB_URL + "downloads.action?articleType=" + articleType, true);	
	ajaxRequest.send(null);	
}	

/**
Renders and loads the top article panel component with top most viewed articles from the server

@param data Plain html data of top articles
*/
function renderTopArticles(data, articleType)
{		
	var articleObject;
	var i, j, resultHTML;
	
	hideNotification('topArticlesNote');                
	
	try
    {
        articleObject = eval('(' + data + ')');
        if ( articleObject.topDownloadedArticles == null)
	    {
	        //alert("No search results for top most viewed articles: " + data);
	        throw "";
        }
    }
    catch(e)
    {
	    //components.penel.hideTopArticle();
	    //alert("Unable to parse top most viewed articles data!\n\n" + e.description); 
	    showFallBackNotification('rightPanelTopArticleBoxDiv',"Unable to get top articles from server" ,"components.penel.getTopArticles(\"" + articleType + "\")");
	    return;
    }
    
    resultHTML = "<img src='" + ROOT_URL + "images/top-articles.png'  style='border:0px;' />";
    resultHTML += "Top 10 most read articles".bold();
	resultHTML += "<table border=0 cellpadding=0>";
	
	for( i = 0; i < articleObject.topDownloadedArticles.length; i ++)
	{
		if( i%2 == 0)
		    resultHTML += "<tr style='background-color: whitesmoke; padding-top: 5px'>";
		else
		    resultHTML += "<tr style='background-color: white; padding-top: 5px'>";
		
		resultHTML += "<td class=searchResultItem>";
		resultHTML += ((i+1) + ". ").bold();
		
		//resultHTML += "<A href=# class=searchResultItem onclick=\"searchResults.getArticleData('" + articleObject.topDownloadedArticles[i].articleID + "')\">";
        resultHTML += "<B><A href=?article=" + articleObject.topDownloadedArticles[i].articleID + " onclick=\"return searchResults.getArticleData('" + articleObject.topDownloadedArticles[i].articleID + "') \">";
	    resultHTML += "\"" + articleObject.topDownloadedArticles[i].articleTitle + "\"</A></B>, ";
		
		authorTempObj = articleObject.topDownloadedArticles[i].authors;
		for( j = 0; authorTempObj != null && j < authorTempObj.length; j ++)
		{
		    //resultHTML += "<A href=# class=searchResultItem";
            //resultHTML += " onclick=\"searchResults.getAuthorData(" + articleObject.topDownloadedArticles[i].authors[j].authorID +")\">";
		    resultHTML += "<A href=?author=" + articleObject.topDownloadedArticles[i].authors[j].authorID +" onclick=\"return searchResults.getAuthorData(" + articleObject.topDownloadedArticles[i].authors[j].authorID +")\">";
	        resultHTML += articleObject.topDownloadedArticles[i].authors[j].firstName + " ";
			resultHTML += articleObject.topDownloadedArticles[i].authors[j].lastName;			
			resultHTML += "</A>, ";				
		}
		
		resultHTML += articleObject.topDownloadedArticles[i].parentTitle.italics() + ", ";
		
		resultHTML += "Vol. " + articleObject.topDownloadedArticles[i].volume + ", ";
		resultHTML += "no. " + articleObject.topDownloadedArticles[i].issueNumber + ", ";
		
		var resultDetailsKeyword = articleObject.topDownloadedArticles[i].parentTitle;
		resultDetailsKeyword += ", " + articleObject.topDownloadedArticles[i].month + " " + articleObject.topDownloadedArticles[i].year;
          
		//resultHTML += "<A href=# class=searchResultItem";
        //resultHTML += " onclick=\"treePub.pubGetPublicationResults('" + articleObject.topDownloadedArticles[i].issueObjectNodeID +"','" + resultDetailsKeyword +"')\">";
        resultHTML += "<A href=?publication=" + articleObject.topDownloadedArticles[i].issueObjectNodeID + "&label=" + escape(resultDetailsKeyword) + " onclick=\"return treePub.pubGetPublicationResults('" + articleObject.topDownloadedArticles[i].issueObjectNodeID + "','" + resultDetailsKeyword + "')\">";
	    resultHTML += articleObject.topDownloadedArticles[i].month + " ";
		resultHTML += articleObject.topDownloadedArticles[i].year;
		resultHTML += "</A>, "; 
		
		resultHTML += "pp. " + articleObject.topDownloadedArticles[i].startPage + "-";
		resultHTML += articleObject.topDownloadedArticles[i].endPage;		
		
		resultHTML += "</td>";	
		resultHTML += "</tr>";
	}
	resultHTML += "</table>";
	
	document.getElementById("rightPanelTopArticleBoxDiv").innerHTML = resultHTML;
	components.penel.showTopArticle();
}

/**
Gets the dynamic top most viewed articles from the sever
*/
function getOtherResources()
{
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
			if (ajaxRequest.status == 200) 
			{
			    components.penel.renderOtherResources(ajaxRequest.responseText);								
			} 
			else 
			{	
                alert("Unable to get response!22: " + ajaxRequest.responseText);	
			}				
		}       
	}	
	ajaxRequest.open("GET", ROOT_URL + "html/otherResources/otherResources.htm", true);	
	ajaxRequest.send(null);	
}

/**
Renders and loads the top article panel component with top most viewed articles from the server

@param data Plain html data of top articles
*/
function renderOtherResources(data)
{	
	var otherResourcesHtml = "";
	
	tempFlag = 0;
	if ( data.length > 0 )
	{	
		tempFlag = 1;		
		otherResourcesHtml += data;
	}	
	otherResourcesHtml += "";
	if ( tempFlag == 0)	
	{
		document.getElementById("queryResultsDivId").innerHTML = "No data found!";	//If the content is empty, then no need to show its component
		return;															
	}
				
	document.getElementById("queryResultsDivId").innerHTML = otherResourcesHtml;	    
	
	hidePagination();			//pagination.js
	
    printer.hidePrinterPageLink();
	
	searchResults.emptySearchResultsDetails();
	searchResults.showSearchResultsBorder();
	
	components.penel.hideMonthIssues();  /* Close notification/dialog content after getting the serach results */
	components.penel.hideCurrentIssues();
	components.penel.hideTopArticle();
	
	historyIsItResultDetails = 0;
	parityHistory.setInHistory();       
}

/**
Gets the static html page of advertisement component
*/
function getAds(htmlFileURL)
{
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
                components.penel.renderAds(ajaxRequest.responseText);	            
			} 
			else
			{	
                hideTopNotification();
                alert("Unable to get ads page: " + ajaxRequest.responseText);                
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/ads/mainAds.htm", true);		
	ajaxRequest.send(null);
}

/**
Renders and loads the advertisement panel component from the server

@param data Plain html data of advertisement component
*/
function renderAds(data)
{	
    if ( data.length > 0 )
	{					
		document.getElementById("rightPanelAdsDiv").innerHTML = data;		
	}
	else
	{
		document.getElementById("rightPanelAdsDiv").innerHTML = "No data found!";
	}
	components.penel.showAds();
	hideTopNotification();		
}

/**
Gets the static html page of help main
*/
function getHelpPages(htmlFileURL)
{
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
			    components.penel.renderHTMLPage( ajaxRequest.responseText );
			    
			    printer.printerPageType = 3;	
	            printer.showPrinterPageLink();	
	            historyIsItResultDetails = 0;
	            parityHistory.setInHistory();
			} 
			else 
			{	
                hideTopNotification();
                alert("Unable to get e-publication page!: " + ajaxRequest.responseText);                
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + htmlFileURL, true);		
	ajaxRequest.send(null);
}

/**
Gets the static html page of help links
*/
function getHelpLinkPages(helpPageLinkURL)
{
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
			    document.getElementById('helpLinkPageResult').innerHTML = "<HR style='border-TOP: 1PX SOLID STEELBLUE; HEIGHT: 1PX; margin: 0PX; padding: 0PX;'; />";	
	            document.getElementById('helpLinkPageResult').innerHTML += ajaxRequest.responseText;	            
	            historyIsItResultDetails = 0;
	            parityHistory.setInHistory();
			} 
			else 
			{	
                hideTopNotification();
                alert("Unable to get e-publication page!: " + ajaxRequest.responseText);
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + helpPageLinkURL, true);		
	ajaxRequest.send(null);	
}

/**
Gets the static html page of other resources
*/
function getNewsLetters(htmlFileURL)
{	
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
			    components.penel.renderHTMLPage( ajaxRequest.responseText );  
			} 
			else 
			{	
                hideTopNotification();
                alert("Unable to get e-publication page!: " + ajaxRequest.responseText);                
			}
		} 
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + htmlFileURL, true);		
	ajaxRequest.send(null);
}

/**
Gets the static html page of other resources
*/
function getOnlineTutorials(htmlFileURL)
{
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
			    components.penel.renderHTMLPage( ajaxRequest.responseText );			    
			} 
			else 
			{	
                hideTopNotification();
                alert("Unable to get online tutorials page: " + ajaxRequest.responseText);                
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + htmlFileURL, true);		
	ajaxRequest.send(null);
}

/**
Gets the static html page of other resources
*/
function getOtherResources(htmlFileURL)
{
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
			    components.penel.renderHTMLPage( ajaxRequest.responseText );			    
			} 
			else 
			{	
                hideTopNotification();
                alert("Unable to get online tutorials page: " + ajaxRequest.responseText);                
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + htmlFileURL, true);		
	ajaxRequest.send(null);
}

/**
Gets the static html page of shopping cart checkout component
*/
function getShoppingCartCheckoutHTMLPage(htmlFileURL, jsonObject, articleURL)
{
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
	            hideTopNotification();
	            components.penel.renderHTMLPage(ajaxRequest.responseText,articleURL);	
	            access.shoppingCart.renderGetShoppingCartCheckout(jsonObject, "checkout",articleURL);	  	    
			} 
			else
			{	
                hideTopNotification();
                alert("Unable to get ads page: " + ajaxRequest.responseText);                
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + htmlFileURL, true);		
	ajaxRequest.send(null);
}

/**
Gets the dynamic top most viewed articles from the sever
*/
function getHTMLPage(htmlFileURL)
{
	var plaiHTMLData = "";
	var ajaxRequest = zXmlHttp.createRequest();	
	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    plaiHTMLData = ajaxRequest.responseText;									                
			} 
			else 
			{	
                alert("Unable to get response!: " + ajaxRequest.responseText);             	
			}
		}
	}
	ajaxRequest.open("GET", ROOT_URL + "html/" + htmlFileURL, false);		
	ajaxRequest.send(null);	
	return plaiHTMLData;
}

/**
Gets the dynamic top most viewed articles from the sever
*/
function renderHTMLPage(htmlData, articleURL)
{
	
	document.getElementById("queryResultsDivId").innerHTML = htmlData;
	
	if(articleURL!=null)
	    return;
	    
	hidePagination();			//pagination.js
	
	searchResults.showSearchResultsBorder();
	searchResults.emptySearchResultsDetails();
	
	components.penel.hideMonthIssues();  // Close notification/dialog content after getting the serach results 
	components.penel.hideCurrentIssues();
	components.penel.hideTopArticle();	
}

/**
Get the static feedback html page
*/
function getFeedbackHTMLPage()
{
    if ( loginStatus == false )
	{
	    //alert("Please login to give feedback!");
	    tempData = "<DIV class='myComSocContent monthIssue'>";
        tempData += "<img src=" + ROOT_URL + "images/alertAttention.gif /> Only ComSoc Members can send feedback.<BR><BR>";  	
        tempData += "If you are a ComSoc member please <A href=http://dl.comsoc.org/comsocdl/DRM-authentication.action?path=LoginUser&src=feedback>Login</A><BR>";
        tempData += "</DIV>";
        tempData = "<BR>" + components.getPlainFormHTMLComponent("Login", tempData) + "<BR>" ;
        document.getElementById("queryResultsDivId").innerHTML = tempData;
        searchResults.hideAllPanels();
        historyIsItResultDetails = 0;
	    parityHistory.setInHistory();
	    printer.showPrinterPageLink(); /*It inturn calls or shows history link */
	    return;	 
	} 
	
	showTopNotification();
	var ajaxRequest = zXmlHttp.createRequest();	
	
	ajaxRequest.onreadystatechange = function()
	{
	    if(ajaxRequest.readyState == 4)
		{
		    if (ajaxRequest.status == 200) 
			{
			    hideTopNotification();
			    components.penel.renderFeedbackHTMLPage(ajaxRequest.responseText);
			} 
			else
			{	
                hideTopNotification();
                alert("Unable to get feedback page");                
			}				
		}       
	}
	ajaxRequest.open("GET", ROOT_URL + "html/global/userFeedback.htm", true);		
	ajaxRequest.send(null);	
}

/**
Get the static feedback html page

@param feedbackHtmlData HTML content of feedback page
*/
function renderFeedbackHTMLPage( feedbackHtmlData )
{
    loadJsCssFile("js/feedback.js", "js");
    document.getElementById("queryResultsDivId").innerHTML = feedbackHtmlData;	    
	
	hidePagination();
	
	searchResults.showSearchResultsBorder();
	searchResults.emptySearchResultsDetails();
	
	components.penel.hideMonthIssues();  // Close notification/dialog content after getting the serach results 
	components.penel.hideCurrentIssues();
	components.penel.hideTopArticle();		
	components.penel.hideAds();	
	
	printer.hidePrinterPageLink();
	
	historyIsItResultDetails = 0;
	parityHistory.setInHistory();
}

/**
Hides the month issues 
*/
function hideMonthIssues()
{
    if ( document.getElementById("currentMonthIssueDivId") )
	    document.getElementById("currentMonthIssueDivId").style.display = "none";
}

/**
Hides the month issues 
*/
function hideCurrentIssues()
{
    if ( document.getElementById("rightPanelIssueBoxOuterDiv") )
	    document.getElementById("rightPanelIssueBoxOuterDiv").style.display = "none";
}

/**
Hides the month issues 
*/
function hideTopArticle()
{
    if ( document.getElementById("topArticlesAndIssuesDivID") )
	    document.getElementById("topArticlesAndIssuesDivID").style.display = "none";
}

/**
Hides the advertisement component
*/
function hideAds()
{
    if ( document.getElementById("rightPanelAdsDiv") )
	    document.getElementById("rightPanelAdsDiv").style.display = "none";
}

/**
Show the month issues panel
*/
function showMonthIssues()
{
    if ( document.getElementById("currentMonthIssueDivId") )
	    document.getElementById("currentMonthIssueDivId").style.display = '';	
}

/**
Show the current issues panel
*/
function showCurrentIssues()
{
	if ( document.getElementById("rightPanelIssueBoxOuterDiv").style )
	    document.getElementById("rightPanelIssueBoxOuterDiv").style.display = '';
}

/**
Show the top articles panel
*/
function showTopArticle()
{
    if ( document.getElementById("topArticlesAndIssuesDivID") )
	    document.getElementById("topArticlesAndIssuesDivID").style.display = ''; //display none issues
}

/**
Shows the advertisement component
*/
function showAds()
{
    if ( document.getElementById("rightPanelAdsDiv") )
	    document.getElementById("rightPanelAdsDiv").style.display = ''; 
}

/**
Shows the advertisement component
*/
function showBanner()
{
    if ( document.getElementById("rightPanelBannerDiv") )
	   document.getElementById("rightPanelBannerDiv").style.display = ''; 
}

/**
Hides the advertisement component
*/
function hideBanner()
{
    if ( document.getElementById("rightPanelBannerDiv") )
	   document.getElementById("rightPanelBannerDiv").style.display = "none";
}

/**
Loads the banner component
*/
function loadBanner()
{
var bannerHTML;
components.penel.showBanner();
    if ( document.getElementById("rightPanelBannerDiv") )
	{
	    bannerHTML = document.getElementById("rightPanelBannerDiv").innerHTML;		
	    document.getElementById("rightPanelBannerDiv").innerHTML = bannerHTML;
	}
}

components.penel = new panel;	/*	<< IMPORTANT!!!  INSTANTIATION OF INNER PANEL CLASS TO SUPER CLASS COMPONENT	*/
/********************************************** END **************************************************
 * Panel class getting serving for super class: component *
*****************************************************************************************************/

