blog = {};


blog.followBlog = function (duid,listId){

		var dialogDiv = document.createElement("div");
		dialogDiv.id = "dialog_"+listId;
		dialogDiv.className='flora';
		htmlStr = "<div id='dialogMessage' style='margin-bottom: 10px;'>Would you like to follow this blog?</div>";
		htmlStr += "<div id='dialogContent' style='width: 200px; margin-bottom: 10px;'></div>";
		
		
		var scr = document.createElement("script");
			$(scr).attr("type","text/javascript");
		txtStr = "$('#optionalText').keyup(function(){$('.featuredUserTxt').text($('#optionalText').val());});";
		$(scr).text(txtStr);		
		$(dialogDiv).html(htmlStr);	
		dialogDiv.appendChild(scr);		
		var cs = document.getElementById("content");
		cs.appendChild(dialogDiv);
	
	
	/*
		url = "/api/circle.php?c=getMyLists";
		
		var selectObject = document.createElement("select");
			selectObject.id="pickCircle";
			$(selectObject).attr("name","pickCircle");
			
		var dialogContent = document.getElementById("dialogContent");
			dialogContent.appendChild(selectObject);
			
		$.getJSON(url,function(jsondata){
				$(jsondata.response).each(function(i,itemdata){
				
				var optionObj = document.createElement("option");
					$(optionObj).attr("value",itemdata.id);
					$(optionObj).text(itemdata.name);					
					selectObject.appendChild(optionObj);
				});
				

		});
		
			*/
		
		$("#dialog_"+listId).dialog(
			{
			width: 480,
			height: 300,
			buttons: { 
      		  "Ok": function() { 
      	      
      	      	var url = "/api/circle.php?c=follow&listId="+listId;

    				$.getJSON(url,function(data){
						$("#dialogMessage").text("You are now following this blog!");
						$(".ui-dialog-buttonpane button").hide();
						setInterval(function(){
						//console.log("redirect");	
							window.location="/myHome.php";
						
						},1000)

					}); 	      	
	      	       
      	/*      	
      	      	url = "/api/featured.php?c=setCircle&circleId="+circleId;
   	      	
      	      	var dialogFoo = $(this);
      	        	      	
      	      	$.getJSON(url, function(response){
      	      		 $(dialogFoo).dialog("close");
		      	      $(dialogFoo).remove();
      	      	});
      	  */    	
      	      	
      	      	
       		   }, 
       		 "Cancel": function() { 
          	  $(this).dialog("close"); 
          	  $(this).remove();
        	} 
  	  		}});

		
}