// GLOBAL Javascript Functions

function Popup(action,data,width,height,scrollbars) {
   vurl = '/popup/popup_fsrc.asp?a=' + action + '&data=' + data
   // Concatenating the width onto the window name is a fudge way of making this window name unique
   // at the same time, keeping the window name the same for the same type of popup
   // then the following FOCUS command will also bring the correct window to the front
   win = window.open(vurl,'Popup'+width,'height=' + height + ',width=' + width + ',scrollbars=' + scrollbars +',resizable=1')
   // Bring the window to the front
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   if (height >= screen.availHeight) {
      if (width >= screen.availWidth) {
         win.parent.moveTo(0,0)
         win.parent.resizeTo(screen.availWidth, screen.availHeight);
      }
   }
}

// General Popup function
function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

// Educators' Ideas popup
function PopupEducatorsIdeas() {
   newWindow('/EducatorsIdeas/start.asp','EducatorsIdeasPopup',750,550,'');
}

// Insites popup
function PopupInsites() {
   // This code must be the same as /insites/global.js ... function Popup
   // Popup('SHOW-DOC','/insites/main.asp',790,590,1)
   action = 'SHOW-DOC'
   width = 790
   height = 545
   scrollbars = 1
   data =''
   vurl = '/insites/shell/popup_fsrc.asp?a=' + action + '&data=' + data
   // Concatenating the width onto the window name is a fudge way of making this window name unique
   // at the same time, keeping the window name the same for the same purpose
   // then the follow FOCUS command will also bring the correct window to the front
   win = window.open(vurl,'Popup'+width,'height=' + height + ',width=' + width + ',scrollbars=' + scrollbars +',resizable=1')
   // Bring the window to the front
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   if (height >= screen.availHeight) {
      if (width >= screen.availWidth) {
         win.parent.moveTo(0,0)
         win.parent.resizeTo(screen.availWidth, screen.availHeight);
      }
   }
   win.parent.moveTo(0,0)
}

