 // You may specify partial version numbers, such as "1" or "1.3",
  //  with the same result. Doing so will automatically load the 
  //  latest version matching that partial revision pattern 
  //  (e.g. 1.3 would load 1.3.2 today and 1 would load 1.4.1).
google.load("jquery", "1.4.1");

google.setOnLoadCallback(function() {
	// Place init code here instead of $(document).ready()
	//alert('window width: ' + $(window).width());
	function setMargin() {
		if ($(window).width() > 1058){
			$('#innerwrapper.container_12').css('margin-left', 98+'px');
		} else if ($(window).width() < 960) {
			$('#innerwrapper.container_12').css('margin-left', 0+'px');
		} else {
			var marginwidth = $(window).width() - 960;
			$('#innerwrapper.container_12').css('margin-left', marginwidth+'px');
		}
	};
	
	function resetContentHeight() {
		var mainH = $('#mainContent').height();
		var secH = $('#secondaryContent').height();
		if ($('#mainContent').height() < $('#secondaryContent').height()){
			//alert('resize mainContent');
			$('#mainContent').css('height', $('#secondaryContent').height()+20+'px');
		} else {
			//alert('no need to resize main content area');
		}
	}
	
	function setFooterWidth() {
		$('#footer').css('width', $(window).width());
	}
		
	$(window).resize(function() {
		setMargin();
		setFooterWidth();
	});
	
	setMargin();
	resetContentHeight();
	setFooterWidth();
	
	
	function handleExternalLinks() { // function makes sure that external links open in new window
		var hostName = window.location.hostname;
		var links = document.getElementsByTagName("a");
		for(var i = 0; i < links.length; i++) {
			if(links[i].href.indexOf(hostName) == -1) {
				var curTitle = (links[i].getAttribute("title")) ? links[i].getAttribute("title") + " - ": "";
				links[i].setAttribute("target", "_blank");
				links[i].setAttribute("title",  curTitle + "opens in new window");
			}
		}
	}

	handleExternalLinks(); // Call the function
});
