var trans=[];for(var i=0x410;i<=0x44F;i++)trans[i]=i-0x350;trans[0x401]=0xA8;trans[0x451]=0xB8;var escapeOrig=window.escape;window.escape=function(str){if(str){var ret=[];for(var i=0;i<str.length;i++){var n=str.charCodeAt(i);if(typeof trans[n]!='undefined')n=trans[n];if (n<=0xFF)ret.push(n);}return escapeOrig(String.fromCharCode.apply(null, ret));}}
var imgload=new Image();

_ = function(id){return document.getElementById(id);}

var ent=function(event){e=event||window.event;if (e.keyCode==13) document.forms.rg.submit();}
var ps=function(event){e=event||window.event;if (e.keyCode==13) document.forms.rg.elements['pass'].focus();}

var chkload=false;
var speeds=false;
$(window).keydown(function(event){
	e=event||window.event;
	if(chkload == true && e.ctrlKey && e.keyCode == 39) {
		chkload=false;
		if(iE===false){
			load_page($(".right-icon").attr("rel"));
			document.location.hash=$(".right-icon").attr("rel");
			return false;
		}
	}
	
	if(chkload == true && e.ctrlKey && e.keyCode == 37) { 
		chkload=false;
		if(iE===false){
			load_page($(".left-icon").attr("rel"));
			document.location.hash=$(".left-icon").attr("rel");
			return false;
		}
	}
	if((e.ctrlKey && e.keyCode==39)||(e.ctrlKey && e.keyCode==37)) return false;
});
var vrab=true;var dStep=0.5;var dTime=1;var idshki="";
var Shown=function(idd){ vrab=false;
if ((cut-dStep)>0)
{	zamedl=zamedl-((zamedl/100)*3);
   	delta=(cut/100)*zamedl;
	cut-=(dStep+delta);
	wObj.style.height=Heightn-cut+"px";
	setTimeout(function () { Shown(idd); },dTime);
} else { wObj.style.height="auto"; vrab=true;	}
}

var Hiden=function(idd){
vrab=false;
if ((cut+dStep)<Heightn)
{	zamedl=zamedl-((zamedl/100)*3);
   	delta=((Heightn-cut)/100)*zamedl;
	cut+=(dStep+delta);
	wObj.style.height=Heightn-cut+"px";
	setTimeout(function(){Hiden(idd);},dTime);
} else {wObj.style.height=0+"px";vrab=true;if(onoff=="1"){cObj.className=class1;onoff=0;}}
}

function get_hesh(){return document.location.hash.replace("#","");}

$(document).ready(function(){
	set_menuz();
});	
function set_menuz(){
	$('.menuZ, .menuZa, .menuL, .menuLa').unbind();
	$('.menuZ, .menuZa, .menuL, .menuLa').click(function(){
			$(this).next().stop(false,false).slideToggle({
				duration:300, 
				easing:'easeOutQuad', 
				complete:function(){
					$(this).prev().attr('class',function(index, currentClass){
    					if(currentClass.length==5) return currentClass+"a";
						return currentClass.replace('a','');
  					});
				}
			});
	});
}
<!-- COOKIE -->
var url=document.domain.replace("www.","");
var setCookies=function(name,value,expires,path,domain,secure){var curCookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");document.cookie=curCookie;}
var deleteCookie=function(name){var domain=url;path="/";document.cookie=name+"="+((path)?";path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";var domain="www."+url;document.cookie=name+"="+((path)?";path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}
var setCookie=function(name,par){var now=new Date();now.setTime(now.getTime()+100*24*60*60*1000);setCookies(name,par,now,'/',url);setCookies(name,par,now,'/','www.'+url);}
var getCookie=function(name) {var cookie=" "+document.cookie;var search=" "+name+"=";var setStr=null;var offset=0;var end=0;if (cookie.length>0){offset=cookie.indexOf(search);if (offset!=-1){offset+=search.length;end=cookie.indexOf(";",offset);if (end==-1){end=cookie.length;}setStr=unescape(cookie.substring(offset, end));}}return(setStr);}
/////////
//var imgShow=function(){insrt();$('#imgView').css("visibility","visible");is();img_obj.style.display="block";imgSize();}
// OPAS
var it,it2,img_obj,iop;
var is=function(){img_obj=_('imgView');iop=(img_obj.style.opacity)?parseFloat(img_obj.style.opacity):parseInt(img_obj.style.filter)/100;if(iop<1){clearTimeout(it2);iop+=0.2;img_obj.style.opacity=iop;img_obj.style.filter='alpha(opacity='+iop*100+')';it=setTimeout(function(){is();},0);}}

var hideimg=function(){img_obj=_('imgView');iop=(img_obj.style.opacity)?parseFloat(img_obj.style.opacity):parseInt(img_obj.style.filter)/100;if(iop>0){clearTimeout(it);iop-=0.2;if(iop<0.1)iop=0;img_obj.style.opacity=iop;img_obj.style.filter='alpha(opacity='+iop*100+')';it2=setTimeout(function(){hideimg();},0);}else{img_obj.style.filter='alpha(opacity=\'0\')';img_obj.style.opacity='0';img_obj.style.visibility="hidden";img_obj.style.display="none";}}// getPageSize

var getPageSize=function(){
	var xScroll,yScroll;
	if(window.innerHeight&&window.scrollMaxY){
		xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;
		}else if(document.body.scrollHeight>document.body.offsetHeight){
			xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;
			}else{
				xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;
				}
	var windowWidth,windowHeight;
	if(self.innerHeight){
		windowWidth=self.innerWidth;windowHeight=self.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight){
			ModewindowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;
			}else if(document.body){
				ExplorerswindowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;
			}
if(yScroll<windowHeight){
	pageHeight=windowHeight;
	}else{
		pageHeight=yScroll;
		}
if(xScroll<windowWidth){
	pageWidth=windowWidth;
	}else{
		pageWidth=xScroll;
		}
		arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll);
		return arrayPageSize;
}


//window.onresize=function(){if(_('imgView'))if(_('imgView').style.display=="block")imgSize();}
//window.onscroll=function(){if(_('imgView'))if(_('imgView').style.display=="block")imgSize();}

////////////////////////
imgload.src="http://fotkai.ru/arrows-loader.gif";
var frmload=false;

var showloader=function(id){
if(frmload===true){	
frmload=false;
if(_('loader'))_('header').removeChild(_('loader'));
var nim=document.createElement("img");
nim.src="http://fotkai.ru/arrows-loader.gif";
nim.title="Идёт загрузка";
nim.id='loader';
nim.onload=_('header').appendChild(nim);
clk(id); 
}
}

var dshowloader=function(){_('header').removeChild(_('loader'));}
/////////////////////

var fadesh=fadesh1=true;
var im_obj; var ipim;
var clk=function(idc){
if(im_obj!=_('imgB') && ipim!=_('pimg')){
if(fadesh1==true){fadesh1=false;fadesh=false;
_('spdf').setAttribute('src','/msql/imgcom.php?img='+idc);
var opacity=1;
if(_('imgView').style.display!="block"){
obji=_('spd');
ipim=_('pimg');
ipim.style.filter='alpha(opacity=100)';
ipim.style.KhtmlOpacity=ipim.style.MozOpacity=ipim.style.opacity=opacity;
var timer=window.setInterval(function(){
 if((opacity-=0.1)<=0.6){fadesh=true;window.clearInterval(timer);}
 if(obji.filters){obji.filters.alpha.opacity=Math.round(opacity*100);ipim.filters.alpha.opacity=Math.round(opacity*100);}
 obji.style.KhtmlOpacity=obji.style.MozOpacity=obji.style.opacity=opacity;
 ipim.style.KhtmlOpacity=ipim.style.MozOpacity=ipim.style.opacity=opacity;
 },15);
}else{
im_obj=_('imgB');
im_obj.style.filter='alpha(opacity=100)';
var timer=window.setInterval(function(){
 if((opacity-=0.1)<=0.6){
//	 im_obj.setAttribute("src","/index/loader.gif");
//	im_obj.style.margin="50px";
	fadesh=true;window.clearInterval(timer);}
 if(im_obj.filters){im_obj.filters.alpha.opacity=Math.round(opacity*100);}
 im_obj.style.KhtmlOpacity=im_obj.style.MozOpacity=im_obj.style.opacity=opacity;
 },5);
}document.location.replace("#"+idc);
}else{setTimeout(function(){clk(idc);},20);}
}
}
var funcDomReady='';
function onDomReady(func) { // функция добавления события
        var oldonload = funcDomReady;
        if (typeof funcDomReady != 'function')
                funcDomReady = func;
        else {
                funcDomReady = function() {
                        oldonload();
                        func();
                }
        }
}

function reszzf(){
//document.getElementById('vkCom').setAttribute("src","javascript:reszz()");
//document.getElementById('vkCom').src="javascript:reszz()";
if(frmload===true){ 
	vkCom.reszz();
	} else {setTimeout(reszzf,10);}
}

var preld=function(n,p){
	var img=new Image();
	if(n) img.src=n;

	var img2=new Image();
	if(p) img2.src=p;
}

var aclk=function(){
if(fadesh==true){
_('picc').innerHTML=spdf.imjb;
//_('picc').style.margin="0px";
var op=0.6;
if(_('imgView').style.display!="block"){
_('spd').innerHTML=spdf.document.getElementById('get_cont').innerHTML;
setTimeout(reszzf,0);
obj1=_('spd');
ipim1=_('pimg');
ipim1.style.filter='alpha(opacity='+op*100+')';
var tmr=window.setInterval(function(){
 if((op+=0.1)>=1){img_obj=_('imgB');img_obj.style.filter='alpha(opacity=100)';img_obj.style.KhtmlOpacity=img_obj.style.MozOpacity=img_obj.style.opacity=1;window.clearInterval(tmr);fadesh1=true;}
 if(obj1.filters){obj1.filters.alpha.opacity=Math.round(op*100);ipim1.filters.alpha.opacity=Math.round(op*100);}
 obj1.style.KhtmlOpacity=obj1.style.MozOpacity=obj1.style.opacity=op;
 ipim1.style.KhtmlOpacity=ipim1.style.MozOpacity=ipim1.style.opacity=op;
 },10);
}else{ 
img_obj1=_('imgB');
img_obj1.style.filter='alpha(opacity='+op*100+')';
var tmr=window.setInterval(function(){
 if((op+=0.1)>=1){_('spd').innerHTML=spdf.document.body.innerHTML;_('pimg').style.filter='alpha(opacity=100)';fadesh1=true;fadesh=true;window.clearInterval(tmr);setTimeout(function(){reszzf()},600);}
 if(img_obj1.filters){img_obj1.filters.alpha.opacity=Math.round(op*100);}
 img_obj1.style.KhtmlOpacity=img_obj1.style.MozOpacity=img_obj1.style.opacity=op;
 },10);
}
}else{setTimeout(function(){aclk();},20);}
if(_('loader'))dshowloader();
chkload=true;
}

/// переменные GET из адресной строки
function $_GET(){
	var tmp=new Array();
	var tmp2=new Array();
	var param=new Array();
    var get=location.search; // строка GET запроса
	if(get!=''){
    	tmp=(get.substr(1)).split('&');//разделяем переменные
	    for(var i=0;i<tmp.length;i++){
    	    tmp2=tmp[i].split('=');//массив param будет содержать
        	param[tmp2[0]]=tmp2[1];//пары ключ(имя переменной)->значение
   		}    
//    var obj=document.getElementById('greq');//вывод на экран
//    for (var key in param){
//        alert(param['gl']);//сдесь мы получаем значение параметра  
//    }  
	return param;
	}    
   }
//////// Прелоад картинок  
(function($) {
  var cache = [];
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

///////////////// INDEX.PHP str=gl
function ViewDialog(){
	var dlg =  $('#picViewDialog'),
        picBlock = dlg.children('.picBlock'),
        picText = dlg.children('.picText'),
        pic = picBlock.children('.pic'),
		pic_= picBlock.children('.pic_'),
        minw = 300, 
		minh = 150;
	
    dlg.dialog({
        position: ['center', 'center'],
        width: 'auto',
        resizable: true,
			autoOpen: false/*,
			show: "blind",
			hide: "explode"*/
//		modal: true
    });
	dlg.parent().css({	
		'-webkit-box-shadow': '5px 5px 15px #000',
		'-moz-box-shadow': '5px 5px 15px #000',
		'box-shadow': '5px 5px 15px #000'
		});

    pic.load(function() {
		$(this).css('opacity','0.5');
/*        if (!dlg.dialog('isOpen'))
            return;*/
        picBlock.height(minh);
        dlg.dialog('option', 'width', 'auto');
        dlg.width(minw);
/*        var neww = Math.max(pic.width(), minw),
            newh = pic.height();*/
//		alert($(this).attr('w')+" | "+$(this).attr('h'));
        var neww = Math.max(pic.attr('w'), minw),
            newh = pic.attr('h');
		if(newh==1) return;
        var pan = {};
        if (neww > minw) {
/*			if(parseInt(dlg.parent().css("left"))-(neww-minw)/2>5) 
				pan.left = '-=' + (neww-minw)/2; 
				else
		    	pan.left=5;*/
			if(($(window).width())/2+$(window).scrollLeft()-neww/2>5) 
				pan.left = ($(window).width())/2+$(window).scrollLeft()-neww/2; 
				else
		    	pan.left=5;
		   }
        pan.top = Math.max(0, ($(window).height())/2+$(window).scrollTop()-newh/2-20);
        picBlock.stop(true,true).animate({ height: newh }, 'fast');
        dlg.parent().stop(true,true).animate(pan, 'fast');
		pic.click(function(){dlg.dialog('close')});
		pic_.click(function(){dlg.dialog('close')});
        dlg.stop(true,true).animate({'width': neww }, 'fast', function(){
			pic.stop(false,false).fadeIn('fast', function(){
				pic_.attr('src', pic.attr('src').replace(/.*(\/gl.*jpg).*/,"$1"));
			});
		});
		if(iE===true)$(".ui-dialog-titlebar").stop(true,true).animate({ width: neww }, 'fast');
//		pic_.attr('src', pic.attr('src').replace(/.*(gl.*jpg).*/,"$1"));
    });
	
	
    pic_.load(function() { 
		if(pic_.attr('src')=="" || pic_.attr('src')=="undefined") return;
		pic_.stop(false,false).fadeIn('slow',function(){
        var neww = Math.max(pic_.width(), minw),
            newh = Math.max(pic_.height(), minh);
        var newwo = Math.max(pic.width(), minw),
            newho = pic.height();
		if(newh==1) return;
		if(pic_.attr('src')=="")return;
        var pan = {};
//        if (neww > newwo) {
			if(($(window).width())/2+$(window).scrollLeft()-neww/2>5) 
				pan.left = ($(window).width())/2+$(window).scrollLeft()-neww/2; 
				else
		    	pan.left=5;
//		   }

        pan.top = Math.max(0, ($(window).height())/2+$(window).scrollTop()-newh/2-20);
        dlg.stop(false,false).animate({ width: neww }, 'fast');
        picBlock.stop(false,false).animate({ height: newh }, 'fast');
        dlg.parent().stop(false,true).animate(pan, 'fast');
		if(iE===true)$(".ui-dialog-titlebar").stop(false,false).animate({ width: neww }, 'fast');
		});
	});
    var reset = function() {
		dlg.dialog('close');
		if(iE===true)$(".ui-dialog-titlebar").css('width', minw-40);
		pic.fadeOut(1);
		pic_.fadeOut(1);
		pic_.css({'display':'none'});
		pic.css({'display':'none'});
		pic_.attr({
			'src' :"",
			'alt' : "",
			'title' : ""
		});
		picBlock.attr({
			'width' : minw,
			'height' : minh
		});
		pic.attr({
			'src' :"",
			'width' : minw,
			'height' : minh
		});
// index/blank.gif
        picText.text('');
        picText.width('');
        picBlock.height(minh);
        dlg.dialog('option', 'width', minw);
        dlg.dialog('option', 'height', 'auto');
        dlg.dialog('option', 'position', 'center');
		dlg.parent().css({
			left:($(window).width())/2+$(window).scrollLeft()-minw/2,
			top:($(window).height())/2+$(window).scrollTop()-minh/2
		})
//        dlg.width('auto');
//		dlg.stop(true,true);
    };
//	$.fx.speeds._default = "fast";
    $.fn.picViewDialog = function() {
	   	reset();
//		setTimeout(function(){
        dlg.dialog('option', 'title', this.html());
        picText.text(this.html());
		if(this.attr('img:width')>this.attr('img:height')) wmb=160; else wmb=120;
		pic.attr({
			'src' :"thmb_gl/timthumb.php?src=../"+this.attr('href')+"&w="+wmb+"&zc=1&q=90",
			'width' : this.attr('img:width'),
			'height' : this.attr('img:height'),
			'w' : this.attr('img:width'),
			'h' : this.attr('img:height')
		});
		pic.width(this.attr('img:width')).height(this.attr('img:height'));
		
		pic_.attr({'alt':this.html(), 'title':this.html()});
        dlg.dialog('open');
//	},0)

    };
}

/////// Первью альбомов в меню
var aimg=$.ajax();
function move_to_cur(id,e){
		x=Math.round(e.pageX-$(id).width()/2); 
		y=Math.round(e.pageY+$(id).height()+5);
		$(id).css({"left":x,"top":y});
}

function move_to_element(mov,el){
		var position = el.position();
		x=position.left+180;
		y=position.top;
		mov.css({"left":x,"top":y});
//		alert(mov.css("left"));
	}
	
function preload_albom_image(e,element){ 
	aimg.abort();
	$('<div class="alb_img"></div>').appendTo("body");
	
	move_to_element($(".alb_img"),element);

	$(".alb_img").fadeIn('slow');
//	alert(element.attr("href"));
	var url=element.attr("href").replace("http://fotkai.ru/","");
	aimg=$.ajax({
		url: '../msql/img.php'+url,
		cache: false, 
		type : 'get', 
		success: function(html,e){
			$(".alb_img").html(html);
			$(".alb_img img").load(function(){$(this).fadeIn("slow")});
			move_to_element($(".alb_img"),element);
			}
		});
	
}
$(document).ready(function(){
	uper_pos();
	$("#uper").addClass('uper');
	$("#uper").html('&uarr; НАВЕРХ &uarr;');
	$("#uper").click(function() {
		$("html,body").stop().animate({
      		scrollTop: 0
   		}, 1100 )
	})
$("#uper").hide(0);

$(window).resize(function(){uper_pos()});
var upx=140;
function uper_pos(){
		x=($(window).width()-900)/2+upx-$(window).scrollLeft();
		if(x<upx)x=upx-$(window).scrollLeft();
		$("#uper").css({"left":x});
}

var dsps=true;
var dsph=true;
$(window).scroll(function(){
uper_pos();
	if($(window).scrollTop()>900) {
		if(dsps) {
			dsps=false;
			dsph=true;
			$("#uper").stop(true, true).show('fast'); 
			} else {
				if(ie==true) $("#uper").stop(true, true).animate({top: '17'},100,function(){
					$(this).animate({top: '20'},400);
				});
			}
	}else { 
		if(dsph) {
			dsph=false;
			dsps=true;
			$("#uper").stop(true, true).hide('fast'); 	
			}	
	}
});
});
/*####  Easing ######
	swing,
	easeInQuad,		easeOutQuad,	easeInOutQuad,
	easeInCubic,	easeOutCubic,	easeInOutCubic,
	easeInQuart,	easeOutQuart,	easeInOutQuart,
	easeInQuint,	easeOutQuint,	easeInOutQuint,
	easeInSine,		easeOutSine, 	easeInOutSine,
	easeInExpo,		easeOutExpo, 	easeInOutExpo,
	easeInCirc,		easeOutCirc, 	easeInOutCirc,
	easeInElastic,	easeOutElastic,	easeInOutElastic,
	easeInBack,		easeOutBack,	easeInOutBack,
	easeInBounce,	easeOutBounce,	easeInOutBounce
*/
