function Project(id, element, orbit_data) {
	this.id = id;
	this.element = element;
	this.orbit_data = orbit_data;
		
	this.init();
	this.start_animation();
}

Project.prototype.init = function() {
	var orbits_data_array = this.orbit_data.split(",");
	
	this.cx = parseInt(orbits_data_array[0]);
	this.cy = parseInt(orbits_data_array[1]);
	
	this.width = parseInt(orbits_data_array[2]);
	this.height = parseInt(orbits_data_array[3]);
	
	this.e_width = this.element.getWidth();
	this.e_height = this.element.getHeight();
	
	this.rotation = parseInt(orbits_data_array[4]);
	
	this.speed = parseInt(orbits_data_array[5]);
	
	this.update_pos(0);
}

Project.prototype.start_animation = function() {
	// calculate random start position on the orbit
	this.angle = Math.round( Math.random()*360 );
	
	var oInstance = this;
	this.interval = setInterval(function(){oInstance.update_pos()}, this.speed);
}

Project.prototype.update_pos = function() {
	var pos = this.get_pos_on_orbit(this.cx, this.cy, this.width, this.height, this.rotation, this.angle);
	
	var x = pos.x + this.cx;
	var y = pos.y + this.cy;
	
	this.element.setStyle( { left: (x - this.e_width/2)+'px', top: (y - this.e_height/2)+'px' } );
	
	this.angle += 0.1;
}

Project.prototype.get_pos_on_orbit = function(cx, cy, width, height, rotation, angle) {
	width = width / 2;
	height = height / 2;
	
	var cosangle = Math.cos( this.deg2rad(rotation) );
	var sinangle = Math.sin( this.deg2rad(rotation) );
		
	var ox = width * Math.cos( this.deg2rad(angle) );
	var oy = height * Math.sin( this.deg2rad(angle) );
	
	var x = (ox * cosangle) - (oy * sinangle);
	var y = (ox * sinangle) + (oy * cosangle);
	
	return { x: Math.round(x), y: Math.round(y) }
}

Project.prototype.deg2rad = function(deg) {
	return deg * (Math.PI / 180);
}
