function ajaxRequest(url,data) 
{
	var aj = new Ajax.Request(
		url, {
			method:'get',
			parameters: data,
			onLoading: function() { 
				var oResults = $('result' + storyNum)
//				oResults.style.border = "1px solid #ccc";
//				oResults.innerHTML = "<p><img src='indicator.gif' alt='loading' /> Casting Vote</p>";
			},
			onComplete: getResponse
		}
	);
}

/* ajax.Response */
function getResponse(oReq) 
{
	var oResults = $('result' + storyNum);
	oResults.style.border = "0";
	oResults.innerHTML = oReq.responseText;
	Effect.Pulsate('oResults'); //scriptaculous effect
}


var storyNum = 0;

/* Outdated. Vote for the unique story 
function pwn(inputBoxId)
{
	var inputVal = document.getElementById(inputBoxId).value;
	storyNum = inputVal.split("-")[0];
	ajaxRequest('http://www.celebritypwn.com/parsenew.php', 'val=' + inputVal);
}
*/
function pwn2(storyid, session)
{
	storyNum = storyid;
	ajaxRequest('/parsenew.php', 'val=' + session);
}

function bequiet(story)
{

	ajaxRequest('/bequiet.php', 'val=' + story);
}

function atrack(story)
{

	ajaxRequest('/atrack.php', 'val=' + story);
}

/* These two functions are for comment replies */
function rep(username, userid) {
	var replyUser = username;
	var replyID = userid;
  document.getElementById('commentreply').innerHTML = 'Replying to: ' + replyUser + ' <a href="javascript://" onclick="rep2()">(cancel)</a><input type="hidden" name="replyto" value="' + replyID +'">';
}
function rep2() {
  document.getElementById('commentreply').innerHTML = " ";
}

function clearme() {
  document.getElementById('clearme').innerHTML = '<img src="/images/asterisk_orange.png" alt="report story icon" title="report story icon" /> <span style="color: #666;">Reported.</span>';
}

function clearmeb() {
  document.getElementById('specialarea').innerHTML = 'Thanks, story has been updated.';
}