var win = null;

function openWin(path,w,h)
{
	var Width = w;	
	var Height = h;
	
	LeftPosition = (screen.width) ? (screen.width-Width)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-Height)/2 : 0;
	
	settings = 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+Width+',height='+Height+',top='+TopPosition+',left='+LeftPosition;
	win = window.open(path,'Zoom',settings);
	
	if(win.focus){
		win.focus();
	}
}

function handleKeyPress(btnID)
{
  if (document.all)
  {
    var btnElement = document.getElementById(btnID);
    
    if (event.keyCode == 13)
    {
      event.returnValue = false;
      event.cancel = true;
      btnElement.click();
    }
  }
}

function getRandomNum(lbound, ubound)
{
    return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar(number, lower, upper, other, extra)
{
    var numberChars = "0123456789";
    var lowerChars  = "abcdefghijklmnopqrstuvwxyz";
    var upperChars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var otherChars  = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
    var charSet     = extra;
    
    if (number == true)
    {
        charSet += numberChars;
    }
    
    if (lower == true)
    {
        charSet += lowerChars;
    }
    
    if (upper == true)
    {
        charSet += upperChars;
    }
    
    if (other == true)
    {
        charSet += otherChars;
    }
    
    return charSet.charAt(getRandomNum(0, charSet.length));
}

function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,latterNumber, latterLower, latterUpper, latterOther)
{
    var rc = "";
    if (length > 0)
    {
        rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
    }
    
    for (var idx = 1; idx < length; ++idx)
    {
        rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
    }
    
    return rc;
}

