function globError(){
 return true;
}

window.onerror = globError;

function DoTool(NewValue,instance) {
  if(NewValue != '-1'){
    document.me.elements['SubmitToolID'].value=NewValue;
    document.me.elements['xSubmitType'].value='Tool';
    if(instance != null) document.me.elements['xSubmit'].value=instance;
    document.me.submit();
  }
}

function DoAction(NewValue,RowID) {
  if(NewValue != '-1'){
    if (NewValue.indexOf(";")==-1){
      document.me.elements['SubmitTID'].value=NewValue;    
      if (RowID != null) {
        document.me.elements['xSubmit'].value=RowID;
      }
      document.me.submit();
    }else { 
      var SelectedUID=0;
      document.me.elements['SubmitTID'].value=NewValue.substring(1,NewValue.indexOf(";"));                 
      for (var i=0;i<document.me.elements.length;i++){
        var e=document.me.elements[i];
        if (e.name == 'SelUID')
          if (e.checked) SelectedUID=SelectedUID+1;         
      }
      if((NewValue.substring(NewValue.indexOf(";")+1))=='1')
        if(SelectedUID==0){
          alert('Please select one record!');
          return;
        }
      if((NewValue.substring(NewValue.indexOf(";")+1))=='2')
        if(SelectedUID>1){
          alert('Only one record allowed to be selected for this operation!');
          return;
        }
      document.me.submit();
    }
  }
}

function DoFolder(NewValue,ToolID) {
  if(NewValue != ''){
    document.me.elements['SubmitFolderID'].value=NewValue.substring(NewValue.lastIndexOf(";")+1);
    if(ToolID != null){
      document.me.elements['SubmitToolID'].value=ToolID;
      document.me.elements['xSubmitType'].value='Tool';
    }
    document.me.submit();
  }
}

function DoSubmit() {
  document.me.elements['xSubmitType'].value='Confirm';  
  document.me.elements['xSubmit'].value='1';  
  document.me.submit();
}

function DoTypeSubmit(submittype) {
  document.me.elements['xSubmitType'].value='Confirm';  
  document.me.elements['xSubmit'].value='1';  
  document.me.elements['SubmitType'].value=submittype;  
  document.me.submit();
}

function DoCancel() {
  document.me.elements['xSubmitType'].value='Confirm';  
  document.me.elements['xSubmit'].value='0';  
  document.me.submit();
}

function DoAlter(ParamName,NewValue,NoSubmit) {
  if(NewValue != -1){
    document.me.elements[ParamName].value=NewValue;
     if (ParamName=='SortAction') {document.me.elements['xSubmitType'].value='SortAction';}
    document.me.elements['SubmitTID'].value='0'; 
    if (NoSubmit != 'Y')
      document.me.submit();
  }
}

function DoMessage(NewValue,IsCancel) {
  if(NewValue != '-1'){  
    document.me.elements['xSubmitType'].value='Message';  
    document.me.elements['xSubmit'].value=NewValue;  
    document.me.submit();
  }
}

function DoXSubmit(NewType,NewValue,IsCancel) {
  document.me.elements['xSubmitType'].value=NewType;  
  document.me.elements['xSubmit'].value=NewValue;  
  document.me.submit();
}

function ExDoXSubmit(NewType,NewValue,ToolID) {
  if(NewValue != '-1'){  
    document.me.elements['xSubmitType'].value=NewType;  
    document.me.elements['xSubmit'].value=NewValue;  
    document.me.elements['SubmitToolID'].value=ToolID;  
    document.me.submit();
  }
}

function DoComxSubmit(NewValue,ToolID,InstanceID) {
  if(NewValue != '-1'){  
    document.me.elements['xSubmitType'].value='GoComm';  
    document.me.elements['xSubmit'].value=NewValue;  
    document.me.elements['SubmitToolID'].value=ToolID;  
    document.me.elements['SubmitInstance'].value=InstanceID;  
    document.me.submit();
  }
}

function DoDirect(NewParam) {
  if(NewParam != '')
    top.location = URL + "?" + NewParam  
  else
    top.location = URL;  
}

function popFeedbackForm() 
{
   var URL="/asp/_feedback/newfeedback.asp?sessionID=" + document.me.elements['SessionID'].value;
   var feedback=window.open(URL,"feedback","width=520,height=400,resizable=yes,status=no");
}

function OnSubmitCheck(me)
{ 
  if (eval(document.me.elements['submitredir'])){
   if (document.me.elements['submitredir'].value!=''){
     document.me.action=document.me.elements['submitredir'].value
   }
 }

 if(document.me.elements['pagetimestamp'].value==''){
  var xTS=new Date();
  document.me.elements['pagetimestamp'].value=xTS.getTime();
 } 

  if(document.me.elements['xSubmitType'].value==''){
     if(window.DoCheck != null)
        if (DoCheck()==false)
          return false;
    document.me.elements['xSubmitType'].value='Confirm';  
    document.me.elements['xSubmit'].value='1'; 
  }

  return true;
}

function print_content(){
  window.open('/default.asp?vid=-8','newWin','');
}

function helpme(community,mode,helptextID,styleID,cbh){
  var url=""
 
  if (mode == 0){
    url = "/_help/showhelp.asp?community=" + community + "&mode=" + mode + "&helptextID=" + helptextID + "&styleID=" + styleID ;
    window.open(url,"showhelp","location=no,scrollbars=yes,resize=no,status=no,width=350,height=400");
  }else{
    url = "/_help/showhelp.asp?community=" + community + "&mode=" + mode + "&helptextID=" + helptextID + "&styleID=" + styleID + "&cbh=" + cbh;
    document.location=url;
  }
}

function GoSite(SiteURL){
  document.location.href= SiteURL + '?actionid=31';
}

function vConnect(theURL){
  vConnURL=""
  if (document.images) {
   if (theURL!=""){
    var spos = theURL.lastIndexOf("/") + 1
    vConnURL = theURL.substring(spos)
    document.images["vConn1"].src=theURL
   } 
  }
}

function vc_imgloaded(){
  var validvconn = 0
  if (document.images) {
    if (document.images["vConn1"].src!=""){
      var imgsrc = document.images["vConn1"].src
      var spos = imgsrc.lastIndexOf("/") + 1
      var theURL = imgsrc.substring(spos)
      window.status = 'vConnect checking response for '+theURL
	
      if (theURL=="vconn.gif"){
        validvconn = 1
        vConnURL=""
        window.status = 'vConnect initialized'
      }
	
      if (theURL=="onerror.gif"){
        validvconn = 10
        window.status = 'vConnect FALSE for '+ vConnURL
      }

      if (vConnURL!="") {
        if (vConnURL.substring(0,3)=="IM_"){
          msgalert_action(validvconn)
        }else{
          ASyncDone(document.images["vConn1"].src,true);
        }
      }
    }
  }
}

function vc_imgerror(){
 if (document.images) {
  document.images["vConn1"].src=location.protocol+'//'+location.hostname+'/api/vconn/onerror.gif'
 }
}

function chk4msg(){
  var ms
  var Today = new Date();
  ms = Today.getMilliseconds();
  var chkit = 'vConnect("/api/vconn/msgalert/IM_'+ms+'")'
  setTimeout(chkit,6000);
}

function Dont(){
//do nothing
}

function msgalert_action(vconnstatus){
  if (vconnstatus==10){
     window.status = ""
     setTimeout('chk4msg()',8000);
  } else {
    window.status = "New Message Waiting!"
    DoMsg();
    setTimeout('chk4msg()',6000);
  }
}

function DoMsg(NewValue,IsCancel) {
   var IsImgFlashing=1
   var tH=window.screen.availHeight;
   var tW=window.screen.availWidth;
   var tParam="left=" + tW + ",top=" + tH + ",width=1,height=1,resizable=no,status=no,menubar=no,titlebar=no,toolbar=no";
   var sessionid=document.me.elements['SessionID'].value; 
   ML_window=window.open(location.protocol+"//"+location.hostname+"/api/vconn/IM_init.asp?mlsessionID="+sessionid,"ML_"+sessionid,tParam);
   ML_window.focus();
}


function ASyncCall(url,message,errormessage,redirect){
  asyncMessage=message;
  asyncErrorMessage=errormessage;
  asyncRedirect=redirect;

  var Today = new Date();
  var ms = Today.getMilliseconds();
  asyncURL=url+'&ms='+ms;
  vConnect(asyncURL);
}

function ASyncDone(asyncsrc,done){
  if(asyncsrc.indexOf(asyncURL)<0) return;

  if(done){
   if(asyncMessage!='') alert(asyncMessage);
  }else{
   if(asyncErrorMessage!='') alert(asyncErrorMessage);
   window.status = vConnURL;
  }
  asyncURL="";
  asyncMessage="";
  asyncErrorMessage="";
  if(asyncRedirect!=null && asyncRedirect!='') document.location=asyncRedirect;
}

 
