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

	$$('.revealed').hide();
	
	if ($('words_link') !== null) {
	var myImages = new Asset.images(['http://onwebtape.com/me/images/book_0.jpg', 
		'http://onwebtape.com/me/images/book_1.jpg',
		'http://onwebtape.com/me/images/book_2.jpg',
		'http://onwebtape.com/me/images/book_3.jpg',
		'http://onwebtape.com/me/images/book_4.jpg',
		'http://onwebtape.com/me/images/book_5.jpg',
		'http://onwebtape.com/me/images/book_6.jpg',
		'http://onwebtape.com/me/images/book_7.jpg',
		'http://onwebtape.com/me/images/book_8.jpg',
		'http://onwebtape.com/me/images/book_9.jpg',
		'http://onwebtape.com/me/images/book_0.jpg'], {
    	onComplete: function(){
        $('words_link').set('html','check it out! (all images loaded)');
    	}
	});
	}
	
	if ($('annie_link') !== null) { 
	var annieImages = new Asset.images(['http://onwebtape.com/me/images/annie_0.jpg', 
		'http://onwebtape.com/me/images/annie_1.jpg',
		'http://onwebtape.com/me/images/annie_2.jpg',
		'http://onwebtape.com/me/images/annie_3.jpg',
		'http://onwebtape.com/me/images/annie_4.jpg',
		'http://onwebtape.com/me/images/annie_5.jpg',
		'http://onwebtape.com/me/images/annie_6.jpg',
		'http://onwebtape.com/me/images/annie_7.jpg',
		'http://onwebtape.com/me/images/annie_8.jpg'], {
    	onComplete: function(){
        $('annie_link').set('html','check it out! (all images loaded)');
    	}
	});
	}

	//toggler
	if ($$('.revealer') === null) { return; }
	else { 
	$$('.revealer').addEvent('click', function(e){
		e.stop();
		
		var which=this.getProperty('rel');
		
		if($(which).isDisplayed()===true) { this.set('text','read more'); }
		else { this.set('text','read less'); }
		
		new Fx.Reveal($(which), {duration: 500, mode: 'vertical'}).toggle();
	});
	}
		
	//contact form
	if ($('contact') === null) { return; }
	else { 
	$('contact').addEvent('submit', function(e){
		e.stop();
		
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		
		var res=$('result');
		
		if(!filter.test($('email').value)){res.set('html', 'hey, that is not a real email address!');return false;}
		else {
			this.set('send', {onComplete: function(response) { res.set('html', response); }});
			this.send();
			}
		
	});
	}
	
	//download resume
	if ($('download') === null) { return; }
	else { 
	$('download').addEvent('click', function(e){
		e.stop();
		this.setStyle('background-position','0 -82px');
		(function(){var myURI = new URI('jMicklos_resume.pdf'); myURI.go();}).delay(500, this);
	});
	}
	
	if($$('.footer_detail')!=null){
	
	
		$$('#footer_links li').addEvents({
		    'mouseenter': function(){
		        this.getElement('.footer_detail').fade('in');
		    },
		    'mouseleave': function(){
		        this.getElement('.footer_detail').fade('out');
		    },
		    'click': function(){
		    	var a = this.getElement('a');
		    	a.getProperty('href');
		    	new URI(a).go();
		    }
		});
	}
	
	if($$('.ls_title')!=null){
				
		$$('.ls_title').each(function(el) {
				
			var toTween=el.getElements('a');
			
			el.addEvents({
				mouseenter: function() { toTween.tween('padding-left','20px'); },
				mouseleave: function() { toTween.tween('padding-left','0px'); }	
			});
		});
	
	}
	//$$('.ls_title').addEvent('mouseover',function(){
	
	//});
	
	if($(document.body).getElements('a[rel=mootube]')!==null) { var moostance = new Mootube({which:'mootube'}); }

});
