


Interactive = Class.create();
Interactive.prototype = {
	initialize: function(knob, container) {
		this.visible = false;

		this.knob = knob;
		this.container = container;

		this.effect = null;

		if (this.knob) {
			this.knob.observe('click', this.onClick.bindAsEventListener(this));
		}
	},
	
	onClick: function() {
		if (this.visible) {
			this.effect = Effect.BlindUp(this.container);
		} else {
			this.effect = Effect.BlindDown(this.container);
		}

		this.effect.knob = this.knob;
		this.effect._finish = this.effect.finish;
		this.effect.finish = function() { this._finish(); this.knob.toggleClassName('interactive_knob_up'); }
		this.visible = ! this.visible;
	}
}


ServiceLightbox = Class.create();
ServiceLightbox.prototype = {
	initialize: function(anchor) {
		this.anchor = anchor;

		this.anchor.observe('click', this.onClick.bindAsEventListener(this));
	},

	onComplete: function() {
		$$('#servicesLightbox .footer a').each(function(e) {
			new ServiceLightbox(e);
		});

		$$('#servicesLightbox .close').each(function(e) {
			Event.observe(e, 'click', function() {
				$('servicesLightbox').remove();
			})
		});

		$('servicesLightbox').show();
	},

	onClick: function(evt) {
		Event.stop(evt);
		var lb = $('servicesLightbox');

		if (! lb) {
			lb = Element.extend(document.createElement('div'));
			lb.id = 'servicesLightbox';
			lb.hide();
			$('main_container').appendChild(lb)
		} else {
			lb.innerHTML = '';
		}

		var px = 365;
		var py = 312;

		lb.setStyle({left: px + 'px', top: py + 'px'});
		
		new Ajax.Updater(lb, this.anchor.href, { insertion: Insertion.Bottom, parameters: 'serviceLightbox=1', onComplete: this.onComplete });
	}
}


function initialize()
{
	new Interactive($('interactive_knob'), $('interactive_container'));

	$$('.structure_circle a, .services_teaser a').each(function(e) {
		new ServiceLightbox(e);
	});
}


Event.observe(window, 'load', initialize);
