// dropdown
$(document).ready(function() {
	$(".dropdown dt a, #request_num, #message_num, #notification_num").click(function() {
		$(".dropdown dt a").not($(this)).removeClass("selected");

		var toggleId;
		if (this.id.indexOf('_num') > 0)
			toggleId = "#ul" + this.id.substr(0, 1);
		else
			toggleId = "#" + this.id.replace(/^dropdown/, "ul");

		$(".dropdown dd ul").not(toggleId).hide();
		$(toggleId).toggle();

		if (toggleId == '#ulr')
			$("#request_num").hide();

		if (toggleId == '#ulm')
			$("#message_num").hide();

		if (toggleId == '#uln')
			$("#notification_num").hide();

		if($(toggleId).css("display") != "none") {
			if (toggleId == '#ulr')
				$("#dropdownr").addClass("selected");

			if (toggleId == '#ulm')
				$("#dropdownm").addClass("selected");

			if (toggleId == '#uln')
				$("#dropdownn").addClass("selected");

			if (toggleId == '#ula')
				$("#dropdowna").addClass("selected");
		}
	});

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (!$clicked.parents().hasClass("dropdown") && !$clicked.parents().hasClass("notification_num")) {
			$(".dropdown dd ul").hide();
			$(".dropdown dt a").removeClass("selected");
		}
	});
});

$(document).ready(function() {
	// drop down request
	$("#dropdownr, #request_num").click(function() {
		$.ajax({
			url: 'ajax/dropdown_request.php',
			cache: false,
			dataType: 'html',
			type: 'GET',
			data: {},
			error: function() {
				
			},
			success: function(response) {
				$('#dropdown_request_loading').hide();
				$('#dropdown_request').html(response);
			}
		});
	});

	// drop down message
	$("#dropdownm, #message_num").click(function() {
		$.ajax({
			url: 'ajax/dropdown_message.php',
			cache: false,
			dataType: 'html',
			type: 'GET',
			data: {},
			error: function() {
				
			},
			success: function(response) {
				$('#dropdown_message_loading').hide();
				$('#dropdown_message').html(response);
			}
		});
	});

	// drop down newfeed
	$("#dropdownn, #notification_num").click(function() {
		$.ajax({
			url: 'ajax/dropdown_notification.php',
			cache: false,
			dataType: 'html',
			type: 'GET',
			data: {},
			error: function() {
				
			},
			success: function(response) {
				$('#dropdown_notification_loading').hide();
				$('#dropdown_notification').html(response);
			}
		});
	});

	// drop down account
	$("#dropdowna").click(function() {
		$.ajax({
			url: 'ajax/dropdown_account.php',
			cache: false,
			dataType: 'html',
			type: 'GET',
			data: {},
			error: function() {
				
			},
			success: function(response) {
				$('#dropdown_account_loading').hide();
				$('#dropdown_account').html(response);
			}
		});
	});
})

