jQuery.fn.extend({
	$defined: function(object) {
		return (object != undefined);
	},
	name: function(index) {
		index = index || 0;
		return this[index].nodeName;
	},
	preloadImages: function() {
		for (var i = 0; i < arguments.length; i++) {
			jQuery("<img>").attr("src", arguments[i]);
		}
	}
});

var tres = {
	populated_center_content : "image",
	previous_center_content : "image",
	load_img: function(arg1){
		var this_arry = ($(arg1).contents(1));
		var this_src = $(this_arry[1]).attr("src");
		var new_src = this_src.replace("thmb","full");
		new_src = new_src.replace("jpg","png");
		var temp_src = $("#center_content_1").html();
		this.previous_center_content = this.populated_center_content;
		$("#center_content_2").replaceWith("<div id=\"center_content_2\">"+temp_src+"</div>");
		this.populated_center_content = "image";
		$("#center_content_1").replaceWith("<div id=\"center_content_1\"><img width=\"1175\" height=\"420\" src=\""+new_src+"\"/></div>");
		$("#center_content_2").fadeOut("slow");
		_gaq.push(['_trackEvent', 'TsunamiMenu', new_src]);
	},
	menu_img: function(arg1){
		var temp_src = $("#center_content_1").html();
		tres.previous_center_content = this.populated_center_content;
		$("#center_content_2").replaceWith("<div id=\"center_content_2\">"+temp_src+"</div>");
		if(arg1 == "home"){
			tres.populated_center_content = "image";
			$("#center_content_1").replaceWith("<div id=\"center_content_1\"><img src=\"images/full/o01.jpg\" width=\"1175\" height=\"420\"></div>");
			tres.swap_eyes('blank_out');
		}else if(arg1 == "cgi"){
			$("#nav1 a").css("background-image","url('images/cgi_label_o.png')");
			$("#nav2 a").removeAttr('style');
			tres.populated_center_content = "image";
			$("#center_content_1").replaceWith("<div id=\"center_content_1\"><img src=\"images/full/cg_text.png\" width=\"1175\" height=\"420\"></div>");
			tres.swap_eyes('fisheye1');
		}else if(arg1 == "pd"){
			$("#nav2 a").css("background-image","url('images/pd_label_o.png')");
			$("#nav1 a").removeAttr('style');
			tres.populated_center_content = "image";
			$("#center_content_1").replaceWith("<div id=\"center_content_1\"><img src=\"images/full/pd_text.png\" width=\"1175\" height=\"420\"></div>");
			tres.swap_eyes('fisheye2');
		}
		if (tres.previous_center_content == "html"){
			$("#center_content_2").replaceWith("<div id=\"center_content_2\">&nbsp;</div>");
		}else{
			$("#center_content_2").fadeOut("slow");
		}
		_gaq.push(['_trackEvent', 'TopMenu', arg1]);
		
	},
	swap_eyes: function(arg1){
		$("#fisheye1").css("display","none");
		$("#fisheye2").css("display","none");
		if (arg1 != "blank_out"){
			//$("fisheyeredraw1").addClass('redraw');
			$("#"+arg1).fadeIn("slow");
			//$("#"+arg1).css("display","block");
			//$("#"+arg1).toggleClass('redraw');
			//$("fisheyeredraw1").toggleClass('redraw');
			//$("fisheyeredraw2").toggleClass('redraw');
		}
		//var temph = $("#"+arg1).html();
		//$("#fisheyeholder").html(temph);
		//position = $("#"+arg1).position();
		//console.log(position.left);
	}
};

// google analytics JS include method
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16279114-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// google analytics JS include method
