//<!--
//
// +-----------------------------------------------------------+
// | This file is part of Triton   CMS Engine                  |
// | Copyright (c) 2005 by Triton                              |
// +-----------------------------------------------------------+
// | Author: Alexander Shipilov <shipilov@pochta.ru>           |
// +-----------------------------------------------------------+
//
//   lib.js
//   28.06.2005 07:27:16
//

var bTrEnLibIsLoaded = true;

// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// convert all characters to lowercase to simplify testing
var agt = navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major  = parseInt(navigator.appVersion);
var is_minor  = parseFloat(navigator.appVersion);
var is_gecko  = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

function oCreateWindow(sURL)
	{
	var sTarget 		=	arguments[1] || "_blank";
	var iWidth 			=	arguments[2] || 600;
	var iHeight			=	arguments[3] || 500;
	var sScrollbars	=	arguments[4] || 'yes';
	var sResizable	=	arguments[5] || 'yes';
	var sStatus			=	arguments[6] || 'no';
	var sLocation		=	arguments[7] || 'no';
	var sToolbar		=	arguments[8] || 'no';
	var sMenubar		=	arguments[9] || 'no';
	var iLeft 			= (screen.availWidth - iWidth) / 2;
	var iTop				= (screen.availHeight - iHeight) / 2;
	// }}}

	if(sTarget == '_self') {
		window.location = sURL;
		}
	else {
		var oWindow = window.open(sURL, sTarget,
			'width=' + iWidth + ',height=' + iHeight + ',' +
			'left=' + iLeft + ',top=' + iTop + ',' +
			'menubar=' + sMenubar + ',resizable=' + sResizable + ',' +
			'status=' + sStatus + ',location='+sLocation+','+
			'toolbar=' + sToolbar + ',scrollbars=' + sScrollbars + ''
			);
		return oWindow;
		}
	}

function oMW(sURL)
	{
	var oParams = arguments[1] || {};
	oCreateWindow(sURL, oParams.target, oParams.width, oParams.height,
		oParams.scrollbars, oParams.resizable, oParams.status, oParams.location,
		oParams.toolbar, oParams.menubar);
	}

function iCalcOffset(oEl, sPos) {
	var iOffset = 0;
	var sPos = "offset" + sPos;
	while(oEl) {		
		if(oEl[sPos])
			iOffset += oEl[sPos];
		oEl = oEl.offsetParent;
		}
	return iOffset;
	}
function vShovHideSearch(oButton) {
	var iX = iCalcOffset(oButton, "Left");
	var iY = iCalcOffset(oButton, "Top");
	oSearch = document.getElementById("searchDiv");
	oSearch.style.left = (iX - 120)+ "px";
	oSearch.style.top = (iY + 25)+ "px";
	oSearch.style.display = !oSearch.style.display ? "block" : "";
	}

function vMenu(sId) {
	DynarchMenu.setup(sId, {
		vertical: true,
		tooltips: true,
		shadows: [4, 4],
		separator: true,
		dx: 2,
		timeout: 300
		});	
	}
function vSw(oEl, sAtrr, sValue) {
	oEl[sAtrr] = sValue;
	}



var oDIV = null;
var sGlUID = 0;
function vShowHideWord(sUID) {
	if(sGlUID != sUID) {
		if(oDIV)
			oDIV.style.display = "none";
		sGlUID = sUID;
		}
	if(oDIV = document.getElementById(sUID))
		oDIV.style.display = oDIV.style.display == "none" ? "" : "none";
	window.location = '#' + sUID + 'A';
	}

var sA = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-@_:';
var sB = '1a2b3c4d5e6f7g8h9i0jklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=+/#';

function sD(sText) {
  sText = unescape(sText);
  sText = sText.replace(/./ig, function($0) {  	
  	return sA.charAt(sB.indexOf($0));
  	});
	return sText;
	}

function vSM(sMail) {
	window.location.href = sD(sMail);
	}

//-->