//***************************************************************************
// Object objcertificate
//***************************************************************************
//---------------------------------------------------------------------------
// Object Creator

function objcertificate() {

	// properties
	this.bgcolor = "ffffff";
	this.systype = "prod";
	this.location = "";
	this.certtype = "";
	this.atid = "";
	this.officeid = "";
	this.cid = "";
	this.caname = "";
	this.luname = "";
	this.udpport = "";
	this.prttype = "";
	this.hwid = "";
	this.notbefore = "";
	this.notafter = "";
	this.deletable = false;
	this.sTempDelete = "";

	// collections & links
	//this.objauthority = new Array();

	// methods
	this.init = objcertificate_init;
	this.display = objcertificate_display;

	//this.destroy = objMonth_Destroy;
	this.debug = objcertificate_Debug;
	//this.updatepercentage = objMonth_UpdatePercentage;
	//this.buidsavequery = objMonth_BuidSaveQuery;
}

//---------------------------------------------------------------------------
// objcertificate_init
                     
function objcertificate_init(systype, location, atid, officeid, cid, luname, prttype, udpport, hwid, notbefore, notafter, deletable, certtype, sTempDelete) {

	this.systype = systype;
	this.location = location;
	this.atid = atid;
	this.officeid = officeid;
	this.cid = cid;
	this.luname = luname;
	this.udpport = udpport;
	this.prttype = prttype;
	this.hwid = hwid;
	this.notbefore = notbefore;
	this.notafter = notafter;
	this.deletable = deletable;
	this.certtype = certtype;
	this.sTempDelete = sTempDelete;
	
	if (this.systype.indexOf('Amadeus Subordicate Intranet Test CA') >= 0)	// 99F9FF   development
	{
		this.systype = "DEV";
		this.bgcolor = "99F9FF";
		this.caname = "PDT CA";
	}
	if (this.systype.indexOf('SGDEVROOTCA') >= 0)	// 99F9FF   development
	{
		this.systype = "DEV";
		this.bgcolor = "99F9FF";
		this.caname = "NCE DEV CA";
	}
	if (this.systype.indexOf('Amadeus Test Internet Subordinate CA') >= 0)	// 99F9FF   development
	{
		this.systype = "DEV";
		this.bgcolor = "99F9FF";
		this.caname = "FVT CA";
	}
	var subj = 'Amadeus Subordinate CA';
	var idx = this.systype.indexOf(subj)
	if (idx >= 0)	// FFFF00   current prod
	{
		// get CA number
		var CA_Number = this.systype.substr(idx + subj.length + 1);
		this.systype = "PROD";
		this.bgcolor = "FFFF00";
		this.caname = "PROD SUB CA" + CA_Number;
	}
	if (this.systype.indexOf('Amadeus Root CA') >= 0)	// FFFF00   current prod
	{
		this.systype = "PROD";
		this.bgcolor = "FFFF00";
		this.caname = "ROOT CA";
	}
	if (this.systype.indexOf('MIAV0P1') >= 0)		// FFFF99   old prod
	{
		this.systype = "PROD";
		this.bgcolor = "FFFF99";
		this.caname = "OLD PROD ROOT CA";
	}
	if (this.systype.indexOf('Amadeus Test Root Authority') >= 0)	// CCFF99   old test
	{
		this.systype = "TEST";
		this.bgcolor = "CCFF99";
		this.caname = "OLD TEST ROOT CA";
	}
	if (this.systype.indexOf('Amadeus Test Subordinate CA1') >= 0)	// CCFF99   old test
	{
		this.systype = "TEST";
		this.bgcolor = "CCFF99";
		this.caname = "OLD TEST SUB CA1";
	}
	if (this.systype.indexOf('Amadeus VistaTest CA') >= 0)	// CCFF99   old test
	{
		this.systype = "TEST";
		this.bgcolor = "CCFF99";
		this.caname = "OLD TEST CA";
	}
	if (this.systype.indexOf('Test Amadeus CA') >= 0)	// CCFF99   old test
	{
		this.systype = "TEST";
		this.bgcolor = "CCFF99";
		this.caname = "OLD TEST CA";
	}
	if (this.systype.indexOf('Amadeus TestSystem Subordinate CA') >= 0)	// 66FF00   current test
	{
		this.systype = "TEST";
		this.bgcolor = "66FF00";
		this.caname = "TEST SUB CA";
	}
}

//---------------------------------------------------------------------------
// objcertificate_display()
function objcertificate_display() {

	var str;
	var strlocation;
   
	if (this.location == 'CU')
		strlocation = '<TD align="center" width="40" class="CommonLine"><IMG width="32" src="images/CUCert.gif"></TD>';
	else
		strlocation = '<TD align="center" width="40" class="CommonLine"><IMG width="32" src="images/LMCert.gif"></TD>';
		
	str ="";
	if (this.certtype != '')
	{
		if ((this.certtype.indexOf('HWID') >= 0) || (this.certtype.indexOf('VIRTUAL') >= 0))
   		{
			str +='<TR bgcolor="'+ this.bgcolor +'">' + strlocation;
			str +='<TD align="center" width="70" class="CommonLine">' + this.certtype + '</TD>';
			if (this.certtype.indexOf('HWID') >= 0)
				str +='<TD align="center" class="CommonLine">' + this.hwid + '</TD><TD align="center" class="CommonLineRight">' + this.caname + '</TD></TR>';
			else
				str +='<TD align="center" class="CommonLine">&nbsp;</TD><TD align="center" class="CommonLineRight">' + this.caname + '</TD></TR>';
   		}
    		else
   		{
			str +='<TR bgcolor="'+ this.bgcolor +'">' + strlocation;
			str +='<TD align="center" width="70" class="CommonLine">' + this.certtype + '</TD>';
			str +='<TD align="center" width="90" class="CommonLine">' + this.atid + '</TD>';
			str +='<TD align="center" width="90" class="CommonLine">' + this.officeid + '</TD>';
			str +='<TD align="center" width="100" class="CommonLine">' + this.cid + '</TD>';
			str +='<TD align="center" width="140" class="CommonLine">' + this.caname + '</TD>';

			if (this.certtype.indexOf('3270') >= 0)
				str +='<TD align="center" width="100" class="CommonLine">' + this.luname + '</TD>';
			else
				if (this.certtype.indexOf('Printer') >= 0)
					str +='	<TD align="center" width="100" class="CommonLine">' + this.prttype + ' - ' + this.udpport + '</TD>';
				else
					str +='	<TD align="center" width="100" class="CommonLine">&nbsp;</TD>';
			str +='<TD align="center" width="140" class="CommonLine"><SPAN style="cursor:hand;" url="CertType.asp?cid=' + this.cid + '&bgc=' + this.bgcolor + '" onclick="openWindow(this.url)">&nbsp;&nbsp;<IMG src="images/ap.gif"></SPAN></TD>';

	   		if (this.deletable == true) 
				str += '<TD align="center" width="40" class="CommonLineRight">' + this.sTempDelete + '</TD></TR>';
   			else
				str += '<TD align="center" width="40" class="CommonLineRight">&nbsp;</TD></TR>';
   		}
	}
	return str; 
}

//---------------------------------------------------------------------------
//
function objcertificate_Debug() {

   alert('this.bgcolor            [' + this.bgcolor + ']\n' +
         'this.systype            [' + this.systype + ']\n' +
         'this.location           [' + this.location + ']\n' +
         'this.certtype           [' + this.certtype + ']\n' +
         'this.atid               [' + this.atid + ']\n' +
         'this.officeid           [' + this.officeid + ']\n' +
         'this.cid                [' + this.cid + ']\n' +
         'this.caname             [' + this.caname + ']\n' +
         'this.luname             [' + this.luname + ']\n' +
         'this.udpport            [' + this.udpport + ']\n' +
         'this.prttype            [' + this.prttype + ']\n' +
         'this.hwid               [' + this.hwid + ']\n' +
         'this.notbefore          [' + this.notbefore + ']\n' +
         'this.notafter           [' + this.notafter + ']\n' +
         'this.deletable          [' + this.deletable + ']\n');
}

// -----------------------------------------------------------
function getLineHeader(title, color)
{
	var strLine = '';
	strLine = '<TABLE id="CerTab" border="0" width="810" cellspacing="0" class="CommonTable">'
		+ '<TR bgcolor="' + color + '"><TD colspan="11" align="center" class="CommonLineRight"><B>' + title + '</B></TD></TR>'
		+ '<TR bgcolor="' + color + '"><TD align="center" class="CommonLine"><B>&nbsp;</B></TD><TD align="center" class="CommonLine"><B>Type</B></TD><TD align="center" class="CommonLine"><B>Atid</B></TD><TD align="center" class="CommonLine"><B>OfficeId</B></TD><TD align="center" class="CommonLine"><B>Cid</B></TD><TD align="center" class="CommonLine"><B>Authority</B></TD><TD align="center" class="CommonLine"><B>LU or Prt-UDPPort</B></TD><TD align="center" class="CommonLine"><B>Products</B></TD><TD align="center" class="CommonLineRight"><B>&nbsp;</B></TD></TR>'
	return strLine;
}

// -----------------------------------------------------------
function getCredentialsHeader(color)
{
	var strLine = '';
	strLine = '<TABLE id="CerTab" border="0" width="810" cellspacing="0" class="CommonTable">'
		+ '<TR bgcolor="' + color + '"><TD colspan="4" align="center" class="CommonLineRight"><B>SECURITY GATEWAY CREDENTIALS</B></TD></TR>'
		+ '<TR bgcolor="' + color + '"><TD align="center" class="CommonLine"><B>&nbsp;</B></TD><TD align="center" class="CommonLine"><B>Type</B></TD><TD align="center" class="CommonLine"><B>Hwid</B></TD><TD align="center" class="CommonLineRight"><B>Authority</B></TD></TR>'
	return strLine;
}

