$(document).ready(function(){

	$('#home_ask_loading_img').hide();
	$('#askQuestionThanks').hide();
	$('#poll_result').hide();
	var articleoffset = 0;

	/* CONTENT LADDAR SCROLLING -----------------------------------------------------------------------------*/
	$('#next').click(function() {
		$('.ladder-container-strip').animate({left:-283}, 600);
		return false;
	});
	$('#prev').click(function() {
		$('.ladder-container-strip').animate({left:0}, 600);
		return false;
	});


	/* ASK A QUESTION SUBMISSION -----------------------------------------------------------------------------*/
	$('#askQuestionForm').submit(function() {
		var xname     = $('#xname').val();
		var xcity     = $('#xcity').val();
		var xtalent   = $('#xtalent').val();
		var xquestion = $('#xquestion').val();

		if ( xname == "" || xcity == "" || xtalent == "" || xquestion == "" || xquestion == "Enter your question here.") {
			alert("All fields required.")
		} else {
			$('#home_ask_loading_img').fadeIn();
			$.ajax({
				type: "GET",
				url: "submitQuestion",
				data: "xname="+ xname + "&xcity=" + xcity + "&xtalent=" + xtalent + "&xquestion=" + xquestion,
				success: function(del){
					$('#askQuestionForm').hide();
					$('#xname').val("");
					$('#xcity').val("");
					$('#xtalent').val("");
					$('#xquestion').val("Enter your question here.");
					$('#home_ask_loading_img').fadeOut();
					$('#askQuestionThanks').fadeIn();
				}
			});
		}
		return false;
	});
	$('#askAgain').click(function() {
		$('#home_ask_loading_img').fadeIn();
		$('#askQuestionThanks').hide();
		$('#askQuestionForm').fadeIn();
		$('#home_ask_loading_img').fadeOut();
		return false;
	});


	/* POLL SUBMISSION ----------------------------------------------------------------------------------------*/
/*
	$('#submitPoll').click(function() {
		$('#poll').hide();
		$('#poll_result').fadeIn();
		return false;
	});
*/

	$('#pollQuestion').submit(function() {
		var answer     = $('.pollQ:checked').val();
		$.ajax({
			type: "GET",
			url: "submitPoll",
			data: "answerid="+ answer,
			success: function(del2){
				$('#poll').hide();
				$('#poll_result').fadeIn();
			}
		});
		return false;
	});


	/* SPORTS INDEX PAGE SCROLLING -----------------------------------------------------------------------------*/
	$('#more_articles').click(function() {
		if ( articleoffset > articlelimit ) {
			articleoffset = articleoffset - 300;
			$('.article-strip').animate({top:articleoffset}, 600);
		}
		return false;
	});
	$('#backtotop').click(function() {
		$('.article-strip').animate({top:0}, 600);
		articleoffset = 0;
		return false;
	});

 });


function showMovie(id, autostart)
{
	var so = new SWFObject("http://sports.espn.go.com/broadband/player.swf?mediaId="+id+"&autoStart="+autostart+"&adminOverride=3269390&n8pe6c=4", "videoPlayer", "318", "261", "9.0.45", "#000000");
	so.addParam("wmode", "opaque");
	so.addParam("allowScriptAccess", "always");
	so.addParam("quality", "high");
	so.addParam("bgcolor", "#000000");
	so.write("player");
}

function clearText(field) {
	if (field.defaultValue == field.value) field.value = '';
	else if (field.value == '') field.value = field.defaultValue;
}
