Event.observe(window, 'load', function() {
	if (page == 'services') {
		initServices();
	} else if (page == 'portfolio') {
		initPortfolio();
	}
});

function initServices() {
	var serviceSections = document.getElementsByClassName('service-section');
	serviceSections.each(function(section) {
		section.style.display = "none";
	});
	
	
	var serviceLinks = document.getElementsByClassName('service-link');
	serviceLinks.each(function(link) {
		link.getElementsByTagName('a')[0].onclick = function() {
			if (this.parentNode.nextSibling.firstChild == null) {		
				new Effect.toggle(this.parentNode.nextSibling.nextSibling, 'blind', {
					afterFinish: function() {
						new Effect.ScrollTo(link, {
							offset: -20
						});
					}
				});
			} else {
				new Effect.toggle(this.parentNode.nextSibling, 'blind', {
					afterFinish: function() {
						new Effect.ScrollTo(link, {
							offset: -20
						});
					}
				});
			}
			return false;
		}
	});
}

function initPortfolio() {
	var items = $('portfolio-list').getElementsByTagName('li');
	for (var i = 0; i < items.length; i++) {
		item = items[i];
		item.getElementsByTagName('a')[0].onclick = function() {
			var link = this;
			new Effect.Puff(this.parentNode.getElementsByTagName('img')[0], {
				duration: 0.5,
				afterFinish: function() {
					window.location = link
				}
			});
			return false;
		}
	}
}
