var nextProjectId = 0;

Project = function(title, img, cat, _year) {
  
  this.id = nextProjectId++;
  this.name = title;
  this.imagesCount = img;
  this.category = cat;
  this.year = _year;    
  this.activeImage = 0; 
  this.aboutText = '';  
  
  loadText(this); 
  
  this.getPresentationHTML = function() {
    return '<li id="project' + this.id + '"><a href="javascript:switchPresentationProject(' + this.id + ')" onmouseover="javascript:hoverPresProject(' + this.id + ')" onmouseout="javascript:unhoverPresProject()"><span>' + this.name + '</span></a></li>';
  }
  
  this.getPortfolioHTML = function() {
    return '<li id="project' + this.id + '"><a href="javascript:switchPortfolioProject(' + this.id + ')" onmouseover="javascript:hoverProject(' + this.id + ')" onmouseout="javascript:unhoverProject()"><span>' + this.name + '</span></a></li>';                                       
  }
  
  this.getPresentationImgHTML = function() { 
    return '<img onclick="switchPresentationProject(' + this.id + ')" style="display: none; cursor: pointer" id="gallery' + this.id + '" src="images/projects/' + this.id + '/0.jpg" height="320" alt="Photo" />'; 
  }
  
  this.getProjectsHTML = function() {
    return '<li id="project' + this.id + '"><a href="javascript:switchProjectsProject(' + this.id + ')" onmouseover="javascript:hoverProjectsProject(' + this.id + ')" onmouseout="javascript:unhoverProjectsProject()"><span>' + this.name + '</span></a></li>';                                       
  }
  
  this.getGalleryHTML = function() {
    var html = '';
    for (var i = 0; i < this.imagesCount; i++) {
      html += '<img id="gallery' + i + '" src="images/projects/' + this.id + '/' + i +'.jpg" height="320" alt="Photo" style="display: ' + ((i == this.activeImage) ? 'block' : 'none') + '" />';
    }     
    if (this.category != 4) {
      html += '<div id="over-text"><div id="over-text-bg"></div><div class="in1" id="projtext' + this.id + '"><div class="in2">' + this.aboutText + '</div></div></div>';
    }
    return html;
  }
  
  this.getGallerySwitchHTML = function() {
    var html = '';
    for (var i = 0; i < this.imagesCount; i++) {
      html += '<a id="imgsw' + i + '" ' + ((i == this.activeImage) ? 'class="active" ' : '') + 'href="javascript:projects[' + this.id + '].switchImage(' + i + ')"><span>Image</span></a>';
    }
    return html;        
  }
  
  this.switchImage = function(index) {
    if (index == this.activeImage) { return; }
    $('#imgsw' + this.activeImage).removeClass('active');
    $('#imgsw' + index).addClass('active');
    $('#gallery' + index).animate({ opacity: 'show' }, 500);
    $('#gallery' + this.activeImage).animate({ opacity: 'hide' }, 500);    
    this.activeImage = index;    
    // sipky    
    portfolioArrows();
  }  
  
  // nacitanie obrazkov
  for (var i = 0; i < this.imagesCount; i++) {
    img = new Image();
    img.onload = nextItemLoaded;
	  img.src = 'images/projects/' + this.id + '/' + i +'.jpg';
	}
  
}
