
// intended primariy as a helper function: prefer popupWindow and pWResizable.
function PP_popupWindowArgs( url, args ) {
  var popup = window.open( url, 'MrAptelaTheFamoutPopupWindow', args );
  popup.focus();
}

function PP_popupWindow( url, width, height ) {
  PP_popupWindowArgs( url, 'width='+width+',height='+height );
}

function PP_popupWindowResizable( url, width, height ) {
  PP_popupWindowArgs( url, 
		      'width='+width+',height='+height + 
		      ',resizable=yes,scrollbars=yes'
		      );
}

// intended primariy as a helper function: prefer pWSubmit and pWSResizable.
function PP_popupWindowSubmitArgs( form, args ) {
  var popup = window.open( '', 'MrAptelaTheFamousPopupWindow', args );
  form.target = popup.name;
  form.submit();
  popup.focus();
}
  
function PP_popupWindowSubmit( form, width, height ) {
  PP_popupWindowSubmitArgs( form, 'width='+width+',height='+height );
}

function PP_popupWindowSubmitResizable( form, width, height ) {
  PP_popupWindowSubmitArgs( form, 
			    'width='+width+',height='+height + 
			    ',resizable=yes,scrollbars=yes' );
}

// ?? function popupNamedWindow( url, name, width, height )?

function PP_closePopup( popup ) {
  if (!popup.opener.closed) {
    popup.opener.focus();
  }
  popup.close();
}

// will error if opener is closed
function PP_closePopupAndLoadContent( popup, url ) {
  popup.opener.parent.content.location = url;
  PP_closePopup( popup );
}

// will error if opener is closed
function PP_closePopupAndSubmit( popup, form ) {
  form.target = popup.opener.name; // XXX ??? popup.opener.parent.content.name?
  form.submit();
  PP_closePopup( popup );
}

// for doing info popups
function PP_popInfo( node ) {
  var pop = window.open("/phoneplex/calltree/info?_popup=1&helpnode=" + node,
			'info',
			'width=350,height=300,scrollbars=yes,resizable=yes');
  pop.onload = children.add('info_'+ node ,pop);
  pop.focus();
}

// functions for "pressing" buttons
// need some global image variables
PP_image_saveIn = new Image(); // "pressed in"
PP_image_saveIn.src = "/phoneplex/images/save_.gif";
PP_image_saveOut = new Image(); // "released"
PP_image_saveOut.src = "/phoneplex/images/save.gif";
PP_image_nextIn = new Image(); // "pressed in"
PP_image_nextIn.src = "/phoneplex/images/next_.gif";
PP_image_nextOut = new Image(); // "released"
PP_image_nextOut.src = "/phoneplex/images/next.gif";

function PP_clickSave( nextFunc ) {
  document.save0.src = PP_image_saveIn.src;
  window.setTimeout( nextFunc, 250 );
}
function PP_releaseSave( nextFunc ) {
  document.save0.src = PP_image_saveOut.src;
  window.setTimeout( nextFunc, 250 );
}

function PP_clickNext( nextFunc ) {
  document.next0.src = PP_image_nextIn.src;
  window.setTimeout( nextFunc, 250 );
}
function PP_releaseNext( nextFunc ) {
  document.next0.src = PP_image_nextOut.src;
  window.setTimeout( nextFunc, 250 );
}
  
