//version 1 feb.15 8:26

(function(){
	
	var Dashboard = {
		
		fadeout: function(){
		
			//on click of dim section
			
			$('#dock-portal').removeClass('down');
			$('#dock-dim').removeClass('down');
			
			
			setTimeout(function(){
				
				$('#dock-portal').hide();
				$('#dock-dim').remove();
				
			},500);
			
				
		},
		
		init: function(e){
				
			//if dim doesn't exist yet
			if (!$('#dock-dim').length){
				

				$('body').append('<div id="dock-dim"></div>');
				
				
				$('#dock-dim').bind('click',Dashboard.fadeout);
						
				
/*
				$('<div id="dock-dim"></div>').appendTo($('body')).bind('click',function(){
		
					//on click of dim section
					
					$('#dock-portal').removeClass('down');
					$('#dock-dim').removeClass('down');
					
					
					setTimeout(function(){
						
						$('#dock-portal').hide();
						$('#dock-dim').remove();
						
					},500);
					
				
				});
*/
				
				
				
				
				
			}
		
			$('#dock-portal').show();
			
			setTimeout(function(){
			
				$('#dock-dim').addClass('down');
				$('#dock-portal').addClass('down');					

				
			},80);
			
			e.preventDefault();
			
		},
		
		
	}



































	var __init = function(){
		
/* 		$('head').append('<link rel="stylesheet" href="/dock/dock.css" media="screen,projection" type="text/css" />'); */

    var head  = document.getElementsByTagName('head')[0];
    var link  = document.createElement('link');
    link.rel  = 'stylesheet';
    link.type = 'text/css';
    link.href = 'http://stuartjmurphy.com/dock/dock.css';
    link.media = 'all';
    head.appendChild(link);

	
		$('body').append('<ul id="sjm-dock"><li id="dock-dashboard"><a href="#">Dashboard</a></li><li id="dock-facebook"><a href="http://facebook.com/pages/Stuart-J-Murphy/117428138325651" target="_blank">Facebook</a></li><li id="dock-twitter"><a href="http://twitter.com/vizlearning" target="_blank">Twitter</a></li></ul>');
	
		$('body').prepend('<div id="dock-portal" style="display:none;"><a class="isil" href="http://iseeilearn.com"><img src="http://stuartjmurphy.com/dock/isil.png"></a><a class="mathstart" href="http://mathstart.net"><img src="http://stuartjmurphy.com/dock/mathstart.png"></a><a class="mainstreet" href="http://mathstart.net/musical/"><img src="http://stuartjmurphy.com/dock/mainstreet.png"></a><a class="vizlearning" href="http://stuartjmurphy.com/vizlearning"><img src="http://stuartjmurphy.com/dock/vizlearning.png"></a><div class="sjm"><a href="http://stuartjmurphy.com/" target="_blank" class="home">Stuart J. Murphy</a><a href="http://stuartjmurphy.com/about" target="_blank" class="about">About Stuart</a><a href="http://stuartjmurphy.com/newsletter/" target="_blank" class="newsletter">Newsletter Archives</a><img src="http://stuartjmurphy.com/dock/sjm.png"></a></div></div>');
	
		
		$('a','#dock-portal').click(function(){
			$('#dock-dim').trigger('click');
		});
		
		
		$('a','#dock-dashboard').click(Dashboard.init);
		
		$(window).load(function(){
			$('#sjm-dock').show();
		});
		

	}













	if (typeof jQuery === "undefined"){
	
    var head  = document.getElementsByTagName('head')[0];
    var script  = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
    head.appendChild(script);


		if (script.addEventListener){
		
			script.addEventListener('load', __init, false);
		
		} else if (script.attachEvent){
		
			script.attachEvent('onload', __init);
		
		}

  } else {
  
  	__init();
  	
  }
	



	
	

})();
