//<!--  ****************************************** 	-->
//<!--           		ZOOM 							-->
//<!--           Object definition					-->
//<!--  ****************************************** 	-->

//<!-- ================== DOMODULE & DOMODULES ==============  -->

//<!-- ------------- doModule --------------- -->
//<!-- // Module entity definition -->

function doModule (pId,pRefPage,pAlt,pSelected,pAllowed,pImageOn,pImageOff,pImageUp,pImageDisable,pRefHelp)
{
 // -------- Properties --------- 
 this.Id = pId;				// Unique Identifier Name
 this.refPage = pRefPage;	// reference HTM or ASP page to be loaded in the frMain frame
 this.alt = pAlt;	// reference HTM or ASP page to be loaded in the frMain frame
 this.selected = 0;			// Boolean that indicates if the module is selected or not.
 this.allowed = pAllowed;	// Boolean that indicates oif the module is accessible by the user.
 this.imageOn = pImageOn;	// Image displayed when the module is selected
 this.imageOff = pImageOff;  // Image displayed when the module is in back ground
 this.imageUp = pImageUp; 	// Image displayed when the module is overmoused.
 this.imageDisable = pImageDisable; // Image displayed when the module is not accessible.
 this.refHelp = pRefHelp; // Image displayed when the module is not accessible.
}

//<!-- ------------- doModules --------------- -->
// Modules collection definition. -->

function doModules ()
{
 // -------- Properties ---------  
 this.length=0;
 this.selected;
 
 // -------- Methods --------- 
 this.add = maddModule; 
 this.pos = mModulePos;
}

//<!-- ------------- maddModule --------------- --> 
// Add a new module item into the collection

function maddModule(pModule)
{
 var i; 
 var mModule = new doModule(pModule.Id, 							
							pModule.refPage,
							pModule.alt,
 							pModule.selected,
							pModule.allowed,
							pModule.imageOn,
							pModule.imageOff,
							pModule.imageUp,
							pModule.imageDisable,
							pModule.refHelp);
 this.length ++;
 i = this.length - 1;
 this[i] = mModule;
}
//<!-- ------------- mModulePos --------------- -->
// Return the position of the module within the Modules array.

function mModulePos (pModuleId)
{
var ModulePos = 0;
for (var i = 0; i < this.length; i++)
  {
  if (this[i].Id == pModuleId)
     ModulePos = 	i;
  }
return ModulePos;
}

function doGroups()
{
	this.length = 0;
	this.add = mAddGroup;
}

function mAddGroup(pGroupId, pGroupName)
{
	pGroup = new doGroup(pGroupId, pGroupName);
	this[this.length] = pGroup;
	this.length++;
}

function doGroup(pGroupId, pGroupName)
{
	this.m_GroupId = pGroupId;
	this.m_GroupName = pGroupName;
}


//<!-- ================== DOPROFILE ==============  -->
// Data Object doprofile 


function doProfile( )
{
 // -------- Properties --------- 
 this.Id = 0;
 this.name;
 this.login;
 this.password;
 this.defaultGroupId;
 this.corpId;
 this.organization;
 this.Currencies = new Array();
 this.CURL=""; 
 this.Groups = new doGroups();
 this.TCPIPAddress;
 this.newsPage;
 this.alias;
 this.tickerRef;
 this.customZNV;
 this.customReport;
 this.dateFormat;
 
 // -------- Method -------------- 
 this.connect = mConnectProfile; 
 this.changeGroup = mChangeProfileGroup;
 this.disconnect = mDisconnectProfile;
 this.save = mSaveProfile;
}
//<!-- ----------- mConnectProfile --------------- -->
// Perform a connection to the system
function mConnectProfile (pLogin,pPassword) {
var encPwd;  // ecripted password

encPwd = mEncript(pPassword);
top.frCache.location.href = '../../Modules/Login/UP_connection.ASP?login='+escape(pLogin)+'&pwd='+escape(encPwd);
}


//<!-- ----------- mConnectProfile --------------- -->
// Perform a connection to the system
function mChangeProfileGroup (pLogin,pPassword, pGroupId) {
var encPwd;  // ecripted password

encPwd = mEncript(pPassword);
alert ("Change Group " + pGroupId);
alert ( '../../Modules/Login/UP_connection.ASP?login='+escape(pLogin)+'&pwd='+escape(encPwd)+'&GroupId='+ pGroupId);
top.frCache.location.href = '../../Modules/Login/UP_connection.ASP?login='+escape(pLogin)+'&pwd='+escape(encPwd)+'&GroupId='+ pGroupId;
}

//<!-- ----------- mDisconnectProfile --------------- -->
function mDisconnectProfile (){
top.frCache.location.href = '../../Modules/Login/UP_disconnect.ASP?ProfileId='+this.Id;
}

//<!-- ----------- mSaveProfile --------------- -->
function mSaveProfile (pPassword,  pDefaultGroupId)
{
	var encPwd;  // ecripted password

	encPwd = mEncript(pPassword);
	top.frCache.location.href = '../../Modules/Profile/UP_Save.ASP?ProfileId='+escape(this.Id)+'&username='+escape(top.gProfile.login)+'&pwd='+escape(encPwd) +
		'&DefaultGroupId='+escape(pDefaultGroupId) + '&DateFormat=' + escape(this.dateFormat);	
}

function mEncript(str)
{
	var i, j, len, s2;
	var word;
	
	word = "Encription1";
	
	len = str.length;
	j=len;
	s2 = "";
	while (j>=0) {
		i = Math.round(10 * Math.random());
		s2 = s2 + str.charAt(j) + word.charAt(i);
		j = j-1;
	}
	
	// now add three random letters
	j=0;
	while (j<3) {
			i = Math.round(10 * Math.random());
			s2 = s2 + word.charAt(i);
			j++;
	}
	return s2;
}

