var d = document;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var modalbox;

var forAll = {
	ru_array: ['А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', 'Ї', 'І', 'Є', 'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я', 'Ї', 'І', 'Є'],
	en_array: ['A', 'B', 'V', 'G', 'D', 'E', 'E', 'Zh', 'Z', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Ch', 'Sh', 'Sch', '`', 'Y', '`', 'E', 'Yu', 'Ya', 'I', 'I', 'e', 'a', 'b', 'v', 'g', 'd', 'e', 'e', 'zh', 'z', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'sch', '`', 'y', '`', 'e', 'yu', 'ya', 'i', 'i', 'e'],
	terms_hint_bottom: null,
	http: null,
	hintObj:{tag:0,obj:null},
	hintPosSub:{top:5,right:5,bottom:5,left:5,leftDif:60,topDif:60},	// отступ от текста при розмещении: top, right, bottom, left, допуск до края leftDif, topDif
	timeCreateHint: 100,
	timeCloseHint: 300,
	slidePSTWait: 700,
	timeTagSearch: 700, showOne: 10,	// pic поиск
	hintAllText: Array(),
	colors: Array('ff0000', 'fe9711', 'fed600', 'bcde1e', '82d013'),
	golosPhone: Array('', 'Ужасно', 'Плохо', 'Средне', 'Хорошо', 'Отлично'),
	allPicSize: ['128x128', '128x160', '132x176', '176x208', '176x220', '208x208', '240x320', '240x400', '320x240', '320x480', '352x416', '480x800'],
	redSize: null
};

/*** выделение текста | пока забить, потом подправлю
dSelect = new function () {
	var self = this;
	var keys = {
			'selectionStart' : '__DSselectionStart',
			'selectionEnd' : '__DSselectionEnd'
	};
	this.setSelect = function (el, start, end){
//		alert(start+', '+end);
		el[keys.selectionStart] = parseInt(start);
		el[keys.selectionEnd] = parseInt(end);
	};
	this.getStart = function(el){
		var start;
		try {
			start = Math.abs(d.selection.createRange().moveStart('character', -100000000));
			try {
				var endReal = Math.abs(el.createTextRange().moveEnd('character', -100000000));
				var r = d.body.createTextRange();
				r.moveToElementText(el);
				var sTest = Math.abs(r.moveStart('character', -100000000));
				var eTest = Math.abs(r.moveEnd('character', -100000000));
				if (eTest - endReal == sTest){
					start -= sTest;
				};
			}catch(err){
			};
		}catch(e){
		};
		if (isNaN(start))
			try {
				start = el.selectionStart;
			}catch(e){
				start = -1;
			};
		return start < 1 ? (start == 0 ? 0 : (start * -1)) : start;
	};
	this.getEnd = function (el){
		var end;
		try {
			end = Math.abs(document.selection.createRange().moveEnd('character', -100000000));
			try {
				var endReal = Math.abs(el.createTextRange().moveEnd('character', -100000000));
				var r = d.body.createTextRange();
				r.moveToElementText(el);
				var sTest = Math.abs(r.moveStart('character', -100000000));
				var eTest = Math.abs(r.moveEnd('character', -100000000));
				if (eTest - endReal == sTest){
					end -= sTest;
				};
			}catch(err){
			};
		}catch(e){
		};
		if (isNaN(end))
			try {
				end = el.selectionEnd;
			}catch(e){
				end = -1;
			};
		return end < 1 ? (end == 0 ? 0 : (end * -1)) : end;
	};
	this.saveSelect = function(e){
		var el = e.srcElement||e.target;
		if (!el || !el.tagName)
			return false;
		var t = el.tagName.toLowerCase();
		if (t == 'textarea'){
			if ('undefined' == typeof el[keys.selectionStart])
				el[keys.selectionStart] = -1;
			if ('undefined' == typeof el[keys.selectionEnd])
				el[keys.selectionEnd] = -1;
			self.setSelect(el, self.getStart(el), self.getEnd(el));
		};
	};
	this.saveSelect_ = function(el){
		self.setSelect(el, self.getStart(el), self.getEnd(el));
	};
};
/*
if (d.attachEvent){
	d.attachEvent('onkeyup', dSelect.saveSelect);
}else if (d.addEventListener){
	d.addEventListener('keyup', dSelect.saveSelect, false);
};

/*** выделение текста */

function show_podbor_help(params)
{
	for(key in params)
	{
		var el = getEl(key);
		if(params[key] == '-1' || params[key] == '0')
			params[key] = '-';
		if(el){
			el.innerHTML = params[key];
		}
	}
}

function dSelect2(slct, val)
{
	slct = getEl(slct);
	if(slct)
	{
		for(var i = 0; i < slct.length; i++)
		{
			if(slct[i].value == val)
			{
				slct[i].selected = true;
				return;
			}
		}
	}
}

function closeAll(){
	closeHintTime();
	closeHintHelpTag();
	closeHintHelpTerms();
	closeSiteSearch();
	closePicSearch('Left');
	closePicSearch('Top');
};

function funNull(){
	
};
function clearCookie(name){	// очистка cookie
	setCookie(name, '');
};

function getGMTTime(time){	// получение времени в формате GMT
	date = new Date();
	if (time != null){
		var sec = date.getTime();
		sec += time * 1000;
		date.setTime(sec);
	};
	return date.toGMTString();
};

d.onclick = closeAll;
window.onresize = closeAll;
d.onload = bodyLoad;
/*
d.onmousemove = function(e){
	if (e != null)
		window.event = e;
};*/

String.prototype.trim = function(){
	return this.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
};

function bodyLoad(){
	var hideDiv = getEl('hideDiv');
	if (hideDiv != null)
		if (hideDiv.style.display != 'none'){
			hideDiv.style.height = d.body.scrollHeight;
		};
};

function methodInObj(obj){
	method = '';
	for (i in obj){
		method += i + '\n';
	};
	return method;
};

function changeUrl(obj){
	location = obj.options[obj.selectedIndex].value;
};

function in_array(element, array, type, lover){
	if (lover == true){
		for (iAr=0; iAr<array.length; iAr++){
			if (element.toLowerCase() == array[iAr].toLowerCase()){
				return (type == 'key' ? iAr : element);
			};
		};
	}else{
		for (iAr=0; iAr<array.length; iAr++){
			if (element == array[iAr]){
				return (type == 'key' ? iAr : element);
			};
		};
	};
	return false;
};

function implode(glue, pieces){	// объеденение элементов массива
	return pieces.join(glue);
};

function keyCod(){
	e = window.event;
	return e.keyCode;
};

function edit13(obj, fun){	// нажатие Enter в поле ввода
	e = window.event;
	var k = e.keyCode;
	if (k == 13) {
		eval(fun+'(obj)');
	};
};

function getEl(id){
	if (d.getElementById(id) != null){
		return d.getElementById(id);
	}else{
		return null
	};
};

function getMesto(element){
	if (typeof(element) != 'object'){
		element = self.getEl(element);
		if (element == null)
			return false;
	};
	var left = element.offsetLeft;
	var top = element.offsetTop;
	var t_left = 0;
	var t_top = 0;
	var scrollLeft = 0;
	var scrollTop = 0;
	for (var parent = element.offsetParent; parent; parent = parent.offsetParent){
		left += parent.offsetLeft - parent.scrollLeft;
		top += parent.offsetTop - parent.scrollTop;
		scrollLeft += parent.scrollLeft;
		scrollTop += parent.scrollTop;
		t_left = parent.scrollLeft;
		t_top = parent.scrollTop;
	};
	left += t_left;
	top += t_top;
	return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight, sLeft: scrollLeft, sTop: scrollTop};
};

function getHttp(){	// Определение объекта для запроса
	forAll.http = null;
	try {
		forAll.http = new ActiveXObject('Msxml2.XMLHTTP');
	}catch (e){
		try{
			forAll.http = new ActiveXObject('Microsoft.XMLHTTP');
		}catch (e){
			if(window.XMLHttpRequest){
				forAll.http = new XMLHttpRequest();
			};
		};
	};
};

function loadUrl(url, fun, arrayPar){
	getHttp();
	if (forAll.http != null){
		if (arrayPar == null){	// loadGET
			forAll.http.onreadystatechange = function(){
				eval(fun+'()');
			};
			forAll.http.open('GET', url, true);
			forAll.http.send(null);
		}else{	// loadPOST
			query = '';
			for (i=0; i<arrayPar[0].length; i++){
				query += arrayPar[0][i]+'='+arrayPar[1][i]+'&';
			};
			forAll.http.onreadystatechange = function(){
				eval(fun+'()');
			};
			forAll.http.open('POST', url, true);
			forAll.http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			forAll.http.setRequestHeader("Content-length", query.length);
			forAll.http.send(query);
		};
	};
};

function loadUrlStream(url, fun, arrayPar){
	var http = null;
	try {
		http = new ActiveXObject('Msxml2.XMLHTTP');
	}catch (e){
		try{
			http = new ActiveXObject('Microsoft.XMLHTTP');
		}catch (e){
			if(window.XMLHttpRequest){
				http = new XMLHttpRequest();
			};
		};
	};
	if (http != null){
		if (url.indexOf('http://') == -1){
			var url = forAll.domen+url;
		};
		if (arrayPar == null){// loadGET
			http.onreadystatechange = function(){
				eval(fun + '(http)');
			};
			http.open('GET', url, true);
			http.send(null);
		}else{	// loadPOST
			var query = '';
			if (!arrayPar.length){
				for (var i in arrayPar){
					query += i + '=' + arrayPar[i] + '&';
				};
			}else{
				for (var i=0; i<arrayPar[0].length; i++){
					query += arrayPar[0][i]+'='+arrayPar[1][i]+'&';
				};
			};
			http.onreadystatechange = function(){
				eval(fun + '(http)');
			};
			http.open("POST", url, true);
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			http.setRequestHeader("Content-length", query.length);
			http.send(query);
		};
	};
};

function evalU(http){
    if (http.readyState == 4){
        if (http.status == 200){
			eval(http.responseText);
		};
	};
};

function alertU(http){
    if (http.readyState == 4){
        if (http.status == 200){
			alert(http.responseText);
		};
	};
};

function createHintHelpTag(fromEl){	// создание всплывающей подсказки для поля
	if (getEl('idHintHelpTag') == null){
		insertIn = getEl('forAllHide');
		fromPosEl = getMesto(fromEl);
		forAll.tag_hint_bottom = '<img src="'+forAll.img_domen+'img/1x1.gif" width="'+(fromPosEl.width-12)+'" height="5"><br><div class="help"><nobr OnClick="closeHintHelpTag()" class="hand">Кликните для выбора по ссылке, или тут чтобы закрыть.</nobr></div>';
		newElem = d.createElement('div');
		newElem.className = 'thems_perehod';
		newElem.id = 'idHintHelpTag';
		newElem.style.display = 'none';
		newElem.style.width = fromPosEl.width-12;
		newElem.style.left = fromPosEl.left;
		insertIn.appendChild(newElem);
	};
};
function closeHintHelpTag(){
	if (getEl('idHintHelpTag') != null){
		forAll.hintTagText = '';
		getEl('idHintHelpTag').style.display = 'none';
	};
};
function hintTagSearchVvod(obj){	// отображение окна всплывающей помощи при вводе в поле тега сайта (привязки)
	clearTimeout(forAll.hintTagTime);
	forAll.tagSearchEdit = obj;
	if (forAll.tagSearchEdit.value.length > 0){
		fromPosEl = getMesto(forAll.tagSearchEdit);
		newElem.style.top = fromPosEl.top+22;
		if (forAll.hintTagText != forAll.tagSearchEdit.value){
			forAll.hintTagTime = setTimeout("hintTagSearchTime()", forAll.timeCreateHint);
		};
	}else{
		closeHintHelpTag();
	};
};
function hintTagSearchTime(){
	forAll.hintTagText = forAll.tagSearchEdit.value;
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'search_word';
	arrayPar[1][0] = forAll.hintTagText;
	loadUrl('/hint/tag_search/', 'showHintHelp', arrayPar);
};
function showHintTagText(titleArray){	// генирацие текста для всплывающего списка, при вводе в поле
	if (forAll.tagSearchEdit.value.length > 0){
		hHT = getEl('idHintHelpTag');
		hHT.innerHTML = '';
		if (titleArray.length > 0){
			for (i=0; i<titleArray.length; i++){
				id = 'hintTextTmpId_' + i;
				hHT.innerHTML += '<a href="javascript:setTagSiteValue(\'' + id + '\')" id="' + id + '">' + titleArray[i] + '</a>';
			};
			hHT.innerHTML += forAll.tag_hint_bottom;
			hHT.style.display = '';
		}else{
			hHT.style.display = 'none';
		};
	};
};
function setTagSiteValue(tag){
	forAll.tagSearchEdit.value = getEl(tag).innerHTML;
	closeHintHelpTag();
};
function hintTagSearchVvodId(obj){	// отображение окна всплывающей помощи при вводе в поле тега сайта (привязки)
	clearTimeout(forAll.hintTagTime);
	forAll.tagSearchEdit = obj;
	if (forAll.tagSearchEdit.value.length > 0){
		fromPosEl = getMesto(forAll.tagSearchEdit);
		newElem.style.top = fromPosEl.top+22;
		if (forAll.hintTagText != forAll.tagSearchEdit.value){
			forAll.hintTagTime = setTimeout("hintTagSearchTimeId()", forAll.timeCreateHint);
		};
	}else{
		closeHintHelpTag();
	};
};
function hintTagSearchTimeId(){

	forAll.hintTagText = forAll.tagSearchEdit.value;
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'search_word';
	arrayPar[1][0] = forAll.hintTagText;
	loadUrl('/hint/tag_search_id/', 'showHintHelp', arrayPar);
};
function showHintTagTextId(titleArray){	// генирацие текста для всплывающего списка, при вводе в поле по id
	if (forAll.tagSearchEdit.value.length > 0){
		hHT = getEl('idHintHelpTag');
		hHT.innerHTML = '';
		if (titleArray.length > 0){
			for (i=0; i<titleArray.length; i++){
				//id = 'hintTextTmpId_' + i;
				if (null != titleArray[i].redirect){
					id = titleArray[i].redirect.id;
					title = titleArray[i].redirect.title;
					hHT.innerHTML += '<span>' + titleArray[i].title + ' &#8594; <a href="javascript:setTagSiteValueId(\'' + id + '\', \'_priv\')" id="' + id + '" style="display: inline-block">' + title + '</a><br/></span>';				
				} else {
					id = titleArray[i].id;
					title = titleArray[i].title;
					hHT.innerHTML += '<a href="javascript:setTagSiteValueId(\'' + id + '\', \'_priv\')" id="' + id + '">' + title + '</a>';
				}
			};
			hHT.innerHTML += forAll.tag_hint_bottom;
			hHT.style.display = '';			
		}else{
			hHT.style.display = 'none';
		};
	};
};
function setTagSiteValueId(tag, elementId){
	getEl(elementId).value = tag;
	forAll.tagSearchEdit.value = getEl(tag).innerHTML;
	closeHintHelpTag();
};

function createHint(hint){	// ф-ция создания таймаута всплывающего окна помощи
	clearTimeout(forAll.hintAllTimeClose);
	clearTimeout(forAll.hintAllTimeCreate);
	if (hint.obj.tagName == 'SPAN'){
		hint.obj.style.color = '#046DB1';
		hint.obj.style.borderBottom = '#046DB1 1px dotted';
		hint.obj.onmouseout = function(){
			closeHint();
			hint.obj.style.color = '#0485D8';
			hint.obj.style.borderBottom = '#0485D8 1px dotted';
		};
		hint.obj.onclick = function(){
			window.open(hint.src, '', '');
		};
	}else{
		hint.obj.onmouseout = function(){closeHint();};
	};
	if (forAll.hintObj.tag != hint.tag){
		closeHintTime();
	};
	forAll.hintObj = hint;
	hintDiv = getEl('idHintHelpAll');

	if (hintDiv == null){	// еще не создано всплывающая подсказка
		forAll.hintAllTimeCreate = setTimeout("createHintTime()", forAll.timeCreateHint);
	}else{
		if (hintDiv.style.display != ''){	// всплывающая подсказка не отображается
			forAll.hintAllTimeCreate = setTimeout("createHintTime()", forAll.timeCreateHint);
		}else{
			forAll.hintObj.mesto = getMesto(forAll.hintObj.obj);
			setHintPos(hintDiv, null);
		};
	};
};

function createHintTime(){	// ф-ция создания всплывающего окна помощи
	fromPosEl = getMesto(forAll.hintObj.obj);
	forAll.hintObj.mesto = fromPosEl;
	hintDiv = getEl('idHintHelpAll');
	insertIn = getEl('forAllHide');
	if (hintDiv == null){
		newElem = d.createElement('div');
		newElem.className = 'hintHelp';
		newElem.id = 'idHintHelpAll';
		newElem.onmouseover = function(){createHint(forAll.hintObj);};
		newElem.onmouseout = function(){closeHint();};
		newElem.style.display = 'none';
		insertIn.appendChild(newElem);
		newElem = d.createElement('div');
		newElem.className = 'hintHelpShadow';
		newElem.id = 'idHintHelpAllShadow';
		insertIn.appendChild(newElem);
	};
	if (forAll.hintAllText[forAll.hintObj.tag] == null){
		loadUrl('/hint/showTag/'+(forAll.hintObj.tag)+'/', 'showHint');
	}else{
		showHintText();
	};
};

function closeHint(){	// ф-ция скрытия всплывающего окна помощи
	clearTimeout(forAll.hintAllTimeCreate);
	if (getEl('idHintHelpAll') != null){
		forAll.hintAllTimeClose = setTimeout("closeHintTime()", forAll.timeCloseHint);
	};
};
function closeHintTime(){	// ф-ция скрытия всплывающего окна помощи по истечению интервала
	if (getEl('idHintHelpAll') != null){
		hintDiv = getEl('idHintHelpAll');
		hintDiv.style.display = 'none';
		hintDiv = getEl('idHintHelpAllShadow');
		hintDiv.style.display = 'none';
	};
};
function showHint(){	// ф-ция перевода текста с сервера на вывод в hintDiv
    if (forAll.http.readyState == 4){
        if (forAll.http.status == 200){
        	if (forAll.http.responseText != ''){
				forAll.hintAllText[forAll.hintObj.tag] = forAll.http.responseText;
				showHintText();
        	};
		};
	};
};
function showHintText(){	// ф-ция отображения hintDiv
	hintDiv = getEl('idHintHelpAll');
	hintDivShadow = getEl('idHintHelpAllShadow');
	hintDivLeft = 0;
	hintDivTop = 0;
	var termsSin = null;
	newSin = forAll.hintAllText[forAll.hintObj.tag];
	while (newSin.indexOf('%sinon%') != -1){
		termsSin = /<b>([^<]+)<\/b>%sinon% -/i.exec(newSin);	// проверка для терминов и их синонимов
		if (termsSin != null){
			if (forAll.hintObj.obj.innerHTML.toLowerCase() == termsSin[1].toLowerCase()){
				newSin = newSin.replace('%sinon%', '');
			}else{
				newSin = newSin.replace('%sinon%', ' (' + forAll.hintObj.obj.innerHTML + ')');
			};
		};
	};
	hintDiv.innerHTML = newSin;

	hintDiv.style.display = '';
	hintM = getMesto(hintDiv);
	hintDiv.style.display = 'none';
	setHintPos(hintDiv, hintM);
	hintDiv.style.display = '';
	hintDivShadow.style.display = '';
};

function setHintPos(hintDiv, hintM){	// определение местоположение всплывающей подсказки
	if (hintM == null){
		if (hintDiv.style.display == ''){
			hintM = getMesto(hintDiv);
		}else{
			hintDiv.style.display = '';
			hintM = getMesto(hintDiv);
			hintDiv.style.display = 'none';
		};
	};
	strHintPos = {left:'',top:'',bgPos:''};
	if ((forAll.hintObj.mesto.left + forAll.hintObj.mesto.width) > (d.body.offsetWidth / 2)){	// слева
		hintDivLeft = forAll.hintObj.mesto.left - hintM.width + 20;
		strHintPos.left = forAll.hintObj.mesto.left + 5;
	}else{	// справа
		hintDivLeft = forAll.hintObj.mesto.left + forAll.hintObj.mesto.width - 10;
		strHintPos.left = forAll.hintObj.mesto.left + forAll.hintObj.mesto.width;
	};
	if (forAll.hintObj.mesto.top - hintM.sTop - hintM.height - forAll.hintObj.mesto.height - 5 >= 0){	// сверху
		hintDivTop = forAll.hintObj.mesto.top - hintM.height - 5;
		strHintPos.top = forAll.hintObj.mesto.top - 6;
		strHintPos.bgPos = '0px -5px';
	}else{	// снизу
		hintDivTop = forAll.hintObj.mesto.top + forAll.hintObj.mesto.height + 7;
		strHintPos.top = forAll.hintObj.mesto.top + forAll.hintObj.mesto.height;
		strHintPos.bgPos = '0px 2px';
	};
	hintDiv.style.left = hintDivLeft;
	hintDiv.style.top = hintDivTop;
	hintDivShadow.style.left = hintDivLeft+2;
	hintDivShadow.style.top = hintDivTop+2;
	hintDivShadow.style.width = hintM.width;
	hintDivShadow.style.height = hintM.height;
	return strHintPos;
};


function createHintHelpTerms(fromEl, subTop){
	var idHintHelpThems = getEl('idHintHelpThems');
	if (idHintHelpThems == null){
		insertIn = getEl('forAllHide');
		fromPosEl = getMesto(fromEl);
		forAll.terms_hint_bottom = '<img src="'+forAll.img_domen+'img/1x1.gif" width="'+(fromPosEl.width-12)+'" height="5"><br><div class="help"><nobr>Кликните для перехода</nobr></div>';
		newElem = d.createElement('div');
		newElem.className = 'thems_perehod';
		newElem.id = 'idHintHelpThems';
		newElem.style.display = 'none';
		newElem.style.left = fromPosEl.left;
		newElem.style.top = fromPosEl.top+subTop;
		insertIn.appendChild(newElem);
	}else{
		fromPosEl = getMesto(fromEl);
		forAll.terms_hint_bottom = '<img src="'+forAll.img_domen+'img/1x1.gif" width="'+(fromPosEl.width-12)+'" height="5"><br><div class="help"><nobr>Кликните для перехода</nobr></div>';
		idHintHelpThems.style.left = fromPosEl.left;
		idHintHelpThems.style.top = fromPosEl.top+subTop;
	};
};
function closeHintHelpTerms(){
	if (getEl('idHintHelpThems') != null){
		forAll.hintTermsText = '';
		getEl('idHintHelpThems').style.display = 'none';
	};
};
function showHintHelp(){
    if (forAll.http.readyState == 4){
        if (forAll.http.status == 200){
			eval(forAll.http.responseText);
		};
	};
};
function alertServerUnsver(){
    if (forAll.http.readyState == 4){
        if (forAll.http.status == 200){
			alert(forAll.http.responseText);
		};
	};
};
function showHintTermsText(srcArray, titleArray, tagArray, idArray, sinonArray){
	if (forAll.termsSearchEdit.value.length > 0){
		hHT = getEl('idHintHelpThems');
		hHT.innerHTML = '';
		if (srcArray.length > 0){
			if(forAll.hintTermsTypeUnsver == 'js'){
				for (i=0; i<srcArray.length; i++){
					id = 'hintTermsTmpId_' + i;
					hHT.innerHTML += '<a href="javascript:addTermsToEdit(\'' + id + '\', ' + tagArray[i] + ', ' + (idArray[i] != null ? idArray[i] : 0) + ')" id="' + id + '" value="' + forAll.domen + 'terms/' + srcArray[i] + '.html">' + titleArray[i] + '</a><div style="display:none" id="hideSin' + id + '">' + sinonArray[i] + '</div>';
				};
			}else{
				for (i=0; i<srcArray.length; i++){
					hHT.innerHTML += '<a href="'+forAll.domen+'terms/'+srcArray[i]+'.html">'+titleArray[i]+'</a>';
				};
			};
			hHT.innerHTML += forAll.terms_hint_bottom;
			hHT.style.display = '';
		}else{
			hHT.style.display = 'none';
		};
	};
};

function addTermsToEdit(terms, tag, id){
	forAll.termsSearchEdit.value = getEl('hideSin'+terms).innerHTML;
	if (getEl(forAll.termsSearchEdit.id + 'HiddenSrc') != null){
		getEl(forAll.termsSearchEdit.id + 'HiddenSrc').value = getEl(terms).getAttribute('value');
	};
	if (getEl(forAll.termsSearchEdit.id + 'HiddenTag') != null){
		getEl(forAll.termsSearchEdit.id + 'HiddenTag').value = tag;
	};
	if (getEl(forAll.termsSearchEdit.id + 'HiddenId') != null){
		getEl(forAll.termsSearchEdit.id + 'HiddenId').value = id;
	};
	closeHintHelpTerms();
}
function hintTermsSearch13(obj){

};
function hintTermsSearchVvod(obj, type){	// ввод в поле быстрого перехода по терминам
	forAll.hintTermsTypeUnsver = type;
	clearTimeout(forAll.hintTermsTime);
	forAll.termsSearchEdit = obj;
	forAll.actTerms = getEl('actTerms').value;
	if (forAll.termsSearchEdit.value.length > 0){
		if (forAll.hintTermsText != forAll.termsSearchEdit.value){
			forAll.hintTermsTime = setTimeout("hintTermsSearchTime()", 500);
		};
	}else{
		closeHintHelpTerms();
	};
};
function hintTermsSearchTime(){
	forAll.hintTermsText = forAll.termsSearchEdit.value;
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'search_word';
	arrayPar[1][0] = forAll.hintTermsText;
	arrayPar[0][1] = 'action_terms';
	arrayPar[1][1] = forAll.actTerms;
	loadUrl('/hint/terms_search/', 'showHintHelp', arrayPar);
};

function createSiteSearch(fromEl, subTop){	// создание выпадающего списка поиска по сайту
	var divSiteSearch = getEl('divSiteSearch');
	if (divSiteSearch == null){
		insertIn = getEl('forAllHide');
		fromPosEl = getMesto(fromEl);
		newElem = d.createElement('div');
		newElem.className = 'siteSearchPanel';
		newElem.id = 'divSiteSearch';
		newElem.style.display = 'none';
		newElem.style.top = fromPosEl.top + subTop;
		insertIn.appendChild(newElem);
	};
};
function vvodSearchSite(obj){	// ввод в поле поиска по сайту
	clearTimeout(forAll.hintSiteSearchTime);
	forAll.searchOnAllSite = obj;
	if (forAll.searchOnAllSite.value.length > 0){
		if (forAll.textSiteSearch != forAll.searchOnAllSite.value){
			forAll.hintSiteSearchTime = setTimeout("vvodSearchSiteTime()", 500);
		};
	}else{
		closeSiteSearch();
	};
};
function vvodSearchSiteTime(){	// создание запроса и вставку в выпадающий список текста
	if ((getEl('divSiteSearch') != null) && (getEl('searchSizteText').value != '')){
		forAll.textSiteSearch = forAll.searchOnAllSite.value;
		arrayPar = Array(Array(),Array());
		arrayPar[0][0] = 'search_word';
		arrayPar[1][0] = forAll.searchOnAllSite.value;
		arrayPar[0][1] = 'razdel';
		arrayPar[1][1] = getEl('searchRazdel').value;
		loadUrl('/hint/searchSite/', 'showHintHelp', arrayPar);
//		loadUrl('/hint/searchSite/', 'alertServerUnsver', arrayPar);
	};
};
function showSiteSearch(img, title, src, size, count){	// отображение выпадающего списко поиску по сайту
	var divSiteSearch = getEl('divSiteSearch');
	fromPosEl = getMesto(getEl('searchSizteText'));
	divSiteSearch.style.left = fromPosEl.left + fromPosEl.width - 300;
	divSiteSearch.style.display = '';
	forAll.pole1x1 = '<img src="' + forAll.img_domen + 'img/1x1.gif" height="1">';
	text = '<div class="top">Найдено:</div>';
	text += '<table id="tableSearch" cellpadding="0" cellspacing="0" width="100%" style="background:url(' + forAll.img_domen + 'img/searchGrad.jpg) repeat-y right top">';

	text += '<tr height="5" style="background-color:#ffffff">';
	text += '<td width="5">' + forAll.pole1x1 + '</td>';
	text += '<td style="border-bottom:#000000 1px dotted">' + forAll.pole1x1 + '</td>';
	text += '<td width="14">' + forAll.pole1x1 + '</td>';
	text += '</tr>';

	for (i=0; i<title.length; i++){
		text += '<tr height="60" OnMouseOver="selectRowsSearch(' + (i+1) + ');slidePhoneSearch(this, ' + count[i] + ', ' + i + ', 60);" OnMouseOut="selectRowsSearch(' + (i+1) + ');slidePhoneSearch(this, 0, ' + i + ', 60);" OnClick="chLocation(\'' + src[i] + '\')" class="hand" style="background-color:#ffffff">';
		text += '<td class="fS1">&nbsp;</td>';
		text += '<td style="border-bottom:#000000 1px dotted">';
		text += '<table cellpadding="0" cellspacing="0" width="100%">';
		text += '<tr>';
		text += '<td valign="center" align="center" width="60">';
		if (img[i] != null){
			text += '<img src="' + img[i] + '" width="' + size[i].w + '" height="' + size[i].h + '" style="margin:2px 0;">';
		}else{
			text += forAll.pole1x1;
		};
		text += '</td>';
		text += '<td width="5"><img src="' + forAll.img_domen + 'img/1x1.gif" width="1" height="50"></td>';
		text += '<td valign="top" class="textPanelSearch">' + title[i] + '</td>';
		text += '</tr>';
		text += '</table>';
		text += '</td>';
		text += '<td valign="center" align="right">' + forAll.pole1x1 + '</td>';
		text += '</tr>';
	};
	text += '</table>';
	text += '<div class="bottom"><a href="' + getEl('searchSrc').value + getEl('searchSizteText').value + '/' + '" class="top_link">Искать дальше</a></div>';
	divSiteSearch.innerHTML = '<div class="conteiner">' + text + '</div>';
	forAll.tableSearch = getEl('tableSearch');
};
function selectRowsSearch(rowsId){	// выделение активного пункта меню выпадающего списка
	if (forAll.tableSearch.rows[rowsId].style.backgroundColor == ''){
		forAll.tableSearch.rows[rowsId].style.backgroundColor = '#ffffff';
		forAll.tableSearch.rows[rowsId].cells[2].innerHTML = forAll.pole1x1;
		forAll.tableSearch.rows[rowsId-1].cells[0].style.borderBottom = '#ffffff 1px solid';
		forAll.tableSearch.rows[rowsId-1].cells[1].style.borderBottom = '#000000 1px dotted';
		forAll.tableSearch.rows[rowsId-1].cells[2].style.borderBottom = '#ffffff 1px solid';
		forAll.tableSearch.rows[rowsId].cells[0].style.borderBottom = '#ffffff 1px solid';
		forAll.tableSearch.rows[rowsId].cells[1].style.borderBottom = '#000000 1px dotted';
		forAll.tableSearch.rows[rowsId].cells[2].style.borderBottom = '#ffffff 1px solid';
		forAll.tableSearch.rows[rowsId].cells[2].style.borderRight = '';
	}else{
		forAll.tableSearch.rows[rowsId].style.backgroundColor = '';
		forAll.tableSearch.rows[rowsId-1].cells[0].style.borderBottom = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId-1].cells[1].style.borderBottom = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId-1].cells[2].style.borderBottom = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId].cells[0].style.borderBottom = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId].cells[1].style.borderBottom = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId].cells[2].style.borderBottom = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId].cells[2].style.borderRight = '#000000 1px solid';
		forAll.tableSearch.rows[rowsId].cells[2].innerHTML = '<img src="' + forAll.img_domen + 'img/strelo4ka.gif" width="4" height="7">';
	};
};
function closeSiteSearch(){	// закрытия выпадающего списка поиска по сайту
    var divSiteSearch = getEl('search_popup');
	if (divSiteSearch != null) {
        document.getElementById('search_popup').style.display = 'none';
	};
};

function createSearchSelect(){	// создание выпадающего списка выбора зоны поиска
	insertIn = getEl('forAllHide');
	newElem = d.createElement('div');
	newElem.className = 'siteSelectSearch';
	newElem.id = 'divSiteSelectSearch';
	newElem.style.display = 'none';
	newElem.onmouseover = function(){keepSearchSelect()};
	newElem.onmouseout = function(){forAll.searchSelectTimeClose = setTimeout("closeSearchSelect()", forAll.timeCloseHint);};
	insertIn.appendChild(newElem);
	newElem = d.createElement('div');
	newElem.className = 'siteSelectSearchShadow';
	newElem.id = 'divSiteSelectSearchShadow';
	newElem.style.display = 'none';
	insertIn.appendChild(newElem);
	indexSelect = 0;
	for (i=0; i<forAll.searchRazdels.length; i++){
		if (location.href.indexOf(forAll.searchRazdels[i].src) != -1){
			if (forAll.searchRazdels[i].razdel != 'terms'){
				indexSelect = i;
			}else{
				indexSelect = 0;
			};
		};
	};
	setZonSiteSearch(indexSelect);
};
function closeSearchSelect(){	// закрытие выпадающего списка выбора зоны поиска
	getEl('divSiteSelectSearchShadow').style.display = 'none';
	getEl('divSiteSelectSearch').style.display = 'none';
};
function keepSearchSelect(){	// удержание выпадающего списка выбора зоны поиска
	clearTimeout(forAll.searchSelectTimeClose);
};
function setZonSiteSearch(indexSelect){	// определение зоны поиска
	var searchRazdel = getEl('searchRazdel');
	searchRazdel.value = forAll.searchRazdels[indexSelect].razdel;
	var searchSrc = getEl('searchSrc');
	searchSrc.value = forAll.searchRazdels[indexSelect].src + forAll.searchRazdels[indexSelect].search;
	forAll.serachSpan.innerHTML = forAll.searchRazdels[indexSelect].title + ' ';
/*
	searchRazdel = getEl('searchSiteAll');
	searchSiteAll.style.display = (indexSelect == 0 ? 'none' : '');
*/
};
function selectZonSiteSearch(clickObj){	// отображение выпадающего списка выбора зоны поиска
	var searchRazdel = getEl('searchRazdel');
	selectText = '';
	for (i=0; i<forAll.searchRazdels.length; i++){
		if (searchRazdel.value == forAll.searchRazdels[i].razdel){
			selectText = '<font class="search_parametrs_text"><a href="javascript:clickZonSiteSearch(' + i + ')" style="line-height:150%;">' + forAll.searchRazdels[i].title + '</a> <img src="' + forAll.img_domen + 'img/arrow_down_1.gif"></font><br>' + selectText;
		}else{
			if (forAll.searchRazdels[i].razdel != 'terms'){
				selectText += '<a href="javascript:clickZonSiteSearch(' + i + ');vvodSearchSiteTime();" style="line-height:130%;">' + forAll.searchRazdels[i].title + '</a><br>';
			}else{
				selectText += '<a href="' + forAll.searchRazdels[i].src + '" style="line-height:130%;">' + forAll.searchRazdels[i].title + '</a><br>';
			};
		};
	};
	var divSiteSelectSearch = getEl('divSiteSelectSearch');
	divSiteSelectSearch.innerHTML = selectText;
	mestoObj = getMesto(clickObj);
	divSiteSelectSearch.style.top = mestoObj.top - 4;
	divSiteSelectSearch.style.left = mestoObj.left - 6;
	divSiteSelectSearch.style.display = '';
	var divSiteSelectSearchShadow = getEl('divSiteSelectSearchShadow');
	mestoObj = getMesto(divSiteSelectSearch);
	divSiteSelectSearchShadow.style.top = mestoObj.top + 2;
	divSiteSelectSearchShadow.style.left = mestoObj.left + 2;
	divSiteSelectSearchShadow.style.width = mestoObj.width;
	divSiteSelectSearchShadow.style.height = mestoObj.height;
	divSiteSelectSearchShadow.style.display = '';
};
function beginSearchSite(){
	chLocation(getEl('searchSrc').value + getEl('searchSizteText').value + '/');
	return false;
};
function beginSearchSiteNews(form){	// поиск конкретно по новостям
	for (i=0; i<forAll.searchRazdels.length; i++){
		if (forAll.searchRazdels[i].razdel == 'news'){
			chLocation(forAll.searchRazdels[i].src + forAll.searchRazdels[i].search + form.search_text.value + '/');
			return false;
		};
	};
	return false;
};
function beginSearchSiteGameAll(form){	// поиск конкретно по играм
	window.location.href = '/search/' + form.search_text.value + '/';
	return false;
};
function beginSearchSitePhoneAll(form){	// поиск конкретно по телефонам
	if(/^http:\/\/[^\/]+\/phone/.test(window.location.href)){
		window.location.href = '/phone/search/' + form.search_text.value + '/';
	}
	else window.location.href = '/search/' + form.search_text.value + '/';
	return false;
};

function clickZonSiteSearch(indexSelect){	// выбор необходимой зоны поиска
	setZonSiteSearch(indexSelect);
	closeSearchSelect();
};

function chLocation(src){
	location.href = (src.indexOf('http://') != -1 ? src : 'http://'+src);
};

function editClick(obj, id, text_){	// ф-ция нажатия на поле ввода поиска
	if (obj.value == text_) {
		obj.value = '';
	}else if((obj.value.length == 0) && (id == 0)){
		obj.value = text_;
	};
};

function showBigImg(obj_img, razmer, to_left, to_top, b_pref){
	obj_img.style.border = '0px';
	el_mesto = getMesto(obj_img);
	if (razmer){
		obj_img.style.position = 'absolute';
		obj_img.style.zIndex = '100';
		obj_img.style.border = b_pref;
		obj_img.alt = '';
		obj_img.title = '';
		width = Math.round(-1*el_mesto.width/2);
		height = Math.round(-1*el_mesto.height/2);
		obj_img.style.left = el_mesto.left + width + to_left;
		obj_img.style.top = el_mesto.top + height + to_top;
		obj_img.width = el_mesto.width*2;
	}else{
		obj_img.style.position = 'relative';
		obj_img.style.zIndex = '1';
		obj_img.style.border = b_pref;
		obj_img.width = Math.round(el_mesto.width/2);
		obj_img.style.left = 0;
		obj_img.style.top = 0;
	};
};

function getAllPropertis(linkObj){	// получение всех свойств объекта
	par = '';
	if (typeof(linkObj) == 'object'){
		for (i in linkObj)
			par += ' ' + i;
	}else{
		obj = getEl(linkObj);
		if (obj != null){
			for (i in obj)
				par += ' ' + i;
		};
	};
	return par;
};

function showHide(el){
	if (el.style != null){
		el.style.display = (el.style.display == '' ? 'none' : '');
	}else{
		if (getEl(el) != null)
			showHide(getEl(el));
	};
};

function addOptListSelect(modelList, objSelect){
	objSelect = getEl(objSelect);
	if (objSelect != null){
		var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
		for (i=0; i<modelList.allPage; i++){
			j = i + 1;
			newElem = d.createElement('option');
			newElem.text = j;
			newElem.value = modelList.prefPage + (j == 1 ? (modelList.firstOff == true ? '' : modelList.pageName + j) : modelList.pageName + j) + modelList.syfPage;
			if (j == modelList.actPage)
				newElem.selected = true;
			objSelect.add(newElem, where);
		};
	};
};

function searchDifNow(){
	google_ad_client = "pub-8521906694815276";google_ad_slot = "5177415865";google_ad_width = 250;google_ad_height = 250;d.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
};

function searchDofNow(){
	google_ad_client = "pub-8521906694815276";google_ad_slot = "6557168353";google_ad_width = 728;google_ad_height = 90;d.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
};

function copyInObect(fromObj, toObj){
	getEl(toObj).innerHTML = getEl(fromObj).innerHTML;
};

function showBlackBG(funOpen, funClose){
	var hideDiv = getEl('hideDiv');

	if (funClose != null)
		hideDiv.onclick = function(){ hideBlackBG(funClose)};
	hideDiv.style.display = 'block';
	hideDiv.style.width = '100%';
//	hideDiv.style.height = (d.body.scrollHeight > 100 ? d.body.scrollHeight : '100%');
//	var h = (window.innerHeight  ? window.innerHeight : (document.documentElement.clientHeight  ? document.documentElement.clientHeight  : document.body.offsetHeight));
//	alert(h);
	hideDiv.style.height = document.documentElement.scrollHeight + 'px';
	if (funOpen != null)
		eval(funOpen);
};

function hideBlackBG(funClose){
	var hideDiv = getEl('hideDiv');
	if (hideDiv != null){
		hideDiv.style.display = 'none';
	};
	if (funClose != null)
		eval(funClose);
};

function showLoginReg(title){
	var regMessage = getEl('regMessage');
	getEl('titleReg').innerHTML = title;
	regMessage.style.left = Math.round(d.body.scrollWidth/2 - 215);
	regMessage.style.display = 'block';
	if ('v' != '\v'){
		regMessage.style.top = 120;
		regMessage.style.position = 'fixed';
	};
};

function showLogin(errors){
	var loginMessage = getEl('logInMessageSmall');
	getEl('logInPanelAbout').style.color = 'red';
	getEl('logInPanelAbout').innerHTML = errors;
	loginMessage.style.left = Math.round(d.documentElement.scrollWidth/2 - 215) + 'px';
	loginMessage.style.display = 'block';
	if ('v' != '\v'){
		loginMessage.style.top = 120;
		loginMessage.style.position = 'fixed';
	};
};

function showDif(elId){
	var elId = getEl(elId);
	elId.style.left = Math.round(d.body.scrollWidth/2 - 215) + 'px';
	elId.style.display = 'block';
	if ('v' != '\v'){
		elId.style.top = 120;
		elId.style.position = 'fixed';
	};
};

function hideLoginReg(){
	var regMessage = getEl('regMessage');
	regMessage.style.display = 'none';
};

function hideLogin(){
	var loginMessage = getEl('logInMessageSmall');
	loginMessage.style.display = 'none';
};

function hideDif(elId){
	var elId = getEl(elId);
	elId.style.display = 'none';
};

function bottomHover(bottom, show){	// наведение курсора мыши на кнопку
	if (show){
		bottom.style.backgroundColor = '#EBE9ED';
	}else{
		bottom.style.backgroundColor = '#ffffff';		
	};
};

function showReg(){
	var regMessageSmall = getEl('regMessageSmall');
	var w = document.documentElement.scrollWidth;
//	regMessageSmall.style.left = Math.round(d.body.scrollWidth/2 - 160);
	regMessageSmall.style.left = Math.round(w/2 - 160) + 'px';
	regMessageSmall.style.display = 'block';
	if ('v' != '\v'){
		regMessageSmall.style.top = 120;
		regMessageSmall.style.position = 'fixed';
	};
};

function hideReg(){
	var regMessageSmall = getEl('regMessageSmall');
	regMessageSmall.style.display = 'none';
};

forAll.regCorrectMail = false;
forAll.regCorrectLogin = false;
forAll.regCorrectPass = false;

function checkMail(mail){	// проверка корректности ввода E-mail
	if (/^\w+([\.-]\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(mail)){
		return true;
	};
	return false;
};

var messageInvalidMail = 'Введен неверный E-mail адрес.';

function editVvodMail(edit, errId){	// ввод в поле e-mail текста
	if (checkMail(edit.value) == false){
		getEl(errId).innerHTML = messageInvalidMail;
		return false;
	}else{
		getEl(errId).innerHTML = '';
	};
	return true;
};

function regEditVvodMail(edit){	// ввод в поле ввода при регистрации mail
	clearTimeout(forAll.regColsEditTimeMail);
	forAll.regColsEditMail = edit;
	if (edit.value.length > 0){
		forAll.regColsEditTimeMail = setTimeout("regEditVvodMailTime()", 2000);
	}else{
		getEl(edit.id + 'Error').innerHTML = '';
		getEl(edit.id + 'Img').innerHTML = '';
		forAll.regCorrectMail = false;
	};
};


function regEditVvodMailTime(){	// проверка mail
	if (checkMail(forAll.regColsEditMail.value)){
		arrayPar = Array(Array(),Array());
		arrayPar[0][0] = 'text';
		arrayPar[1][0] = forAll.regColsEditMail.value;
		arrayPar[0][1] = 'cols';
		arrayPar[1][1] = 'mail';
		loadUrl('/hint/checkReg/', 'showHintHelp', arrayPar);
	}else{
		forAll.regCorrectMail = false;
		if (forAll.regColsEditMail.value.length > 0){
			getEl(forAll.regColsEditMail.id + 'Error').innerHTML = messageInvalidMail;
			getEl(forAll.regColsEditMail.id + 'Img').innerHTML = '<img src="' + forAll.img_domen + 'img/no_reg.gif" width="16" height="16" style="margin-bottom:4px;">';
		}else{
			getEl(forAll.regColsEditMail.id + 'Error').innerHTML = '';
			getEl(forAll.regColsEditMail.id + 'Img').innerHTML = '';
		};
	};
};

var messageIllegalCharsInLogin = 'Введены запрещенные символы!<br>Нельзя вводить &lt; и &gt';

function regEditVvodLogin(edit){	// ввод в поле ввода при регистрации login
	clearTimeout(forAll.regColsEditTimeLogin);
	forAll.regColsEditLogin = edit;
	if (edit.value.length > 0){
		if (/^[^\<\>]+$/.test(edit.value)){
			forAll.regColsEditTimeLogin = setTimeout("regEditVvodLoginTime()", 500);
		}else{
			getEl(edit.id + 'Error').innerHTML = messageIllegalCharsInLogin;
			getEl(edit.id + 'Img').innerHTML = '<img src="' + forAll.img_domen + 'img/no_reg.gif" width="16" height="16" style="margin-bottom:4px;">';
			forAll.regCorrectLogin = false;
		};
	}else{
		getEl(edit.id + 'Error').innerHTML = '';
		getEl(edit.id + 'Img').innerHTML = '';
		forAll.regCorrectLogin = false;
	};
};

function regEditVvodLoginTime(){	// проверка login
	if (forAll.regColsEditLogin.value.length > 0){
		arrayPar = Array(Array(),Array());
		arrayPar[0][0] = 'text';
		arrayPar[1][0] = forAll.regColsEditLogin.value;
		arrayPar[0][1] = 'cols';
		arrayPar[1][1] = 'login';
		loadUrl('/hint/checkReg/', 'showHintHelp', arrayPar);
	}else{
		getEl(forAll.regColsEditLogin.id + 'Error').innerHTML = '';
		getEl(forAll.regColsEditLogin.id + 'Img').innerHTML = '';
		forAll.regCorrectLogin = false;
	};
};

var messagePasswordDifferent = 'Введенные пароли не совпадают!';
var messagePasswordLittle = 'Пароль должен быть не менее 4 символов.';

function regEditVvodPass(pass1, pass2, error){	// проверка совпадения паролей
	errImg = '<img src="' + forAll.img_domen + 'img/@server@_reg.gif" width="16" height="16" style="margin-bottom:4px;">';
	if (getEl(pass2).value.length > 3){
		if (getEl(pass1).value == getEl(pass2).value){
			getEl(error + 'Error').innerHTML = '';
			getEl(error + 'Img').innerHTML = errImg.replace('@server@', 'yes');
			forAll.regCorrectPass = true;
		}else{
			getEl(error + 'Error').innerHTML = messagePasswordDifferent;
			getEl(error + 'Img').innerHTML = errImg.replace('@server@', 'no');
			forAll.regCorrectPass = false;
		};
	}else{
		getEl(error + 'Error').innerHTML = messagePasswordLittle;
		getEl(error + 'Img').innerHTML = errImg.replace('@server@', 'no');
		forAll.regCorrectPass = false;
	};
};

var messageMailExists = 'Пользователь с таким E-mail уже существует. <a href="' + forAll.domen + 'account/forget/">Востановить пароль.</a>';
var messageLoginExists = 'Пользователь с таким Именем уже существует.';

function regServer(server, cols){	// ответ сервака по запросу проверки регистрационнных данных
	errImg = '<img src="' + forAll.img_domen + 'img/@server@_reg.gif" width="16" height="16" style="margin-bottom:4px;">';
	if (cols == 'mail'){
		if (server){
			getEl(forAll.regColsEditMail.id + 'Error').innerHTML = '';
			getEl(forAll.regColsEditMail.id + 'Img').innerHTML = errImg.replace('@server@', 'yes');
			forAll.regCorrectMail = true;
		}else{
			getEl(forAll.regColsEditMail.id + 'Error').innerHTML = messageMailExists;
			getEl(forAll.regColsEditMail.id + 'Img').innerHTML = errImg.replace('@server@', 'no');
			forAll.regCorrectMail = false;
		};
	}else{
		if (server){
			getEl(forAll.regColsEditLogin.id + 'Error').innerHTML = '';
			getEl(forAll.regColsEditLogin.id + 'Img').innerHTML = errImg.replace('@server@', 'yes');
			forAll.regCorrectLogin = true;
		}else{
			getEl(forAll.regColsEditLogin.id + 'Error').innerHTML = messageLoginExists;
			getEl(forAll.regColsEditLogin.id + 'Img').innerHTML = errImg.replace('@server@', 'no');
			forAll.regCorrectLogin = false;
		};
	};
};

function checkRegForm(form){	// проверка регистрационной формы
	form = form.form;
	for (i=0; i<form.elements.length; i++){
		if (form.elements[i].value == ''){
			form.reg_sub.disabled = true;
			return;
		};
	};
	if ((forAll.regCorrectMail) && (forAll.regCorrectLogin) && (forAll.regCorrectPass) && (form.kapchaCod.value.length == 4)){
		form.reg_sub.disabled = false;
	}else{
		form.reg_sub.disabled = true;
	};
};

function checkForgetForm(){	// проверка смены пароля
	if (getEl('pass_reg_forget1').value.length > 3)
		if (getEl('pass_reg_forget1').value == getEl('pass_reg_forget2').value){
			return true;
		};
	return false;
};

function showKapchaReg(div){
	getEl(div).innerHTML = '<img src="' + forAll.domen + 'kapcha/' + Math.random() + '.gif" id="' + div + 'kapchaReg" class="hand" OnClick="kapchaReload(this);" width="150" height="50">';
};

function kapchaReload(kapcha){	// ф-ция перезагрузки капчи
	if (typeof(kapcha) != 'object'){
		kapcha = getEl(kapcha);
	};
	if (kapcha == null)
		return false;
	kapcha.src = forAll.domen + 'kapcha/' + Math.random() + '.gif';
	return false;
};

function chCR(td){	// changeColorReiting смена градиента полосы рейтинга
	if (td.offsetParent.tagName == 'TABLE'){
		count = td.offsetParent.rows[0].cells.length;
		for (i=0; i<count; i++){
			if (td.offsetParent.rows[0].cells[i] == td){
				getEl('oPB' + td.offsetParent.id).style.backgroundColor = '#' + forAll.colors[i];
				getEl('oPB' + td.offsetParent.id).style.width = 20 * (i + 1) + '%';
				forAll.reitingNewColor = (i + 1);
				getEl('aliasReiting').innerHTML = forAll.golosPhone[forAll.reitingNewColor];
			};
		};
	};
};

function sethCR(obj){	// setColorReiting определение нового рейтинга
	obj.id = forAll.reitingNewColor * 20;
	getEl('reitingGolos').value = forAll.reitingNewColor;
};

function clearhCR(obj, id){	// clearColorReiting очистка временного градиента рейтинга и возврат первоначального
	if (forAll.reitingSet == null){
		getEl('oPB' + id).style.backgroundColor = forAll.colors[((obj.id / 20) - 1)];
		getEl('oPB' + id).style.width = obj.id + '%';
		getEl('aliasReiting').innerHTML = forAll.golosPhone[(obj.id / 20)];
	};
};

function showUnsver(id){	// отображение спика ответов на вопрос
	if (getEl('unsverA_' + id).style.display == 'none'){
		getEl('unsverA_' + id).style.display = '';
		getEl('textVopros_' + id).style.fontWeight = '';
		getEl('borderVoprosTop_' + id).style.backgroundColor = '';
		getEl('textTitle_' + id).style.backgroundColor = '';
		getEl('textVoprosTr_' + id).style.backgroundColor = '';
		getEl('unsverTextForm_' + id).style.backgroundColor = '';
		getEl('unsverTextForm_' + id).style.display = 'none';
		getEl('unsverTextTr_' + id).style.display = 'none';
	}else{
		getEl('unsverA_' + id).style.display = 'none';
		getEl('textVopros_' + id).style.fontWeight = 'bold';
		getEl('borderVoprosTop_' + id).style.backgroundColor = '#EFEFEF';
		getEl('textTitle_' + id).style.backgroundColor = '#EFEFEF';
		getEl('textVoprosTr_' + id).style.backgroundColor = '#EFEFEF';
		getEl('unsverTextForm_' + id).style.backgroundColor = '#EFEFEF';
		getEl('unsverTextForm_' + id).style.display = '';
		getEl('unsverTextTr_' + id).style.display = '';
		getEl('memoUnsver_' + id).focus();
		if (getEl('unsverText_' + id).innerHTML.length < 10){
			getEl('unsverText_' + id).innerHTML = '<center style="margin-top:10px;">Загружаются ответы.<br /><img src="' + forAll.img_domen + 'img/zagruzka.gif" width="208" height="13" /></center>';
			loadUrlStream('hint/phoneOtvet/' + id + '/0/' + Math.random(), 'insertOtvet');
		};
	};
};

function showComentBlankGame(id){	// отображение бланка ответа на коментарии к играм
	if (getEl('comentForm_' + id).style.display == ''){
		getEl('comentForm_' + id).style.display = 'none';
		getEl('comentGlav_' + id).style.display = '';
	}else{
		getEl('comentGlav_' + id).style.display = 'none';
		getEl('comentForm_' + id).style.display = '';
	};
};

function insertOtvet(http){	// вставка ответов после перезагрузки
    if (http.readyState == 4){
        if (http.status == 200){
        	text = http.responseText.split('<!-- id -->');
        	if (getEl('unsverText_' + text[0]) != null)
        		getEl('unsverText_' + text[0]).innerHTML = text[1];
		};
	};
};

function insertOtzuv(http){	// вставка отзывов после перезагрузки
    if (http.readyState == 4){
        if (http.status == 200){
        	if (getEl('otzuvIdReload') != null)
        		getEl('otzuvIdReload').innerHTML = http.responseText;
		};
	};
};

function insertVopros(http){	// вставка вопросов после перезагрузки
    if (http.readyState == 4){
        if (http.status == 200){
        	if (getEl('voprosuIdReload') != null)
        		getEl('voprosuIdReload').innerHTML = http.responseText;
		};
	};
};

function insertComent(http){	// вставка коментария после перезагрузки
    if (http.readyState == 4){
        if (http.status == 200){
        	if (getEl('comentIdReload') != null)
        		getEl('comentIdReload').innerHTML = http.responseText;
		};
	};
};

function showLoad(to, text){	// отображение полосы загрузки
	if (text == null)
		text = 'Загружается&nbsp;&nbsp;';
	getEl(to).innerHTML = text + '<img src="' + forAll.img_domen + 'img/zagruzka.gif" width="208" height="13" />';
};

function showBGVopros(table, color){	// подсвечивать область вопроса и ответов на него
	table.style.backgroundColor = '#' + color;
};

function chAccLogIn(form){	// проверка авторизации при отписывании
	if (getCookie('time_in') == false){
		forAll.lastForm = form;
		showBlackBG("showLoginReg('Отзывы у нас для своих...');showKapchaReg('kapchaRegDivKoment')", "hideLoginReg()");
		return false;
	};
};

function logInDifForm(form, fun){	// попытка войти в аккаунт или зарегаться, с подальшей передачей фокуса в другую форму
	if (fun != null){
		if (eval(fun) != false){
			while (forAll.lastForm.elements.length > 0){
				forAll.lastForm.elements[0].style.display = 'none';
				form.appendChild(forAll.lastForm.elements[0]);
			};
			return true;
		};
		return false;
	}else{
		while (forAll.lastForm.elements.length > 0){
			forAll.lastForm.elements[0].style.display = 'none';
			form.appendChild(forAll.lastForm.elements[0]);
		};
		return true;
	};
	return false;
};

function kRegCodF(elId){
	getEl(elId).style.display = 'none';
};

function chOtzuvForm(form){	// проверка корректности заполнения формы отзывов
	if (form.time_us.value == '-'){
		alert('Вы не указали время пользования!');
		form.time_us.focus();
		return false;
	};
	if (form.reiting.value == ''){
		alert('Вы не поставили оценку!');
		form.time_us.focus();
		return false;
	};
	if ((form.text_adv.value == '') && (form.text_disadv.value == '')){
		alert('Вы не написали достоинства или недостатки!');
		form.text_adv.focus();
		return false;
	};
	return chAccLogIn(form);
};

function chVoprosuForm(form){	// проверка корректности заполнения формы вопросов
	if (form.text_vopros.value == ''){
		alert('Вы не написали вопрос!');
		form.text_vopros.focus();
		return false;
	}else{
		
	};
	return chAccLogIn(form);
};

function chOtvetForm(form){	// проверка корректности заполнения формы ответа на вопрос
	if (form.text_coment.value == ''){  // text_unsver
		alert('Вы не написали свой ответ!');
		form.text_unsver.focus();
		return false;
	};
	return chAccLogIn(form);
};

function chOtzuvContentForm(form){	// проверка корректности заполнения формы добавления отзыва
	if (form.text_coment.value == ''){
		alert('Вы не написали свой отзыв!');
		form.text_coment.focus();
		return false;
	};
	return chAccLogIn(form);
};

function targetIns(textarea){
	forAll.inpuutIns = textarea;
};

function setIns(type, repl){	// ф-ция вставки в поле ввода
	if (forAll.inpuutIns != null){
		memo = forAll.inpuutIns;
		range = forAll.inpuutIns.value;
		switch (type){
			case 'smail':
				dSelect.saveSelect_(memo);
				memo.value = range.substring(0, memo.__DSselectionStart) + repl.smail + range.substring(memo.__DSselectionEnd, range.length);
			break;
		};
		memo.focus();
	};
	return false;
};

function textLen(textObj, maxLen, offLen){	// обрезка текста при заполнении поля memo
	offLenObj = getEl(offLen);
	if (textObj.value.length > maxLen){
		textObj.value = textObj.value.substring(0, maxLen);
	};
	offLenObj.innerHTML = maxLen - textObj.value.length;
};

function clearKorpus(checkbox){	// выбор любого корпуса телефона в подборе
	checkbox.checked = false;
	i = 1;
	while (checkbox = getEl('korpus' + i)){
		checkbox.checked = false;
		i++;
	};
	selectKorpus();
};

function selectKorpus(){	// переопределение корпусов в подборе
	korpus = getEl('tableKorpus').getElementsByTagName('input');
	for (i=0; i<korpus.length; i++)
		if (korpus[i].checked == true){
			getEl('korpus0').checked = false;
			return null;
		};
	getEl('korpus0').checked = true;
};

function addBrandsToPodbor(select, kpk){	// добавление бренда в список подбора
	var id = select.options[select.selectedIndex].value;
	if (id != '-'){
		var text = select.options[select.selectedIndex].text;
		insertIn = getEl('divtBrands2');
		newElem = d.createElement('label');
		newElem.id = 'lableBrands' + id;
		newElem.style.display = 'block';
		insertIn.appendChild(newElem);
		insertIn = getEl('lableBrands' + id);
		newElem = d.createElement('input');
		newElem.type = 'checkbox';
		newElem.name = 'brands';
		newElem.id = 'brands' + id;
		newElem.value = id;
		newElem.onclick = function(){
			removeBrandsToPodbor(id);
			selectBrands();
			if(kpk == true)
				podborPreSubmitKpk(getEl('formP'));
			else if(kpk == 'notebook')
				podborPreSubmitNotebook(getEl('formP'));
			else if(kpk == 'dvd')
				podborPreSubmitDvd(getEl('formP'));
			else if(kpk == 'garnitury')
				podborPreSubmitGarnitury(getEl('formP'));
			else if(kpk == 'gps')
				podborPreSubmitGps(getEl('formP'));
			else if(kpk == 'mp3')
				podborPreSubmitMp3(getEl('formP'));
			else if(kpk == 'photo')
				podborPreSubmitPhoto(getEl('formP'));
			else if(kpk == 'camera')
				podborPreSubmitCamera(getEl('formP'));
			else if(kpk == 'mediaplayer')
				podborPreSubmitMedia(getEl('formP'));
			else if(kpk == 'headphone')
				podborPreSubmitHeadphone(getEl('formP'));
			else if(kpk == 'tv')
				podborPreSubmitTv(getEl('formP'));
			else podborPreSubmit(getEl('formP'));
		};
		insertIn.appendChild(newElem);
		select.removeChild(select.options[select.selectedIndex]);
		select.selectedIndex = 0;
		getEl('brands' + id).checked = true;
		newElem = d.createElement('b');
		newElem.id = 'bBrands' + id;
		newElem.innerHTML = ' ' + text;
		insertIn.appendChild(newElem);
	};
};

function addDVDTypesToPodbor(select, kpk){	// добавление бренда в список подбора
	var id = select.options[select.selectedIndex].value;
	if (id != '-'){
		var text = select.options[select.selectedIndex].text;
		insertIn = getEl('divtTypes2');
		newElem = d.createElement('label');
		newElem.id = 'labelDvdTypes' + id;
		newElem.style.display = 'block';
		insertIn.appendChild(newElem);
		insertIn = getEl('labelDvdTypes' + id);
		newElem = d.createElement('input');
		newElem.type = 'checkbox';
		newElem.name = 'dvd-types';
		newElem.id = 'dvd-types' + id;
		newElem.value = id;
		newElem.onclick = function(){
			removeDvdTypesToPodbor(id);
			selectBrands();
			if(kpk == true) {
				podborPreSubmitKpk(getEl('formP'));
			} else if(kpk == 'notebook') {
				podborPreSubmitNotebook(getEl('formP'));
			} else if(kpk == 'garnitury') {
				podborPreSubmitGarnitury(getEl('formP'));
			} else if(kpk == 'dvd') {
				podborPreSubmitDvd(getEl('formP'));
			} else if(kpk == 'photo') {
				podborPreSubmitPhoto(getEl('formP'));
			}
			else {
				podborPreSubmit(getEl('formP'));
			}
		};
		insertIn.appendChild(newElem);
		select.removeChild(select.options[select.selectedIndex]);
		select.selectedIndex = 0;
		getEl('dvd-types' + id).checked = true;
		newElem = d.createElement('span');
		newElem.id = 'bdvd-types' + id;
		newElem.innerHTML = ' ' + text;
		insertIn.appendChild(newElem);
		//alert('all ok. Mob.js => addDVDTypesToPodbor');
	};
};

function addBrandsToPodborNoSelect(id, t){	// добавление бренда в список подбора без добавление его в выпадающий список
	var text = forAll.allBrands[id].bCap;
	insertIn = getEl('divtBrands2');
	newElem = d.createElement('label');
	newElem.id = 'lableBrands' + id;
	newElem.style.display = 'block';
	insertIn.appendChild(newElem);
	insertIn = getEl('lableBrands' + id);
	newElem = d.createElement('input');
	newElem.type = 'checkbox';
	newElem.name = 'brands';
	newElem.id = 'brands' + id;
	newElem.value = id;
	newElem.onclick = function(){
		removeBrandsToPodbor(id);
		selectBrands();
		if(t == true)
			podborPreSubmitKpk(getEl('formP'));
		else if(t == 'notebook')
			podborPreSubmitNotebook(getEl('formP'));
		else if(t == 'dvd')
			podborPreSubmitDvd(getEl('formP'));
		else if(t == 'mp3')
			podborPreSubmitMp3(getEl('formP'));
		else if(t == 'garnitury')
			podborPreSubmitGarnitury(getEl('formP'));
		else if(t == 'camera')
			podborPreSubmitCamera(getEl('formP'));
		else if(t == 'mediaplayer')
			podborPreSubmitMedia(getEl('formP'));
		else if(t == 'headphone')
			podborPreSubmitHeadphone(getEl('formP'));
		else if(t == 'tv')
			podborPreSubmitTv(getEl('formP'));
		else podborPreSubmit(getEl('formP'));
	};
	insertIn.appendChild(newElem);
	getEl('brands' + id).checked = true;
	newElem = d.createElement('b');
	newElem.id = 'bBrands' + id;
	newElem.innerHTML = ' ' + text;
	insertIn.appendChild(newElem);
};

function removeBrandsToPodbor(labelId){	// удаление выбранного бренда из списка подбора
	select = getEl('selectBrands2');
	var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
	crOptionBrands(select, labelId, forAll.allBrands[labelId].bCap, where);
	label = getEl('lableBrands' + labelId);
	label.parentNode.removeChild(label);
};

function removeDvdTypesToPodbor(labelId){	// удаление выбранного бренда из списка подбора
	select = getEl('selectDvdTypes');
	var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
	crOptionBrands(select, labelId, forAll.allBrands[labelId].bCap, where);
	label = getEl('dvd-types' + labelId);
	label.parentNode.removeChild(label);
};

function clearBrands(checkbox){	// убераем галочки со всех брендов
	brands = getEl('divtBrands1').getElementsByTagName('input');
	for (i=0; i<brands.length; i++)
		brands[i].checked = false;
	brands = getEl('divtBrands2').getElementsByTagName('label');
	while (brands.length > 0){
		brands[0].parentNode.removeChild(brands[0]);
	};
	selectBrands();
};

function selectBrands(){	// нажатие на один из брендов
	brands = getEl('divtBrands1').getElementsByTagName('input');
	for (i=0; i<brands.length; i++)
		if (brands[i].checked == true){
			getEl('brands0').checked = false;
			return null;
		};
	brands = getEl('divtBrands2').getElementsByTagName('input');
	if (brands.length > 0){
		getEl('brands0').checked = false;
		return null;
	};
	getEl('brands0').checked = true;
};

function podborChYears(select1, select2, selectCh){	// выбор и смена года подбора
	if (selectCh == 1){
		if ((select1.value != '') && (select2.value != ''))
			if (select1.selectedIndex > select2.selectedIndex){
				select2.selectedIndex = select1.selectedIndex;
			};
	}else{
		if ((select1.value != '') && (select2.value != ''))
			if (select1.selectedIndex > select2.selectedIndex){
				select1.selectedIndex = select2.selectedIndex;
			};
	};
};

function addBrandsToSelect(checkedBrands, t){	// создание выпадающего списка дополнительных брендов
	select = getEl('selectBrands2');
	var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
	if (checkedBrands.length > 0)
		getEl('brands0').checked = false;
	for (i in checkedBrands){
		if (forAll.allBrands[checkedBrands[i]].bGr == 3){
			getEl('brands' + checkedBrands[i]).checked = true;
		}else{
			addBrandsToPodborNoSelect(checkedBrands[i], t);
		};
	};
};

function addKorpusToPodbor(checkedKorpus){	// включение/выключение сатически корпусов
	if (checkedKorpus.length > 0)
		getEl('korpus0').checked = false;
	for (i in checkedKorpus){
		if (getEl('korpus' + checkedKorpus[i]) != null){
			getEl('korpus' + checkedKorpus[i]).checked = true;
		};
	};
};

function setYearPicsCam(year1, year2, camPic){	// отмечение необходимого пункта выпадающего списка
	var yearSel = getEl('year10').options;
	for (i=0; i<yearSel.length; i++){
		if (yearSel[i].value == year1){
			getEl('year10').selectedIndex = i;
		};
	};
	yearSel = getEl('year20').options;
	for (i=0; i<yearSel.length; i++){
		if (yearSel[i].value == year2){
			getEl('year20').selectedIndex = i;
		};
	};
	camSel = getEl('cam4').options;
	for (i=0; i<camSel.length; i++){
		if (camSel[i].value == camPic){
			getEl('cam4').selectedIndex = i;
		};
	};
};

function crOptionBrands(select, i, brand, where){	// создание одного пункта выпадающего списка бренда
	newElem = d.createElement('option');
	newElem.id = 'brands' + i;
	newElem.value = i;
	newElem.text = brand;
	select.add(newElem, where);
};

function camSet(checkbox){	// включение/выключение параметров камеры
	getEl('cam1').checked = checkbox.checked;
	if (checkbox.checked == false){
		getEl('cam2').checked = false;
		getEl('cam3').checked = false;
	};
	camPix(!checkbox.checked);
};

function camPix(onOff){	// активность выпадающего списка
	if (onOff){
		getEl('cam4').selectedIndex = 0;
	};
};

function camCheck(checkbox){	// включение одного из параметров камеры
	if (checkbox.checked == true){
		getEl('cam0').checked = true;
	}else if(checkbox.id == 'cam1'){
		getEl('cam0').checked = false;
	};
	camSet(getEl('cam0'));
};

function chCamPix(checkbox){	// ф-ция смены пиксельности камеры
	if (checkbox.selectedIndex > 0){
		getEl('cam0').checked = true;
		camSet(getEl('cam0'));
	};
};

function podborPreSubmitTime(form){	// предъопределение возможных параметров подбора по с задержкой на ввод
	clearTimeout(forAll.pPSTime);
	forAll.pPSTime = setTimeout('podborPreSubmit(getEl(\'' + form.id + '\'))', 500);
};

function podborPreSubmit(form){	// предъопределение возможных параметров подбора
	forAll.lastActiveElement = d.activeElement;
	src = createPodborSrc(form);
	if (forAll.podborCheck == null)
		forAll.podborCheck = 'podbor/';
	if (forAll.podborCheck != src){
		forAll.podborCheck = src;
		src = forAll.domen + 'hint/podborPhone/' + src;
		if (forAll.formPCh == true){
			if (form.elements.disabled != null){
				form.elements.disabled = true;
			}else{
				for (i in form.elements){
					if (form.elements[i] != null)
						form.elements[i].disabled = true;
				};
			};
			loadUrl(src, 'showHintHelp');
//loadUrl(src, 'alertServerUnsver');
		};
	};
};

function resetPodbor(){	// возврат подбора в первоначальную форму
	var form = getEl('formP');
	for (i=0; i<form.elements.length; i++){
		switch (form.elements[i].type){
			case 'checkbox':
				form.elements[i].checked = false;
			break;
			case 'radio':
				if (/0$/.test(form.elements[i].id)){
					form.elements[i].checked = true;
				};
			break;
			case 'select-one':
				form.elements[i].selectedIndex = 0;
			break;
			case 'text':
				form.elements[i].value = '';
			break;
			case 'hidden':
				form.elements[i].value = '';
			break;
		};
	};
	clearKorpus(getEl('korpus0'));
	clearBrands(getEl('brands0'));
	podborPreSubmit(form);
};

function podborSubmit(form){	// submit(); формы подбора
	src = forAll.domen + 'phone/' + createPodborSrc(form);
	chLocation(src);
	return false;
};

function dBrands(brandsOn){	// включение/выключение бренда
	var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
	select = getEl('selectBrands2');
	while (select.options.length > 1){
		select.remove(1);
	};
	countBrands = 0;
	if (brandsOn[0] == null){
		var allBrands = {};
		for (i in forAll.allBrands){
			allBrands[i] = 1;
		};
		for (i in brandsOn){
			countBrands += (brandsOn[i] > 0 ? brandsOn[i] : 0);
			brands = getEl('brands' + i);
			if (brands != null){
				brands.disabled = false;
				if (brands.checked){
					brands.parentNode.style.backgroundColor = '#FFF5A0';
				}else{
					brands.parentNode.style.backgroundColor = '';
				};
				span = getEl('bBrands' + i);
				span.style.color = '#000000';
				span.innerText = (span.innerText != null ? span.innerText : span.textContent); 
				brandText = span.innerText.split(' (');
				span.innerHTML = brandText[0] + (brandsOn[i] > 0 ? ' <span style="color:#909090;font-weight:100;background-color:;">(' + brandsOn[i] + ')</span>' : '');
			}else{
				if(forAll.allBrands[i])
					crOptionBrands(select, i, forAll.allBrands[i].bCap + (brandsOn[i] > 0 ? ' (' + brandsOn[i] + ')' : ''), where);
			};
			allBrands[i] = null;
		};
		for (i in allBrands){
			if (allBrands[i] != null){
				brands = getEl('brands' + i);
				if (brands != null){
					span = getEl('bBrands' + i);
					span.innerText = (span.innerText != null ? span.innerText : span.textContent);
					brandText = span.innerText.split(' (');
					if (!brands.checked){
						brands.parentNode.style.backgroundColor = '';
						brands.disabled = true;
						span.style.color = '#ADADAD';
						span.innerHTML = brandText[0];
					}else{
						span.innerHTML = brandText[0] + ' <span style="color:#909090;font-weight:100;">(0)</span>';
					}
				};
			};
		};
	}else{
		for (i in forAll.allBrands){
			brands = getEl('brands' + i);
			if (brands != null){
				brands.disabled = false;
				span = getEl('bBrands' + i);
				span.style.color = '#000000';
				span.innerText = (span.innerText != null ? span.innerText : span.textContent);
				brandText = span.innerText.split(' (');
				span.innerHTML = brandText[0];
			}else{
				crOptionBrands(select, i, forAll.allBrands[i].bCap, where);
			};
		};
	};
	var countModels = getEl('countModels');
	if (countBrands > 0){
		countModels.disabled = false;
		countModels.value = 'Показать (' + countBrands + ')';
	}else{
		countModels.disabled = true;
		countModels.value = 'Показать';
	};
};

function dCC(checkbox, onOff){	// включение/выключение checkbox/radio
	checkbox = getEl(checkbox);
	if(!checkbox) return;
	if (!checkbox.checked){
		checkbox.parentNode.style.backgroundColor = '';
		checkbox.disabled = (onOff == '' ? true : false);
		if (checkbox.disabled){
			checkbox.parentNode.style.color = '#ADADAD';
		}else{
			checkbox.parentNode.style.color = '#000000';
		};
	}else{
		checkbox.parentNode.style.backgroundColor = '#FFF5A0';
	};
};

function dSelect(selectId, val){	// определение неактивности пунктов выпадающего списка
	var select = getEl(selectId);
	if (select != null){
		if (typeof val == 'object'){	// массив
			selectOpt = select.options;
			for (i=0; i<selectOpt.length; i++){
				for (j in val){
					if (selectOpt[i].value > val[j]){
						selectOpt[i].disabled = true;
						selectOpt[i].style.color = '#ADADAD';
						if (select.selectedIndex == i){
							select.selectedIndex = 0;
						};
					}else{
						selectOpt[i].disabled = false;
						selectOpt[i].style.color = '#000000';
					};
				};
			};
		}else{	// общее значение
			selectOpt = select.options;
			for (i=0; i<selectOpt.length; i++){
				if (val != '-1'){
					val = parseInt(val);
					if (isNaN(val)){
						val = -1;
					};
					if (selectOpt[i].value > val){
						selectOpt[i].disabled = true;
						selectOpt[i].style.color = '#ADADAD';
						if (select.selectedIndex == i){
							select.selectedIndex = 0;
						};
					}else{
						selectOpt[i].disabled = false;
						selectOpt[i].style.color = '#000000';
					};
				}else{
					selectOpt[i].disabled = false;
					selectOpt[i].style.color = '#000000';
				};
			};
		};
	};
};

function ogrSelect(select){	// запрет выбора неактивного поля
	if (select.options[select.selectedIndex].disabled){
		select.selectedIndex = 0;
	};
};

function actForm(formId){
	var form = getEl(formId);
	if (form.elements.disabled != null){
		form.elements.disabled = false;
	}else{
		for (i in form.elements){
			form.elements[i].disabled = false;
		};
	};
	if (forAll.lastActiveElement != null)
		forAll.lastActiveElement.focus();
};

function sHPT(){	// showHidePodborText - отображение подсказок подбора
	if (forAll.maxMP == ''){	// maxMP - maxMemPhone
		forAll.maxMP = 0;
	};
	getEl('maxMemPhone').innerHTML = forAll.maxMP;
	if (forAll.minPP == ''){	// minPP - minPricePhone
		forAll.minPP = 0;
	};
	getEl('minPricePhone').innerHTML = forAll.minPP;
	if (forAll.maxPP == ''){	// maxPP - maxPricePhone
		forAll.maxPP = 0;
	};
	getEl('maxPricePhone').innerHTML = forAll.maxPP;
	showSTGC();
};

function showSTGC(){	// showSmartTelGsmCdma - отображение колдичества SMART TEL GSM CDMA
	getEl('spanTP1').innerHTML = '';
	getEl('spanTP2').innerHTML = '';
	getEl('spanS1').innerHTML = '';
	getEl('spanS2').innerHTML = '';
	if (getEl('type_phone0').checked){
		dCC('type_phone1', forAll.t1PP);
		if (forAll.t1PP > 0){
			getEl('spanTP1').innerHTML = '(' + forAll.t1PP + ')';
		};
		dCC('type_phone2', forAll.t2PP);
		if (forAll.t2PP > 0){
			getEl('spanTP2').innerHTML = '(' + forAll.t2PP + ')';
		};
	}else{
		dCC('type_phone1', 1);
		dCC('type_phone2', 1);
	};
	if (getEl('standart0').checked){
		dCC('standart1', forAll.s1PP);
		if (forAll.s1PP > 0){
			getEl('spanS1').innerHTML = '(' + forAll.s1PP + ')';
		};
		dCC('standart2', forAll.s2PP);
		if (forAll.s2PP > 0){
			getEl('spanS2').innerHTML = '(' + forAll.s2PP + ')';
		};
	}else{
		dCC('standart1', 1);
		dCC('standart2', 1);
	};
};

function createPodborSrc(form){	// создание адресной строки для подбора
	var el = form.elements;
	var src = 'podbor/';
	var srcAr = {};
	try{
		for (i=0; i<el.length; i++){
			if (el[i].name != ''){
				switch (el[i].type){
					case 'checkbox':
						if (el[i].checked == true){
							if (srcAr[el[i].name] == null)
								srcAr[el[i].name] = [];
							srcAr[el[i].name][srcAr[el[i].name].length] = el[i].value;
						};
					break;
					case 'radio':
						if (el[i].checked == true){
							if (el[i].value != 0){
								el_val = parseInt(el[i].value);
								if (isNaN(el_val)){
									if (srcAr[el[i].value] == null)
										srcAr[el[i].value] = [];
									srcAr[el[i].value][srcAr[el[i].value].length] = 'on';
								}else{
									if (srcAr[el[i].name] == null)
										srcAr[el[i].name] = [];
									srcAr[el[i].name][srcAr[el[i].name].length] = el[i].value;
								};
							};
						};
					break;
					case 'select-one':
						if (el[i].options[el[i].selectedIndex].value != ''){
							if (srcAr[el[i].name] == null)
								srcAr[el[i].name] = [];
							srcAr[el[i].name][srcAr[el[i].name].length] = el[i].value;
						};
					break;
					case 'text':
						textTmp = el[i].value.replace(',', '.');
						textTmp = parseFloat(textTmp);
						
						textTmp = (isNaN(textTmp) ? 0 : textTmp);
						if (textTmp > 0){
							if (srcAr[el[i].name] == null)
								srcAr[el[i].name] = [];
							srcAr[el[i].name][srcAr[el[i].name].length] = textTmp;
						};
					break;
					case 'hidden':
						textTmp = parseInt(el[i].value);
						textTmp = (isNaN(textTmp) ? 0 : 1);
						if (textTmp == 1){
							if (srcAr[el[i].name] == null)
								srcAr[el[i].name] = [];
							srcAr[el[i].name][srcAr[el[i].name].length] = 'on';
						};
					break;
				};
			};
		};
		for (i in srcAr){
			if (i == 'brands'){
				if (srcAr[i].length == 1){
					if (srcAr[i][0] != 0)
						src = forAll.allBrands[srcAr[i][0]].bSrc + '/' + src;
				}else{
					src += i;
					for (j in srcAr[i])
						src += '-' + srcAr[i][j];
					src += '/';
				};
			}else if(i == 'korpus'){
				if (srcAr[i][0] != 0){
					src += i;
					for (j in srcAr[i])
						src += '-' + srcAr[i][j];
					src += '/';
				};
			}else if(i == 'pType'){
				if (srcAr[i][0] != 0){
					src += i;
					for (j in srcAr[i])
						src += '-' + srcAr[i][j];
					src += '/';
				};
			}else{
				if (srcAr[i][0] == 'on'){
					src += i + '/';
				}else{
					src += i;
					for (j in srcAr[i])
						src += '-' + srcAr[i][j];
					src += '/';
				};
			};
		};
	}catch(e){
	};
	return src;
};


















////////----------------------------------------------------------
var zakladki = new function(){
	this.allSite = new Array('Memori','&#1041;&#1086;&#1073;&#1088;&#1044;&#1086;&#1073;&#1088;','&#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1082;&#1080; Google','&#1071;&#1085;&#1076;&#1077;&#1082;&#1089;.&#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1082;&#1080;','Twitter','del.icio.us','&#1058;&#1077;&#1082;&#1089;&#1090; 2.0','News2','&#1052;&#1080;&#1089;&#1090;&#1077;&#1088; &#1042;&#1086;&#1085;&#1075;','&#1052;&#1086;&#1105;&#1052;&#1077;&#1089;&#1090;&#1086;','&#1057;&#1052;&#1048; 2','&#1042;&#1072;&#1072;&#1091;!','AddScoop','LinkStore','RuSpace','&#1057;&#1090;&#1086; &#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1086;&#1082;');
	this.showZakl = function(objZ, titleZ, srcZ){
		zakladki.title = encodeURIComponent(titleZ);
		zakladki.src = encodeURIComponent(srcZ);
		pos = getMesto(objZ);
		divZ = getEl('zakladki');
		if (divZ == null){
			insertIn = getEl('forAllHide');
			var newElem = d.createElement('div');
			newElem.id = 'zakladki';
			newElem.onmouseout = function(){
				zakladki.hideZ();
			};
			newElem.onmouseover = function(){
				clearTimeout(forAll.zakladki);
			};
			insertIn.appendChild(newElem);
			divZ = getEl('zakladki');
		};
		divZ.style.top = pos.top;
		divZ.style.left = pos.left - 189;
		html = '';
		for (i=0; i<16; i++){
			html += '<a href="' + zakladki.getSrc(i) + '" style="background-position: -274px ' + (i * -16) + 'px;" target="_blank"><span id="sfs">' + zakladki.allSite[i] + '</span></a>';
		};
		divZ.innerHTML = html;
		divZ.style.display = 'block';
	};
	this.getSrc = function(id){
		switch (id) {
			case 0: return 'http://memori.ru/link/?sm=1&u_data[url]=' + zakladki.src + '&u_data[name]=' + zakladki.title; break;
			case 1: return 'http://bobrdobr.ru/addext.html?url=' + zakladki.src + '&title=' + zakladki.title; break;
			case 2: return 'http://www.google.com/bookmarks/mark?op=add&bkmk=' + zakladki.src + '&title=' + zakladki.title; break;
			case 3: return 'http://zakladki.yandex.ru/userarea/links/addfromfav.asp?bAddLink_x=1&lurl=' + zakladki.src + '&lname=' + zakladki.title; break;
			case 4: return 'http://twitter.com/home?status=' + zakladki.title + ' ' + zakladki.src; break;
			case 5: return 'http://del.icio.us/post?v=4&noui&jump=close&url=' + zakladki.src + '&title=' + zakladki.title; break;
			case 6: return 'http://text20.ru/add/?source=' + zakladki.src + '&title=' + zakladki.title + '&text='; break;
			case 7: return 'http://news2.ru/add_story.php?url=' + zakladki.src; break;
			case 8: return 'http://www.mister-wong.ru/index.php?action=addurl&bm_url=' + zakladki.src + '&bm_description=' + zakladki.title; break;
			case 9: return 'http://moemesto.ru/post.php?url=' + zakladki.src + '&title=' + zakladki.title; break;
			case 10: return 'http://smi2.ru/add/?url=' + zakladki.src + '&precaption=' + zakladki.title; break;
			case 11: return 'http://www.vaau.ru/submit/?action=step2&url=' + zakladki.src; break;
			case 12: return 'http://myscoop.ru/add/?URL=' + zakladki.src + '&title=' + zakladki.title; break;
			case 13: return 'http://www.linkstore.ru/servlet/LinkStore?a=add&url=' + zakladki.src + '&title=' + zakladki.title; break;
			case 14: return 'http://www.ruspace.ru/index.php?link=bookmark&action=bookmarkNew&bm=1&url=' + zakladki.src + '&title=' + zakladki.title; break;
			case 15: return 'http://www.100zakladok.ru/save/?bmurl=' + zakladki.src + '&bmtitle=' + zakladki.title; break;
		};
	};
	this.hideZ = function(){
		if (getEl('zakladki') != null){
			forAll.zakladki = setTimeout('zakladki.closeZakladki()', 500);
		};
	};
	this.closeZakladki = function(){
		clearTimeout(forAll.zakladki);
		getEl('zakladki').style.display = 'none';
	};
};

function updatePhoneRating(id){	// запрос к серверу для получения рейтинга телефона
	loadUrlStream('hint/phoneOcenka/' + id + '/', 'evalU');
};

function setPhoneOcenka(ocenka) {	// определение рейтинга телефона
	getEl('rating_val').innerHTML = ocenka.ocenka;
	getEl('rating_amount').innerHTML = 'Количество голосов: ' + ocenka.count;
	getEl('ocenka_all').style.width = ocenka.width + '%';
	getEl('ocenka_all').style.backgroundColor = '#' + ocenka.color;
};

function showHelpPodbor(el){
	el = el.getElementsByTagName('INPUT')[0];
	if (el.disabled){
		clearTimeout(forAll.hHPTime);
		sHP = getEl('showHelpPodbor');
		if (sHP == null){
			insertIn = getEl('forAllHide');
			newElem = d.createElement('div');
			newElem.id = 'showHelpPodbor';
			newElem.innerHTML = 'В моделях с указанными ранее характеристиками этот параметр отсутствует';
			newElem.className = 'hint_help fArial fS13 c606060';
			newElem.style.display = 'none';
			insertIn.appendChild(newElem);
			newElem = d.createElement('div');
			newElem.id = 'showHelpPodborS';
			newElem.className = 'hHShadow';
			insertIn.appendChild(newElem);
			newElem = d.createElement('div');
			newElem.id = 'showHelpPodborYg';
			newElem.className = 'hint_help_yg';
			newElem.style.display = 'none';
			insertIn.appendChild(newElem);
			sHP = getEl('showHelpPodbor');
		};
		hintDivShadow = getEl('showHelpPodborS');
		sHPY = getEl('showHelpPodborYg');
		forAll.hintObj = {};
		forAll.hintObj.mesto = getMesto(el);
		sHPYP = setHintPos(sHP);
		sHPY.style.left = sHPYP.left;
		sHPY.style.top = sHPYP.top;
		sHPY.style.backgroundPosition = sHPYP.bgPos;
		hintDivShadow.style.display = '';
		sHP.style.display = '';
		sHPY.style.display = '';
		forAll.hHPTime = setTimeout("hideHelpPodbor()", 3000);
	};
};

function hideHelpPodbor(){
	if (getEl('showHelpPodbor') != null){
		getEl('showHelpPodbor').style.display = 'none';
		getEl('showHelpPodborS').style.display = 'none';
		getEl('showHelpPodborYg').style.display = 'none';
	};
};

function slidePhoneSearch(img, count, id, size){	// смена изображения телефона в поиске
	if (forAll.slidePS == null){
		forAll.slidePS = [];
		forAll.slidePSOldSrc = [];
		forAll.slidePSSize = [];
	};
	img = img.getElementsByTagName('IMG')[0];
	clearTimeout(forAll.slidePSTime);
	if (count == 0){
		if (forAll.slidePS[id] != null){
			img.src = forAll.slidePSOldSrc[id];
			img.width = forAll.slidePSSize[id].width;
			img.height = forAll.slidePSSize[id].height;
			img.style.marginTop = 0;
		};
	}else if(count > 1){
		forAll.slidePS[id] = img;
		forAll.slidePSOldSrc[id] = img.src;
		forAll.slidePSSize[id] = {width:img.width,height:img.height};
		forAll.slidePSTime = setTimeout('slidePhoneSearchTime(2, ' + count + ', ' + id + ', ' + size + ')', forAll.slidePSTWait);
	}else{
		forAll.slidePS[id] = null;
	};
};

function slidePhoneSearchTime(nowImg, count, id, size){
	newImg = new Image();
	newImg.onload = function(){
		forAll.slidePS[id].style.marginTop = Math.round((size - newImg.height)/2) + 'px';
		forAll.slidePS[id].height = newImg.height;
		forAll.slidePS[id].width = newImg.width;
		forAll.slidePS[id].src = newImg.src;
		forAll.slidePSTime = setTimeout('slidePhoneSearchTime(' + nowImg + ', ' + count + ', ' + id + ', ' + size + ')', forAll.slidePSTWait);
	};
	if (nowImg > count){
		newSrc = '01';
		nowImg = 2;
	}else{
		newSrc = (nowImg < 10 ? '0' + nowImg : nowImg);
		nowImg++;
	};
	oldSrc = forAll.slidePSOldSrc[id].split('/');
	oldSrc[oldSrc.length-1] = oldSrc[oldSrc.length-1].replace(/^(\d{2})(_[^\/\.]+\.\w+)$/, newSrc + '$2');
	newImg.src = implode('/', oldSrc);
};

function showAndHide(obj, id, title){
	if (typeof obj != 'object')
		obj = getEl(obj);
	if (getEl(id).style.display == ''){
		getEl(id).style.display = 'none';
		if (title != null){
			obj.innerHTML = title[0];
		};
	}else{
		getEl(id).style.display = '';
		if (title != null){
			obj.innerHTML = title[1];
		};
	};
	setCookie(id, getEl(id).style.display, 2592000);
};

function picDelPar(par){	// удаление параметра просмотра из адреса
	var link = [];
	for (var i in par){
		if (typeof par[i] == 'string'){
			if (par[i] != ''){
				link[link.length] = i + '=' + par[i];
			};
		}else{
			if (par[i][0] != ''){
				var k = link.length;
				link[k] = i + '=' + par[i][0];
				for (var j=1; j<par[i].length; j++){
					link[k] += '+' + par[i][j];
				};
			};
		};
	};
	if (link.length > 0){
		d.location = forAll.pic_domen + 'gallery/' + implode(';', link) + '/';
	}else{
		d.location = forAll.pic_domen;
	};
};

function picSetColorType(objColorType){
	if ((objColorType.parentNode != null) && (objColorType.parentNode.className != 'picCTS')){
		forAll.picType = parseInt(objColorType.parentNode.id.replace(/picColorType(\d+)/, '$1'));
		for (var i=1; i<4; i++){
			getEl('picColorType' + i).className = '';
		};
		objColorType.parentNode.className = 'picCTS';
		picLookImg();
	};
};

function picLookImg(){	// изменение изображения
	if (forAll.picQueryImg != forAll.picType + ':' + getEl('picLight').value + ':' + getEl('picContrast').value + ':' + getEl('picSize').value + ':' + forAll.picImg + ':' + forAll.picSize + ':' + (forAll.myImg != null ? 1 : 0)){
		getEl('picLookImg').src = forAll.img_domen + 'img/1x1.gif';
		forAll.range1.load();
		forAll.range2.load();
		forAll.range3.load();
		if (getEl('picTelPhone') != null)
			getEl('picTelPhone').disabled = true;
		for (var i=1; i<4; i++){
			getEl('picColorType' + i).getElementsByTagName('A')[0].onclick = null;
			getEl('picColorType' + i).getElementsByTagName('DIV')[1].style.background = 'url(' + forAll.img_domen + 'img/range/load.gif) no-repeat center center';
		};
		var arrayPar = {type:forAll.picType, picLight:getEl('picLight').value, picContrast:getEl('picContrast').value, picSize:getEl('picSize').value, img:forAll.picImg, size:forAll.picSize};
		if (forAll.myImg != null){
			if (forAll.picImg == getCookie('myImgMod_') && forAll.picSize == getCookie('myImgMod_size')){
				arrayPar.myImg = getCookie('myImgSrc');
			}else{
				arrayPar.myImg = 0;
			};
		}else if(forAll.selfImg != null){
			arrayPar.myImg = forAll.selfImg;
		};
		loadUrlStream(forAll.pic_domen + 'hint/getNewSize/', 'evalU', arrayPar);
	};
};

function reloadLookImg(par){	// ответ севера после изменения изображения
	if (par.stop == null){
		if (par.type != null){
			forAll.picType = par.type;
		};
		if (par.img != null){
			getEl('picLookImg').src = par.img;
		}else{
			picNoSizeImg();
		};
		if (par.filesSize != null && par.filesSize != ''){
			for (var i=1; i<par.filesSize.length + 1; i++){
				getEl('picSizeFile' + i).innerHTML = Math.round(par.filesSize[i - 1] / 1024) + 'Kb';
			};
		}else{
			for (var i=1; i<6; i++){
				getEl('picSizeFile' + i).innerHTML = '0Kb';
			};
		};
		if (par.cod != null){
			getEl('picWapCod').innerHTML = '<span>' + par.cod[0] + '</span>' + par.cod[1];
		};
	}else{
		picNoSizeImg();
		for (var i=1; i<6; i++){
			getEl('picSizeFile' + i).innerHTML = '0Kb';
		};
	};
};

function picSetFun(){	// определение всех необходимых ф-ций при просмотре отдельного изображения
	forAll.picQueryImg = forAll.picType + ':' + getEl('picLight').value + ':' + getEl('picContrast').value + ':' + getEl('picSize').value + ':' + forAll.picImg + ':' + forAll.picSize + ':' + (forAll.myImg != null ? 1 : 0);
	getEl('picLookImg').onload = picImgLoaded;
	for (var i=1; i<4; i++){
		getEl('picColorType' + i).getElementsByTagName('A')[0].onclick = function(){picSetColorType(this);};
		getEl('picColorType' + i).getElementsByTagName('DIV')[1].style.background = 'url(' + forAll.img_domen + 'img/color/face.gif) no-repeat -' + (33 * (i - 1)) + 'px 0';
	};
};

function picWriteSize(brands){	// отображение списка размеров
	var links = getEl('picAllSize').getElementsByTagName('A');
	for(var i=0; i<links.length; i++){
		var sizeTmp = links[i].name;
		links[i].href = 'javascript:setNewPicSize(\'' + sizeTmp + '\');';
		links[i].id = 'picASAC_' + sizeTmp;
		links[i].onclick = function(){
			clearCookie('gamebrand');
			clearCookie('gamebrandnumber');
			clearCookie('gamephonescrsize');
			clearCookie('gamephone');
			clearCookie('gamephonenumber');
		};
		if (forAll.picSize == sizeTmp && forAll.actSelf == 0){
			links[i].parentNode.className = 'picLAS';
		};
	};
	var mySize = getCookie('size');
	if (forAll.noDBSize === true && mySize !== false){
		var mySLink = '<div';
		mySLink += ' class="picLAS"';
		getEl('pic_self_size').innerHTML = mySLink += '><a href="javascript:setNewPicSize(\'' + mySize + '\', null, true);" id="picASAC_' + mySize + '_"><span>Свой ' + mySize + '</span></a></div>';
	}else{
		mySize = getCookie('myImgMod_');
		if (mySize !== false && mySize == forAll.picImg){
			mySize = getCookie('myImgMod_size');
			var mySLink = '<div';
			if (forAll.actSelf == 1){
				forAll.myImg = true;
				mySLink += ' class="picLAS"';
			};
			getEl('pic_self_size').innerHTML = mySLink += '><a href="javascript:setNewPicSize(\'' + mySize + '\', null, true);" id="picASAC_' + mySize + '_"><span>Свой ' + mySize + '</span></a></div>';
		};
	};
	var gB = getCookie('gamebrand');
	var gBB = false;
	d.write('<div style="margin-top:10px;padding:10px 5px 5px 5px;background-color:#e6e6e6;border-top:#959595 1px solid;">');
	d.write('<table cellpadding="0" cellspacing="0" style="overflow:hidden;width:110px;height:110px;background-color:#ffffff;"><tr><td align="center"><img src="' + forAll.img_domen + 'img/net.gif" id="picImgPhoneL" style="border:#fff 5px solid;" /></td></tr></table>');
	d.write('<select id="picTelBrand" OnChange="picLoadPhone(this);" style="margin-top:15px;width:150px;">');
	d.write('<option value="0" style="background-color:#ffffff;">Выберите производителя</option>');
	for (i in brands){
		d.write('<option value="' + i + '" src="' + brands[i][1] + '"' + (i == gB ? ' selected' : '') + ' class="gameSelectOption' + brands[i][2] + '">' + brands[i][0] + '</option>');
		if (i == gB)
			gBB = true;
	};
	d.write('</select>');
	d.write('<select id="picTelPhone" OnChange="modelILNS(this);" DISABLED style="width:150px;">');
	d.write('<option value="0|0|0" style="background-color:#ffffff;">Выберите модель</option>');
	d.write('</select>');
	d.write('</div>');
	if (gBB){
		forAll.gamePhone = getCookie('gamephone');
		picLoadPhone(getEl('picTelBrand'));
	};
};

function modelILNS(select){
	var size = select.options[select.selectedIndex].value.split('|');
	if (getEl('picTelBrand').options[getEl('picTelBrand').selectedIndex].value != 0){
		setCookie('gamebrand', getEl('picTelBrand').options[getEl('picTelBrand').selectedIndex].value, 3600);
		setCookie('gamebrandnumber', getEl('picTelBrand').options[getEl('picTelBrand').selectedIndex].index, 3600);
		if (size[1] != 0){
			var brand = getEl('picTelBrand').options[getEl('picTelBrand').selectedIndex].getAttribute('src');
			getEl('picImgPhoneL').src = forAll.img_domen + 'phone/100_100_1/' + brand + '/' + brand + '_' + size[2] + '/01_' + brand + '_' + size[2] + '.jpg';
			setCookie('gamephonescrsize', size[0], 3600);
			setCookie('size', size[0], 3600);
			setCookie('gamephone', size[1], 7776000);
			setCookie('gamephonenumber', select.options[select.selectedIndex].index, 3600);
			if (getEl('picASAC_' + size[0] + '_') == null){
				var noStSize = true;
				for (var s in forAll.allPicSize){
					if (size[0] == forAll.allPicSize[s]){
						noStSize = false;
						break;
					};
				};
				if (noStSize){
					getEl('pic_self_size').innerHTML = '<div><a href="javascript:setNewPicSize(\'' + size[0] + '\', null, true);" id="picASAC_' + size[0] + '_"><span>Свой ' + (size[0] != '0x0' ? size[0] : 'размер') + '</span></a></div>';
					setNewPicSize(size[0], true, true);
				}else{
					getEl('pic_self_size').innerHTML = '';
					setNewPicSize(size[0], true);
				};
			};
			return true;
		};
	};
	getEl('pic_self_size').innerHTML = '';
	getEl('picImgPhoneL').src = forAll.img_domen + 'img/net.gif';
};

function picLoadPhone(select){
	getEl('picImgPhoneL').src = forAll.img_domen + 'img/net.gif';
	clearCookie('gamebrand');
	clearCookie('gamebrandnumber');
	clearCookie('gamephonescrsize');
	clearCookie('gamephone');
	clearCookie('gamephonenumber');
	if (select.options[select.selectedIndex].value > 0){
		loadUrlStream(forAll.pic_domen + 'hint/loadPhone/' + select.options[select.selectedIndex].value + '/', 'evalU');
	}else{
		while (getEl('picTelPhone').options.length > 1){
			getEl('picTelPhone').remove(1);
		};
		getEl('picTelPhone').disabled = true;
	};
};

function addToTelPhone(models){
	forAll.gamePhone = (forAll.gamePhone != null ? forAll.gamePhone : 0);
	var objSelect = getEl('picTelPhone');
	while (objSelect.options.length > 1){
		objSelect.remove(1);
	};
	objSelect.disabled = false;
	for (var i=0; i<models.length; i++){
		var newElem = d.createElement('option');
		newElem.text = models[i].t;
		newElem.style.backgroundColor = '#ffffff';
		newElem.value = models[i].v + '|' + models[i].i + '|' + models[i].s;
		if (forAll.gamePhone == models[i].i){
			newElem.selected = true;
		};
		objSelect.add(newElem, where);
		if (forAll.gamePhone == models[i].i){
			modelILNS(objSelect);
		};
	};
};

function setNewPicSize(size, phone, my){
	if (getEl('picASAC_' + size + '_') != null || getEl('picASAC_' + size) != null){
		if ((getEl('picASAC_' + size + '_') != null && getEl('picASAC_' + size + '_').parentNode.className != 'picLAS') || (getEl('picASAC_' + size) != null && getEl('picASAC_' + size).parentNode.className != 'picLAS')){
			if (forAll.picSlide != null){
				forAll.picSlide.side.left = false;
				forAll.picSlide.side.right = false;
			};
			forAll.picSize = size;
			forAll.myImg = my;
			picSetSize(true);
			if (forAll.picSlide != null)
				forAll.picSlide.load(0);
			if (phone !== true){
				getEl('picTelBrand').selectedIndex = 0;
				getEl('picTelPhone').selectedIndex = 0;
				while (getEl('picTelPhone').options.length > 1){
					getEl('picTelPhone').remove(1);
				};
				getEl('picTelPhone').disabled = true;
				getEl('picImgPhoneL').src = forAll.img_domen + 'img/net.gif';
			};
			var links = getEl('picAllSize').getElementsByTagName('A');
			for(var i=0; i<links.length; i++){
				if(links[i].id != 'picASAC_' + size || my === true){
					links[i].parentNode.className = '';
				}else{
					links[i].parentNode.className = 'picLAS';
				};
			};
			if (my == true){
				getEl('picASAC_' + size + '_').parentNode.className = 'picLAS';
			};
		};
	}else{
		picNoSizeImg();
	};
};

function picImgLoaded(){
	if (getEl('picLookImg').src != forAll.img_domen + 'img/1x1.gif'){
		forAll.range1.loaded();
		forAll.range2.loaded();
		forAll.range3.loaded();
		picSetFun();
		if (getEl('picTelPhone') != null){
			if (getEl('picTelPhone').options.length > 1){
				getEl('picTelPhone').disabled = false;
			};
		};
	};
};

function picNoSizeImg(){
	forAll.tmpPicSize = forAll.picSize;
	forAll.picSize = '240x320';
	picSetSize(false);
	getEl('picLookImg').src = forAll.img_domen + 'pic/gallery/240x320/0.jpg';
	forAll.picSize = forAll.tmpPicSize;
	delete forAll.tmpPicSize;
};

function picSetSize(srcRev){
	try {
		if (forAll.picQueryImg != forAll.picType + ':' + getEl('picLight').value + ':' + getEl('picContrast').value + ':' + getEl('picSize').value + ':' + forAll.picImg + ':' + forAll.picSize + ':' + (forAll.myImg != null ? 1 : 0)){
			setRealSrc();
			if (srcRev === true){
				picLookImg();
			};
			setNSIR();
		};
	}catch(e){
	};
};

function setNSIR(){
	var size = forAll.picSize.split('x');
	size[0] = parseInt(size[0]);
	size[1] = parseInt(size[1]);
	if (size[0] > 240){
		size[1] = Math.round(size[1] * 240 / size[0]);
		size[0] = 240;
	};
	getEl('picVZI').style.width = size[0] + 14;
	getEl('picVZI').style.height = size[1] + 14;
	getEl('picBZI').style.width = size[0] + 13;
	getEl('picBZI').style.height = size[1] + 13;
	getEl('picLookImg').style.width = size[0];
	getEl('picLookImg').style.height = size[1];
	getEl('picDZI').style.width = size[0] + 12;
	getEl('picDZI').style.height = size[1] + 12;
};

function setNewSizeCut(){
	setNSIR();
};

function slide(pr){	// слайдинг изображений
	var self = this;
	this.step = pr.step;
	this.timeAR = pr.timeAR;
	this.timeSR = pr.timeSR;
	this.countLoad = 6;
	this.color = ['', '', '-bw', '-sepia'];
	this.side = {left:false,right:false,first:0,last:0};
	this.noScroll = false;
	this.show = function(img, add, size){
		size = size.split('x');
		size = Math.round(parseInt(size[1]) * 111 / parseInt(size[0]));
		getEl('picSlideDiv').style.height = size + 39;
		var color = self.color[forAll.picType];
		switch (add){
			case 0:
//				var ci = getEl('picImgSlide').rows[0].cells.length;
				self.side.first = 0;
				self.side.last = 0;
				var left = 0;
				var right = 0;
				getEl('picImgSlide').deleteRow(0);
				getEl('picImgSlide').insertRow(0);
				var ci = 0;
				for(var j in img){
					if (self.side.first < parseInt(j)){
						self.side.first = parseInt(j);
						if (self.side.last == 0){
							self.side.last = parseInt(j);
						};
					};
					if (self.side.last > parseInt(j)){
						self.side.last = parseInt(j);
					};
					getEl('picImgSlide').rows[0].insertCell(ci);
					getEl('picImgSlide').rows[0].cells[ci++].innerHTML = '<a href="' + forAll.pic_domen + 'image/' + img[j] + '-' + j + '.html" class="hand' + (forAll.picImg != j ? '' : ' act') + '"><div class="picShadow pS' + size + '"></div><div class="picImg pI' + size + '"><div class="pId' + size + '"><img src="' + forAll.img_domen + 'img/color/grad.png" class="pId' + size + '" /></div></div><img src="' + forAll.img_domen + 'pic/gallery/111x' + size + '/' + img[j] + '-' + j + '.jpg" class="picObj i' + size + '" /></a>';
//					getEl('picImgSlide').rows[0].cells[ci++].innerHTML = '<a href="' + forAll.pic_domen + 'image/' + img[j] + '-' + j + color + '.html" class="hand' + (forAll.picImg != j ? '' : ' act') + '"><div class="picShadow pS' + size + '"></div><div class="picImg pI' + size + '"><div class="pId' + size + '"><img src="' + forAll.img_domen + 'img/color/grad.png" class="pId' + size + '" /></div></div><img src="' + forAll.img_domen + 'pic/gallery/111x' + size + '/' + img[j] + '-' + j + '.jpg" class="picObj i' + size + '" /></a>';
					if (forAll.picImg < parseInt(j)){
						++left;
					}else{
						++right;
					};
				};
				var count = Math.round(parseInt(getEl('picLookImgList').offsetWidth) / 159);
				if (left + right >= count){
					if (right < count){
						getEl('picImgSlide').style.marginLeft = (left + right - count) * -159;
					}else if(left > 0){
						getEl('picImgSlide').style.marginLeft = (left - 1) * -159;
					}else{
						getEl('picImgSlide').style.marginLeft = 0;
					};
				}else{
					self.noScroll = true;
					getEl('picImgSlide').style.marginLeft = 0;
					getEl('picScrollLeft').style.display = 'none';
					getEl('picScrollRight').style.display = 'none';
					self.side.left = true;
					self.side.right = true;
				};
			break;
			case 1:
				var margin = parseInt(getEl('picImgSlide').style.marginLeft);
				for(var j in img){
					if (self.side.first < parseInt(j)){
						self.side.first = parseInt(j);
					};
					getEl('picImgSlide').rows[0].insertCell(0);
					getEl('picImgSlide').rows[0].cells[0].innerHTML = '<a href="' + forAll.pic_domen + 'image/' + img[j] + '-' + j + '.html" class="hand' + (forAll.picImg != j ? '' : ' act') + '"><div class="picShadow pS' + size + '"></div><div class="picImg pI' + size + '"><div class="pId' + size + '"><img src="' + forAll.img_domen + 'img/color/grad.png" class="pId' + size + '" /></div></div><img src="' + forAll.img_domen + 'pic/gallery/111x' + size + '/' + img[j] + '-' + j + '.jpg" class="picObj i' + size + '" /></a>';
//					getEl('picImgSlide').rows[0].cells[0].innerHTML = '<a href="' + forAll.pic_domen + 'image/' + img[j] + '-' + j + color + '.html" class="hand' + (forAll.picImg != j ? '' : ' act') + '"><div class="picShadow pS' + size + '"></div><div class="picImg pI' + size + '"><div class="pId' + size + '"><img src="' + forAll.img_domen + 'img/color/grad.png" class="pId' + size + '" /></div></div><img src="' + forAll.img_domen + 'pic/gallery/111x' + size + '/' + img[j] + '-' + j + '.jpg" class="picObj i' + size + '" /></a>';
					getEl('picImgSlide').style.marginLeft = (margin-=159);
					self.side.left = false;
				};
			break;
			case 2:
				var ci = getEl('picImgSlide').rows[0].cells.length;
				for(var j in img){
					if (self.side.last > parseInt(j)){
						self.side.last = parseInt(j);
					};
					getEl('picImgSlide').rows[0].insertCell(ci);
					getEl('picImgSlide').rows[0].cells[ci++].innerHTML = '<a href="' + forAll.pic_domen + 'image/' + img[j] + '-' + j + '.html" class="hand' + (forAll.picImg != j ? '' : ' act') + '"><div class="picShadow pS' + size + '"></div><div class="picImg pI' + size + '"><div class="pId' + size + '"><img src="' + forAll.img_domen + 'img/color/grad.png" class="pId' + size + '" /></div></div><img src="' + forAll.img_domen + 'pic/gallery/111x' + size + '/' + img[j] + '-' + j + '.jpg" class="picObj i' + size + '" /></a>';
//					getEl('picImgSlide').rows[0].cells[ci++].innerHTML = '<a href="' + forAll.pic_domen + 'image/' + img[j] + '-' + j + color + '.html" class="hand' + (forAll.picImg != j ? '' : ' act') + '"><div class="picShadow pS' + size + '"></div><div class="picImg pI' + size + '"><div class="pId' + size + '"><img src="' + forAll.img_domen + 'img/color/grad.png" class="pId' + size + '" /></div></div><img src="' + forAll.img_domen + 'pic/gallery/111x' + size + '/' + img[j] + '-' + j + '.jpg" class="picObj i' + size + '" /></a>';
					self.side.right = false;
				};
			break;
		};
	};
	this.scroll = function(e){
		if (self.noScroll == true)
			return false;
		var wDelta = 0;
		if (!e){
			e = window.event;
		};
		if (e.wheelDelta){
			wDelta = e.wheelDelta / 120;
		}else if (e.detail){
			wDelta = -e.detail / 3;
		};
		if (wDelta){
			var currentPosition = parseInt(getEl('picImgSlide').style.marginLeft);
			var newPosition = wDelta * self.step + currentPosition;
			getEl('picScrollLeft').style.display = '';
			getEl('picScrollRight').style.display = '';
			if (wDelta < 0){
				if(parseInt(getEl('picLookImgList').offsetWidth) >= getEl('picImgSlide').rows[0].cells.length * 159 + newPosition){
					newPosition = getEl('picImgSlide').rows[0].cells.length * -159 + parseInt(getEl('picLookImgList').offsetWidth) + 15;
					getEl('picScrollRight').style.display = 'none';
				}else{
					getEl('picScrollRight').style.backgroundColor = '#046db7';
				};
				clearTimeout(self.wD0);
				self.wD0 = setTimeout("getEl('picScrollRight').style.backgroundColor = ''", self.timeAR);
				self.setPosition(newPosition);
				if ((parseInt(getEl('picLookImgList').offsetWidth) + self.countLoad * 159) >= getEl('picLookImgList').scrollWidth){
					if (self.side.right == false){
						self.side.right = true;
						self.load(2);
					};
				};
			}else{
				if (newPosition >= 0){
					newPosition = 0;
					getEl('picScrollLeft').style.display = 'none';
				}else{
					getEl('picScrollLeft').style.backgroundColor = '#046db7';
				};
				clearTimeout(self.wD1);
				self.wD1 = setTimeout("getEl('picScrollLeft').style.backgroundColor = ''", self.timeAR);
				self.setPosition(newPosition);
				if(self.countLoad * 159 >= -newPosition){
					if (self.side.left == false){
						self.side.left = true;
						self.load(1);
					};
				};
			};
		};
		if (e.preventDefault){
			e.preventDefault();
		};
		e.returnValue = false;
	};
	this.setPosition = function(newPosition){
		getEl('picImgSlide').style.marginLeft = newPosition + 'px';
		return false;
	};
	this.scrollLeft = function(){
		self.scroll({wheelDelta:-120});
		self.sT = setTimeout("getEl('picScrollRight').onmousedown();", self.timeSR);
		document.onmouseup = self.scrollClear;
	};
	this.scrollRight = function(){
		self.scroll({wheelDelta:120});
		self.sT = setTimeout("getEl('picScrollLeft').onmousedown();", self.timeSR);
		document.onmouseup = self.scrollClear;
	};
	this.scrollClear = function(){
		clearTimeout(self.sT);
		document.onmouseup = null;
	};
	this.load = function(first){
    	var arrayPar = {razdel:forAll.razdel, side:first, size:forAll.picSize, color:forAll.picColor, img:forAll.picImg};
    	if (first == 1){
    		arrayPar.from = self.side.first;
    	}else{
    		arrayPar.from = self.side.last;
    	};
    	loadUrlStream(forAll.pic_domen + 'hint/lookImgList/?' + Math.random(), 'evalU', arrayPar);
	};
	this.load(0);
	getEl('picScrollLeft').onmousedown = self.scrollRight;
	if (getEl('slideList').addEventListener){
		getEl('slideList').addEventListener('DOMMouseScroll', self.scroll, false);
	};
	getEl('slideList').onmousewheel = self.scroll;
	getEl('picScrollRight').onmousedown = self.scrollLeft;
};

function picResetMod(){
	forAll.range1.reset();
	forAll.range2.reset();
	forAll.range3.reset();
	picLookImg();
};

function picDownloadImg(img){
	if (/\/0.jpg$/.test(img.src)){
		d.location = getEl('picCutSelf').href;
	}else{
		var src = img.src.split('/');
		var newSrc = src[3];
		for (var i=4; i<src.length; i++){
			newSrc += '/' + src[i];
		};
		d.location = forAll.pic_domen + 'download/' + newSrc;
	};
};

function setRealSrc(){
	var size = (forAll.tmpPicSize != null ? forAll.tmpPicSize : forAll.picSize).split('x');
	var gBrand = getCookie('gamebrand');
	var gPhone = getCookie('gamephone');
	if (size[0] * size[1] != 0){
		size[0] = parseInt(size[0]) + 4;
		size[1] = parseInt(size[1]) + 4;
		var newSrc = forAll.toCutNew + 'rmw:' + size[0] + ';rmh:' + size[1] + ';rw:' + size[0] + ';rh:' + size[1] + ';' + ((gBrand !== false && gBrand != '' && gPhone !== false && gPhone != '') ? 'bp:' + gBrand + ';tp:' + gPhone + ';' : 'ss:1;');
	}else{
		var newSrc = forAll.toCutNew;
	};
	getEl('picCutSelf').href = newSrc;
};

function picLoadImg(form){
	if (form.picImgWWW.value == ''){
		alert('Вы не указали изображение!');
		return false;
	};
	var gBrand = getCookie('gamebrand');
	var gPhone = getCookie('gamephone');
	var size = getCookie('gamephonescrsize');
	if ((gBrand !== false) && (gBrand !== false) && (size !== false)){
		size = size.split('x');
		var newSrc = forAll.pic_domen + 'cut/#src:' + form.picImgWWW.value + ';rmw:' + (parseInt(size[0]) + 4) + ';rmh:' + (parseInt(size[1]) + 4) + ';rw:' + (parseInt(size[0]) + 4) + ';rh:' + (parseInt(size[1]) + 4) + ';' + 'bp:' + parseInt(gBrand) + ';tp:' + parseInt(gPhone) + ';';
	}else{
		var newSrc = forAll.pic_domen + 'cut/#src:' + form.picImgWWW.value + ';';
	};
	d.location = newSrc;
	return false;
};

function picLoadImgPC(form){
	if (form.picImgPC.value == ''){
		('Вы не указали изображение!');
		return false;
	};
};

function addModelRPanel(list){
	var model = '';
	for (var i in list){
		model += '<option class="gameSelectOption0" ssize="' + list[i][1] + 'x' + list[i][2] + '" value="' + i + '">' + list[i][0] + '</option>';
	};
	getEl('spanmodellist2').innerHTML = "<select id='modellist2' name='modellist2' style='width: 100%;' OnChange=setCookie('gamephone',this.options[this.selectedIndex].value,3600);setCookie('gamephonenumber',this.options[this.selectedIndex].index,3600);setCookie('gamephonescrsize',this.options[this.selectedIndex].getAttribute('ssize'),3600);setCookie('t_rek',1,3600);window.location=window.location;><option class='gameSelectOption0' name='0x0' value='0'>Выберите Модель</option>" + model + "</select>";
};

function chL2S(par){
	if (getEl('picDelEl_size') != null){
		var select = '<select class="input" style="width:105px;" OnChange="clearCookie(\'size\');changeUrl(this);">';
		var color = '';
		var first = [];
		if (par.color != ''){
			color = 'color=' + par.color + ';';
			first[first.length] = 'color=' + par.color;
		};
		if (par.tag.length > 0 && par.tag[0] != ''){
			var tag = ';tag=' + implode('+', par.tag);
			first[first.length] = 'tag=' + implode('+', par.tag);
		}else{
			var tag = '';
		};
		select += '<option value="' + forAll.pic_domen + (first.length > 0 ? 'gallery/' + implode(';', first) + '/' : '') + '">Без размера</option>';
		for (var s in forAll.allPicSize){
			select += '<option value="' + forAll.pic_domen + 'gallery/' + color + 'size=' + forAll.allPicSize[s] + tag + '/"' + (forAll.allPicSize[s] == par.size ? ' selected' : '') + '>' + forAll.allPicSize[s] + '</option>';
		};
		select += '</select>';
		getEl('picDelEl_size').innerHTML = select;
	};
};



function picSelTag(e){	// нажатие кнопки вниз и вверх при выборе тега изображения
	e = (!e ? event : e);
	var edit = (e.srcElement != null ? e.srcElement : e.target);
	if (forAll.sTmpActWord == null)
		forAll.sTmpActWord = {};
	if (forAll.sTmpActWord[edit.id] == null){
		forAll.sTmpActWord[edit.id] = -1;
	};
	if (e.keyCode == 40){	// вниз
		var picTagA = getEl('div' + edit.id).getElementsByTagName('A');
		if (forAll.sTmpActWord[edit.id] > -1 && picTagA[forAll.sTmpActWord[edit.id]] != null)
			picTagA[forAll.sTmpActWord[edit.id]].style.backgroundColor = '';
		++forAll.sTmpActWord[edit.id];
		if (picTagA[forAll.sTmpActWord[edit.id]] != null){
			edit.value = picTagA[forAll.sTmpActWord[edit.id]].innerHTML.replace(/<[^>]+>/ig, '');
			picTagA[forAll.sTmpActWord[edit.id]].style.backgroundColor = '#a0a0a0';
			if (picTagA[forAll.sTmpActWord[edit.id] + 2] != null){
				if (picTagA[forAll.sTmpActWord[edit.id] + 2].style.display != '')
					picTagA[forAll.sTmpActWord[edit.id] + 2].style.display = '';
				if (picTagA[forAll.sTmpActWord[edit.id] - forAll.showOne + 2] != null)
					picTagA[forAll.sTmpActWord[edit.id] - forAll.showOne + 2].style.display = 'none';
			};
			if (picTagA.length - forAll.sTmpActWord[edit.id] < forAll.showOne + 2){
				if (forAll.picNowLoad !== true){
					forAll.picNowLoad = true;
					picSearchTagTime(edit, picTagA.length);
				};
			};
		}else{
			forAll.sTmpActWord[edit.id] = picTagA.length;
			edit.value = forAll.picTagSearch;
		};
		return true;
	}else if(e.keyCode == 38){	// вверх
		var picTagA = getEl('div' + edit.id).getElementsByTagName('A');
		if (picTagA[forAll.sTmpActWord[edit.id]] != null)
			picTagA[forAll.sTmpActWord[edit.id]].style.backgroundColor = '';
		--forAll.sTmpActWord[edit.id];
		if (forAll.sTmpActWord[edit.id] > -1 && picTagA[forAll.sTmpActWord[edit.id]] != null){
			edit.value = picTagA[forAll.sTmpActWord[edit.id]].innerHTML.replace(/<[^>]+>/ig, '');
			picTagA[forAll.sTmpActWord[edit.id]].style.backgroundColor = '#a0a0a0';
			if (picTagA[forAll.sTmpActWord[edit.id] - 2] != null){
				picTagA[forAll.sTmpActWord[edit.id] - 2].style.display = '';
				if (picTagA[forAll.sTmpActWord[edit.id] + forAll.showOne - 2] != null)
					picTagA[forAll.sTmpActWord[edit.id] + forAll.showOne - 2].style.display = 'none';
			};
		}else{
			forAll.sTmpActWord[edit.id] = -1;
			edit.value = forAll.picTagSearch;
		};
		return true;
	}else if(e.keyCode == 13){	// Enter
		var picTagA = getEl('div' + edit.id).getElementsByTagName('A');
		if (forAll.sTmpActWord[edit.id] > -1 && picTagA[forAll.sTmpActWord[edit.id]] != null){
			d.location = picTagA[forAll.sTmpActWord[edit.id]].href;
		}else{
			if (forAll.dibilClick == null){
				forAll.dibilClick = 5;
			};
			if (forAll.dibilClick <= 0){
				alert('Ты ШО, тупой? о_0\nСказано же, выбери один из пунктов!');
			}else{
				--forAll.dibilClick;
				alert('Выберите один из пунктов в выпадающем списке под полем ввода.');
			};
		};
		return true;
	};
	return false;
};

function picSearchTag(edit, zon){	// поиск тегов изображений
	if (forAll.picSTTime == null)
		forAll.picSTTime = {};
	clearTimeout(forAll.picSTTime[zon]);
	if (forAll.noSearch === true)
		return false;
	delete forAll.sTmpActWord;
	if (getEl('divpTS_' + zon) != null && edit.value != ''){
		if (edit.value != forAll.picTagSearch){
			forAll.picTagSearch = edit.value;
			forAll.picSTTime[zon] = setTimeout("picSearchTagTime('" + zon + "', 0);", forAll.timeTagSearch);
		};
	}else{
		forAll.picTagSearch = '';
		if (getEl('divpTS_' + zon) != null)
			getEl('divpTS_' + zon).style.display = 'none';
	};
};
function picSearchTagTime(zon, limit){	// поиск тегов изображений
	edit = (typeof zon == 'string' ? getEl('pTS_' + zon) : zon);
	zon = (typeof zon == 'string' ? zon : zon.id.replace(/^\w+_(\w+)$/, '$1'));
	if (limit == 0)
		getEl('divpTS_' + zon).innerHTML = '';
	edit.style.background = '#fff url(' + forAll.img_domen + 'img/range/load.gif) no-repeat right center';
	if (zon != 'Left'){
		loadUrlStream(forAll.pic_domen + 'hint/searchTag/?' + Math.random(), 'evalU', {color:forAll.picPar.color,size:forAll.picPar.size,tags:forAll.picPar.tag,tag:forAll.picTagSearch,limit:limit,zon:zon});
	}else{
		loadUrlStream(forAll.pic_domen + 'hint/searchTag/?' + Math.random(), 'evalU', {tag:forAll.picTagSearch,limit:limit,zon:zon});
	};
};

function showPicSearchTag(newTag, par, zon, limit, top){	// ответ сервера по поиску тегов изображений
	var table = (limit == 1 ? '<div id="divApTS_' + zon + '">' : '');
	var srcTag = [];
	if (forAll.picPar != null){
		if (forAll.picPar.color != null && forAll.picPar.color != ''){
			srcTag[srcTag.length] = 'color=' + forAll.picPar.color;
		};
		if (forAll.picPar.size != null && forAll.picPar.size != ''){
			srcTag[srcTag.length] = 'size=' + forAll.picPar.size;
		};
	};
	var c = 0;
	for (var i in newTag){
		++c;
		if (par){
			var tmpTag = [];
			if (forAll.picPar.tag.length > 0 && forAll.picPar.tag[0] != ''){
				for (var j in forAll.picPar.tag){
					tmpTag[tmpTag.length] = forAll.picPar.tag[j];
				};
			};
			tmpTag[tmpTag.length] = i;
			table += '<a href="' + forAll.pic_domen + 'gallery/' + (srcTag.length > 0 ? implode(';', srcTag) + ';' : '') + 'tag=' + implode('+', tmpTag.sort()) + '/" style="' + (forAll.showOne < c || limit == 0 ? 'display:none;' : '') + '">' + newTag[i] + '</a>';
		}else{
			table += '<a href="' + forAll.pic_domen + 'gallery/' + 'tag=' + i + '/" style="' + (forAll.showOne < c || limit == 0 ? 'display:none;' : '') + '">' + newTag[i] + '</a>';
		};
	};
	fromPosEl = getMesto(getEl('pTS_' + zon));
	if (limit == 1){
		table += '</div><img src="'+forAll.img_domen+'img/1x1.gif" width="'+(fromPosEl.width-12)+'" height="5"><br><div class="help"><nobr>Кликните для перехода</nobr></div>';
		getEl('divpTS_' + zon).innerHTML = table;
		getEl('divpTS_' + zon).style.top = fromPosEl.top + fromPosEl.height + 1;
		getEl('divpTS_' + zon).style.display = '';
	}else{
		getEl('divApTS_' + zon).innerHTML += table;
		forAll.picNowLoad = false;
	};
	endPicSearch(zon);
};

function closePicSearch(zon){
//	alert('Нет таковых');
	endPicSearch(zon);
	if (getEl('divpTS_' + zon) != null){
		getEl('divpTS_' + zon).style.display = 'none';
	};
};

function endPicSearch(zon){
	if (getEl('pTS_' + zon) != null){
		getEl('pTS_' + zon).style.background = '#fff';
	};
};
/////////////KPK
function updateKpkRating(id){	// запрос к серверу для получения рейтинга кпк
	loadUrlStream(forAll.kpk_domen + 'hint/kpkOcenka/' + id + '/', 'evalU');
};

function beginSearchSiteKpkAll(form){	// поиск конкретно по телефонам
	for (i=0; i<forAll.searchRazdels.length; i++){
		if (forAll.searchRazdels[i].razdel == 'kpk'){
			chLocation(forAll.searchRazdels[i].src + forAll.searchRazdels[i].search + form.search_text.value + '/');
			return false;
		};
	};
	return false;
};

function sHPTKpk(){	// showHidePodborText - отображение подсказок подбора для кпк
	if (forAll.maxMP == ''){	// maxMP - maxMemPhone
		forAll.maxMP = 0;
	};
	getEl('maxMemKpk').innerHTML = forAll.maxMP;
	if (forAll.minPP == ''){	// minPP - minPricePhone
		forAll.minPP = 0;
	};
	getEl('minPricePhone').innerHTML = forAll.minPP;
	if (forAll.maxPP == ''){	// maxPP - maxPricePhone
		forAll.maxPP = 0;
	};
	getEl('maxPricePhone').innerHTML = forAll.maxPP;
	if (forAll.maxFreq == ''){
		forAll.maxFreq = 0;
	};
	getEl('maxFreqKpk').innerHTML = forAll.maxFreq;
};

function resetPodborKpk(){	// возврат подбора в первоначальную форму
	var form = getEl('formP');
	for (i=0; i<form.elements.length; i++){
		switch (form.elements[i].type){
			case 'checkbox':
				form.elements[i].checked = false;
			break;
			case 'radio':
				if (/0$/.test(form.elements[i].id)){
					form.elements[i].checked = true;
				};
			break;
			case 'select-one':
				form.elements[i].selectedIndex = 0;
			break;
			case 'text':
				form.elements[i].value = '';
			break;
			case 'hidden':
				form.elements[i].value = '';
			break;
		};
	};
	podborPreSubmitKpk(form);
};

function podborPreSubmitKpk(form){	// предъопределение возможных параметров подбора
	forAll.lastActiveElement = d.activeElement;
	src = createPodborSrc(form);
	
	if (forAll.podborCheck == null)
		forAll.podborCheck = 'podbor/';
	if (forAll.podborCheck != src){
		forAll.podborCheck = src;
		src = forAll.kpk_domen + 'hint/podborKpk/' + src;
		if (forAll.formPCh == true){
			if (form.elements.disabled != null){
				form.elements.disabled = true;
			}else{
				for (i in form.elements){
					if (form.elements[i] != null)
						form.elements[i].disabled = true;
				};
			};

			loadUrl(src, 'showHintHelp');
		};
	};
};

function podborSubmitKpk(form){	// submit(); формы подбора
	src = forAll.kpk_domen + createPodborSrc(form);
	chLocation(src);
	return false;
};

var tt = null;

function new_search_over()
{
	clearTimeout(tt);
}

function new_search_out(event)
{
		var iframes = document.getElementsByTagName('iframe');
		var objects = document.getElementsByTagName('object');
		for(var i = 0; i < iframes.length; i++)
		{
			iframes[i].style.visibility = '';
		}
		for(var i = 0; i < objects.length; i++)
		{
			iframes[i].style.visibility = '';
		}
		
		var src_txt = getEl('src_text');
		src_txt.style.width = '';
		getEl('hr_shad').style.width = '';
		getEl('tsb').style.width = '';
		var slct = getEl('search_top_list');
		slct.style.display = 'none';
		getEl('search_popup').style.display = 'none'
		getEl('tsb_zanaves').style.display = '';
		getEl('btn12').style.display = 'none';
}

function cancel_event(event)
{
	 event = event || window.event;
	 if (event.preventDefault)
	 {
      event.preventDefault();
      event.stopPropagation();
    }
	else
	{
      event.returnValue = false;
      event.cancelBubble = true;
    }
}

function new_search_focus(el)
{
	el.style.width = '640px';
	getEl('hr_shad').style.width = '784px';
	getEl('tsb').style.width = '783px';
	
	var zanaves = getEl('tsb_zanaves');
	zanaves.style.display = 'block';
	zanaves.style.height = getEl('top_menu_tr').offsetHeight + getEl('top_line1').offsetHeight + 12 + 'px';
	getEl('btn12').style.display = 'block';
	getEl('new_search_td').style.display = '';
	if(getEl('src_text').value.length == 0)
	{
		getEl('btn12').disabled = true;
	}
	var slct = getEl('search_top_list');
	slct.style.left = (el.offsetLeft + 508) + 'px';
	slct.style.top = '15px';
	slct.style.display = 'inline';
}

var lite_search_tt = null;
var last_search = '';
var last_razdel = '';
function lite_search() // быстрый поиск
{
	if(lite_search_tt)
		clearTimeout(lite_search_tt);
	var el = getEl('src_text');
	var el2 = getEl('search_top_list');
	if(el.value == '')
	{
		closeSiteSearch();
		return;
	}
	if(el.value.length > 0 && el2.value != 'pic')
	{
		getEl('btn12').disabled = false;
	}
	else
	{
		getEl('btn12').disabled = true;
	}
	
	if(el.value.length > 0 && (el.value != last_search || el2.value != last_razdel))
	{
		last_search = el.value;
		last_razdel = el2.value;
		lite_search_tt = setTimeout("lite_search2()", 500);
	}
}

function lite_search2()
{
	var razdel = getEl('search_top_list').value;
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'search_word';
	arrayPar[1][0] = getEl('src_text').value;
	arrayPar[0][1] = 'razdel';
	arrayPar[1][1] = razdel;
	loadUrl('/hint/searchSite/', 'showHintHelp', arrayPar);
}

var search_cnt = 0;
var srch_srcs = 0;
function showSiteSearch2(img, title, src, size, count){	// отображение выпадающего списко поиску по сайту
		var iframes = document.getElementsByTagName('iframe');
		var objects = document.getElementsByTagName('object');
		for(var i = 0; i < iframes.length; i++)
		{
			iframes[i].style.visibility = 'hidden';
		}
		for(var i = 0; i < objects.length; i++)
		{
			iframes[i].style.visibility = 'hidden';
		}
	search_cnt = title.length;
	srch_srcs = src;
	cur_row = 0;
	var divSiteSearch = getEl('search_popup');
	fromPosEl = getMesto(getEl('src_text'));
	divSiteSearch.style.top = '35px';
	divSiteSearch.style.left = '80px';
	divSiteSearch.style.display = 'block';
	forAll.pole1x1 = '<img src="' + forAll.img_domen + 'img/1x1.gif" height="1">';
	text = '<div class="top">Найдено:</div>';
	text += '<table id="tableSearch" cellpadding="0" cellspacing="0" width="100%" style="background:url(' + forAll.img_domen + 'img/searchGrad.jpg) repeat-y right top">';

	text += '<tr height="5" style="background-color:#ffffff">';
	text += '<td width="5">' + forAll.pole1x1 + '</td>';
	text += '<td style="border-bottom:#000000 1px dotted">' + forAll.pole1x1 + '</td>';
	text += '<td width="14">' + forAll.pole1x1 + '</td>';
	text += '</tr>';
	for (i=0; i<title.length; i++){
		text += '<tr height="60" OnMouseOver="selectRowsSearch(' + (i+1) + ');slidePhoneSearch(this, ' + count[i] + ', ' + i + ', 60);" OnMouseOut="selectRowsSearch(' + (i+1) + ');slidePhoneSearch(this, 0, ' + i + ', 60);" OnClick="chLocation(\'' + src[i] + '\')" class="hand" style="background-color:#ffffff">';
		text += '<td class="fS1">&nbsp;</td>';
		text += '<td style="border-bottom:#000000 1px dotted">';
		text += '<table cellpadding="0" cellspacing="0" width="100%">';
		text += '<tr>';
		text += '<td valign="center" align="center" width="60">';
		if (img[i] != null){
			text += '<img src="' + img[i] + '" width="' + size[i].w + '" height="' + size[i].h + '" style="margin:2px 0;">';
		}else{
			text += forAll.pole1x1;
		};
		text += '</td>';
		text += '<td width="5"><img src="' + forAll.img_domen + 'img/1x1.gif" width="1" height="50"></td>';
		text += '<td valign="top" class="textPanelSearch">' + title[i] + '</td>';
		text += '</tr>';
		text += '</table>';
		text += '</td>';
		text += '<td valign="center" align="right">' + forAll.pole1x1 + '</td>';
		text += '</tr>';
	};
	text += '</table>';
	var razdel = getEl('search_top_list').value;
	var dmn = forAll.domen + 'phone/search/';
	switch(razdel)
	{
		case 'phone': break;
		case 'notebook': dmn = forAll.notebook_domen + 'search/'; break;
		case 'garnitury': dmn = forAll.garnitury_domen + 'search/'; break;
		case 'notebook': dmn = forAll.notebook_domen + 'search/'; break;
		case 'game': dmn = forAll.game_domen + 'search/'; break;
		case 'gps': dmn = forAll.gps_domen + 'search/'; break;
		case 'photo': dmn = forAll.photo_domen + 'search/'; break;
		case 'mp3': dmn = forAll.mp3_domen + 'search/'; break;
		case 'dvd': dmn = forAll.dvd_domen + 'search/'; break;
		case 'camera': dmn = forAll.camera_domen + 'search/'; break;
		case 'headphone': dmn = forAll.headphone_domen + 'search/'; break;
		case 'mediaplayer': dmn = forAll.mediaplayer_domen + 'search/'; break;
		case 'tv': dmn = forAll.tv_domen + 'search/'; break;
		case 'news': dmn = forAll.domen + 'news/search/'; break;
	}
	text += '<div class="bottom"><a onclick="window.location.href = this.href;" href="' + dmn + getEl('src_text').value + '/' + '" class="top_link">Искать дальше</a></div>';
	divSiteSearch.innerHTML = '<div class="conteiner">' + text + '</div>';
	forAll.tableSearch = getEl('tableSearch');
};

function submit_new_search()
{
	var txt = getEl('src_text').value;
	var cat = getEl('search_top_list').value;
	var dmn = '';
	
	if(txt.length > 0)
	{
		switch(cat)
		{
			case 'phone': dmn = forAll.domen + 'phone/'; break;
			case 'notebook': dmn = forAll.notebook_domen; break;
			case 'garnitury': dmn = forAll.garnitury_domen; break;
			case 'game': dmn = forAll.game_domen; break;
			case 'gps': dmn = forAll.gps_domen; break;
			case 'photo': dmn = forAll.photo_domen; break;
			case 'mp3': dmn = forAll.mp3_domen; break;
			case 'dvd': dmn = forAll.dvd_domen; break;
			case 'camera': dmn = forAll.camera_domen; break;
			case 'headphone': dmn = forAll.headphone_domen; break;
			case 'mediaplayer': dmn = forAll.mediaplayer_domen; break;
			case 'tv': dmn = forAll.tv_domen; break;
			case 'news': dmn = forAll.domen + 'news/'; break;
		}
		if(dmn.length > 0)
		{
			//alert(dmn + 'search/' + txt + '/');
			window.location.href = dmn + 'search/' + txt + '/';
			
		}
	}
}

function new_search_tr(el)
{
	el.style.background = '#fff url('+forAll.img_domen+'img/searchGrad.jpg) right top repeat-y';
	el.getElementsByTagName('td')[0].style.backgroundColor = '#fff';
}

function norm_new_search()
{
	if(red_url.length > 0)
	{
		window.location.href = red_url;
		return false;
	}
	if(getEl('search_top_list').value != 'pic')
	{
		submit_new_search();
		return false;
	}
	return false;
}

function new_search_tr2(el)
{
	el.style.background = '';
}

function set_search_kat()
{
	var reg_exps = new Array(
		new Array(/^http:\/\/notebook\./, 'notebook'),
		new Array(/^http:\/\/garnitury\./, 'garnitury'),
		new Array(/^http:\/\/game\./, 'game'),
		new Array(/^http:\/\/gps\./, 'gps'),
		new Array(/^http:\/\/dvd\./, 'dvd'),
		new Array(/^http:\/\/photo\./, 'photo'),
		new Array(/^http:\/\/mp3\./, 'mp3'),
		new Array(/^http:\/\/camera\./, 'camera'),
		new Array(/^http:\/\/headphones\./, 'headphone'),
		new Array(/^http:\/\/mediaplayer\./, 'mediaplayer'),
		new Array(/^http:\/\/tv\./, 'tv'),
		new Array(/^http:\/\/[^\/]+\/phone/, 'phone'),
		new Array(/^http:\/\/[^\/]+\/news/, 'news')
	);
	var t = false;
	for(var i = 0; i < reg_exps.length; i++)
	{
		if(reg_exps[i][0].test(window.location.href))
		{
			getEl('search_top_list').value = reg_exps[i][1];
			t = true;
		}
	}
	if(!t) getEl('search_top_list').selectedIndex = 0;
}
var tbl_pic_s;
function showPicSearchTag2(title){	// ответ сервера по поиску тегов изображений
	search_cnt = title.length;
	srch_srcs = new Array();
	cur_row = 0;
	var divSiteSearch = getEl('search_popup');
	fromPosEl = getMesto(getEl('src_text'));
	divSiteSearch.style.top = '35px';
	divSiteSearch.style.left = '80px';
	divSiteSearch.style.display = 'block';
	forAll.pole1x1 = '<img src="' + forAll.img_domen + 'img/1x1.gif" height="1">';
	text = '<div id="tag_search_back"><table id="tableSearch" class="tbl_tags_search" cellpadding="0" cellspacing="0" width="100%" >';
	var i = 0;
	for (var s in title){
		srch_srcs.push(forAll.pic_domen + 'gallery/tag='+ s +'/');
		text += '<tr>';
		text += '<td><a href="'+forAll.pic_domen + 'gallery/tag='+ s +'/">'+title[s]+'</a></td>';
		text += '</tr>';
		i++;
	}
	search_cnt = i;
	text += '</table><div id="tag_search_back_help">Кликните для перехода</div></div>';
	
	divSiteSearch.innerHTML = '<div class="conteiner">' + text + '</div>';
	tbl_pic_s = getEl('tableSearch');
};

function sbmt_main_game(el, dmn)
{
	var prnt = el.parentNode;
	var brand = prnt.getElementsByTagName('select')[0].value;
	var model = prnt.getElementsByTagName('select')[1].value;
	if(brand != '' && model == '')
	{
		window.location.href = dmn + 'brands/' + brand + '/';
	}
	else if(brand != '' && model != '')
	{
		setCookie('gamephone', model, 7776000);
		window.location.href = dmn;
	}
}

function main_game_ml(el, id_str, id_btn)
{
	if(el.value != '')
	{
		getEl(id_btn).disabled = false;
		$.post("/hint/mainGameModel/", { brand: el.value },function(data){
			if(data.length > 0)
			{
				var mlist = getEl(id_str);
				mlist.innerHTML = data;
				mlist.disabled = false;
			}
	   });
	}
	else
	{
		getEl(id_str).disabled = true;
	}
}

//-----------------------показ всплывающей формы в шапке с каталогами------------------------------//
var tMoreCatalogs = false;
function showMoreCatalogs(ev)
{
	ev = ev || window.event;
	ev = ev.target || ev.srcElement;
	
	$('#more_catalogs').show();
}

function hideMoreCatalogs(ev)
{
	ev = ev || window.event;
	ev = ev.target || ev.srcElement;
	while(ev = ev.parentNode){
		if (ev.id == 'more_catalogs'){
			return;
		};
	};

	tMoreCatalogs = setTimeout(function(){
		$('#more_catalogs').hide();
	}, 500);
}