function positionSocial() {
    var banner_offset = $("#banner").offset();
    var banner_width = $("#banner").width();
    //change this so it iterates and adds the image widths
    $("#social_links").css("width", "75px");
    $("#social_links").css("left", String(banner_width + banner_offset.left - 78) + "px");
    $("#social_links").css("top", "38px");
    $("#social_links").css("position", "absolute");

}

function positionSidebar() {
	if (document.getElementById('sidebar')) {
		var sidebar = document.getElementById('sidebar');
		var main_content = document.getElementById('main_content');

		mc_height = sidebar.offsetHeight + 15;
		main_content.style.minHeight = mc_height + 'px';
	}
}

window.onresize = function() {
	positionSocial();
}

/* change this to jQuery */

window.onload = function() {

/*	alert(document.getElementById('sidebar').offsetWidth);*/

	positionSocial();
	positionSidebar();

	if(document.getElementsByClassName) {
		var top_nav_elements = document.getElementsByClassName('top_nav');
	} else {  //stupid IE doesn't run getElementsByClassName correctly
		var top_nav_elements = [];
		var a = document.getElementsByTagName('UL');
		for(var i = 0; i < a.length; i++) {
			if(a[i].className == 'top_nav') {
				top_nav_elements.push(a[i]);
			}
		}
	}



	for(var i = 0; i < top_nav_elements.length; i++) {

		top_nav_elements[i].onmouseover = function() {
			var id = this.id.split('_');
			var itemid = 'top_nav_item_' + id[id.length - 1];
			document.getElementById(itemid).getElementsByTagName('A')[0].style.color = "#ffffff";

//			document.getElementById('sub_nav_wrapper').className = 'sub_nav_wrapper_show';

//			document.getElementById('sub_nav_wrapper').style.left = document.getElementById('top_nav').offsetLeft + 'px';
		}

		top_nav_elements[i].onmouseout = function() {
			var id = this.id.split('_');
			var itemid = 'top_nav_item_' + id[id.length - 1];
			document.getElementById(itemid).getElementsByTagName('A')[0].style.color = "#660000";

//			document.getElementById('sub_nav_wrapper').className = 'sub_nav_wrapper_hidden';
		}


		top_nav_elements[i].onclick = function() {
			var id = this.id.split('_');
			var itemid = 'top_nav_item_' + id[id.length - 1];
			location.href = document.getElementById(itemid).getElementsByTagName('A')[0].pathname;
		}
	}
}

/*I don't like this at all! Is there a way we can get scripts into user created pages. new field??? */
$(document).ready( function() {
  $("#frm_application").submit( function() {
    if($("#no_citizen").attr("checked")) {
      location.href="http://www.mlsem.org/application/intl/";
    } else if($("#yes_citizen").attr("checked")) {
      location.href="http://www.mlsem.org/application/dom/";
    } else {
      alert("Please select whether you are a U.S. citizen or not!");
    }
    return false;
  });
});
