function getRealWidth() {
	var myWidth = 0
  if (typeof(window.innerWidth) == 'number') {
    myWidth = window.innerWidth;
  } else if (document.documentElement && document.documentElement.clientWidth) {
    myWidth = document.documentElement.clientWidth;
  } else if (document.body && document.body.clientWidth) {
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}
function getRealHeight() {
	var myHeight = 0
  if (typeof(window.innerHeight) == 'number' ) {
    myHeight = window.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {
    myHeight = document.documentElement.clientHeight;
  } else if (document.body && document.body.clientHeight) {
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function getObj(elementID){
	if (typeof elementID == "string") {
		return document.getElementById(elementID);
	}else{
		return elementID;
	}
}

function menuLinks(elemID) {
	var el = document.getElementById(elemID);
	if (lastMenu != null) {
		getObj(lastMenu).style.display = "none";
	} 
	el.style.display = "block";
	lastMenu = elemID;
}

function mayorsWelcome(popurl){
	winpops=window.open(popurl,"","width=480,height=620,top=10,left=10,resizable,scrollbars")
}

function openpopup(popurl,wid,hei) {
	winpops=window.open(popurl,"cnf","width="+wid+",height="+hei+",top=10,left=10,resizable,scrollbars")
}
function openpopup2(popurl,wid,hei) {
	winpops=window.open(popurl,"cnf2","width="+wid+",height="+hei+",top=10,left=10,resizable,scrollbars")
}

function setVisibility(obj,vis){
	var theObj = getObj(obj);
	if (vis == true || vis=='visible' || vis=='y'){
		theObj.style.visibility = "visible";
	} else {
		theObj.style.visibility = "hidden";
	}
}

function shiftTo(obj,x,y,z){
	var newObj = getObj(obj);
	newObj.style.left = x + "px";
	newObj.style.top = y + "px";
	newObj.style.zIndex = z;
}

var mouseX, mouseY;
function getMouseXY(evt) {
	if (window.event) {var evt = window.event;}
	//before using browser_is, you must ensure that browserdetection.js is included
	if (browser_is.ie) {
    mouseX = event.clientX + document.body.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop;
  } else { 
    mouseX = evt.pageX;
    mouseY = evt.pageY;
  }  
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0;}
  if (mouseY < 0){mouseY = 0;}  

}

function popBox(evt, elementID, vis) {
	getMouseXY(evt);
	if (window.event) {evt = window.event;}
	if (evt) {
		if (vis == "n") {
			var x = 0;
			var y = 0;
			var z = 0;
		}
	} else {
		var x = 0;
		var y = 0;
		var z = 0;
	}

	shiftTo(elementID, mouseX, mouseY, z);
	setVisibility(elementID, vis);

}

// show a Milonic menu
function mm_showMenu(menuName, vis) {
   if (arguments.length > 1) {
       //alert(arguments.length);
    _m[getMenuByName(menuName)][7] = arguments[1]; }
   popup(menuName);
}

//hide a Milonic menu
function mm_hideMenu(menuName, vis) {
   var menuNum = getMenuByName(menuName);
   if (arguments.length > 1) {   
      _m[menuNum][7] = arguments[1];
   }

   menuDisplay(menuNum, 0);
}

function trackLink(href_val, prepend) {
	href_val = href_val.replace("http://","");
	href_val = href_val.replace("https://","");
	href_val = href_val.replace("www.","");
	do {
		href_val = href_val.replace(".","_");
	} while (href_val.indexOf(".") > 0);
	href_val = href_val.substring(0, href_val.indexOf("/"));
	pageTracker._trackPageview('/' + prepend + '/' + href_val);
}

function trackPDF(href_val, prepend) {
	href_val = href_val.replace(window.location.protocol + "//","");
	href_val = href_val.replace(window.location.host,"");
	href_val = href_val.replace(window.location.hostname,"");

	pageTracker._trackPageview('/' + prepend + href_val);
}
