Shadowbox.init();
var active;
var perm;
var dragTip;

/*window.addEvent('domready', function(){
	showTips();
	setActive('start',null);
	
	$('site_nav').getElements('.navlink').each(function(a){
		a.set('onclick',a);
	});
	
	$('interactive').setStyle('display','block');
		
	
	var aTip = new Tips($$('a'),{
		onShow: function(toolTip) {
			toolTip.tween('opacity',1);
			dragTip.hide();
		},
		onHide: function(toolTip) {
			toolTip.tween('opacity',0);
			dragTip.show();
		}
	});
	$$('a').store('tip:text','click');
	var dragTip = new Tips($$('.section_body'),{
		onShow: function(toolTip) {
			toolTip.tween('opacity',1);
		},
		onHide: function(toolTip) {
			toolTip.tween('opacity',0);
		}
	});
	$$('.section_body').store('tip:text','click & drag to move');
	
	var headerTip = new Tips($$('.section_body h1'),{
		onShow: function(toolTip) {
			toolTip.tween('opacity',1);
			dragTip.hide();
		},
		onHide: function(toolTip) {
			toolTip.tween('opacity',0);
			dragTip.show();
		}
	});
	$$('.section_body h1').store('tip:text','click to activate');
	
	var portfolioTip = new Tips($$('.portfolio_link'),{
		onShow: function(toolTip) {
			toolTip.tween('opacity',1);
			dragTip.hide();
		},
		onHide: function(toolTip) {
			toolTip.tween('opacity',0);
			dragTip.show();
		}
	});
	$$('.portfolio_link').each(function(image){
		image.store('tip:text','click to see...<br/><img src="_imgs/portfolio_thumbs/'+image.get('rev')+'.jpg"/>');
	});
	
	var bioTip = new Tips($$('.readbio'),{
		onShow: function(toolTip) {
			toolTip.tween('opacity',1);
			dragTip.hide();
		},
		onHide: function(toolTip) {
			toolTip.tween('opacity',0);
			dragTip.show();
		}
	});
	$$('.readbio').store('tip:text','click to expand');
	
	
	$('site_content').makeDraggable({
	     onStart:function(el){
	      $('site_content').setStyles({'opacity':'.3'});
	      hideTips(0)
	    },
	    onComplete:function(el){
	      $('site_content').setOpacity(1);
	      if($('site_content').getPosition().x !== 0)
	       $('site_content').tween('left',0);
	      if(!perm)
	          showTips()
	    }
	  });
	
	
	$$('.section_body h1').addEvent('click',function(e){
	 var parent = this.getParent('.section_body').get('id');
	 setActive(parent,null);
	 hideTips(1);
	});
	$$('.section_body').addEvent('click',function(e){
	 if(this.id !== active)
	  setActive(this.id,null);
	 hideTips(1);
	});
	
	$$('.bio').each(function(name){
		doneReading(name.id);
	});
	
	$('portfolio_nav').getElements('a').each(function(a){
		a.addEvent('click',function(el){
			$$('#create div.subsection').setStyle('display','none');
			$(this.get('text')).setStyle('display','block');
			$$('#portfolio_nav a').removeClass('active');
			this.addClass('active');
			
			setActive('create',null);
		});
	});
	
	$('closetips').setStyles({'display':'block','opacity':0});
	$('showtips').setStyles({'display':'block','opacity':0});
});
*/
function setActive(section, sub){
	if(sub){
		var dest = $(sub);
		var myFx = new Fx.Scroll2('wrapper',{duration: 1000,transition: Fx.Transitions.Quad.easeInOut,offset: {'y': -280}}).toElement(dest);
	}
	else{
		var dest = $(section);
		var myFx = new Fx.Scroll2('wrapper',{wait: false, duration: 1000,transition: Fx.Transitions.Quad.easeInOut,offset: {'x':-200,'y': -200}}).toElement(dest);
	}
	
	$$('.lg_type').removeClass('lg_type');
	$$('.dk_grey').removeClass('dk_grey');
	$$('.section_body').setOpacity(.3);
	$(section).addClass('dk_grey lg_type').setOpacity(1);
	active = section;
	
	pageTracker._trackPageview('/'+active);
}
function showTips(){

	if(Browser.Engine.trident)
		var bottom = -54;
	else
		var bottom = -1;
		
(function(){
	$('tips').tween('bottom',bottom);
	    $('showtips').tween('opacity',0);
	    $('closetips').tween('opacity',1);
	}).delay(800);

}
function hideTips(show){

	if(Browser.Engine.trident)
		var bottom = -108;
	else
		var bottom = -50;
		
	$('tips').tween('bottom',bottom);
	$('showtips').tween('opacity',1);
	$('closetips').tween('opacity',0);
	
	if(show && !perm)
	 showTips();
}
function readBio(name){
	var mySlide = new Fx.Slide(name).toggle();
	setActive('are',name);
}
function doneReading(name){
	var mySlide = new Fx.Slide(name).slideOut();
}
function showPortfolio(dest){
	var myFx = new Fx.Scroll('portfolio-wrapper',{duration: 1000,transition: Fx.Transitions.Quad.easeInOut}).toElement(dest);
	$('site_content').setOpacity(.5);
	$('site_nav').setOpacity(0);
	$('portfolio-wrapper').setOpacity(1);
	$('portfolio-wrapper').tween('left',0);
}

function readBio2(name)
{
	if(document.getElementById(name).style.visibility == 'visible')
	{
		document.getElementById(name).style.visibility = 'hidden';
		document.getElementById(name).style.height = '0';
	}
	else
	{
		document.getElementById(name).style.visibility = 'visible';
		document.getElementById(name).style.height = 'auto';
	}
	
}

function doneReading2(name){
	document.getElementById(name).style.visibility = 'hidden';
	document.getElementById(name).style.height = '0';
}

function adjustMenuDivs(){
  var df=document.getElementById('site_nav');
  df.style.left = 25;
  df.style.top = document.body.clientHeight-(parseInt(df.offsetHeight));
}

function displayPortfolio(name)
{
	document.getElementById('interactive').style.display = 'none';
	document.getElementById('interactiveLink').style.color = "#f80";
	document.getElementById('interactiveLink').style.textDecoration = 'underline';
	document.getElementById('branding').style.display = 'none';
	document.getElementById('brandingLink').style.color = "#f80";
	document.getElementById('brandingLink').style.textDecoration = 'underline';
	document.getElementById('other').style.display = 'none';
	document.getElementById('otherLink').style.color = "#f80";
	document.getElementById('otherLink').style.textDecoration = 'underline';
	document.getElementById(name).style.display = 'inline';
	document.getElementById(name+'Link').style.color = "#666";
	document.getElementById(name+'Link').style.textDecoration = 'none';
}

function displaySecretBox()
{
	var sbox = document.getElementById('secretBox');
	var shadow = document.getElementById('shadowBox');
	//alert(sbox.style.display);
	sboxLeft   = ((document.body.offsetWidth / 2) - 325);
	shadowLeft = ((document.body.offsetWidth / 2) - 325) + 10;
	sbox.style.left = sboxLeft + "px";
	shadow.style.left = shadowLeft + "px";
	shadow.style.width = "660px";
	//shadow.innerHeight = sbox.innerHeight;
	sbox.style.display = 'inline';
	shadow.style.display = 'inline';
}

function closeSecretBox()
{
	var sbox = document.getElementById('secretBox');
	var shadow = document.getElementById('shadowBox');
	sbox.style.display = 'none';
	shadow.style.display = 'none';
}