function showLayer(iconObj) {
	document.getElementById("blackLayer").style.display = "block"
	
	// position calculator
	calcIconX = find_pos_x(document.getElementById(iconObj)) + 23 + 10
	calcIconY = find_pos_y(document.getElementById(iconObj))
	
	// check for moving calculator to left side of icon
	if (arguments.length > 1)
		calcIconX -= 450
	
	document.getElementById("calculator").style.top = calcIconY + "px"
	document.getElementById("calculator").style.left = calcIconX + "px"
	
	document.getElementById("calculator").style.display = "block"
}

function hideCalc() {
	document.getElementById("blackLayer").style.display = "none"
	document.getElementById("calculator").style.display = "none"
}

function addCalc() {
	tuitionVal = parseInt(document.getElementById("tuition").value)
	booksVal = parseInt(document.getElementById("books").value)
	travelVal = parseInt(document.getElementById("travel").value)
	roomVal = parseInt(document.getElementById("room").value)
	otherVal = parseInt(document.getElementById("other").value)
	
	expenses = tuitionVal + booksVal + travelVal + roomVal + otherVal
	
	document.getElementById("expenses").value = expenses
	
}

function subtractCalc() {
	expenses = parseInt(document.getElementById("expenses").value)
	cash = parseInt(document.getElementById("cash").value)
	
	document.getElementById("borrow").value = expenses - cash
	
}

function find_pos_x(obj) {
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}

function find_pos_y(obj) {
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}
