$(document).ready(function(){
	$.ajax({
	   type: "GET",
	   url: "/webservice/ideas.php",
	   cache: false,
	   success: function(msg){
			$("#ideasWrapper").html(msg);
			$("#ideaContent").slideDown();
	   }
	 });
	 
	$.ajax({
	   type: "GET",
	   url: "/webservice/idea_form.php",
	   cache: false,
	   success: function(msg){
			$("#ideaFormWrapper").html(msg);				
	   }
	 });	 
	 
	 loadTopIdeas(1);
	 
})

function loadPage(pageIndex){
	$("#ideaContent").slideUp("slow",function(){
		$("#ideasWrapper").html('<?php echo $str_loading; ?>');
	});
	
	setTimeout("getPage(" + pageIndex + ")",1000)
}



function getPage(pageIndex){
	$.ajax({
	   type: "GET",
	   url: "/webservice/ideas.php",
	   data: "page=" + pageIndex,
	   cache: false,
	   success: function(msg){
			$("#ideasWrapper").html(msg);
			$("#ideaContent").slideDown();
	   }
	 });	
}

function loadTopIdeas(pageIndex){
	$("div#topIdeas").slideUp("fast", function(){
		$("div#topIdeasLoading").fadeIn();
		setTimeout("getTopIdeas(" + pageIndex + ")", 250);
	});
}

function getTopIdeas(pageIndex){
	$.ajax({
	   type: "GET",
	   url: "/webservice/top_ideas.php",
	   data: "page=" + pageIndex,
	   cache: false,
	   success: function(msg){
			$("div#topIdeasLoading").fadeOut("normal", function(){
				$("div#topIdeas").html(msg);
				$("div#topIdeas").fadeIn();					
			});
	   }
	 });	
}
