// PROJECT107 // global javascript
var current_id = 'main';

document.observe("dom:loaded", function() {						
  	// after everything is loaded up
	Cufon.replace('h1')('h2');
	Cufon.now();
	
	// the heart
	Effect.Grow('heart_icon', { duration: 4, transition: Effect.Transitions.spring });
	Effect.Appear('navigation', { delay: 1.5, duration: .5, afterFinish: function(){ navLink(current_id); } });
	
	//navLink(current_id);
	
	
});

function navLink(id){
	// fade out current content
	Effect.Fade('lower_content', { duration: .5 });
	Effect.Appear('loader', { delay: 0, duration: .8 });
	// hide the container so the new content fades in, not blinks in
	$('lower_content').setStyle({display: 'none'});
	
	// load the new content
	new Ajax.Updater('lower_content', 'page.php?id='+id, {evalScripts: true, onSuccess: secLoaded()});
	
	// for google analytics
	pageTracker._trackPageview("/"+id );
	
	// set current id
	current_id = id;
}

function secLoaded(){
	// clean up the viewport
	Effect.Fade('loader', { delay: 0, duration: .5 });
	Effect.Appear('lower_content', { delay: .5, duration: .2});
}


function dropOut(id){
	Effect.DropOut(id, { duration: 1, transition: Effect.Transitions.sinoidal });
	showStatus();
}

function showStatus(){
	Effect.Appear('contact_status', { delay: .5, duration: .5 });
}
function sendMail(id){
	$('send_bttn').disable();
	Effect.Fade('contact_status', { delay: 0, duration: 0 });
	new Ajax.Updater('contact_status', 'sendmail.php', { method: 'post', evalScripts: true, parameters: Form.serialize('email_form') });
}

function allowMail(){
	$('send_bttn').enable();
	
}

// for the bug reporting on the cod page
function sendBug(){
	Effect.Appear('loader');
	new Ajax.Updater('bug_report', 'bugreport.php', { method: 'post', evalScripts: true, parameters: Form.serialize('bugreport'), onSuccess: function(){ $('loader').Fade() } });
}