function ___Start() {
	var oLenta = $('lenta_table');
	
	if(!oLenta) {
		___Bg('../img/projects-bg.jpg',1600,1000);
		CheckImg();
		return;
	}
	else {
		if(!iCurrIndex) {
			iCurrIndex=1;
		}
		var oImg = $('prev_img_'+iCurrIndex);
		var aParams = (oImg.getAttribute('title')).split(';');
		___Bg(aParams[0], aParams[1], aParams[2]);
	}
}

var bShadow = false;
function ___Bg(sPath, iW, iH, iCNum) {
	if(bShadow) {
		return;
	}
	bShadow=true;
	var oTable = $('lenta_table');
	var oContainer = $('bg_image');
	var oImg = $('background_image');
	var oImg2 = $('background_image_2');
	var oLayout = $('layout');
	
	var iWidth = oLayout.offsetWidth*1;
	var iHeight = oLayout.offsetHeight*1;
	
	if(oTimer !== null) {
		window.clearTimeout(oTimer);
		oTimer = null;
	}
	if(!oTable) {
		oImg.src = '../img/projects-bg.jpg';
		
		if(iWidth>iW || iHeight>iH) {
			_MC.SetClass(oImg, 'w', 'h');
			
			var iW = oImg.offsetWidth*1;
			var iH = oImg.offsetHeight*1;
			if(iHeight>iH) {
				_MC.SetClass(oImg, 'h', 'w');
			}
		}
		return;
	}
	
	if(iWidth>iW || iHeight>iH) {
		_MC.SetClass(oImg, 'w', 'h');
		
		var iW = oImg.offsetWidth*1;
		var iH = oImg.offsetHeight*1;
		if(iHeight>iH) {
			_MC.SetClass(oImg, 'h', 'w');
		}
	}
	BgResize();
	
	/*
	var iTd = 0;
	for( var i=0, iL=oTable.rows[0].cells.length; i<iL; i++ ) {
		var sParam = sPath+';'+iW+';'+iH;
		var oTd = oTable.rows[0].cells[i];
		
		var oIm = oTd.getElementsByTagName('img')[0];
		var sImTitle = oIm.getAttribute('title');
		
		if(sParam === sImTitle) {
			iTd=i;
		}
	}
	iCurrIndex = iTd;
	*/
	if(iCNum) {
		var iImgL = $('prev_num').value*1;
		var oImg = $('prev_img_'+iCNum);
		var oPrev = $('prev_loader_'+iCNum);
		
		for(var i=0; i<iImgL; i++) {
			var oPrevImg = $('prev_img_'+(i+1));
			var oPrevImgL = $('prev_loader_'+(i+1));
			if(oPrevImg && oPrevImgL) {
				_MC.SetClass(oPrevImg, ' ', 'curr');
				_MC.SetClass(oPrevImgL, 'hidden', ' ');
			}
		}
		
		_MC.SetClass(oPrev, ' ', 'hidden');
		_MC.SetClass(oImg, 'curr', ' ');
		iCurrIndex=iCNum;
	}
	iCurrIndex++;
	
	if(oTable) {
		var oParent = $('gallery');
		var oLine = $('holder');
		
		var iWidth = oParent.offsetWidth*1;//длина блока с показываемыми превьхами
		var iW = oTable.offsetWidth*1;//длина всего блока с превьюхами
		
		var iImgL = $('prev_num').value*1;//количество картинок
		var iStep = oTable.rows[0].cells[0].offsetWidth*1;//длина картинкм
		var iLeft = ( isNaN( parseInt(oLine.style.marginLeft) ) ) ? -9 : parseInt(oLine.style.marginLeft);//текущее положение блока с превьюхами от левого края
		
		var iCurrL = iStep*(iCurrIndex-1);//левая точка картинки
		
		if(iWidth<iW) {
		
			if(iCurrL+iStep>iWidth) {
				iL = ( iLeft-iStep <= iWidth-iW ) ? iWidth-iW : (iWidth-(iCurrL))-9;
				___PositionGoLeft(oLine, iL);
			}
			
			else if( (iCurrL-iStep)<iLeft*(-1) ) {
				iL = ( iLeft-iCurrL+iStep >= -9 ) ? -9 : ((iCurrL-iStep+9)*(-1));
				___PositionGoRight(oLine, iL);
			}
		}
	}
	
	var oI_ = null;
	//oI_ = new Image();
	oI_ = document.createElement('img');
	oI_.onload = function() {
		BgResize();
		opacityShow(0, sPath);
		
		var iImgL = $('prev_num').value*1;
		var iP = (iCurrIndex-2<1) ? iImgL : iCurrIndex-2;
		var iN = (iCurrIndex-1>iImgL) ? 1 : iCurrIndex-1;
		
		for(var i=0; i<iImgL; i++) {
			var oPrevImg = $('prev_img_'+(i+1));
			var oPrevImgL = $('prev_loader_'+(i+1));
			if(oPrevImg && oPrevImgL) {
				_MC.SetClass(oPrevImg, ' ', 'curr');
				_MC.SetClass(oPrevImgL, 'hidden', ' ');
			}
		}
		
		var oNextImg = $('prev_img_'+iN);
		_MC.SetClass(oNextImg, 'curr', ' ');
		
		
		if(!$('prev_img_'+iCurrIndex)) {
			iCurrIndex=1;
		}
		oTimer = window.setTimeout(___NextBG, 15000);
	}
	oI_.src = sPath;
	$('img_container').appendChild(oI_);
	BgResize();
}

function ___NextBG() {
	var oLenta = $('lenta_table');
	var oTable = $('lenta_table');
	
	var iImgL = $('prev_num').value*1;
	var iP = (iCurrIndex-1<1) ? iImgL : iCurrIndex-1;
	var oPImg = $('prev_img_'+iP);
	var oImg = $('prev_img_'+iCurrIndex);
	var oPrevImg = $('prev_loader_'+iCurrIndex);
	
	var aParams = (oImg.getAttribute('title')).split(';');
	_MC.SetClass(oPImg, ' ', 'curr');
	_MC.SetClass(oImg, 'curr', ' ');
	_MC.SetClass(oPrevImg, ' ', 'hidden');
	
	if(oTable) {
		/*
		var oParent = $('gallery');
		var oLine = $('holder');
		
		var iWidth = oParent.offsetWidth*1;
		var iW = oTable.offsetWidth*1;
		
		var iImgL = $('prev_num').value*1;
		var iStep = oTable.rows[0].cells[0].offsetWidth*1;
		var iLeft = ( isNaN( parseInt(oLine.style.marginLeft) ) ) ? -9 : parseInt(oLine.style.marginLeft);
		
		var iCurrL = iStep*(iCurrIndex-1);
		
		if(iWidth<iW && (iCurrL+iStep>iWidth || iCurrIndex*1===1) ) {
			if( iCurrIndex*1===1 ) {
				iLeft = -9
				iL = (iLeft+iStep>-9) ? -9 : iLeft+iStep;
				___PositionGoRight(oLine, iL);
			}
			else {
				iL = ( iLeft-iStep < iWidth-iW ) ? iWidth-iW : iLeft-iStep;
				___PositionGoLeft(oLine, iL);
			}
		}
		*/
	}
	
	___Bg(aParams[0], aParams[1], aParams[2]);
	
}

function ___Position(iNum) {
	var oParent = $('gallery');
	var oLine = $('holder');
	var oTable = $('lenta_table');
	
	if(!oTable) {
		return;
	}
	
	var iWidth = oParent.offsetWidth*1;
	var iW = oTable.offsetWidth*1;
	if(!iCurrIndex) {
		iCurrIndex=0;
	}
	if(iNum && iWidth<iW ) {
		var iStep = oTable.rows[0].cells[0].offsetWidth*1*4;
		var iLeft = ( isNaN( parseInt(oLine.style.marginLeft) ) ) ? -9 : parseInt(oLine.style.marginLeft);
		if(iNum===1) {
			iL = ( iLeft-iStep < iWidth-iW ) ? iWidth-iW : iLeft-iStep;
			___PositionGoLeft(oLine, iL);
			//oLine.style.marginLeft = iL+'px';
		}
		else {
			iL = (iLeft+iStep>-9) ? -9 : iLeft+iStep;
			___PositionGoRight(oLine, iL);
			//oLine.style.marginLeft = iL+'px';
		}
		
	}
	else {
		if(iWidth>=iW) {
			oLine.style.marginLeft = '-9px';
			___PositionBtn();
		}
	}
}

function ___PositionGoLeft(oElem, iL) {
	var Step = 15;
	var rate = 10;	// 15 fps
	
	var iLeft = ( isNaN( parseInt(oElem.style.marginLeft) ) ) ? -9 : parseInt(oElem.style.marginLeft);
	
	if (iLeft > iL) {
		iLeft -= Step;
		if (iLeft < iL) {
			iLeft = iL;
		}

		oElem.style.marginLeft = iLeft+'px';
	}
	
	if (iLeft > iL) {
		setTimeout(function () {
			___PositionGoLeft(oElem, iL);
		}, rate);
	}
	else {
		___PositionBtn();
	}
}
function ___PositionGoRight(oElem, iL) {
	var Step = 15;
	var rate = 10;	// 15 fps
	
	var iLeft = ( isNaN( parseInt(oElem.style.marginLeft) ) ) ? -9 : parseInt(oElem.style.marginLeft);
	
	//alert([iLeft, iL]);
	
	if (iLeft < -9) {
		iLeft += Step;
		if (iLeft > -9) {
			iLeft = -9;
		}

		oElem.style.marginLeft = iLeft+'px';
	}
	
	if (iLeft < iL) {
		setTimeout(function () {
			___PositionGoRight(oElem, iL);
		}, rate);
	}
	else {
		___PositionBtn();
	}
}

function ___PositionBtn() {
	var oBtnL = $('gotoLeft');
	var oBtnR = $('gotoRight');
	
	var oParent = $('gallery');
	var oLine = $('holder');
	var oTable = $('lenta_table');
	
	var iLeft = ( isNaN( parseInt(oLine.style.marginLeft) ) ) ? -9 : parseInt(oLine.style.marginLeft);
	
	var iWidth = oParent.offsetWidth*1;
	var iW = oTable.offsetWidth*1;
	
	if(iLeft >= -9) {
		_MC.SetClass(oBtnL, 'hidden', ' ');
	}
	else {
		_MC.SetClass(oBtnL, ' ', 'hidden');
	}
	
	if( iLeft <= iWidth-iW) {
		_MC.SetClass(oBtnR, 'hidden', ' ');
	}
	else {
		_MC.SetClass(oBtnR, ' ', 'hidden');
	}
}

function ___Popup(sType) {
	var oLayout = $('layout');
	var oBg = $('overlay');
	var oPopup = $('popup');
	var oContent = $('content');
	var oHeader = $('title');
	var sContent = '';
	if(sType==='about') {
		sHeader = '';
		sContent = $('aboutContent').innerHTML;
	}
	else {
		sHeader = 'Контакты';
		sContent = $('contactContent').innerHTML;
	}
	var iWidth = oLayout.offsetWidth*1;
	var iHeight = oLayout.offsetHeight*1;
	
	oBg.style.width='100%';
	
	oContent.innerHTML = sContent;
	oHeader.innerHTML = sHeader;
	
	var iBrowserHeight = _MC.BrowserHeight();
	var iScroll = _MC.BrowserScroll();
	
	_MC.SetClass(oBg, ' ', 'hidden');
	_MC.SetClass(oPopup, ' ', 'hidden');
	
	var iW = oPopup.offsetWidth*1;
	var iH = oPopup.offsetHeight*1;
	
	
	if(iH > iHeight) {
		iHeight = iH;
		oPopup.style.top = iScroll+'px';
	}
	var iTop = (iBrowserHeight <= iH) ? iScroll : (iBrowserHeight - iH) / 2 + iScroll;
	
	oPopup.style.top = iTop+'px';
	
	oBg.style.height = iHeight+'px';
	
//	_MC.SetHash(sType);
}

function ___PopupClose() {
	var oBg = $('overlay');
	var oPopup = $('popup');
	
	_MC.SetClass(oBg, 'hidden', ' ');
	_MC.SetClass(oPopup, 'hidden', ' ');
}

function CheckPopup() {
	var sHash = _MC.GetHash();
	
	if(sHash!== '' && (sHash === 'about' || sHash === 'contact')) {
		___Popup(sHash);
	}
}

window.onresize = function() {
	BgResize();
}

function BgResize() {
	var oLayout = $('layout');
	var oImg = $('background_image');
	var oImg2 = $('background_image_2');
	var iWidth = oLayout.offsetWidth*1;
	var iHeight = oLayout.offsetHeight*1;
	var oBg = $('overlay');
	
	var iW = oImg.offsetWidth*1;
	var iH = oImg.offsetHeight*1;
	
	if(iWidth>iW || iHeight>iH) {
		_MC.SetClass(oImg, 'w', 'h');
		
		var iW = oImg.offsetWidth*1;
		var iH = oImg.offsetHeight*1;
		if(iHeight>iH) {
			_MC.SetClass(oImg, 'h', 'w');
		}
	}
	___Position();
	
	var iBrowserHeight = _MC.BrowserHeight();
	var iScroll = _MC.BrowserScroll();
	
	var oParent = $('gallery');
	var oHolder = $('holder');
	var oLenta = $('lenta_table');
	
	oBg.style.height = iHeight+'px';
	
	if (oLenta) {
		var iPWidth = oParent.offsetWidth*1;
		var iWidth = oLenta.offsetWidth*1;
		
		var iCurrL = ( isNaN(parseInt(oHolder.style.marginLeft)) ) ? 9 : parseInt(oHolder.style.marginLeft)*(-1);
		
		if(iWidth>iPWidth && (iWidth - iCurrL)<iPWidth) {
			var iL = (iWidth-iPWidth)*(-1);
			if(iL>-9) {
				iL = -9;
			}
			oHolder.style.marginLeft = iL+'px';
		}
	}
}

function opacityCycle( oEl, bShow ) {
	var _this = this;
	var iTime = 20;
	
	this.bShow = bShow;
	this.oElem = oEl;
	this.sOpacity = getOpacityProperty();
	this.iStepNum = 1;
	this.iStep = (_MC.isIe()) ? 100/15 : 1/15;
	this.iCurrOpacity = (this.iStepNum == 1 && bShow) ? 0 : ( _MC.isIe() ) ? 100 : 1 ;
	this.gTimeout = null;
	
	
	if( this.bShow ) {
		this.oTimer1 = setInterval(
			function() {
				_this.oElem.style.display = 'block';
				if( _MC.isIe() ) {
					this.iOp = _this.iCurrOpacity + _this.iStep*_this.iStepNum;
					var oAlpha = _this.oElem.filters['DXImageTransform.Microsoft.alpha'] || _this.oElem.filters.alpha;
					if (oAlpha)
						oAlpha.opacity = this.iOp;
					else
						_this.oElem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+this.iOp+")";
					if(this.iOp == 100) {
						_MC.SetClass(_this.oElem, ' ', 'opacity_0');
						clearInterval(_this.oTimer1);
						clearTimeout(_this.gTimeout);
						BgResize();
					}
				}
				else {
					this.iOp = _this.iCurrOpacity + _this.iStep*_this.iStepNum;
					_this.oElem.style[_this.sOpacity] = this.iOp;
					if(this.iOp == 1) {
						_MC.SetClass(_this.oElem, ' ', 'opacity_0');
						clearInterval(_this.oTimer1);
						clearTimeout(_this.gTimeout);
						BgResize();
					}
				}
				_this.iStepNum++;
			},
			iTime
		);
	}
	else {
		this.oTimer2 = setInterval(
			function() {
				if( _this.sOpacity == 'filter' ) {
					this.iOp = _this.iCurrOpacity - _this.iStep*_this.iStepNum;
					var oAlpha = _this.oElem.filters['DXImageTransform.Microsoft.alpha'] || _this.oElem.filters.alpha;
					if (oAlpha)
						oAlpha.opacity = this.iOp;
					else
						_this.oElem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+this.iOp+")";
					if(this.iOp == 0) {
						_this.oElem.style.display = 'none';
						_MC.SetClass(_this.oElem, 'opacity_0', ' ');
						_this.oElem.style.zIndex = 1;
						clearInterval(_this.oTimer2);
					}
				}
				else {
					this.iOp = _this.iCurrOpacity - _this.iStep*_this.iStepNum;
					_this.oElem.style[_this.sOpacity] = this.iOp;
					if(this.iOp == 0) {
						_this.oElem.style.display = 'none';
						_MC.SetClass(_this.oElem, 'opacity_0', ' ');
						_this.oElem.style.zIndex = 1;
						clearInterval(_this.oTimer2);
					}
				}
				_this.iStepNum++;
			},
			iTime
		);
	}
	return;
}

function opacityHide(iOp) {
	var reduceOpacityBy = 100/10;
	var rate = 30;	// 15 fps
	
	var sOpacity = getOpacityProperty();
	
	oElem = $('background_image_2');

	if (iOp > 0) {
		iOp -= reduceOpacityBy;
		if (iOp < 0) {
			iOp = 0;
		}

		if (oElem.filters) {
			try {
				oElem.filters.item("DXImageTransform.Microsoft.Alpha").opacity = iOp;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				oElem.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + iOp + ')';
			}
		} else {
			oElem.style[sOpacity] = iOp / 100;
		}
	}
	
	if (iOp > 0) {
		setTimeout(function () {
			opacityHide(iOp);
		}, rate);
	}
	else {
		_MC.SetClass(oElem, 'opacity_0', ' ');
		bShadow = false;
	}
}

function opacityShow(iOp, sPath) {
	iOp = iOp*1;
	var reduceOpacityBy = 100/10;
	var rate = 30;	// 15 fps
	
	var sOpacity = getOpacityProperty();
	oElem = $('background_image_2');

	if (iOp < 100) {
		iOp += reduceOpacityBy;
		if (iOp > 100) {
			iOp = 100;
		}

		if (oElem.filters) {
			try {
				oElem.filters.item("DXImageTransform.Microsoft.Alpha").opacity = iOp;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				oElem.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + iOp + ')';
			}
		} else {
			oElem.style[sOpacity] = iOp / 100;
		}
	}

	if (iOp < 100) {
		setTimeout(function () {
			opacityShow(iOp, sPath);
		}, rate);
		_MC.SetClass(oElem, ' ', 'opacity_0');
		BgResize();
		//alert([oElem, oElem.id, oElem.src]);
	}
	else {
		$('background_image').src = sPath;
		BgResize();
		//alert(1);
		opacityHide(100);
	}
}

function getOpacityProperty() {
	if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
		return 'opacity';
	else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 и младше, Firefox 0.8 
		return 'MozOpacity';
	else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
		return 'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
		return 'filter';

	return false; //нет прозрачности
}

function _LoadProj(iNum) {
	var oProj = $('proj_'+iNum);
	var oProjPrev = $('proj_prev_'+iNum);
	
	_MC.SetClass(oProj, ' ', 'invisible');
	_MC.SetClass(oProjPrev, 'hidden', ' ');
}

var ContactFormClear = function(button){
	button.form.reset();
	return false;
};

var ContactFormSubmit = function(form){
	if(form.name.value == '') {
		alert('Поле "Имя" не заполнено.');
	} else if(form.email.value == '') {
		alert('Поле "E-mail" не заполнено.')
	} else if(form.phone.value == '') {
		alert('Поле "Телефон" не заполнено.')
	} else {
		
		var sName = form.name.value;
		var sEmail = form.email.value;
		var sPhone = form.phone.value;
		var sFax = form.fax.value;
		var sCompany = form.company.value;
		var sAddress = form.address.value;
		var sMsg = form.message.value;
		
		var sParams = 'name='+sName+'&email='+sEmail+'&phone='+sPhone+'&fax='+sFax+'&company='+sCompany+'&address='+sAddress+'&message='+sMsg;
		
		new _AJAX('/ajax/?action=contact', 'post',ContactFormSubmitEnd, sParams );
	}
	return false;
};
var ContactFormSubmitEnd = function(oData){
	___PopupClose();
	return false;
};

function CFHover(oElem) {
	if(oElem.id === 'clear') {
		oElem.src = '../img/btn-clear-h.png';
	}
	else {
		oElem.src = '../img/btn-send-h.png';
	}
}
function CFOut(oElem) {
	if(oElem.id === 'clear') {
		oElem.src = '../img/btn-clear.png';
	}
	else {
		oElem.src = '../img/btn-send.png';
	}
}

function oPreviewHover(oElem) {
	_MC.SetClass(oElem, 'hover', ' ');
}
function oPreviewOut(oElem) {
	_MC.SetClass(oElem, ' ', 'hover');
}

/* Галерея */
var iUserNum = null;
function GalleryHeight() {
	var oFade = $('fade');
	var oLayout = $('layout');
	
	var iHeight = oLayout.offsetHeight*1;
	if(iHeight<1000) {
		iHeight = 1000;
	}
	oFade.style.height = iHeight+'px';
}

var ___iUserNum = null;
function ___ShowGallery(iUser, sName, iNum) {
	___iUserNum = iUser;
	if( oUserImg[iUser]['img'] ) {
		ShowGallery(___iUserNum, 1);
	}
	else {
		var sRand = _MC.RandomStr();
		var sUrl = '/ajax?action=project&name='+sName+'&rand='+sRand+'&num='+iNum;
		var sParams = '';
		
		new _AJAX( sUrl, 'get', ___ShowGalleryEnd, null );
	}
}
function ___ShowGalleryEnd(oData) {
	var oResp = eval('('+oData.responseText+')');
	
	var oData = oUserImg[___iUserNum];
	
	oData['name'] = oResp['title'];
	oData['name_'] = oResp['name'];
	oData['nm'] = oResp['num']*1;
	oData['link'] = oResp['link'];
	oData['img'] = [];
	
	for(var i=0, iL=oResp['images'].length; i<iL; i++) {
		var aRD = oResp['images'][i];
		oData['img'][i] = {};
		
		var aD = oData['img'][i];
		aD['id'] = aRD['num'];
		aD['src'] = aRD['big'];
		aD['width'] = aRD['big-w'];
		aD['height'] = aRD['big-h'];
		aD['s_src'] = aRD['small'];
		aD['s_width'] = aRD['small-w'];
		aD['s_height'] = aRD['small-h'];
		aD['curr'] = false;
		//aD['link'] = '#gallery='+___iUserNum+'&id='+aRD['num']+'&name='+oResp['name'];
		aD['url'] = '#'+oResp['name']+'&'+aRD['num']+'&'+___iUserNum;
		
		if(aRD['file'] && aRD['file']!= '') {
			aD['file'] = aRD['file'];
		}
	}
	
	ShowGallery(___iUserNum, oData['nm']);
}

var bGalleryTop = false;
function ShowGallery(iUser, iPhoto) {
	GalleryHeight();
	var oFade = $('fade');
	var oImgBlock = $('photo_list');
	var oLink = $('photo_list_user');
	
	_MC.SetClass(oFade, ' ', 'hidden');
	_MC.SetClass(oImgBlock, ' ', 'hidden');
	
	oLink.innerHTML = oUserImg[iUser]['name'];
	
	iUserNum = iUser;
	Gallery(iPhoto);
	bGalleryTop = true;
}
function ShowGalleryNext(iUser, iPhoto) {
	if(bGo){
		return;
	}
	GalleryHeight();
	var oFade = $('fade');
	var oImgBlock = $('photo_list');
	var oImg = $('photo_list_curr');
	var oLink = $('photo_list_user');
	var oVideo = $('photo_list_curr_video');
	
	var oLoader = $('photo_loader_'+iPhoto);
	var oBl = $('photo_'+iPhoto);
	
	_MC.SetClass(oFade, ' ', 'hidden');
	
	oLink.innerHTML = oUserImg[iUser]['name'];
	
	iUserNum = iUser;
	var oRight = $('photo_list_next');
	var aImg = oUserImg[iUser]['img'];
	
	for(var i=0, iLn = aImg.length; i<iLn; i++) {
		if( aImg[i]['id'] === iPhoto ) {
			if( aImg[i]['curr'] ) {
				
				return;
			}
			iIn = i;
		}
		aImg[i]['curr'] = false;
		
		var oBlock = $('photo_'+aImg[i]['id']);
		_MC.SetClass(oBlock, ' ', 'curr');
	}
	aImg[iIn]['curr'] = true;
	if(!oUserImg[iUser]['type']) {
		_MC.SetClass(oImgBlock, ' ', 'hidden');
	}
	_MC.SetClass(oVideo, 'hidden', ' ');
	_MC.SetClass(oImg, ' ', 'hidden');
	oVideo.innerHTML = '';
	_MC.SetClass(oLoader, ' ', 'hidden');
	_MC.SetClass(oBl, 'curr', ' ');
	
	GalleryGo();
}
function CloseGallery() {
	var oFade = $('fade');
	var oImgBlock = $('photo_list');
	var oImg = $('photo_list_curr');
	var oVideoBlock = $('photo_list_curr_video');
	var oClose = $('photo_list_close');
	
	_MC.SetClass(oFade, 'hidden', ' ');
	_MC.SetClass(oImgBlock, 'hidden', ' ');
	_MC.SetClass(oVideoBlock, 'hidden', ' ');
	_MC.SetClass(oClose, 'hidden', ' ');
	_MC.SetClass(oImg, ' ', 'hidden');
	
	iUserNum = null;
	bGalleryTop = false;
	if(_MC.isIe()) {
		_MC.SetClass( $('photo_search_city_list'), ' ', 'invisible' );
		_MC.SetClass( $('city'), ' ', 'invisible' );
	}
	
	var oImg = $('photo_list_curr');
	oImg.src = '../img/d-t.gif';
	oImg.width = 32;
	oImg.height = 32;
	
	_MC.SetHash(' ');
}

function CloseGalleryHover() {
	var oClose = $('photo_list_close');
	var oVClose = $('video_list_close');
	
	_MC.SetClass(oClose, 'hover', ' ');
	_MC.SetClass(oVClose, 'hover', ' ');
}
function CloseGalleryOut() {
	var oClose = $('photo_list_close');
	var oVClose = $('video_list_close');
	
	_MC.SetClass(oClose, ' ', 'hover');
	_MC.SetClass(oVClose, ' ', 'hover');
}

function SetOverClass(oElem) {
	_MC.SetClass(oElem, 'hover', ' ');
}
function DelOverClass(oElem) {
	_MC.SetClass(oElem, ' ', 'hover');
}

function CreateMoveImg( iTop, iLeft, sSrc, iWidth, iHeight ) {
	var oImg = document.createElement('img');
	oImg.style.position = 'absolute';
	oImg.style.top = iTop+'px';
	oImg.style.left = iLeft+'px';
	oImg.src = sSrc;
	oImg.width = iWidth;
	oImg.height = iHeight;
	oImg.style.zIndex = 100;
	oImg.style.border = '1px solid white';
	return oImg;
}

function Gallery( iNum ) {
	var aImg = oUserImg[iUserNum]['img'];
	var iIn = 0;
	for(var i=0, iLn = aImg.length; i<iLn; i++) {
		aImg[i]['curr'] = false;
		if( aImg[i]['id'] === iNum) {
			iIn = i;
		}
	}
	
	aImg[iIn]['curr'] = true;
	var oFade = $('fade');
	var oPhoto = $('photo_list');
	var oLayout = $('layout');
	
	var iHeight = oLayout.offsetHeight*1;
	
	var iScroll = _MC.isIe() ? document.body.parentElement.scrollTop*1 : window.scrollY;
	if(iScroll+1000 > iHeight) {
		//iHeight = iScroll+1000;
		//iScroll = iHeight-1000;
	}
	if(!bGalleryTop) {
		oPhoto.style.top = iScroll+'px';
		oFade.style.height = iHeight+'px';
	}
	var oParent = $('photo_list_curr_par');
	
	var oBg = $('photo_list_curr_bg');
	var oPr = $('photo_list_preview');
	oBg.style.width = (aImg[iIn]['width']*1)+'px';
	oBg.style.height = (aImg[iIn]['height']*1+82)+'px';
	//oPr.style.marginTop = (aImg[iIn]['height']*1+30)+'px';
	
	GalleryPreview(iNum);
	GalleryGo();
}

var bGo=false;
function GalleryGo() {
	var oLink = $('photo_list_link');
	var oClose = $('photo_list_close');
	_MC.SetClass(oLink, 'hidden', ' ');
	/*
	Получаем текущий элемент
	в зависимости от стороны в которую двигаемся получаем финальные координаты картинок, которые перемещаем
	создаем объекты клоны, в которые копируем адреса картинок и перемещаем их
	после завершения анимации устанавливаем картинки на исходную позицию, удаляем клоны
	*/
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var iCurr = 0;
	for(var i=0; i<iLn; i++) {
		if(aImg[i]['curr']) {
			var iCurr = i;
		}
	}
	if( bGo ) {
		return;
	}
	else {
		bGo = true;
	}
	
	//var oI = new Image();
	//oI.src = aImg[iCurr]['src'];
	
	_MC.SetClass(oClose, 'hidden', ' ');
	GalleryImgHide(100, iCurr);
}
function GalleryImgHide(iOp, iNum) {
	var reduceOpacityBy = 100/10;
	var rate = 30;	// 15 fps
	
	var sOpacity = getOpacityProperty();
	
	oElem = $('photo_list_curr');

	if (iOp > 0) {
		iOp -= reduceOpacityBy;
		if (iOp < 0) {
			iOp = 0;
		}

		if (oElem.filters) {
			try {
				oElem.filters.item("DXImageTransform.Microsoft.Alpha").opacity = iOp;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				oElem.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + iOp + ')';
			}
		} else {
			oElem.style[sOpacity] = iOp / 100;
		}
	}
	
	if (iOp > 0) {
		setTimeout(function () {
			GalleryImgHide(iOp, iNum);
		}, rate);
	}
	else {
		_MC.SetClass(oElem, 'opacity_0', ' ');
		_MC.SetClass(oElem, 'hidden', ' ');
		GalleryImgSize(iNum);
	}
}
function GalleryImgShow(iOp, oData) {
	iOp = iOp*1;
	var reduceOpacityBy = 100/10;
	var rate = 30;	// 15 fps
	
	var sOpacity = getOpacityProperty();
	oElem = $('photo_list_curr');

	if (iOp < 100) {
		iOp += reduceOpacityBy;
		if (iOp > 100) {
			iOp = 100;
		}

		if (oElem.filters) {
			try {
				oElem.filters.item("DXImageTransform.Microsoft.Alpha").opacity = iOp;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				oElem.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + iOp + ')';
			}
		} else {
			oElem.style[sOpacity] = iOp / 100;
		}
	}
	
	if (iOp < 100) {
		setTimeout(function () {
			GalleryImgShow(iOp, oData);
		}, rate);
		_MC.SetClass(oElem, ' ', 'opacity_0');
		_MC.SetClass(oElem, ' ', 'hidden');
	}
	else {
		var oLoader = $('photo_loader_'+oData['id']);
		var oParent = $('photo_list_curr_par');
		var oLink = $('photo_list_link');
		if(oData['file']) {
			var oV = $('photo_list_curr_video');
			var oI = $('photo_list_curr');
			ShowClose();
			_MC.SetClass(oI, 'hidden', ' ');
			_MC.SetClass(oLink, 'hidden', ' ');
			_MC.SetClass(oV, ' ', 'hidden');
			
			var so = new SWFObject('/Data/Design/video/player.swf','mpl',oData['width'],oData['height'],'9');
			so.addParam('allowfullscreen','true');
			so.addParam('allowscriptaccess','always');
			so.addParam('wmode','opaque');
			so.addVariable('file', oData['file']);
			so.addVariable('backcolor','000000');
			so.addVariable('frontcolor','f1f1f1');
			so.addVariable('lightcolor','008ecd');
			//so.addVariable('playlistsize','240');
			//so.addVariable('bufferlength','5');
			//so.addVariable('playlist','right');
			so.addVariable('stretching','uniform');
			so.write('photo_list_curr_video');
			
		}
		else {
			var oV = $('photo_list_curr_video');
			var oI = $('photo_list_curr');
			_MC.SetClass(oI, ' ', 'hidden');
			_MC.SetClass(oV, 'hidden', ' ');
			if(oData['link'] && oData['link']!= '') {
				SetLink();
			}
			ShowClose();
		}
		
		GallerySetText(oData['id']);
		
		_MC.SetClass(oLoader, 'hidden', ' ');
		bGo=false;
	}
}

function ShowClose() {
	var oClose = $('photo_list_close');
	var oImg = $('photo_list_curr_bg');
	
	var iT = oImg.offsetTop*1;
	var iL = oImg.offsetLeft*1;
	var iW = oImg.offsetWidth*1;
	
	//oClose.style.top = (iT+15)+'px';
	//oClose.style.left = (iL+iW-10)+'px';
	_MC.SetClass(oClose, ' ', 'hidden');
}

function GalleryImgSize(iNum) {
	var iIndex = iNum;
	var aImg = oUserImg[iUserNum]['img'];
	var oData = aImg[iIndex];
	
	
	if(oUserImg[iUserNum]['link'] && _MC.Trim(oUserImg[iUserNum]['link']) != '') {
		oData['link'] = _MC.Trim(oUserImg[iUserNum]['link']);
	}
	
	var oPrev = $('photo_list_preview');
	var iMT = parseInt(oPrev.style.marginTop);
	
	var oBg = $('photo_list_curr_bg');
	var iW = parseInt(oBg.style.width);
	var iH = parseInt(oBg.style.height);
	var bUp = (oData['height']*1+82<iH) ? true : false;
	
	GalleryImgWidth(bUp, oData, iW, iH);
}
function GalleryImgWidth(bUp, oData, iW, iH) {
	var oBg = $('photo_list_curr_bg');
	if(bUp) {
		var iStep = -15;
		iW+=iStep;
		if (iW<oData['width']*1) {
			iW = oData['width']*1;
		}
	}
	else{
		var iStep = 15;
		iW+=iStep;
		if (iW>oData['width']*1) {
			iW = oData['width']*1;
		}
	}
	
	oBg.style.width = iW+'px';
	
	if(oData['width']*1!==iW) {
		setTimeout(function () {
			GalleryImgWidth(bUp, oData, iW, iH);
		}, 20);
	}
	else {
		GalleryImgHeight(bUp, oData, iW, iH)
	}
}
function GalleryImgHeight(bUp, oData, iW, iH) {
	var oBg = $('photo_list_curr_bg');
	var iHgt = 82;
	var iPictH = oData['height']*1+iHgt;
	if(bUp) {
		var iStep = -15;
		iH+=iStep;
		if (iH<iPictH) {
			iH = iPictH;
		}
	}
	else{
		var iStep = 15;
		iH+=iStep;
		if (iH>iPictH) {
			iH = iPictH;
		}
	}
	
	oBg.style.height = iH+'px';
	
	if(iPictH!==iH) {
		setTimeout(function () {
			GalleryImgHeight(bUp, oData, iW, iH);
		}, 20);
	}
	else {
		var oImg = document.createElement('img');
		oImg.onload = function() {
			var oI = $('photo_list_curr');
			oI.width = oData['width'];
			oI.height = oData['height'];
			oI.src = oData['src'];
			GalleryImgShow(0, oData);
		}
		oImg.src = oData['src'];
		$('img_container').appendChild(oImg);
	}
}


function GalleryPreviewBuild() {
	var oPrev = $('photo_list_preview_prev_arrow');
	var oNext = $('photo_list_preview_next_arrow');
	var oList = $('photo_list_preview_list_line');
	
	var aImg = oUserImg[iUserNum]['img'];
	var iL = aImg.length;
	
	var aHTML = [];
	for(var i=0; i<iL; i++) {
		aHTML[aHTML.length] = '<div id="photo_'+(i+1)+'" onclick="ShowGalleryNext('+iUserNum+', '+aImg[i]['id']+'); return false;">';
		aHTML[aHTML.length] = '<img src="'+aImg[i]['s_src']+'" width="'+aImg[i]['s_width']+'" height="'+aImg[i]['s_height']+'" alt="" border="0" />';
		aHTML[aHTML.length] = '<img id="photo_loader_'+(i+1)+'" class="loader hidden" src="../img/d-t.gif" width="'+(aImg[i]['s_width']+2)+'" height="'+(aImg[i]['s_height']+2)+'" alt="" border="0" />';
		if(aImg[i]['file'] != null && _MC.Trim(aImg[i]['file'])!= '') {
			aHTML[aHTML.length] = '<img class="video" src="../img/d-t.gif" width="'+(aImg[i]['s_width']+2)+'" height="'+(aImg[i]['s_height']+2)+'" alt="" border="0" />';
		}
		aHTML[aHTML.length] = '</div>';
	}
	
	if(iL<=7) {
		$('photo_list_preview').style.width = 104*iL+14+'px';
		$('photo_list_preview_list').style.width = 104*iL+'px';
		
		_MC.SetClass(oPrev, 'off', ' ');
		_MC.SetClass(oNext, 'off', ' ');
		_MC.SetClass(oPrev, 'invisible', ' ');
		_MC.SetClass(oNext, 'invisible', ' ');
	}
	else {
		$('photo_list_preview').style.width = '742px';
		$('photo_list_preview').style.let = '742px';
		$('photo_list_preview_list').setAttribute('style', '');
		$('photo_list_preview_list').removeAttribute('style');
		
		_MC.SetClass(oNext, ' ', 'off');
		_MC.SetClass(oPrev, ' ', 'invisible');
		_MC.SetClass(oNext, ' ', 'invisible');
	}
	_MC.SetClass(oPrev, 'off', ' ');
	
	oList.style.left = 'auto';
	oList.innerHTML = aHTML.join('');
	
	if(iL>7) {
		
	}
}

function GalleryPreview(iNum) {
	if(!bGalleryTop) {
		GalleryPreviewBuild();
	}
	var oCurr = $('photo_'+iNum);
	if(oCurr) {
		var aImg = oUserImg[iUserNum]['img'];
		var iL = aImg.length;
		for(var i=0; i<iL; i++) {
			var oElem = $('photo_'+(i+1));
			
			_MC.SetClass(oElem, ' ', 'curr');
		}
		
		var iLft = oCurr.offsetLeft*1;
		if(iLft>=104*7 && iL>7) {
			var iP = iLft/104;
			var oList = $('photo_list_preview_list_line');
			oList.style.left = ( ( (iP-6)*104 )*(-1) )+'px';
		}
		
		_MC.SetClass(oCurr, 'curr', ' ');
		return oCurr;
	}
	else {
		return null;
	}
}

function GallerySetText(iIndex) {
	var aImg = oUserImg[iUserNum]['img'];
	
	_MC.SetHash(aImg[iIndex-1]['url']);
}

var bGallerPrevGo = false;
function GalleryLineLeft() {
	if(bPrev) {
		bPrev = false;
		bPrevGo = false;
		return;
	}
	if(bGallerPrevGo || _MC.MatchClass( $('photo_list_preview_next_arrow'), 'off'))
		return;
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var oList = $('photo_list_preview_list_line');
	var iW = 104;
	var iWidth = iLn*iW;
	var iLWidth = 7*iW;
	var iLft = 0;
	
	if(iWidth<=iLWidth) {
		return;
	}
	
	var iLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
	var iDiff = iWidth-iLWidth;
	var aLine = [];
	for(var i=1; i<=iDiff/iW; i++) {
		aLine[aLine.length] = iW*i-iLft;
	}
	var iCLt = 0;
	for(var j=0, iLen=aLine.length; j<iLen; j++) {
		if( iLeft*(-1)<	aLine[j]) {
			iCLt = aLine[j]*(-1);
			break;
		}
	}
	if(!iCLt) {
		iCLt = aLine[aLine.length-1]*(-1);
	}
	
	if( iLeft*(-1)-iLft < iWidth-iLWidth ) {
		var _this = this;
		this.iLine = iW;
		this.oTimer = window.setInterval(function(){
			bGallerPrevGo = true;
			var iCLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
			var iStep = ( ((iCLt*(-1))-(iCLeft*(-1))) < 10) ? iCLt-iCLeft : -10;
			var iL = iStep*1+iCLeft*1;
				
			if( iL*(-1) >= iCLt*(-1) ) {
				bGallerPrevGo = false;
				window.clearInterval(_this.oTimer);
				oList.style.left = iL+'px';
			}
			else {
				oList.style.left = iL+'px';
			}
			_this.iLine += iStep;
		}, 30);
		
		_MC.SetClass( $('photo_list_preview_prev_arrow'), ' ', 'off' );
		if(iLeft*(-1)+iLft+iW === iWidth-iLWidth) {
			_MC.SetClass( $('photo_list_preview_next_arrow'), 'off', ' ' );
			_MC.SetClass( $('photo_list_preview_next_arrow'), ' ', 'hover' );
		}
	}
}
function GalleryLineRight() {
	if(bPrev) {
		bPrev = false;
		bPrevGo = false;
		return;
	}
	if(bGallerPrevGo || _MC.MatchClass( $('photo_list_preview_prev_arrow'), 'off'))
		return;
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var oList = $('photo_list_preview_list_line');
	var iW = 104;
	var iWidth = iLn*iW;
	var iLWidth = 7*iW;
	var iLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
	var iLft = 0;
	
	if( iWidth<=iLWidth || iLeft >= 0 ) {
		return;
	}
	
	var iDiff = iWidth-iLWidth;
	var aLine = [];
	for(var i=1; i<=iDiff/iW; i++) {
		aLine[aLine.length] = iW*i-iLft;
	}
	var iCLt = 0;
	for(var j=aLine.length-1; j>=0; j--) {
		if( iLeft*(-1)>	aLine[j]) {
			iCLt = aLine[j]*(-1);
			break;
		}
	}
	if(!iCLt) {
		iCLt = iLft;
	}
	
	if( iLeft < iLft ) {
		var _this = this;
		this.iLine = iW;
		this.oTimer = window.setInterval(function(){
			bGallerPrevGo = true;
			var iCLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
			var iStep = (  ((iCLeft*(-1))-(iCLt*(-1))) < 10) ? (iCLeft-iCLt)*(-1) : 10;
			var iL = iStep*1+iCLeft*1;
				
			if( iL >= iCLt ) {
				bGallerPrevGo = false;
				window.clearInterval(_this.oTimer);
				oList.style.left = iL+'px';
			}
			else {
				oList.style.left = iL+'px';
			}
			_this.iLine -= iStep;
		}, 30);
		
		_MC.SetClass( $('photo_list_preview_next_arrow'), ' ', 'off' );
		if(iLeft+iW === iLft) {
			_MC.SetClass( $('photo_list_preview_prev_arrow'), 'off', ' ' );
			_MC.SetClass( $('photo_list_preview_prev_arrow'), ' ', 'hover' );
		}
	}
}

var _bGallerPrevGo = false;
var GLTimer = null;
var bPrevGo = false;
var bPrev = false;
function GalleryLineGoLeft() {
	if( _MC.MatchClass( $('photo_list_preview_next_arrow'), 'off') || bPrev || bPrevGo )
		return;
	var _this = this;
	this.iTime = 100;
	this.iCurrTime = 0;
	
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var oList = $('photo_list_preview_list_line');
	var iW = 104;
	var iWidth = iLn*iW;
	var iLWidth = 7*iW;
	bPrevGo = true;
	var iLft = 0;
	
	var iLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
	this.iLine = iWidth - ( Math.abs(iLeft)+iLWidth )+ iLft ;
	
	this.bInterval = false;
	GLTimer = window.setInterval(function(){
		if(_this.iCurrTime >= 100) {
			bPrev = true;
			var iDiff = iWidth-iLWidth;
			var aLine = [];
			for(var i=1; i<=iDiff/iW; i++) {
				aLine[aLine.length] = iW*i-iLft;
			}
			var iCLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
			var iCLt = 0;
			for(var j=0, iLen=aLine.length; j<iLen; j++) {
				if( iCLeft*(-1)<= aLine[j]) {
					iCLt = aLine[j]*(-1);
					break;
				}
			}
			if(!iCLt) {
				iCLt = aLine[aLine.length-1]*(-1);
			}
			
			var iStepDiff = (iCLt - iCLeft*(-1));
			var iStep = ( iStepDiff < 15 && iStepDiff>0) ? (iCLt - iCLeft*(-1))  : 15;
			iStep *= -1;
			var iL = iStep*1+iCLeft*1;
			
			/*
			$('photo_list_curr_par').style.color = 'white';
			$('photo_list_curr_par').innerHTML += iCLeft*(-1)+ ' '+iCLt*(-1)+' '+bPrevGo.toString()+'; ';
			*/
				
			if( (iCLeft*(-1) >= iCLt*(-1) && !bPrevGo) || (iCLeft*(-1) >= aLine[aLine.length-1]) ) {
				window.clearInterval(GLTimer);
				GLTimer = null;
				oList.style.left = iCLt+'px';
				bPrev = false;
			}
			else {
				oList.style.left = iL+'px';
			}
			_this.iLine += iStep;
		}
		else {
			bPrev = false;
			_this.iCurrTime += 10;
		}
		//$('photo_list_curr_par').style.color = 'white';
		//$('photo_list_curr_par').innerHTML += _MC.RandomStr()+'; ';
	}, 10);
}
function GalleryLineGoLeftStop() {
	if(!bPrev) {
		window.clearInterval(GLTimer);
		GLTimer = null;
	}
	bPrevGo = false;
	
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var oList = $('photo_list_preview_list_line');
	var iW = 104;
	var iWidth = iLn*iW;
	var iLWidth = 7*iW;
	var iLft = 0;
	
	var iLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
	_MC.SetClass( $('photo_list_preview_prev_arrow'), ' ', 'off' );
	if(iLeft*(-1)+iLft >= iWidth-iLWidth) {
		_MC.SetClass( $('photo_list_preview_next_arrow'), 'off', ' ' );
		_MC.SetClass( $('photo_list_preview_next_arrow'), ' ', 'hover' );
	}
}

function GalleryLineGoRight() {
	if( _MC.MatchClass( $('photo_list_preview_prev_arrow'), 'off') || bPrev || bPrevGo )
		return;
	var _this = this;
	this.iTime = 100;
	this.iCurrTime = 0;
	
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var oList = $('photo_list_preview_list_line');
	var iW = 104;
	var iWidth = iLn*iW;
	var iLWidth = 7*iW;
	bPrevGo = true;
	var iLft = 0;
	
	var iLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
	this.iLine = iWidth - ( Math.abs(iLeft)+iLWidth )+ iLft ;
	
	this.bInterval = false;
	GLTimer = window.setInterval(function(){
		if(_this.iCurrTime >= 100) {
			bPrev = true;
			var iDiff = iWidth-iLWidth;
			var aLine = [];
			for(var i=0; i<iDiff/iW; i++) {
				aLine[aLine.length] = iW*i-iLft;
			}
			var iCLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
			var iCLt = 0;
			for(var j=aLine.length-1; j>=0; j--) {
				if( iCLeft*(-1) > aLine[j] ) {
					iCLt = aLine[j]*(-1);
					break;
				}
			}
			if(!iCLt) {
				iCLt = iLft;
			}
			
			var iStepDiff = (iCLt - iCLeft*(-1));
			var iStep = ( iStepDiff < 15 && iStepDiff>0) ? (iCLt - iCLeft*(-1)) : 15;
			var iL = iStep*1+iCLeft*1;
			
			if( (iL>=iCLt && !bPrevGo) || (iCLeft >= iLft) ) {
				window.clearInterval(GLTimer);
				GLTimer = null;
				oList.style.left = iCLt+'px';
				bPrev = false;
			}
			else {
				oList.style.left = iL+'px';
			}
			_this.iLine += iStep;
		}
		else {
			bPrev = false;
			_this.iCurrTime += 10;
		}
		//$('photo_list_curr_par').style.color = 'white';
		//$('photo_list_curr_par').innerHTML += _MC.RandomStr()+'; ';
	}, 10);
}
function GalleryLineGoRightStop() {
	if(!bPrev) {
		window.clearInterval(GLTimer);
		GLTimer = null;
	}
	bPrevGo = false;
	var iLft = 0;
	
	var aImg = oUserImg[iUserNum]['img'];
	var iLn = aImg.length;
	var oList = $('photo_list_preview_list_line');
	var iW = 104;
	var iWidth = iLn*iW;
	var iLWidth = 7*iW;
	
	var iLeft = ( isNaN( parseInt(oList.style.left) ) ) ? iLft : parseInt(oList.style.left);
	_MC.SetClass( $('photo_list_preview_next_arrow'), ' ', 'off' );
	if(iLeft === iLft) {
		_MC.SetClass( $('photo_list_preview_prev_arrow'), 'off', ' ' );
		_MC.SetClass( $('photo_list_preview_prev_arrow'), ' ', 'hover' );
	}
}

function GalleryArrowHover(oElem) {
	if(!_MC.MatchClass(oElem, 'off')) {
		_MC.SetClass(oElem, 'hover', ' ');
	}
}
function GalleryArrowOut(oElem) {
		_MC.SetClass(oElem, ' ', 'hover');
}

function SetLink() {
	var oLink = $('photo_list_link');
	
	var sLink = oUserImg[iUserNum]['link'];
	
	if( _MC.Trim(sLink) != '' ) {
		var oImg = $('photo_list_curr');
		
		var iW = oImg.offsetWidth*1;
		var iH = oImg.offsetHeight*1;
		var iL = oImg.offsetLeft*1;
		
		oLink.style.width = iW+'px';
		oLink.style.height = (iH)+'px';
		//oLink.style.left = iL+'px';
		
		oLink.href = sLink;
		
		_MC.SetClass(oLink, ' ', 'hidden');
	}
	else {
		oLink.href = '#';
		_MC.SetClass(oLink, 'hidden', ' ');
	}
}

function SelectImgText() {
	if(_MC.isIe()){
		var range = document.body.createTextRange();
		var tab=document.getElementById('photo_list_curr_txt_link');
		range.moveToElementText(tab);
		range.select();
	}
	else {
		var selection = window.getSelection();
		var range = document.createRange();
		var tab = document.getElementById('photo_list_curr_txt_link');
			 
		range.selectNodeContents(tab);
		selection.addRange(range);
	}
}

function GResize() {
	
}

function CheckImg() {
	var sHash = _MC.GetHash().toString();
	sHash = _MC.Trim(sHash);
	
	if(sHash!== '' && sHash.indexOf('about')<0 && sHash.indexOf('contact')<0) {
		var aH = sHash.split('&');
		
		if( oUserImg[aH[2]*1]['img'] ) {
			ShowGallery(aH[2]*1, aH[1]*1);
		}
		else {
			___ShowGallery(aH[2]*1, aH[0], aH[1]*1);
		}
	}
}
/* Галерея */






































