var win_print=null;
var bLoading=false;
var bShowHelp=false;
var oTD=null;
var _sErrorReload="An error has occured.\n\nMYCT Support Services has been notified of this fact. \nPlease clear your browser cache, refresh and try again. \nIf the problem persists, please contact support.\n\nThis page will now be reloaded.";
window.isDisabled=false;
var oPopup=window.createPopup();
oPopup.document.createStyleSheet('popup_v3a.css')

function process_button(){
  try{
    event.cancelBubble=true;
    if(window.isDisabled){
      event.returnValue=false;
      return false
    }
    var oEl=event.srcElement;window.status="";
    while(oEl.className.indexOf("Btn")==-1){
      oEl=oEl.parentElement;
      if(!oEl)return
    }
    if(oEl.disabled)return false;
    if(oEl.parentElement&&oEl.parentElement.disabled)return false;
    oEl.blur();
    var baseClass=oEl.className.substring(0,oEl.className.indexOf("Btn")+3);
    switch(event.type){
      case "mouseout":
        if(oEl.contains(event.toElement))break;
        if(oEl.STATE)oEl.className=baseClass+oEl.STATE;
        else oEl.className=baseClass+"Up";
        break;
      case "mouseover":
        if(oEl.contains(event.fromElement))break;
        oEl.className=baseClass+"On";
        break;
      case "mousedown":
        oEl.className=baseClass+"Down";
        break;
      case "mouseup":
        oEl.className=baseClass+"Up";
        break;
      case "click":
        if(oEl.ACTION){
          oTD=oEl;
          if(String(oTD.ACTION)=="HELP"){
            fnShowHelp();
            event.returnValue=false;
            break
          }
          if(String(oTD.ACTION)=="NOHELP"){
            fnHideHelp();
            event.returnValue=false;
            break
          }
          if(String(oTD.ACTION)=="POPMENU"){
            oPopup.document.body.innerHTML=oTD.children[1].innerHTML;
            var iMaxHeight=parseInt(oTD.getAttribute("mHeight"));
            if(iMaxHeight==0||oTD.children[1].children[0].children.length<iMaxHeight){
              oPopup.show(0,oTD.offsetHeight+2,oTD.getAttribute("mWidth"),(oTD.children[1].children[0].children.length*15)+2,oTD)
            }else{
              oPopup.document.body.firstChild.className="clsMenuChoicesScroll";
              oPopup.show(0,oTD.offsetHeight+2,oTD.getAttribute("mWidth"),(iMaxHeight*15)+2,oTD)
            }
            event.returnValue=false;
            break
          }
          if(oTD.getAttribute("status"))window.status=oTD.getAttribute("status");
          if(oTD.getAttribute("ACTION").indexOf("LL:")==-1)fnIsDisabled(true);
          setTimeout("process_event()",10)
        }else{
          oEl.all.tags("A")[0].click();
          break
        }
        event.returnValue=false;
        break;
      case "dblclick":
        event.returnValue=false;
        break;
      case "selectstart":
        if(oEl)event.returnValue=false;
        break;
      default:break
    }
  }catch(e){
    fnLogError(null,e,false)
  }
}

function process_event(){
  try{
    switch(String(oTD.ACTION)){
      case "LL:CALC":
        window.showModelessDialog("/assets/htm/calculator.htm",window,"status:no;dialogWidth:260px;dialogHeight:225px;center:yes;dialogHide:yes;edge:raised;help:no;scroll:no;resizable:no;");
        break;
      case "LL:EXPERT":
        var sReturn=window.showModalDialog("/assets/scripts/dialogs/ask_expert.asp?token="+top.token+"&Subject="+escape(document.title),"","dialogHeight:300px;dialogWidth:400px;help:no;resizable:no;status:no;");
        break
    }
    
    if(oTD.ACTION&&oTD.getAttribute("ACTION").indexOf("LL:")!=-1&&"function"==typeof(fnCustomAction))fnCustomAction(oTD);
    else if("function"==typeof(fnCustomAction))fnCustomReturn(fnCustomAction(oTD))
  }catch(e){
    fnLogError(null,e,false)
  }
}

function fnCustomReturn(bDisabled){
  setTimeout('fnIsDisabled('+bDisabled+');',10)
}

function fnIsDisabled(bDisabled){
  try{
    if(typeof(bDisabled)!="undefined")window.isDisabled=bDisabled;
    if(typeof(tblHeader)=="object")tblHeader.disabled=window.isDisabled;
    if(typeof(divCopyright)=="object")divCopyright.disabled=window.isDisabled;
    if(!window.isDisabled)window.status="";
    else if(oPopup.isOpen)oPopup.hide()}catch(e){fnLogError(null,e,false)
  }
}
function fnShowHelp(){
  divHelp.style.display="block";
  oTD.all.tags("A")[0].innerHTML="close help";
  oTD.title="Close help window.";
  oTD.ACTION="NOHELP";
  oTD.className="clsSaveBtnUp"
}
function fnHideHelp(){
  divHelp.style.display="none";
  oTD.all.tags("A")[0].innerHTML="help";
  oTD.title="Show help for this page.";
  oTD.ACTION="HELP";
  oTD.className="clsBtnUp"
}
function fnToggleContent(oRef){
  try{
    var oEl=event.srcElement.parentElement.parentElement.all;
    var oBlock=document.all[ oRef ];
    if(oBlock.style.display=="block"){
      oBlock.style.display="none";
      oEl.tags("IMG")[0].alt="Expand";
      oEl.tags("IMG")[0].src="/graphics/plus.gif";
      oEl.tags("span")[0].style.display="inline"
    }else{
      oBlock.style.display="block";
      oEl.tags("IMG")[0].alt="Collapse";
      oEl.tags("IMG")[0].src="/graphics/minus.gif";
      oEl.tags("span")[0].style.display="none";
      oBlock.scrollIntoView(false)
    }
    event.cancelBubble=true;
    event.returnValue=false
  }catch(e){
    fnLogError(null,e,false)
  }
}
function fnGetDateString(sFormat,oDate){
  if(oDate==null) var oDate=new Date();
  switch(sFormat){
    case "dmy":
      return oDate.getDate()+"/"+(oDate.getMonth()+1)+"/"+oDate.getFullYear();
      break;
    case "mdy":
      return(oDate.getMonth()+1)+"/"+oDate.getDate()+"/"+oDate.getFullYear();
      break;
    default:
      alert("invalid date format");
      return oDate.getDate()+"/"+(oDate.getMonth()+1)+"/"+oDate.getFullYear();
      break
  }
}

function fnSyncToc(sSearch){
  if(!sSearch)top.fraToc.location.replace("/assets/scripts/toc.asp"+top.fraTopic.location.search);
  else top.fraToc.location.replace("/assets/scripts/toc.asp"+sSearch)
}
function fnPopError(msg,url,lno){
  if(top.location.host.indexOf("localhost")!=-1){
    alert("Error Occurred! Handled by Generic Error Handler\nError: "+msg+"\nURL: "+url+"\nLine Number: "+lno)
  }else{
    var sError="Error: "+msg+"\nURL: "+url+"\nLine Number: "+lno;
    //fnLogError(null,sError,true,false)
  }
  //top.fraTopic.location.replace("/assets/htm/fatal_error.htm")
}

function fnLogError(oH,oErr,bFatal,bSilent){
  var oC=fnLogError.caller;
  var sCaller="";
  var sErr="";
  if(typeof(oC)=="function"){
    sCaller=String(oC);
    sCaller=sCaller.replace(/^([^(]+).+$/,"$1");
    sErr="Function arguments: ";
    for(var i=0;i<oC.arguments.length;i++)sErr+=oC.arguments[ i ]+" - ";
    sErr+="\n"
  }
  if(typeof(bSilent)=="undefined")bSilent=false;
  if(typeof(bFatal)=="undefined")bFatal=false;
  if(oH&&oH.readyState&&oH.readyState>1&&(oH.status==2||oH.status==12029)){
    alert("Unable to establish a connection with the server.\nPlease check your internet connection and try again.");
    fnIsDisabled(false);
    return
  }
  
  if(typeof(oErr.parseError)=="object"&&oErr.parseError.errorCode!=0)sErr+=oErr.parseError.reason;
  else if(typeof(oErr.description)!="undefined")sErr+=("Exception type: "+oErr.name+"\nDescription: "+oErr.description);
  
  if(typeof(oErr)=="object"&&typeof(oErr.xml)=="string")sErr+=("\nXML: "+oErr.xml);
  if(top.location.host.indexOf("localhost")!=-1||top.location.host.indexOf("evivid01")!=-1){
    alert("Error: "+sErr+"\n\nCaller: "+sCaller);
    fnIsDisabled(false);
    return
  }else{
    try{
      var oHTTP=new ActiveXObject("Msxml2.XMLHTTP.3.0");
      if(window.returnValue)oHTTP.open("POST","http://"+top.location.hostname+"/assets/scripts/common/update/log_error.asp"+location.search,false);
      else oHTTP.open("POST","http://"+top.location.hostname+"/assets/scripts/common/update/log_error.asp?token="+top.token,false);
      oHTTP.send("<log error='"+escape(sErr)+"' file='"+location.pathname+"' caller='"+escape(sCaller)+"'/>");
      if(oHTTP.responseTEXT.indexOf("@pass")!=-1)var bLodged=true;else var bLodged=false
    }catch(e){
    }finally{
      fnIsDisabled(false);
      if(bSilent)return;
      if(!bFatal||window.returnValue){
        if(bLodged){
          if(oErr.parseError&&oErr.parseError.reason)alert("Unable to load a file required to display this page.\n\nMYCT Support Services has been notified of this fact. \nPlease clear your browser cache, refresh and try again. \nIf the problem persists, please contact support.");
          else alert("An error has occured.\n\nMYCT Support Services has been notified of this fact. \nPlease clear your browser cache, refresh and try again. \nIf the problem persists, please contact support.")
        }else{
          if(oErr.parseError&&oErr.parseError.reason)alert("Unable to load a file required to display this page.\n\nPlease clear your browser cache, refresh and try again. \nIf the problem persists, please contact support.");
          else alert("An error has occured.\n\nPlease clear your browser cache, refresh and try again. \nIf the problem persists, please contact support.")
        }
      }else location.replace("/assets/htm/fatal_error.htm")
    }
  }
}
  
function context_menu(){
  //event.returnValue=false
}

function on_control_select(){
  event.cancelBubble=true
}

function fnOnload(){
  try{
    if(typeof(top.fraPaneBar)!="undefined"&&typeof(top.fraPaneBar.document.all[ "pageTitle" ])!="undefined"){
      top.fraPaneBar.document.all[ "pageTitle" ].innerHTML=top.fraTopic.document.title;
      window.status=""
    }
    if(typeof(tblHeader)=="object"){
      with(tblHeader){
        ondblclick=onmousedown=onmouseup=onmouseover=onmouseout=onclick=onselectstart=process_button
      }
    }
    if(typeof(divCopyright)=="object"){
      with(divCopyright){
        ondblclick=onmousedown=onmouseup=onmouseover=onmouseout=onclick=onselectstart=process_button
      }
    }
    if(top.location.host.indexOf("localhost")==-1)document.oncontextmenu=context_menu;
    document.onselectstart=context_menu;
    if(typeof(iAuth_Level)!="undefined"&&iAuth_Level<3){
      document.body.style.backgroundPosition="center";
      document.body.style.backgroundImage="url(/graphics/readonly.gif)";
      document.body.style.backgroundRepeat="no-repeat";
      
      
      var oElements=document.body.getElementsByTagName("INPUT");
      var iLength=oElements.length;
      for(var i=0;i<iLength;i++)oElements[ i ].readOnly=true;
      var oElements=document.body.getElementsByTagName("TEXTAREA");
      var iLength=oElements.length;
      for(var i=0;i<iLength;i++)oElements[ i ].readOnly=true;
      if(document.all.rowButtons)document.all.rowButtons.disabled=true;
      if(document.all.footButtons)document.all.footButtons.disabled=true
    }else{
      var oElements=document.body.getElementsByTagName("INPUT");
      var iLength=oElements.length;
      for(var i=0;i<iLength;i++)oElements[ i ].attachEvent("onselectstart",on_control_select);
      var oElements=document.body.getElementsByTagName("TEXTAREA");
      var iLength=oElements.length;
      for(var i=0;i<iLength;i++)oElements[ i ].attachEvent("onselectstart",on_control_select)
    }
    
    if(!window.returnValue){
      var oDate=new Date();
      top.lastRequest=oDate.toLocaleString()
    }
    if(typeof(fnPageLoad)=="function")fnPageLoad()
  }catch(e){
    fnLogError(null,e,false)
  }
}

function fnUnload(){
  if(typeof(lnkSave)=="undefined")return;
  if(String(window.location.href).indexOf("new_user")!=-1)return;
  if(lnkSave.style.display=="block"&&top.bAutoSave)fnSave(false);
  else if(lnkSave.style.display=="block"&&!top.bAutoSave){
    if(window.confirm("You have made changes to this page that have not been saved!\nDo you want these changes saved? If yes, select 'OK'\n\nTo continue without saving changes, select 'Cancel'"))fnSave(false)
  }
}

window.onerror=fnPopError;
window.onload=fnOnload;
window.onbeforeunload=fnUnload;

