// JavaScript Document

$(document).ready( function() {
			$('body').vCenter();
			$(window).resize(function() { $('body').vCenter(); });
			
			$("a[rel='external']").addClass("externalLink").click(
			function() { 
				window.open($(this).attr("href")); return false;  // make rel="external" links open in new windows
			});
			
			if(jQuery.browser.msie) {
				if(parseInt(jQuery.browser.version) < 8) {
					  $("#copyContainer").hide().fadeIn("slow", function() {
								  this.style.removeAttribute('filter');
							  });
				}
				else { /* IE 8 doesn't like the filter fix */ }
			}
			else { // not IE
				$("#copyContainer").hide().fadeIn("slow");
			}
			
			$("#visibilityLink a").click(function() {
									var g = $("#copyContainer");
									var w = $("#visibilityLink a span");
									if(g.is(":hidden")) {
										if(jQuery.browser.msie) {
												if(parseInt(jQuery.browser.version) < 8) {
														g.fadeIn("slow", function() {
   																	this.style.removeAttribute('filter');
																});
												}
												else { /* IE 8 doesn't like the filter fix */
														g.fadeIn("slow");
												}
										}
										else { // not IE
											g.fadeIn("slow");
										}
										w.text("HIDE");
									}
									else {
										g.fadeOut("slow");
										w.text("SHOW");
									}
									return false;
							});
});

function fadeInSubNav() {
	if(jQuery.browser.msie) {
			if(parseInt(jQuery.browser.version) < 8) {
					$("#subNav").hide().fadeIn("slow", function() {
							this.style.removeAttribute('filter');
						});
			}
			else { /* IE 8 doesn't like the filter fix */ }
	}
	else { // not IE
			$("#subNav").hide().fadeIn("slow");
	}	
}

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);