/* Tooltip
--------------------------------------------- */

//x = selector
//content = content
//attr = boolean to test if content is static or pulled from an attribute
var tooltip_handler_array = new Array();
function tooltip(x, content, attr)
{
	//Is it an attribute or not
	attr = attr || 'false';
	$('.tooltippopup').hide();
	var tooltip_id = x.substr(1).replace(/ /g, '-') + '_tooltip';
	$('body').append('<div class="popup tooltippopup" id="' + tooltip_id + '"></div>');
	var y = '#' + tooltip_id;
	
	$(x).live('hover', function() {
		if ($(y).css('display') != 'none') {
			/*$(y).animate({opacity: 0.0}, 500, function() {
				$(this).css('display', 'none');
			});*/
		} else {		
			//set general aligning of box up
			$(y).css('position', 'absolute')
			if (attr) $(y).html($(this).attr(content));
			else $(y).html(content)
			$(y).css('left',$(this).offset().left + 'px');
			$(y).css('top', $(this).offset().top + $(this).outerHeight() + 'px');
			if($(y).css('top') < 0) $(y).css('top',0);
				
			//display it
			$(y).css('display', 'block').stop().animate({opacity: 0.9}, 500);
		}
	});
	
	$('body').click(function(){
		$('.tooltippopup').hide();
	});
		
	return y;	
}

function goTo(param)
{
	window.location = '#/' + param;
}

function keepSlide(x) {
	var div = $(x);
	var div_ori = div.offset();
	$(window).scroll(function() {
		if (window.pageYOffset >= div_ori.top) {
			div.css({ position: 'fixed', top: 0	});			
			$('#nav_placeholder').show();
		} else {
			div.css('position', 'relative');			
			$('#nav_placeholder').hide();
		}		
	});	
}
/*
 * Konami Code For jQuery Plugin
 * Using the Konami code, easily configure and Easter Egg for your page
 * or any element on the page.
 *
 * Copyright 2011 8BIT, http://8bit.io
 * Released under the MIT License
 */
(function($){$.fn.konami=function(options){var opts=$.extend({},$.fn.konami.defaults,options);return this.each(function(){var masterKey=[38,38,40,40,37,39,37,39,66,65];var controllerCode=[];$(window).keyup(function(evt){var code=evt.keyCode?evt.keyCode:evt.which;controllerCode.push(code);if(controllerCode.length===10){var bIsValid=true;for(var i=0,l=masterKey.length;i<l;i++){if(masterKey[i]!==controllerCode[i]){bIsValid=false;}}
if(bIsValid){opts.cheat();}
controllerCode=[];}});});};$.fn.konami.defaults={cheat:null};})(jQuery);

