
var possibleChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

function GenerateRandom(length) {
  var tmp = "";
  for(i = 0; i < length; i++)
    tmp += possibleChars.charAt(Math.floor(Math.random() * possibleChars.length));
  return tmp;
}

// Pops up a window with the height and width that accomadates the sign in page
function PopUpWindowSignIn(url) {
  PopUpWindow(url, 600, 470);
}

function PopUpWindowSignIn(url, scrollbars) {
  if(!scrollbars) {
    PopUpWindow(url, 600, 470);
    return;
  }
  PopUpWindow(url, 620, 470, true);
}

function PopUpWindow(url, width, height) {
  PopUpWindow(url, width, height, false);
}

function PopUpWindow(url, width, height, scrollbars) {
  attributes = "width=" + width + ",height=" + height;
  if(scrollbars)
    attributes += ",scrollbars";
  
  // A random string is used for the name so that other pop-ups don't override other ones
  var tmp = GenerateRandom(10);
  popupWindow = window.open(url, tmp, attributes);
  if(popupWindow)
    popupWindow.focus();
}
