window.addEvent('domready', function() {
	//nav

		$$('#nav li a').each(function(nl) {
			nl.addEvent('click', function() {
				$$('#nav li a').each(function(nl2) {
					nl2.removeClass('active');
				});
				nl.addClass('active');
			});
		});

	//

	// services
	if($('wwrapper')) {
		var wfx = new Fx.Morph($('wwrapper'), {
			wait: false,
			duration: 700,
			onComplete: function() {
				wfx.start({'opacity': '1', 'transition': 'Fx.Transitions.Expo.easeOut'});
			}
		});


		if(location.hash != '') {
			$$('.htoggle').each(function(hta) {
				hta.removeClass('active');
			});
			var thetoggle = $(location.hash.substring(1)).getParent().getChildren();
			thetoggle = thetoggle[0];
			thetoggle.addClass('active');
			var theli = $(location.hash.substring(1)).getChildren();
			if(theli) {
				thetext = theli.get('html');
				(function() { $('wwrapper').set('html', thetext); Cufon.replace('#wwrapper h3'); }).delay(700);
				wfx.start({'opacity': '0', 'transition': 'Fx.Transitions.Sine.easeOut'});
			}
		}

		// contact page email address 
			if($('emailreplace')) {
				$('emailreplace').set('html', '<a href="mailto:supercopy@gmail.com">supercopy@gmail.com</a>');
			}
		//
	
		$$('.htoggle').each(function(ht) {
			ht.addEvent('click', function(e) {
				e.stop;
				ht.blur();
				if(!ht.hasClass('active')) {
					$$('.htoggle').each(function(hta) {
						hta.removeClass('active');
					});
					ht.addClass('active');
					var parul = ht.getParent().getChildren().getChildren();
					var thetext = parul[1].get('html');
					(function() { $('wwrapper').set('html', thetext); Cufon.replace('#wwrapper h3'); }).delay(700);
					wfx.start({'opacity': '0'});
				}
			});
		});

		
	}
	//


});

