/*
 * dsquared: http://www.dsq.co.uk
 * author: Mark Bain - mb@dsq.co.uk
 * date: 2011/10/05
 * 
 */

news = function (id) {
    news.prototype.html(id);
}

news.prototype.html = function (id) {
    
    $.ajax ({
        async: false,
        url: "/latest_news.php",
        success: function (html) {
            var lastest_article = news.prototype.getArticles (html);
            lastest_article += "<br /><strong><a href=\"../latest_news.php/\">more ></a></strong>"
            $("#" + id).html(lastest_article);
            
            $("#" + id + " h3").css ({
                "font-size": "100%",
                "font-weight": "bold"
            });
            
            $("#" + id + " div").css ({
                "padding": "0px",
                "background-image" : "none",
                "border": "0"
            });
            
            $("#" + id + " img").css ({
                "width": "75px",
                "height": "75px"
            });
            
            
            if ($.browser.msie && $.browser.version.substr(0,1)==7) {
                $("#" + id + " p").css ({
                    width: "100px"
                });
                $("#" + id).css ({
                    "overflow":"hidden"
                });
                
                
            }
            
        }
    });
}

news.prototype.getArticles = function (html) {
    var article_first_pass = html.split("</article>");
    var article_second_pass = article_first_pass[0].split('<article style="clear: both; overflow: hidden;">');
    var section = article_second_pass[1].split("<br />");
    var text = section[0].replace("&amp;pound;", "&pound;");
    return text
}
