/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */

document.write('<style type="text/css">.tabber{display:none;}<\/style>');


function removeArticle(Id,mgs_id,count_Id,count_detail_id,link_id,link_detail_id)
{ 	 
	//alert(Id);
	  
	 jQuery.ajax({
          type: "POST",
          url: "/articles/removesavedarticle",
                    data: "id=" + Id,
                                   
          success: function (msg) 
          {  
                if(msg.indexOf("|") != -1)
         	    {
					splitMsg = msg.split("|");	
					//$('#message_content'+Id).html(splitMsg[0]);
					var statusMsgContainer = $(mgs_id);
					  statusMsgContainer.html(splitMsg[0]);
					  statusMsgContainer.fadeIn("slow", function(){
									            setTimeout(function() {
									                _removeDisplayMessage(statusMsgContainer);
									            }, 2500);
									        });
				    
					 var _removeDisplayMessage = function(messageEl) {
				        $(messageEl).fadeOut("slow", function(){
				            $(this).html('');
				        });
				    }		
					
					$(link_id).html(splitMsg[1]);
					$(link_detail_id).html(splitMsg[1]);
					$(count_Id).html(splitMsg[2]);
					$(count_detail_id).html(splitMsg[2]);
				}
     	}
   	});	
}


function downrateArticle(Id,msg_id)
{ 	 
	 jQuery.ajax({
          type: "POST",
          url: "/articles/ratingdown",
                    data: "id=" + Id,
                              
          success: function (returnVal) 
         			{  
         				//jQuery('#message_contentdetail'+Id).html=="";
         				//jQuery('#message_contentdetail'+Id).html(returnVal);
         				var statusMsgContainerDetail = $(msg_id);
					  	statusMsgContainerDetail.html(returnVal);
					  	statusMsgContainerDetail.fadeIn("slow", function(){
									            setTimeout(function() {
									                _removeDisplayMessage(statusMsgContainerDetail);
									            }, 2500);
									        });
					 	var _removeDisplayMessage = function(messageEl) {
				        $(messageEl).fadeOut("slow", function(){
				            $(this).html('');
				        });
				    }	
         				//jQuery('#message_contentdetail'+Id).show(); 
     	  			}
   	});	 
}

function insertComment(Id)
{

 	 commentText = jQuery("#comment_text").val();
 	 if(commentText == '')
 	 {
 	 	alert("Please enter the comment.");
 	 	return false;
 	 }

	 jQuery.ajax({
          type: "POST",
          url: "/articles/postcomment",
          data: "article_id=" + Id + "&comment_text=" + commentText,
          success: function(returnVal)
         			{  
         				document.getElementById("comment_text").value = ""; 						
             			jQuery('#comments_content').html(returnVal);
                        jQuery('#comments_content').show();             			      
     	  			}
   	});	 
}

function insertScrap(Id)
{

 	 scrapText = jQuery("#scrap_text").val();
 	 if(scrapText == '')
 	 {
 	 	alert("Please enter the scrap.");
 	 	return false;
 	 }

	 jQuery.ajax({
          type: "POST",
          url: "/users/postscrap",
          data: "consumer_id=" + Id + "&scrap_text=" + scrapText,
          success: function(returnVal)
         			{  
         				//alert(returnVal);
         				document.getElementById("scrap_text").value = ""; 						
             			jQuery('#scrap_content').html(returnVal);
                        jQuery('#scrap_content').show();             			      
     	  			}
   	});	 
}
