//  Copyright (c) 2000-2005 PeopleSoft, Inc.  All Rights Reserved.
//  ToolsRel: 8.47.08

document.props = new Object();
document.props.location = document.location.href;
document.props.domain = document.domain;

function saveWarning(frameName,form,target,url)
{
var changed=null;

if (form)
  changed = checkFormChanged(form, null);

if (changed==null && top.frames && frameName.length>0 )
{
  objFrame = top.frames[frameName];
  if (objFrame)
    changed=checkFrameChanged(objFrame);
}

if ((changed==null) && top.frames)
  changed = checkAnyFrameChanged(top.frames);

var rtn = true;
if (changed)
  rtn = !confirm("You have unsaved data on this page. Click OK to go back and save, or Cancel to continue.");

if (!url)
  return rtn;           

if (rtn)
  open(url, target)

}

function setAnchorAndFocus(link) 
{
setAnchor(link);

var obj = document.anchors[link];
if (obj == null && document.getElementById) 
    obj=document.getElementById(link);
if (obj != null)
    tryFocus(obj);
} 


function setAnchor(link) 
{
var obj = document.anchors[link];
if (obj == null && document.getElementById) 
    obj=document.getElementById(link);

if (obj!=null && typeof obj == 'object')
    {
    if (obj.scrollIntoView) 
        obj.scrollIntoView();
    else 
        
        
        
        
	    if (document.location.hash != ("#" + link) && document.location.hash != link) 
            document.location.href = "#"+link;
    }
}                

function checkAnyFrameChanged(frames)
{
for (var j=0; j < frames.length; ++j)
{
  var objFrame = frames[j];
  if (checkFrameChanged(objFrame))
    return true;
  
  if ((!isCrossDomain(objFrame)) && (objFrame.frames))
    if (checkAnyFrameChanged(objFrame.frames))
      return true;
}
}

function checkFrameChanged(objFrame)
{
if (isCrossDomain(objFrame))
  return null;

var objForms = objFrame.document.forms;
if (!objForms)
  return null;

var retval = null;
for (var i=0; i < objForms.length; i++)
{
  var change = checkFormChanged(objForms[i], objFrame);
  if (change != null)
  {
    if (change)
      return true;
    retval = change;
  }
}
return retval;
}

function checkFormChanged(form, objFrame)
{
if (!form.ICChanged)
  return null;          
if (form.ICChanged.value == "-1")
  return false;        
if (form.ICChanged.value == "1")
  return true;          
for (var j = 0; j < form.length; ++j)
{
  if (isChanged(form.elements[j], objFrame))
     return true;
}
return false;
}

function ignoreChg(obj, objFrame)
{
if (obj.getAttribute == null)
  {
  var ignoreChgElem = null; 
  if (objFrame != null)
    ignoreChgElem = objFrame.ignoreChgElem;
  if (ignoreChgElem == null)
    return false;
  for (var i=0; i<ignoreChgElem.length; i++)
    if (obj.name == ignoreChgElem[i])
      return true;
  return false;
  }
else
  return obj.getAttribute("PSnchg");
}

function isChanged(obj, objFrame)
{
if (obj.type == "checkbox"  || obj.type == "radio")
  return (obj.checked != obj.defaultChecked) && !ignoreChg(obj, objFrame);
else if (obj.type == "select-one" && obj.selectedIndex > -1)
  return !(obj.options[obj.selectedIndex].defaultSelected) && !ignoreChg(obj, objFrame);
else if (obj.type == "select-multiple")
{
  for (var i =0; i < obj.options.length; ++i)
  {
     if (obj.options[i].defaultSelected != obj.options[i].selected)
        return !ignoreChg(obj, objFrame);
  }
  return false;
}
else if (obj.type == "hidden" || obj.type == "button")
  return false;
else
  return (obj.value != obj.defaultValue) && !ignoreChg(obj, objFrame);
}

var timeoutWin;
var timeoutWarningID;
var timeoutID;

function setupTimeoutMac()  
{
window.setTimeout("setupTimeout();", 1000);		
}

function setupTimeout() 
{
if (totalTimeoutMilliseconds != 2073600000)
{
  if (!isSessionLoggedout())
  {
  window.clearTimeout(timeoutWarningID);
  window.clearTimeout(timeoutID);
  timeoutID = window.setTimeout('displayTimeoutMsg()', totalTimeoutMilliseconds);	
  timeoutWarningID = window.setTimeout('displayTimeoutWarningMsg()', warningTimeoutMilliseconds); 
  }
}
}

function displayTimeoutMsg() 
{
timeoutMsg = "Your session has been timed out. As a security precaution"
    + " " + totalTimeoutMilliseconds/60000 + " " + "minutes of inactivity."; 
self.location = timeOutURL;   
}

function displayTimeoutWarningMsg()                      
{
timeoutWinOption = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=330,height=220";
timeoutWin =window.open( timeoutWarningPageURL, "timeoutWarning", timeoutWinOption, true); 
timeoutWin.focus(); 
}

function getForm(document,formname)
{
var objForms = document.forms;
if (!objForms)
  return null;

for (var i=0; i < objForms.length; i++)
{
  if (objForms[i].name==formname)
    return objForms[i];
}
return null;
}

function getLoginCookieValue(cookiename)
{
var allcookies;
allcookies = document.cookie;

if (allcookies == "")
  return "-1";

var start = allcookies.indexOf(cookiename + '=');
if (start == -1) return "-1";          
start += cookiename.length + 1;   
    
var end = allcookies.indexOf(';', start);
if (end == -1) end = allcookies.length;
var cookieval = allcookies.substring(start, end);
var a = cookieval.split(' ');
var winhref=window.location.href;    
winhref=winhref.toLowerCase();
for(var i=0; i < a.length; i++)
{  
  if (a[i].length>0)
  {
    var urlpath = a[i].substring(0,a[i].lastIndexOf("/"));
    var pshome = a[i].substring(a[i].lastIndexOf("/"),a[i].length);       
    urlpath = urlpath.toLowerCase();
    pshome = pshome.toLowerCase();
    if ((winhref.indexOf(urlpath) !=-1) && (winhref.indexOf(pshome) !=-1))
       return a[i];
  }
}
return "-1";
}

function isSessionLoggedout()
{
var val =  getLoginCookieValue("PS_LOGINLIST");
if (val==-1)
{
  self.location=timeOutURL;
  return true;
}
return false;
}

function isIE() {
var isIE = navigator.appVersion.indexOf("MSIE")>0;
return isIE;
}

function isMAC() {
var isMAC = navigator.appVersion.indexOf("Mac")>0;
return isMAC;
}

function addExtraParam(saveWarn,frameName,form,target,tgturl,openNewWindowOption)
{
  var rtn = true;

  if (saveWarn == "Y")
  {
    var changed=null;

    if (form)
      changed = checkFormChanged(form, null);

    if (changed==null && top.frames && frameName.length>0 )
    {
      objFrame = top.frames[frameName];
      if (objFrame)
        changed=checkFrameChanged(objFrame);
    }

    if ((changed==null) && top.frames)
      changed = checkAnyFrameChanged(top.frames);

    if (changed)
      rtn = !confirm("You have unsaved data on this page. Click OK to go back and save, or Cancel to continue.");

    if (!tgturl)
      return rtn;           
  }
  
  if (rtn)
  {
    var newurl = "";
    if (typeof URLIntercept == "function"){
      newurl = URLIntercept(tgturl,target);
      if (newurl == "") 
        return;  
      else
        tgturl = newurl;  
      }  
      // open(tgturl, target);
      open(tgturl, target, ((target.toLowerCase() == '_blank') ? openNewWindowOption : ''));
  }
}