userAgent.load('rinix.Rollover.buildRollovers');
userAgent.load('rinix.Menu.buildRolloverMenus');
// userAgent.load('rinix.Menu.buildMenus');


//Popup handling functionality

var SPOOFING = 'SPOOFING_IDENTITY';
var TAMPERING = 'TAMPERING_WITH_DATA';
var DISCLOSURE = 'INFORMATION_DISCLOSURE';
var REPUDIATION = 'REPUDIATION';
var DENIAL = 'DENIAL_OF_SERVICE';
var ELEVATION = 'ELEVATION_OF_PRIVILEGES';

//This tag opens code fragment, over which a popup
//should be drawn.
function openPopupContainer() {
	document.write('<div style="position: relative; height: 7em;">');
}

//This tag closes popup code fragment.
function closePopupContainer() {
	document.write('</div>');
}

//This function places tags that handle popup positioning
//and receive popup content.
//Style is hardcoded, because it is taken from parent table 
//by default and cannot be overloaded by "class" attribute.
// top - popup top shift (defaults to 31)
// left - popup left shift (defaults to 220)
// width - popup maximum width (defaults to 200)
// height - popup maximum height (defaults to 300)
// bgcol - background color (defaults to white). Guarantees
//         the background color of the width*height square
function placePopupDestination(width, height, top, left, bgcol) {
	if (!top || top == null || top == '') {
		top = 31;
	}
	if (!left || left == null || left == '') {
		left = 220;
	}
	if (!width || width == null || width == '') {
		width = 200;
	}
	if (!height || height == null || height == '') {
		height = 300;
	}
	if (!bgcol || bgcol == null || bgcol == '') {
		bgcol = 'white';
	}
	document.write(
		'<div style="position: absolute; top: ' + top + 'px; left: ' + left + 'px;">' +
			'<div style="width: ' + width + 'px; height: ' + height + 'px;">' +
				'<div style="position: relative; background: ' + bgcol + ';" id="popupDest">' +
				'</div>' +
			'</div>' +
		'</div>');
}

//This function puts content into popup destination.
//Style is hardcoded, because it is taken from parent table 
//by default and cannot be overloaded by "class" attribute.
// width - popup width (defaults to 200)
// height - popup height (defaults to 300)
// titleText - text of the title (defaults to "Title", accepts HTML)
// bodyText - text of the contents (defaults to "Text", accepts HTML)
// titleStyle - style attribute of the title <div> may be overloaded
// bodyStyle - style attribute of the bode <div> may be overloaded
function showPopup(width,height,titleText,bodyText,titleStyle,bodyStyle) {
	if (!titleText || titleText == null || titleText == '') {
		titleText = 'Title';
	}
	if (!bodyText || bodyText == null || bodyText == '') {
		bodyText = 'Text';
	}
	if (!titleStyle || titleStyle == null || titleStyle == '') {
		titleStyle = 'position: absolute; padding: 4px; font-weight: bold; font-size: 11px; color: #2271DF; text-align: left; vertical-align: top;';
	}
	if (!bodyStyle || bodyStyle == null || bodyStyle == '') {
		bodyStyle = 'position: relative; top: 20px;';
	}
	if (!width || width == null || width == '') {
		width = 200;
	}
	if (!height || height == null || height == '') {
		height = 300;
	}

	pp = document.getElementById('popupDest');
	pp.innerHTML = 
	'<table width="' + width + 'px" height="' + height + 'px" border="0" cellspacing="0" cellpadding="0">'+
		'<tr>' +
			'<td>' +
				'<div style="' + titleStyle + '">' + titleText + '</div>' +
				'<div style="position: relative;" align="right"><a href="javascript:closePopup();" style="text-decoration: none;">X</a></div>' +
				'<div style="' + bodyStyle + '">' + bodyText + '</div>' +
			'</td>' +
			'</tr>' +
	'</table>';
	pp.style.visibility = 'visible';
}

//This function removes popup content from the destination.
function closePopup() {
	pp = document.getElementById('popupDest');
	pp.innerHTML = '';
	pp.style.visibility = 'hidden';
}

//This function shows popups for the security page.
function popup(type) {
	if (type == SPOOFING) {
		showPopup(200,150,'Spoofing identity','This is a key risk for systems when multiple users work in a single IT environment - application or database. You must be sure that no user can circumvent your security system and obtain ability to act as and instead of any other user.');
	}
	if (type == TAMPERING) {
		showPopup(200,140,'Tampering with data','Malicious users can avoid any client-side validation and change any data sent to them. It is critical that sensitive data received by an application from external clients is carefully checked out.');
	}
	if (type == DISCLOSURE) {
		showPopup(200,150,'Information disclosure','If application stores any private user data, it should protect this data from being accessed by someone else. Software protection should cover data storages, business logic of an application, all correspondence among the users and clients.');
	}
	if (type == REPUDIATION) {
		showPopup(200,180,'Repudiation','Some users may dispute the actions they have performed inside the software system. For example, they may attempt to repudiate an order or a funds transfer. To prevent losing money on such deceptions, it is essential for your application to have a strong auditing and traceability system.');
	}
	if (type == DENIAL) {
		showPopup(200,250,'Denial of service','Denial of service or DOS attacks are well known thanks to mass media news. Every year hackers attempt to disrupt the most popular Web sites. Unfair competitors may use these methods to complicate business processes of their competitors. They simultaneously send many requests to the target system, thereby greatly overloading that system\'s operative memory. As a result, the system becomes highly busy and cannot serve its users properly.');
	}
	if (type == ELEVATION) {
		showPopup(200,130,'Elevation of privileges','Many applications can be accessed and employed by various user groups. These applications must perfectly control the roles and permissions granted to each individual user.');
	}
}

// <<Back helper
function getHost(referrer) {
	return referrer.substring(7,referrer.indexOf('/',7));
}
