window.addEvent('domready', function() {
//$('navbg').setStyle('opacity', '0.45');
//	$('navbs').setStyle('opacity', '0.4');
//	$('credit').setStyle('opacity', '0.4');

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

	// end nav
	
	// gallery 
		$$('.thumb').each(function(thm) {
			var h2afx = new Fx.Morph(thm, {
				wait: false,
				duration: 700,
				transition: Fx.Transitions.Sine.easeOut
			});
			thm.addEvent('mouseover', function() {
				h2afx.start({ 'border-color':'#e0c25a' });
			});
			thm.addEvent('mouseout', function() {
				h2afx.start({ 'border-color':'#222' });
			});
		});
	
		$$('.cover_thumb').each(function(cvthm) {
			var cvchildren = cvthm.getChildren();
			var cvtitle = cvchildren[0].getChildren();
			var cvborder = cvchildren[1].getChildren();
			var titfx = new Fx.Morph(cvtitle[0], {
				wait: false,
				duration: 700,
				transition: Fx.Transitions.Sine.easeOut
			});
			var borderfx = new Fx.Morph(cvborder[0], {
				wait: false,
				duration: 700,
				transition: Fx.Transitions.Sine.easeOut
			});
			cvthm.addEvent('mouseover', function() {
				titfx.start({'color':'#e0c25a'});
				borderfx.start({'border-color':'#e0c25a'});
			});
			cvthm.addEvent('mouseout', function() {
				titfx.start({'color':'#fff'});
				borderfx.start({'border-color':'#222'});
			});
		});

	//


	// contact page

	$$('.textinp').each(function(ta) {
		ta.addEvent('focus', function() {
			ta.addClass('textactive');
		});
		ta.addEvent('blur', function() {
			ta.removeClass('textactive');
		});
	});

	if($$('.email')) {
		$$('.email').each(function(em) {
			em.set('html', '<a href="mailto:david@bigwoodbuilders.com">david@bigwoodbuilders.com</a>');
		});
	}


		// contact page form
		if($('contactform')) {
			$('contactform').addEvent('submit', function(e) {
				$('msg').setStyle('opacity', '0');
				e.stop();
				var req = new Request({
				   url: $('contactform').action,
				   onSuccess: function(response){
						if(response == '1') {
							$('contactform').reset();
							$$('.semitrans').each(function(st) {
								st.removeClass('empty');
							});
							$('msg').set('html', '<br />Thank you, your message has been sent!');
						} else {
							$('msg').set('html', '<br />'+response);
						}

						new Fx.Morph($('msg'), {
							wait: false, 
							duration: 1000, 
							transition: Fx.Transitions.Quart.easeInOut,
							onComplete: function() {
							}
						}).start({ 'opacity': 1 }); 

				   }
				}).post($('contactform'));
			});
		}
		//
	//
});


