// JavaScript Document
function doGoogleSearch() {
	var terms = document.getElementById('SearchTerms').value;
	if((terms == 'Search RalphvandenBerg.com [powered by Google]') || (terms.length<1)) {
		alert('Please input valid search terms.');
		document.getElementById('SearchTerms').value = '';
		document.getElementById('SearchTerms').focus();
		return false;
	}
	else {
		// now submit google's seach.
		document.getElementById('google_search_box_q').value = terms;
		document.google_search_form.submit();
		return false;
	}
}
function checkLoginForm(thisform) {
	with(thisform) {
		if(email.value.length < 3) {
			alert('Please submit a valid email address for log in.');
			email.focus();
			return false;
		}
		else if(pass.value.length < 1) {
			alert('Please type in your password.');
			pass.focus();
			return false;
		}
		else return true;
	}
}
function toggleDisplay(field) {
	with(document.getElementById(field)) {
		if(style.display == 'none') {
			style.display = 'inline';
		}
		else style.display = 'none';
	}
}
function jumptoLogin() {
	scroll(0,0);
	document.getElementById('loginfield').style.display = 'inline';
	return false;
}
function checkConfCode(thisform) {
	with(thisform) {
		if(confirmcode.value.length<3) {
			return false;
		}
		else return true;
	}
}
function checkPWform(thisform) {
	with(thisform) {
		if(new_pw.value.length<5) {
			alert('Password must be atleast 5 characters long.');
			new_pw.value = '';
			new_pw_conf.value = '';
			new_pw.focus();
			return false;
		}
		else if(new_pw.value != new_pw_conf.value) {
			alert('Your passwords do not match. Please make sure you type them the same twice.');
			new_pw.value = '';
			new_pw_conf.value = '';
			new_pw.focus();
			return false;
		}
		else return true;
	}
}
function compare_pws() {
	if(document.forms.newpws.new_pw.value == document.forms.newpws.new_pw_conf.value) {
		document.getElementById('pw_match_ok').innerHTML = '<b>OK</b>';
	}
	else {
		document.getElementById('pw_match_ok').innerHTML = '';
	}
}
function getToPosting() {
	// check the input.
	var articleId = document.getElementById('articleid').value;
	var comment = document.getElementById('comment_box').value;
	if(comment.length < 2) {
		alert('Please type a substantial comment.');
		document.getElementById('comment_box').focus();
		return false;
	}
	// Ajax it:
	postOnRambling(articleId, comment);
}
function postWallcomment(wallId) {
	var comment = document.getElementById('wallcomment').value;
	if(comment.length < 2) {
		alert('Please type a substantial comment.');
		document.getElementById('').focus('wallcomment');
		return false;
	}
	// Ajax it:
	postOnWall(wallId, comment);
}
function responseAction(data) {
	document.getElementById('comment_area_div').innerHTML = data;
}
