function spotCreate(){
	spotFs['zero'] = new Date().getTime();
	this.reportSent = false;
	this.srnd = Math.random();
	this.report = {
		'start'					: 0,
		'ajaxBefore'			: 0,	
		'ajaxStartComplete'		: 0,
		'ajaxAccessStatusFound'	: 0, 
		'ajaxStartParse'		: 0, 
		'ajaxSplitComplete'		: 0,
		'ajaxIsJson'			: 0, 
		'ajaxIsJsonError'		: 0,
		'ajaxBeforeParseAjax'	: 0,
		'ajaxAfterParseAjax'	: 0,
		'ajaxOnFailure'			: 0,
		'ajaxOnException' 		: 0
	};
	this.report['start'] = 1;
	
	if(window['spotSR']){
		this.report['renderStart'] = spotSR;
	} else {
		this.report['renderStart'] = '0';
	}
	
	this.arrArray = new Array();
	
	this.jump = function(link){ if(this.b[link]){ return this.b[link]; } else { 
	//alert('this.jump error with ID: ' + link);  
	} }
	this._time = {};
	this._time.i = [];
	this.srvTime = 0;
	this.loaderTimer = null;
	if(!this.inited) { this.inited = false; }
	this.fotoCropInited = false;
	this.init = function(){
		this.inited = true;
	        if(spotFs['init']){
	        	spotFs['secondInit'] = new Date().getTime();
	        } else {
			spotFs['init'] = new Date().getTime();
		}

		this._intervalId;
		this.o = {} // main object
		this.b = {} // cached boxes
		//this.hash = this.getCurrentHash();
		this.hash = this.kill(document.location.hash);
		this.fl1 = new fotoLine();
		this.fl2 = new fotoLine();
		
		this.prevUrl = document.referrer;
		this.currUrl = document.URL.replace(/\/spot#/, "");
		this.prevHash = '';
		this.voted = {};

		this.cacheBlocks(); // cache boxes->b
		this.bindCommonEvents();

		/*
		if(Prototype.Browser.IE){
			this.history = $('spotHistory');
			this.history.src = 'http://foto.mail.ru/catalog/static/spothist.html?page=' + this.hash;
		} else {
			this.load();
		}
		*/
		this.load();

		this.ohint = setTimeout(this.observeHash.bind(this), 250);
		
		this.inited = true;
		spot_spotReady = true;
	}

	this.reportReset = function(){
		this.report = {
			'renderStart'	: (new Date()).getTime()
		}
		this.srnd = Math.random();
		this.reportSent = false;
		this.afterSent = false;
	}
	
	this.kill = function(l){
		if(l.indexOf('#') != -1){ l = l.substr(1,l.length); }
		return l;
	}
	
	this.observeHash = function(){
		//var _n = this.getCurrentHash();
		var _n = this.kill(document.location.hash);
		if(_n != this.hash){
			this.hash = _n;
			this.spotGo(null, _n);
		}
		this.ohint = setTimeout(this.observeHash.bind(this), 250);
	}
	
	this._timeInterval = function(t){
		if (!this._time[t]) {
			this._time[t] = new Date(); 
		} else {
            this._time.i[this._time.i.length] = t + '=' + ( (new Date()).getTime() - this._time[t].getTime() );
            delete this._time[t];
	    }
	}

	this.spotGo = function(e, out){
		spotFs['spotGo'] = new Date().getTime();
		this.reportReset();
		if(out){
			var hs = out;
			if(hs.indexOf('#') != -1){ hs = hs.substr(1,hs.length); }
		} else {
			var hs = out;
			if(hs.indexOf('#') != -1){ hs = hs.substr(1,hs.length); }
		}
		//hs = this.getHash(hs);

		var r = /^[#]{0,1}\/(community|mail|list|inbox|bk|corp)+\/[A-Za-z0-9-_.]+\/[A-Za-z0-9-_.]+\/[0-9]+\.(spot|html)/;
		if(r.test(hs)){
		        /*
			if(Prototype.Browser.IE){
				this.history.src = 'http://foto.mail.ru/catalog/static/spothist.html?page=' + hs;
//				return false;
			} else {
				this.load();
			}
			*/
			this.load();
		}
	}
	
	this.spotStep = function(to){
		spot.hash = to;
		spot.load();
	}
	
	this.spotNext = function(){
		if(this.o.foto.next_image != false){
			this.hash = this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.next_image + '.spot';
			//document.location.hash = this.getHash(this.hash, 'html');
			this.load();
		} else {
			document.location.href = this.o.user.CurBox + this.o.album.id;
		}
	}

	this.formUrl = function(){
		return 'http://' + this.o.PhotoPerlHost + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html';
	}
	
	this.getCurrentHash = function(){
		return this.getHash(document.location.hash);
	}
	
	this.getHash = function(hashString, t){
		if(hashString.indexOf('#') != -1){ hashString = hashString.substr(hashString.indexOf('#')+1,hashString.length); }
		var lpart;
		var rpart;
		if(hashString.indexOf('?') != -1){
			var _h1 = hashString.split('?');
			lpart = _h1[0];
			rpart = _h1[1];
		} else {
			lpart = hashString;
		}
		var leftHash = lpart.split('/');
		leftHash = leftHash.without('');
		if(leftHash.length == 4){ leftHash[3] = leftHash[3].replace(/(.html$|.spot$)/, ''); }
		lpart = '/' + leftHash.join('/');
		if(t == 'clean'){
			return lpart;
		} else if (t == 'html'){
			return lpart + '.html' + ((rpart) ? '?' + rpart : '');
		} else {
			return lpart + '.spot' + ((rpart) ? '?' + rpart : '');
		}
	}
	
	this.error10 = function(){
		this.report['timeOut'] = 1;
		this.hideAjaxLoad();
		this.reportSent = true;
		this.show500Alert('timeout');
		spotOnError('SPOTERROR: 30 sec timeout error found.', '', this.srnd);
	}
		
	this.hideAjaxLoad = function(){
		clearTimeout(this.loaderTimer);
		this.loaderTimer = null;
		clearTimeout(this.s10);
		this.s10 = null;
		var _sal = $('spot-ajax-load');
		if(_sal){
			_sal.hide();
		}
	
	}
		
	this.showAjaxLoad = function(){
		var _sal = $('spot-ajax-load');
		if(_sal){
			this.loaderTimer = setTimeout(function() {
				_sal.show(); 
				this.reportSent = true; 
				//spotOnError('SPOTERROR: ajax loader found.', '', this.srnd);
			}, 5000);
			clearTimeout(this.s10);
			this.s10 = null;
			this.s10 = setTimeout(this.error10.bind(this), 30000);
		}
	}
		
	this.load = function(){
		spotFs['load'] = new Date().getTime();
		spotFs['spot_initial'] = spot_initial;
		spotFs['spot_ajaxReady'] = spot_ajaxReady;
		spotFs['spot_ajaxStarted'] = spot_ajaxStarted;
		if(spot_fromHead == true){
			spot_fromHead = false;
			spotFs['loadBranch1'] = new Date().getTime();
		        spot_ajaxStarted = false;
			spot_initial = false;
			
			this._timeInterval('srvt');
			this.ivt = {};
			this.ivt.i = [];
			if(this.inited == true){ 
				this.showAjaxLoad();
			}
			
			this.ajaxReturned(spot_preObject);
//		} else if ((spot_ajaxStarted == false && spot_initial == false) || ()){
		} else {
			spot_fromHead = false;
			spot_spotReady = false;
			spotFs['loadBranch2'] = new Date().getTime();
			this._timeInterval('srvt');
			this.ivt = {};
			this.ivt.i = [];
			if(this.inited == true){ 
				this.showAjaxLoad();
			}
			var ie6cache = Math.random() + '' + new Date().getTime();
			var url = location.protocol + '//' + location.host + this.getHash(this.hash);
//			if(url.indexOf('?') == -1){ url += '?spotAjax=1'; } else { url += '&spotAjax=1'; }
                        if(url.indexOf('?') == -1){ url += '?r=' + ie6cache + '&getmy=1&from=spot'; } else { url += '&r=' + ie6cache + '&getmy=1&from=spot'; }
//                        if(url.indexOf('?') == -1){ url += '?getmy=1'; } else { url += '&getmy=1'; }
			var r = /http:\/\/[:A-Za-z0-9.^/]+\/(community|mail|list|inbox|bk|corp)+\/[A-Za-z0-9-_.]+\/[A-Za-z0-9-_.]+\/[0-9]+\.(spot|html)[:0-9]*/;
			if(r.test(url)){
				this.report['ajaxBefore'] = 1;
				this.report['renderAjaxStart'] = (new Date()).getTime();
				new Ajax.Request(url, {
					method:	'get',
					onComplete:	this.ajaxReturned.bind(this),
					onFailure: function(t){
						this.report['ajaxOnFailure'] = 1;
						this.reportSent = true;
						this.show500Alert('SP500E1: ajaxRequest onFailure: Error ' + t.status + ' (' + t.statusText + ')');
					}.bind(this),
					onException: function(a,b){
						this.report['ajaxOnException'] = 1;
						this.exception = b;
						this.report['exception'] = b.message;
						//this.show500Alert('ajaxRequest onException');
					}.bind(this)
				});
			} else {
				this.show404Alert('invalid URL');
			}
		}
//		} else {
//			spotFs['loadBranch3'] = 1;
//		}
	}

	this.ajaxReturned = function(t){
					this.report['renderAjaxCallback'] = (new Date()).getTime();
					this.report['ajaxStartComplete'] = 1;
					this._timeInterval('srvt');
					this._renderTime(0);
					clearTimeout(this.loaderTimer);
					this.loaderTimer = null;
					var r = t.responseText;
					this.AccessStatus = {}
					if(r.indexOf('"AccessStatus"') != -1 ){
						this.report['ajaxAccessStatusFound'] = 1;
						this.hideAjaxLoad();
						this.AccessStatus = r.evalJSON(false).shift();
						if(this.AccessStatus.AccessStatus == 1){
							this.showEroAlert();
						} else if(this.AccessStatus.AccessStatus == 2){
							this.showPasswordAlert();
						} else if (this.AccessStatus.AccessStatus == 3){
							this.showDeniedAlert();
						} else if (this.AccessStatus.AccessStatus == 4){
							this.show404Alert('AccessStatus=4');
						} else if (this.AccessStatus.AccessStatus == 5){
							this.reportSent = true;
							this.show500Alert('AccessStatus=5');
						} else if (this.AccessStatus.AccessStatus == 6){
							this.show404Alert('AccessStatus=6');
						}
					} else {
						this.report['ajaxStartParse'] = 1;
						var x = r.split(/<!--___-->/);
						this.report['ajaxSplitComplete'] = 1;
						if(x[0].isJSON()){
							this.report['ajaxIsJson'] = 1;
						} else {
							this.report['ajaxIsJson'] = 0;
							this.report['ajaxIsJsonError'] = 1;
						}
						var ext_o = x[0].evalJSON(false).shift();
						var ext_b = x[1];
						this.report['ajaxBeforeParseAjax'] = 1;
						this.parseAjax(ext_o, ext_b);
						this.report['ajaxAfterParseAjax'] = 1;
					}
					this.hideAjaxLoad();
		}

	this.checkRedir = function(obj){
		if(obj){
			if(obj.RedirUrl && obj.RedirUrl.indexOf('http://') != -1){
				document.location.href = obj.RedirUrl;
			}
		}
	}	
	this.parseAjax = function(){
		this.checkRedir(arguments[0]);
		this.hideCommonAlert();
		this.firstInited = true;
			
		if(this.o.user){
			var _c1 = this.o.user.email;
			var _c2 = this.o.album.id;
			var _initial = false;
		} else { var _initial = true; }

		this.o = Object.clone(arguments[0]);
		if(_initial != true){
			this.prevUrl = this.currUrl;
			this.currUrl = this.formUrl();
		}
		this.prevHash = this.hash;
		this.f2inited = false;

		this.now_banners = arguments[1];
		this._spot_banners = this.now_banners.split(/<!--___slotsplit___-->/);

		if(_initial == true){
			this.rewriteFull();

			this.fl1.setParams({
				'id'			:	'spot-fotoother-line',
				'inline'		:	5,
				'type'			:	'advanced',
				'imgHost'		:	'http://' + this.o.PhotoContentHost,
				'handleMouse'	:	true
			});
			this.fl2.setParams({
				'id'			:	'spot-fotoliked-line',
				'inline'		:	5,
				'type'			:	'simple',
				'imgHost'		:	'http://' + this.o.PhotoContentHost,
				'handleMouse'	:	true,
				'noCurrent'		:	true
			});

			this.jump('crop_bound').removeClassName('img-loader');
			this.fl1.fillData(this.o.otherFoto.array, this.o.otherFoto.data, this.o.otherFoto.current);
		} else {
			if(this.o.user.email == _c1 && this.o.album.id == _c2){
				this.rewriteSimple();
				this.fl1.fillData(this.o.otherFoto.array, this.o.otherFoto.data, this.o.otherFoto.current);
			} else {
				this.rewriteFull();
				this.fl1.fillData(this.o.otherFoto.array, this.o.otherFoto.data, this.o.otherFoto.current);
			}
		}
	}
	
	this.bindCommonEvents = function(){
		this.jump('spot-nav-title-edit-submit').observe('click', this.editTitleSave.bindAsEventListener(this));
		this.jump('spot-nav-title-edit-cancel').observe('click', this.editTitleCancel.bindAsEventListener(this));
		
		//ctrl + arrow
		document.observe('keydown',this.listPage.bind(this));
		
		//mm3
		this.jump('spot-blogs-submit').onclick = this.go_in_blogs.bindAsEventListener(this);
		this.jump('spot-mm-m3-a2').observe('click', function(e){
			var __el = Event.element(e);
			if(this.blockedAjax == 0){
				ajax_call('perl_isinblacklist', function(st){
					if(st == '0'){
						this.blockedAjax = 1;
						InfoBlock.show('GetCode', e, __el, 'submenu', 'rel', 5, 40, true, 3);
					} else if (st == '1'){
						this.blockedAjax = 2;
						alert('Вы не можете публиковать фото этого пользователя');
					}
				}.bindAsEventListener(this));
			} else if (this.blockedAjax == 1){
				InfoBlock.show('GetCode', e, __el, 'submenu', 'rel', 5, 40, true, 3);
			} else if (this.blockedAjax == 2){
				alert('Вы не можете публиковать фото этого пользователя');
			}
		}.bindAsEventListener(this));
		//mm7
		this.jump('spot-m7-a').onclick = this.MM7.bind(this);
		
		// cookie photoprint
		this.jump('spot-addin-cook').observe('click', function(){ incook(true, this.o.user.email, this.o.album.id); }.bind(this));
		this.jump('spot-delfrom-cook').observe('click', function(){ incook(false, this.o.user.email, this.o.album.id); }.bind(this));
		
		//PhotoInfo description editing
		this.jump('imageCommentSpan').observe('click', function(){
			this.jump('imageComment-own').hide();
			this.jump('fotoDescription').show();						
		}.bind(this));
		this.jump('spot-info-desc-submit')
			.observe('click', function(){
				ajax_call('perl_change_image_comment', this.o.foto.id, this.o.album.id, this.jump('spot-info-desc-edit').getValue(), function(newname,imageid){
					if(imageid){
						if(newname == undefined || newname == null || newname == ''){
							newname = 'Нет описания';
						}
						this.jump('imageCommentSpan').update(newname);
						this.jump('imageComment-own').show();
						this.jump('fotoDescription').hide();						
					} else { alert('Ошибка!'); }
				}.bind(this));
			}.bind(this));
		this.jump('spot-info-desc-reset')
			.observe('click', function(){
				this.jump('imageComment-own').show();
				this.jump('fotoDescription').hide();						
			}.bind(this));
		
		//photoinfo tags edit
		this.jump('spot-tags-close').observe('click', function(){ this.jump('editLabelsBlockId').hide(); }.bind(this));
		this.jump('spot-tags-reset').observe('click', function(){ this.jump('editLabelsBlockId').hide(); }.bind(this));
		this.jump('spot-tags-submit').observe('click', function(){
			ajax_call('perl_save_tags',this.jump('txtarForEditLabelsId').getValue(), this.o.album.id, this.o.foto.id,function(tags,user_tags,encoded,photo_id,isError,errorText){
				if (!tags.length) {tags = [tags];}
				if(tags == 'error'){ 
					alert(user_tags); 
				} else {
				
					var tags_hash = [];
					$A(tags).each( function(s){
						tags_hash.push({'Name': s, 'Tag': s});
					});
					this.FillFotoTags(tags_hash, this.o.user.CurBox, this.jump('labelLinkListId'));
					if(user_tags.length > 0){
						var user_tags_hash = [];
						$A(user_tags).each( function(s){
							user_tags_hash.push({'Name': s, 'Tag': s, 'Count': 0});
						})
						this.FillUserTags(user_tags_hash, this.jump('spot-tags-user-tags'));
					}
					this.jump('editLabelsBlockId').hide();
					if(isError){ alert(errorText); }
				}
			}.bind(this));
		}.bind(this));
		
		
		// comments pages 
		this.jump('spot-com-next').observe('click', function(){ this.replaceComments(this.o.comments.pages.next_page); }.bind(this));
		this.jump('spot-com-pnext').observe('click', function(){ this.replaceComments(this.o.comments.pages.next_list); }.bind(this));
		this.jump('spot-com-prev').observe('click', function(){ this.replaceComments(this.o.comments.pages.prev_page); }.bind(this));
		this.jump('spot-com-pprev').observe('click', function(){ this.replaceComments(this.o.comments.pages.prev_list); }.bind(this));
		
		this.jump('spot-liked-a').observe('click', this.likedChange.bind(this));

		//voter
		$('f2_r11').observe('click', function(){ hide2x(); this.tryVote(1); }.bind(this));
		$('f2_r22').observe('click', function(){ hide2x(); this.tryVote(2); }.bind(this));
		$('f2_r33').observe('click', function(){ hide2x(); this.tryVote(3); }.bind(this));
		$('f2_r44').observe('click', function(){ hide2x(); this.tryVote(4); }.bind(this));
		$('f2_r55').observe('click', function(){ hide2x(); this.tryVote(5); }.bind(this));
		
		
		// capcha window
		this.jump('spot-capcha-close').observe('click', function(){
			this.jump('for_capcha').hide();
		}.bind(this));
		
		this.jump('spot-vote-capcha-refresh').observe('click', function(){ this.refreshCapcha(this.vote_mark); }.bind(this));
		this.jump('spot-vote-capcha-refresh2').observe('click', function(){ this.refreshCapcha(this.vote_mark); }.bind(this));
		
		this.jump('spot-vote-capcha-send').observe('click', function(){
			this.sendCapcha();
		}.bind(this));
		
		this.jump('spot-votes-ax2').observe('click', function(e){
			var __el = Event.element(e);
			InfoBlock.show('SmsBox', e, __el, 'smsgame', 'abs', 5, 0, false, '','x2');
		}.bindAsEventListener(this));
		
		//Awards
		
		[this.jump('spot-aw-aavg1'), this.jump('spot-aw-aavg2'), this.jump('spot-aw-aavg3')].each( function(s, i){
			s.observe('click', function(e, _i){
				var __i = _i + 3;
				awardHelp(e, s, __i, '', '', this.o.foto.image_AvgMark);
			}.bindAsEventListener(this, i));
		}.bind(this));
		
		//megavoters
		this.jump('MegaVoteIco')
			.observe('mouseover', function(){
				megavoters.get();
			}.bind(this))
			.observe('mouseout', function(){
				megavoters.hide();
			}.bind(this));
			
			
			
		//this.jump('spot-image-main-link').onclick = this.spotNext.bindAsEventListener(this);
		//this.jump('spot-image-next').onclick = this.spotNext.bindAsEventListener(this);
		//this.jump('spot-image-prev').onclick = this.spotGo.bindAsEventListener(this);
		//$$('a.fl-a1, a.fl-a2').each( function(s){
		//	s.onclick = this.spotGo.bindAsEventListener(this);
		//}.bind(this));
			
		//miss
		['spot-fc-banner-close-miss', 'spot-fc-banner-link-miss'].each( function(s){
			$(s).observe('click', function(){
				if(this.jump('Banner_flag').style.display == 'none'){
					this.jump('Banner_link').addClassName('on');
					this.jump('Banner_flag').show();
				} else {
					this.jump('Banner_link').removeClassName('on');
					this.jump('Banner_flag').hide();
				}
			}.bind(this));
		}.bind(this));
		
		this.jump('crop_bound')
			.observe('mouseover', this.arrItemsShow.bind(this))
			.observe('mouseout', this.arrItemsHide.bind(this));
		
		//ads irame
	}                                                    
	
	this.fotoId = function(){
		return this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '/';
	}
	
	
	this.tryVote = function(mark){
		if(this.voted[this.fotoId()]){ alert(this.fotoId()); return; }
		if (this.o.album.OwnAlbum && this.o.ExtFoto == false) { alert('Вы не можете голосовать за собственное фото'); return; }
		this.vote_mark = mark;
		if(this.o.foto.VoteNeedCapcha){
			this.refreshCapcha();
		} else {
			this.addVote('');
		}
	}
	
	this.refreshCapcha = function(){
		ajax_call('perl_get_capcha_id',this.vote_mark,function(st,id){
			if (st == 1) {
				this.vote_capcha_id = id;
				this.jump('img_for_capcha').writeAttribute('src', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/get_image_photo?id=' + this.vote_capcha_id);
				this.jump('for_capcha').show();
				this.jump('security_image_answer').focus();
				document.body.observe('click', function(){
					this.cleanCapcha();
					document.body.stopObserving('click');
				}.bind(this));
			} else {
				alert ('Не удалось сформировать картинку. Повторите пожалуйста ваш выбор.');
			}	  		
		}.bind(this));
	}
	
	this.addVote = function(__answer){
		if(!__answer){ __answer = ''; }
		ajax_call('perl_add_vote', this.vote_mark, this.o.foto.id, this.o.album.id, this.vote_capcha_id, __answer, function(st, newrating, votescount, errorcode, errortext){
			if (st == 1) {
				this.voted[this.fotoId()] = 'Вы уже голосовали за фото';
				this.o.foto.image_Rate = newrating;
				this.o.foto.image_Votes = votescount;
				this._write('ratingBlock');
				this.cleanCapcha();
				this.setVoteMessage('Спасибо, ваш голос принят');
			} else {
				if (errorcode==2) {
					this.voted[this.fotoId()] = 'Вы уже голосовали за фото';
					this.cleanCapcha();
					this.setVoteMessage('Вы уже голосовали за фото');
				}else if (errorcode==3) {
					alert('Неверно введён код защиты!');
					this.refreshCapcha();
				}else if (errorcode==4){
					this.voted[this.fotoId()] = 'Проголосовать не получилось';
					this.cleanCapcha();
					this.setVoteMessage('Проголосовать не получилось');
				}else if (errorcode==9){
					this.cleanCapcha();
					this.setVoteMessage(errortext);
				}else{
					this.voted[this.fotoId()] = 'Проголосовать не получилось';
					this.cleanCapcha();
					this.setVoteMessage('Проголосовать не получилось');
				}
			}
		}.bind(this));
	}
	
	this.sendCapcha = function(){
		var __answer = this.jump('security_image_answer').getValue();
		this.addVote(__answer);
	}
	
	this.cleanCapcha = function(){
		this.jump('for_capcha').hide();
		this.vote_mark = '';
		this.vote_capcha_id = '';
		this.jump('security_image_answer').setValue('');
		this.jump('img_for_capcha').writeAttribute('src', 'http://img.imgsmail.ru/0.gif');
	}
	
	this.setVoteMessage = function(m){
		this.jump('image_Rate_Vote_Access').hide();
		this.jump('vote_message').update(m).show();
	}

	this.likedChange = function(){
		if(this.jump('spot-fotoliked-line').readAttribute('shown') == '0'){
			if(this.f2inited){
				this.jump('spot-fotoliked-line')
					.writeAttribute('shown', '1')
					.show();
			} else {
				ajax_call_nologin('perl_load_similar',this.o.foto.id,function(arr){
					var _a = [];
					var _d = {};
					arr.each( function(s){
						var _imgId = '/' + s.ImgBox + '/' + s.ImgID + '/';
						_a.push(_imgId);
						_d[_imgId] = {
							'UrlHtml'	:	'/' + s.ImgBox + '/' + s.ImgID + '.html',
							'ImgId'		:	s.ImgID,
							'Title'		:	s.Title,
							'UrlJpg'	:	'/' + s.ImgBox + '/' + 'p-' + s.ImgID + '.jpg',
							'megaVote'	:	0
						}
					}.bind(this));
					this.fl2.fillData(_a, _d, '');
					this.f2inited = true;
					this.jump('spot-fotoliked-line').writeAttribute('shown', 1).show();
				}.bind(this));
			}
		} else {
			this.jump('spot-fotoliked-line')
				.writeAttribute('shown', '0')
				.hide();
		}
	}
	
	this.rewriteFull = function(){
		if(window['PhotoEmail']){ PhotoEmail = this.o.user.email; }
		this._timeInterval('render');
		this._write('foto');
		this._write('loginform');
		this._write('counters_top');
		this._write('other');
		this._write('fub');
		this._write('mainmenu');
		this._write('photoinfo1');
		this._wpt();
		this._write('otheralbums');
		this._write('comments');
		this._write('comments_control');
		this._write('likedalbums');
		this._write('ratingBlock');
		this._write('mrim');
		this._write('wanttalk');
		this._write('prevline');
		try{ this._ads2(); } catch(e) {}
		this._write('counters_bottom');
		if(this.o.i.YLoad == true){ this._write('Y'); }
		this._timeInterval('render');
		this._renderTime();
		this.jump('centralImgId').show();
	}

	this.rewriteSimple = function(){
		if(window['PhotoEmail']){ PhotoEmail = this.o.user.email; }
		this._timeInterval('render');
		this._write('foto');
		this._write('loginform');
		this._write('counters_top');
		this._write('other');
		this._write('fub');
		this._write('mainmenu');
		this._write('photoinfo1');
		this._wpt();
		this._write('comments');
		this._write('comments_control');
		this._write('likedalbums');
		this._write('ratingBlock');
		this._write('mrim');
		this._write('wanttalk');
		try{ this._ads2(); } catch(e) {}
		this._write('counters_bottom');
		if(this.o.i.YLoad == true){ this._write('Y'); }
		this._timeInterval('render');
		this._renderTime();
		this.jump('centralImgId').show();
	}

	this.fetchBanners = function() { 
		var re = /banner=\"(\d*)\"/, arr;
		this._banners = [];
		this._banners_obj = {};
		for(var i = 0; i < this._spot_banners.length; i++) { 
			if (re.test(this._spot_banners[i]))  { //alert(this._spot_banners[i]);
				arr = re.exec(this._spot_banners[i]);
				var idx = arr[1]; 
				this._banners_obj[idx] = this._spot_banners[i].strip();
				this._banners.push(idx);
			}
				
		}
	}
	
	this.createBannerSlots = function(){
		$('spot-slot-1').innerHTML = '';
		this._banners.each( function(s){
			var __d = new Element('div', {'id': 'banner_container_' + s, 'class' : 'slot_left'});
			$('spot-slot-1').appendChild(__d);
		}.bind(this));
	}

	this.getBanner = function(idx){
		return spot._banners_obj[idx];
	}

	this.bannerContent = {}
	this.moveBannerIE = function(idx) {
		var bc = spot.bannerContent[idx];
		if(!bc || !bc.length) return;
		
		var flashvars = bc.match(/flashvars\=\"([^\"]+)\"/);
		if(flashvars) flashvars = flashvars[1];
		if(flashvars) {
			bc = bc.replace(/NAME=\"FlashVars\" VALUE=\"/, 'name="FlashVars" value="' + flashvars);
		}
		$('banner_container_' + idx).innerHTML += bc;
	}

		
	this.showBanner = function(idx){
		var _bc = $('banner_container_'+idx);
		var _pb = $('pre_banner_'+idx); 
		if(_bc && _pb){
			_bc.appendChild(_pb);
		}
	}
	
	this.execScript = function(idx) { 
		switch(idx) {
			case 9999 : this.getMrims(); break;
		}
	}
	
	this._ads2 = function(){
		this._timeInterval('banners');
		var sdd = $('spot-direct-div');
		if(sdd && 1 == 0){
			var sd = '<iframe width="728" border="0" frameborder="0" marginwidth="0" marginheight="0" src="' + 'http://' + this.o.PhotoPerlHost + '/catalog/static/spot_direct.html?r=' + Math.random() + '&rp=http://' + this.o.PhotoPerlHost + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html' + '"></iframe>';
			sdd.innerHTML = '';
			ssd.insert(sd);
			sd = $(ssd.lastChild);
			sd.observe('load', function(){
				try{
					sd.style.height = (sd.contentWindow.document.body.scrollHeight + 50) + 'px';
				} catch(e){}
			}.bind(this));
		}
				
		$$('iframe.spot-remove-me').each( function(s){ s.remove(); });
		this.fetchBanners();
		this.createBannerSlots();
		this._banners.each(function(s){
				
			var idx = s;

			if(Prototype.Browser.IE){
			var jssrc = "javascript:{document.write('<scr" + "ipt>" +
				"window.onload = function() { try{" +
				"	if(document && document.body) { parent.spot.bannerContent[" + idx + "] = document.body.innerHTML;"+
				"		parent.spot.moveBannerIE("+idx+");" +
				//"		parent.spot.showBanner("+idx +");" +
				"	};"+
				"} catch(e){}};" +
				"document.domain=\\\"mail.ru\\\";" +
				"document.write(parent.spot.getBanner("+idx+"));" +
				"</scr"+"ipt>');document.close();};";

			} else {
			
			var jssrc = "javascript:{document.write('<scr" + "ipt>" +
				"window.onload = function() {try{" +
				"	var h = document.getElementsByTagName(\\\"head\\\")[0];" +
				"	if (h){"+
				"		var ta = h.getElementsByTagName(\\\"*\\\");"+
				"		if(ta.length>0){"+
				"			for(var i = 0; i < ta.length; i++){"+
				"				if(ta[i].tagName == \\\"SCRIPT\\\"){"+
				//"					try{if(ta[i].getAttribute(\\\"src\\\") != \\\"\\\") {var _s = parent.document.createElement(\\\"SCRIPT\\\"); _s.setAttribute(\\\"src\\\",ta[i].getAttribute(\\\"src\\\")); parent.document.body.appendChild(_s);}}catch(e){};"+
				//"					parent.document.body.appendChild(ta[i]);"+
				"				}"+
				"				if (ta[i].tagName == \\\"STYLE\\\"){"+
				"					parent.document.getElementById(\\\"banner_container_"+idx+"\\\").appendChild(ta[i]);"+
				"				}"+
				"			}"+
				"		}"+
				"	};"+
				"	if(document && document.body) { while(document.body) {" +
				"		parent.document.getElementById(\\\"banner_container_"+idx+"\\\").appendChild(document.body.firstChild);}" +
				//"		parent.spot.showBanner("+idx +");" +
				"	};"+
				"} catch(e){}};" +
				"document.domain=\\\"mail.ru\\\";" +
				"document.write(parent.spot.getBanner("+idx+"));" +
				"</scr"+"ipt>');document.close();};";
			}
				
			var iframe = new Element('iframe').addClassName('spot-remove-me');
		
			iframe.style.display = 'none';
			iframe.id = 'banner_frame_' + idx;
			iframe.src = jssrc;
			document.body.appendChild(iframe);
		}.bind(this));
		
		this._timeInterval('banners');
		
	}

	this.cacheBlocks = function(){
		var toCache = $$('.s-cc');
        for(var cIdx = 0, cLen = toCache.length; cIdx < cLen; ++cIdx){
			var sccItem = toCache[cIdx];
			if(this.b[sccItem.readAttribute('id')]){ 
			//alert('cache failed, duplicate item: ' + sccItem.readAttribute('id')); 
			}
			this.b[sccItem.readAttribute('id')] = $(sccItem);
        }
    }
	
	this.arrItemsShow = function(){
		if(this.arrItemShown == false){
			if(typeof this.arrArray == 'object'){
			this.arrArray.each( function(s){
				this.arrItems[s].o.addClassName('pers_shown');
				this.arrItems[s].o.removeClassName('pers_over');
			}.bind(this));
			}
		}
	}
	
	this.arrItemsHide = function(){
	        if(typeof this.arrArray == 'object'){
		this.arrArray.each( function(s){
			this.arrItems[s].o.removeClassName('pers_shown');
			if(this.arrItemShown != s){ this.arrItems[s].o.removeClassName('pers_over'); }
		}.bind(this));
		}
	}
	
	this.arrItemHide = function(ssid){
		this.arrItemShown = '';
		var ssidItem = $('pers_' + ssid);
		if(ssidItem){
			ssidItem.removeClassName('pers_shown');
			ssidItem.removeClassName('pers_over');
		}
	}
				
	this.arrItemShow = function(ssid){
		this.arrItemShown = ssid;
		this.arrItemsHide();
		var ssidItem = $('pers_' + ssid);
		if(ssidItem){
			ssidItem.addClassName('pers_shown');
			ssidItem.addClassName('pers_over');
		}
		var ssidTxt = ssidItem.select('div.box_txt')[0];
		if(ssidTxt.style.width != ''){
		} else {
			if(ssidItem.getWidth() < ssidTxt.getWidth()){
				ssidTxt.style.width = 'auto';
				var _of = Math.round((ssidTxt.getWidth() - ssidItem.getWidth()) / 2);
				ssidTxt.style.left = '-' + _of + 'px';
			} else {
				ssidTxt.style.width = parseInt(ssidItem.getWidth()) + 'px';
			}
			if(ssidItem.getHeight() + ssidItem.positionedOffset()[1]  > (this.jump('crop_bound').getHeight() - 10)){
				ssidTxt.style.bottom = parseInt(ssidItem.getHeight() - 2) + 'px';
			}
		}
	}
	
    this._writePersons = function(){
		this.jump('crop_bound').select('div.allocation').each( function(s){ s.remove(); });
		var sp = this.o.person; 
		this.arrItems = new Object();
		this.arrArray = new Array();
		this.arrItemShown = false;
		for(sx in sp){
			var sitem = sp[sx];
			if(!sitem['SID']) sitem['SID'] = sitem['PID']; 
			var div1 = new Element('div', {'id': 'pers_' + sitem['SID']})
				.addClassName('allocation')
				.setStyle({'top': sitem['top'] + 'px', 'left': sitem['left'] + 'px', 'width': sitem['width'] + 'px', 'display': 'block'})
				.observe('mouseover', this.arrItemShow.bind(this, sitem['SID']))
				.observe('mouseout', this.arrItemHide.bind(this, sitem['SID']));
				
			var div2 = new Element('div', {'id': 'pers_' + sitem['SID'] + '_pic'})
				.addClassName('pic')
				.setStyle({'width': sitem['width'] + 'px', 'height': sitem['height'] + 'px' })
				
			var img1 = new Element('img', {'src': 'http://img.imgsmail.ru/0.gif', 'width': sitem['width'], 'height': sitem['height'], 'alt': ''});
			if(sitem['id'] && sitem['id'] != 0){
				var a1 = new Element('a', {'href': 'http://' + this.o.PhotoPerlHost + sitem['dir'], 'target': '_blank'});
				a1.appendChild(img1);
				div2.appendChild(a1);
			} else {
				div2.appendChild(img1);
			}
			var div3 = new Element('div', {'id': 'pers_' + sitem['SID'] + '_txt'})
				.addClassName('box_txt');
				
			var div4 = new Element('div', {'align': 'center'})
				.addClassName('txt')
				.setStyle({'top': sitem['height'] + 'px'});
				
			if(sitem['id'] && sitem['id'] != 0){
				var a2 = new Element('a', {'href': 'http://' + this.o.PhotoPerlHost + sitem['dir']}).update(sitem['nickname']);
				div4.appendChild(a2);
			} else {
			    var span2 = new Element('span').update(sitem['nickname']);
				div4.appendChild(span2);
			}
			div3.appendChild(div4);
			div1.appendChild(div2);
			div1.appendChild(div3);
			
			if(this.o.album.OwnAlbum == true){
			var pd = new Element('img', {'src': 'http://img.imgsmail.ru/r/foto2/pers_delete.gif'})
				.setStyle({'position': 'absolute', 'top': '2px', 'right': '1px'})
				.addClassName('pers_delete')
				.observe('click', function(sp, ss){
					if (!ss || typeof ss == "undefined") ss = sp;
					if(confirm('Удалить отмеченного друга?')) {
						if (this.o.ExtFoto && (sitem['email'] == this.o.auser.email)) {
							ajax_call('perl_delete_person',this.o.album.id,this.o.foto.id,'',ss,function(){
								this.spotNext();
							}.bind(this));
						} else {
							ajax_call('perl_delete_person',this.o.album.id,this.o.foto.id,'',ss,function(id,error){
								if(!id){alert(error);}
								$('pers_' + id).parentNode.removeChild($('pers_' + id));
								$('span_' + id).parentNode.removeChild($('span_' + id));
								person_Items--;
								if (person_Items <= 0) {
									$('AlbumName_listNames').style.display = 'none';
									$('div_mb_person').style.display = 'none';
			}
							}.bind(this));
		}
	}
				}.bind(this, sitem['PID'], sitem['SID']));				

			div1.appendChild(pd);
			}
			
	
			this.jump('crop_bound').appendChild(div1);
					
			var __id = 'pers_' + sitem['SID'];
					
			this.arrArray.push(__id);
					
			this.arrItems[__id] = {
				'o': div1,
				'p': div2,
				't': div3,
				'w': div1.getWidth(),
				'h': div1.getHeight(),
				's': div1.offsetWidth * div1.offsetHeight,
				'z': Math.round(Math.sqrt(360000) - Math.sqrt(div1.offsetWidth * div1.offsetHeight))
						}
					}
					
					
				}

	this._Y = function(id){var __y = $(id);if(__y){return __y;} else {return document.createElement('span');}}
	this._write = function(b){
	
		switch(b){
		        case 'Y':
		                this._Y('Y_ActiveFriendsOnlineCount').innerHTML = this.o.i.ActiveFriendsOnlineCount;
		                if(this.o.i.ActiveFriendsCounter){
		                	var _y1 = '<a type="booster" href="http://' + this.o.MyMailHost + '/my/friends';
		                	_y1 += (this.o.i.ActiveFriendsRequest) ? '_requests' : '-suggest';
		                	_y1 += '" class="mf_menu2 booster-sc">' + this.o.i.ActiveFriendsCounter + '</a>';
		                } else {
		                	var _y1 = '<span class="mf_menu2a"> - </span>'
		                }
				this._Y('Y_ActiveFriendsCounter').innerHTML = _y1;
				this._Y('Y_ActiveFriendsCount').innerHTML = this.o.i.ActiveFriendsCount;
				if(this.o.i.DialoguesUnread){
					var _y2 = '<a type="booster" href="http://' + this.o.MyMailHost + '/dialogues" class="mf_menu2 booster-sc">' + this.o.i.DialoguesUnread + '</a>';
				} else {
					var _y2 = '<span class="mf_menu2a"> - </span>';
				}
				this._Y('Y_DialoguesUnread').innerHTML = _y2;
				this._Y('Y_ActiveDialoguesCount').innerHTML = this.o.i.ActiveDialoguesCount;
				if(this.o.i.ActiveGuestCount){
				    	if(this.o.i.ActiveGuestCountMoreThen200){
				    		this._Y('Y_ActiveGuestCount').innerHTML = '200+';
				    	} else {
				    		this._Y('Y_ActiveGuestCount').innerHTML = this.o.i.ActiveGuestCount;
				    	}
				} else {
					this._Y('Y_ActiveGuestCount').innerHTML = '0';
				}
				if(this.o.i.ActiveGiftsUnreadCount){
					this._Y('Y_ActiveGiftsUnreadCount').innerHTML = '<a type="booster" href="http://' + this.o.MyMailHost + '/my/gifts" class="booster-sc mf_menu2">' + this.o.i.ActiveGiftsUnreadCount + '</a>'
				} else {
					this._Y('Y_ActiveGiftsUnreadCount').innerHTML = '<span class="mf_menu2a"> - </span>';
				}
				if(this.o.i.ActiveGiftsCount){
					this._Y('Y_ActiveGiftsCount').innerHTML = this.o.i.ActiveGiftsCount;
				} else {
					this._Y('Y_ActiveGiftsCount').innerHTML = '0';
				}
				this._Y('Y_CommunityInvitationCount').innerHTML = (this.o.i.CommunityInvitationCount) ? '<a href="http://' + this.o.MyMailHost + '/my/communities?invites" class="mf_menu2">' + this.o.i.CommunityInvitationCount + '</a>' : '<span class="mf_menu2a"> - </span>';
				this._Y('Y_ActiveCommunityCount').innerHTML = this.o.i.ActiveCommunityCount;
				this._Y('Y_ActiveAudioCount').innerHTML = this.o.i.ActiveAudioCount;
				this._Y('Y_ActiveFavoriteCount').innerHTML = this.o.i.ActiveFavoriteCount;
				this._Y('Y_UserApplicationsNotifyCount').innerHTML = (this.o.i.UserApplicationsNotifyCount) ? '<a href="http://' + this.o.MyMailHost + '/cgi-bin/app/notified" class="mf_menu2">' + this.o.i.UserApplicationsNotifyCount + '</a>' : '<span class="mf_menu2a"> - </span>';
				this._Y('Y_UserApplicationsCount').innerHTML = this.o.i.UserApplicationsCount;
		                this._Y('Y_ActiveMyFotoCount').innerHTML = this.o.i.ActiveMyFotoCount;
		        	break;
			case 'loginform':
				if(this.o.auser.id != ''){
					// AUTH
					this.jump('f2_41').show();
					this.jump('f2_49').update(this.o.auser.email);
					this.jump('spot-login-button').hide();
					
					//left
					$('spot-left-login').hide();
					
					if(this.o.NoMyCreated == true){ $('spot-my1').show(); } else { $('spot-my1').hide(); } 
					$('spot-my2').show();
					
					if(this.o.auser.WebAgentEnabled == true && this.o.auser.RegInfoLogin == false){
						if(typeof window['onWaReady'] == 'undefined'){
							webagentTurnOn();
							window.onWaReady('html');
						}
					}
					
				} else {
					// UNAUTH
					this.jump('f2_41').hide();
					this.jump('f2_49').update('');
					this.jump('spot-login-button').show();
					
					//left
					$('spot-left-login').show();

					$('spot-my1').hide();
					$('spot-my2').hide();
				}
				this.jump('spot-login-page').writeAttribute('value', document.URL);
				
				
				
				break;		
			case 'counters_top':
				this.jump('spot-top-counters').innerHTML = '';
				var tnsurl = "http://www.tns-counter.ru/V13a****mail_ru/ru/CP1251/tmsec=mail_foto-other/";
				var tnsimg = new Element('img', {'width': 1, 'height': 1, 'alt': '', 'src': tnsurl});
				this.jump('spot-top-counters').appendChild(tnsimg);
				break;
			
			case 'counters_bottom':
				this.jump('spot-bottom-counters').innerHTML = '';
				
				var liurl = 'http://counter.yadro.ru/hit?r'+
						escape(this.prevUrl)+((typeof(screen)=="undefined")?"":
						";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
						screen.colorDepth:screen.pixelDepth))+";u"+escape(this.currUrl)+
						";"+Math.random();

				var liimg = new Element('img', {'src': liurl, 'width': 1, 'height': 1, alt: ''});

				this.jump('spot-bottom-counters').appendChild(liimg);
				
				var top_js = 13;
				var top_a = ';r='+escape(this.prevUrl)+';j='+navigator.javaEnabled()+
					';s='+screen.width+'*'+screen.height+
					';d='+(screen.colorDepth?screen.colorDepth:screen.pixelDepth);
				var top_url = 'http://top3.mail.ru/counter'+'?id=865542;js='+top_js+top_a+';rand='+Math.random();
				var top_img = new Element('img', {'width': 1, 'height': 1, 'alt': '', 'src': top_url});
				this.jump('spot-bottom-counters').appendChild(top_img);
				break;
		
		
            case 'other':
				// Auth forms back
				// Left form
				var login1 = $('spot-login1-back');
				if(login1){ $('spot-login1-back').setValue('http://' + this.o.PhotoImagineHost + '/spot#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html'); }
				var login2 = $$('div#f2_loginform_new input[name=page]');
				if(login2 && login2.length && login2.length == 1){
					login2 = login2[0];
					login2.setValue('http://' + this.o.PhotoImagineHost + '/spot#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html');
				}
				
				if(this.o.foto.title_Exists){
					document.title = 'Фото@Mail.ru: ' + this.o.user.fio + ' : ' + this.o.foto.title;
					try{ pAlert.title = 'Фото@Mail.ru: ' + this.o.user.fio + ' : ' + this.o.foto.title; } catch(e) {}
				} else {
					document.title = 'Фото@Mail.ru: ' + this.o.user.fio;
					try{ pAlert.title = 'Фото@Mail.ru: ' + this.o.user.fio; } catch(e) {}
				}
				
				//miss
				
				if(this.o.foto.contestId == 279){
					$('f2_blueheader').hide();
					$$('p.f2_top')[0].hide();
					$$('p.f2_bottom')[0].hide();
					$('spot-miss2009').show();
				} else {
					$('spot-miss2009').hide();
					$('f2_blueheader').show();
					$$('p.f2_top')[0].show();
					$$('p.f2_bottom')[0].show();
				}
				
				//You selected link on _myphoto
				if(this.o.album.OwnAlbum && this.o.album.id == '_myphoto' && this.o.auser.FotoMyCnt != "") {
					this.jump('spot-you-selected').show();
					this.jump('spot-you-selected-a')
						.update("Вы отмечены на " + this.o.auser.FotoMyCnt + " фото")
						.writeAttribute("href", location.protocol + '//' + location.host + this.o.auser.ActiveBox + "_myface");
				}else {
					this.jump('spot-you-selected').hide();
				}

				try{ pAlert.alertID = ''; pAlert.listen(); } catch(e) {}
				
				break;

			case 'fub':
				this.jump('spot-avatar-link').writeAttribute('href', this.o.user.CurBox);
                this.jump('spot-avatar-image').setStyle({'backgroundImage':	'url(http://' + this.o.PhotoAvtHost + this.o.user.CurBox + '_avatarsmall)'});
                this.jump('spot-user-dog-link').writeAttribute('href', 'http://www.mail.ru/agent?message&to=' + this.o.user.email);
				
				this.jump('spot-user-dog').writeAttribute('email', this.o.user.email);
                this.jump('spot-user-name-link')
                    .writeAttribute('href', 'http://' + this.o.MyMailHost + this.o.user.CurBox)
					.update(this.o.user.fio);
                

				if(this.o.user.MyMailOnline == true){
					this.jump('spot-ghost-span-invisible').hide();
					this.jump('spot-ghost-span-online-link').writeAttribute('href', 'http://' + this.o.MyMailHost + '/my/dialogues?thread=' + this.o.user.email);
					this.jump('spot-ghost-span-online').show();
				} else {
					this.jump('spot-ghost-span-invisible').hide();
					this.jump('spot-ghost-span-online').hide();
					this.jump('spot-ghost-span-invisible-link').writeAttribute('href', 'javascript:void(0)');
					this.jump('spot-ghost-span-online-link').writeAttribute('href', 'javascript:void(0)');
				}
                                
				
				this.jump('spot-nav-ui').writeAttribute('href', this.o.user.CurBox);
				this.jump('spot-nav-album').writeAttribute('href', this.o.user.CurBox + this.o.album.id).update((this.o.album.title != false) ? this.o.album.title : 'Без названия');
				this.jump('spot-nav-image').update(this.o.foto.title).show();
				this.jump('spot-nav-image-edit').hide();

				if(this.o.album.OwnAlbum && !this.o.ExtFoto){
				    this.jump('spot-nav-image')
						.addClassName('spot-editable')
						.observe('click', spot.editTitle.bindAsEventListener(this));
				} else {
				    this.jump('spot-nav-image')
						.removeClassName('spot-editable')
						.stopObserving('click');
				}
				
				if(this.o.album.id == '_favorites'){
				    this.jump('spot-nav-album-fav-link').writeAttribute('href', 'http://' + this.o.PhotoImagineHost + '/' + this.o.foto.FavPath + '/' + this.o.foto.FavID + '.html');
					this.jump('spot-nav-album-fav').show();
				} else {
					this.jump('spot-nav-album-fav-link').writeAttribute('href', 'javascript:void(0)');
					this.jump('spot-nav-album-fav').hide();
				}

				if(this.o.ExtFoto == true){
				    this.jump('spot-ext-author-email').writeAttribute('href', 'http://www.mail.ru/agent?message&amp;to=' + this.o.foto.ExtEmail);
					this.jump('spot-ext-author-status').writeAttribute('email', this.o.foto.ExtEmail);
					this.jump('spot-ext-author-name').writeAttribute('href', 'http://' + this.o.PhotoImagineHost + this.o.foto.ExtCurBox);
					this.jump('spot-ext-author-name').innerHTML = this.o.foto.FIO ? this.o.foto.FIO : 'Автор оригинального фото';
					this.jump('spot-ext-author').show();
				} else {
					//this.jump('spot-nav-album-fav-link').writeAttribute('href', 'javascript:void(0)');
					this.jump('spot-ext-author').hide();
				}

				if(this.o.album.OwnAlbum && this.o.album.id != '_favorites'){
				        this.jump('spot-fub-add-link').writeAttribute('href', '/cgi-bin/photo/addphoto?album=' + this.o.album.id);
					this.jump('spot-fub-add-li').show();
				} else {
				        this.jump('spot-fub-add-link').writeAttribute('href', 'javascript:void(0)');
					this.jump('spot-fub-add-li').hide();
				}
				if(this.o.album.OwnAlbum && !this.o.ExtFoto && this.o.album.id != '_favorites'){
					this.jump('spot-fub-edit-li').show();
					this.jump('spot-fub-edit-link')
						.writeAttribute('href', '/cgi-bin/photo/editphoto?id=' + this.o.foto.id + '&album=' + this.o.album.id + '&user=' + this.o.user.email);
					this.jump('spot-fub-delete-li').show();
					this.jump('spot-fub-delete-link').observe('click', function(){
						var __c = confirm('Вы действительно хотите удалить это фото?');

						if(__c){
							var __u = '/cgi-bin/photo/editphoto?delete=1&album=' + this.o.album.id + '&id=' + this.o.foto.id;
							if(this.o.auser.PhotoModerator || this.o.auser.mega_admin){
								__u += '&user=' + this.o.user.PhotoUser + '&domain=' + this.o.user.PhotoDomain;
							}
							document.location.href = __u;
						}
					}.bind(this));
					
					this.jump('spot-fub-complain-li').hide();
					this.jump('spot-fub-complain-link').stopObserving('click');
				} else {
					this.jump('spot-fub-edit-li').hide();
					this.jump('spot-fub-edit-link').writeAttribute('href', 'javascript:void(0)');
					this.jump('spot-fub-delete-li').hide();
					this.jump('spot-fub-delete-link').stopObserving('click');;
					if(!this.o.user.community && this.o.album.id != '_favorites'){
						this.jump('spot-fub-complain-li').show();
						this.jump('spot-fub-complain-link')
							.observe('click', function(){
								ajax_call('perl_photo_complain', this.o.foto.id, function(arr){
									if(arr[0] == 0){
										alert(arr[1]);
									} else {
										//alert("Спасибо, ваша жалоба будет рассмотрена модераторами в ближайшее время.");
										this.jump('spot-fub-complain-li').hide();
									}
								}.bind(this));
							}.bind(this));
					} else {
						this.jump('spot-fub-complain-li').hide();
						this.jump('spot-fub-complain-link').stopObserving('click');
					}
				}
				this.jump('spot-fub-root').show();
                break;
			case 'foto':

				this.jump('centralImgId')
					.writeAttribute('src', this.o.foto.jpg)
					.observe('load', function(e){
						this.report['imageLoaded'] = 1;
						if(this.reportSent == true && this.afterSent == false){
							spotOnError('Image loaded after 500 sent.', this.reportLog('a'), this.srnd);
							this.afterSent = true;
						}
						var __img = Event.element(e);
						__img.show();
						
						this.hideAjaxLoad();
						this.jump('centralImgId').stopObserving('load');
					}.bindAsEventListener(this));
					
				/*
				if(typeof this.fImg == 'undefined'){
					this.fImg = true;
					this.jump('centralImgId')
						.setStyle({'width': this.o.foto.width + 'px', 'height': this.o.foto.height + 'px'})
						.writeAttribute('width', this.o.foto.width)
						.writeAttribute('height', this.o.foto.height).show();
				
				
				}
				*/
				this.hideAjaxLoad();
				if(this.o.foto.prev_image != false){
					this.jump('spot-image-prev').writeAttribute('href', '#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.prev_image + '.html').show();
				} else {
					this.jump('spot-image-prev').writeAttribute('href', 'javascript:void(0)').hide();
				}
				this.jump('spot-image-prev').setStyle({'height': this.o.foto.height + 'px', 'cursor': 'pointer'});
				this.jump('spot-image-next').setStyle({'height': this.o.foto.height + 'px', 'cursor': 'pointer'});
				this.jump('crop_bound').setStyle({'width': this.o.foto.width + 'px', 'height': this.o.foto.height + 'px'});

				if(this.o.foto.next_image != false){
					this.jump('spot-image-main-link').writeAttribute('href', '#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.next_image + '.html');
					this.jump('spot-image-next').writeAttribute('href', '#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.next_image + '.html').show();
				} else {
					this.jump('spot-image-main-link').writeAttribute('href', this.o.user.CurBox + this.o.album.id);
					this.jump('spot-image-next').writeAttribute('href', 'javascript:void(0)').hide();
				}
				this._writePersons();
				//positionBorderFriends();
				
				if(this.o.foto.width){
					this.jump('LeftMenu').setStyle({'left': this.o.foto.width + 'px'});
				} else {
					this.jump('LeftMenu').setStyle({'left': '600px'});
				
				}
				
				this.resetStyle();
				
				//megavoters
				
				if(this.o.foto.image_DoubleVotes > 0){
					if(this.o.foto.width > 0){
						this.jump('MegaVoteIco').setStyle({'left': this.o.foto.width + 'px'});
					} else {
						this.jump('MegaVoteIco').setStyle({'left': '600px'});
					}
					this.jump('MegaVoteIco').show();
					if(megavoters.inited) megavoters.remove();
					if (this.o.ExtFoto) 
						megavoters.init(this.o.foto.ExtID, this.o.auser.id, this.o.user.CurBox);
					else 
						megavoters.init(this.o.foto.id, this.o.auser.id, this.o.user.CurBox);
				} else {
					this.jump('MegaVoteIco').hide();
					this.jump('MegaVoters').update('');
				}
								
				// Left menu
				if(this.o.foto.image_DoubleVotes > 0){
					this.jump('LeftMenu').setStyle({'marginTop': '80px'});
				} else {
					this.jump('LeftMenu').setStyle({'marginTop': '0px'});
				}
				
				this.jump('LeftMenu').show();
				if(this.o.exif.make || this.o.exif.model){
					this.jump('spot-leftmenu-exif').show();
				} else {
					this.jump('spot-leftmenu-exif').hide();
				}
				exif_info = Object.clone(this.o.exif);
				
				//ssize
				if(this.o.foto.image_SSize && this.o.foto.image_SWidth && (this.o.foto.width != this.o.foto.image_SWidth)){
					this.jump('spot-leftmenu-ssize-href').writeAttribute('href', 'http://' + this.o.PhotoContentHost + this.o.user.CurBox + this.o.album.id + '/s-' + this.o.foto.id + '.' + this.o.foto.image_Ext);
					if(this.o.foto.image_SWidth && this.o.foto.image_SHeight){
						this.jump('spot-leftmenu-ssize-info').update('<br /><span>' + this.o.foto.image_SWidth + '<br />&times;<br />' + this.o.foto.image_SHeight + '</span>');
					} else {
						this.jump('spot-leftmenu-ssize-info').update('');
					}
					if(this.o.foto.width == false && this.o.foto.height == false){
						this.jump('spot-leftmenu-ssize').setStyle({'height': '22px'});
					} else {
						this.jump('spot-leftmenu-ssize').setStyle({'height': ''});
					}
					this.jump('spot-leftmenu-ssize').show();
				} else {
					this.jump('spot-leftmenu-ssize').hide();
					this.jump('spot-leftmenu-ssize-href').writeAttribute('href', 'javascript:void(0)');
					this.jump('spot-leftmenu-ssize-info').update('');
				}
				
				if(this.o.album.id != '_animated' && this.o.album.id != '_animateddialog'){
					this.jump('spot-leftmenu-slide').select('a')[0].writeAttribute('href', this.o.user.CurBox + this.o.album.id + '/slideshow');
					this.jump('spot-leftmenu-slide').show();
				} else {
					this.jump('spot-leftmenu-slide').hide();
					this.jump('spot-leftmenu-slide').select('a')[0].writeAttribute('href', 'javascript:void(0)');
				}
				
				if(this.o.foto.contestId == '279'){
					$('Copyright').setStyle({'background': 'url(http://img.imgsmail.ru/r/miss2009/head.jpg) top center no-repeat'});
				} else {
					//$('Copyright').setStyle({'background': 'url(http://img.imgsmail.ru/r/foto2/f.gif) #00468c no-repeat left top'});
					$('Copyright').setStyle({'backgroundImage': ''});
				}
				
				// contest mark
				if(this.o.foto.contestId){
					
					if(this.o.foto.contestId == '279'){
						if(this.o.foto.image_ContestModerated){
							this.jump('spot-fc-nominate-miss').update('Участница конкурса').setStyle({'fontSize': '100%'});
						} else {
							this.jump('spot-fc-nominate-miss').update('Номинировано на конкурс ').setStyle({'fontSize': '100%'});
						}
						var __a = new Element('a', {'href': 'javascript:void(0)'});
						var __i = new Element('img', {'src': 'http://img.imgsmail.ru/0.gif', 'alt': ''}).addClassName('icon_help');
						__a.appendChild(__i);
						__a.observe('click', function(e){
							var __el = Event.element(e);
							addTextHint(86, this.o.foto.image_Contest);
							contextHelp(e, __el, 86);
						}.bindAsEventListener(this));

						var __url = '/contest/' + this.o.foto.image_ContestEng + '?email=' + this.o.user.email + '&itemid=' + this.o.foto.id;
						this.jump('spot-fc-curl-miss').writeAttribute('href', __url).update(this.o.foto.image_Contest);

						if(this.o.foto.image_ContestModerated){
							this.jump('spot-fc-banner-miss').show();
							this.jump('spot-fc-foto-miss').writeAttribute('src', 'http://content.foto.mail.ru' + this.o.user.CurBox + this.o.album.id + '/p-' + this.o.foto.id + '.jpg');
							this.jump('spot-fc-html-miss').setValue('<table width="240" height="60" border="0" cellpadding="0" cellspacing="0" background="http://img.imgsmail.ru/r/miss2009.gif"><tr><td width="60" align="center" valign="middle"><a href="http://foto.mail.ru' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html?contest_catalog=miss2009" target="_blank"><img width="50" height="50" border="0" alt="Мисс Интернет 2009" src="http://content.foto.mail.ru' + this.o.user.CurBox + this.o.album.id + '/p-' + this.o.foto.id + '.jpg"/></a></td><td width="180"><a href="http://foto.mail.ru' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html?contest_catalog=miss2009" target="_blank"><img src="http://img.imgsmail.ru/r/1.gif" height="60" width="180" border="0" alt="Мисс Интернет 2009" /></a></td></tr></table>');
						} else {
							this.jump('spot-fc-banner-miss').hide();
							this.jump('spot-fc-foto-miss').writeAttribute('src', 'javascript:void(0)');
							this.jump('spot-fc-html-miss').setValue('');
						}

						this.jump('flag_image_contest_miss').show();
						
					} else {
						this.jump('flag_image_contest_miss').hide();
						if(this.o.foto.image_ContestModerated){
							this.jump('spot-fc-nominate').update('Участник конкурса').setStyle({'fontSize': '100%'});
						} else {
							this.jump('spot-fc-nominate').update('Номинировано на конкурс ').setStyle({'fontSize': '100%'});
							var __a = new Element('a', {'href': 'javascript:void(0)'});
							var __i = new Element('img', {'src': 'http://img.imgsmail.ru/0.gif', 'alt': ''}).addClassName('icon_help');
							__a.appendChild(__i);
							__a.observe('click', function(e){
								var __el = Event.element(e);
								addTextHint(86, this.o.foto.image_Contest);
								contextHelp(e, __el, 86);
							}.bindAsEventListener(this));
						}
						var __url = '';
						if(this.o.foto.contestId == 148 || this.o.foto.contestId == 149 || this.o.foto.contestId == 150 || this.o.foto.contestId == 151 || this.o.foto.contestId == 152){
							var __icurl = 'http://10let.mail.ru/catalog/' + this.o.foto.image_ContestEng + '.html';
						}
						if(this.o.foto.ContestHost){
							__url = 'http://' + this.o.foto.ContestHost + '?sort=r#' + this.o.user.email + '_' + this.o.foto.id;
						} else {
							if(__icurl){ __url = __icurl; } else { __url = '/contest/' + this.o.foto.image_ContestEng + '?email=' + this.o.user.email + '&itemid=' + this.o.foto.id; }
						}
						this.jump('spot-fc-curl').writeAttribute('href', __url).update(this.o.foto.image_Contest);
						this.jump('flag_image_contest').show();
					}
				} else {
					this.jump('flag_image_contest').hide();
					this.jump('spot-fc-nominate').update('');
					this.jump('spot-fc-curl').writeAttribute('href', 'javascript:void(0)').update('');
					this.jump('flag_image_contest_miss').hide();
				}
				
				if(this.o.foto.showDayPhoto == true){
					var _top = (this.o.foto.contestId == false) ? '' : '70px';
					this.jump('flag_dp').setStyle({'top': _top});
					this.jump('flag_dp_link1').writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/dayphoto?pos=' + this.o.foto.image_DayphotoPos + '&image_id=' + this.o.foto.id + '&email=' + this.o.user.email);
					this.jump('flag_dp_cp').update(this.o.foto.dp_cps);
					this.jump('flag_dp').show();
				} else {
					this.jump('flag_dp_link1').writeAttribute('href', 'javascript:void(0)');
					this.jump('flag_dp_cp').update('');
					this.jump('flag_dp').hide();
				}
								
				break;
			case 'mainmenu':
				this.jump('spot-mm-m1').hide();
				this.jump('spot-mm-m2').hide();
				this.jump('spot-mm-m3').hide();
				this.jump('spot-mm-m4').hide();
				this.jump('spot-mm-m5').hide();
				this.jump('addin_cook').hide();
				this.jump('spot-mm-m7').hide();
				this.jump('spot-mm-m8').hide();
				this.jump('nominate_li').hide();
				this.jump('notnominate_li').hide();
				
				// write tags to fav div textarea
				this.jump('txtarForAddToFavorId').setValue(this.o.foto.PhotoTagsString);
				if(this.o.album.id != '_favorites' && this.o.album.id != '_animated' && this.o.album.id != '_animateddialog'){
					this.jump('spot-mm-m1').show();
				} else {
					this.jump('spot-mm-m1').hide();
				}
				
				// m2
				if(this.o.album.access == 2){
					this.jump('spot-mm-m2').show();
					if(this.o.auser.id && this.o.get.show_addfriend){
						this.jump('spot-mm-m2').firstDescendant().writeAttribute('id', 'link_addFriend');
						
					} else {
						this.jump('spot-mm-m2').firstDescendant().writeAttribute('id', '');
					}
					
					if(this.o.auser.id){
						this.jump('link_addFriend_li')
							.writeAttribute('href', 'javascript:void(0)')
							.addClassName('dashed');
					} else {
						this.jump('link_addFriend_li')
							.writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/login?noclear=1&page=http://' + this.o.PhotoPerlHost + '/spot/#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.spot#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html?show_addfriend=1')
							.removeClassName('dashed');
					}
					
					if(this.o.album.id != '_quarantine' && this.o.foto.themeId != '4' && this.o.foto.themeId != '35'){
						this.jump('SendCard')
							.update('')
							.show();
						
						var SendCardHtml = '<img class="spr spr_ico_postcard" src="http://img.imgsmail.ru/0.gif" alt="Отправить как открытку" title="Отправить как открытку" border="0" /><a class="sub" name="cln3065" href="http://cards.mail.ru/cardedit.html?pic=' + this.o.foto.jpg;
						if(this.o.auser.user){
							SendCardHtml += '&sendername=';
							if(this.o.auser.nick){
								SendCardHtml += this.o.auser.nick;
							} else {
								SendCardHtml += this.o.auser.email;
							}
							SendCardHtml += '&senderemail=' + this.o.auser.email;
						}
						
						SendCardHtml += '" target="_blank">Отправить как открытку</a>';
						this.jump('SendCard').update(SendCardHtml);
					} else {
						this.jump('SendCard').hide();
					}
					
				} else {
					this.jump('spot-mm-m2').hide();
				}
				
				// m3 

				// fotoPreview for html-code
				fotoPreview = '<br clear="all" style="line-height:1px;" /><div style="padding-right: 7px; padding-left: 7px; padding-bottom: 7px; padding-top: 17px;"><table cellspacing="0" cellpadding="0" class="fotopre" style="margin:20px 0"><tr><td style="padding:0"><a href="' + this.o.foto.href + '" target="_blank"><img src="' + this.o.foto.pjpg + '" width="' + this.o.foto.pwidth + '" height="' + this.o.foto.pheight + '" border="0" alt="Увеличить" /></a></td></tr><tr><td class="enlarge" style="padding:0 0 2px 0;background-color:#003B75;font-size:65%;text-align:center"><a href="' + this.o.foto.href + '" target="_blank" style="color:#FFFFFF;font-family:Tahoma">Увеличить</a></td></tr></table>Автор: <a href="http://www.mail.ru/agent?message&amp;to=' + this.o.user.email + '"><img src="http://status.mail.ru/?' + this.o.user.email + '" align="absmiddle" width="13" height="13" border="0" alt="Агент@Mail.Ru" /></a><a href="http://' + this.o.PhotoPerlHost + this.o.user.CurBox + '" target="_blank">' + this.o.user.fio + '</a><br />Альбом: <a href="http://' + this.o.PhotoPerlHost + this.o.user.CurBox + this.o.album.id + '" target="_blank">' + this.o.album.title + '</a></div>';
				this.jump('html-code').setValue(fotoPreview);
				this.jump('url-code').setValue(this.o.foto.jpg);
				this.jump('bb-code').setValue('[img=' + this.o.foto.jpg + ']');

				this.blockedAjax = 0;
				this.jump('spot-mm-m3').show();
				if(this.o.album.access == 2){
					if(this.o.foto.themeId != 4 && this.o.foto.themeId != 35){
						this.jump('spot-mm-m3-m1').show();
						if(this.o.auser.id){
							this.jump('spot-mm-m3-a1')
								.addClassName('dashed')
								.writeAttribute('href', 'javascript:void(0)');
							this.jump('spot-mm-m3-a1').onclick = this.MM1.bindAsEventListener(this);
						} else {
							this.jump('spot-mm-m3-a1')
								.removeClassName('dashed')
								.writeAttribute('href', 'http://' + this.o.PhotoImagineHost + '/cgi-bin/login?noclear=1&page=http%3A%2F%2F' + this.o.PhotoImagineHost + '/spot#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html');
						}
					} else {
						this.jump('spot-mm-m3-m1').hide();
					}
					this.jump('spot-blogs-form').writeAttribute('action', 'http://blogs.mail.ru/' + this.o.auser.domain + '/' + this.o.auser.user + '/jupdate');
					this.jump('spot-mm-m3-m2').show();
					// Function binded in bindCommonEvents()
				} else {
					this.jump('spot-mm-m3-a1').hide();
					this.jump('spot-mm-m3-a2').hide();
				}
				
				
				
				
			
				
				
				//m4 
				if(this.o.album.access == 2 && this.o.foto.Ero != true && this.o.album.id != '_favorites' && this.o.album.id != '_animated' && this.o.album.id != '_animateddialog'){
					this.jump('spot-mm-m4').show();
				} else {
					this.jump('spot-mm-m4').hide();
				}
				

				//m5
				if((this.o.album.access == 2 || this.o.album.access == 4 || this.o.album.access == 5 || this.o.album.access == 6) && this.o.album.id != '_favorites' && this.o.album.id != '_animated' && this.o.album.id != '_animateddialog'){
					this.jump('spot-mm-m5').show();
					if(this.o.auser.id){
						this.jump('cropToggle').writeAttribute('href', 'http://' + this.o.PhotoImagineHost + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html?static=1&allocationFriends=1');
					} else {
						this.jump('cropToggle').writeAttribute('href', 'http://' + this.o.PhotoImagineHost + '/cgi-bin/login?noclear=1&page=http%3A%2F%2F' + this.o.PhotoImagineHost + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.id + '.html?allocationFriends%3D1&static=1');
					}
				} else {
					this.jump('spot-mm-m5').hide();
				}
				
				// Rewriting global vars for friends_alloc
				current_album_id = this.o.album.id;
				current_image_id = this.o.foto.id;
				var_OwnAlbum = (this.o.album.OwnAlbum) ? 1 : 0;
				person_Items = this.o.person.count;
				
				// m6 
				
				this.jump('photoid').setValue(this.o.foto.id);

				this.initPhotoPrint(true);
				
				if(this.o.auser.id && this.o.album.id != '_favorites' && this.o.album.id != '_animated' && this.o.album.id != '_animateddialog'){

				} else {

				}

				//m7
				
				if(this.o.album.access == 2 && this.o.album.id != '_animated' && this.o.album.id != '_animateddialog'){
					this.jump('spot-mm-m7').show();
					if(this.o.foto.themeId == 4){
					} else {
					}
				} else {
					this.jump('spot-mm-m7').hide();
				}
				
				//m8
				
				if(this.o.album.OwnAlbum && this.o.album.albumSkinAccess){
					this.jump('spot-mm-m8').show();
					if(!this.o.get.style && (this.o.foto.skin || this.o.album.skin)){
						this.jump('spot-m8-a')
							.setStyle({'marginTop': ''})
							.writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/selectskin?id=' + this.o.foto.id + '&mode=skinphoto')
							.update('Изменить оформление');
					} else {
						this.jump('spot-m8-a')
							.setStyle({'marginTop': '-2px'})
							.writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/selectskin?id=' + this.o.foto.id + '&mode=skinphoto')
							.update('Оформить<br />фото');
					}
				} else {
					this.jump('spot-mm-m8').hide();
				}

				//m9 m10 nominate
				if(this.o.album.OwnAlbum && this.o.ExtFoto == false && this.o.album.id != '_animated' && this.o.album.id != '_animateddialog' && this.o.album.id != '_favorites') {
					//set globals
					image_ContestId = this.o.foto.contestId;
					image_id = this.o.foto.id;
					
					this.jump('spot-m9-a').stopObserving("click");
					this.jump('spot-m10-a').stopObserving("click");
								
					if(this.o.foto.contestId) {
						this.jump('spot-m10-a').observe("click", function(){
								notNominate(this.o.foto.id, this.o.foto.image_Contest);
						}.bind(this));
						this.jump('notnominate_li').show();
					}
					else {
						this.jump('spot-m9-a').observe("click", function(){
							nominate_ajax();$('spot-m9-a').blur(); return false;
						}.bind(this));
					
						this.jump('nominate_li').show();
					}
				}
								
				var __w = 0;
				$$('#MainMenu a.main').each( function(s){
					__w += s.parentNode.offsetWidth;
				});
				if(__w != 0){ $('MainMenu').setStyle({'width': __w + 'px'}); }
				break;	
			
			case 'comments':
				
				this.placeComments(this.o.comments);
				$$('a.spot-add-comment-link').each( function(s){
					s.stopObserving('click');
					var _place = s.readAttribute('place');
					if(!_place) { _place = 'top'; }
					s.observe('click', function(){
						commentRep(_place, 0, '', this.o.comments.page, this.o.foto.id, this.o.album.id, this.o.user.CurBox);
					}.bind(this));
				}.bind(this));
				break;
				
				
			case 'comments_control':
				if(this.o.auser.comment_read_access == '1' && this.o.auser.comment_write_access == '1' && this.o.comments.comments_list.length > 0){
					this.jump('spot-com-topform').show();
				} else {
					this.jump('spot-com-topform').hide();
				}
				
				if(this.o.auser.comment_write_access == '1'){
					this.jump('spot-com-bottomform').show();
					if(this.o.auser.comment_read_access != '1' && (this.o.album.album_Read == '0' || this.o.album.album_Read == '1')){
						if(this.o.album.album_Read == '0'){
							this.jump('spot-com-warn').update('Комментарии увидит только автор').show();
						} else if (this.o.album.album_Read == '1'){
							this.jump('spot-com-warn').update('Комментарии увидят только избранные пользователи').show();
						}
					} else {
						this.jump('spot-com-warn').update('').hide();
					}
				} else {
					this.jump('spot-com-bottomform').hide();
				}
				
				if(this.o.comments.pages.count > 0){
					
					if(this.o.comments.pages.prev_page){ this.jump('spot-com-prev').show(); } else { this.jump('spot-com-prev').hide(); }
					if(this.o.comments.pages.prev_list){ this.jump('spot-com-pprev').show(); } else { this.jump('spot-com-pprev').hide(); }
					if(this.o.comments.pages.next_page){ this.jump('spot-com-next').show(); } else { this.jump('spot-com-next').hide(); }
					if(this.o.comments.pages.next_list){ this.jump('spot-com-pnext').show(); } else { this.jump('spot-com-pnext').hide(); }
					
					this.jump('spot-com-plist').innerHTML = '';
					this.o.comments.pages.list.each( function(s){
						
						if(s['selected']){
							var _el = new Element('b').addClassName('current_page').update(s['name']);
						} else {
							var _el = new Element('a', {'href': 'javascript:void(0)'}).update(s['name']);
							_el.observe('click', this.replaceComments.bind(this, s['link'])); 
						}
						this.jump('spot-com-plist').appendChild(_el);
					}.bind(this));
					
					this.jump('spot-com-pages').show();
				} else {
					this.jump('spot-com-pages').hide();
				}
				commentRepHide();
				break;
				
			case 'likedalbums':
				if(this.o.foto.TagErotic || this.o.album.id == '_myphoto'){
					this.jump('spot-liked-p').hide();
				} else {
					this.jump('spot-liked-p').show();
				}

				this.jump('spot-fotoliked-line')
					.writeAttribute('shown', '0')
					.hide();


				break;
				
			case 'otheralbums':
				if(this.o.otheralbums.count > 0){
					this.jump('spot-other-albums').innerHTML = '<div class="line mb15 mt15"></div><p style="font-size: 90%"><a style="color: #0857a6" href="' + this.o.user.CurBox + '"><b>Другие альбомы (' + this.o.otheralbums.count + ')</b></a></p>';
					var iter1 = (this.o.otheralbums.count > 9) ? 9 : this.o.otheralbums.count;
					var clear_iter = 0;
					for(var i = 0, l = iter1; i < iter1; ++i){
						clear_iter++;
						var _aitem = this.o.otheralbums.array[i];
						var nfx = this.__create_item(_aitem);
						this.jump('spot-other-albums').appendChild(nfx);
						if(clear_iter == 3){
							this.jump('spot-other-albums').appendChild(new Element('div').addClassName('new_folder_clear'));
							clear_iter = 0;
						}
					}
										
					if(this.o.otheralbums.count > 9){
						var nfh = new Element('div', {'id': 'new_album_hidden'}).setStyle({'display': 'none'});
						var clear_iter = 0;
						for(var i = 9, l = this.o.otheralbums.count; i < l; ++i){
							clear_iter++;
							var _aitem = this.o.otheralbums.array[i];
							var nfx = this.__create_item(_aitem);
							nfh.appendChild(nfx);
							if(clear_iter == 3){
								nfh.appendChild(new Element('div').addClassName('new_folder_clear'));
								clear_iter = 0;
							}
						}
						this.jump('spot-other-albums').appendChild(nfh);

						this.jump('spot-other-albums').appendChild(new Element('div').addClassName('new_folder_clear'));
						var pth = new Element('p').addClassName('tableHiddenLink');
						var pta = new Element('a', {'href': 'javascript:void(0)'})
							.observe('click', function(e){
								var a = Event.element(e);
								var w = $('new_album_hidden');
								if(w && w.style.display == 'none'){
									w.show();
									a.addClassName('arrowLeft');
								} else {
									w.hide();
									a.removeClassName('arrowLeft');
								}
							}.bindAsEventListener(this))
							.update('Все альбомы');
							
						pth.appendChild(pta);
						this.jump('spot-other-albums').appendChild(pth);
					}
					
					this.jump('spot-other-albums').show();
				} else {
					this.jump('spot-other-albums').hide();
					this.jump('spot-other-albums').innerHTML = '';
				}
				break;
			case 'photoinfo1':
				this.jump('ft_tb').hide();
				if(this.o.album.access == '2' || this.o.album.access == '4' || this.o.album.access == '5' || this.o.album.access == '6'){

					this.jump('block_selFriends').innerHTML = '';
	
					if(this.o.person_count > 0){
						var span1 = new Element('span', {'id': 'AlbumName_listNames'}).addClassName('nowrap');
						if(this.o.album.OwnAlbum){
							span1.update('Уже отмечены:');
						} else {
							span1.update('На фото:');
						}
						this.jump('block_selFriends').appendChild(span1);
						
						var sp = this.o.person;
						
						var __first = 1;
						for(sx in sp){
							if (!__first) this.jump('block_selFriends').appendChild(document.createTextNode(', '));__first=0;
							var sitem = sp[sx];
							if(!sitem['SID']) sitem['SID'] = sitem['PID'];
							var span_pid = new Element('span', {'id': 'span_' + sitem['SID']});
							if(sitem['id'] != 0){
								var dog_person = new Element('a', {'href': 'http://www.mail.ru/agent?message&amp;to=' + sitem['email'], 'title': 'Щелкни, чтобы пообщаться с этим человеком в Mail.Ru Агенте'});
								var dog_person_i = new Element('i', {'email': sitem['email']}).addClassName('f2_mrim_status').addClassName('f2_off');
								var dog_person_img = new Element('img', {'src': 'http://img.imgsmail.ru/0.gif', 'alt': ''}).addClassName('f2_ico');
								dog_person_i.appendChild(dog_person_img);
								dog_person.appendChild(dog_person_i);
								span_pid.appendChild(dog_person);

								var span_person = new Element('a', {'href': 'http://' + this.o.MyMailHost + sitem['dir'], 'target': '_blank'})
									.observe('mouseover', this.arrItemShow.bind(this, sitem['SID']))
									.observe('mouseout', this.arrItemsHide.bind(this))
									.update(sitem['nickname']);
								span_pid.appendChild(span_person);

								if((this.o.album.OwnAlbum && !this.o.ExtFoto) || this.o.myExtFoto || sitem['email'] == this.o.auser.email || sitem['adder_email'] == this.o.auser.email){
									var ad_person = new Element('a', {'href': 'javascript:void(0)'})
										.observe('click', function(sp, ss){
											if (!ss || typeof ss == "undefined") ss = sp;
											if(confirm('Удалить отмеченного друга?')) {
												if (this.o.ExtFoto && (sitem['email'] == this.o.auser.email)) {
													ajax_call('perl_delete_person',this.o.album.id,this.o.foto.id,'',ss,function(){
														this.spotNext();
													}.bind(this));
												} else {
													ajax_call('perl_delete_person',this.o.album.id,this.o.foto.id,'',ss,function(id,error){
														if(!id){alert(error);}
														$('pers_' + id).parentNode.removeChild($('pers_' + id));
														$('span_' + id).parentNode.removeChild($('span_' + id));
														person_Items--;
														if (person_Items <= 0) {
															$('AlbumName_listNames').style.display = 'none';
															$('div_mb_person').style.display = 'none';
														}												
													}.bind(this));
												}
											}
										}.bind(this, sitem['PID'], sitem['SID']))
					.observe('mouseover', this.arrItemShow.bind(this, sitem['SID']))
										.observe('mouseout', this.arrItemsHide.bind(this));
									var ad_person_img = new Element('img', {'src': 'http://img.imgsmail.ru/mail/ru/images/my/ico_delete_bold.gif', 'alt': ''})
										.addClassName('delete_button')
										.setStyle({'margin': '0 2px 0 2px', 'verticalAlign': '-4px'});
									ad_person.appendChild(ad_person_img);
									span_pid.appendChild(ad_person);
								}
							} else {
								var span_person = new Element('span')
									.setStyle({'color': '#666', 'cursor': 'hand', 'cursor': 'pointer'})
				.observe('mouseover', this.arrItemShow.bind(this, sitem['SID']))
									.observe('mouseout', this.arrItemsHide.bind(this))
									.update(sitem['nickname']);
								span_pid.appendChild(span_person);
								
								if(this.o.album.OwnAlbum || sitem['email'] == this.o.auser.email || sitem['adder_email'] == this.o.auser.email){
									var ad_person = new Element('a', {'href': 'javascript:void(0)'})
										.observe('click', function(sp){
											if(confirm('Удалить отмеченного друга?')) {
												ajax_call('perl_delete_person',this.o.album.id,this.o.foto.id,'',sp,function(id,error){
													if(!id){alert(error);}
													$('pers_' + id).parentNode.removeChild($('pers_' + id));
													$('span_' + id).parentNode.removeChild($('span_' + id));
													person_Items--;
													if (person_Items <= 0) {
														$('AlbumName_listNames').style.display = 'none';
														$('div_mb_person').style.display = 'none';
													}												
												}.bind(this)); 
											}
										}.bind(this, sitem['SID']))
					.observe('mouseover', this.arrItemShow.bind(this, sitem['SID']))
										.observe('mouseout', this.arrItemsHide.bind(this));
									var ad_person_img = new Element('img', {'src': 'http://img.imgsmail.ru/mail/ru/images/my/ico_delete_bold.gif', 'alt': ''})
										.addClassName('delete_button')
										.setStyle({'margin': '0 2px 0 2px', 'verticalAlign': '-4px'});
									ad_person.appendChild(ad_person_img);
									span_pid.appendChild(ad_person);
								}
							}
							this.jump('block_selFriends').appendChild(span_pid);
						}
					}
					this.jump('block_selFriends').show();
				} else {
					this.jump('block_selFriends').innerHTML = '';
					this.jump('block_selFriends').hide();
				}
				
				//theme
				this.jump('spot-info-theme').innerHTML = '';
				if(this.o.foto.themeEng == 'erotic'){
					this.jump('spot-info-theme').appendChild(new Element('span').addClassName('t75').update(this.o.foto.theme));
				} else {
					this.jump('spot-info-theme').appendChild(new Element('a', {'href': 'http://' + this.o.PhotoPerlHost + '/themes/' + this.o.foto.themeEng}).addClassName('t75').update(this.o.foto.theme));
				}
				
				//desc
				this.jump('spot-info-desc-edit').setValue(this.o.foto.description);
				if(this.o.foto.description || (this.o.album.OwnAlbum && !this.o.ExtFoto)){
					this.jump('spot-info-desc').show();
					if(this.o.album.OwnAlbum && this.o.album.id != '_favotires' && this.o.foto.contestId != '279' && !this.o.ExtFoto){
						if(this.o.foto.description){
							this.jump('imageCommentSpan').update(this.o.foto.description);
						} else {
							this.jump('imageCommentSpan').update('Описание фото');
						}
						this.jump('spot-info-desc-own').show();
						this.jump('spot-info-desc-common').hide();
					} else {
						this.jump('imageComment').update(this.o.foto.description);
						this.jump('spot-info-desc-own').hide();
						this.jump('spot-info-desc-common').show();
					}
				} else {
					this.jump('spot-info-desc').hide();
				}
				
				//tags
				this.jump('labelLinkListId').update('');
				this.jump('txtarForEditLabelsId').setValue(this.o.foto.PhotoTagsString);
				if(this.o.album.id != '_animated' && this.o.album.id != '_animateddialog' && (this.o.foto.PhotoTags_Items > 0 || (this.o.album.OwnAlbum && !this.o.ExtFoto)) && !this.o.foto.TagErotic){
					
					if (this.o.ExtFoto) 
						this.FillFotoTags(this.o.foto.PhotoTags, this.o.foto.ExtCurBox, this.jump('labelLinkListId'));
					else 
						this.FillFotoTags(this.o.foto.PhotoTags, this.o.user.CurBox,  this.jump('labelLinkListId'));
					

					if(this.o.foto.UserTags_Items > 0){
						
						this.FillUserTags(this.o.foto.UserTags, this.jump('spot-tags-user-tags'));
						
						this.jump('spot-tags-user-label').show();
						this.jump('spot-tags-user-tags').show();
					} else {
						this.jump('spot-tags-user-label').hide();
						this.jump('spot-tags-user-tags').hide();
						this.jump('spot-tags-user-tags').innerHTML = '';
					}
					
					this.jump('spot-info-tags').show();
				} else {
					this.jump('spot-info-tags').hide();
				}
				
				// Photoinfo right block
				if(this.o.foto.width || this.o.foto.height){
					this.jump('Sizes').update(this.o.foto.width + '&times;' + this.o.foto.height + '&nbsp;&nbsp;').show();
				} else {
					this.jump('Sizes').update('').hide();
				}
				
				if(this.o.foto.image_AddTime_d){
					this.jump('spot-info-added-span').update(this.o.foto.image_AddTime_d + '.' + this.o.foto.image_AddTime_m + '.' + this.o.foto.image_AddTime_Y);
					this.jump('spot-info-added').show();
				} else {
					this.jump('spot-info-added').hide();
					this.jump('spot-info-added-span').update('');
				}
				
				if(this.o.foto.image_ShotTime_d){
					this.jump('spot-info-shoted-span').update(this.o.foto.image_ShotTime_d + '.' + this.o.foto.image_ShotTime_m + '.' + this.o.foto.image_ShotTime_Y);
					this.jump('spot-info-shoted').show();
				} else {
					this.jump('spot-info-shoted').hide();
					this.jump('spot-info-shoted-span').update('');
				}
				
				if(this.o.foto.image_viewCountMonth || this.o.foto.image_viewCountYesterday || this.o.foto.image_viewCountToday || this.o.foto.image_viewCount){
					if(this.o.foto.image_viewCountToday){ this.jump('spot-view-count1').update(this.o.foto.image_viewCountToday + '&nbsp;&mdash;&nbsp;сегодня<br />').show(); } else { this.jump('spot-view-count1').update('').hide(); }
					if(this.o.foto.image_viewCountYesterday){ this.jump('spot-view-count2').update(this.o.foto.image_viewCountYesterday + '&nbsp;&mdash;&nbsp;вчера').show(); } else { this.jump('spot-view-count2').update('').hide(); }
					if(this.o.foto.image_viewCountMonth){ this.jump('spot-view-count3').update(this.o.foto.image_viewCountMonth + '&nbsp;&mdash;&nbsp;за месяц<br />').show(); } else { this.jump('spot-view-count3').update('').hide(); }
					if(this.o.foto.image_viewCount){ this.jump('spot-view-count4').update(this.o.foto.image_viewCount + '&nbsp;&mdash;&nbsp;всего').show(); } else { this.jump('spot-view-count4').update('').hide(); }
				} else {                                                                      
					this.jump('spot-info-views').hide();
					this.jump('spot-info-views').select('span').each( function(s){ s.update(''); });
				}
				
				// exif
				if(this.o.exif.make || this.o.exif.model){
					this.jump('Exif').show();
					if(this.o.exif.CameraId){
						this.jump('spot-info-exif-show').update(this.o.exif.model).show();
						this.jump('spot-info-exif-link').update('').hide();
					} else {
						this.jump('spot-info-exif-show').update('').hide();
						this.jump('spot-info-exif-link').update(this.o.exif.model).show();
					}
					this.jump('spot-info-exif-make').update(this.o.exif.make);
				} else {
					this.jump('Exif').hide();
					this.jump('spot-info-exif-show').update('').hide();
					this.jump('spot-info-exif-link').update('').hide();
					this.jump('spot-info-exif-make').update('');
				}
				this.jump('ft_tb').show();
				break;
				
			case 'ratingBlock':
				this.jump('spot-rating-block').hide();
				
				rating = this.o.foto.image_Rate;
				
				this.vote_mark = '';
				this.vote_capcha_id = '';
				this.jump('security_image_answer').setValue('');
				this.jump('for_capcha').hide();
				this.jump('img_for_capcha').writeAttribute('src', 'http://img.imgsmail.ru/0.gif');
				
				this.jump('image_Rate').update(this.o.foto.image_Rate);
				
				if(this.o.auser.view_vote_access && this.o.foto.image_Votes > 0){
					this.jump('total_voted').show();
					this.jump('image_VotesCount')
						.writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/rating?email=' + this.o.user.PhotoUser + '@' + this.o.user.PhotoDomain + '&id=' + this.o.foto.id)
						.update(this.o.foto.image_Votes);
				} else {
					this.jump('image_VotesCount')
						.writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/rating?email=' + this.o.user.PhotoUser + '@' + this.o.user.PhotoDomain + '&id=' + this.o.foto.id)
						.update('');
					this.jump('total_voted').hide();
				}
				
				if (this.o.ExtFoto) 
					InfoBlock.initSMSHelp(this.o.PhotoPerlHost,this.o.user.id,this.o.auser.id,this.o.foto.ExtID,this.o.album.id);
				else 
					InfoBlock.initSMSHelp(this.o.PhotoPerlHost,this.o.user.id,this.o.auser.id,this.o.foto.id,this.o.album.id);
				
				
				if(this.o.auser.muchEstimate){

				
					// Cleaning second block
					this.jump('image_Rate_Vote_Access').hide();
					this.cleanCapcha();
					this.jump('vote_message').hide().update('');
					//Cleaning third block
					this.jump('spot-vote-blocked').hide();
					this.jump('fly-voting_block').hide().update('');
					
					// Do something with first block
					this.jump('spot-rating-estimate').show();
					this.jump('spot-rating-estimate').select('a').each( function(s){
						s.writeAttribute('href', 'http://my.mail.ru/cgi-bin/my/fixedestimate?album=' + this.o.album.id + '&id=' + this.o.foto.id);
					}.bind(this));
				} else {
					//Cleaning first block
					this.jump('spot-rating-estimate').hide();
					this.jump('spot-rating-estimate').select('a').each( function(s){
						s.writeAttribute('href', 'javascript:void(0)');
					}.bind(this));
					//Cleaning third block
					this.jump('spot-vote-blocked').hide();
					this.jump('fly-voting_block').hide().update('');
					
					//Do something with second block
					if(!this.o.auser.contest_novote && this.o.auser.vote_access){
						if(this.voted[this.fotoId()]){
							this.jump('image_Rate_Vote_Access').hide();
							this.jump('vote_message').update(this.voted[this.fotoId()]).show();
						} else {
							this.jump('image_Rate_Vote_Access').show();
							var __noid = this.jump('spot-votes-10').select('div.spot-votes-noid')[0];
							if(this.o.auser.DoubleVoter){
								this.jump('spot-votes-10').stopObserving('click');
								if(__noid){ __noid.writeAttribute('id', 'mega_active'); }
								this.jump('spot-votes-a10').observe('click', function(){
									this.tryVote(10);
								}.bind(this));
							} else {
								this.jump('spot-votes-10').observe('click', function(e){
									var __el = Event.element(e);
									InfoBlock.show('SmsBox', e, __el, 'smsgame', 'abs', 28,'left', false,'','megavote24');
								}.bindAsEventListener(this));
								if(__noid){ __noid.writeAttribute('id', 'mega'); }
								this.jump('spot-votes-a10').stopObserving('click');
							}
							
							if(this.o.foto.image_DobuleVote > this.o.CurrentTime){
								this.jump('spot-votes-x2').removeClassName('x2').addClassName('x2_active');
								this.jump('spot-votes-imgx2')
									.writeAttribute('alt', 'Оценки этого фото удваиваются, потому что оно участвует в SMS-игре &quot;Дайте две!&quot;')
									.writeAttribute('title', 'Оценки этого фото удваиваются, потому что оно участвует в SMS-игре &quot;Дайте две!&quot;');
							} else {
								this.jump('spot-votes-x2').addClassName('x2').removeClassName('x2_active');
								this.jump('spot-votes-imgx2')
									.writeAttribute('alt', 'Удваивать голоса')
									.writeAttribute('title', 'Удваивать голоса');
							}
						}
					} else {
						//Cleaning first block
						this.jump('spot-rating-estimate').hide();
						this.jump('spot-rating-estimate').select('a').each( function(s){
							s.writeAttribute('href', 'javascript:void(0)');
						}.bind(this));
						// Cleaning second block
						this.jump('image_Rate_Vote_Access').hide();
						this.cleanCapcha();
						this.jump('vote_message').hide().update('');					
				
						// Do something with third block
						if(!this.o.album.OwnAlbum){
							this.jump('spot-vote-blocked-a').observe('click', function(e){
								var __el = Event.element(e);
								InfoBlock.show('fly-voting_block', e, __el, 'submenu', 'rel', 0, 0, false, '');
							}.bindAsEventListener(this));
							var __fly = 'Голосование заблокировано владельцем';
							if(this.o.auser.content_novote){ __fly = 'Закрыто голосование в конкурсе'; }
							if(this.o.album.album_Vote == '1'){ __fly = 'Голосование доступно избранным пользователям'; }
							
							this.jump('fly-voting_block').update(__fly);
							this.jump('spot-vote-blocked').setStyle({'textAlign': 'left'}).setStyle({'paddingTop': '6px'}).show();
						}
					}					
				}
				
				// Awards
				this.jump('Awards').select('li').each( function(s){
					s.hide();
				}.bind(this));
				if(this.o.foto.image_WasSMSLast || this.o.foto.image_WasLeader || this.o.foto.image_Rate > 500 || this.o.foto.image_AvgMark > 4.5 || this.o.foto.image_DayphotoWinnerpos > 0){
					if(this.o.foto.image_Rate > 2500){
						this.jump('spot-aw-rate1').show();
					} else if (this.o.foto.image_Rate > 1000){
						this.jump('spot-aw-rate2').show();
					} else if (this.o.foto.image_Rate > 500){
						this.jump('spot-aw-rate3').show();
					}
					
					if(this.o.foto.image_AvgMark > 4.9){
						this.jump('spot-aw-avg1').show();
					} else if(this.o.foto.image_AvgMark > 4.8){
						this.jump('spot-aw-avg2').show();
					} else if(this.o.foto.image_AvgMark > 4.5){
						this.jump('spot-aw-avg3').show();
					}
					
					if(this.o.foto.image_DayphotoWinnerpos > 0 && this.o.foto.image_DayphotoWinnerpos < 21){
						if(this.o.foto.image_DayphotoWinnerpos == 1){ 
							this.jump('spot-aw-adf1').writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/dayphoto?tab=3&ymd=' + this.o.foto.image_DayphotoYMD);
							this.jump('spot-aw-idf1').writeAttribute('alt', '1-е место &laquo;Фото дня&raquo;').writeAttribute('title', '1-е место &laquo;Фото дня&raquo;');
							this.jump('spot-aw-df1').show(); 
						}
						if(this.o.foto.image_DayphotoWinnerpos == 2){ 
							this.jump('spot-aw-adf2').writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/dayphoto?tab=3&ymd=' + this.o.foto.image_DayphotoYMD);
							this.jump('spot-aw-idf2').writeAttribute('alt', '2-е место &laquo;Фото дня&raquo;').writeAttribute('title', '2-е место &laquo;Фото дня&raquo;');
							this.jump('spot-aw-df2').show(); 
						}
						if(this.o.foto.image_DayphotoWinnerpos == 3){ 
							this.jump('spot-aw-adf3').writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/dayphoto?tab=3&ymd=' + this.o.foto.image_DayphotoYMD);
							this.jump('spot-aw-idf3').writeAttribute('alt', '3-е место &laquo;Фото дня&raquo;').writeAttribute('title', '3-е место &laquo;Фото дня&raquo;');
							this.jump('spot-aw-df3').show(); 
						}
						if(this.o.foto.image_DayphotoWinnerpos > 3 && this.o.foto.image_DayphotoWinnerpos < 21){ 
							this.jump('spot-aw-adfx').writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/cgi-bin/photo/dayphoto?tab=3&ymd=' + this.o.foto.image_DayphotoYMD);
							this.jump('spot-aw-dfx').show(); 
						}
					}
					
					if(this.o.foto.image_WasSMSLast){ 
						this.jump('spot-aw-asms').writeAttribute('href', 'http://' + this.o.PhotoPerlHost + '/catalog/SMSLast/1.html');
						this.jump('spot-aw-sms').show(); 
					}
					if(this.o.foto.image_WasLeader){ this.jump('spot-aw-fld').show(); }
					
					this.jump('Awards').show();
				} else {
					this.jump('Awards').hide();
				}
				
				this.jump('spot-rating-block').show();
				
				break;
			
			case 'mrim' : setTimeout(this.getMrims.bind(this),2000);
			
				break;
				
			case 'wanttalk' : setTimeout(switch_wanttalk.bind(this, 1),2000);
			
				break;
				
			case 'prevline' : this.jump('spot-fotoother-line').show();
			
				break;
				
        }
    }

	this.getMrims = function() {
		var mrimstatus_url = "";
		mrimstatus_url += getTagsMrimStatus('f2_mrim_status','I');
		mrimstatus_url += (mrimstatus_url != "") ? "," : "" ;
		mrimstatus_url += getTagsMrimStatus('spr-mrim-9','A');
		mrimstatus_url = mrimstatus_url.replace(/\,{2,}/gi,",");
		if (mrimstatus_url) {
			mrimstatus_url = "http://" + PhotoPerlHost() + "/proxy-mrim-status?" + mrimstatus_url;
			ajax_call_nomagick(mrimstatus_url, mrimstatus_callback);
		}
	}
	
	this.listPage = function(event) { 
		if (!event) event = window.event;
		var key = event.keyCode;
		
		if (event.ctrlKey)
		{
			var tagName = (event.target || event.srcElement).tagName;
			if (tagName != 'INPUT' && tagName != 'TEXTAREA')
			{
				var doc;
				if (key == 37) { event.preventDefault(); doc = this.jump('spot-image-prev').readAttribute("href");}
				if (key == 39) { event.preventDefault(); doc = this.jump('spot-image-next').readAttribute("href");}
				if (/#/.test(doc))   
					location.hash = doc;
				
			}
		}
	}
	
	this.FillUserTags = function(t,o){
		o.innerHTML = '';
		t.each( function(s){
			var _nt = new Element('a', {'href': 'javascript:void(0)'})
				.addClassName('t70')
				.addClassName('tahoma')
				.addClassName('additional')
				.observe('click', function(label){
					var textarea = this.jump('txtarForEditLabelsId');
					var value = textarea.getValue();
					while (value != "" && value.charCodeAt(value.length - 1) == 32) {
						value = value.substring(0, value.length - 2);
					}
					textarea.setValue(value);
					if (value == "") { textarea.setValue(label); }
					else if (value.charCodeAt(value.length - 1) == 44) { textarea.setValue(value += " " + label); }
					else { textarea.setValue(value += ", " + label); }
				}.bind(this, s['Tag']))
				.update(s['Tag']);
			o.appendChild(_nt);
			o.appendChild(document.createTextNode(' '));
		}.bind(this));
	}
	
	this.FillFotoTags = function(t,cb,o){
		o.innerHTML = '';
		t.each( function(s){
			var __tag = new Element('a', {'href': 'http://' + this.o.PhotoPerlHost + cb + 'tags/' + s['Name']}).addClassName('additional').update(s['Tag']);
			this.jump('labelLinkListId').appendChild(__tag);
			this.jump('labelLinkListId').appendChild(document.createTextNode(' '));
		}.bind(this));
		
		if(this.o.album.OwnAlbum && !this.o.ExtFoto){
			var __sp = new Element('span').addClassName('nowrap');
			var __ed = new Element('a', {'href': 'javascript:void(0)'})
				.observe('click', function(){
					this.jump('editLabelsBlockId').show();
				}.bind(this))
				.update('<img src="http://img.imgsmail.ru/r/foto2/ico_pencil.gif" width="16" height="16" alt="" />Редактировать');
			__sp.appendChild(__ed);
			this.jump('labelLinkListId').appendChild(__sp);
		}
	}
	
	this.__create_item = function(_aitem){
		var nf = new Element('div').addClassName('new_folder');
		var nf_link = new Element('a', {'href': this.o.user.CurBox + _aitem.id + '/'}).addClassName('spr').addClassName('spr_ico_folder');
		if(_aitem.access != 2){
			nf_link.innerHTML += '<img src="http://img.imgsmail.ru/0.gif" width="9" height="13" alt="" class="locked spr spr_folder_locked" />&nbsp;';
		}
		nf_link.innerHTML += (_aitem.name) ? _aitem.name : 'Без названия';
		nf.appendChild(nf_link);
		
		nf.appendChild(new Element('span').update(_aitem.count));
		return nf;
	}

	
	this.MM7 = function(){
		var xurl = 'http://www.smsonline.ru/mail/s.cgi?id=4';
		if(this.o.foto.themeId == 4){ xurl += '&ero=1'; }
		xurl += '&f=' + this.o.foto.jsjpg;
		window.open(xurl, 'smsonline'+parseInt(Math.random()*10000),'width=780, height=580, titlebar=no, resizable=no, status=yes, scrollbars=no');
	}
	
	this.MM1 = function(e){
		var el = Event.element(e);
		if(this.blockedAjax == 0){
			ajax_call('perl_isinblacklist', function(st){
				if(st == '0'){
					this.blockedAjax = 1;
					InfoBlock.show('GoBlog', e, el, 'submenu', 'rel', 5, 40, true, 3);
				} else if (st == '1'){
					this.blockedAjax = 2;
					alert('Вы не можете размещать в блоге фото этого пользователя');
				}
			}.bind(this));
		} else if (this.blockedAjax == 1){
			InfoBlock.show('GoBlog', e, el, 'submenu', 'rel', 5, 40, true, 3);
		} else if (this.blockedAjax == 2){
			alert('Вы не можете размещать в блоге фото этого пользователя');
		}
	}
		
	this.go_in_blogs = function(){
		var ba_preview = (this.jump('only_preview')) ? this.jump('only_preview').checked : false;
		var ba_border  = (this.jump('with_border'))  ? this.jump('with_border').checked : false;
		var ba_width = (ba_preview) ? this.o.foto.pwidth : this.o.foto.width;
		var ba_height = (ba_preview)? this.o.foto.pheight : this.o.foto.height;
		if(this.o.album.id == '_favorites'){
			var ba_id = this.o.foto.FavID;
			var ba_email = this.o.user.FavEmail;
			var ba_album_url = this.o.foto.FavAlbum;
		} else {
			var ba_id = this.o.foto.id;
			var ba_email = this.o.user.email;
			var ba_album_url = this.o.album.id;
		}
		var ba_body = '<foto preview="' + (ba_preview?1:0) + '" border="' + (ba_border?1:0) + '" author_name="' + this.o.user.blogs_name + '" author_email="' + ba_email + '" album_name="' + this.o.album.title + '" album_url="' + ba_album_url + '" image_id="' + ba_id + '" width="' + ba_width + '" height="' + ba_height + '" title="' + this.o.foto.title + '" theme="' + this.o.foto.themeEng + '" />'
		this.jump('spot-blogs-subject').setValue(this.o.foto.title);
		this.jump('spot-blogs-body').setValue(ba_body);
		this.jump('spot-blogs-form').submit();
		InfoBlock.hide();
		return false;
	}

	this.highLight = function(e){
		var el = Event.element(e);
		el.setStyle({'backgroundColor': '#dfdfdf'});
	}
	this.unhighLight = function(e){
		var el = Event.element(e);
		el.setStyle({'backgroundColor': '#efefef'});
	}
	
	
	
	this.prevImage = function(){
		document.location.hash = '#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.prev_image + '.html';
		this.rewriteSimple();
	}
	this.nextImage = function(){
		document.location.hash = '#' + this.o.user.CurBox + this.o.album.id + '/' + this.o.foto.next_image + '.html';
		spot.rewriteSimple();
	}
	
	this.editTitle = function(){
		this.jump('spot-nav-image').hide();
		this.jump('spot-nav-image-edit').show();
		this.jump('spot-nav-title-edit').setValue(this.o.foto.title);
	}
	
	this.editTitleSave = function(){
		this.jump('spot-nav-image-edit').hide();
		ajax_call('perl_change_image_name', this.o.foto.id, this.o.album.id, this.jump('spot-nav-title-edit').getValue(), function(title,id){
			if(id){
				if (title == undefined || title == null || title == '') {
					title = 'Без названия';
				}
				this.o.foto.title = title;
				this._write('fub');
			} else {
				alert('Ошибка!');
			}
		}.bind(this));
	}
	
	this.editTitleCancel = function(){
		this.jump('spot-nav-image-edit').hide();
		this.jump('spot-nav-image').show();
	}
	
	this.setLoadImage = function(){

	}
	
	this.placeComments = function(o){
		var l = o.comments_list;
		this.jump('spot-comment-place').innerHTML = '';
		if(l.length > 0){
			l.each( function(s, i){
				this.writeComment(o[s]);
			}.bind(this));
		}
		this._write('comments_control');
	}
	
	

	this.replaceComments = function(){
		if(arguments[0]){
			var pg = arguments[0];
		}
		
		var url = 'http://' + this.o.PhotoPerlHost + this.getHash(this.hash);
		
		if(url.indexOf('?') == -1){
			url += '?spotComments=1';
		} else {
			url += '&spotComments=1';
		}
		if(pg){ url += '&page=' + pg; }
		ajax_call_static(url, this.replaceCommentsCallback.bind(this));	
	}
	
	this.replaceCommentsCallback = function(){
		this.o.comments = Object.clone(arguments[0].comments);
		this.placeComments(this.o.comments);
		$('place_top').scrollTo();
	}
	
	this.writeComment = function(d){
		var t = this.jump('spot-comment-place');
		if(d.deleted == '1' || d.blocked == '1'){
			var div_del = new Element('div').addClassName('mb20');
			var div_del_span = new Element('span', {'id': 'tab' + d.id});
			var div_del_span_b = new Element('b').addClassName('t75').update('Комментарий удалён');
			div_del_span.appendChild(div_del_span_b);
			div_del.appendChild(div_del_span);
			t.appendChild(div_del);
		} else {
			var LeftLevel = 5;
			if(d.slevel != 0){
				if(d.slevel == 1){
					LeftLevel = 35;
				} else {
					LeftLevel = (d.width2 - 25);
				}
			}
			
			// Main comment div
			var div_Comment = new Element('div', {'id': 'tab' + d.id}).setStyle({'marginLeft': LeftLevel + 'px'}).addClassName('Comment');
			
			// Arrow in nested comments
			var div_re = new Element('div').addClassName('re');
			if(d.slevel != 0){
				var div_re_1 = new Element('div');
				var img_in_re = new Element('img', {'src': 'http://img.imgsmail.ru/0.gif', 'width': '25', 'height': '15', 'alt': ''}).addClassName('spr').addClassName('spr_comm_arrow');
				div_re_1.appendChild(img_in_re);
				div_re.appendChild(div_re_1);
			}
			div_Comment.appendChild(div_re);
			
			// Div with Userpick
			var div_up = new Element('div').addClassName('user_pic');
			var div_up_1 = new Element('div');
			var div_up_a = new Element('a', {'href': 'http://my.mail.ru' + d.authorurl}).setStyle({'height': '90px'}).addClassName('avatar_bsv');
			var div_up_img = new Element('img', {'src': 'http://avt.foto.mail.ru' + d.authorurl + '_avatar', 'alt': ''});
			var div_up_cp = new Element('div').addClassName('cp');
			div_up_a.appendChild(div_up_img);
			div_up_1.appendChild(div_up_a);
			div_up_1.appendChild(div_up_cp);
			div_up.appendChild(div_up_1);
			div_Comment.appendChild(div_up);
			
			var div_message = new Element('div').addClassName('message');
			
			var div_message_1 = new Element('div').addClassName('mb3').addClassName('mes_author');
			var div_message_1_a = new Element('a', {'href': 'http://www.mail.ru/agent?message&to=' + d.author, 'title': 'Щелкни, чтобы пообщаться с этим человеком в Mail.Ru Агенте'});
			var div_message_1_a_i = new Element('i', {'email': d.author}).addClassName('f2_mrim_status').addClassName('f2_off');
			var div_message_1_a_i_img = new Element('img', {'src': 'http://img.imgsmail.ru/0.gif', 'alt': ''}).addClassName('f2_ico');
			div_message_1_a_i.appendChild(div_message_1_a_i_img);
			div_message_1_a.appendChild(div_message_1_a_i);
			div_message_1.appendChild(div_message_1_a);

			var div_message_afio = new Element('a', {'href': 'http://my.mail.ru' + d.authorurl}).update(d.fio);
			div_message_1.appendChild(div_message_afio);

			div_message_1.innerHTML += '&nbsp;&nbsp;<span>' + d.update_d + '.' + d.update_m + '.' + d.update_Y + '&nbsp;&nbsp;' + d.update_H + ':' + d.update_M + '</span>';

			if(d.OwnComment != 1){
				var complain_span = new Element('span').addClassName('complain_comment');
				var complain_img = new Element('img', {'hspace': '5', 'src': 'http://img.imgsmail.ru/0.gif', 'alt': 'Пожаловаться на комментарий', 'border': '0'}).addClassName('spr').addClassName('spr_ico_moder');
				complain_span.appendChild(complain_img);
				var complain_a = new Element('a', {'id': 'comment' + d.id, 'href': 'javascript:void(0)'}).update('Пожаловаться');
				complain_a.onclick = function(){
					ajax_call('perl_comment_complain', this.o.album.id, this.o.foto.id, d.id, CommentComplainCallback);
				}.bind(this);
				
				complain_span.appendChild(complain_a);
				div_message_1.appendChild(complain_span);
			}
			
			div_message.appendChild(div_message_1);

			
			var div_re = new Element('div').addClassName('text').addClassName('mb20');
			var div_re2 = new Element('div').addClassName('mb10');
			var __strb = 'Re';
			if(d.slevel > 0){ __strb += '[' + d.slevel + ']' }
			__strb += ':';
			if(this.o.foto.title){ __strb += this.o.foto.title; } else { __strb += 'Без названия'; }
			var div_re2_b = new Element('b').update(__strb);
			div_re2.appendChild(div_re2_b);
			div_re.appendChild(div_re2);

			var div_re_p = new Element('p').update(d.comment);
			div_re.appendChild(div_re_p);
			
			
			div_message.appendChild(div_re);
			
		
			var div_t60 = new Element('div').addClassName('t60');



			
			if(d.id){
				if(this.o.auser.comment_write_access == '1'){
					var div_t60_a1 = new Element('a', {'href': 'javascript:void(0)', 'id': 'l_' + d.id}).update('Ответить');
					div_t60_a1.observe('click', function(){ 
						commentRep(d.id, 0, '', this.o.comments.page, this.o.foto.id, this.o.album.id, this.o.user.CurBox);
					}.bind(this));
					div_t60.appendChild(div_t60_a1);
				}
				if(this.o.album.OwnAlbum || d.OwnComment || this.o.auser.PhotoModerator){
					var __a2url = this.o.AdminURL;
					if(this.o.auser.PhotoModerator){ __a2url += 'admin/'; }					
					__a2url += 'delcomment?id=' + this.o.foto.id + '&album=' + this.o.album.id + '&author=' + this.o.user.email + '&n=' + d.id + '&page=' + this.o.comments.page;
					var div_t60_a2 = new Element('a', {'id': 'd_' + d.id, 'href': __a2url}).setStyle({'paddingLeft': '10px'}).update('Удалить');
					div_t60_a2.observe('click', this.Wrapper_DelCommentDialog.bindAsEventListener(this, this.o.foto.id, this.o.album.id, this.o.comments.page, this.o.comments.count));
					div_t60.appendChild(div_t60_a2);
				}
			} else {
				if(d.number){
					if(this.o.album.OwnAlbum || d.OwnComment || this.o.auser.PhotoModerator){
						var __a3url = this.o.AdminURL;
						if(this.o.auser.PhotoModerator){ __a3url += 'admin/'; }
						__a3url += 'delcomment?id=' + this.o.foto.id + '&album=' + this.o.album.id + '&author=' + this.o.user.email + '&n=' + d.number + '&page=' + this.o.comments.page;
						var div_t60_a3 = new Element('a', {'id': 'dn_' + d.number, 'href': __a3url}).update('Удалить');
					}
				}
			}
			
			div_message.appendChild(div_t60);
			
			div_Comment.appendChild(div_message);
			
			var div_clear = new Element('div').addClassName('clear');
			var div_clear_span = new Element('span');
			div_clear.appendChild(div_clear_span);
			div_Comment.appendChild(div_clear);
			
			t.appendChild(div_Comment);
			
			var div_500 = new Element('div', {'id': 'place_' + d.id}).setStyle({'width': '500px', 'marginLeft': LeftLevel + 'px'});
			t.appendChild(div_500);
			
			
		}
	}
	
	this.Wrapper_DelCommentDialog = function(e, image_id, album_id, comment_page){
		ob = Event.element(e);
		e.stop();		
		DelCommentDialog(ob, image_id, album_id, comment_page);
	}

	this.initPhotoPrint = function(noadd){
		this.global_cookie = '';
		if(this.o.photoprint.Imagine){
			var arr = new Array();
			arr = this.o.photoprint.Imagine.split(':');
			arr.shift();
			this.global_cookie = arr.join(':');   
		} else {
			this.global_cookie = (this.o.photoprint.Perl) ? this.o.photoprint.Perl : '';
		}

		if(this.o.photoprint.Has_Perl || this.o.photoprint.Imagine){
			set_cookie('photoprint', this.global_cookie, null, '/', 'mail.ru');
			var cookie = get_cookie('photoprint');
			if(cookie == '0'){
				var expiredate = new Date(); 
				expiredate = new Date(expiredate.getTime()-1000);
				set_cookie('photoprint','',expiredate,'/','mail.ru');
			}
		}
		
			
		if (this.global_cookie != null && this.global_cookie != '') {
			var user = new Array;
			user = this.global_cookie.split('&');
			var photo_id =  document.getElementById('photoid').value;
			
			for (var i=0;i<user.length;i++) {			
				
				var photo = new Array;
				photo = user[i].split(':');
				if(photo[0] != this.o.user.email) continue;
				var found = false;
				for (var j=1;j<photo.length;j++) {
					if(photo[j]=='') continue;
					var prop = new Array;
					prop = photo[j].split(',');
					if (prop[1]==photo_id) {
						
						found = true;
						incook(true,this.o.user.email,this.o.album.id,noadd);
						this.jump('spot-foto-main').addClassName('for_print');
						this.jump('addin_cook').hide();
						this.jump('delfrom_cook').show();
						break;
					}
				}
				
				
				
				if(!found){
					
					incook(false,this.o.user.email,this.o.album.id,noadd);
					this.jump('spot-foto-main').removeClassName('for_print');
					this.jump('addin_cook').show();
					this.jump('delfrom_cook').hide();
				}
			}
		} else {
			this.jump('spot-foto-main').removeClassName('for_print');
			this.jump('addin_cook').show();
			this.jump('delfrom_cook').hide();
		}
	}

	this.resetStyle = function(){
		// Skins
		if(this.o.get.style != ''){ this.o.foto.imageStyle = this.o.get.style; }
		var fotoStyle = this.o.foto.imageBrand ? this.o.foto.imageBrand : this.o.foto.imageStyle;
		if(fotoStyle){
			this.jump('spot-foto-main').setStyle({'paddingTop': '0px'});
			this.jump('spot-skinDiv').classNames().each( function(s){
				if(s.indexOf('skin_foto') != -1){
					this.jump('spot-skinDiv').removeClassName(s);
				}
			}.bind(this));
			this.jump('spot-skinDiv').addClassName('skin_foto').addClassName('skin_foto' + fotoStyle);
		} else {
			this.jump('spot-foto-main').setStyle({'paddingTop': ''});
			this.jump('spot-skinDiv').removeClassName('skin_foto');
			this.jump('spot-skinDiv').classNames().each( function(s){
				if(s.indexOf('skin_foto') != -1){
					this.jump('spot-skinDiv').removeClassName(s);
				}
			}.bind(this));
		}				
	}
	
	this.reportLog = function(){
		try{
			var __a = arguments;
			var __o = '';
			this.report['renderEnd'] = (new Date()).getTime();
			if(this.report['renderStart'] != 0){
				this.report['renderTotal'] = this.report['renderEnd'] - this.report['renderStart'];
			}
			if(this.report['renderAjaxStart'] != 0 && this.report['renderAjaxCallback'] != 0){
				this.report['renderAjaxTotal'] = this.report['renderAjaxCallback'] - this.report['renderAjaxStart'];
			}
			var __start = false;
			for(i1 in this.report){
				if(__start){ __o += '$'; }
				__o += i1 + '*' + this.report[i1];
				__start = true;
			}
			if(__a.length > 0){
				__o += '&qa=' + __a[0];
			}
			return __o;
		} catch (e){
		    return 'err';
		}
	}
}
	

//хочу общаться
function switch_wanttalk(s) { 
	var d = $$(".mf_divWantTalk")[0], a1 = $$(".mf_divWantTalkHide a")[0], a2 = $$(".mf_divWantTalkHide a")[1], main = $("want-talk");
	var c,w;
	
	if(!d || !a1 || !a2 || !main) return;
	
	main.show();
	
	c = getCookie("wanttalk"); 
	
	if(s == 1) { 
		w = (c == 0) ? 0 : 1;
	}
	else {
		w = (c == 0) ? 1 : 0;
		setCookie("wanttalk", w);
	}
				
	if(w) { 
		a2.removeClassName("hidden");
		a1.addClassName("hidden");
		d.removeClassName("hidden");
	}
	else {	
		a2.addClassName("hidden");
		a1.removeClassName("hidden");
		d.addClassName("hidden");
	}
}

//номинировать
var image_ContestId, image_id;
    
function nominate_ajax(){
	var ndiv = $('nominate_list');
	if(!ndiv){
		ajax_call('perl_contests_list', nominate_ajax_callback);
	} else {
		if(ndiv.getStyle('display') == 'block'){
			ndiv.hide();
			document.stopObserving('click', nominate_hide);
		} else {
			ndiv.show();
			document.observe('click', nominate_hide);
		}
	}
}

function nominate_hide(e){
	var el = e.element();
	if(!el || !el.hasClassName('unbind')){
		$('nominate_list').hide();
		document.stopObserving('click', nominate_hide);
	}
}

function nominate_ajax_callback(s,h){
	if(s == 1 && h && h.length > 0){
		var ndiv = new Element('div', {'id': 'nominate_list'});
		ndiv.appendChild(new Element('p').update('Конкурсы:'));

		for(var i = 0, l = h.length; i < l; ++i){
			var _a = new Element('a', {'href': 'http://' + PhotoImagineHost() + '/cgi-bin/photo/nominate?id=' + image_id + '&SetContest=' + h[i]['id'], 'target': '_blank'}).update(h[i]['name']);
			if(h[i]['id'] == image_ContestId){
				_a.setStyle({'fontWeight': 'bold'});
			}

			if(image_ContestId && h[i]['id'] != image_ContestId){
				_a.observe('click', function(e){
					if(!confirm("Одно фото может быть номинировано только на один конкурс. При номинации фото на другой конкурс оно перестанет участвовать в текущем конкурсе. Продолжить?")){ e.stop(); }
				});
			}
			ndiv.appendChild(_a);
		}

		ndiv.appendChild(new Element('img', {'src': 'http://img.imgsmail.ru/r/foto2/ico_close.gif'})
									.setStyle({'cursor': 'pointer', 'position': 'absolute', 'top': '5px', 'right': '5px'})
									.observe('click', nominate_hide));
		
		$('nominate_li').appendChild(ndiv);
		document.observe('click', nominate_hide);

	}
}

function notNominate(image_id, image_Contest) {
	if (confirm('Вы собираетесь снять фото с конкурса ' + image_Contest + '. Продолжить?')) {
		ajax_call('perl_clear_nominate',image_id, function() {
			$("spot-m9-a").observe("click", function(){
				nominate_ajax();$('spot-m9-a').blur(); return false;
			}.bind(this));
		});
		gebi('notnominate_li').style.display = 'none';
		gebi('nominate_li').style.display = 'block';
		gebi('flag_image_contest').style.display = 'none';
		spot.o.foto.imageBrand = false;
		spot.resetStyle();
		image_ContestId = '';
		centerMenu();		
	}
}


//mrim
var arrMRIMStatus;
var arrTagsI, arrTagsA;
function getTagsMrimStatus(class_name,tag_name)
{
	var mrimstatus_url;
	var arrTags, emails = [];
	
	switch (tag_name) {
		case "I" : arrTags = arrTagsI; break;
		case "A" : arrTags = arrTagsA; break;
	}
	var arrTags = gebc(class_name,tag_name);
	var arrTagsL = arrTags.length;
	arrMRIMStatus = [];
	for (var i = 0; i < arrTagsL; i++)
	{
		if (arrTags[i].className && arrTags[i].className != 'undefined' && arrTags[i].className.indexOf(class_name) != -1) {
			arrMRIMStatus[arrMRIMStatus.length] = arrTags[i];
			
			if(arrTags[i].getAttribute("email")) 
				emails.push(arrTags[i].getAttribute("email")); 
			else if(arrTags[i].getAttribute("href")) {
				var arr = arrTags[i].href.match(/to\=(\S*)$/);
				if(arr[1]) emails.push(arr[1]);
			}	
			
		}
	}
	
	switch (tag_name) {
		case "I" : arrTagsI = arrTags; break;
		case "A" : arrTagsA = arrTags; break;
	}
	
	if(emails.length > 0) {
		mrimstatus_url = emails.join(","); 
		if (mrimstatus_url != '') return mrimstatus_url;
	}
	else return "";
}


function mrimstatus_callback(mrimstatus,error)
{
	var arrMrimStatus_callback = mrimstatus.split('');
	var arrMrimStatus_callbackL = arrMrimStatus_callback.length;
	for (var i = 0; i < arrTagsI.length; i++)
	{
		switch (arrMrimStatus_callback[i]) {
		case '1' :
			arrTagsI[i].className = 'f2_mrim_status f2_on';
			break;
		case '2' :
			arrTagsI[i].className = 'f2_mrim_status f2_left';
			break;
		default :
			arrTagsI[i].className = 'f2_mrim_status f2_off';
			break;
		}
	}
	
	for (var a = 0; a < arrTagsA.length; a++)
	{
		switch (arrMrimStatus_callback[i+a]) {
		case '1' :
			arrTagsA[a].className += ' mrim-online_9';
			break;
		case '2' :
			arrTagsA[a].className += ' mrim-away_9';
			break;
		default :
			arrTagsA[a].className += ' mrim-offline_9';
			break;
		}
	}
}

//login form
function f2_show_loginform(evt, prefix) {
	cancelBubbling(evt);
	if(typeof prefix == "undefined") pre = ""; else pre = prefix + "_";
	gebi(pre + "reg_new").style.display='none';
	if (navigator.userAgent.indexOf("Opera") != -1) {gebi(pre + "f2_domain").style.height='21px';}
	gebi(pre + "f2_loginform_new").onclick = cancelBubbling;
	gebi(pre + "f2_loginform_new").style.display='block';
	if (gebi(pre + "f2_41a"))  gebi(pre + "f2_41a").style.display='none';
	
	document.observe('click', f2_hide_loginform.bind(this,prefix));
	
	return false;
}
function f2_hide_loginform(prefix) { 
	if(typeof prefix == "undefined") prefix = ""; else pre = prefix + "_";
	if (gebi(pre + "f2_loginform_new")) gebi(pre + "f2_loginform_new").style.display = "none";
	if (gebi(pre + "reg_new")) gebi(pre + "reg_new").style.display='block';
	if (gebi(pre + "f2_41a")) gebi(pre + "f2_41a").style.display='block';
}

var __sgtTime;
function sgtlog(t){
        if(window['__sgt'] == true){
		var sgtconsole = document.getElementById('sgtconsole');
		if(!sgtconsole){
			var sgtconsole = document.createElement('div');
			sgtconsole.style.display = 'block';
			sgtconsole.style.position = 'absolute';
			sgtconsole.style.border = '1px solid black';
			sgtconsole.style.backgroundColor = '#eee';
			sgtconsole.style.top = '30px';
			sgtconsole.style.left = '10px';
			sgtconsole.style.fontSize = '10px';
			sgtconsole.style.width = '250px';
			sgtconsole.style.height = '400px';
			sgtconsole.style.overflow = 'auto';
			sgtconsole.style.zIndex = '2048';
			sgtconsole.style.fontFamily = 'Arial';
			sgtconsole.style.padding = '5px';
			sgtconsole.id = 'sgtconsole';
			document.body.appendChild(sgtconsole);
		}



		if(window['__sgtTime'] && __sgtTime != ''){
			var __internal = (new Date()).getTime() - __sgtTime;
			__sgtTime = (new Date()).getTime();
		} else {
		        __sgtTime = (new Date()).getTime();
		 	var __internal = '';
		}

		sgtconsole.innerHTML = '<span style="color: #999">' + ((new Date()).getTime()).toString().substr(8, 5) + ' </span> <b style="color: green">(+' + __internal + 'ms)</b>: ' + t + '<br />' + sgtconsole.innerHTML;
	}
}
