jQuery(document).ready(function($)
{

	$(".expand").click(function() {
		if ($(this).parent().next(".post_area").is(":visible") == true) {
		    $(this).html("See More");
		} else {
			$(this).html("See Less");
		}
		$(this).parent().next(".post_area").slideToggle(250);
		return false;
	});
	
	$(".bp_media_expand").click(function(){
		$(this).slideUp(250);
		$(this).next(".bp_media_view").slideDown(250);
	})
	$(".bp_media_view_close").click(function(){
		$(this).parent().slideUp(250);
		$(this).parent().prev(".bp_media_expand").slideDown(250);
	})
	
	$("#subscribe_input").inputLabel("Enter email");
	$("#bp_popup").dialog({autoOpen: false, title: "Subscribe", buttons: { 
			"Ok": function() {
				$(this).dialog("close"); 
				$("#subscribe_input").attr("value","");
				$("#subscribe_input").inputLabel("Enter email");
	}}});

	$("#member_subscribe").submit(function() {
		var url = $("#member_subscribe").attr("url");
		//alert($("#member_subscribe").serialize());
		
		jQuery.post(url, $("#member_subscribe").serialize(),
				function(data){
					var output_id = $("#member_subscribe").attr("output_id");
					if (typeof output_id == 'undefined' || output_id == false) {
						output_id = "bp_popup";
					}
					if(output_id=="bp_popup") {
						$("#bp_popup").html(data);
						$("#bp_popup").dialog("open");
					} else {
						$("#"+output_id).html(data);
						$("#subscribe_input").attr("value","");
						$("#subscribe_input").inputLabel("Enter email");
					}
				},'html');
				return false;
	});						 				
	$("#bp_subscribe_button").click(function(){
		$("#member_subscribe").submit();
	});


	$(".bp_follow_expand").click(function(){
			$(".bp_follow_tab").hide();
			var tab = $(this).attr('tab');
			$("#"+tab).show();
			//$("#bp_follow_expansion").slideToggle(250);
			$("#bp_follow_expansion").slideDown(250);
			return false;
	});

	$(document).click(function() {
		$('#bp_follow_expansion').slideUp(250);
	});	

	$("#bp_follow_expansion .bp_follow_tab a").click(function(){
		document.location = $(this).attr('href');
	});	

	$("#bp_follow_expansion").click(function(){
		return false;
	});


});

