jQuery.noConflict();
(function($) {
    $(document).ready(function(){
	
	initMenu();
	
	$.fn.selectedmenu = function() 
	{
		$(this).attr("src","images/circle_arrow.gif");
		var hcontent = "<div style='text-align:center;width:95%;height:100%;'><img src='images/loading.gif' border=0 align=absmiddle></div>";
		 $("#search_professional_content").html(hcontent);
	}

	$.fn.normalmenu = function() 
	{
		$(this).attr("src","images/circle_arrow2.gif");
	}


	$("#featured_left_menu a").click(function () {
		$("#recently_pro_left_menu img").normalmenu();
		$("#top_searched_left_menu img").normalmenu();
		$("#recent_request_left_menu img").normalmenu();
		$("#featured_left_menu img").selectedmenu();
		$.get("featured_pro.php", function(data){
		  $("#right_container_width").html(data);
		});
	return false;	
	});
	$("#recently_pro_left_menu a").click(function () {
		$("#recent_request_left_menu img").normalmenu();
		$("#top_searched_left_menu img").normalmenu();
		$("#featured_left_menu img").normalmenu();
		$("#recently_pro_left_menu img").selectedmenu();
		$.get("recently_added_pro.php", { tabid: "recently_pro"}, function(data){
		  $("#right_container_width").html(data);
		});
	return false;	
	});
	$("#top_searched_left_menu a").click(function () {
		$("#recent_request_left_menu img").normalmenu();
		$("#recently_pro_left_menu img").normalmenu();
		$("#featured_left_menu img").normalmenu();
		$("#top_searched_left_menu img").selectedmenu();
		$.get("top_searched_professional.php", { tabid: "top_searched"}, function(data){
		  $("#right_container_width").html(data);
		});
	return false;	
	});
	$("#recent_request_left_menu a").click(function () {
		$("#recently_pro_left_menu img").normalmenu();
		$("#featured_left_menu img").normalmenu();
		$("#top_searched_left_menu img").normalmenu();
		$("#recent_request_left_menu img").selectedmenu();
		$.get("recent_request_pro.php", { tabid: "recent_request"}, function(data){
		  $("#right_container_width").html(data);
		});
	return false;	
	});

    });
})(jQuery);


function initMenu() {
  $('#umenu ul').hide("fast",function(){
	if($('#left_menu').val() == "1")
	{
	      var catid = $('#catid').val();
	      $("#cat_"+catid+" img").attr("src","images/arrow_down.png");    	
	     var checkElement = $("#cat_"+catid).next();
    	     checkElement.slideDown(250);
	}  
  });  

  $('#umenu li a').click(
    function() {
      var catstr = $(this).attr("id");	
      var temp = catstr.split("_");
      var catid = 0;
      var sub_catid = 0;	
      
      catid = temp[1];

	$(' [id^=cat_]').each(	
		function(intIndex){
			$("#"+this.id+" img").attr("src","images/arrow_right.png");
		}
	);

      $("#"+this.id+" img").attr("src","images/arrow_down.png");    	
      $("#menu_cont_"+catid+"_0").css("color","#4f4f4f");
	

	if(temp[0] == "menu" && temp[1] == "cont")
	{
		catid = temp[2];
		sub_catid = temp[3];
	}
	var hcontent = "<div style='text-align:center;width:95%;height:100%;'><img src='images/loading.gif' border=0 align=absmiddle></div>";
	
	if($("#ptype").val() == "O")
	{
		$("#placeholder_content").html(hcontent);
		$.get("category_opportunity.php",{'catid':catid,'sub_catid':sub_catid}, function(data){	
		  $("#right_container_width").html(data);
		});
	}
	else
	{
		$("#placeholder_content").html(hcontent);
		$.get("category_pro.php",{'catid':catid,'sub_catid':sub_catid}, function(data){	
		  $("#right_container_width").html(data);
		});
	}
      
	      var checkElement = $(this).next();

	      if((checkElement.is('ul')) && (checkElement.is(':visible'))) 
	      {
		return false;
	      }
	      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) 
	      {
		$('#umenu ul:visible').slideUp(250);
		checkElement.slideDown(250);
		return false;
	      }
      }
    );
  }

