
(function($) {
	
	var footerCntrlHeight;
	var footerCntrlOffsetTop;
	var tableHeight;
	var tableOffsetTop;
	var baselineElementHeight;
	
	$.forceImageOver = (function(){
						
		//$(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
		
	});
	
	// controls placement of footer to prevent content hiding
	$.preventFooterOverContent = (function() {
		
		var footerTop = $("#baseBar").offset().top;
		// accounting for iphone height property
		var windowheight = window.innerHeight ? window.innerHeight : $(window).height();
		
		if(windowheight<604)
		{
			// change position to relative and lock in place
			$("#baseBar").css( { "position": "relative" } );
			$("#baseBar").css( { "top": "575px" } );

		} else {
			
			// ensure position is fixed
			$("#baseBar").css( { "position": "fixed" } );
			$("#baseBar").css( { "top": '' } );
		}
		
	});
	/* Calculate and set the footer */
	$.anchorFooterToBaseline = (function(){

		if(baselineElementHeight==undefined)baselineElementHeight =Number($("#baseBar").css("height").replace("px", ""));

		// accounting for iphone height property
		//var windowheight = $(window).height();// window.innerHeight ? window.innerHeight : $(window).height()
		var windowheight = window.innerHeight ? window.innerHeight : $(window).height()

		var footerTop = Number(windowheight) - baselineElementHeight;		
		footerTop = (footerTop>575)?footerTop :575; // adjust so the bar does not rise above the content

		$("#baseBar").css( { "top": (Number(footerTop)) + "px" } );

		//alert($("#baseBar").css("top"));
	});
	
	/* Calculate center and arrange all affected pieces */
	$.centerall = (function(){
		
		// accounting for iphone height property
		var windowwidth = $(window).width();// window.innerWidth ? window.innerWidth : $(window).width()
		
		/* Calculate the center of page */
		var pos = $("#Table_01").offset();
		var xOffset = (windowwidth / 2);
		xOffset -= (1057/2);
		//var yOffset = pos.top;
	
		/* adjust the page */
		//$("#Table_01").css( { "left": (xOffset) + "px", "top": (yOffset) + "px" } );
		$("#Table_01").css( { "left": (xOffset) + "px"} );
	
		/* adjust menu positions */
		var windowAdjustment = 10;
		var portfolioMnu = Number($("#portfolio-off").css("left").replace("px", "")) + Number($("#Table_01").css("left").replace("px", "")) - windowAdjustment;
		//var mnu = $("#menu_shell").offset();
		//var mnuLeft = xOffset+mnu.left;
		$("#menu_shell").css( { "left": (portfolioMnu) + "px" } );
		
	});

	
})(jQuery);

