/*
 * Animation Helpers for Galposter Webpage
 * jQuery 1.5.x required! 
 * 
 * @author Marcin Wróbel
 * @company Loco Martinez
 * @date 2011-02-24 
 * @version 1.0
 * 
 * LICENSE - BSD
 *
 *
 */
 
var greenBox = function() {}
greenBox.prototype.init = function() {
	this.elements = [];
	this.active_element = null;
	this.delay = 350;
	this.maxWidth = 200;
	this.is_clicked = false;
	this.timeout = false;
	this.step = 1;
}
greenBox.prototype.width = function(width) {
	this.maxWidth = width;
}
greenBox.prototype.add = function(element) {
	var el = $(element);
	el.css('width', 0);
	this.elements.push(el);
}
greenBox.prototype.show = function(index) {
	this.active_element = index < 6 ? index-1 : 0;
	this.animate();
}
greenBox.prototype.animate = function() {
	var ignore = ignore ? ignore : false;
	for (var index in this.elements) {
		if (index != this.active_element) {
			this._hide(this.elements[index]);
		}
	}
	if (this.elements[this.active_element]) {
		this._show(this.elements[this.active_element]);
	}
}
greenBox.prototype._hide = function(el) {
	el.addClass('is_hiding').animate({width:0},this.delay);
}
greenBox.prototype._show = function(el) {
	el.removeClass('is_hiding').removeClass('hidden').addClass('is_visible').css('width', 0).animate({width:this.maxWidth},this.delay);
}
greenBox.prototype.auto = function(delay) {
	var delay = delay ? delay : 1000;
	if (this.is_clicked == false) {
		this.timeout = setTimeout(function() {
			if (animGB.active_element == 4) {
				this.step = -1;
			} else if (animGB.active_element == 0) {
				this.step = 1;
			}
			animGB.show(animGB.active_element + 1 + this.step);
			animBG.show(animGB.active_element + 1);
			myNav.select(animGB.active_element);
			animGB.auto(delay);
		}, delay);
	}
}
greenBox.prototype.resetAuto = function() {
	this.is_clicked = true;
	if (this.timeout) {
		clearTimeout(this.timeout);
	}
}


var greyBG = function() {}
greyBG.prototype.init = function(element) {
	this.element = $(element);
	this.previous_active_element = null;
	this.active_element = 0;
	this.delay = 1750;
	this.vertical_step = -446;
}
greyBG.prototype.show = function(index) {
	this.previous_active_element = this.active_element;
	this.active_element = index-1;
	this.animate();
}
greyBG.prototype.animate = function() {
	var position = this.vertical_step * this.active_element;
	this.element.animate({top:position},this.delay * Math.abs(this.previous_active_element - this.active_element));
}

var global_type = 'integrated';
var showProject = function() {}
showProject.prototype.init = function(element) {
	this.delay = 550;
	this.delay_column = 550;
	this.size = {
		bg: 741,
		box: 185,
		box_wide: 370
	}
	this.old_bg = $('#main_bg_project_old');
	this.bg = $('#main_bg_project_new');
	this.columns = $('#project_details_new .column_container .box.width_1');
	this.columns_wide = $('#project_details_new .column_container .box.width_2');
	this.side_menu = $('#side_menu');
	
	//$('.project_details .navigation .previous').click(function() { navigateProjects(-1, global_type); return false; });
	//$('.project_details .navigation .next').click(function() { navigateProjects(1, global_type); return false; });
	
	this.animate();
}
showProject.prototype.switchBG = function() {
	this.old_bg.attr('className', this.bg.attr('className'));
}
showProject.prototype.animate = function() {
	this.bg.css('width', 0).animate({ width:this.size.bg }, this.delay);
	this.columns.css('width', 0).animate({width:this.size.box}, this.delay_column);
	this.columns_wide.css('width', 0).animate({width:this.size.box_wide}, this.delay_column);
}
