﻿/*******************************************************************************    
 * File Name    : Popups.js
 * Description  : Contains popup modal dialog helpers functions
 * Date Created : 2006-06-13
 * Created By   : Sergiy Kupchik
 * 
 * Notes:       : If is used to show page that is not inherited 
                  from the Inovas.Accreditation.Collection.PopupPageBase, page must have 
                  <base target="_self"></base>
                  in the <head> section.
                  (PopupPageBase adds this on Render).
 
 * -----------------------------------------------------------------------------
 * Changes.
 * 
 * -----------------------------------------------------------------------------
 * Date Updated : 
 * Updated By   : 
 * Description  : 
 * -----------------------------------------------------------------------------
 
 
 ******************************************************************************/

var winModalWindow;

 
function IgnoreEvents(e)
{
  return false
}
 
function ShowPopupDlg(url, name, width, height, resize )
{
   
  //IE 
  var returnValue;
  if (window.showModalDialog)
  {
    if (resize == "true" || resize == "yes" || resize == "1") {
       returnValue = window.showModalDialog(url ,name,
        "center:no;edge:raised;resizable:yes;scroll:yes;status:no;dialogTop:0;dialogLeft:0;dialogWidth=" + width + "px;dialogHeight=" +height + "px")
    
    }
    else {
       returnValue = window.showModalDialog(url ,name,
        "center:no;edge:raised;resizable:no;scroll:yes;status:no;dialogTop:0;dialogLeft:0;dialogWidth=" + width + "px;dialogHeight=" +height + "px")
    }
      return returnValue;
  }
  else
  {
    //Mozilla
    window.top.captureEvents (Event.CLICK|Event.FOCUS)
    //window.top.onclick=IgnoreEvents
    window.top.onfocus=HandleFocus 
    if (resize == "true" || resize == "yes" || resize == "1") {
        winModalWindow = 
            window.open (url, name, "resizable=yes,dependent=yes,scrollbars=yes,top=0,left=0,width="+width+",,height=" + height)
    }
    else {
        winModalWindow = 
            window.open (url, name, "resizable=no,dependent=yes,scrollbars=yes,top=0,left=0,width="+width+";,height=" + height)
    
    
    }
    winModalWindow.focus()
    
  }
}



 
function HandleFocus()
{
  if (winModalWindow)
  {
    if (!winModalWindow.closed)
    {
      winModalWindow.focus()
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS)
      window.top.onclick = ""
      winModalWindow = null;
    }
  }
  return false;
}

