window.addEvent('domready', function() {
		
   var getnewcontent = function(newcontent){        
        //setup tween
        var tween = $('info').get('tween', {property: 'opacity'});
        //fade it away
        tween.start(0).chain(function(){
            // moving all the elements FROM result TO hiddencontent
            $('info').getChildren().inject( $('hiddencontent') );
            // moving the newcontent FROM its place (hiddencontent) TO result
            newcontent.inject($('info'));
            //show again
            tween.start(1);
        });
    };
	
	$$('.getportfolio1').addEvent('click', function() { 
		var myContent = document.id('portfolio1'); // OR var myPort = $('portfolio1');
		getnewcontent.run(myContent);
	});
	
	$$('.getcontact').addEvent('click', function() { 
		var myContent = document.id('contactme'); // OR var myPort = $('portfolio1');
		getnewcontent.run(myContent);
	});
	
	$$('.getabout').addEvent('click', function() { 
		var myContent = document.id('about');
		getnewcontent.run(myContent);
	});

	$$('a.nudge').set({
		'morph' : { duration: 200, link : 'cancel'},
		'events' : {
			'mouseenter' : function(){ this.morph({'padding-left' : 10, 'color' : '#000000'}); },
			'mouseleave' : function(){ this.morph({'padding-left' : 0, 'color' : '#999999'}); }
		}
	});
	
});


window.addEvent('domready', function() {
	var Tips2 = new Tips($$('.mbOverlay'), {
		initialize:function(){
			this.fx = new Fx.tween(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
});
	
 
window.addEvent('domready', function() {
    var myform = document.id('myForm');
    var name = document.id('name');
    var mail = document.id('mail');
    var check = document.id('check');
    var text = document.id('text'); //Here a little fix
    var bttn = document.id('bttn');
    myform.addEvent('submit',function(e) {
        e.stop();
        var myData = {
            'name':name.get('value').clean(),
            'mail':mail.get('value').clean(),
            'check':check.get('value').clean(),
            'text':text.get('value').clean()
        };
        var myReq = new Request.JSON({'url':'/inc/ajaxsendmail.php'});
        myReq.addEvent('request',function() { bttn.set('disabled',true).set('value','...'); });
        myReq.addEvent('success',function(feed,txt) {
            if (!feed) {

			var errortween = $('somethingiswrong').get('tween', {property: 'opacity'});
			//fade it away
			errortween.start(0).chain(function(){
				// moving all the elements FROM result TO hiddencontent
				document.getElementById("somethingiswrong").innerHTML = (txt);
				//show again
				errortween.start(1);
			});

            bttn.set('disabled',false).set('value','Verstuur opnieuw...');
            return 0; }
            if (feed.status == 1) {
            document.getElementById("somethingiswrong").innerHTML = "<strong>Jou informatie is verstuurd. Alvast bedankt.</strong>";
            } else {
            document.getElementById("somethingiswrong").innerHTML = "Er is een fout opgetreden, gelieve via een andere weg contact op te nemen.<!-- s:D -->";
            }
        });
        myReq.post(myData);
    });
   
});
