// Xml data sources
var __casestudy = "casestudy";
var __manual = "manual";
var __other = "other";
var __book = "book";
var __article= "article";

//**************************************************************************************
// Object:		Publication
// Inherits:	None
Publication = function() {
	this.isOpen = false;	
	this.contentDiv;
		
} // end object

	Publication.prototype.open = function(contentDiv) {
		if (!contentDiv || !CDA.find(contentDiv)){alert("UNEXPECTED: 'contentDiv' either requires a value or does not exist.");return;} // end if 

		this.contentDiv = CDA.find(contentDiv);
		this.loadTabNav();
		this.isOpen = true;
						
	} // end method
	
	Publication.prototype.loadTabNav = function() {
		/// Returns what function to call to display text in content div
		TabNav.prototype.getEvalJsFunc = function(anchorLoopIndex) { // method override
			
			switch (anchorLoopIndex) {
				case 0: // General Tab
					return "CDA.Publication.showBook()";
								
				case 1: // Project Document Tab
					return "CDA.Publication.showPublication(__casestudy)";
				case 2: // Books						
					return "CDA.Publication.showArticle()";
				
				case 3: // Articles
					return "CDA.Publication.showPublication(__manual)";
				
				case 4: // Countries
					return "CDA.Publication.showPublication(__other)";
								
				default:
					break;
			
			} // end switch
			return null;
		} // end override
		
		var tabMenu = new TabNav();		
		tabMenu.load("maintab");
	} // end method
	
	Publication.prototype.showPublication = function(pubtype) {		
		if (!this.isOpen){alert("UNEXPECTED: Publication must be opened first prior to calling showDesc()");return;} // end if 
		this.clearContent();		
		var dt=null;
		switch (pubtype) {
			case __casestudy:			
				dt = new CaseStudy( null, "datatable", false );				
				break;
			
			case __manual:
				dt = new Manual( null, "datatable", false );
				break;
				
			case __other:
				dt = new Other( null, "datatable", false );
				break;
				
			default:				
				alert("ERROR: Should not be here");return;
						
		} // end switch	
		
		dt.parent = this.contentDiv;
		dt.show();
		this.resizeContent();	        
	} // end method
	
	Publication.prototype.showArticle = function() {
		
		if (!this.isOpen){alert("UNEXPECTED: Publication must be opened first prior to calling showDesc()");return;} // end if 
		this.clearContent();
		var art = new Article( null, "datatable", false );
		art.parent = this.contentDiv;
		art.show();
		this.resizeContent();
	        
	} // end method
	
	Publication.prototype.showBook = function() {
		
		if (!this.isOpen){alert("UNEXPECTED: Publication must be opened first prior to calling showDesc()");return;} // end if 
		this.clearContent();
		var book = new Book( null, "datatable", false );
		book.parent = this.contentDiv;
		book.show();
		this.resizeContent();
	        
	} // end method
			
	Publication.prototype.clearContent = function(datasource, dataNode, noDataMessage) {
		this.contentDiv.innerHTML = "";
	 } // end method
	
	Publication.prototype.resizeContent = function(datasource, dataNode, noDataMessage) { 
		CDA.Page.resizeBody();
	} // end method
	
	Publication.prototype.getPubData= function(descDivId) {
		if (!this.isOpen){alert("UNEXPECTED: Publication must be opened first prior to calling showDesc()");return;} // end if 
		CDA.Html.cssDisplay(descDivId, "none");	
		CDA.Page.resizeBody();				
	} // end method
	
	
//**************************************************************************************
// Object:		ProjNestedNav
// Inherits:	NestedNav (js/NestedNav.js)
ProjNestedNav.prototype = new NestedNav();
ProjNestedNav.prototype.constructor=ProjNestedNav;
function ProjNestedNav(menuarray) {
		
	this.cssClass = "nnInnerTab";
	this.separator = new TextSeparator("|", "separator");
	this.anchors = menuarray;
			
} // end object

if(!window.CDA) {
	CDA=new Object();
} // end if

if(!window.CDA.Publication) {
	CDA.Publication=new Publication();
} // end if
	



