jQuery(document).ready(function() {

	$(document).ready(function() {
	
		// add markup to container and apply click handlers to anchors
		$("#myform").submit(function(e){
	
			e.preventDefault();
			
			$("#text_keyword").html( $("#keyword").val() );
			$keyword = $("#site").val()+$("#keyword").val();
			$("#google").html(loading());
			$("#yahoo").html(loading());
			$("#live").html(loading());
			
			// send request
			$.post("/ranking.php", { uri: $("#uri").val(), keyword: $keyword, engine: "Google", market: $("#market").val(), active: $('#chk_google').is(':checked'), long: "1" },
				function(data){
					$("#google").html(data);
				});
			
			$.post("/ranking.php", { uri: $("#uri").val(), keyword: $keyword, engine: "Yahoo", market: $("#market").val(), active: $('#chk_yahoo').is(':checked'), long: "1" },
				function(data){
					$("#yahoo").html(data);
				});
			
			$.post("/ranking.php", { uri: $("#uri").val(), keyword: $keyword, engine: "Live", market: $("#market").val(), active: $('#chk_live').is(':checked'), long: "1" },
				function(data){
					$("#live").html(data);
				});
		});
		
		// not in top 1000
		$(".notin1000").live("click", 
			function(e){
				e.preventDefault();
				$(".help1000").fadeIn();
			}
		);
		$(".notin1000").live("mouseout", 
			function(e){
				e.preventDefault();
				$(".help1000").fadeOut();
			}
		);
	});
});
