﻿ // JScript 文件 脚本文件夹//作者:炮灰向前冲
//2008-7-15

    function isObject(obj){
        if (obj != null && typeof(obj) != "undefined")
            return true;
        else
            return false;
    }
    
    function focusFirstElement(formName){
        var form = document.forms[formName];
        if (!isObject(form) || form.tagName != "FORM")
            return;
            
        var elements = form.elements;
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].type == 'text' && !elements[i].disabled) {
                elements[i].focus();
                break;
            }
        }
    }
    
    function fillNumbericOptions(start, end, val){
        var str = "";
        for (var i=start; i<=end; i++){
            str += "<option value='" + i + "'" ;
            if (i == val)
                str += " selected";
            str += " >" + i + "</option>";
        }

        document.write (str);
    }
    
    function fillOptions(data, val){
        var str = "";
        for (var i=0; i<data.length; i++){
            
            str += "<option value='" + data[i][0] + "'" ;
            if (data[i][0] == val)
                str += " selected";
            str += " >" + data[i][1] + "</option>";
            
        }
        
        document.write (str);
    }
    
    function fillQuestionOptions(val){
       fillOptions(hintQuestionList, val);
    }
    
    function fillIDTypeOptions(val){
       fillOptions(IDCardTypeList, val);
    }
    
    function fillSecureOptions(val){
        
       fillOptions(updateSecureList, val);
    }
    
    function getHintQuestion(val){
        if (val == "")
            return val;
            
        for (var i=0; i<hintQuestionList.length; i++){
            if (hintQuestionList[i][0] != "" && hintQuestionList[i][0] == val)
                return hintQuestionList[i][1];
        }
    }
    
    function getUpdateSecure(val){
        if (val == "")
            return val;
            
        for (var i=0; i<updateSecureList.length; i++){
            if (updateSecureList[i][0] != "" && updateSecureList[i][0] == val)
                return updateSecureList[i][1];
        }
    }
    
    function getIDCardType(val){
        if (val == "")
            return val;
            
        for (var i=0; i<IDCardTypeList.length; i++){
            if (IDCardTypeList[i][0] != "" && IDCardTypeList[i][0] == val)
                return IDCardTypeList[i][1];
        }
    }
    
    function getCountry(val){
        if (val == "")
            return val;
        
        for (var i=0; i<countryList.length; i++){
            if (countryList[i][0] != "" && countryList[i][0] == val)
                return countryList[i][1];
        }
    }
    
    function hideSelectForm(){
        var opts = document.getElementsByTagName("SELECT");
        if (opts == null || typeof(opts) == "undefined")
            return ;
            
        for (var i=0; i<opts.length; i++){
            opts[i].style.visibility = "hidden";
        }
    }
    
    function showSelectForm(){
        var opts = document.getElementsByTagName("SELECT");
        if (opts == null || typeof(opts) == "undefined")
            return ;
            
        for (var i=0; i<opts.length; i++){
            
            opts[i].style.visibility = "visible";
        }
    }
    
    function createBgDiv(id){
        if (!isObject(id))
            id = "backgroundDiv";
           
        offHeight = window.screen.height;
        var div = document.createElement("DIV");
        div.id = id;
        div.style.left = 0;
        div.style.top = 0;
        //div.style.width=document.body.scrollWidth;
		div.style.width="100%"
       // div.style.height = document.body.scrollHeight;
	    div.style.height = parent.document.body.scrollHeight;
	    //div.style.left=event.clientX+document.body.scrollLeft;  
        //div.style.top=event.clientY+document.body.scrollTop;  
        div.style.position = "absolute";
        div.style.display = "";
        div.style.zIndex = "999";
        //div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
        div.style.backgroundColor="#2A4A6B";
        document.body.appendChild(div);
        hideSelectForm();
        
        fadeBg(10, id);
        
        return div;
    }
    
    function fadeBg(index, str){
        var obj = document.getElementById(str);
		    if (isObject(obj))
       // obj.style.filter = "alpha(Opacity=" + index + ")";
         obj.style.filter = "alpha(Opacity=50)";
     //   if (index < 50)
       //     window.setTimeout("fadeBg(" + (index+5) + ", '" + str + "')", 10);
        
    }
function showConfirmMsg1(divm){
                                if (!isObject(document.getElementById("logoutDiv")))
                                        createBgDiv("logoutDiv");
                                      
                                    var infoDiv = document.getElementById(divm);
                                    
                                    //infoDiv.innerHTML = generateConfirmLogoutMsg();
                                    
                                    with(infoDiv.style){
                                       zIndex = 1000; 
                                        position = "absolute"; 
                                       width = "300px";
                                      //  top = (document.body.offsetHeight-150)/2 + document.body.scrollTop; 
                                       //left = (document.body.offsetWidth-400)/2;
                                        border = "1px #4372A5 solid"; 
                                       padding = "10px"; 
                                       //backgroundColor = "#ffffff"; 
                                       // filter = "Alpha(Opacity=90)";
                                       display = "block";
                                   }
                                    
                            }

                            
                            function cancelLogout(divm){
                                var aa = document.getElementById("logoutDiv");
                                var infoDiv = document.getElementById(divm);
                                    infoDiv.style.display = "none";
                                
                                if (isObject(aa))
                                    document.body.removeChild(aa);     
                                
                                showSelectForm();
                           }
                               