// SCRIPT BY Mike Gleason Jr Couturier (mcouturier@bmgmultimedia.com)
// FOR BMG Multimedia
// http://www.bmgmultimedia.com/

// ---- Reload parent page         ----
// Parameter(s):
//   - none
function ReloadParent(){
  if(window.opener && !window.opener.closed)
    window.opener.document.location.reload();
}

// ---- Reload parent with page    ----
// Parameter(s):
//   - none
function ReloadParentWithURL(theURL){
  if(window.opener && !window.opener.closed)
    window.opener.document.location.href = theURL;
}

// ---- Reload parent and close    ----
// Parameter(s):
//   - none
function ReloadParentNClose(){
  ReloadParent();
  CloseWindow();
}

// ---- Reload parent and close    ----
// Parameter(s):
//   - none
function ReloadParentWithURLNClose(theURL){
  ReloadParentWithURL(theURL);
  CloseWindow();
}

// ---- Open browser window        ----
// Parameter(s):
//   - winPath    (string)
//   - winName    (string)
//   - winWidth   (int)
//   - winHeight  (int)
//   - Scrollable (int)
function OpenNewWindow(winPath, winName, winWidth, winHeight, winScrollable){
  var winLeft = (screen.width - winWidth) / 2;
  var winTop = (screen.height - winHeight ) / 2;
  var theWindow = window.open(winPath, winName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+winScrollable+',resizable=0,width='+winWidth+',height='+winHeight+',screenX='+winLeft+',screenY='+winTop+',left='+winLeft+',top='+winTop+'');
  theWindow.opener = self;
  theWindow.focus();
}

// ---- Close browser window       ----
// Parameter(s):
//   - winName    (string, optionnal)
function CloseWindow(winName){
  var winTarget = winName && winName.length != 0 ? eval("window." + winName) : eval("window");
  if(winTarget.opener && !winTarget.opener.closed)
    winTarget.opener.focus();
  winTarget.close();
}
