var isIE6 = false;

/* test for IE6 */
/* disables the 'sticky' "anchor-right" class elements and anchors them to the right all the time */
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 if (ieversion ==6) isIE6 = true; 
}

var MAXOFFSET = '-290px'; //anchor-right sticky threshold
var selectedmenu;
var whichmenu;
var tweeturl = "http://twitter.com/status/user_timeline/herzfeldrubin.json?count=2&callback=?";   /*twitter json link - pulls the 2 most recent tweets*/

/* on document ready and window resize, grab the current width and height of window*/
/* window width is used to make all 'anchor-right' class elements stick to the absolute right side of the window until it reaches it's max threshold*/
/* window height to determine the height of the gray footer should the window height exceed the height of the home viewport - causing a stretching effect */

/*document ready */
$(document).ready(function () {
	$(".item").css({"padding-top" : $("#toppanel").height()});
	var windowWidth = $(window).width();
	var windowHeight = $(window).height();
	
	if(windowWidth > 990 && windowWidth < 1281 && !(isIE6)){
		h1offset = 990 - windowWidth;
		$(".item .anchor-right").css({ 'right' : h1offset });
	}
	else if(windowWidth > 1280 && !(isIE6)){
		$(".item .anchor-right").css({ 'right' : MAXOFFSET });
	}
	else {
		$(".item .anchor-right").css({ 'right' : '0px' });
	}
	$(".item .anchor-right").show();
	
	if(windowHeight > 812){
		$("#bottompanel").css({"height" : 131 + windowHeight - 812 + "px"});+
		$("#wrapper").css({"height" : 812 + windowHeight - 812 + "px"});
	}
	
	/*window resize event handler*/
	$(window).resize(function() {
		windowHeight = $(window).height();
		
		windowWidth = $(window).width();
		if(windowHeight > 812){
			$("#bottompanel").css({"height" : 131 + windowHeight - 812 + "px"});
			$("#wrapper").css({"height" : 812 + windowHeight - 812 + "px"});
		}
		
		if(windowWidth > 990 && windowWidth < 1281 && !(isIE6)){
			h1offset = 990 - windowWidth;
			$(".item .anchor-right").css({ 'right' : h1offset });
		}
		
		else if(windowWidth > 1280 && !(isIE6)){
			$(".item .anchor-right").css({ 'right' : MAXOFFSET });
		}
		else {
			$(".item .anchor-right").css({ 'right' : '0px' });
		}
	});
});
