
function layOutPage()
{
    var articles =  constructArticles();
    var ob = null;
    for(var i = 0; i < articles.length; i++)
    {
        ob = document.getElementById(getPressArticleId(i));
        ob.innerHTML = articles[i].toHtml();
    }            
}

function wrapInDiv(theClass, content)
{

    var str = "<div align=\"center\" class=\"";
    str += theClass;
    str += "\">";
    str += content;
    str += "</div>";
    return str;

}

function _toHtml()
{    

    var strurl = "<a href=\"";
    strurl += this.url;
    strurl += "\" target=\"_blank\" class=\"articleTitle\">";
    strurl += this.title;
    strurl += "</a>";
    
    var str = wrapInDiv("articleTitle", strurl);
    if(!isEmptyString(this.line2))
    {
        str += wrapInDiv("line2", this.line2);
    }
    if(!isEmptyString(this.author))
    {
        str += wrapInDiv("author", "by " + this.author);
    }
    if(!isEmptyString(this.publication))
    {
         str += wrapInDiv("publication", this.publication);
    }
    if(!isEmptyString(this.date))
    {
        str += wrapInDiv("date", this.date);  
    }       
    return str;
}

function _report()
{
    var str = this.title;
    var sep = ": ";
    str += "\n";
    str += "line2";
    str += sep;
    str += this.line2;
    str += "\n";
    str += "author";
    str += sep;
    str += this.author;
    str += "\n";
    str += "publication";
    str += sep;
    str += this.publication;
    str += "\n";
    str += "date";
    str += sep;
    str += this.date;
    str += "\n";
    str += "url";
    str += sep;
    str += this.line2;

    alert(str);
}



function getPressArticleId(indx)
{
    return BASE_PRESS_ARTICLE_ID + (indx + 1);
}

function isEmptyString(str)
{
    if(str == null) return true;
     if(str == undefined) return true;
    if(str == "") return true;
    return false;   
}


function testPressArticle()
{   
    var pic = new picture("500", "500", "Elegance 1", "01", "Elegance");
    pic.report();
}

// props constructor
function pressArticle(title, author, publication, date, url)
{
	// props
	this.title = title;
	this.author = author;
	this.publication = publication;
	this.date = date;
	this.url = url;
	this.line2 = "";
	
	//functions
	this.report = _report;
	this.toHtml =  _toHtml;

}

