// javascript method: "pxToEm"
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4($){k.9.7=5.9.7=4(a){3 b=p;2(b.j==5)b=d(b);2(!a)3 a=$(\'g\');2($(a).6()>0){3 c=b*(1/(d($(a).r("n-6"))))+\'m\';8 c}l 8\'i: o h q f s a e t\'}})(u);',31,31,'||if|var|function|String|size|pxToEm|return|prototype||||parseInt|DOM|is|body|scope|Error|constructor|Number|else|em|font|Provided|this|argument|css|not|element|jQuery'.split('|'),0,{}));


// hover fix plugin
/*jQuery.fn.fixHover.js : for all elements, add hover class on mouseover and remove on mouseout */
jQuery.fn.fixHover = function(){
	$(this).each(function(){
		var hoverClasses = ' hover';
		if($(this).attr('class')){		
			var classes = $(this).attr('class');
			var classArray = classes.split(' ');
			$(classArray).each(function(){
				hoverClasses += ' ' + this + 'Hover';
			});
		}
		$(this).hover(
		function(){
			if(classes) $(this).attr('class', classes + hoverClasses);
			else $(this).addClass('hover');
		},
		function(){
			if(classes) $(this).attr('class', classes);
			else $(this).removeClass('hover');
		}
		);
	});
}



// $(...).newWindow();
// open links in a new window on click, add a title attribute to tell the user it will open in a new window
jQuery.fn.newWindow = function(){
	$(this).click(function(){
		var newWindow = window.open(jQuery(this).attr('href'), '_blank').focus();
	    return false;
	});
	jQuery(this).attr('title', '* This link opens in a new window');
	return jQuery(this);
}


/*-------------------------------------------------------------------- 
 * JQuery Plugin: "EqualHeights"
 * by:
   Scott Jehl (scott@filamentgroup.com) 
   Todd Parker (todd@filamentgroup.com)
   http://www.filamentgroup.com
 *
 * Copyright (c) 2007 Filament Group
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Description: Compares the heights of the first-children of a provided element 
 								  and sets their min-height to the tallest height. Sets in em units by default if pxToEm() method is available.
 * Dependencies: jQuery library, pxToEm method								  
 * Usage Example: $(element).equalHeights();
   						      Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
 * Version: 1.0, 08.02.2007
 * Changelog:
 *  08.02.2007 initial Version 1.0
--------------------------------------------------------------------*/

$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
				if($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if(!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm($(this)); 
		//use ems unless px is specified or for ie6, set height since min-height isn't supported
		var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
		if ($.browser.msie && (ie6)) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return $(this);
};

document.documentElement.className = "js";


/* Screen Behavior */

$(function(){

/* hacky nav highlighting */
    var loc = window.location.href;
    
		//pop-up fades
		$('#jq-intro li').hover(
			function(){$(this).find('div.jq-checkpointSubhead:hidden').fadeIn(500);},
			function(){$(this).find('div.jq-checkpointSubhead:visible').fadeOut(500);}
		);

		//cta click
		$('#jq-intro li div p').click(function(){
			$(this).parent().prev().trigger('click');
		});

		//home snippet
		$('.jq-runCode').click(function(){
			eval($(this).parent().find('code').text());
			$(this).hide();
			return false;
		});

		//interior content box heights
		$('#jq-interior #jq-content').equalHeights();
		
});

