var prevLoginCnt = 0;
var prevPassCnt = 0;
var qsTimeout;
var isIE = isMozilla = isOpera = false;
var agentVer = false;
var geckoVer = false;

// Определение версии браузера 
if (navigator.userAgent.indexOf('Gecko') >= 0) {
	isMozilla = true;
	agentVer = parseInt(navigator.userAgent.substr(navigator.userAgent.indexOf("Gecko") + 6, 8));
	geckoVer = parseFloat(navigator.userAgent.substr(8, 3));
} else if (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.toLowerCase().indexOf('opera') < 0) {
	isIE = true;
	agentVer = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf("MSIE") + 5, 3));
} else if (navigator.appName.toLowerCase() == 'opera' || navigator.userAgent.toLowerCase().indexOf('opera') >= 0) {
	isOpera = true;
	agentVer = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera') + 6, 4));
}

function loginFocus(inp) { 
	if (!prevLoginCnt) {
		inp.value = '';
		prevLoginCnt++;
	}
}

function passFocus(inp) {
	if (!prevPassCnt) {
		var newInp = document.createElement('input');
		newInp.type = 'password';
		newInp.id = inp.id;
		newInp.name = inp.name;
		newInp.className = inp.className;
		document.getElementById('lFields').replaceChild(newInp, inp);
		newInp.focus();
		if (isIE) newInp.focus();
		prevPassCnt++;
	}
}

function tableStyle() {
	var contentBlock = document.getElementById('leftCol');
	var tables = contentBlock.getElementsByTagName('table');
	if (tables) {
		for (i = 0; i < tables.length; i++) {
			var table = tables[i];
			if (table.parentNode.tagName.toLowerCase() == 'fieldset') continue;

			for (j = 0; j < table.rows.length; j++) {
				if (j == 0) continue;
				if (j % 2 != 0) {
					table.rows[j].className = 'odd';
				}
			}
		}
	}
}

function quikStartMOver() {
	clearTimeout(qsTimeout);
	var sites = document.getElementById('sites');
	var sitesLayer = document.getElementById('sitesLayer');
	
	if (sites != null && sitesLayer != null) {
		var lTop = sites.clientHeight + sites.offsetParent.clientTop + sites.offsetTop;
		var lLeft = sites.offsetLeft; 
		
		if (isIE) {
			if (agentVer < 8) lTop -= 2;
			if (agentVer >= 7 && agentVer < 8) lLeft -= 1;
		}
		 
		sites.className = 'active';
		sitesLayer.style.display = 'block';
		sitesLayer.style.top = lTop;
		sitesLayer.style.left = lLeft;
	}
}

function quikStartMOut() {
	qsTimeout = setTimeout("_quikStartMOut()", 300);
}

function _quikStartMOut() {
	var sites = document.getElementById('sites');
	var sitesLayer = document.getElementById('sitesLayer');
	
	if (sites != null && sitesLayer != null) {
		sites.className = '';
		sitesLayer.style.display = 'none';
	}
}

