var cms_core_c = function()
{
	this.explorer_b = (navigator.appName.indexOf('Microsoft') != -1);
}

/* ........................................... */

cms_core_c.prototype.getRandomInt = function(min_i, max_i)
{
	return Math.floor(Math.random() * (max_i - min_i + 1)) + min_i;
};

/* ........................................... */

cms_core_c.prototype.getFlash = function(id_s)
{
	return document.getElementById(id_s + '_' + (this.explorer_b ? 'object' : 'embed'));
};

/* ........................................... */

cms_core_c.prototype.getWindowHeight = function()
{
	return window.innerHeight ? window.innerHeight : document.body.clientHeight;
};

cms_core_c.prototype.getWindowBottom = function()
{
	return this.getWindowHeight() + (window.pageYOffset ? window.pageYOffset : (document[document.documentElement ? 'documentElement' : 'body'].scrollTop));
};

cms_core_c.prototype.getX = function(current_de)
{
	return current_de.offsetParent ? (current_de.offsetLeft + this.getX(current_de.offsetParent)) : current_de.offsetLeft;
};

cms_core_c.prototype.getY = function(current_de, out_of_body)
{
	out_of_body = out_of_body ? out_of_body : ({node: this.explorer_b ? current_de : current_de.parentNode}.node.nodeName.toLowerCase() == 'html');

	return (current_de.offsetParent ? (current_de.offsetTop + this.getY(current_de.offsetParent, out_of_body)) : current_de.offsetTop) - (out_of_body ? 0 : (this.explorer_b ? current_de.scrollTop : current_de.parentNode.scrollTop));
};

cms_core_c.prototype.getWidth = function(current_de)
{
	return current_de.offsetWidth;
};

cms_core_c.prototype.getHeight = function(current_de)
{
	return current_de.offsetHeight;
};

/* ........................................... */

cms_core_c.prototype.setMenu = function(parent_i, active_i)
{
	if (typeof top.menu_frame != 'undefined')
	{
		setRequest('top.menu_frame', '', {object: 'core__structure__menu__c', method: 'getMenu', parent: parent_i, active: active_i});
	}
};

cms_core_c.prototype.setMenuReload = function()
{
	top.menu_frame.location.reload(true);
};

cms_core_c.prototype.setTitle = function(content_s)
{
	if (typeof top.title_frame != 'undefined')
	{
		top.title_frame.setTitle(content_s);
	}
};

/* ........................................... */

cms_core_c.prototype.setBrowser = function(root_i, parent_i, name_s, title_s, folder_select_i, file_select_i, dialog_s, key_s)
{
	browser_result_structure_id_slot = document.editor_form.elements[name_s + '_structure_id'];
	browser_result_name_slot = document.editor_form.elements[name_s + '_name'];

	browser_result_folder_i = folder_select_i;
	browser_result_file_i = file_select_i;

	var dialog_s = (typeof dialog_s != 'undefined') ? (dialog_s ? dialog_s : 'generic_browser') : 'generic_browser';

	setWindowOpen('generic_browser_window', '', {object: 'core__dialog__frameset_c', method: 'getFrameset', name: dialog_s, src: escape('main.php?object=core__structure__browser__interface_c&amp;method=getInterface&amp;parent=' + parent_i + '&amp;dialog=' + dialog_s), s__root: root_i, s__src: 'INCLUDE/JS/SITE/PAGE/VERSION/LAYOUT/ELEMENT/INPUT/BROWSER/browser.js', s__key: ((typeof key_s != 'undefined') ? key_s : ''), title: title_s}, {width: 400, height: 400, resizable: 'yes'});
};

cms_core_c.prototype.setDialog = function(src_s, session_o, title_s, height_i, name_s, key_s)
{
	var name_s = (typeof name_s != 'undefined') ? (name_s ? name_s : 'generic_dialog') : 'generic_dialog';

	setWindowOpen('generic_dialog_window', '', {object: 'core__dialog__frameset_c', method: 'getFrameset', name: name_s, src: escape(src_s + '&amp;dialog=' + name_s), s__key: ((typeof key_s != 'undefined') ? key_s : ''), title: title_s}, {width: 400, height: height_i, resizable: 'yes'});
};

/* ........................................... */

var __iv_a = new Array();

function __setIntervalAction(index_i)
{
	if (__iv_a[index_i])
	{
		var argument_a = __iv_a[index_i].argument_a;

		var call_s = '__iv_a[index_i].method_o(';

		for (var i_i = 0; i_i < argument_a.length; i_i++)
		{
			call_s += 'argument_a[' + i_i + ']';
			call_s += (i_i < (argument_a.length - 1)) ? ',' : '';
		}

		call_s += ')';

		eval(call_s);

		if (__iv_a[index_i])
		{
			__iv_a[index_i].timer_id_i = setTimeout("__setIntervalAction(" + index_i + ")", __iv_a[index_i].interval_i);
		}
	}
}

function __setEnhancedInterval(method_o, interval_i)
{
	var index_i = __iv_a.length;

	__iv_a[index_i] = new Object();

	__iv_a[index_i].interval_i = interval_i;
	__iv_a[index_i].method_o = method_o;
	__iv_a[index_i].argument_a = new Array();

	for (var i_i = 2; i_i < arguments.length; i_i++)
	{
		__iv_a[index_i].argument_a[__iv_a[index_i].argument_a.length] = arguments[i_i];
	}

	__iv_a[index_i].timer_id_i = setTimeout('__setIntervalAction(' + index_i + ')', interval_i);

	return index_i + 1; // Add 1 so a true 0 interval won't return false.
}

function __setEnhancedClearInterval(index_i)
{
	var index_i = index_i - 1;

	if (__iv_a[index_i])
	{
		clearTimeout(__iv_a[index_i].timer_id_i);

		__iv_a[index_i] = null;
	}
}

function __setRegisterEnhancedInterval()
{
	window.setInterval = __setEnhancedInterval;
	window.clearInterval = __setEnhancedClearInterval;
}

__setRegisterEnhancedInterval();
