// --  ****************************************** 	-->
// --           Zoom N View							-->
// --           Object definition					-->
// --  ****************************************** 	-->


// --  ****************************************** 	-->
// -- 				NODES 							-->
// --  ****************************************** 	-->
// -- ------------- doNode --------------- -->
// Node entity definition

function doNode (pID, pParentID, pName, pType, pTemplateID)
{
 // -------- Properties --------- 
 this.ID = pID;				// Unique Identifier Name
 this.parentID = pParentID;	// Parent No in the Tree. 0 if no Parent
 this.name = pName;					// User-friendly name of the node
 this.type = pType;			// type (ROOT, ZOOM , VIEW or FOLDER)
 this.templateID = pTemplateID;		// ID of the template that belongs the report to.
}

// -- ------------- doNodes --------------- -->
// Nodes collection definition.

function doNodes ()
{
 // -------- Properties ---------  
 this.length=0; 
 this.selected;

 // -------- Methods --------- 
 this.add = maddNode; 
 this.clear = mclearNodes; 
 this.node = mnodeNode;
 this.select = mselectNode;

}

// -- ------------- mnodeNodes --------------- --> 
// select the given ID Node in the collection.
function mselectNode(pID) {
var intSelected = 0;
for (var i = 0; i < this.length; i++) 
	if (this[i].ID  == pID) {
		this.selected =  this[i];
		intSelected =1;		
	}
return 	intSelected;
}	

// -- ------------- mnodeNodes --------------- --> 
// return the node from the collection by passing its ID
function mnodeNode(pID) {
var LocatedNode;
for (var i = 0; i < this.length; i++) 
	if (this[i].ID  == pID) {
		LocatedNode =  this[i];
		}
return LocatedNode;
}	

// -- ------------- maddNode --------------- --> 
// Add a new node item into the collection

function maddNode(pID, pParentID,pName, pType , pTemplateID)
{
var i; 
var mNode = new doNode;

mNode.ID = pID;
mNode.parentID = pParentID;
mNode.selected = 0; 
mNode.name = pName;
mNode.type = pType;
mNode.templateID = pTemplateID;

 this.length ++;
 i = this.length - 1;
 this[i] = mNode;
}

////<!-- ------------- mclearNodes --------------- --> 
// Remove all the item of the collection
function mclearNodes ()
{
for (var i = 0; i < this.length; i++)
	this[i] = null;
this.length = 0;
}




// --  ****************************************** 	-->
// -- 				TEMPLATES						-->
// --  ****************************************** 	-->

// -- ------------- doTemplate --------------- -->
// Template entity definition

function doTemplate (pID, pName, pIcon)
{
 // -------- Properties --------- 
 this.ID = pID;		// Unique Identifier Number
 this.name = pName;					// Name displayed to the user.
 this.icon = pIcon;					//  icon displayed to the user.
}

// -- ------------- doTemplates --------------- -->
// Template collection definition.
function doTemplates ()
{
 // -------- Properties ---------  
 this.length=0;
 
 // -------- Methods --------- 
 this.add = maddTemplate; 
 this.clear = mclearTemplates; 
}

// -- ------------- maddTemplate --------------- --> 
// Add a new template item into the collection
function maddTemplate(pID, pName, pIcon)
{
var i; 
var mTemplate = new doTemplate;


mTemplate.ID = pID;
mTemplate.name = pName;
mTemplate.icon = pIcon;

 this.length ++;
 i = this.length - 1;
 this[i] = mTemplate;
}

// -- ------------- mclearTemplates --------------- --> 
// Remove all the item of the collection
function mclearTemplates ()
{
for (var i = 0; i < this.length; i++)
	this[i] = null;
this.length = 0;
}






function doDateRange (pCode, pDisplayName, pPeroidType )
{
 // -------- Properties --------- 
 this.ID = pCode;				// DateRange Code
 this.name = pDisplayName;				// User-friendly name of the daterange
 this.periodType = pPeroidType
}

// -- ------------- doDateRanges --------------- -->
// daterange collection definition.

function doDateRanges ()
{
 // -------- Properties ---------  
 this.length=0; 
 this.selected;

 // -------- Methods --------- 
 this.add = maddDateRange; 
 this.clear = mclearItems; 
 this.daterange = mGetDateRange;
 this.select = mselectItem;

}

// -- ------------- mnodeNodes --------------- --> 
// select the given ID Node in the collection.
function mselectItem(pID) {
var intSelected = 0;
for (var i = 0; i < this.length; i++) 
	if (this[i].ID  == pID) {
		this.selected =  this[i];
		intSelected =1;		
	}
return 	intSelected;
}	

// -- ------------- mnodeDateRanges --------------- --> 
// return the node from the collection by passing its ID
function mGetDateRange(pID) {
var LocatedDateRange;
for (var i = 0; i < this.length; i++) 
	if (this[i].ID  == pID) {
		LocatedDateRange =  this[i];
		}
return LocatedDateRange;
}	

// -- ------------- maddDateRange --------------- --> 
// Add a new daterange item into the collection

function maddDateRange(pID, pName, pPeriodType)
{

var i; 
var mDateRange = new doDateRange;

mDateRange.ID = pID;
mDateRange.name = pName;
mDateRange.periodType = pPeriodType;
mDateRange.selected = 0; 

 this.length ++;
 i = this.length - 1;
 this[i] = mDateRange;
}

////<!-- ------------- mclearDateRanges --------------- --> 
// Remove all the item of the collection
function mclearItems ()
{
for (var i = 0; i < this.length; i++)
	this[i] = null;
this.length = 0;
}


function doDateGranularity (pID, pGranularity )
{
 // -------- Properties --------- 
 this.ID = pID;						// Date ID
 this.Granularity = pGranularity;	// Time Granularity available in the cube
}

// -- ------------- doDateGranularities --------------- -->
// daterange collection definition.

function doDateGranularities ()
{
 // -------- Properties ---------  
 this.length=0; 
 this.selected;

 // -------- Methods --------- 
 this.add = maddDateGranularity; 
 this.clear = mclearItems; 
 this.dateGranularity = mGetDateGranularity;
 this.select = mselectItem;

}

// -- ------------- DateGranularity --------------- --> 

function mGetDateGranularity(pID) {
 var LocatedDateGranularity;
 for (var i = 0; i < this.length; i++) 
	if (this[i].ID  == pID) {
		LocatedDateGranularity =  this[i];
	}
 return LocatedDateGranularity;
}	

// -- ------------- maddDateGranularity --------------- --> 
// Add a new DateGranularity item into the collection

function maddDateGranularity(pID, pGranularity)
{
 var i; 
 var mDateGranularity = new doDateGranularity;

 mDateGranularity.ID = pID;
 mDateGranularity.Granularity = pGranularity;
 mDateGranularity.selected = 0; 

 this.length ++;
 i = this.length - 1;
 this[i] = mDateGranularity;
}



