var open_menu_cat_id =-1;
var current_page = 1;
var max_page = -1;
$(function()
{
	
});
function close_browse(){
	//$("#browse_menu").slideUp("slow");
	$("#browse_menu").fadeOut("slow");
	open_menu_cat_id =-1;
	$("#browse_navigation a").css("color","#0A5F90");
	
}
function display_menu(cat_id,link, image, link)
{
	$("#browse_navigation a").css("color","#0A5F90");
	if($("#browse_menu").css("display") == "none")
	{
		$(link).css("color","red");
		$.post(
				"/ajax/cat_browse.ajax.php",
				"action=get_category_table&cat_id="+cat_id+"&link="+link+"&image="+image,
				function(data){
					$("#browse_menu").html(data);
					//$("#browse_menu").slideDown("slow");
					$("#browse_menu").show();
				open_menu_cat_id = cat_id;
				},
				"html"
				);

	}
	else
	{
		//its already showing slide it up then start loading other thing
		if(open_menu_cat_id == cat_id)
		{
			//$("#browse_menu").slideUp("slow"); 
			$("#browse_menu").hide("slow");
			
			return;
		}
		else
		{
			$(link).css("color","red");
			$.post(
				"/ajax/cat_browse.ajax.php",
				"action=get_category_table&cat_id="+cat_id+"&link="+link+"&image="+image,
				function(data){
					$("#browse_menu").html(data);
					//$("#browse_menu").slideDown("slow");
					$("#browse_menu").show();
				open_menu_cat_id = cat_id;
				},
				"html"
				);
				
			/*$("#browse_menu").slideUp("slow",
			function()
			{

				
				
			});*/
		}
		
	}
}
function get_browse_page(sort_by, cat_id, page)
{
	$("#browse_section").fadeOut("slow",function(){
		
		$(this).html("<br><br><center><img src='images/loading.gif'></center>").fadeIn("slow");
		current_page = page;
		$.post(
		"/ajax/cat_browse.ajax.php",
		"action=get_browse_page&cat_id="+cat_id+"&page="+page+"&sort_by="+sort_by,
		function(data){
			$("#browse_section").fadeOut("slow",function(){
			$(this).html(data).fadeIn("slow");
		});
		},
		"html"
		);
	});
	
	
}
function next_page(sort_by,cat_id)
{
	current_page++;
	get_browse_page(sort_by, cat_id, current_page);
}
function prev_page(sort_by,cat_id)
{
	current_page--;
	get_browse_page(sort_by, cat_id, current_page);
}