url='http://www.litediary.com/';
t=new Array(); t['cch']=new Array(); t['q']=new Array(); t['sh']=new Array();
qrs=0;

function xhc() {
xH=false;
if (!xH && typeof XMLHttpRequest != 'undefined') {xH = new XMLHttpRequest();}}

function upP() {response=xH.responseText;}

function gb(i) {return document.getElementById(i);}
function gs(i) {return gb(i).style;}
function xhq(q) {
xhc();
xH.open('post',url,true);
xH.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xH.setRequestHeader("Content-length", q.length);
xH.setRequestHeader("Connection", "close");
xH.send(q);
}

function ajax_auth(act) {
dark();
if (act==1) xhq('auth=true&login='+document.forms.login.elements.login.value+'&pass='+document.forms.login.elements.pass.value);
if (act==0) xhq('act=logout');
xH.onreadystatechange = function() {
	if (xH.readyState==4 && xH.status==200) {
	gc('act=index');
	}
	}
dark();
}

function addcomment(postid) {
var form=document.forms.commentform.elements
var q="act=admin&ajax=true&q=add&type=comment&postid="+postid+"&comment="+encodeURI(form.comment.value)
if (form.author.value!='false') xhq(q+"&registered=true");
if (form.author.value=='false') xhq(q+"&registered=false&name="+form.nickname.value+"&email="+form.email.value+"&url="+form.url.value);
xH.onreadystatechange = function() {
	if (xH.readyState==4 && xH.status==200) {
	gb('commentlist').innerHTML+=xH.responseText;
	form.comment.value='';
	if (gb('comments_num').innerHTML=='0') gs('commentlist').display='block';
	gb('comments_num').innerHTML++;
	}
	}
}

function ajax_changeset(n,v,i) {xhq("act=admin&ajax=true&q=changeset&name="+n+"&value="+v);}

function ajax_del(id,next,what) {
dark();
if (!next) next=false;
xhq("act=admin&ajax=true&q=delete&type="+what+"&id="+id);
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		if (next) gc('act=index');
	}
	}
if (what=='page') setTimeout("window.location=window.location",750);
if (!next && what=='post') {
if (gb('post-row-'+id)) gs('post-row-'+id).display='none';
if (gb('post-space-'+id)) gs('post-space-'+id).innerHTML='none';
if (gb('post-row2-'+id)) {gs('post-row2-'+id).display='none';
gb('post-row2-'+id).style.innerHTML='none';}
if (gb('latest-title-'+id)) {gs('latest-title-'+id).display='none';
gs('latest-title-'+id).innerHTML='none';}
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) gc('act=index');}
}
if (what=='link') gs('blogroll-link-id-'+id).display='none';
if (what=='comment') {
	gs('comm-'+id).display='none';
	gb('comments_num').innerHTML--;
	gb('comm-'+id).innerHTML='';
	if (gb('comments_num').innerHTML=='0') gs('commentlist').display='none';
	}
dark();
}

function gc(what) {
	query=what;
	setTimeout("if (typeof t['cch']['"+what+"']!='undefined') delete t['cch']['"+what+"']",3000);
	dark();
	xhq('contentonly=true&'+what);
	xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		upP();scrollTo(0,0);	window.location.hash='#'+query;qrs++;t['q'][qrs]=query;
		gb('general').innerHTML=response;
		dark();
		}
	}
}
function gcc() {gc(t['q'][qrs])}
function f5() {window.location.reload()}

function startedit(id) {
if (typeof t['edit-'+id]=='undefined') {
t['edit-'+id]=0;
xhq('ajax=true&act=admin&q=edit&type=post&id='+id);
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		upP();
		if (gb('entry-titlelink-'+id)) gb('entry-titlelink-'+id).rel='t';
		gb('entry-body-'+id).innerHTML=response;
		gb('entry-title-'+id).innerHTML="<input type='text' value='"+gb('entry-title-'+id).innerHTML+"' class='postformfield entrytitle' id='title-area-"+id+"'/>";
		gb('post-time-'+id).innerHTML="<input type='text' value='"+gb('post-time-'+id).innerHTML+"' id='posttime-area-"+id+"' class='posttime'/>  <a href='javascript://' onclick='checkposttimeformat("+id+");'>[?]</a>";
		t['edit-'+id]++;
		block=true;
		gb('entry-edit-'+id).focus();}
		}
		return true;
		}
if (typeof t['edit-'+id]!='undefined' && t['edit-'+id]>0) {
xhq('ajax=true&act=admin&q=edit&type=post&id='+id+'&posttime='+gb('posttime-area-'+id).value+'&title='+gb('title-area-'+id).value+'&text='+gb('entry-edit-'+id).value);
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		upP();
		gb('entry-body-'+id).innerHTML=response;
		gb('entry-title-'+id).innerHTML=gb('title-area-'+id).value;
		gb('post-time-'+id).innerHTML=gb('posttime-area-'+id).value;
		if (gb('entry-titlelink-'+id)) gb('entry-titlelink-'+id).rel='bookmark';
		delete t['edit-'+id];
		block=false;
		}
		}
		return false;
}
}

function sendprofileinfo() {
var f=document.forms.profile.elements;
xhq('act=account&q=edit&type=profile&publish=true&adm[nickname]='+f.adm_nickname.value+'&adm[email]='+f.adm_email.value+'&adm[url]='+f.adm_url.value+'&pass[0]='+f.pass0.value+'&pass[1]='+f.pass1.value);
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		gc('act=account&q=edit&type=profile');
	}
	}
}

function sh(id,set) {if (set) {if (typeof t['sh'][set]=='undefined') t['sh'][set]=new Array();if (gs(id).display!='none') {t['sh'][set]=false;gs(id).display='none';} else {if (gb(t['sh'][set]) && t['sh'][set]!=id) gs(t['sh'][set]).display='none';gs(id).display='block';if (id!=t['sh'][set]) t['sh'][set]=id;};} else {if (gs(id).display!='none') {gs(id).display='none';} else {gs(id).display='block';}}
}
function s(id) {gb(id)?gs(id).display='block':null;}
function h(id) {gb(id)?gs(id).display='none':null;}
function ccf(id) {
t['errs']=0;
(gb('comment').value!='' && gb('email').value!='' && gb('nickname').value!='') ? null : t['errs']++;
xhq('act=check&ajax=true&q=email&email='+gb('email').value)
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		upP();if (response!='1') t['errs']++;
			if (t['errs']==0) {addcomment(id);} else {return false;}
	}
	}
}
function checkposttimeformat(id) {
xhq('act=admin&ajax=true&q=posttimecheck&posttime='+gb('posttime-area-'+id).value);
xH.onreadystatechange = function() {
	if(xH.readyState==4 && xH.status==200) {
		upP();
		if (response=='1') {gb('posttime-area-'+id).className='correctvalue';ptv=true;} else {
			gb('posttime-area-'+id).className='incorrectvalue';ptv=false;}
	}
	}
}
function timedifcheck() {
var mydate=new Date;var a=mydate.getHours()-mydate.getUTCHours();var b='';
if (a>0) {b='+'+a;} else {b='-'+a;};if (a==0) b='';
if (confirm('Your timezone offset is GMT'+b+'. Would you like to set this timezone for this site?')) timedifset(a)
}
function timedifset(dif) {xhq('act=admin&ajax=true&q=settimedif&dif='+dif);xH.onreadystatechange=function() {if(xH.readyState==4 && xH.status==200) gcc()}}
function get_set_module(k) {
xhq('act=admin&ajax=true&q='+k+'&type=set');xH.onreadystatechange=function() {if (xH.readyState==4 && xH.status==200) {upP();s(k+'_area');gb(k+'_area').innerHTML=response;}}}
	function unset_module(k,d) {xhq('act=admin&ajax=true&q='+k+'&type=save&'+d);h(k+'_area');}

function mozWrap(ta, open, close) {
	var selLength = ta.textLength; var selStart = ta.selectionStart; var selEnd = ta.selectionEnd;
	if (selEnd == 1 || selEnd == 2) selEnd = selLength;
	var s1=(ta.value).substring(0,selStart);
	var s2=(ta.value).substring(selStart, selEnd)
	var s3=(ta.value).substring(selEnd, selLength);
	ta.value=s1+open+s2+close+s3;
	return;
}
function dark() {gs("wall").display=="none" ? gs("wall").display="block" : gs("wall").display="none";}
function wwl() {wlw=setInterval("if (window.location.hash!='#'+t['q'][qrs] && gs('wall').display!='block') {query=window.location.hash.replace('#','');if (typeof t['q'][qrs-1]!='undefined' && t['q'][qrs-1]==query) qrs=qrs-2; if (typeof t['q'][qrs+1]!='undefined' && t['q'][qrs+1]==query) qrs=qrs++; gc(query);}",18);}
t['q'][0]='act=index';if (!window.location.hash) window.location.hash='#act=index';wwl();
