var WarningWindowWindow=null;
var WarningWindowInterval;
var WarningWindow = new Object;
var TipsWindow = null;
var TipOpenInterval;
var saveWarningInterval;

WarningWindow.value = '';
WarningWindow.eventhandler = null;
function openAmmHomePage()
{
  if ( window.opener )
  {
    window.opener.location = 'http:/www.announcemymove.com/';
    window.close();
  }
  else
  {
    window.location = 'http:/www.announcemymove.com/';
  }
}
function closeThenEval(cmd)
{
  if ( TipsWindow != null )
    TipsWindow.close();
  if ( WarningWindowWindow != null )
    WarningWindowWindow.close();

  TipOpenInterval = window.setInterval("delayedEval('" + cmd + "')",200);
}
function closeAndReopen(id)
{
  if ( TipsWindow != null )
    TipsWindow.close();
  if ( WarningWindowWindow != null )
    WarningWindowWindow.close();

  TipOpenInterval = window.setInterval("showTipsDelayed(" + id + ")",200); // Account Modification Policy
}
function openTips(TipsMessageId)
{
  var url='/member/tips.php?id=' + TipsMessageId;
  try {
    fullurl = url + "&session=" + document.memberform.session.value;
    url = fullurl;
  }
  catch (everything) {   }
  var args='width=380,height=519,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0';  
  return window.open(url,"Tips",args); 
}
function showTips(TipsMessageId)
{
  if ( TipsWindow != null )
    TipsWindow.close();
  TipsWindow = openTips(TipsMessageId);
}
function delayedEval(cmd)
{
  window.clearInterval(TipOpenInterval);
  eval(cmd);
}
function showTipsDelayed(TipsMessageId)
{
  window.clearInterval(TipOpenInterval);
  TipsWindow = openTips(TipsMessageId);
}

function WarningWindowMaintainFocus()
{
  try
  {
    if (WarningWindowWindow.closed)
     {
        window.clearInterval(WarningWindowInterval);
	if ( WarningWindow.eventhandler != null )
	  eval(WarningWindow.eventhandler);
	WarningWindowWindow = null;       
        return;
     }
    WarningWindowWindow.focus(); 
  }
  catch (everything) {   }
}
        
function openWarningWithParams(WarningMessageId, param1, param2)
{
  var url='/member/warning.php?id=' + WarningMessageId;
  try {
    fullurl = url + "&session=" + document.memberform.session.value;
    url = fullurl;
  }
  catch (everything) {   }

  if ( param1 != null )
  {
    url = url + "&param1=" + param1;
    if ( param2 != null )
      url = url + "&param2=" + param2;
  }
  url = encodeURI( url );
  var args='width=380,height=519,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0';
  return window.open(url,"Warning",args); 
}
function openWarning(WarningMessageId)
{
  return openWarningWithParams(WarningMessageId, null, null)
}

function WarningWindowRemoveWatch()
{
  WarningWindow.value = '';
  WarningWindow.eventhandler = '';
}

function WarningWindowShowWithParams(WarningMessageId,EventHandler,param1,param2)
{
  WarningWindowRemoveWatch();
  WarningWindow.eventhandler = EventHandler;
  WarningWindowWindow=openWarningWithParams( WarningMessageId, param1, param2 );
  WarningWindowWindow.focus(); 
  WarningWindowInterval = window.setInterval("WarningWindowMaintainFocus()",5);
}
function autoLogoutWarning()
{
  WarningWindowShowWithParams( 37, "checkIntervalReset()", null, null );
}
function checkIntervalReset()
{
  checkResult = WarningWindow.value;
  WarningWindowRemoveWatch();
  if ( checkResult == "Yes" ) {
    resetInterval();
  } else if ( checkResult == "No" ) {
    autoLogout();
  }
}
function WarningWindowShow(WarningMessageId,EventHandler)
{
  WarningWindowShowWithParams(WarningMessageId,EventHandler,null,null);
}
function WarningDoNothing()
{
}
function simpleWarningShow(id)
{
  WarningWindowShow(id,'WarningDoNothing()');
}
function YesNoCancelSaveForm()
{
  checkResult = WarningWindow.value;
  WarningWindowRemoveWatch();
  if ( checkResult == "Yes" ) {
    document.memberform.savechanges.value = "t";
    if ( showSaveWarning != null ) {
      eval(showSaveWarning);
    }
    document.memberform.submit();
  } else if ( checkResult == "No" ) {
    document.memberform.submit();
  }
}
function contactus(subject) {
  url = '/contactus.php?subject=' + subject + '&id=1&agentid=' + document.memberform.id.value;
  obj = document.getElementsByName('sales_id');
  if ( obj != null && obj.length == 1 ) {
    url = url + "&salesperson=" + obj[0].value;
  }
  options = "width=668,height=550,scrollbars=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=no,toolbar=no";
  window.open( url, 'ContactAgent', options );
}
function contactBilling() {
  contactus('billing');
}
function openPicture(url, width, height)
{
  var args='width=' + width + ',height=' + height + ',toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0';
  window.open(url,"Picture",args); 
}
