function news_footer(token, date, feedTitle, title) {
	document.write("<div style=\"height:0px;border:none;\" class=\"localNewsSource\"><img src=\"http://static.destakes.com/images/document.gif\" border=\"0\" align=\"top\"> "+feedTitle);
	document.write(" &nbsp;<img src=\"http://static.destakes.com/images/clock.gif\" border=\"0\" align=\"top\"> "+date);
	document.write(" &nbsp;<img src=\"http://static.destakes.com/images/share.gif\" border=\"0\" align=\"top\"> <a href=\"http://destakes.com/redir/"+token+"|"+title+"\" rel=\"shareit\" style=\"color:#888888\">Partilhar</a> ");
	document.write(" &nbsp;<img src=\"http://static.destakes.com/images/mail.gif\" border=\"0\" style=\"padding-bottom:0px;\"> <a style=\"color:#888888\;cursor:pointer\" onClick=\"email_news_form('"+token+"')\">Enviar por email</a>");
	document.write(" &nbsp;<a style=\"color:#888888\" href=\"http://www.destakes.com/comentarios/"+token+"\"><img src=\"http://static.destakes.com/images/comment.gif\" border=\"0\" align=\"top\">&nbsp;<span id=\"total_comments_"+token+"\"></span></a></div><br/>");
	document.write("<div class=\"email_news_div\" id=\"email_news_form_div_"+token+"\"></div>");
news_comments(token);
}

function email_news_form(id) {
	 $('#email_news_form_div_'+id).load('/email_news_form.php?token='+id);
	 $('#email_news_form_div_'+id).slideToggle('slow');
}

function news_comments(token) {
        var data = $.get('/comentarios/ajax/news_comments.php?token='+token, function(data){
           $("span#total_comments_"+token).html(data+"Comentário(s)");
        });
}

function flag_news_comment(id) {
	$.get('/comentarios/ajax/comment_flag.php?id='+id, function(data){
          /*alert("Data Loaded: " + data);*/
	  $("#comment-"+id).fadeOut("slow");
        });
}

function validate(formData, jqForm, options) {
    var form = jqForm[0]; 
    if (!form.name.value || !form.email.value) { 
        alert('Por favor, introduza o seu nome e o email de destino');
        if (!form.email.value) form.email.focus();
        if (!form.name.value) form.name.focus();
        return false; 
    } 
}

function toggle(what,where) {
        $("#"+what+"_iframe").attr({src: where});
	if ( $("#"+what).css("display") == "block") {
		$("#" + what).fadeOut("200");
	} else {
		$("#" + what).fadeIn("200");
	}
}


