function HostelPictureWindow(url) {
  SmallWin = window.open(url, 'HostelPicture','scrollbars=yes,resizable=yes,height=500,width=600');

  if (window.focus) {
    SmallWin.focus();
  }

  if (SmallWin.opener == null) {
    SmallWin.opener = window;
  }
}

function popUpUrl(URL) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=450,left = 540,top = 375');");
}

function currFormat(amount) {
  amount -= 0;
  amount = (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
  amount = amount.toString();

  bits = amount.split('.');

  return bits[0] + '.' + bits[1].substring(0,2);
}

function showHostelDesc(rowNum) {
  var descDiv = document.getElementById('hostelDesc_' + rowNum);

  descDiv.zIndex = '10';
  descDiv.style.display = 'block';
  descDiv.style.position = 'absolute';
}

function hideHostelDesc(rowNum) {
  document.getElementById('hostelDesc_' + rowNum).style.display = 'none';
}

function quickChangeCurrency(CurrencyCode) {
 document.theForm.Currency.value = CurrencyCode;
 document.theForm.submit();
}

function setTotals() {
  var warn = "";
  showChosen = 0;
  document.getElementById('PrivateWarning').value = 0;
  beds = price = displayedBeds = 0;
  sel = Selects.length;

  for (i=0; i<sel; i++) {
    menu = document.getElementById(Selects[i]);
    menuNum = parseInt(Selects[i].replace(/People/, ''));
    val = parseInt(menu.options[menu.selectedIndex].value);
    displayed = parseInt(menu.options[menu.selectedIndex].text);

    if(displayed != val) {
      document.getElementById('PrivateWarning').value=1;
      if(Warnings[i].length) {
        warn += Warnings[i]
      }
    }

    beds += val;
    displayedBeds += displayed;
    price += val*Prices[i];

    if(val > 0) {
      document.getElementById('ChosenNum'+menuNum).innerHTML = Math.ceil(val/Beds[i]);;
      document.getElementById('ChosenPersons'+menuNum).innerHTML = displayed;
      document.getElementById('ChosenPrice'+menuNum).innerHTML = currFormat(val*Prices[i]);
      document.getElementById('Chosen'+menuNum).style.display = rowDisplay;
      showChosen = 1;
    } else {
      document.getElementById('Chosen'+menuNum).style.display = 'none';
    }
  }

  if(warn.length) {
    document.getElementById('privateText').innerHTML = warn;
    document.getElementById('privateMessage').style.display = rowDisplay
  } else {
    document.getElementById('privateMessage').style.display = 'none'
  }

  if(showChosen) {
    document.getElementById('ChosenHead').style.display = rowDisplay;
    document.getElementById('priceTotal').style.display = rowDisplay;
    document.getElementById('ChosenTotal').style.display = rowDisplay;
  } else {
    document.getElementById('ChosenHead').style.display = 'none';
    document.getElementById('priceTotal').style.display = 'none';
    document.getElementById('ChosenTotal').style.display = 'none';
  }

  deposit = price/10;
  Deposit = document.getElementById('PayNow');
  Deposit.innerHTML = symbol + currFormat(deposit);
  TotalPrice = document.getElementById('PayNowTotal');
  TotalPrice.innerHTML = symbol + currFormat(price);
}
