
/*
 (EWEJS) Evolver's Web Engine JavaScript
  implements: popups
*/

if( typeof __Core =="undefined")
 alert( 'v4_Core.js is required in v4_Popup.js');

var __Popup =4.00;

// opens popup
function v4_OpenPopup( width, height, popupname, url, resizable, scrollbars) {
  var _top =Math.ceil((screen.height - height)/2) -30;
  var _left =Math.ceil((screen.width - width)/2);
  if( !resizable || resizable ==false)
    resizable ="no";
  else resizable ="yes";
  if( !scrollbars || scrollbars ==false)
    scrollbars ="no";
  else scrollbars ="yes";
  var wn =window.open( url, popupname, 'width=' + width + ',height=' + height + ',location=no,status=no,toolbar=no,menubar=no,resizable=' +resizable +',scrollbars=' +scrollbars +',top=' + _top + ',left=' + _left);
  wn.name =popupname;
  wn.focus();
}
// opens popup basing on screen size
function v4_OpenPopupPerc( width_perc, height_perc, popupname, url, resizable, scrollbars) {
  var _w =(screen.width *(width_perc *0.01));
  var _h =(screen.height *(height_perc *0.01));
  if( !resizable || resizable ==false)
    resizable ="no";
  else resizable ="yes";
  if( !scrollbars || scrollbars ==false)
    scrollbars ="no";
  else scrollbars ="yes";
  return v4_OpenPopup( _w, _h, popupname, url, resizable, scrollbars);
}
// closes window and refreshes opener
function v4_PopupCloseOpenerRefresh( win) {
 win.opener.location.href =win.opener.location.href;
 win.close();
}
// closes window and opener navigates to specified location
function v4_PopupCloseOpenerNavigate( win, url) {
 win.opener.location.href =url;
 win.close();
}