function ViewLive(){
	var review = { 
		feed: jQuery("#feed_title").val(),
		status: "live"
		};
	jQuery.post("/livescores/modify/", review,
		function(response){
			//jQuery("#review_errors").empty();
			// evaluate the "success" parameter
			if(response.success == "True"){
				jQuery("#livescores").empty();
				jQuery("#livescores").prepend(response.html).slideDown();
			}
			else{
				jQuery("#review_errors").append(response.html);
			}
		}, "json");
}

function ViewFinished(){
	var review = { 
		feed: jQuery("#feed_title").val(),
		status: "finished"
		};
	jQuery.post("/livescores/modify/", review,
		function(response){
			//jQuery("#review_errors").empty();
			// evaluate the "success" parameter
			if(response.success == "True"){
				jQuery("#livescores").empty();
				jQuery("#livescores").prepend(response.html).slideDown();
			}
			else{
				jQuery("#review_errors").append(response.html);
			}
		}, "json");
}

function ViewUpcoming(){
	var review = { 
		feed: jQuery("#feed_title").val(),
		status: "upcoming"
		};
	jQuery.post("/livescores/modify/", review,
		function(response){
			//jQuery("#review_errors").empty();
			// evaluate the "success" parameter
			if(response.success == "True"){
				jQuery("#livescores").empty();
				jQuery("#livescores").prepend(response.html).slideDown();
			}
			else{
				jQuery("#review_errors").append(response.html);
			}
		}, "json");
}

function ViewAll(){
	var review = { 
		feed: jQuery("#feed_title").val(),
		status: "all"
		};
	jQuery.post("/livescores/modify/", review,
		function(response){
			//jQuery("#review_errors").empty();
			// evaluate the "success" parameter
			if(response.success == "True"){
				jQuery("#livescores").empty();
				jQuery("#livescores").prepend(response.html).slideDown();
			}
			else{
				jQuery("#review_errors").append(response.html);
			}
		}, "json");
}

function ViewSearch(){
		text = jQuery("#search_term").val(); // some preliminary checks
		if (text == "Search" || text.length > 15){
			alert("Enter a search term up to 15 characters.");
			return false;
		}
	var review = { 
		feed: jQuery("#feed_title").val(),
		status: "search",
		search_term: jQuery("#search_term").val()
		};
	jQuery.post("/livescores/modify/", review,
		function(response){
			//jQuery("#review_errors").empty();
			// evaluate the "success" parameter
			if(response.success == "True"){
				jQuery("#livescores").empty();
				jQuery("#livescores").prepend(response.html).slideDown();
			}
			else{
				jQuery("#review_errors").append(response.html);
			}
		}, "json");
}

// toggles visibility of "write review" link
// and the review form.
function slideToggleLivescoreHelpForm(){
	jQuery("#explanation").slideToggle();
	//jQuery("#explain").slideToggle();
}

function slideToggleLeftSidebarForm(){
	jQuery("#bet-school-topics").slideToggle();

}

function statusBox(){
	jQuery('<div id="loading">Loading...</div>')
	.prependTo("#main")
	.ajaxStart(function(){jQuery(this).show();})
	.ajaxStop(function(){jQuery(this).hide();})
}

function prepareDocument(){
	//prepare the search box
	//prepare product review form

	jQuery("#explanation").addClass('hidden')
	//jQuery("#bet-school-topics").addClass('hidden')

	jQuery("#explain").click(slideToggleLivescoreHelpForm);
	//jQuery("#bet-school").click(slideToggleLeftSidebarForm);

	jQuery("#live_games").click(ViewLive);
	jQuery("#finished_games").click(ViewFinished);
	jQuery("#upcoming_games").click(ViewUpcoming);
	jQuery("#all_games").click(ViewAll);
	jQuery("#search_for").click(ViewSearch);


	statusBox();
}

jQuery(document).ready(prepareDocument);
//jQuery(document).ready(alector);





