// Rafal.Sienkiewicz@eti.pg.gda.pl

	function ImageDesc(pSrc, pFullSrc, pAlt, pTitle) {
		this.src = pSrc;
		this.fullSrc = pFullSrc;
		this.alt = pAlt + " (click on the picture to view full size)";
		if (pTitle) {
			this.title = pTitle ;
		} else {
			this.title = " "
		}		
		
		this.cacheImg = new Image();
		this.cacheImg.src = pSrc;
	}
	
	function ImageList(pId, pImagesDescArr, pImageWidth) {
			this.pId = pId;
			this.pImagesDescArr = pImagesDescArr;			
			this.currentIndex = 0;
			this.maxSize = 3;
			this.toHTML = toHTML;
			this.moveLeft = moveLeft;
			this.moveRight = moveRight;
			this.initialize = initialize;
			this.maxLeft = maxLeft;
			this.maxRight = maxRight;
			this.imageWidth = pImageWidth;
			this.enlarge = enlarge;
			this.fixNavigation = fixNavigation;
	}
	
	function enlarge(pImageSrc) {
		window.open(pImageSrc, "Preview");
	}
	function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

	function getWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

	function toHTML() {
		var pHTML = "";
		for (i=this.currentIndex; i<this.pImagesDescArr.length && i<(this.currentIndex + this.maxSize); i++) {
			pHTML = pHTML + "<div style='float: left'>"
			pHTML = pHTML + "<img src='" + this.pImagesDescArr[i].src + "' alt='" +  this.pImagesDescArr[i].alt + "' ";		
			pHTML = pHTML + " style='cursor: pointer' onclick='enlarge(\"" +  this.pImagesDescArr[i].fullSrc + "\")' ";
			var currentWidth = ((getWidth() - 72)* 0.9 / this.maxSize);
			if (currentWidth > 0.5 * this.imageWidth && currentWidth < this.imageWidth) {
				pHTML = pHTML + " width = '" + currentWidth  + "' ";
			} else if (currentWidth <= 0.5 * this.imageWidth) {
				pHTML = pHTML + " width = '" + (0.5 * this.imageWidth) + "' ";
			} else {
				pHTML = pHTML + " width = '" + this.imageWidth + "' ";
			}
			pHTML = pHTML + ">&nbsp;";
			pHTML = pHTML + "<div style='align: center'>" + this.pImagesDescArr[i].title + " (" + (i+1) + "/" + this.pImagesDescArr.length + ")</div>";
			pHTML = pHTML + "</div>";
		}
		
		document.getElementById(this.pId).innerHTML = pHTML;
		this.fixNavigation();
	}
	function maxRight() {
		if (this.pImagesDescArr.length < this.maxSize) {
			return 0;
		} else {
			return this.pImagesDescArr.length - this.maxSize;			
		}	  
	}
	
	function maxLeft() {
		return 0;
	}
	
	function fixNavigation() {
		if (this.currentIndex == this.maxLeft()) {
			document.getElementById(this.pId+'Left').style.visibility='hidden';
		} else {
			document.getElementById(this.pId+'Left').style.visibility='';
		}
		if (this.currentIndex == this.maxRight()) {
			document.getElementById(this.pId+'Right').style.visibility='hidden';
		} else {
			document.getElementById(this.pId+'Right').style.visibility='';
		}	
	}
	
	function moveLeft() {
		this.currentIndex = this.currentIndex-1;	
		var pMaxLeft = this.maxLeft();
		if (this.currentIndex < pMaxLeft) {
			this.currentIndex = pMaxLeft;
		}
		
		this.toHTML();		
	}
	function moveRight() {
		this.currentIndex = this.currentIndex+1;
		var pMaxLeft = this.maxLeft();
		if (this.currentIndex > this.maxRight()) {
			this.currentIndex = this.maxRight();
		}
		this.toHTML();
	}
	
	function initialize() {
		  var pHTML = "";
		  var pAllowSwitch = (this.maxRight() > 0)
		  
		  pHTML = pHTML + "<div id='" + this.pId + "Left' style='float: left; valign: center;' ";
			if (!pAllowSwitch) {
				 pHTML = pHTML +  " style='visibility: hidden' ";
			}
			pHTML = pHTML + "><span onclick='" + this.pId + ".moveLeft()'>" ;
			pHTML = pHTML + "<img src='left.PNG'";

			pHTML = pHTML + "></span>&nbsp;";
			pHTML = pHTML + "</div>";
			
			pHTML = pHTML + "<div id='" + this.pId + "' style='float: left'></div>";
			
			pHTML = pHTML + "<div id='" + this.pId + "Right' style='float: left; valign: center;'";
			if (!pAllowSwitch) {
				 pHTML = pHTML +  " style='visibility: hidden' ";
			}			
			pHTML = pHTML + "><span onclick='" + this.pId + ".moveRight()'>" ;
			pHTML = pHTML + "<img src='right.PNG'";
			
			pHTML = pHTML + "></span>";
			pHTML = pHTML + "</div>";
			
			document.write(pHTML);
			this.toHTML();	  
	}
	
	function Publication(pId, pAuthor, pYear, pTitle, pInfo, pUrl, pAbstract) {
		this.id = pId;
		this.author = pAuthor;
		this.year = pYear;
		this.title = pTitle;
		this.info = pInfo;
		this.url = pUrl;
		this.abstract = pAbstract;
		
		this.toHTML = pubToHtml;
	}
	
	function switchVisibility(pId) {
	pObj = document.getElementById(pId);
	if (pObj.style.display == 'none') {
			pObj.style.display = '';
		} else {
			pObj.style.display = 'none';
		}
	}
	
	function pubToHtml() {
		  var pHTML = "";
		  pHTML = pHTML + "<div id='" + this.id + "' >";
		  pHTML = pHTML + this.author;
		  pHTML = pHTML + ", " + this.year;		 
		  pHTML = pHTML + ", <i>"
		  
		  pHTML = pHTML + this.title;
		  pHTML = pHTML + "</i>, "
		  pHTML = pHTML + this.info;
		  if (this.url) {
			pHTML = pHTML + ", <a href='" + this.url + "' target='_blank'>Link</a>";
		  }
		  if (this.abstract) {
			pHTML = pHTML + ", <a href='#' ";
			pHTML = pHTML + " onclick='switchVisibility(\"" + this.id + "Abstract\" )'";
			pHTML = pHTML + ">Abstract</a>";
		  }
		  pHTML = pHTML + ", <a href='digihive.bib' target='_blank'>Bibtex</a>";
		  pHTML = pHTML + "</div>";
		  if (this.abstract) {
			pHTML = pHTML + "<div id='" + this.id + "Abstract' style='padding-bottom: 5px; padding-top: 5px; display: none;'>";
			pHTML = pHTML + this.abstract;
			pHTML = pHTML + "</div>";
			
		  }
		  document.write(pHTML);
	}
	
	
	function PubList(pArr) {

		this.publications = pArr;
		this.toHTML = pubListToHTML;
	}
	
	function  pubListToHTML() {

		document.write("<ol>");
		for (i=0; i<this.publications.length; i++) {
			document.write("<li style='padding: 5px;'>");
			this.publications[i].toHTML();
		}
		document.write("</ol>");
	}
	
	
	
	var pPubArr = new Array();
	var pCurrentIndex = 0;
	pPubArr[pCurrentIndex++] = new Publication('sienkiewicz2010Thesis', 'Sienkiewicz R.', '2010', 'The particle methods for simulation of emergent phenomena', 'PhD thesis, Gdańsk University of Technology, Gdańsk, Poland');

	pPubArr[pCurrentIndex++] = new Publication('sienkiewicz2009Experiments', 'Sienkiewicz R.', '2009', 'Experiments with the Universal Constructor in the DigiHive Environment', 'Artificial Life: Borrowing from Biology, 4th Australian Conference, ACAL 2009, Melbourne, Australia, December 1-4, 2009, LNAI 5865, pp. 106-115', 'http://www.springerlink.com/content/y286815033t45282/', 'The paper discusses the performance and limitations of the universal constructor embedded in the DigiHive environment and presents the results of two simulation experiments showing the possibility of workaround the limitations.');

	
	pPubArr[pCurrentIndex++] = new Publication('sienkiewiczJ2009Constructor', 'Sienkiewicz R., Jędruch W.', '2009', 'The universal constructor in the DigiHive environment', 'Proceedings of 10th European Conference on Artificial Life, ECAL 2009, Budapest, Hungary, LNCS  5778, pp. 178-186', '', 'The paper describes an universal constructor model realized in artificial environment called DigiHive. The environment is a two dimensional space, containing stacks of hexagonal tiles being able to moving, colliding, and making bonds between them. On the higher level of organization a structure of tiles specifies some function whose execution affects other tiles in its neighborhood. After short description of the DigiHive the paper describes design of an universal constructor and discusses possibilities of simulating self-replicating strategies in the environment.');

	pPubArr[pCurrentIndex++] = new Publication('jedruchS2008Modelowanie', 'Jędruch W., Sienkiewicz R.', '2008', 'Modelowanie systemów samoreprodukujących się', 'Metody informatyki stosowanej, 16(3):135—147 (in Polish)', 'http://pan.wi.ps.pl/pliki/MetInfStos/MetInfStos_2008_03.pdf', 'The paper describes a self-replicating system realized in the artificial world model, DigiHive. The model is a two dimensional space in which there are stacks of hexagonal tiles which are moving, colliding, and making bonds between them. On the higher level of organization a structure of tiles specifies some function whose execution affects other tiles in its neighborhood.');
	
	pPubArr[pCurrentIndex++] = new Publication('sienkiewicz2007Language', 'Sienkiewicz R.', '2007', 'A new language in an artificial life environment', 'D. Rutkowska (Eds.): PD FCCS 2007: 3rd Polish and International PD Forum-Conference on Computer Science, Smardzewice-Łódź, Poland (in Polish)', 'http://www.fccs.wshe.lodz.pl/fccs2007/artykuly/sienkiewicz.pdf', 'In the fields of artificial life, artificial chemistry or swarm intelligence there are proposed abstract environments for modelling of emergence phenomena and self-organization processes. Usually the environments consists of a large number of entities,  which move and collide according to rules like those of classical mechanics. At a higher level of organization the entities  interact between themselves according to functions encoded in their internal structure. The functions can emerged spontaneously as the result of collision of entities. The way of coding such functions - the language, has large influence on properties of the  environments. Described in the paper the new language of the DigiHive environment, shows new ideas of the construction and way of encoding of environment languages.');

	pPubArr[pCurrentIndex++] = new Publication('sienkiewicz2007Environment', 'Sienkiewicz R., Jędruch W.', '2007', 'An artificial environment for Ssimulation of emergent Behaviour', 'Adaptive and Natural Computing Algorithms: 8th International Conference, ICANNGA 2007, Warsaw, Poland, April 11-14, 2007, Proceedings, Part I, LNCS 4431, pp. 386-393', 'http://www.springerlink.com/content/u20l7026l7g22662/', 'The paper presents an artificial world model in which various self-organization and self-modification processes could be simulated. The model is a two dimensional space in which there are stacks of hexagonal tiles which are moving, colliding, and making bonds between them. On the higher level of organization a structure of tiles specifies some function whose execution affects other tiles in its neighborhood. Functions encoded in the structures of tiles are expressed in the simple Prolog-like language. Few examples illustrate the behavior of the system.');
	
	pPubArr[pCurrentIndex++] = new Publication('jedruchS2007Iteligencja', 'Jędruch W., Sienkiewicz R.', '2007', 'Inteligencja zespołowa', 'Kowalczuk Z., Wiszniewski B (Eds.), Inteligentne wydobywanie informacji w celach diagnostycznych, PWNT, Gdańsk, Poland (in Polish)', '', 'Artykuł stanowi próbę przeglądu i usystematyzowania zadań zarysowujacych się nowych kierunków sztucznej inteligencji dotyczących działań zespołowych. W szczególności zespołowej optymalizacji, zespołowego wydobywania i przetwarzania informacji oraz podejmowania decyzji, a także modelowania zjawisk samoorganizacji i emergencji charakterystycznych dla procesów biologicznych. W drugiej części artykułu omówione jest przykładowe środowisko dla modelowania zjawisk, w których współdziałanie wielu prostych jednostek prowadzi do powstawania złożonych struktur.');
	
		pPubArr[pCurrentIndex++] = new Publication('jedruchS2006Modelowanie', 'Jędruch W., Sienkiewicz R.', '2006', 'Modelowanie indywiduowe', 'Aplikacje rozproszone i systemy internetowe, Kask Book, pp. 241-252, Gdańsk University of Technology, Gdańsk, Poland (in Polish)', '', '');
	
		pPubArr[pCurrentIndex++] = new Publication('knitter2006', 'Knitter S.', '2006', 'Badanie dynamiki systemów samoreprodukujących się w sztucznym środowisku', 'Master\'s thesis, Gdańsk University of Technology, Gdańsk, Poland (in Polish)', '', '');

		pPubArr[pCurrentIndex++] = new Publication('sienkiewicz2006Report', 'Sienkiewicz R., Jędruch W.', '2006', 'The universe for individual based modelling', 'Tech. Report 11/2006/ETI, Gdańsk University of Technology, Gdańsk, Poland', '', '');		
	
	pPubArr[pCurrentIndex++] = new Publication('sienkiewiczJ2004Organization', 'Sienkiewicz R., Jędruch W.', '2004', 'Self-organization in an artificial environment', 'Proceedings of an VI International Conference on Artificial Intelligence AI-19\'2004, Nr 23, pp 81-88, Siedlce, Poland', '', '');	
	var pPubList = new PubList(pPubArr);	