﻿/********************************************
Copyright@2007 Snailsoft All rights reserved.
********************************************/
var tipTimeout;

var Snailsoft = {
    Version : "1.0.0021",
    Copyright : "Copyright 2007 Snailsoft All rights reserved.",
    Script : {
        Alert: function(str){
            window.alert(str);
        },
        
        AlertAndRedirect: function(str,redir){
            window.alert(str);
            window.location = redir;
        },
        
        AlertAndClose: function(str){
            window.alert(str);
            window.opener = null;
            window.open('','_parent','');
            window.close();
        },
        
        ShowTipWindow: function(tip,second){
            if(document.readyState!="complete") return;  
            var w = $("tipWindow");
            if(w != null) return;
            
            var tw = document.createElement("div");
            tw.id = "tipWindow";
            tw.className = "tip_window";
            tw.innerHTML = "<img src='/images/warn.gif' align='left'>&nbsp;&nbsp;";
            tw.innerHTML += tip;
            document.body.appendChild(tw);
            
            w = $("tipWindow");
            
            if(second>0)
            {
                tipTimeout = window.setTimeout(Snailsoft.Script.HideTipWindow,second*1000);
            }
            w.focus();
            w.attachEvent("onblur",Snailsoft.Script.HideTipWindow);
        },
        
        HideTipWindow: function(){
            var tw = $("tipWindow");
            if(tw == null) return;
            
            tw.detachEvent("onblur",Snailsoft.Script.HideTipWindow);
            window.clearTimeout(tipTimeout);
            document.body.removeChild(tw);
        },
    
        GetErrorInfo: function(errorCode){
            for(var i=0;i<GlobalErrors.length;i++)
            {
                if(GlobalErrors[i].ErrorCode == errorCode)
                    return "错误"+ GlobalErrors[i].ErrorCode + " : " + GlobalErrors[i].ErrorMessage ;
            }
            return "错误"+ errorCode;
        }
    }
    
}

function $(element) {
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
}

function ApplicationError(errorCode,errorMessage) {
    this.ErrorCode = errorCode;
    this.ErrorMessage = errorMessage;
}


