var ajaxObjects = new Array();

function LogOut() {
	bo = document.getElementsByTagName('body');
	bo[0].style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)';
	bo[0].style.MozOpacity = '0.5';
	bo[0].style.opacity = '0.5';
	
	
	if (confirm('Are your sure you want to logout?')) {
		return true;
	} else {
		bo[0].style.filter = '';
		bo[0].style.MozOpacity = '1';
		bo[0].style.opacity = '1';
		
		return false;
	}
}
function CheckDiscard(frm) {
	if(frm.title.value !== '') {
		if (confirm("Your blog has not been saved yet.\r\nDiscard your blog?")) {
			return true;
		} else {
			return false;
		}
	}
	return true;
}
function CheckBlog(frm) {
	if(frm.title.value == '') {
		alert('Please enter a valid title to continue...');
		return false;
	}
	return true;
}

function addsmiley(code) { 
	var pretext = document.myform.post.value; 
	this.code = code; 
	document.myform.post.value = pretext + code; 
} 
function setBackground() {
	var bodyLeft = (document.getElementById("bodyWrapper").offsetLeft - 90);
	document.body.style.backgroundPosition = bodyLeft + "px 0px";
	
	setTimeout("setBackground()", 50);
}
function navBtnOff (img) {
	img.src = img.src.replace('_on','');
}
function navBtnOn (img) {
	img.src = img.src.replace('.gif','_on.gif');
}
function displayHQ(ajaxIndex) {
	var xml = ajaxObjects[ajaxIndex].response;
	document.getElementById('hqWaitMsg').style.display='none';
	var obj = document.getElementById('hqarchivebg');
	obj.innerHTML = xml;
}
function loadHQ() {
	var serverSideFile = '/latesthq.php';
	var ajaxIndex = ajaxObjects.length;
	document.getElementById('hqWaitMsg').style.display='block';
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = serverSideFile;
	ajaxObjects[ajaxIndex].onCompletion = function(){ displayHQ(ajaxIndex); };
	ajaxObjects[ajaxIndex].runAJAX();
}
function clearField(myfrm) {
	var frm = myfrm
	if (frm.txtlogin.value=="Username" || frm.txtpass.value=="Password") {
		frm.txtlogin.value="";
		frm.txtpass.value="";
	}
}
function registerField(myfrm) {
	var frm = myfrm
	if (frm.nick.value == "") {
		alert('You forgot to enter a nickname.');
		return false;
	}
	if(frm.pass.value=="") {
		alert('please enter a password');
		return false;
	}
	if(frm.email.value=="") {
		alert('You need to enter a proper e-mail address');
		return false;
	}
	if(frm.ver.value=="") {
		alert('Please repeat the verification number to continue.');
		return false;
	}
	return true;
}

function activateField(myfrm) {
	var frm = myfrm
	if (!frm.actblog.checked) {
		alert('You need to agree to our rules & terms before you can continue.');
		return false;
	} else {
		return true;
	}
}
setTimeout("setBackground()", 500);