function set_focus(d, el)
{
	if (!el) return;

	if ((x = findObj(e, d)) != null) {
		if (x.focus)
			x.focus();
		if (x.select)
			x.select();
	}
}

function syn(s)
{
	if (!s || !s.options || !s.options.length) 
		return false;
	
	if (s.options[s.options.length - 1].selected)
		s.options[s.options.length - 1].selected = false;
}

function plesk_scroll(w)
{
	var nav = navigator.appName;
	var ver = parseInt(navigator.appVersion);
	if ((nav.indexOf('Netscape') != -1) && (ver == 4) && w.document.location.hash) {
		var aname = w.document.location.hash.substr(1);
		var an = w.document.anchors[aname];
		if (an)
			w.scrollTo(an.x, an.y);
	}
}

function MM_reloadPage(init)	// reloads the window if Nav4 resized
{
	if (init == true)
		with (navigator) {
			if ((appName == 'Netscape') && (parseInt(appVersion) == 4)) {
				document.MM_pgW = innerWidth;
				document.MM_pgH = innerHeight;
				onresize = MM_reloadPage;
			}
		}
	else
		if ((innerWidth != document.MM_pgW) || (innerHeight != document.MM_pgH))
			location.reload();
}

function getButtonName(name)
{
    re = /^bname_([A-Za-z0-9-]+)$/;
    return name.replace(re,"$1");
}


function isFramed()
{
	if (opt_no_frames)
		return false;
	else
		return !("undefined" == typeof top.fraMain || "undefined" == typeof top.fraMain.fraLeftFrame);
}

function topLoaded()
{
	return !("undefined" == typeof top);
}

function workFrameLoaded()
{
	if (opt_no_frames)
		return true;
	else
		return topLoaded() && !("undefined" == typeof top.fraMain ||
			"undefined" == typeof top.fraMain.document);
}

function topFrameLoaded()
{
	if (opt_no_frames)
		return false;
	else
		return topLoaded();
}

function leftFrameLoaded()
{
	if (opt_no_frames)
		return false;
	else
		return topLoaded() && !("undefined" == typeof top.fraLeftFrame ||
			"undefined" == typeof top.fraLeftFrame.document);
}

function conhelpLoaded()
{
	if (opt_no_frames)
		return false;
	else
		return leftFrameLoaded() && !("undefined" == typeof top.fraLeftFrame.document.forms[0] ||
		"undefined" == typeof top.fraLeftFrame._c);
}

function contextLoaded()
{
	if (opt_no_frames)
		return false;
	else
		return topLoaded() && !("undefined" == typeof top._context);
}

function helpPrefixLoaded()
{
	if (opt_no_frames)
		return false;
	else
		return topLoaded() && !("undefined" == typeof top._help_prefix);
}

function helpPermLoaded()
{
	if (opt_no_frames)
		return false;
	else
		return topLoaded() && !("undefined" == typeof top._helpPerm);
}

function setActiveButtonByName(name)
{
	if (!conhelpLoaded())
		return false;
	
	return top.fraLeftFrame.setActiveNode(name);
}
	
function setActiveButton(o)
{
	if (!conhelpLoaded())
		return false;
	
	return top.fraLeftFrame.setActiveNode(o.id);
}
	
function setScrollInIE()
{
	if (!leftFrameLoaded())
		return;
	var navL = top.fraLeftFrame.fraDeeptree.document.getElementById('pageLayout');
	try {
	top.fraLeftFrame.fraDeeptree.document.body.scroll = (navL.clientHeight > top.fraLeftFrame.fraDeeptree.document.documentElement.clientHeight || navL.clientWidth > top.fraLeftFrame.fraDeeptree.document.documentElement.clientWidth) ? 'yes' : 'no';
	}catch(e){}
}

//---------------------------------- redirect

function get_workframe()
{
	try {
		if (top.fraMain.visibilityContent && !top.fraMain.removeMe)
			return top.fraMain.fraRightFrame.fraContent.visibilityContent;
	} catch (e) {}
	if (top.fraMain) {
		return top.fraMain.fraRightFrame.fraContent;
	}else{
		return this;
	}
}

function go_to(href)
{
	return go_to_workframe(href);
}

function go_to_workframe(href)
{
	return _go_to(isFramed() ? get_workframe() : this, href);
}

function refresh_leftframe()
{
	if (opt_integrated_mode)
		return go_to_leftframe("/vz/cp/psa/menu");
	else
		return go_to_leftframe("/left.php3");
}

function go_to_leftframe(href)
{
	if (!leftFrameLoaded())
		return false;
	else
		return _go_to(top.fraLeftFrame, href);
}

function refresh_topframe()

{
	return go_to_topframe("/top.php3");
}

function go_to_topframe(href)
{
	if (!topFrameLoaded())
		return false;
	else
		return _go_to(top.topFrame, href);
}

function go_to_top(href)
{
	if (!topLoaded())
		return false;
	else
		return _go_to(top, href);
}

function _go_to(target, href)
{
	target.location = href;
	return false;
}

//---------------------------------- conhelp & help

function SetConHelp(conhelp_name, direct)
{
	if (!conhelpLoaded())
		return false;
	return top.fraLeftFrame._SetConHelp(conhelp_name, direct);
}

function SetContext(context, conhelp)
{
	SetHelpModule('');

	if (opt_integrated_mode && !opt_no_frames)
		return top.SetContext(context, conhelp)

	if (!contextLoaded())
		return false;
	if (context)
		top._context = context;
	top._conhelp = conhelp;
	return SetConHelp();
}

function SetHelpModule(module)
{
	if (opt_integrated_mode && !opt_no_frames && top.SetHelpModule)
		return top.SetHelpModule(module)

	try {
		top._help_module = module;
	} catch (e) {
		return false;
	}

	return true;
}

function GetContext()
{
	if (!contextLoaded())
		return false;
	return top._context;
}

function GetConhelp()
{
	if (!contextLoaded())
		return false;
	return top._conhelp;
}

function GetHelpPrefix()
{
	if (!helpPrefixLoaded())
		return false;
	return top._help_prefix;
}

function GetHelpModule()
{
	try {
		return top._help_module;
	} catch (e) {
		return false;
	}
}

function getHelpPerm()
{
	if (!helpPermLoaded())
		return false;
	return top._helpPerm;
}

function resetHelpPerm()
{
	if (!helpPermLoaded())
		return false;
	top._helpPerm = true;
	return true;
}

function denyHelpPerm()
{
	if (!helpPermLoaded())
		return false;
	top._helpPerm = false;
	return true;
}

function mouse_move(context, direct)
{
	if (opt_no_frames || !opt_integrated_mode)
		SetConHelp(context, direct);
	else
		top.mouse_move(context);
}

function lsetup_handler(e)
{
	lsetup(this);
	return true;
}

function lsetup(target)
{
	
	try {
		if (!target)
			target = this;

		var o_set = target.document.getElementById('loaderContainerWH');
		var o_getH = target.document.getElementsByTagName('BODY')[0];

		o_set.style.height = o_getH.scrollHeight;
	} catch (e) {
		//alert(e);
	}
}

function lon(target)
{
	try {
		if (parent.visibilityToolbar)
			parent.visibilityToolbar.set_display("standbyDisplayNoControls");
	} catch (e) {}

	try {
		if (!target)
			target = this;
		lsetup(target);

		if (!target._lon_disabled_arr)
			target._lon_disabled_arr = new Array();
		else if (target._lon_disabled_arr.length > 0)
			return true;

		target.document.getElementById("loaderContainer").style.display = "";
		var select_arr = target.document.getElementsByTagName("select");

		for (var i = 0; i < select_arr.length; i++) {
			if (select_arr[i].disabled)
				continue;

			select_arr[i].disabled = true;
			_lon_disabled_arr.pop(select_arr[i]);
			var clone = target.document.createElement("input");
			clone.type = "hidden";
			clone.name = select_arr[i].name;
			var values = new Array();
			for (var n = 0; n < select_arr[i].length; n++) {
				if (select_arr[i][n].selected) {
					values[values.length] = select_arr[i][n].value;
				}
			}
			clone.value = values.join(",");
			select_arr[i].parentNode.insertBefore(clone, select_arr[i]);
		}
	} catch (e) {
		return false;
	}
	return true;
}

function _lon(target) {
	try {
		if (!target)
			target = this;

		oLoader = target.document.getElementById("loader");
		oBody = target.document.getElementsByTagName("body")[0];
		if (oLoader || oBody) {
			zIndex = oLoader.style.zIndex;
			if ( zIndex == "" ) zIndex = oLoader.currentStyle.zIndex;
			zIndex = parseInt(zIndex);
			if (!isNaN(zIndex) && zIndex > 1) {
				sHiderID = oLoader.id + "SubLayer";
				oBody.insertAdjacentHTML("afterBegin", '<iframe src="javascript:false;" id="' + sHiderID + '" scroll="no" frameborder="0" style="position:absolute;visibility:hidden;border:0;top:0;left;0;width:0;height:0;background-color:#ccc;z-index:' + (zIndex - 1) + ';"></iframe>');
				oIframe = target.document.getElementById(sHiderID);
				oIframe.style.width = oLoader.offsetWidth + "px";
				oIframe.style.height = oLoader.offsetHeight + "px";
				oIframe.style.left = oLoader.offsetLeft + "px";
				oIframe.style.top = oLoader.offsetTop + "px";
				oIframe.style.visibility = "visible";
			}
		}
	} catch (e) {
		return false;
	}
	return true;
}

function loff(target)
{
	try {
		if (parent.visibilityToolbar) {
			parent.visibilityToolbar.set_display(visibilityCount
												 ? "standbyDisplay"
												 : "standbyDisplayNoControls");
		}
	} catch (e) {}

	try {
		if (!target)
			target = this;

		target.document.getElementById("loaderContainer").style.display = "none";

		if (target._lon_disabled_arr) {
			while(_lon_disabled_arr.legth > 0) {
				var select = _lon_disabled_arr.push();
				select.disabled = false;

				var clones_arr = target.document.getElementsByName(select.name);
				for (var n = 0; n < clones_arr.length; n++) {
					if ("hidden" == clones_arr[n].type)
						clones_arr[n].parent.removeChild(clones_arr[n]);
				}
			}
		}
	} catch (e) {
		return false;
	}
	return true;
}

function lsubmit(f)
{
	try {
		if (f.lock.value == "true")
			return false;
		f.lock.value = "true";
	} catch (e) {
	}

	lon();

	try {
		f.submit(f);
	} catch (e) {
		loff();
		return false;
	}
	return true;
}

function hasClass(element, className)
{
    var classes = element.className.split(' ');
	for (var i in classes) {
		if (classes[i] == className)
			return true;
	}
	return false;
}

function addClass(element, className)
{
	if (!hasClass(element, className))
		element.className = (element.className == '' ? className : element.className + ' ' + className);
}

function removeClass(element, className)
{
	var newValue = '';
    var classes = element.className.split(' ');
	for (var i in classes) {
		if (classes[i] != className)
			newValue += newValue.length ? ' ' + classes[i] : classes[i];
	}
	element.className = newValue;
}

MM_reloadPage(true);
