function show_send_story_form() {
		
	divs = document.getElementById("story_container");
		
	AjaxRequest.get({
		'url':'ajax_stories/form_send_story.php'
		,'onLoading':function(req) 	{ /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess':function(req) 	{ divs.innerHTML = req.responseText; }
		,'onError':function(req) 	{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function show_story_list() {
		
	divs = document.getElementById("story_list_container");
		
	AjaxRequest.get({
		'url':'ajax_stories/list_stories.php'
		,'onLoading':function(req) 	{ /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess':function(req) 	{ divs.innerHTML = req.responseText; }
		,'onError':function(req) 	{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function do_send_story() {
		
	div_ok  = document.getElementById("story_container");
	div_err = document.getElementById("send_story_error");
	
	userid = document.getElementById("story_user_id").value;
	title  = document.getElementById("story_title").value;
	text   = document.getElementById("story_text").value;
		
	AjaxRequest.get({
		'url':'ajax_stories/do_send_story.php'
		,'userid': userid
		,'title':  title
		,'text':   text
		,'onLoading': function(req) { /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess': function(req) { 
			if ( req.responseText.indexOf('<table id="box_stories_head">') != -1 ) {
			    div_ok.innerHTML  = req.responseText;
			} else {
                div_err.innerHTML = req.responseText;
			}
        }
		,'onError':   function(req) { alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function do_story_vote(vote_for, voter) {

    if ( (typeof(vote_for)=='undefined') || (vote_for == 0) ) {
        return false;
    }
    if ( (typeof(voter)=='undefined') || (voter == 0) ) {
        return false;
    }
    
	AjaxRequest.get({
		'url':'ajax_stories/do_vote.php'
		,'vote_for': vote_for
		,'voter':    voter
		,'onLoading': function(req) { /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess': function(req) { 
			if ( req.responseText.indexOf('SUCCESS') != -1 ) {
			    show_story_list();
			}
        }
		,'onError':   function(req) { alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function do_story_vote_change(vote_for, voter) {
		
    if ( (typeof(vote_for)=='undefined') || (vote_for == 0) ) {
        return false;
    }
    if ( (typeof(voter)=='undefined') || (voter == 0) ) {
        return false;
    }

    AjaxRequest.get({
		'url':'ajax_stories/do_vote_change.php'
		,'vote_for': vote_for
		,'voter':    voter
		,'onLoading': function(req) { /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess': function(req) { 
			if ( req.responseText.indexOf('SUCCESS') != -1 ) {
			    show_story_list();
			}
        }
		,'onError':   function(req) { alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}
