var op_order = 'CreationDate';
var op_p = 1;
function makeComment(id) {
	var url = 'comment.php?id=' + id + '&comment_text=' + escape($('comment_text').value);
	ajaxLoad('news_comment', url, null, 'Sending comment...');
	/*new Ajax('comment.php', {
			 method: 'post',
			 data: $('comment'),
			 update: $('news_comment')
			 }).request();*/
	return false;
}
function setOrder(ord, id) {
	op_order = ord;
	opinionPage(op_p, id);
}
function nextQuestion(id) {
	var url = 'vote_next.php?id=' + id;
	ajaxLoad('poll_box', url, null, 'Fetching next poll');
}
function vote(id, qid, ai) {
	var url = 'vote_now.php?id=' + id + '&qid=' + qid + '&ai=' + ai;
	ajaxLoad('vote_panel', url);
	/*
	new Ajax('vote_now.php?id=' + id + '&qid=' + qid + '&ai=' + ai, {
			 method: 'get',
			 update: $('vote_panel')
			 }).request();*/
}
function voteLive(id, qid, ai) {
	var url = 'vote_live.php?id=' + id + '&qid=' + qid + '&ai=' + ai;
	ajaxLoad('poll_box', url, null, 'Posting vote');
}
function opinionPage(p, id) {
	op_p = p;
	var url = 'opinions.php?p=' + p + '&id=' + id + '&ord=' + op_order;
	ajaxLoad('div_opinions', url);
	/*new Ajax('opinions.php?p=' + p + '&id=' + id + '&ord=' + op_order, {
					method: 'get',
					update: $('div_opinions')
				}).request();*/
}
function opinionRate(p, id, oid) {
	op_p = p;
	var url = 'opinions.php?p=' + p + '&id=' + id + '&ord=' + op_order + "&oid=" + oid + "&action=rate";
	ajaxLoad('div_opinions', url);
	/*new Ajax('opinions.php?p=' + p + '&id=' + id + '&ord=' + op_order + "&oid=" + oid + "&action=rate", {
					method: 'get',
					update: $('div_opinions')
				}).request();*/
}
function opinionReport(p, id, oid) {
	op_p = p;
	var url = 'opinions.php?p=' + p + '&id=' + id + '&ord=' + op_order + "&oid=" + oid + "&action=report";
	ajaxLoad('div_opinions', url);
	/*new Ajax('opinions.php?p=' + p + '&id=' + id + '&ord=' + op_order + "&oid=" + oid + "&action=report", {
					method: 'get',
					update: $('div_opinions')
				}).request();*/
}
function isPasswordOK() {
	var f = document.getElementById('register');
	var alphaExp =  /^[a-zA-Z]+$/;
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	var alphaNumericExp = /^[0-9a-zA-Z]+$/;
	if (!f.password.value.match(alphaNumericExp)) {
		alert("Password can only contain letters and numbers");
		f.password.focus();
		return false;
	}
	if (f.password.value.length < 7) {
		alert("Password must be at least seven characters long");
		f.password.focus();
		return false;
	}
	f.submit();
	return true;
}
function isComplete() {
	var f = document.getElementById('register');
	var alphaExp =  /^[a-zA-Z]+$/;
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	var alphaNumericExp = /^[0-9a-zA-Z]+$/;
	if (!f.terms_ok.checked) {
		alert("You must agree to the terms and conditions to register");
		return false;
	}
	if (f.screen_name.value.length < 6) {
		alert("Screen name must be of six characters or more");
		f.screen_name.focus();
		return false;
	}
	if (!f.screen_name.value.match(alphaExp)) {
		alert("Screen name can only contain letters");
		f.screen_name.focus();
		return false;
	}
	if (!f.email.value.match(emailExp)) {
		alert("The format of your email address isn't correct");
		f.email.focus();
		return false;
	}
	if (!f.password.value.match(alphaNumericExp)) {
		alert("Password can only contain letters and numbers");
		f.password.focus();
		return false;
	}
	if (f.password.value.length < 7) {
		alert("Password must be at least seven characters long");
		f.password.focus();
		return false;
	}
	f.submit();
	return true;
}