/**
 * One of the items that should be shown in a preview bar
 * @param String title
 * @param String introduction
 * @param String type (news, vacancy or project)
 * @param String imageSrc		Source of the thumbnail of the small image
 * @param String linkUrl		Url that the visitor is directed to after clicking on the item
 */
function PreviewItem(title, introduction, type, imageSrc, linkUrl) {

	/**
	 * The title of this preview item
	 * @var String
	 */
	var title;
	
	/**
	 * The introduction of this preview item
	 * @var String
	 */
	var introduction;

	/**
	 * The type of the preview item
	 * @var String
	 */
	var type;
	
	/**
	 * Source of the thumbnail of the small image
	 * @var String
	 */
	var imageSrc;
	
	/**
	 * Url that the visitor is directed to after clicking on the item
	 * @var String
	 */
	var linkUrl;
	
	//Set the item properties
	this.title = title;
	this.introduction = introduction;
	this.type = type;
	this.imageSrc = imageSrc;
	this.linkUrl = linkUrl;
	
	/**
	 * Creates a new container with this preview items' information
	 * @return HtmlElement		DIV element
	 */
	this.createContainer = function() {
		//Initialize the container
		var container = document.createElement('DIV');
		
		//Add image area to the container
		var imageArea = document.createElement('DIV');
		imageArea.className = 'image ' + this.type;
		container.appendChild(imageArea);
		
		//Add image thumbnail in image area
		var link = document.createElement('A');
		link.setAttribute('href', this.linkUrl);
		var image = document.createElement('IMG');
		image.setAttribute('src', imageSrc);
		link.appendChild(image);
		imageArea.appendChild(link);

		//Add whitebar to the container
		var whiteBar = document.createElement('DIV');
		whiteBar.className = 'whiteBar';
		container.appendChild(whiteBar);
		
		//Add the title to the container
		var title = document.createElement('H2');
		var link = document.createElement('A');
		link.setAttribute('href', this.linkUrl);
		link.innerHTML = this.title;
		title.appendChild(link);
		container.appendChild(title);
		
		//Add the introduction to the container
		var introduction = document.createElement('P');
		var link = document.createElement('A');
		link.setAttribute('href', this.linkUrl);
		link.innerHTML = this.introduction;
		introduction.appendChild(link);
		container.appendChild(introduction);
		
		return container;
	}
	
}
